How to use the @zendeskgarden/container-utilities.composeEventHandlers function in @zendeskgarden/container-utilities

To help you get started, we’ve selected a few @zendeskgarden/container-utilities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zendeskgarden / react-containers / packages / tooltip / src / useTooltip.ts View on Github external
const getTriggerProps = (
    { tabIndex = 0, onMouseEnter, onMouseLeave, onFocus, onBlur, onKeyDown, ...other } = {} as any
  ) => {
    return {
      tabIndex,
      onMouseEnter: composeEventHandlers(onMouseEnter, () => openTooltip()),
      onMouseLeave: composeEventHandlers(onMouseLeave, () => closeTooltip()),
      onFocus: composeEventHandlers(onFocus, () => openTooltip()),
      // Close menu immediately when blurred
      onBlur: composeEventHandlers(onBlur, () => closeTooltip(0)),
      onKeyDown: composeEventHandlers(onKeyDown, (event: KeyboardEvent) => {
        if (event.keyCode === KEY_CODES.ESCAPE && visibility) {
          closeTooltip(0);
        }
      }),
      'aria-describedby': _id,
      'data-garden-container-id': 'containers.tooltip',
      'data-garden-container-version': PACKAGE_VERSION,
      ...other
    };
  };
github zendeskgarden / react-components / packages / forms / src / elements / Range.js View on Github external
useEffect(() => {
    updateBackgroundWidthFromInput(rangeRef.current);
  }, [rangeRef, updateBackgroundWidthFromInput]);

  return (
     {
            updateBackgroundWidthFromInput(event.target);
          })
        },
        { isDescribed: true }
      )}
    />
  );
});
github zendeskgarden / react-containers / packages / modal / src / useModal.ts View on Github external
const getBackdropProps = ({ onClick, ...other } = {} as any) => {
    return {
      onClick: composeEventHandlers(onClick, (event: MouseEvent) => {
        closeModal(event);
      }),
      'data-garden-container-id': 'containers.modal',
      'data-garden-container-version': PACKAGE_VERSION,
      ...other
    };
  };
github zendeskgarden / react-components / packages / forms / src / fields / other / FauxInput.js View on Github external
({ onMouseEnter, onMouseLeave, onFocus, onBlur, ...props }, ref) => {
    const [isHovered, setIsHovered] = useState(false);
    const [isFocused, setIsFocused] = useState(false);

    const onMouseEnterHandler = composeEventHandlers(onMouseEnter, () => {
      setIsHovered(true);
    });

    const onMouseLeaveHandler = composeEventHandlers(onMouseLeave, () => {
      setIsHovered(false);
    });

    const onFocusHandler = composeEventHandlers(onFocus, () => {
      setIsFocused(true);
    });

    const onBlurHandler = composeEventHandlers(onBlur, () => {
      setIsFocused(false);
    });

    return (
github zendeskgarden / react-components / packages / forms / src / fields / Toggle.js View on Github external
getLabelProps: ({ onMouseUp, ...other }) =>
      getLabelProps({ onMouseUp: composeEventHandlers(onMouseUp, onFocusMouseDown), ...other }),
    ...fieldCtx
github zendeskgarden / react-containers / packages / keyboardfocus / src / useKeyboardFocus.ts View on Github external
tabIndex = 0,
      onBlur,
      onFocus,
      onMouseDown,
      onPointerDown,
      onTouchStart,
      ...props
    } = {} as any
  ) => {
    return {
      tabIndex,
      onBlur: composeEventHandlers(onBlur, onKeyboardFocusBlur),
      onFocus: composeEventHandlers(onFocus, onKeyboardFocus),
      onMouseDown: composeEventHandlers(onMouseDown, onKeyboardFocusPointerDown),
      onPointerDown: composeEventHandlers(onPointerDown, onKeyboardFocusPointerDown),
      onTouchStart: composeEventHandlers(onTouchStart, onKeyboardFocusPointerDown),
      'data-garden-container-id': 'containers.keyboardfocus',
      'data-garden-container-version': PACKAGE_VERSION,
      ...props
    };
  };
github zendeskgarden / react-containers / packages / keyboardfocus / src / useKeyboardFocus.ts View on Github external
{
      tabIndex = 0,
      onBlur,
      onFocus,
      onMouseDown,
      onPointerDown,
      onTouchStart,
      ...props
    } = {} as any
  ) => {
    return {
      tabIndex,
      onBlur: composeEventHandlers(onBlur, onKeyboardFocusBlur),
      onFocus: composeEventHandlers(onFocus, onKeyboardFocus),
      onMouseDown: composeEventHandlers(onMouseDown, onKeyboardFocusPointerDown),
      onPointerDown: composeEventHandlers(onPointerDown, onKeyboardFocusPointerDown),
      onTouchStart: composeEventHandlers(onTouchStart, onKeyboardFocusPointerDown),
      'data-garden-container-id': 'containers.keyboardfocus',
      'data-garden-container-version': PACKAGE_VERSION,
      ...props
    };
  };
github zendeskgarden / react-containers / packages / focusjail / src / useFocusJail.ts View on Github external
const getContainerProps = ({ onKeyDown, ...other } = {} as any) => {
    return {
      onKeyDown: composeEventHandlers(onKeyDown, (event: KeyboardEvent) => {
        if (event.keyCode !== KEY_CODES.TAB) {
          return;
        }
        validateContainerRef();

        const tabbableNodes = getTabbableNodes();

        if (
          event.shiftKey &&
          (event.target === tabbableNodes.firstItem || event.target === currentRef)
        ) {
          focusElement(tabbableNodes.lastItem);
          event.preventDefault();
        }

        if (!event.shiftKey && event.target === tabbableNodes.lastItem) {
github zendeskgarden / react-components / packages / forms / src / fields / Radio.js View on Github external
getLabelProps: ({ onMouseUp, ...other }) =>
      getLabelProps({ onMouseUp: composeEventHandlers(onMouseUp, onFocusMouseDown), ...other }),
    ...fieldCtx
github zendeskgarden / react-containers / packages / keyboardfocus / src / useKeyboardFocus.ts View on Github external
const getFocusProps = (
    {
      tabIndex = 0,
      onBlur,
      onFocus,
      onMouseDown,
      onPointerDown,
      onTouchStart,
      ...props
    } = {} as any
  ) => {
    return {
      tabIndex,
      onBlur: composeEventHandlers(onBlur, onKeyboardFocusBlur),
      onFocus: composeEventHandlers(onFocus, onKeyboardFocus),
      onMouseDown: composeEventHandlers(onMouseDown, onKeyboardFocusPointerDown),
      onPointerDown: composeEventHandlers(onPointerDown, onKeyboardFocusPointerDown),
      onTouchStart: composeEventHandlers(onTouchStart, onKeyboardFocusPointerDown),
      'data-garden-container-id': 'containers.keyboardfocus',
      'data-garden-container-version': PACKAGE_VERSION,
      ...props
    };
  };