@ariakit/react-core 0.2.14 → 0.2.16
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/{GHDSJPDP.cjs → 2CBM6TG2.cjs} +9 -1
- package/cjs/__chunks/{JQNHOFVL.cjs → 4PH5LF7R.cjs} +4 -4
- package/cjs/__chunks/{IMHF4TCR.cjs → 5SFIKBWF.cjs} +2 -2
- package/cjs/__chunks/{XE2DJMCI.cjs → 6BAHKJ5K.cjs} +14 -20
- package/cjs/__chunks/{G2UVEERG.cjs → AHLK6SVF.cjs} +10 -10
- package/cjs/__chunks/{GICQ7PSP.cjs → BIJBAZHT.cjs} +2 -2
- package/cjs/__chunks/{AMRCH2Z5.cjs → BW4OCE2W.cjs} +4 -4
- package/cjs/__chunks/{ZWMVFMQY.cjs → CHVOMF22.cjs} +4 -4
- package/cjs/__chunks/{FWCSM5BC.cjs → CY7GQARX.cjs} +13 -13
- package/cjs/__chunks/{SIVNE3PR.cjs → ETK4FMZH.cjs} +12 -12
- package/cjs/__chunks/{FNDPLH5R.cjs → EVXAMK7D.cjs} +6 -8
- package/cjs/__chunks/{KD3RAGO6.cjs → EWI7RF64.cjs} +5 -5
- package/cjs/__chunks/{LE4VG2T4.cjs → EYVMZOCS.cjs} +8 -8
- package/cjs/__chunks/{O22LNQHS.cjs → FA3DXDDT.cjs} +2 -2
- package/cjs/__chunks/{JMBF4JHZ.cjs → FNKDTHTN.cjs} +4 -4
- package/cjs/__chunks/{LZV54A37.cjs → FVVV75ZK.cjs} +2 -2
- package/cjs/__chunks/{745H7MDU.cjs → GAQNLEPX.cjs} +6 -6
- package/cjs/__chunks/{FSADYSOP.cjs → HTEAWNBY.cjs} +14 -3
- package/cjs/__chunks/{HSFSIYIQ.cjs → JLC4GR5L.cjs} +2 -2
- package/cjs/__chunks/{HUVFPCMZ.cjs → KJBIRAH5.cjs} +24 -6
- package/cjs/__chunks/{OYXMXGQJ.cjs → KKAG47JR.cjs} +2 -2
- package/cjs/__chunks/{VBRBBWCP.cjs → NH6Q6YSM.cjs} +2 -2
- package/cjs/__chunks/{3MC2XJ5F.cjs → OHBR6IPU.cjs} +45 -33
- package/cjs/__chunks/{PRMEV7L5.cjs → PBJASQI6.cjs} +4 -4
- package/cjs/__chunks/{TFOIZV2V.cjs → PD5YFDLO.cjs} +3 -2
- package/cjs/__chunks/{IQIITEH3.cjs → QCWWP2P4.cjs} +2 -2
- package/cjs/__chunks/QW7NAUIX.cjs +113 -0
- package/cjs/__chunks/{63OBHNVT.cjs → VB7SPR3I.cjs} +7 -7
- package/cjs/__chunks/{LG6XOVBQ.cjs → VGBPLBUZ.cjs} +3 -3
- package/cjs/__chunks/{44MSVBJL.cjs → VKPXIX7D.cjs} +3 -3
- 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-renderer.cjs +3 -3
- package/cjs/collection/collection-store.cjs +3 -3
- package/cjs/combobox/combobox-item.cjs +4 -4
- package/cjs/combobox/combobox-popover.cjs +12 -12
- package/cjs/combobox/combobox-store.cjs +11 -11
- package/cjs/combobox/combobox.cjs +3 -3
- package/cjs/composite/composite-container.cjs +3 -3
- package/cjs/composite/composite-item.cjs +4 -4
- package/cjs/composite/composite-overflow-disclosure.cjs +7 -6
- package/cjs/composite/composite-overflow-store.cjs +7 -7
- package/cjs/composite/composite-overflow.cjs +12 -12
- package/cjs/composite/composite-renderer.cjs +4 -4
- package/cjs/composite/composite-store.cjs +4 -4
- package/cjs/dialog/dialog-backdrop.cjs +6 -6
- package/cjs/dialog/dialog-store.cjs +4 -4
- package/cjs/dialog/dialog.cjs +11 -11
- package/cjs/dialog/utils/disable-accessibility-tree-outside.cjs +3 -3
- package/cjs/dialog/utils/disable-tree-outside.cjs +4 -4
- package/cjs/dialog/utils/mark-tree-outside.cjs +3 -3
- package/cjs/dialog/utils/use-hide-on-interact-outside.cjs +4 -4
- package/cjs/dialog/utils/use-hide-on-interact-outside.d.ts +1 -1
- package/cjs/dialog/utils/use-nested-dialogs.cjs +2 -2
- package/cjs/dialog/utils/walk-tree-outside.cjs +2 -2
- package/cjs/dialog/utils/walk-tree-outside.d.ts +1 -1
- package/cjs/disclosure/disclosure-store.cjs +3 -3
- package/cjs/focusable/focusable.d.ts +52 -13
- 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 +8 -8
- package/cjs/hovercard/hovercard-anchor.cjs +2 -2
- package/cjs/hovercard/hovercard-disclosure.cjs +12 -14
- package/cjs/hovercard/hovercard-store.cjs +6 -6
- package/cjs/hovercard/hovercard.cjs +13 -13
- package/cjs/menu/menu-bar-store.cjs +6 -6
- package/cjs/menu/menu-button.cjs +9 -6
- package/cjs/menu/menu-item-checkbox.cjs +9 -9
- package/cjs/menu/menu-item-radio.cjs +7 -7
- package/cjs/menu/menu-item.cjs +5 -5
- package/cjs/menu/menu-list.cjs +3 -3
- package/cjs/menu/menu-store.cjs +13 -13
- package/cjs/menu/menu.cjs +15 -15
- package/cjs/popover/popover-store.cjs +5 -5
- package/cjs/popover/popover.cjs +12 -12
- package/cjs/radio/radio-store.cjs +7 -7
- package/cjs/radio/radio.cjs +5 -5
- package/cjs/select/select-item.cjs +4 -4
- package/cjs/select/select-popover.cjs +12 -12
- package/cjs/select/select-renderer.cjs +7 -7
- package/cjs/select/select-store.cjs +11 -11
- package/cjs/tab/tab-panel.cjs +5 -5
- package/cjs/tab/tab-store.cjs +9 -9
- package/cjs/tab/tab.cjs +4 -4
- package/cjs/toolbar/toolbar-container.cjs +7 -7
- package/cjs/toolbar/toolbar-input.cjs +5 -5
- package/cjs/toolbar/toolbar-item.cjs +5 -5
- package/cjs/toolbar/toolbar-store.cjs +6 -6
- package/cjs/tooltip/tooltip-anchor.cjs +33 -20
- package/cjs/tooltip/tooltip-store.cjs +10 -10
- package/cjs/tooltip/tooltip.cjs +13 -13
- package/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/cjs/utils/store.cjs +2 -2
- package/esm/__chunks/{7J6H5Y2H.js → 432NLB7J.js} +2 -2
- package/esm/__chunks/{FV23EKJL.js → 5M4ITSXL.js} +3 -2
- package/esm/__chunks/{6RR2HJXR.js → 5PDNXTAR.js} +1 -1
- package/esm/__chunks/{QHXLY5NM.js → 5QHNNZNE.js} +1 -1
- package/esm/__chunks/{WEWVELT3.js → 6F6CCCKT.js} +1 -1
- package/esm/__chunks/{DCG3EYDE.js → 7SIWUER2.js} +2 -2
- package/esm/__chunks/{F6KX6FT7.js → CEBWVZJQ.js} +2 -2
- package/esm/__chunks/{DIA4OBYO.js → CU3AKJBN.js} +1 -1
- package/esm/__chunks/{5TTSBUCW.js → CYNFBMYS.js} +1 -1
- package/esm/__chunks/{4XWTU3WN.js → E5XSMSHD.js} +25 -7
- package/esm/__chunks/{6RGH36XF.js → EICJBDBV.js} +2 -2
- package/esm/__chunks/{WVP274TO.js → F6PEGR7W.js} +1 -1
- package/esm/__chunks/{WKNTOKYS.js → FSTINJD5.js} +1 -1
- package/esm/__chunks/{LUUMYNYQ.js → FW5SU7FV.js} +2 -2
- package/esm/__chunks/{CYJJUQU3.js → GDORSOK6.js} +1 -1
- package/esm/__chunks/{HCTED3MY.js → JD3UVZX5.js} +1 -1
- package/esm/__chunks/{HCZMY53N.js → LEBYH5FW.js} +13 -2
- package/esm/__chunks/{AR6DTI3S.js → NHPU54IO.js} +2 -2
- package/esm/__chunks/{RH5PYIJN.js → ORZC42PG.js} +5 -7
- package/esm/__chunks/{OEA63YXU.js → PLOINBVB.js} +14 -20
- package/esm/__chunks/{VKYM5S67.js → Q52PUUUL.js} +1 -1
- package/esm/__chunks/{HWFO52CA.js → QJUX534W.js} +2 -2
- package/esm/__chunks/{OOWNFOTF.js → QPTZ2G2N.js} +51 -28
- package/esm/__chunks/{NCSSU46J.js → R4VIEIUH.js} +1 -1
- package/esm/__chunks/{GADPWICI.js → TG7IDXTX.js} +38 -26
- package/esm/__chunks/{KRFS2JCI.js → TQ5BKSY4.js} +2 -2
- package/esm/__chunks/{C2N5FZMW.js → UKOZA6YP.js} +2 -2
- package/esm/__chunks/{HGFTMLQ7.js → VFNGSUSF.js} +13 -13
- package/esm/__chunks/{5PLAJI33.js → X5CHG5LF.js} +2 -2
- package/esm/__chunks/{I3PXTXPI.js → Y5XLHDDM.js} +9 -1
- 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-renderer.js +2 -2
- package/esm/collection/collection-store.js +2 -2
- package/esm/combobox/combobox-item.js +3 -3
- package/esm/combobox/combobox-popover.js +11 -11
- package/esm/combobox/combobox-store.js +6 -6
- package/esm/combobox/combobox.js +3 -3
- package/esm/composite/composite-container.js +2 -2
- package/esm/composite/composite-item.js +3 -3
- package/esm/composite/composite-overflow-disclosure.js +6 -5
- package/esm/composite/composite-overflow-store.js +4 -4
- package/esm/composite/composite-overflow.js +11 -11
- package/esm/composite/composite-renderer.js +3 -3
- package/esm/composite/composite-store.js +3 -3
- package/esm/dialog/dialog-backdrop.js +5 -5
- package/esm/dialog/dialog-store.js +3 -3
- package/esm/dialog/dialog.js +10 -10
- package/esm/dialog/utils/disable-accessibility-tree-outside.js +2 -2
- package/esm/dialog/utils/disable-tree-outside.js +3 -3
- package/esm/dialog/utils/mark-tree-outside.js +2 -2
- package/esm/dialog/utils/use-hide-on-interact-outside.d.ts +1 -1
- package/esm/dialog/utils/use-hide-on-interact-outside.js +3 -3
- package/esm/dialog/utils/use-nested-dialogs.js +1 -1
- package/esm/dialog/utils/walk-tree-outside.d.ts +1 -1
- package/esm/dialog/utils/walk-tree-outside.js +1 -1
- package/esm/disclosure/disclosure-store.js +2 -2
- package/esm/focusable/focusable.d.ts +52 -13
- package/esm/form/form-checkbox.js +5 -5
- 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 +2 -2
- package/esm/hovercard/hovercard-anchor.js +1 -1
- package/esm/hovercard/hovercard-disclosure.js +12 -14
- package/esm/hovercard/hovercard-store.js +5 -5
- package/esm/hovercard/hovercard.js +12 -12
- package/esm/menu/menu-bar-store.js +3 -3
- package/esm/menu/menu-button.js +7 -4
- package/esm/menu/menu-item-checkbox.js +6 -6
- package/esm/menu/menu-item-radio.js +5 -5
- 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 +13 -13
- package/esm/popover/popover-store.js +4 -4
- package/esm/popover/popover.js +11 -11
- package/esm/radio/radio-store.js +3 -3
- package/esm/radio/radio.js +4 -4
- package/esm/select/select-item.js +3 -3
- package/esm/select/select-popover.js +11 -11
- package/esm/select/select-renderer.js +3 -3
- 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 -3
- package/esm/toolbar/toolbar-container.js +5 -5
- package/esm/toolbar/toolbar-input.js +4 -4
- package/esm/toolbar/toolbar-item.js +4 -4
- package/esm/toolbar/toolbar-store.js +3 -3
- package/esm/tooltip/tooltip-anchor.js +34 -21
- package/esm/tooltip/tooltip-store.js +5 -5
- package/esm/tooltip/tooltip.js +12 -12
- package/esm/tsconfig.build.tsbuildinfo +1 -1
- package/esm/utils/store.js +1 -1
- package/package.json +2 -2
- package/cjs/__chunks/KLWT4P56.cjs +0 -90
|
@@ -20,12 +20,13 @@ function walkTreeOutside(elements, callback, ancestorCallback) {
|
|
|
20
20
|
return maybeAncestor.contains(element);
|
|
21
21
|
});
|
|
22
22
|
const doc = getDocument(element);
|
|
23
|
+
const originalElement = element;
|
|
23
24
|
while (element.parentElement && element !== doc.body) {
|
|
24
|
-
ancestorCallback == null ? void 0 : ancestorCallback(element.parentElement);
|
|
25
|
+
ancestorCallback == null ? void 0 : ancestorCallback(element.parentElement, originalElement);
|
|
25
26
|
if (!hasAncestorAlready) {
|
|
26
27
|
for (const child of element.parentElement.children) {
|
|
27
28
|
if (isValidElement(child, elements)) {
|
|
28
|
-
callback(child);
|
|
29
|
+
callback(child, originalElement);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./P4RGQGTG.js";
|
|
4
4
|
import {
|
|
5
5
|
useCollectionItem
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./VFNGSUSF.js";
|
|
7
7
|
import {
|
|
8
8
|
focusSilently,
|
|
9
9
|
getEnabledItem,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
} from "./NQJBHION.js";
|
|
22
22
|
import {
|
|
23
23
|
useStoreState
|
|
24
|
-
} from "./
|
|
24
|
+
} from "./QPTZ2G2N.js";
|
|
25
25
|
import {
|
|
26
26
|
useBooleanEvent,
|
|
27
27
|
useEvent,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getCollectionRendererItemId,
|
|
3
3
|
useCollectionRenderer
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./5PDNXTAR.js";
|
|
5
5
|
import {
|
|
6
6
|
CompositeContext
|
|
7
7
|
} from "./WJ37OVG2.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./NQJBHION.js";
|
|
12
12
|
import {
|
|
13
13
|
useStoreState
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./QPTZ2G2N.js";
|
|
15
15
|
import {
|
|
16
16
|
useId
|
|
17
17
|
} from "./J7Q2EO23.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isElementMarked
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./LEBYH5FW.js";
|
|
4
4
|
import {
|
|
5
5
|
usePreviousMouseDownRef
|
|
6
6
|
} from "./7JNF6I52.js";
|
|
7
7
|
import {
|
|
8
|
-
useEvent
|
|
8
|
+
useEvent,
|
|
9
|
+
useSafeLayoutEffect
|
|
9
10
|
} from "./J7Q2EO23.js";
|
|
10
11
|
import {
|
|
11
12
|
__spreadProps,
|
|
@@ -13,7 +14,7 @@ import {
|
|
|
13
14
|
} from "./PNRLI7OV.js";
|
|
14
15
|
|
|
15
16
|
// src/dialog/utils/use-hide-on-interact-outside.ts
|
|
16
|
-
import { useEffect } from "react";
|
|
17
|
+
import { useEffect, useRef } from "react";
|
|
17
18
|
import { contains, getDocument, isVisible } from "@ariakit/core/utils/dom";
|
|
18
19
|
import { addGlobalEventListener } from "@ariakit/core/utils/events";
|
|
19
20
|
function isInDocument(target) {
|
|
@@ -47,10 +48,26 @@ function useEventOutside({
|
|
|
47
48
|
store,
|
|
48
49
|
type,
|
|
49
50
|
listener,
|
|
50
|
-
capture
|
|
51
|
+
capture,
|
|
52
|
+
domReady
|
|
51
53
|
}) {
|
|
52
54
|
const callListener = useEvent(listener);
|
|
53
55
|
const open = store.useState("open");
|
|
56
|
+
const focusedRef = useRef(false);
|
|
57
|
+
useSafeLayoutEffect(() => {
|
|
58
|
+
if (!open)
|
|
59
|
+
return;
|
|
60
|
+
if (!domReady)
|
|
61
|
+
return;
|
|
62
|
+
const { contentElement } = store.getState();
|
|
63
|
+
if (!contentElement)
|
|
64
|
+
return;
|
|
65
|
+
const onFocus = () => {
|
|
66
|
+
focusedRef.current = true;
|
|
67
|
+
};
|
|
68
|
+
contentElement.addEventListener("focusin", onFocus, true);
|
|
69
|
+
return () => contentElement.removeEventListener("focusin", onFocus, true);
|
|
70
|
+
}, [store, open, domReady]);
|
|
54
71
|
useEffect(() => {
|
|
55
72
|
if (!open)
|
|
56
73
|
return;
|
|
@@ -71,7 +88,8 @@ function useEventOutside({
|
|
|
71
88
|
return;
|
|
72
89
|
if (isMouseEventOnDialog(event, contentElement))
|
|
73
90
|
return;
|
|
74
|
-
|
|
91
|
+
const focused = focusedRef.current;
|
|
92
|
+
if (focused && !isElementMarked(target, contentElement.id))
|
|
75
93
|
return;
|
|
76
94
|
callListener(event);
|
|
77
95
|
};
|
|
@@ -84,10 +102,10 @@ function shouldHideOnInteractOutside(hideOnInteractOutside, event) {
|
|
|
84
102
|
}
|
|
85
103
|
return !!hideOnInteractOutside;
|
|
86
104
|
}
|
|
87
|
-
function useHideOnInteractOutside(store, hideOnInteractOutside) {
|
|
105
|
+
function useHideOnInteractOutside(store, hideOnInteractOutside, domReady) {
|
|
88
106
|
const open = store.useState("open");
|
|
89
107
|
const previousMouseDownRef = usePreviousMouseDownRef(open);
|
|
90
|
-
const props = { store, capture: true };
|
|
108
|
+
const props = { store, domReady, capture: true };
|
|
91
109
|
useEventOutside(__spreadProps(__spreadValues({}, props), {
|
|
92
110
|
type: "click",
|
|
93
111
|
listener: (event) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useDialogStoreOptions,
|
|
3
3
|
useDialogStoreProps
|
|
4
|
-
} from "./
|
|
4
|
+
} from "./FW5SU7FV.js";
|
|
5
5
|
import {
|
|
6
6
|
useStore,
|
|
7
7
|
useStoreProps
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./QPTZ2G2N.js";
|
|
9
9
|
import {
|
|
10
10
|
__spreadValues
|
|
11
11
|
} from "./PNRLI7OV.js";
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./FW6QFGFT.js";
|
|
7
7
|
import {
|
|
8
8
|
walkTreeOutside
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./5M4ITSXL.js";
|
|
10
10
|
|
|
11
11
|
// src/dialog/utils/mark-tree-outside.ts
|
|
12
12
|
import { chain } from "@ariakit/core/utils/misc";
|
|
@@ -15,12 +15,18 @@ function getPropertyName(id = "", ancestor = false) {
|
|
|
15
15
|
}
|
|
16
16
|
function markElement(element, id = "") {
|
|
17
17
|
return chain(
|
|
18
|
+
// Debug
|
|
19
|
+
// setAttribute(element, getPropertyName(), "true"),
|
|
20
|
+
// setAttribute(element, getPropertyName(id), "true"),
|
|
18
21
|
setProperty(element, getPropertyName(), true),
|
|
19
22
|
setProperty(element, getPropertyName(id), true)
|
|
20
23
|
);
|
|
21
24
|
}
|
|
22
25
|
function markAncestor(element, id = "") {
|
|
23
26
|
return chain(
|
|
27
|
+
// Debug
|
|
28
|
+
// setAttribute(element, getPropertyName("", true), "true"),
|
|
29
|
+
// setAttribute(element, getPropertyName(id, true), "true"),
|
|
24
30
|
setProperty(element, getPropertyName("", true), true),
|
|
25
31
|
setProperty(element, getPropertyName(id, true), true)
|
|
26
32
|
);
|
|
@@ -48,7 +54,12 @@ function markTreeOutside(dialogId, ...elements) {
|
|
|
48
54
|
return;
|
|
49
55
|
cleanups.unshift(markElement(element, dialogId));
|
|
50
56
|
},
|
|
51
|
-
(ancestor) =>
|
|
57
|
+
(ancestor, element) => {
|
|
58
|
+
const isAnotherDialogAncestor = element.hasAttribute("data-dialog") && element.id !== dialogId;
|
|
59
|
+
if (isAnotherDialogAncestor)
|
|
60
|
+
return;
|
|
61
|
+
cleanups.unshift(markAncestor(ancestor, dialogId));
|
|
62
|
+
}
|
|
52
63
|
);
|
|
53
64
|
const restoreAccessibilityTree = () => {
|
|
54
65
|
cleanups.forEach((fn) => fn());
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hideElementFromAccessibilityTree
|
|
3
|
-
} from "./
|
|
3
|
+
} from "./GDORSOK6.js";
|
|
4
4
|
import {
|
|
5
5
|
isBackdrop
|
|
6
6
|
} from "./IXXFVVA2.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "./FW6QFGFT.js";
|
|
15
15
|
import {
|
|
16
16
|
walkTreeOutside
|
|
17
|
-
} from "./
|
|
17
|
+
} from "./5M4ITSXL.js";
|
|
18
18
|
|
|
19
19
|
// src/dialog/utils/disable-tree-outside.ts
|
|
20
20
|
import { contains } from "@ariakit/core/utils/dom";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./X7FKJQME.js";
|
|
6
6
|
import {
|
|
7
7
|
usePopover
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./CU3AKJBN.js";
|
|
9
9
|
import {
|
|
10
10
|
createComponent,
|
|
11
11
|
createElement,
|
|
@@ -39,6 +39,7 @@ import { contains } from "@ariakit/core/utils/dom";
|
|
|
39
39
|
import { addGlobalEventListener } from "@ariakit/core/utils/events";
|
|
40
40
|
import { hasFocusWithin } from "@ariakit/core/utils/focus";
|
|
41
41
|
import { chain, isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
|
|
42
|
+
import { sync } from "@ariakit/core/utils/store";
|
|
42
43
|
import { jsx } from "react/jsx-runtime";
|
|
43
44
|
function isMovingOnHovercard(target, card, anchor, nested) {
|
|
44
45
|
if (hasFocusWithin(card))
|
|
@@ -95,12 +96,9 @@ function useAutoFocusOnHide(_a) {
|
|
|
95
96
|
});
|
|
96
97
|
const finalFocusRef = useRef(null);
|
|
97
98
|
useEffect(() => {
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
["anchorElement"]
|
|
103
|
-
);
|
|
99
|
+
return sync(store, ["anchorElement"], (state) => {
|
|
100
|
+
finalFocusRef.current = state.anchorElement;
|
|
101
|
+
});
|
|
104
102
|
}, []);
|
|
105
103
|
props = __spreadProps(__spreadValues({
|
|
106
104
|
autoFocusOnHide,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
useState
|
|
12
12
|
} from "react";
|
|
13
13
|
import { chain } from "@ariakit/core/utils/misc";
|
|
14
|
+
import { sync } from "@ariakit/core/utils/store";
|
|
14
15
|
import { jsx } from "react/jsx-runtime";
|
|
15
16
|
var NestedDialogsContext = createContext({});
|
|
16
17
|
function useNestedDialogs(store) {
|
|
@@ -27,28 +28,21 @@ function useNestedDialogs(store) {
|
|
|
27
28
|
[context]
|
|
28
29
|
);
|
|
29
30
|
useSafeLayoutEffect(() => {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
["open", "contentElement"]
|
|
40
|
-
);
|
|
31
|
+
return sync(store, ["open", "contentElement"], (state) => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!state.open)
|
|
34
|
+
return;
|
|
35
|
+
if (!state.contentElement)
|
|
36
|
+
return;
|
|
37
|
+
return (_a = context.add) == null ? void 0 : _a.call(context, store);
|
|
38
|
+
});
|
|
41
39
|
}, [store, context]);
|
|
42
40
|
useSafeLayoutEffect(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
store.hide();
|
|
49
|
-
},
|
|
50
|
-
["open"]
|
|
51
|
-
);
|
|
41
|
+
return sync(context.store, ["open"], (state) => {
|
|
42
|
+
if (state.open)
|
|
43
|
+
return;
|
|
44
|
+
store.hide();
|
|
45
|
+
});
|
|
52
46
|
}, [context, store]);
|
|
53
47
|
const providerValue = useMemo(() => ({ store, add }), [store, add]);
|
|
54
48
|
const wrapElement = useCallback(
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./6I2PARRP.js";
|
|
4
4
|
import {
|
|
5
5
|
useCompositeItem
|
|
6
|
-
} from "./
|
|
6
|
+
} from "./7SIWUER2.js";
|
|
7
7
|
import {
|
|
8
8
|
createElement,
|
|
9
9
|
createHook,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./NQJBHION.js";
|
|
12
12
|
import {
|
|
13
13
|
useStoreState
|
|
14
|
-
} from "./
|
|
14
|
+
} from "./QPTZ2G2N.js";
|
|
15
15
|
import {
|
|
16
16
|
useEvent,
|
|
17
17
|
useId,
|
|
@@ -9,13 +9,44 @@ import {
|
|
|
9
9
|
} from "./PNRLI7OV.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/store.tsx
|
|
12
|
-
import
|
|
12
|
+
import * as React from "react";
|
|
13
13
|
import { hasOwnProperty, identity } from "@ariakit/core/utils/misc";
|
|
14
|
+
import { batch, init, subscribe, sync } from "@ariakit/core/utils/store";
|
|
14
15
|
import { flushSync } from "react-dom";
|
|
15
16
|
import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
|
|
16
17
|
var noopSubscribe = () => () => {
|
|
17
18
|
};
|
|
19
|
+
var inFlushSyncContext = false;
|
|
20
|
+
function safeFlushSync(fn, canFlushSync = true) {
|
|
21
|
+
if (inFlushSyncContext || !canFlushSync) {
|
|
22
|
+
fn();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
inFlushSyncContext = true;
|
|
26
|
+
const originalError = console.error;
|
|
27
|
+
if (process.env.NODE_ENV !== "production") {
|
|
28
|
+
console.error = (msg) => {
|
|
29
|
+
if (msg.startsWith("Warning: flushSync"))
|
|
30
|
+
return;
|
|
31
|
+
originalError(msg);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
flushSync(fn);
|
|
36
|
+
} finally {
|
|
37
|
+
console.error = originalError;
|
|
38
|
+
inFlushSyncContext = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
18
41
|
function useStoreState(store, keyOrSelector = identity) {
|
|
42
|
+
const storeSubscribe = React.useCallback(
|
|
43
|
+
(callback) => {
|
|
44
|
+
if (!store)
|
|
45
|
+
return noopSubscribe();
|
|
46
|
+
return subscribe(store, null, callback);
|
|
47
|
+
},
|
|
48
|
+
[store]
|
|
49
|
+
);
|
|
19
50
|
const getSnapshot = () => {
|
|
20
51
|
if (!store)
|
|
21
52
|
return;
|
|
@@ -30,11 +61,7 @@ function useStoreState(store, keyOrSelector = identity) {
|
|
|
30
61
|
return;
|
|
31
62
|
return state[key];
|
|
32
63
|
};
|
|
33
|
-
return useSyncExternalStore(
|
|
34
|
-
(store == null ? void 0 : store.subscribe) || noopSubscribe,
|
|
35
|
-
getSnapshot,
|
|
36
|
-
getSnapshot
|
|
37
|
-
);
|
|
64
|
+
return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
|
|
38
65
|
}
|
|
39
66
|
function useStoreProps(store, props, key, setKey) {
|
|
40
67
|
const value = hasOwnProperty(props, key) ? props[key] : void 0;
|
|
@@ -47,40 +74,36 @@ function useStoreProps(store, props, key, setKey) {
|
|
|
47
74
|
queueMicrotask(() => {
|
|
48
75
|
canFlushSync = true;
|
|
49
76
|
});
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
flushSync(() => setValue(state[key]));
|
|
61
|
-
} else {
|
|
62
|
-
setValue(state[key]);
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
[key]
|
|
66
|
-
);
|
|
77
|
+
return sync(store, [key], (state, prev) => {
|
|
78
|
+
const { value: value2, setValue } = propsRef.current;
|
|
79
|
+
if (!setValue)
|
|
80
|
+
return;
|
|
81
|
+
if (state[key] === prev[key])
|
|
82
|
+
return;
|
|
83
|
+
if (state[key] === value2)
|
|
84
|
+
return;
|
|
85
|
+
safeFlushSync(() => setValue(state[key]), canFlushSync);
|
|
86
|
+
});
|
|
67
87
|
}, [store, key]);
|
|
68
88
|
useSafeLayoutEffect(() => {
|
|
69
|
-
return store
|
|
89
|
+
return batch(store, [key], () => {
|
|
70
90
|
if (value === void 0)
|
|
71
91
|
return;
|
|
72
92
|
store.setState(key, value);
|
|
73
|
-
}
|
|
93
|
+
});
|
|
74
94
|
}, [store, key, value]);
|
|
75
95
|
}
|
|
76
96
|
function useStore(createStore) {
|
|
77
97
|
const store = useLazyValue(createStore);
|
|
78
|
-
useSafeLayoutEffect(() =>
|
|
79
|
-
const useState = useCallback(
|
|
98
|
+
useSafeLayoutEffect(() => init(store), [store]);
|
|
99
|
+
const useState = React.useCallback(
|
|
80
100
|
(keyOrSelector) => useStoreState(store, keyOrSelector),
|
|
81
101
|
[store]
|
|
82
102
|
);
|
|
83
|
-
return useMemo(
|
|
103
|
+
return React.useMemo(
|
|
104
|
+
() => __spreadProps(__spreadValues({}, store), { useState }),
|
|
105
|
+
[store, useState]
|
|
106
|
+
);
|
|
84
107
|
}
|
|
85
108
|
|
|
86
109
|
export {
|