@ariakit/react-core 0.1.3 → 0.1.5
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.
- package/CHANGELOG.md +28 -0
- package/cjs/__chunks/{NYVIJAIX.cjs → 3CPBCP3F.cjs} +2 -2
- package/cjs/__chunks/{FSEBHZVD.cjs → 63KDRM7J.cjs} +4 -4
- package/cjs/__chunks/{WYGT6WVD.cjs → BJ6S3SB5.cjs} +16 -16
- package/cjs/__chunks/{IYRMREW7.cjs → BX3HGZ7I.cjs} +5 -5
- package/cjs/__chunks/{CMHDB7LY.cjs → CP6M4POZ.cjs} +2 -2
- package/cjs/__chunks/{YITIRUCT.cjs → DH774RHH.cjs} +2 -2
- package/cjs/__chunks/{ND6THRTE.cjs → EQUPHBKX.cjs} +4 -4
- package/cjs/__chunks/{RG6JXX7T.cjs → EZLBMRYS.cjs} +13 -13
- package/cjs/__chunks/{H5Z2A5K2.cjs → FJEN5XPE.cjs} +5 -5
- package/cjs/__chunks/{HJTX27PU.cjs → GSMEXLDS.cjs} +43 -22
- package/cjs/__chunks/{KIZFPB5R.cjs → J3TNGZSO.cjs} +5 -5
- package/cjs/__chunks/{5LMWS5O4.cjs → KPYDIKOY.cjs} +3 -3
- package/cjs/__chunks/{IVRU7X3P.cjs → KUXCWMWW.cjs} +9 -1
- package/cjs/__chunks/{XKBGBOWQ.cjs → MWKUZW4E.cjs} +2 -0
- package/cjs/__chunks/{3QEUUQVB.cjs → NKZKDBAR.cjs} +0 -4
- package/cjs/__chunks/OKPDB2ZM.cjs +44 -0
- package/cjs/__chunks/{ABU7PK6G.cjs → PZ72QR7P.cjs} +2 -2
- package/cjs/__chunks/{7HZT2AAH.cjs → SGWCIO3J.cjs} +2 -2
- package/cjs/__chunks/{F6IOE5QT.cjs → TQ3ZXPQL.cjs} +3 -3
- package/cjs/__chunks/{TIVUAJD3.cjs → TZBXRN4U.cjs} +13 -13
- package/cjs/__chunks/{T4TB3AAZ.cjs → UK7WFIG4.cjs} +22 -14
- package/cjs/__chunks/{LH4INSYS.cjs → UYAQKYEJ.cjs} +2 -2
- package/cjs/__chunks/{QRBTWQPI.cjs → YTLECYPS.cjs} +8 -10
- package/cjs/__chunks/{NJHMO3XK.cjs → Z5OM7SNB.cjs} +3 -3
- package/cjs/__chunks/{KWHAB2F2.cjs → ZDO3DQPW.cjs} +1 -2
- package/cjs/__chunks/{3RC6Q4WI.cjs → ZS4MDBUW.cjs} +2 -2
- package/cjs/checkbox/checkbox-store.cjs +3 -3
- package/cjs/checkbox/checkbox.cjs +3 -3
- package/cjs/collection/collection-item.cjs +2 -2
- package/cjs/collection/collection-store.cjs +3 -3
- package/cjs/combobox/combobox-item.cjs +4 -3
- package/cjs/combobox/combobox-popover.cjs +9 -10
- package/cjs/combobox/combobox-store.cjs +12 -12
- package/cjs/combobox/combobox.cjs +20 -8
- package/cjs/composite/composite-container.cjs +3 -3
- package/cjs/composite/composite-item.cjs +4 -3
- package/cjs/composite/composite-overflow-disclosure.cjs +4 -3
- package/cjs/composite/composite-overflow-store.cjs +7 -7
- package/cjs/composite/composite-overflow.cjs +9 -10
- package/cjs/composite/composite-store.cjs +4 -4
- package/cjs/dialog/dialog-store.cjs +4 -4
- package/cjs/dialog/dialog.cjs +8 -9
- package/cjs/dialog/utils/disable-tree-outside.cjs +7 -0
- package/cjs/dialog/utils/disable-tree-outside.d.ts +3 -0
- package/cjs/dialog/utils/use-champion-dialog.cjs +2 -2
- package/cjs/dialog/utils/use-hide-on-interact-outside.cjs +2 -2
- package/cjs/dialog/utils/use-nested-dialogs.cjs +2 -2
- package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
- package/cjs/disclosure/disclosure-store.cjs +3 -3
- package/cjs/form/form-checkbox.cjs +8 -8
- package/cjs/form/form-description.cjs +2 -2
- package/cjs/form/form-error.cjs +2 -2
- package/cjs/form/form-field.cjs +3 -3
- package/cjs/form/form-input.cjs +3 -3
- package/cjs/form/form-label.cjs +2 -2
- package/cjs/form/form-push.cjs +2 -2
- package/cjs/form/form-radio.cjs +7 -7
- package/cjs/form/form-store.cjs +28 -17
- package/cjs/hovercard/hovercard-store.cjs +6 -6
- package/cjs/hovercard/hovercard.cjs +10 -11
- package/cjs/menu/menu-bar-store.cjs +6 -6
- package/cjs/menu/menu-button.cjs +2 -2
- package/cjs/menu/menu-item-checkbox.cjs +10 -10
- package/cjs/menu/menu-item-radio.cjs +8 -8
- package/cjs/menu/menu-item.cjs +5 -5
- package/cjs/menu/menu-list.cjs +3 -3
- package/cjs/menu/menu-store.cjs +14 -14
- package/cjs/menu/menu.cjs +13 -14
- package/cjs/popover/popover-store.cjs +5 -5
- package/cjs/popover/popover.cjs +9 -10
- package/cjs/portal/portal.cjs +2 -2
- package/cjs/radio/radio-store.cjs +7 -7
- package/cjs/radio/radio.cjs +5 -5
- package/cjs/select/select-item.cjs +4 -3
- package/cjs/select/select-popover.cjs +9 -10
- package/cjs/select/select-store.cjs +12 -12
- package/cjs/tab/tab-panel.cjs +5 -5
- package/cjs/tab/tab-store.cjs +9 -9
- package/cjs/tab/tab.cjs +4 -3
- package/cjs/toolbar/toolbar-container.cjs +7 -7
- package/cjs/toolbar/toolbar-input.cjs +5 -4
- package/cjs/toolbar/toolbar-item.cjs +5 -4
- package/cjs/toolbar/toolbar-store.cjs +6 -6
- package/cjs/tooltip/tooltip-store.cjs +7 -7
- package/cjs/tooltip/tooltip.cjs +2 -2
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/cjs/utils/store.cjs +2 -2
- package/dialog/utils/disable-tree-outside/package.json +7 -0
- package/esm/__chunks/{WOX4XCVH.js → 2EEVGFEH.js} +1 -1
- package/esm/__chunks/{56XURSTF.js → 36HCAR3M.js} +1 -1
- package/esm/__chunks/{IACKFX3D.js → 7VB6U7Y2.js} +1 -1
- package/esm/__chunks/{HLAXMBLL.js → ARIIJA3Z.js} +3 -1
- package/esm/__chunks/{RFLPDFU5.js → CDHQAO3X.js} +7 -9
- package/esm/__chunks/{ZVCQYVEV.js → FD7UP2TJ.js} +3 -4
- package/esm/__chunks/{QCGEDLZG.js → GLAECEAR.js} +1 -1
- package/esm/__chunks/{4RNONDN5.js → GM2BWWHD.js} +1 -1
- package/esm/__chunks/{LFCJQX2O.js → GWYHKM6Q.js} +1 -1
- package/esm/__chunks/{EJZ6BVXG.js → IIX2NU6T.js} +22 -14
- package/esm/__chunks/{47TE2UD5.js → JCOAGXR2.js} +2 -2
- package/esm/__chunks/{PAZURDJA.js → JIT55CHU.js} +39 -18
- package/esm/__chunks/{WHN4PCW7.js → JOV72LYK.js} +12 -12
- package/esm/__chunks/{YDNX3N4B.js → KTHONFWV.js} +3 -3
- package/esm/__chunks/{4STD3S2Y.js → LBUPFIVF.js} +2 -2
- package/esm/__chunks/{6DAEYZ43.js → LTH56VDS.js} +3 -3
- package/esm/__chunks/{RSJJ72ZD.js → M6QENKOT.js} +2 -2
- package/esm/__chunks/{HRNQJHNJ.js → MAJ5ZZ2S.js} +1 -1
- package/esm/__chunks/{3OSYJZM5.js → MPZ7PKON.js} +9 -1
- package/esm/__chunks/{OGTE6FGV.js → ND76WTDR.js} +2 -2
- package/esm/__chunks/{XQPXGTBO.js → NY7SYLNQ.js} +1 -1
- package/esm/__chunks/{OJNRBQKS.js → ON2AV7GH.js} +1 -5
- package/esm/__chunks/{CWHDUB4A.js → P4W76ES3.js} +1 -1
- package/esm/__chunks/X3J57OQT.js +44 -0
- package/esm/__chunks/{OXIHLN45.js → YHRHKO5B.js} +1 -1
- package/esm/__chunks/{2EP53RLR.js → ZCEPUYV7.js} +2 -2
- package/esm/checkbox/checkbox-store.js +2 -2
- package/esm/checkbox/checkbox.js +2 -2
- package/esm/collection/collection-item.js +1 -1
- package/esm/collection/collection-store.js +2 -2
- package/esm/combobox/combobox-item.js +3 -2
- package/esm/combobox/combobox-popover.js +8 -9
- package/esm/combobox/combobox-store.js +6 -6
- package/esm/combobox/combobox.js +20 -8
- package/esm/composite/composite-container.js +2 -2
- package/esm/composite/composite-item.js +3 -2
- package/esm/composite/composite-overflow-disclosure.js +3 -2
- package/esm/composite/composite-overflow-store.js +4 -4
- package/esm/composite/composite-overflow.js +8 -9
- package/esm/composite/composite-store.js +3 -3
- package/esm/dialog/dialog-store.js +3 -3
- package/esm/dialog/dialog.js +7 -8
- package/esm/dialog/utils/disable-tree-outside.d.ts +3 -0
- package/esm/dialog/utils/disable-tree-outside.js +7 -0
- package/esm/dialog/utils/use-champion-dialog.js +1 -1
- package/esm/dialog/utils/use-hide-on-interact-outside.js +1 -1
- package/esm/dialog/utils/use-nested-dialogs.js +1 -1
- package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
- package/esm/disclosure/disclosure-store.js +2 -2
- package/esm/form/form-checkbox.js +7 -7
- package/esm/form/form-description.js +1 -1
- package/esm/form/form-error.js +1 -1
- package/esm/form/form-field.js +2 -2
- package/esm/form/form-input.js +2 -2
- package/esm/form/form-label.js +1 -1
- package/esm/form/form-push.js +1 -1
- package/esm/form/form-radio.js +5 -5
- package/esm/form/form-store.js +24 -13
- package/esm/hovercard/hovercard-store.js +5 -5
- package/esm/hovercard/hovercard.js +9 -10
- package/esm/menu/menu-bar-store.js +3 -3
- package/esm/menu/menu-button.js +1 -1
- package/esm/menu/menu-item-checkbox.js +9 -9
- package/esm/menu/menu-item-radio.js +6 -6
- package/esm/menu/menu-item.js +4 -4
- package/esm/menu/menu-list.js +2 -2
- package/esm/menu/menu-store.js +7 -7
- package/esm/menu/menu.js +11 -12
- package/esm/popover/popover-store.js +4 -4
- package/esm/popover/popover.js +8 -9
- package/esm/portal/portal.js +1 -1
- package/esm/radio/radio-store.js +3 -3
- package/esm/radio/radio.js +4 -4
- package/esm/select/select-item.js +3 -2
- package/esm/select/select-popover.js +8 -9
- package/esm/select/select-store.js +6 -6
- package/esm/tab/tab-panel.js +3 -3
- package/esm/tab/tab-store.js +3 -3
- package/esm/tab/tab.js +3 -2
- package/esm/toolbar/toolbar-container.js +5 -5
- package/esm/toolbar/toolbar-input.js +4 -3
- package/esm/toolbar/toolbar-item.js +4 -3
- package/esm/toolbar/toolbar-store.js +3 -3
- package/esm/tooltip/tooltip-store.js +4 -4
- package/esm/tooltip/tooltip.js +1 -1
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/esm/utils/store.js +1 -1
- package/package.json +5 -9
- package/cjs/__chunks/ORRE4SVW.cjs +0 -31
- package/cjs/__chunks/RDNP4FTV.cjs +0 -30
- package/cjs/dialog/utils/disable-pointer-events-outside.cjs +0 -7
- package/cjs/dialog/utils/disable-pointer-events-outside.d.ts +0 -3
- package/cjs/dialog/utils/use-focus-on-child-unmount.cjs +0 -6
- package/cjs/dialog/utils/use-focus-on-child-unmount.d.ts +0 -6
- package/dialog/utils/disable-pointer-events-outside/package.json +0 -7
- package/dialog/utils/use-focus-on-child-unmount/package.json +0 -7
- package/esm/__chunks/547F7FFZ.js +0 -30
- package/esm/__chunks/WO2RXMKK.js +0 -31
- package/esm/dialog/utils/disable-pointer-events-outside.d.ts +0 -3
- package/esm/dialog/utils/disable-pointer-events-outside.js +0 -7
- package/esm/dialog/utils/use-focus-on-child-unmount.d.ts +0 -6
- package/esm/dialog/utils/use-focus-on-child-unmount.js +0 -6
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./P3I4MECH.js";
|
|
4
4
|
import {
|
|
5
5
|
useCollectionItem
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./ON2AV7GH.js";
|
|
7
7
|
import {
|
|
8
8
|
createElement,
|
|
9
9
|
createHook,
|
|
@@ -24,15 +24,13 @@ function getNamedElement(ref, name) {
|
|
|
24
24
|
const element = ref.current;
|
|
25
25
|
if (!element)
|
|
26
26
|
return null;
|
|
27
|
-
if (element.name
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const document = getDocument(element);
|
|
32
|
-
return document.getElementsByName(name)[0];
|
|
33
|
-
}
|
|
27
|
+
if (element.name === name)
|
|
28
|
+
return element;
|
|
29
|
+
if (element.form) {
|
|
30
|
+
return element.form.elements.namedItem(name);
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
const document = getDocument(element);
|
|
33
|
+
return document.getElementsByName(name)[0];
|
|
36
34
|
}
|
|
37
35
|
function useItem(store, name, type) {
|
|
38
36
|
return store.useState(
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useForceUpdate
|
|
3
|
-
useSafeLayoutEffect
|
|
2
|
+
useForceUpdate
|
|
4
3
|
} from "./B7MIN7YT.js";
|
|
5
4
|
|
|
6
5
|
// src/dialog/utils/use-champion-dialog.ts
|
|
7
|
-
import { useCallback } from "react";
|
|
6
|
+
import { useCallback, useEffect } from "react";
|
|
8
7
|
import { getDocument } from "@ariakit/core/utils/dom";
|
|
9
8
|
import { flushSync } from "react-dom";
|
|
10
9
|
function useChampionDialog(attribute, store, enabled) {
|
|
@@ -19,7 +18,7 @@ function useChampionDialog(attribute, store, enabled) {
|
|
|
19
18
|
const id = body.getAttribute(attribute);
|
|
20
19
|
return !id || id === dialog.id;
|
|
21
20
|
}, [updated, store, enabled, attribute]);
|
|
22
|
-
|
|
21
|
+
useEffect(() => {
|
|
23
22
|
const dialog = store.getState().contentElement;
|
|
24
23
|
if (!dialog)
|
|
25
24
|
return;
|
|
@@ -18,8 +18,6 @@ function useNestedDialogs(store, modal) {
|
|
|
18
18
|
const context = useContext(NestedDialogsContext);
|
|
19
19
|
const [openModals, setOpenModals] = useState([]);
|
|
20
20
|
const [nestedDialogs, setNestedDialogs] = useState([]);
|
|
21
|
-
const open = store.useState("open");
|
|
22
|
-
const contentElement = store.useState("contentElement");
|
|
23
21
|
const addDialog = useCallback(
|
|
24
22
|
(dialog) => {
|
|
25
23
|
return chain(
|
|
@@ -34,7 +32,7 @@ function useNestedDialogs(store, modal) {
|
|
|
34
32
|
})()
|
|
35
33
|
);
|
|
36
34
|
},
|
|
37
|
-
[context
|
|
35
|
+
[context]
|
|
38
36
|
);
|
|
39
37
|
const showModal = useCallback(
|
|
40
38
|
(dialog) => {
|
|
@@ -50,22 +48,32 @@ function useNestedDialogs(store, modal) {
|
|
|
50
48
|
})()
|
|
51
49
|
);
|
|
52
50
|
},
|
|
53
|
-
[context
|
|
51
|
+
[context]
|
|
54
52
|
);
|
|
55
53
|
useSafeLayoutEffect(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
return store.sync(
|
|
55
|
+
(state) => {
|
|
56
|
+
if (!state.contentElement)
|
|
57
|
+
return;
|
|
58
|
+
return context.addDialog?.(state.contentElement);
|
|
59
|
+
},
|
|
60
|
+
["contentElement"]
|
|
61
|
+
);
|
|
62
|
+
}, [store, context]);
|
|
60
63
|
useSafeLayoutEffect(() => {
|
|
61
64
|
if (!modal)
|
|
62
65
|
return;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
return store.sync(
|
|
67
|
+
(state) => {
|
|
68
|
+
if (!state.open)
|
|
69
|
+
return;
|
|
70
|
+
if (!state.contentElement)
|
|
71
|
+
return;
|
|
72
|
+
return context.showModal?.(state.contentElement);
|
|
73
|
+
},
|
|
74
|
+
["open", "contentElement"]
|
|
75
|
+
);
|
|
76
|
+
}, [store, modal, context]);
|
|
69
77
|
useEffect(() => {
|
|
70
78
|
return context.store?.syncBatch(
|
|
71
79
|
(state) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
usePopoverStoreOptions,
|
|
3
3
|
usePopoverStoreProps
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./M6QENKOT.js";
|
|
5
5
|
import {
|
|
6
6
|
useStore
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./LTH56VDS.js";
|
|
8
8
|
|
|
9
9
|
// src/hovercard/hovercard-store.ts
|
|
10
10
|
import * as Core from "@ariakit/core/hovercard/hovercard-store";
|
|
@@ -3,16 +3,13 @@ import {
|
|
|
3
3
|
} from "./4U6AOLE4.js";
|
|
4
4
|
import {
|
|
5
5
|
useHideOnInteractOutside
|
|
6
|
-
} from "./
|
|
7
|
-
import {
|
|
8
|
-
useFocusOnChildUnmount
|
|
9
|
-
} from "./WO2RXMKK.js";
|
|
6
|
+
} from "./ARIIJA3Z.js";
|
|
10
7
|
import {
|
|
11
8
|
prependHiddenDismiss
|
|
12
9
|
} from "./PU22SOKH.js";
|
|
13
10
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./
|
|
11
|
+
disableTreeOutside
|
|
12
|
+
} from "./X3J57OQT.js";
|
|
16
13
|
import {
|
|
17
14
|
disableAccessibilityTreeOutside
|
|
18
15
|
} from "./NV7HSBKK.js";
|
|
@@ -21,13 +18,13 @@ import {
|
|
|
21
18
|
} from "./2SVAPVVI.js";
|
|
22
19
|
import {
|
|
23
20
|
usePreventBodyScroll
|
|
24
|
-
} from "./
|
|
21
|
+
} from "./GWYHKM6Q.js";
|
|
25
22
|
import {
|
|
26
23
|
useChampionDialog
|
|
27
|
-
} from "./
|
|
24
|
+
} from "./FD7UP2TJ.js";
|
|
28
25
|
import {
|
|
29
26
|
useNestedDialogs
|
|
30
|
-
} from "./
|
|
27
|
+
} from "./IIX2NU6T.js";
|
|
31
28
|
import {
|
|
32
29
|
HeadingLevel
|
|
33
30
|
} from "./6OMX4H3W.js";
|
|
@@ -41,7 +38,7 @@ import {
|
|
|
41
38
|
} from "./5TGAWEHD.js";
|
|
42
39
|
import {
|
|
43
40
|
usePortal
|
|
44
|
-
} from "./
|
|
41
|
+
} from "./MPZ7PKON.js";
|
|
45
42
|
import {
|
|
46
43
|
useDisclosureContent
|
|
47
44
|
} from "./FFRIGW5T.js";
|
|
@@ -165,13 +162,36 @@ var useDialog = createHook(
|
|
|
165
162
|
(state) => preventBodyScroll && state.mounted
|
|
166
163
|
);
|
|
167
164
|
usePreventBodyScroll(store, shouldPreventBodyScroll);
|
|
168
|
-
useFocusOnChildUnmount(store);
|
|
169
165
|
useHideOnInteractOutside({
|
|
170
166
|
store,
|
|
171
167
|
modal,
|
|
172
168
|
hideOnInteractOutside,
|
|
173
169
|
nestedDialogs
|
|
174
170
|
});
|
|
171
|
+
const shouldRestoreLostFocus = useChampionDialog(
|
|
172
|
+
"data-dialog-restore-lost-focus",
|
|
173
|
+
store,
|
|
174
|
+
open && modal && !openModals.length
|
|
175
|
+
);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (!shouldRestoreLostFocus())
|
|
178
|
+
return;
|
|
179
|
+
let raf = 0;
|
|
180
|
+
const restoreLostFocus = () => {
|
|
181
|
+
const dialog = ref.current;
|
|
182
|
+
raf = requestAnimationFrame(restoreLostFocus);
|
|
183
|
+
if (!dialog)
|
|
184
|
+
return;
|
|
185
|
+
const doc = getDocument(dialog);
|
|
186
|
+
if (!doc.hasFocus())
|
|
187
|
+
return;
|
|
188
|
+
if (doc.activeElement !== doc.body)
|
|
189
|
+
return;
|
|
190
|
+
dialog.focus();
|
|
191
|
+
};
|
|
192
|
+
restoreLostFocus();
|
|
193
|
+
return () => cancelAnimationFrame(raf);
|
|
194
|
+
}, [shouldRestoreLostFocus]);
|
|
175
195
|
const mounted = store.useState("mounted");
|
|
176
196
|
if (isSafariBrowser) {
|
|
177
197
|
useEffect(() => {
|
|
@@ -229,13 +249,11 @@ var useDialog = createHook(
|
|
|
229
249
|
if (modal) {
|
|
230
250
|
return chain(
|
|
231
251
|
disableAccessibilityTreeOutside(element),
|
|
232
|
-
|
|
233
|
-
// events outside of the modal dialog.
|
|
234
|
-
!backdrop ? disablePointerEventsOutside(element) : null
|
|
252
|
+
disableTreeOutside(element)
|
|
235
253
|
);
|
|
236
254
|
}
|
|
237
255
|
return disableAccessibilityTreeOutside(element);
|
|
238
|
-
}, [shouldDisableOutside, portal, portalNode, modal
|
|
256
|
+
}, [shouldDisableOutside, portal, portalNode, modal]);
|
|
239
257
|
const mayAutoFocusOnShow = !!autoFocusOnShow;
|
|
240
258
|
const autoFocusOnShowProp = useBooleanEvent(autoFocusOnShow);
|
|
241
259
|
useEffect(() => {
|
|
@@ -371,9 +389,12 @@ var useDialog = createHook(
|
|
|
371
389
|
(element) => /* @__PURE__ */ jsx(HeadingLevel, { level: modal ? 1 : void 0, children: element }),
|
|
372
390
|
[modal]
|
|
373
391
|
);
|
|
374
|
-
const shouldFocusTrap =
|
|
375
|
-
|
|
376
|
-
)
|
|
392
|
+
const [shouldFocusTrap, setShouldFocusTrap] = useState(false);
|
|
393
|
+
const hasOpenModals = !!openModals.length;
|
|
394
|
+
useSafeLayoutEffect(() => {
|
|
395
|
+
const value = open && modal && !hasOpenModals && !("inert" in HTMLElement.prototype);
|
|
396
|
+
setShouldFocusTrap(value);
|
|
397
|
+
}, [modal, open, hasOpenModals]);
|
|
377
398
|
props = useFocusTrapRegion({ ...props, enabled: shouldFocusTrap });
|
|
378
399
|
const hiddenProp = props.hidden;
|
|
379
400
|
props = useWrapElement(
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./SAVDGYCC.js";
|
|
4
4
|
import {
|
|
5
5
|
useCollectionItem
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./ON2AV7GH.js";
|
|
7
7
|
import {
|
|
8
8
|
focusSilently,
|
|
9
9
|
getEnabledItem,
|
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
createHook,
|
|
20
20
|
createMemoComponent
|
|
21
21
|
} from "./JE5NWDDX.js";
|
|
22
|
+
import {
|
|
23
|
+
useStoreState
|
|
24
|
+
} from "./LTH56VDS.js";
|
|
22
25
|
import {
|
|
23
26
|
useBooleanEvent,
|
|
24
27
|
useEvent,
|
|
@@ -36,7 +39,6 @@ import {
|
|
|
36
39
|
isTextField
|
|
37
40
|
} from "@ariakit/core/utils/dom";
|
|
38
41
|
import { isPortalEvent, isSelfTarget } from "@ariakit/core/utils/events";
|
|
39
|
-
import { invariant } from "@ariakit/core/utils/misc";
|
|
40
42
|
import { jsx } from "react/jsx-runtime";
|
|
41
43
|
function isEditableElement(element) {
|
|
42
44
|
if (element.isContentEditable)
|
|
@@ -144,14 +146,10 @@ var useCompositeItem = createHook(
|
|
|
144
146
|
}) => {
|
|
145
147
|
const context = useContext(CompositeContext);
|
|
146
148
|
store = store || context;
|
|
147
|
-
invariant(
|
|
148
|
-
store,
|
|
149
|
-
process.env.NODE_ENV !== "production" && "CompositeItem must be wrapped in a Composite component"
|
|
150
|
-
);
|
|
151
149
|
const id = useId(props.id);
|
|
152
150
|
const ref = useRef(null);
|
|
153
151
|
const row = useContext(CompositeRowContext);
|
|
154
|
-
const rowId = store
|
|
152
|
+
const rowId = useStoreState(store, (state) => {
|
|
155
153
|
if (rowIdProp)
|
|
156
154
|
return rowIdProp;
|
|
157
155
|
if (!row?.baseElement)
|
|
@@ -274,7 +272,8 @@ var useCompositeItem = createHook(
|
|
|
274
272
|
}
|
|
275
273
|
}
|
|
276
274
|
});
|
|
277
|
-
const baseElement =
|
|
275
|
+
const baseElement = useStoreState(
|
|
276
|
+
store,
|
|
278
277
|
(state) => state.baseElement || void 0
|
|
279
278
|
);
|
|
280
279
|
const providerValue = useMemo(
|
|
@@ -286,9 +285,9 @@ var useCompositeItem = createHook(
|
|
|
286
285
|
(element) => /* @__PURE__ */ jsx(CompositeItemContext.Provider, { value: providerValue, children: element }),
|
|
287
286
|
[providerValue]
|
|
288
287
|
);
|
|
289
|
-
const isActiveItem = store
|
|
288
|
+
const isActiveItem = useStoreState(store, (state) => state.activeId === id);
|
|
290
289
|
const role = useRole(ref, props);
|
|
291
|
-
const virtualFocus = store
|
|
290
|
+
const virtualFocus = useStoreState(store, "virtualFocus");
|
|
292
291
|
let ariaSelected;
|
|
293
292
|
if (isActiveItem) {
|
|
294
293
|
if (requiresAriaSelected(role)) {
|
|
@@ -297,7 +296,8 @@ var useCompositeItem = createHook(
|
|
|
297
296
|
ariaSelected = true;
|
|
298
297
|
}
|
|
299
298
|
}
|
|
300
|
-
const shouldTabIndex =
|
|
299
|
+
const shouldTabIndex = useStoreState(
|
|
300
|
+
store,
|
|
301
301
|
(state) => !state.virtualFocus && isActiveItem
|
|
302
302
|
);
|
|
303
303
|
props = {
|
|
@@ -306,7 +306,7 @@ var useCompositeItem = createHook(
|
|
|
306
306
|
"data-active-item": isActiveItem ? "" : void 0,
|
|
307
307
|
...props,
|
|
308
308
|
ref: useForkRef(ref, props.ref),
|
|
309
|
-
tabIndex: shouldTabIndex ? props.tabIndex : -1,
|
|
309
|
+
tabIndex: shouldTabIndex !== false ? props.tabIndex : -1,
|
|
310
310
|
onFocus,
|
|
311
311
|
onBlurCapture,
|
|
312
312
|
onKeyDown
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./DRSUYUM5.js";
|
|
11
11
|
import {
|
|
12
12
|
useCompositeItem
|
|
13
|
-
} from "./
|
|
13
|
+
} from "./JOV72LYK.js";
|
|
14
14
|
import {
|
|
15
15
|
createElement,
|
|
16
16
|
createHook,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
} from "./JE5NWDDX.js";
|
|
19
19
|
import {
|
|
20
20
|
useStoreState
|
|
21
|
-
} from "./
|
|
21
|
+
} from "./LTH56VDS.js";
|
|
22
22
|
import {
|
|
23
23
|
useBooleanEvent,
|
|
24
24
|
useEvent
|
|
@@ -42,7 +42,7 @@ var useMenuItem = createHook(
|
|
|
42
42
|
store = store || menuContext || menuBarContext;
|
|
43
43
|
invariant(
|
|
44
44
|
store,
|
|
45
|
-
process.env.NODE_ENV !== "production" && "MenuItem must be wrapped in a MenuList,
|
|
45
|
+
process.env.NODE_ENV !== "production" && "MenuItem must be wrapped in a MenuList, Menu or MenuBar component"
|
|
46
46
|
);
|
|
47
47
|
const onClickProp = props.onClick;
|
|
48
48
|
const hideOnClickProp = useBooleanEvent(hideOnClick);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./6I2PARRP.js";
|
|
4
4
|
import {
|
|
5
5
|
useCompositeItem
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./JOV72LYK.js";
|
|
7
7
|
import {
|
|
8
8
|
createElement,
|
|
9
9
|
createHook,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./JE5NWDDX.js";
|
|
12
12
|
import {
|
|
13
13
|
useStoreState
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./LTH56VDS.js";
|
|
15
15
|
import {
|
|
16
16
|
useEvent,
|
|
17
17
|
useForkRef,
|
|
@@ -60,12 +60,12 @@ function useStoreProps(store, props, key, setKey) {
|
|
|
60
60
|
}
|
|
61
61
|
function useStore(createStore) {
|
|
62
62
|
const store = useLazyValue(createStore);
|
|
63
|
-
useSafeLayoutEffect(() => store.init(), []);
|
|
63
|
+
useSafeLayoutEffect(() => store.init(), [store]);
|
|
64
64
|
const useState = useCallback(
|
|
65
65
|
(keyOrSelector) => useStoreState(store, keyOrSelector),
|
|
66
|
-
[]
|
|
66
|
+
[store]
|
|
67
67
|
);
|
|
68
|
-
return useMemo(() => ({ ...store, useState }), []);
|
|
68
|
+
return useMemo(() => ({ ...store, useState }), [store, useState]);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export {
|
|
@@ -122,7 +122,15 @@ var usePortal = createHook(
|
|
|
122
122
|
if (!portal)
|
|
123
123
|
return element;
|
|
124
124
|
if (!portalNode) {
|
|
125
|
-
return /* @__PURE__ */ jsx(
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
"span",
|
|
127
|
+
{
|
|
128
|
+
ref: refProp,
|
|
129
|
+
id: props.id,
|
|
130
|
+
style: { position: "fixed" },
|
|
131
|
+
hidden: true
|
|
132
|
+
}
|
|
133
|
+
);
|
|
126
134
|
}
|
|
127
135
|
element = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
128
136
|
preserveTabOrder && portalNode && /* @__PURE__ */ jsx(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useDisclosureStoreOptions,
|
|
3
3
|
useDisclosureStoreProps
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./YHRHKO5B.js";
|
|
5
5
|
import {
|
|
6
6
|
useStore
|
|
7
|
-
} from "./
|
|
7
|
+
} from "./LTH56VDS.js";
|
|
8
8
|
|
|
9
9
|
// src/dialog/dialog-store.ts
|
|
10
10
|
import * as Core from "@ariakit/core/dialog/dialog-store";
|
|
@@ -13,15 +13,11 @@ import {
|
|
|
13
13
|
|
|
14
14
|
// src/collection/collection-item.ts
|
|
15
15
|
import { useCallback, useContext, useRef } from "react";
|
|
16
|
-
import { identity
|
|
16
|
+
import { identity } from "@ariakit/core/utils/misc";
|
|
17
17
|
var useCollectionItem = createHook(
|
|
18
18
|
({ store, shouldRegisterItem = true, getItem = identity, ...props }) => {
|
|
19
19
|
const context = useContext(CollectionContext);
|
|
20
20
|
store = store || context;
|
|
21
|
-
invariant(
|
|
22
|
-
store,
|
|
23
|
-
process.env.NODE_ENV !== "production" && "CollectionItem must be wrapped in a Collection component"
|
|
24
|
-
);
|
|
25
21
|
const id = useId(props.id);
|
|
26
22
|
const unrenderItem = useRef();
|
|
27
23
|
const ref = useCallback(
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
walkTreeOutside
|
|
3
|
+
} from "./HVXLVRRR.js";
|
|
4
|
+
|
|
5
|
+
// src/dialog/utils/disable-tree-outside.ts
|
|
6
|
+
import { chain, noop } from "@ariakit/core/utils/misc";
|
|
7
|
+
function assignStyle(element, style) {
|
|
8
|
+
if (!element)
|
|
9
|
+
return () => {
|
|
10
|
+
};
|
|
11
|
+
const previousStyle = element.style.cssText;
|
|
12
|
+
Object.assign(element.style, style);
|
|
13
|
+
return () => {
|
|
14
|
+
element.style.cssText = previousStyle;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function disableElement(element) {
|
|
18
|
+
if (!("style" in element))
|
|
19
|
+
return noop;
|
|
20
|
+
const previousInert = element.inert;
|
|
21
|
+
element.inert = true;
|
|
22
|
+
return chain(
|
|
23
|
+
assignStyle(element, {
|
|
24
|
+
pointerEvents: "none",
|
|
25
|
+
userSelect: "none",
|
|
26
|
+
cursor: "default"
|
|
27
|
+
}),
|
|
28
|
+
() => element.inert = previousInert
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function disableTreeOutside(...elements) {
|
|
32
|
+
const cleanups = [];
|
|
33
|
+
walkTreeOutside(elements, (element) => {
|
|
34
|
+
cleanups.unshift(disableElement(element));
|
|
35
|
+
});
|
|
36
|
+
const restorePointerEvents = () => {
|
|
37
|
+
cleanups.forEach((fn) => fn());
|
|
38
|
+
};
|
|
39
|
+
return restorePointerEvents;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
disableTreeOutside
|
|
44
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useCollectionStoreOptions,
|
|
3
3
|
useCollectionStoreProps
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./36HCAR3M.js";
|
|
5
5
|
import {
|
|
6
6
|
useStore,
|
|
7
7
|
useStoreProps
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./LTH56VDS.js";
|
|
9
9
|
|
|
10
10
|
// src/composite/composite-store.ts
|
|
11
11
|
import * as Core from "@ariakit/core/composite/composite-store";
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
useCheckboxStore,
|
|
3
3
|
useCheckboxStoreOptions,
|
|
4
4
|
useCheckboxStoreProps
|
|
5
|
-
} from "../__chunks/
|
|
6
|
-
import "../__chunks/
|
|
5
|
+
} from "../__chunks/MAJ5ZZ2S.js";
|
|
6
|
+
import "../__chunks/LTH56VDS.js";
|
|
7
7
|
import "../__chunks/B7MIN7YT.js";
|
|
8
8
|
import "../__chunks/SXC6BPOF.js";
|
|
9
9
|
export {
|
package/esm/checkbox/checkbox.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Checkbox,
|
|
3
3
|
useCheckbox
|
|
4
|
-
} from "../__chunks/
|
|
4
|
+
} from "../__chunks/GM2BWWHD.js";
|
|
5
5
|
import "../__chunks/M5KYRTQG.js";
|
|
6
6
|
import "../__chunks/SAVDGYCC.js";
|
|
7
7
|
import "../__chunks/5TGAWEHD.js";
|
|
8
8
|
import "../__chunks/JE5NWDDX.js";
|
|
9
|
-
import "../__chunks/
|
|
9
|
+
import "../__chunks/LTH56VDS.js";
|
|
10
10
|
import "../__chunks/B7MIN7YT.js";
|
|
11
11
|
import "../__chunks/SXC6BPOF.js";
|
|
12
12
|
export {
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
useCollectionStore,
|
|
3
3
|
useCollectionStoreOptions,
|
|
4
4
|
useCollectionStoreProps
|
|
5
|
-
} from "../__chunks/
|
|
6
|
-
import "../__chunks/
|
|
5
|
+
} from "../__chunks/36HCAR3M.js";
|
|
6
|
+
import "../__chunks/LTH56VDS.js";
|
|
7
7
|
import "../__chunks/B7MIN7YT.js";
|
|
8
8
|
import "../__chunks/SXC6BPOF.js";
|
|
9
9
|
export {
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
} from "../__chunks/DRSUYUM5.js";
|
|
8
8
|
import {
|
|
9
9
|
useCompositeItem
|
|
10
|
-
} from "../__chunks/
|
|
10
|
+
} from "../__chunks/JOV72LYK.js";
|
|
11
11
|
import "../__chunks/SAVDGYCC.js";
|
|
12
|
-
import "../__chunks/
|
|
12
|
+
import "../__chunks/ON2AV7GH.js";
|
|
13
13
|
import "../__chunks/T3DJZG63.js";
|
|
14
14
|
import "../__chunks/STKLF26R.js";
|
|
15
15
|
import "../__chunks/5TGAWEHD.js";
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
createHook,
|
|
20
20
|
createMemoComponent
|
|
21
21
|
} from "../__chunks/JE5NWDDX.js";
|
|
22
|
+
import "../__chunks/LTH56VDS.js";
|
|
22
23
|
import {
|
|
23
24
|
useBooleanEvent,
|
|
24
25
|
useEvent,
|