How to use the reakit-utils/warning.warning 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 / Dialog / __utils / useFocusOnShow.ts View on Github external
useUpdateEffect(() => {
    const dialog = dialogRef.current;

    warning(
      Boolean(shouldFocus && !dialog),
      "[reakit/Dialog]",
      "Can't set initial focus on dialog because `ref` wasn't passed to component.",
      "See https://reakit.io/docs/dialog"
    );

    // If there're nested open dialogs, let them handle focus
    if (
      !shouldFocus ||
      !dialog ||
      nestedDialogs.find(child =>
        Boolean(child.current && !child.current.hidden)
      )
    ) {
      return;
    }
github reakit / reakit / packages / reakit / src / Dialog / __utils / useFocusTrap.ts View on Github external
React.useEffect(() => {
    if (!shouldTrap) return undefined;
    const portal = portalRef.current;

    if (!portal) {
      warning(
        true,
        "[reakit/Dialog]",
        "Can't trap focus within modal dialog because either `ref` wasn't passed to component or the component wasn't rendered within a portal",
        "See https://reakit.io/docs/dialog"
      );

      return undefined;
    }

    if (!beforeElement.current) {
      beforeElement.current = document.createElement("div");
      beforeElement.current.className = focusTrapClassName;
      beforeElement.current.tabIndex = 0;
      beforeElement.current.style.position = "fixed";
      beforeElement.current.setAttribute("aria-hidden", "true");
    }
github reakit / reakit / packages / reakit / src / Dialog / Dialog.tsx View on Github external
(event: React.KeyboardEvent) => {
        if (event.key === "Escape" && options.hideOnEsc) {
          if (!options.hide) {
            warning(
              true,
              "[reakit/Dialog]",
              "`hideOnEsc` prop is truthy, but `hide` prop wasn't provided.",
              "See https://reakit.io/docs/dialog"
            );
            return;
          }
          event.stopPropagation();
          options.hide();
        }
      },
      [options.hideOnEsc, options.hide]
github reakit / reakit / packages / reakit / src / Menu / Menu.tsx View on Github external
useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Menu]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/menu"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / utils / Provider.ts View on Github external
import { warning } from "reakit-utils/warning";

warning(
  true,
  "[reakit/Provider]",
  "Importing `Provider` from `reakit/utils` or `reakit/utils/Provider` is deprecated.",
  "Please, import `Provider` from `reakit` or `reakit/Provider` instead"
);

export * from "../Provider";
github reakit / reakit / packages / reakit / src / Toolbar / Toolbar.tsx View on Github external
useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Toolbar]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/toolbar"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Rover / RoverState.ts View on Github external
};
      }
      return {
        ...state,
        stops: [
          ...stops.slice(0, indexToInsertAt),
          { id, ref },
          ...stops.slice(indexToInsertAt)
        ]
      };
    }
    case "unregister": {
      const { id } = action;
      const nextStops = stops.filter(stop => stop.id !== id);
      if (nextStops.length === stops.length) {
        warning(true, "[reakit/RoverState]", `${id} stop is not registered`);
        return state;
      }

      return {
        ...state,
        stops: nextStops,
        unstable_pastId: pastId && pastId === id ? null : pastId,
        currentId: currentId && currentId === id ? null : currentId
      };
    }
    case "move": {
      const { id, silent } = action;
      const nextMoves = silent ? moves : moves + 1;

      if (id === null) {
        return {
github reakit / reakit / packages / reakit / src / Menu / MenuBar.tsx View on Github external
useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] &&
        !props["aria-labelledby"] &&
        props.role !== "menubar",
      "[reakit/Menu]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/menu"
    );

    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Tab / TabList.tsx View on Github external
useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/TabList]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/tab"
    );
    return useCreateElement(type, props, children);
  }
});
github reakit / reakit / packages / reakit / src / Popover / Popover.ts View on Github external
useCreateElement: (type, props, children) => {
    warning(
      !props["aria-label"] && !props["aria-labelledby"],
      "[reakit/Popover]",
      "You should provide either `aria-label` or `aria-labelledby` props.",
      "See https://reakit.io/docs/popover"
    );
    return useCreateElement(type, props, children);
  }
});