lecom-ui 4.1.9 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +5 -0
  2. package/dist/_virtual/index.js +7 -0
  3. package/dist/components/Accordion/Accordion.js +40 -37
  4. package/dist/components/Button/Button.js +10 -9
  5. package/dist/components/Button/CustomButton.js +6 -5
  6. package/dist/components/Card/Card.js +7 -6
  7. package/dist/components/Checkbox/Checkbox.js +35 -30
  8. package/dist/components/CustomIcon/Icons/CadastroFacil.js +15 -5
  9. package/dist/components/CustomIcon/Icons/LogoLecom.js +15 -12
  10. package/dist/components/CustomIcon/Icons/LogoLecomBrand.js +8 -5
  11. package/dist/components/CustomIcon/Icons/ModoTeste.js +13 -5
  12. package/dist/components/CustomIcon/Icons/Rpa.js +17 -5
  13. package/dist/components/DataTable/DataTable.js +33 -158
  14. package/dist/components/Dialog/Dialog.js +40 -31
  15. package/dist/components/DropdownMenu/DropdownMenu.js +55 -46
  16. package/dist/components/Header/Header.js +51 -35
  17. package/dist/components/Header/HelpMenu.js +52 -41
  18. package/dist/components/Header/ImgBrand.js +5 -8
  19. package/dist/components/Header/ModulesMenu.js +63 -50
  20. package/dist/components/Header/SocialMenu.js +5 -6
  21. package/dist/components/Header/UserMenu.js +81 -51
  22. package/dist/components/Input/Input.js +11 -2
  23. package/dist/components/Layout/Layout.js +62 -45
  24. package/dist/components/Notification/Notification.js +9 -8
  25. package/dist/components/Notification/NotificationBase.js +5 -5
  26. package/dist/components/Notification/NotificationCallout.js +33 -27
  27. package/dist/components/Notification/NotificationCloseButton.js +4 -3
  28. package/dist/components/Notification/NotificationContent.js +24 -18
  29. package/dist/components/Notification/NotificationIcon.js +9 -6
  30. package/dist/components/Notification/NotificationInline.js +23 -20
  31. package/dist/components/Notification/NotificationToast.js +28 -25
  32. package/dist/components/Notification/useNotificationToast.js +0 -1
  33. package/dist/components/Popover/Popover.js +8 -7
  34. package/dist/components/ScrollArea/ScrollArea.js +18 -15
  35. package/dist/components/Select/Select.js +63 -54
  36. package/dist/components/Separator/Separator.js +5 -4
  37. package/dist/components/Sheet/Sheet.js +35 -26
  38. package/dist/components/Sidebar/Sidebar.js +112 -95
  39. package/dist/components/Skeleton/Skeleton.js +2 -2
  40. package/dist/components/Table/Table.js +15 -26
  41. package/dist/components/Tag/Tag.js +6 -5
  42. package/dist/components/Tooltip/Tooltip.js +17 -15
  43. package/dist/components/Typography/Typography.js +6 -7
  44. package/dist/hooks/use-mobile.js +1 -1
  45. package/dist/i18n/index.js +4 -53
  46. package/dist/i18n/locales/en_us.js +4 -3
  47. package/dist/i18n/locales/es_es.js +4 -3
  48. package/dist/i18n/locales/index.js +4 -4
  49. package/dist/i18n/locales/pt_br.js +4 -3
  50. package/dist/index.d.ts +108 -304
  51. package/dist/index.js +1 -12
  52. package/dist/lib/utils.js +2 -2
  53. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +806 -0
  54. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +726 -0
  55. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +347 -0
  56. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +154 -0
  57. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +136 -0
  58. package/dist/node_modules/@radix-ui/number/dist/index.js +6 -0
  59. package/dist/node_modules/@radix-ui/primitive/dist/index.js +11 -0
  60. package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +303 -0
  61. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
  62. package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +157 -0
  63. package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +144 -0
  64. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +68 -0
  65. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +39 -0
  66. package/dist/node_modules/@radix-ui/react-context/dist/index.js +79 -0
  67. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +319 -0
  68. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +11 -0
  69. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +211 -0
  70. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +265 -0
  71. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +29 -0
  72. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +207 -0
  73. package/dist/node_modules/@radix-ui/react-id/dist/index.js +15 -0
  74. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +831 -0
  75. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +296 -0
  76. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +278 -0
  77. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
  78. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +130 -0
  79. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +41 -0
  80. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +220 -0
  81. package/dist/node_modules/@radix-ui/react-scroll-area/dist/index.js +718 -0
  82. package/dist/node_modules/@radix-ui/react-select/dist/index.js +1143 -0
  83. package/dist/node_modules/@radix-ui/react-separator/dist/index.js +30 -0
  84. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +81 -0
  85. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +476 -0
  86. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +12 -0
  87. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +46 -0
  88. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +18 -0
  89. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +7 -0
  90. package/dist/node_modules/@radix-ui/react-use-previous/dist/index.js +15 -0
  91. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +40 -0
  92. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +35 -0
  93. package/dist/node_modules/@tanstack/react-table/build/lib/index.js +74 -0
  94. package/dist/node_modules/@tanstack/table-core/build/lib/index.js +3023 -0
  95. package/dist/node_modules/aria-hidden/dist/es2015/index.js +136 -0
  96. package/dist/node_modules/class-variance-authority/dist/index.js +44 -0
  97. package/dist/node_modules/clsx/dist/clsx.js +3 -0
  98. package/dist/node_modules/get-nonce/dist/es2015/index.js +8 -0
  99. package/dist/node_modules/hex-color-opacity/lib/index.js +22 -0
  100. package/dist/node_modules/i18next/dist/esm/i18next.js +2228 -0
  101. package/dist/node_modules/lucide-react/dist/esm/Icon.js +44 -0
  102. package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +26 -0
  103. package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +20 -0
  104. package/dist/node_modules/lucide-react/dist/esm/icons/check.js +13 -0
  105. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +15 -0
  106. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +15 -0
  107. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +13 -0
  108. package/dist/node_modules/lucide-react/dist/esm/icons/circle-alert.js +17 -0
  109. package/dist/node_modules/lucide-react/dist/esm/icons/circle-check.js +16 -0
  110. package/dist/node_modules/lucide-react/dist/esm/icons/circle-help.js +17 -0
  111. package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +15 -0
  112. package/dist/node_modules/lucide-react/dist/esm/icons/info.js +17 -0
  113. package/dist/node_modules/lucide-react/dist/esm/icons/menu.js +17 -0
  114. package/dist/node_modules/lucide-react/dist/esm/icons/message-square.js +15 -0
  115. package/dist/node_modules/lucide-react/dist/esm/icons/minus.js +13 -0
  116. package/dist/node_modules/lucide-react/dist/esm/icons/panel-left.js +16 -0
  117. package/dist/node_modules/lucide-react/dist/esm/icons/triangle-alert.js +23 -0
  118. package/dist/node_modules/lucide-react/dist/esm/icons/user.js +16 -0
  119. package/dist/node_modules/lucide-react/dist/esm/icons/x.js +16 -0
  120. package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +13 -0
  121. package/dist/node_modules/react-i18next/dist/es/context.js +18 -0
  122. package/dist/node_modules/react-i18next/dist/es/defaults.js +21 -0
  123. package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +7 -0
  124. package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +12 -0
  125. package/dist/node_modules/react-i18next/dist/es/unescape.js +27 -0
  126. package/dist/node_modules/react-i18next/dist/es/useTranslation.js +112 -0
  127. package/dist/node_modules/react-i18next/dist/es/utils.js +63 -0
  128. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +9 -0
  129. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +160 -0
  130. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +38 -0
  131. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +21 -0
  132. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +109 -0
  133. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
  134. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
  135. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +56 -0
  136. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +10 -0
  137. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +31 -0
  138. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +19 -0
  139. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +25 -0
  140. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +51 -0
  141. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +2493 -0
  142. package/dist/node_modules/tslib/tslib.es6.js +56 -0
  143. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +24 -0
  144. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +48 -0
  145. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +42 -0
  146. package/dist/node_modules/use-color-luminance/index.es.js +105 -0
  147. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +21 -0
  148. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +77 -0
  149. package/dist/plugin/typographies.ts +146 -152
  150. package/dist/style.min.css +1 -1
  151. package/dist/utils/cookie.js +9 -6
  152. package/package.json +11 -3
