How to use the reakit-utils/useAllCallbacks.useAllCallbacks function in reakit-utils

To help you get started, we’ve selected a few reakit-utils 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 reakit / reakit / packages / reakit / src / Menu / MenuItem.tsx View on Github external
// Move focus onto menu after blurring
        if (
          document.activeElement === document.body &&
          menuRef.current &&
          !isTouchDevice()
        ) {
          menuRef.current.focus();
        }
      },
      [menuRef]
    );

    return {
      role: "menuitem",
      onMouseOver: useAllCallbacks(onMouseOver, htmlOnMouseOver),
      onMouseOut: useAllCallbacks(onMouseOut, htmlOnMouseOut),
      ...htmlProps
    };
  }
});
github reakit / reakit / packages / reakit / src / Tooltip / TooltipReference.ts View on Github external
{
      ref: htmlRef,
      onFocus: htmlOnFocus,
      onBlur: htmlOnBlur,
      onMouseEnter: htmlOnMouseEnter,
      onMouseLeave: htmlOnMouseLeave,
      ...htmlProps
    }
  ) {
    return {
      ref: mergeRefs(options.unstable_referenceRef, htmlRef),
      tabIndex: 0,
      onFocus: useAllCallbacks(options.show, htmlOnFocus),
      onBlur: useAllCallbacks(options.hide, htmlOnBlur),
      onMouseEnter: useAllCallbacks(options.show, htmlOnMouseEnter),
      onMouseLeave: useAllCallbacks(options.hide, htmlOnMouseLeave),
      "aria-describedby": options.baseId,
      ...htmlProps
    };
  }
});
github reakit / reakit / packages / reakit / src / Tooltip / TooltipReference.ts View on Github external
useProps(
    options,
    {
      ref: htmlRef,
      onFocus: htmlOnFocus,
      onBlur: htmlOnBlur,
      onMouseEnter: htmlOnMouseEnter,
      onMouseLeave: htmlOnMouseLeave,
      ...htmlProps
    }
  ) {
    return {
      ref: mergeRefs(options.unstable_referenceRef, htmlRef),
      tabIndex: 0,
      onFocus: useAllCallbacks(options.show, htmlOnFocus),
      onBlur: useAllCallbacks(options.hide, htmlOnBlur),
      onMouseEnter: useAllCallbacks(options.show, htmlOnMouseEnter),
      onMouseLeave: useAllCallbacks(options.hide, htmlOnMouseLeave),
      "aria-describedby": options.baseId,
      ...htmlProps
    };
  }
});
github reakit / reakit / packages / reakit / src / Form / FormSubmitButton.ts View on Github external
useProps(options, { onClick: htmlOnClick, ...htmlProps }) {
    const onClick = React.useCallback(() => {
      window.requestAnimationFrame(() => {
        const input = getFirstInvalidInput(options.baseId);
        if (input) {
          input.focus();
          if ("select" in input) {
            input.select();
          }
        }
      });
    }, [options.baseId]);

    return {
      type: "submit",
      onClick: useAllCallbacks(onClick, htmlOnClick),
      ...htmlProps
    };
  }
});
github reakit / reakit / packages / reakit / src / Form / FormRadio.ts View on Github external
options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    const onBlur = React.useCallback(() => {
      options.blur(options.name);
    }, [options.blur, options.name]);

    const onFocus = React.useCallback(() => {
      options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    return {
      name: formatInputName(options.name),
      onChange: useAllCallbacks(onChange, htmlOnChange),
      onBlur: useAllCallbacks(onBlur, htmlOnBlur),
      onFocus: useAllCallbacks(onFocus, htmlOnFocus),
      ...htmlProps
    };
  }
}) as >(
github reakit / reakit / packages / reakit / src / Form / FormRadio.ts View on Github external
const onChange = React.useCallback(() => {
      options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    const onBlur = React.useCallback(() => {
      options.blur(options.name);
    }, [options.blur, options.name]);

    const onFocus = React.useCallback(() => {
      options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    return {
      name: formatInputName(options.name),
      onChange: useAllCallbacks(onChange, htmlOnChange),
      onBlur: useAllCallbacks(onBlur, htmlOnBlur),
      onFocus: useAllCallbacks(onFocus, htmlOnFocus),
      ...htmlProps
    };
  }
}) as >(
github reakit / reakit / packages / reakit / src / Form / FormPushButton.ts View on Github external
const input = document.querySelector(selector);
        if (input) {
          input.focus();
        }
      });
    }, [
      options.push,
      options.name,
      options.value,
      options.values,
      options.baseId
    ]);

    return {
      id: getPushButtonId(options.name, options.baseId),
      onClick: useAllCallbacks(onClick, htmlOnClick),
      ...htmlProps
    };
  }
}) as >(
github reakit / reakit / packages / reakit / src / Dialog / Dialog.tsx View on Github external
"See https://reakit.io/docs/dialog"
            );
            return;
          }
          event.stopPropagation();
          options.hide();
        }
      },
      [options.hideOnEsc, options.hide]
    );

    return {
      ref: mergeRefs(dialog, htmlRef),
      role: "dialog",
      tabIndex: -1,
      onKeyDown: useAllCallbacks(onKeyDown, htmlOnKeyDown),
      unstable_wrap: usePipe(wrap, portalWrap, htmlWrap),
      "aria-modal": options.modal ? true : undefined,
      "data-dialog": true,
      ...htmlProps
    };
  }
});
github reakit / reakit / packages / reakit / src / Form / FormRadio.ts View on Github external
) {
    const onChange = React.useCallback(() => {
      options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    const onBlur = React.useCallback(() => {
      options.blur(options.name);
    }, [options.blur, options.name]);

    const onFocus = React.useCallback(() => {
      options.update(options.name, options.value);
    }, [options.update, options.name, options.value]);

    return {
      name: formatInputName(options.name),
      onChange: useAllCallbacks(onChange, htmlOnChange),
      onBlur: useAllCallbacks(onBlur, htmlOnBlur),
      onFocus: useAllCallbacks(onFocus, htmlOnFocus),
      ...htmlProps
    };
  }
}) as >(
github reakit / reakit / packages / reakit / src / Menu / MenuDisclosure.ts View on Github external
options.show();
      } else {
        options.toggle();
      }
    }, [
      hasParent,
      parentIsMenuBar,
      hasShownOnFocus,
      options.show,
      options.toggle
    ]);

    return {
      ref: mergeRefs(ref, htmlRef),
      "aria-haspopup": "menu",
      onClick: useAllCallbacks(onClick, htmlOnClick),
      onKeyDown: useAllCallbacks(onKeyDown, htmlOnKeyDown),
      onFocus: useAllCallbacks(onFocus, htmlOnFocus),
      onMouseOver: useAllCallbacks(onMouseOver, htmlOnMouseOver),
      ...htmlProps
    };
  },