Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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");
}
(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]
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);
}
});
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";
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);
}
});
};
}
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 {
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);
}
});
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);
}
});
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);
}
});