@@ -0,0 +1,130 @@
1
+ import * as React from 'react';
2
+ import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
3
+ import { useLayoutEffect as useLayoutEffect2 } from '../../react-use-layout-effect/dist/index.js';
4
+
5
+ function useStateMachine(initialState, machine) {
6
+ return React.useReducer((state, event) => {
7
+ const nextState = machine[state][event];
8
+ return nextState ?? state;
9
+ }, initialState);
10
+ }
11
+
12
+ // packages/react/presence/src/Presence.tsx
13
+ var Presence = (props) => {
14
+ const { present, children } = props;
15
+ const presence = usePresence(present);
16
+ const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
17
+ const ref = useComposedRefs(presence.ref, getElementRef(child));
18
+ const forceMount = typeof children === "function";
19
+ return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
20
+ };
21
+ Presence.displayName = "Presence";
22
+ function usePresence(present) {
23
+ const [node, setNode] = React.useState();
24
+ const stylesRef = React.useRef({});
25
+ const prevPresentRef = React.useRef(present);
26
+ const prevAnimationNameRef = React.useRef("none");
27
+ const initialState = present ? "mounted" : "unmounted";
28
+ const [state, send] = useStateMachine(initialState, {
29
+ mounted: {
30
+ UNMOUNT: "unmounted",
31
+ ANIMATION_OUT: "unmountSuspended"
32
+ },
33
+ unmountSuspended: {
34
+ MOUNT: "mounted",
35
+ ANIMATION_END: "unmounted"
36
+ },
37
+ unmounted: {
38
+ MOUNT: "mounted"
39
+ }
40
+ });
41
+ React.useEffect(() => {
42
+ const currentAnimationName = getAnimationName(stylesRef.current);
43
+ prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
44
+ }, [state]);
45
+ useLayoutEffect2(() => {
46
+ const styles = stylesRef.current;
47
+ const wasPresent = prevPresentRef.current;
48
+ const hasPresentChanged = wasPresent !== present;
49
+ if (hasPresentChanged) {
50
+ const prevAnimationName = prevAnimationNameRef.current;
51
+ const currentAnimationName = getAnimationName(styles);
52
+ if (present) {
53
+ send("MOUNT");
54
+ } else if (currentAnimationName === "none" || styles?.display === "none") {
55
+ send("UNMOUNT");
56
+ } else {
57
+ const isAnimating = prevAnimationName !== currentAnimationName;
58
+ if (wasPresent && isAnimating) {
59
+ send("ANIMATION_OUT");
60
+ } else {
61
+ send("UNMOUNT");
62
+ }
63
+ }
64
+ prevPresentRef.current = present;
65
+ }
66
+ }, [present, send]);
67
+ useLayoutEffect2(() => {
68
+ if (node) {
69
+ let timeoutId;
70
+ const ownerWindow = node.ownerDocument.defaultView ?? window;
71
+ const handleAnimationEnd = (event) => {
72
+ const currentAnimationName = getAnimationName(stylesRef.current);
73
+ const isCurrentAnimation = currentAnimationName.includes(event.animationName);
74
+ if (event.target === node && isCurrentAnimation) {
75
+ send("ANIMATION_END");
76
+ if (!prevPresentRef.current) {
77
+ const currentFillMode = node.style.animationFillMode;
78
+ node.style.animationFillMode = "forwards";
79
+ timeoutId = ownerWindow.setTimeout(() => {
80
+ if (node.style.animationFillMode === "forwards") {
81
+ node.style.animationFillMode = currentFillMode;
82
+ }
83
+ });
84
+ }
85
+ }
86
+ };
87
+ const handleAnimationStart = (event) => {
88
+ if (event.target === node) {
89
+ prevAnimationNameRef.current = getAnimationName(stylesRef.current);
90
+ }
91
+ };
92
+ node.addEventListener("animationstart", handleAnimationStart);
93
+ node.addEventListener("animationcancel", handleAnimationEnd);
94
+ node.addEventListener("animationend", handleAnimationEnd);
95
+ return () => {
96
+ ownerWindow.clearTimeout(timeoutId);
97
+ node.removeEventListener("animationstart", handleAnimationStart);
98
+ node.removeEventListener("animationcancel", handleAnimationEnd);
99
+ node.removeEventListener("animationend", handleAnimationEnd);
100
+ };
101
+ } else {
102
+ send("ANIMATION_END");
103
+ }
104
+ }, [node, send]);
105
+ return {
106
+ isPresent: ["mounted", "unmountSuspended"].includes(state),
107
+ ref: React.useCallback((node2) => {
108
+ if (node2) stylesRef.current = getComputedStyle(node2);
109
+ setNode(node2);
110
+ }, [])
111
+ };
112
+ }
113
+ function getAnimationName(styles) {
114
+ return styles?.animationName || "none";
115
+ }
116
+ function getElementRef(element) {
117
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
118
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
119
+ if (mayWarn) {
120
+ return element.ref;
121
+ }
122
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
123
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
124
+ if (mayWarn) {
125
+ return element.props.ref;
126
+ }
127
+ return element.props.ref || element.ref;
128
+ }
129
+
130
+ export { Presence };
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+ import * as ReactDOM from 'react-dom';
3
+ import { Slot } from '../../react-slot/dist/index.js';
4
+ import { jsx } from 'react/jsx-runtime';
5
+
6
+ // packages/react/primitive/src/primitive.tsx
7
+ var NODES = [
8
+ "a",
9
+ "button",
10
+ "div",
11
+ "form",
12
+ "h2",
13
+ "h3",
14
+ "img",
15
+ "input",
16
+ "label",
17
+ "li",
18
+ "nav",
19
+ "ol",
20
+ "p",
21
+ "span",
22
+ "svg",
23
+ "ul"
24
+ ];
25
+ var Primitive = NODES.reduce((primitive, node) => {
26
+ const Node = React.forwardRef((props, forwardedRef) => {
27
+ const { asChild, ...primitiveProps } = props;
28
+ const Comp = asChild ? Slot : node;
29
+ if (typeof window !== "undefined") {
30
+ window[Symbol.for("radix-ui")] = true;
31
+ }
32
+ return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
33
+ });
34
+ Node.displayName = `Primitive.${node}`;
35
+ return { ...primitive, [node]: Node };
36
+ }, {});
37
+ function dispatchDiscreteCustomEvent(target, event) {
38
+ if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
39
+ }
40
+
41
+ export { Primitive, dispatchDiscreteCustomEvent };
@@ -0,0 +1,220 @@
1
+ import * as React from 'react';
2
+ import { composeEventHandlers } from '../../primitive/dist/index.js';
3
+ import { createCollection } from '../../react-collection/dist/index.js';
4
+ import { useComposedRefs } from '../../react-compose-refs/dist/index.js';
5
+ import { createContextScope } from '../../react-context/dist/index.js';
6
+ import { useId } from '../../react-id/dist/index.js';
7
+ import { Primitive } from '../../react-primitive/dist/index.js';
8
+ import { useCallbackRef } from '../../react-use-callback-ref/dist/index.js';
9
+ import { useControllableState } from '../../react-use-controllable-state/dist/index.js';
10
+ import { useDirection } from '../../react-direction/dist/index.js';
11
+ import { jsx } from 'react/jsx-runtime';
12
+
13
+ var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
14
+ var EVENT_OPTIONS = { bubbles: false, cancelable: true };
15
+ var GROUP_NAME = "RovingFocusGroup";
16
+ var [Collection, useCollection, createCollectionScope] = createCollection(GROUP_NAME);
17
+ var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
18
+ GROUP_NAME,
19
+ [createCollectionScope]
20
+ );
21
+ var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
22
+ var RovingFocusGroup = React.forwardRef(
23
+ (props, forwardedRef) => {
24
+ return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
25
+ }
26
+ );
27
+ RovingFocusGroup.displayName = GROUP_NAME;
28
+ var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
29
+ const {
30
+ __scopeRovingFocusGroup,
31
+ orientation,
32
+ loop = false,
33
+ dir,
34
+ currentTabStopId: currentTabStopIdProp,
35
+ defaultCurrentTabStopId,
36
+ onCurrentTabStopIdChange,
37
+ onEntryFocus,
38
+ preventScrollOnEntryFocus = false,
39
+ ...groupProps
40
+ } = props;
41
+ const ref = React.useRef(null);
42
+ const composedRefs = useComposedRefs(forwardedRef, ref);
43
+ const direction = useDirection(dir);
44
+ const [currentTabStopId = null, setCurrentTabStopId] = useControllableState({
45
+ prop: currentTabStopIdProp,
46
+ defaultProp: defaultCurrentTabStopId,
47
+ onChange: onCurrentTabStopIdChange
48
+ });
49
+ const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
50
+ const handleEntryFocus = useCallbackRef(onEntryFocus);
51
+ const getItems = useCollection(__scopeRovingFocusGroup);
52
+ const isClickFocusRef = React.useRef(false);
53
+ const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
54
+ React.useEffect(() => {
55
+ const node = ref.current;
56
+ if (node) {
57
+ node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
58
+ return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
59
+ }
60
+ }, [handleEntryFocus]);
61
+ return /* @__PURE__ */ jsx(
62
+ RovingFocusProvider,
63
+ {
64
+ scope: __scopeRovingFocusGroup,
65
+ orientation,
66
+ dir: direction,
67
+ loop,
68
+ currentTabStopId,
69
+ onItemFocus: React.useCallback(
70
+ (tabStopId) => setCurrentTabStopId(tabStopId),
71
+ [setCurrentTabStopId]
72
+ ),
73
+ onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
74
+ onFocusableItemAdd: React.useCallback(
75
+ () => setFocusableItemsCount((prevCount) => prevCount + 1),
76
+ []
77
+ ),
78
+ onFocusableItemRemove: React.useCallback(
79
+ () => setFocusableItemsCount((prevCount) => prevCount - 1),
80
+ []
81
+ ),
82
+ children: /* @__PURE__ */ jsx(
83
+ Primitive.div,
84
+ {
85
+ tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
86
+ "data-orientation": orientation,
87
+ ...groupProps,
88
+ ref: composedRefs,
89
+ style: { outline: "none", ...props.style },
90
+ onMouseDown: composeEventHandlers(props.onMouseDown, () => {
91
+ isClickFocusRef.current = true;
92
+ }),
93
+ onFocus: composeEventHandlers(props.onFocus, (event) => {
94
+ const isKeyboardFocus = !isClickFocusRef.current;
95
+ if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
96
+ const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
97
+ event.currentTarget.dispatchEvent(entryFocusEvent);
98
+ if (!entryFocusEvent.defaultPrevented) {
99
+ const items = getItems().filter((item) => item.focusable);
100
+ const activeItem = items.find((item) => item.active);
101
+ const currentItem = items.find((item) => item.id === currentTabStopId);
102
+ const candidateItems = [activeItem, currentItem, ...items].filter(
103
+ Boolean
104
+ );
105
+ const candidateNodes = candidateItems.map((item) => item.ref.current);
106
+ focusFirst(candidateNodes, preventScrollOnEntryFocus);
107
+ }
108
+ }
109
+ isClickFocusRef.current = false;
110
+ }),
111
+ onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
112
+ }
113
+ )
114
+ }
115
+ );
116
+ });
117
+ var ITEM_NAME = "RovingFocusGroupItem";
118
+ var RovingFocusGroupItem = React.forwardRef(
119
+ (props, forwardedRef) => {
120
+ const {
121
+ __scopeRovingFocusGroup,
122
+ focusable = true,
123
+ active = false,
124
+ tabStopId,
125
+ ...itemProps
126
+ } = props;
127
+ const autoId = useId();
128
+ const id = tabStopId || autoId;
129
+ const context = useRovingFocusContext(ITEM_NAME, __scopeRovingFocusGroup);
130
+ const isCurrentTabStop = context.currentTabStopId === id;
131
+ const getItems = useCollection(__scopeRovingFocusGroup);
132
+ const { onFocusableItemAdd, onFocusableItemRemove } = context;
133
+ React.useEffect(() => {
134
+ if (focusable) {
135
+ onFocusableItemAdd();
136
+ return () => onFocusableItemRemove();
137
+ }
138
+ }, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
139
+ return /* @__PURE__ */ jsx(
140
+ Collection.ItemSlot,
141
+ {
142
+ scope: __scopeRovingFocusGroup,
143
+ id,
144
+ focusable,
145
+ active,
146
+ children: /* @__PURE__ */ jsx(
147
+ Primitive.span,
148
+ {
149
+ tabIndex: isCurrentTabStop ? 0 : -1,
150
+ "data-orientation": context.orientation,
151
+ ...itemProps,
152
+ ref: forwardedRef,
153
+ onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
154
+ if (!focusable) event.preventDefault();
155
+ else context.onItemFocus(id);
156
+ }),
157
+ onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
158
+ onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
159
+ if (event.key === "Tab" && event.shiftKey) {
160
+ context.onItemShiftTab();
161
+ return;
162
+ }
163
+ if (event.target !== event.currentTarget) return;
164
+ const focusIntent = getFocusIntent(event, context.orientation, context.dir);
165
+ if (focusIntent !== void 0) {
166
+ if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
167
+ event.preventDefault();
168
+ const items = getItems().filter((item) => item.focusable);
169
+ let candidateNodes = items.map((item) => item.ref.current);
170
+ if (focusIntent === "last") candidateNodes.reverse();
171
+ else if (focusIntent === "prev" || focusIntent === "next") {
172
+ if (focusIntent === "prev") candidateNodes.reverse();
173
+ const currentIndex = candidateNodes.indexOf(event.currentTarget);
174
+ candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
175
+ }
176
+ setTimeout(() => focusFirst(candidateNodes));
177
+ }
178
+ })
179
+ }
180
+ )
181
+ }
182
+ );
183
+ }
184
+ );
185
+ RovingFocusGroupItem.displayName = ITEM_NAME;
186
+ var MAP_KEY_TO_FOCUS_INTENT = {
187
+ ArrowLeft: "prev",
188
+ ArrowUp: "prev",
189
+ ArrowRight: "next",
190
+ ArrowDown: "next",
191
+ PageUp: "first",
192
+ Home: "first",
193
+ PageDown: "last",
194
+ End: "last"
195
+ };
196
+ function getDirectionAwareKey(key, dir) {
197
+ if (dir !== "rtl") return key;
198
+ return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
199
+ }
200
+ function getFocusIntent(event, orientation, dir) {
201
+ const key = getDirectionAwareKey(event.key, dir);
202
+ if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
203
+ if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
204
+ return MAP_KEY_TO_FOCUS_INTENT[key];
205
+ }
206
+ function focusFirst(candidates, preventScroll = false) {
207
+ const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
208
+ for (const candidate of candidates) {
209
+ if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
210
+ candidate.focus({ preventScroll });
211
+ if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
212
+ }
213
+ }
214
+ function wrapArray(array, startIndex) {
215
+ return array.map((_, index) => array[(startIndex + index) % array.length]);
216
+ }
217
+ var Root = RovingFocusGroup;
218
+ var Item = RovingFocusGroupItem;
219
+
220
+ export { Item, Root, RovingFocusGroup, RovingFocusGroupItem, createRovingFocusGroupScope };