@ariakit/core 0.3.3 → 0.3.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/cjs/__chunks/{RCYVACJO.cjs → 3UT5FE6K.cjs} +9 -4
  3. package/cjs/__chunks/{TTWS4MDC.cjs → AR2VJ37F.cjs} +30 -29
  4. package/cjs/__chunks/{72I2GWXF.cjs → AV6KTKLE.cjs} +2 -1
  5. package/cjs/__chunks/F5YZIIEA.cjs +29 -0
  6. package/cjs/__chunks/{A7K3KZJL.cjs → F6Q5QSXF.cjs} +20 -19
  7. package/cjs/__chunks/{W5IQT6Z2.cjs → FFY2GSOG.cjs} +17 -16
  8. package/cjs/__chunks/{A4GDJCZB.cjs → FJSZTIOU.cjs} +18 -17
  9. package/cjs/__chunks/{EXM2AW52.cjs → FTB5CXVB.cjs} +3 -1
  10. package/cjs/__chunks/{EIRIJC7T.cjs → G5EW4WED.cjs} +8 -7
  11. package/cjs/__chunks/{ZYIEFAMB.cjs → HOEZKRUM.cjs} +18 -17
  12. package/cjs/__chunks/{DFFIYGBS.cjs → MYTMMWXI.cjs} +4 -3
  13. package/cjs/__chunks/{GDZQUFNP.cjs → ULSPM3Y3.cjs} +3 -1
  14. package/cjs/__chunks/XVR5QRC3.cjs +42 -0
  15. package/cjs/checkbox/checkbox-store.cjs +9 -8
  16. package/cjs/checkbox/checkbox-store.d.cts +41 -0
  17. package/cjs/collection/collection-store.cjs +8 -7
  18. package/cjs/collection/collection-store.d.cts +65 -0
  19. package/cjs/combobox/combobox-store.cjs +37 -36
  20. package/cjs/combobox/combobox-store.d.cts +77 -0
  21. package/cjs/composite/composite-overflow-store.cjs +9 -8
  22. package/cjs/composite/composite-overflow-store.d.cts +10 -0
  23. package/cjs/composite/composite-store.cjs +10 -9
  24. package/cjs/composite/composite-store.d.cts +206 -0
  25. package/cjs/dialog/dialog-store.cjs +8 -7
  26. package/cjs/dialog/dialog-store.d.cts +10 -0
  27. package/cjs/disclosure/disclosure-store.cjs +7 -6
  28. package/cjs/disclosure/disclosure-store.d.cts +125 -0
  29. package/cjs/form/form-store.cjs +30 -29
  30. package/cjs/form/form-store.d.cts +236 -0
  31. package/cjs/form/types.cjs +1 -1
  32. package/cjs/form/types.d.cts +38 -0
  33. package/cjs/hovercard/hovercard-store.cjs +10 -9
  34. package/cjs/hovercard/hovercard-store.d.cts +46 -0
  35. package/cjs/index.cjs +2 -1
  36. package/cjs/index.d.cts +2 -0
  37. package/cjs/menu/menu-bar-store.cjs +10 -22
  38. package/cjs/menu/menu-bar-store.d.cts +10 -0
  39. package/cjs/menu/menu-bar-store.d.ts +6 -6
  40. package/cjs/menu/menu-store.cjs +35 -34
  41. package/cjs/menu/menu-store.d.cts +78 -0
  42. package/cjs/menubar/menubar-store.cjs +14 -0
  43. package/cjs/menubar/menubar-store.d.cts +10 -0
  44. package/cjs/menubar/menubar-store.d.ts +10 -0
  45. package/cjs/popover/popover-store.cjs +9 -8
  46. package/cjs/popover/popover-store.d.cts +69 -0
  47. package/cjs/radio/radio-store.cjs +16 -15
  48. package/cjs/radio/radio-store.d.cts +36 -0
  49. package/cjs/select/select-store.cjs +37 -36
  50. package/cjs/select/select-store.d.cts +93 -0
  51. package/cjs/tab/tab-store.cjs +28 -27
  52. package/cjs/tab/tab-store.d.cts +87 -0
  53. package/cjs/toolbar/toolbar-store.cjs +12 -11
  54. package/cjs/toolbar/toolbar-store.d.cts +21 -0
  55. package/cjs/tooltip/tooltip-store.cjs +17 -16
  56. package/cjs/tooltip/tooltip-store.d.cts +29 -0
  57. package/cjs/utils/array.cjs +5 -4
  58. package/cjs/utils/array.d.cts +29 -0
  59. package/cjs/utils/dom.cjs +5 -4
  60. package/cjs/utils/dom.d.cts +105 -0
  61. package/cjs/utils/events.cjs +10 -9
  62. package/cjs/utils/events.d.cts +70 -0
  63. package/cjs/utils/focus.cjs +17 -16
  64. package/cjs/utils/focus.d.cts +117 -0
  65. package/cjs/utils/misc.cjs +7 -4
  66. package/cjs/utils/misc.d.cts +124 -0
  67. package/cjs/utils/misc.d.ts +7 -0
  68. package/cjs/utils/platform.cjs +6 -5
  69. package/cjs/utils/platform.d.cts +20 -0
  70. package/cjs/utils/store.cjs +6 -5
  71. package/cjs/utils/store.d.cts +71 -0
  72. package/cjs/utils/types.cjs +1 -1
  73. package/cjs/utils/types.d.cts +74 -0
  74. package/esm/__chunks/{PNRLI7OV.js → 4R3V3JGP.js} +1 -0
  75. package/esm/__chunks/{E6THWJ7N.js → 5BWT4GY2.js} +6 -5
  76. package/esm/__chunks/{UCFCIHEU.js → 5UJPJ37G.js} +2 -1
  77. package/esm/__chunks/{C57Q2UMF.js → 6EMNXRG3.js} +5 -4
  78. package/esm/__chunks/6LSGADQM.js +29 -0
  79. package/esm/__chunks/{5XEKIOCW.js → 7PRQYBBV.js} +2 -0
  80. package/esm/__chunks/{HN27WCTM.js → DREIYIMP.js} +2 -1
  81. package/esm/__chunks/{L4QLJSLG.js → EIFVU736.js} +5 -4
  82. package/esm/__chunks/{Y5SJEQQJ.js → HJS6GJT4.js} +3 -2
  83. package/esm/__chunks/{WVTCK5PV.js → I2VQ3XGR.js} +6 -1
  84. package/esm/__chunks/{JLNC5RR2.js → MRBDYBGO.js} +5 -4
  85. package/esm/__chunks/{O35LWD4W.js → NIF7E7VE.js} +2 -0
  86. package/esm/__chunks/{A2MHRHOV.js → PCA5ARZU.js} +4 -3
  87. package/esm/checkbox/checkbox-store.js +4 -3
  88. package/esm/collection/collection-store.js +6 -5
  89. package/esm/combobox/combobox-store.js +12 -11
  90. package/esm/composite/composite-overflow-store.js +7 -6
  91. package/esm/composite/composite-store.js +8 -7
  92. package/esm/dialog/dialog-store.js +6 -5
  93. package/esm/disclosure/disclosure-store.js +5 -4
  94. package/esm/form/form-store.js +6 -5
  95. package/esm/form/types.js +1 -0
  96. package/esm/hovercard/hovercard-store.js +8 -7
  97. package/esm/index.js +2 -1
  98. package/esm/menu/menu-bar-store.d.ts +6 -6
  99. package/esm/menu/menu-bar-store.js +11 -23
  100. package/esm/menu/menu-store.js +12 -11
  101. package/esm/menubar/menubar-store.d.ts +10 -0
  102. package/esm/menubar/menubar-store.js +14 -0
  103. package/esm/popover/popover-store.js +7 -6
  104. package/esm/radio/radio-store.js +8 -7
  105. package/esm/select/select-store.js +11 -10
  106. package/esm/tab/tab-store.js +8 -7
  107. package/esm/toolbar/toolbar-store.js +8 -7
  108. package/esm/tooltip/tooltip-store.js +8 -7
  109. package/esm/utils/array.js +3 -2
  110. package/esm/utils/dom.js +3 -2
  111. package/esm/utils/events.js +4 -3
  112. package/esm/utils/focus.js +3 -2
  113. package/esm/utils/misc.d.ts +7 -0
  114. package/esm/utils/misc.js +5 -2
  115. package/esm/utils/platform.js +4 -3
  116. package/esm/utils/store.js +4 -3
  117. package/esm/utils/types.js +1 -0
  118. package/menubar/menubar-store/package.json +8 -0
  119. package/package.json +116 -28
  120. package/cjs/__chunks/NEBQQIUX.cjs +0 -41
  121. package/cjs/tsconfig.build.tsbuildinfo +0 -1
  122. package/esm/tsconfig.build.tsbuildinfo +0 -1
@@ -0,0 +1,87 @@
1
+ import type { CollectionStore, CollectionStoreItem } from "../collection/collection-store.js";
2
+ import type { CompositeStoreFunctions, CompositeStoreItem, CompositeStoreOptions, CompositeStoreState } from "../composite/composite-store.js";
3
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
4
+ import type { SetState } from "../utils/types.js";
5
+ type Item = CompositeStoreItem & {
6
+ dimmed?: boolean;
7
+ };
8
+ type Panel = CollectionStoreItem & {
9
+ tabId?: string | null;
10
+ };
11
+ export declare function createTabStore(props?: TabStoreProps): TabStore;
12
+ export type TabStoreItem = Item;
13
+ export type TabStorePanel = Panel;
14
+ export interface TabStoreState extends CompositeStoreState<Item> {
15
+ /**
16
+ * @default "horizontal"
17
+ */
18
+ orientation: CompositeStoreState<Item>["orientation"];
19
+ /**
20
+ * @default true
21
+ */
22
+ focusLoop: CompositeStoreState<Item>["focusLoop"];
23
+ /**
24
+ * The id of the tab whose panel is currently visible. If it's `undefined`, it
25
+ * will be automatically set to the first enabled tab.
26
+ *
27
+ * Live examples:
28
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
29
+ */
30
+ selectedId: TabStoreState["activeId"];
31
+ /**
32
+ * Whether the tab should be selected when it receives focus. If it's set to
33
+ * `false`, the tab will be selected only when it's clicked.
34
+ *
35
+ * Live examples:
36
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
37
+ * @default true
38
+ */
39
+ selectOnMove?: boolean;
40
+ }
41
+ export interface TabStoreFunctions extends CompositeStoreFunctions<Item> {
42
+ /**
43
+ * Sets the `selectedId` state without moving focus. If you want to move focus,
44
+ * use the `select` function instead.
45
+ *
46
+ * Live examples:
47
+ * - [Tab with React Router](https://ariakit.org/examples/tab-react-router)
48
+ * @example
49
+ * // Selects the tab with id "tab-1"
50
+ * store.setSelectedId("tab-1");
51
+ * // Toggles between "tab-1" and "tab-2"
52
+ * store.setSelectedId((id) => id === "tab-1" ? "tab-2" : "tab-1"));
53
+ * // Selects the first tab
54
+ * store.setSelectedId(store.first());
55
+ * // Selects the next tab
56
+ * store.setSelectedId(store.next());
57
+ */
58
+ setSelectedId: SetState<TabStoreState["selectedId"]>;
59
+ /**
60
+ * A collection store containing the tab panels.
61
+ */
62
+ panels: CollectionStore<Panel>;
63
+ /**
64
+ * Selects the tab for the given id and moves focus to it. If you want to set
65
+ * the `selectedId` state without moving focus, use the `setSelectedId`
66
+ * function instead.
67
+ * @param id The id of the tab to select.
68
+ * @example
69
+ * // Selects the tab with id "tab-1"
70
+ * store.select("tab-1");
71
+ * // Selects the first tab
72
+ * store.select(store.first());
73
+ * // Selects the next tab
74
+ * store.select(store.next());
75
+ */
76
+ select: TabStore["move"];
77
+ }
78
+ export interface TabStoreOptions extends StoreOptions<TabStoreState, "orientation" | "focusLoop" | "selectedId" | "selectOnMove">, CompositeStoreOptions<Item> {
79
+ /**
80
+ * The id of the tab whose panel is currently visible. If it's `undefined`, it
81
+ * will be automatically set to the first enabled tab.
82
+ */
83
+ defaultSelectedId?: TabStoreState["selectedId"];
84
+ }
85
+ export type TabStoreProps = TabStoreOptions & StoreProps<TabStoreState>;
86
+ export type TabStore = TabStoreFunctions & Store<TabStoreState>;
87
+ export {};
@@ -1,29 +1,30 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _TTWS4MDCcjs = require('../__chunks/TTWS4MDC.cjs');
4
- require('../__chunks/W5IQT6Z2.cjs');
5
- require('../__chunks/A4GDJCZB.cjs');
6
3
 
4
+ var _AR2VJ37Fcjs = require('../__chunks/AR2VJ37F.cjs');
5
+ require('../__chunks/FFY2GSOG.cjs');
6
+ require('../__chunks/FJSZTIOU.cjs');
7
7
 
8
- var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
9
- require('../__chunks/EXM2AW52.cjs');
10
- require('../__chunks/GDZQUFNP.cjs');
11
8
 
9
+ var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
10
+ require('../__chunks/FTB5CXVB.cjs');
11
+ require('../__chunks/ULSPM3Y3.cjs');
12
12
 
13
13
 
14
- var _72I2GWXFcjs = require('../__chunks/72I2GWXF.cjs');
14
+
15
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
15
16
 
16
17
  // src/toolbar/toolbar-store.ts
17
18
  function createToolbarStore(props = {}) {
18
19
  var _a;
19
20
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
20
- return _TTWS4MDCcjs.createCompositeStore.call(void 0, _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, props), {
21
- orientation: _RCYVACJOcjs.defaultValue.call(void 0,
21
+ return _AR2VJ37Fcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
22
+ orientation: _3UT5FE6Kcjs.defaultValue.call(void 0,
22
23
  props.orientation,
23
24
  syncState == null ? void 0 : syncState.orientation,
24
25
  "horizontal"
25
26
  ),
26
- focusLoop: _RCYVACJOcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
27
+ focusLoop: _3UT5FE6Kcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
27
28
  }));
28
29
  }
29
30
 
@@ -0,0 +1,21 @@
1
+ import type { CompositeStore, CompositeStoreFunctions, CompositeStoreOptions, CompositeStoreProps, CompositeStoreState } from "../composite/composite-store.js";
2
+ import type { StoreOptions } from "../utils/store.js";
3
+ /**
4
+ * Creates a toolbar store.
5
+ */
6
+ export declare function createToolbarStore(props?: ToolbarStoreProps): ToolbarStore;
7
+ export interface ToolbarStoreState extends CompositeStoreState {
8
+ /**
9
+ * @default "horizontal"
10
+ */
11
+ orientation: CompositeStoreState["orientation"];
12
+ /**
13
+ * @default true
14
+ */
15
+ focusLoop: CompositeStoreState["focusLoop"];
16
+ }
17
+ export type ToolbarStoreFunctions = CompositeStoreFunctions;
18
+ export interface ToolbarStoreOptions extends StoreOptions<ToolbarStoreState, "orientation" | "focusLoop">, CompositeStoreOptions {
19
+ }
20
+ export type ToolbarStore = CompositeStore;
21
+ export type ToolbarStoreProps = CompositeStoreProps;
@@ -1,38 +1,39 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _NEBQQIUXcjs = require('../__chunks/NEBQQIUX.cjs');
4
- require('../__chunks/ZYIEFAMB.cjs');
5
- require('../__chunks/DFFIYGBS.cjs');
6
- require('../__chunks/A7K3KZJL.cjs');
7
3
 
4
+ var _XVR5QRC3cjs = require('../__chunks/XVR5QRC3.cjs');
5
+ require('../__chunks/HOEZKRUM.cjs');
6
+ require('../__chunks/MYTMMWXI.cjs');
7
+ require('../__chunks/F6Q5QSXF.cjs');
8
8
 
9
- var _A4GDJCZBcjs = require('../__chunks/A4GDJCZB.cjs');
10
9
 
10
+ var _FJSZTIOUcjs = require('../__chunks/FJSZTIOU.cjs');
11
11
 
12
- var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
13
12
 
13
+ var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
14
14
 
15
15
 
16
- var _72I2GWXFcjs = require('../__chunks/72I2GWXF.cjs');
16
+
17
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
17
18
 
18
19
  // src/tooltip/tooltip-store.ts
19
20
  function createTooltipStore(props = {}) {
20
21
  var _a;
21
22
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
22
- const hovercard = _NEBQQIUXcjs.createHovercardStore.call(void 0, _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, props), {
23
- placement: _RCYVACJOcjs.defaultValue.call(void 0,
23
+ const hovercard = _XVR5QRC3cjs.createHovercardStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
24
+ placement: _3UT5FE6Kcjs.defaultValue.call(void 0,
24
25
  props.placement,
25
26
  syncState == null ? void 0 : syncState.placement,
26
27
  "top"
27
28
  ),
28
- hideTimeout: _RCYVACJOcjs.defaultValue.call(void 0, props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout, 0)
29
+ hideTimeout: _3UT5FE6Kcjs.defaultValue.call(void 0, props.hideTimeout, syncState == null ? void 0 : syncState.hideTimeout, 0)
29
30
  }));
30
- const initialState = _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, hovercard.getState()), {
31
- type: _RCYVACJOcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
32
- skipTimeout: _RCYVACJOcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
31
+ const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, hovercard.getState()), {
32
+ type: _3UT5FE6Kcjs.defaultValue.call(void 0, props.type, syncState == null ? void 0 : syncState.type, "description"),
33
+ skipTimeout: _3UT5FE6Kcjs.defaultValue.call(void 0, props.skipTimeout, syncState == null ? void 0 : syncState.skipTimeout, 300)
33
34
  });
34
- const tooltip = _A4GDJCZBcjs.createStore.call(void 0, initialState, hovercard, props.store);
35
- return _72I2GWXFcjs.__spreadValues.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
35
+ const tooltip = _FJSZTIOUcjs.createStore.call(void 0, initialState, hovercard, props.store);
36
+ return _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, hovercard), tooltip);
36
37
  }
37
38
 
38
39
 
@@ -0,0 +1,29 @@
1
+ import type { HovercardStoreFunctions, HovercardStoreOptions, HovercardStoreState } from "../hovercard/hovercard-store.js";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
+ /**
4
+ * Creates a tooltip store.
5
+ */
6
+ export declare function createTooltipStore(props?: TooltipStoreProps): TooltipStore;
7
+ export interface TooltipStoreState extends HovercardStoreState {
8
+ /**
9
+ * Determines whether the tooltip is being used as a label or a description
10
+ * for the anchor element.
11
+ * @default "description"
12
+ */
13
+ type: "label" | "description";
14
+ /**
15
+ * The amount of time after a tooltip is hidden while all tooltips on the
16
+ * page can be shown immediately, without waiting for the show timeout.
17
+ * @default 300
18
+ */
19
+ skipTimeout: number;
20
+ /** @default "top" */
21
+ placement: HovercardStoreState["placement"];
22
+ /** @default 0 */
23
+ hideTimeout?: HovercardStoreState["hideTimeout"];
24
+ }
25
+ export type TooltipStoreFunctions = HovercardStoreFunctions;
26
+ export interface TooltipStoreOptions extends StoreOptions<TooltipStoreState, "type" | "placement" | "timeout" | "showTimeout" | "hideTimeout" | "skipTimeout">, HovercardStoreOptions {
27
+ }
28
+ export type TooltipStoreProps = TooltipStoreOptions & StoreProps<TooltipStoreState>;
29
+ export type TooltipStore = TooltipStoreFunctions & Store<TooltipStoreState>;
@@ -1,13 +1,14 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
4
 
5
5
 
6
- var _GDZQUFNPcjs = require('../__chunks/GDZQUFNP.cjs');
7
- require('../__chunks/72I2GWXF.cjs');
8
6
 
7
+ var _ULSPM3Y3cjs = require('../__chunks/ULSPM3Y3.cjs');
8
+ require('../__chunks/AV6KTKLE.cjs');
9
9
 
10
10
 
11
11
 
12
12
 
13
- exports.addItemToArray = _GDZQUFNPcjs.addItemToArray; exports.flatten2DArray = _GDZQUFNPcjs.flatten2DArray; exports.reverseArray = _GDZQUFNPcjs.reverseArray; exports.toArray = _GDZQUFNPcjs.toArray;
13
+
14
+ exports.addItemToArray = _ULSPM3Y3cjs.addItemToArray; exports.flatten2DArray = _ULSPM3Y3cjs.flatten2DArray; exports.reverseArray = _ULSPM3Y3cjs.reverseArray; exports.toArray = _ULSPM3Y3cjs.toArray;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Transforms `arg` into an array if it's not already.
3
+ * @example
4
+ * toArray("a"); // ["a"]
5
+ * toArray(["a"]); // ["a"]
6
+ */
7
+ export declare function toArray<T>(arg: T): T extends readonly any[] ? T : T[];
8
+ /**
9
+ * Immutably adds an index to an array.
10
+ * @example
11
+ * addItemToArray(["a", "b", "d"], "c", 2); // ["a", "b", "c", "d"]
12
+ * @returns {Array} A new array with the item in the passed array index.
13
+ */
14
+ export declare function addItemToArray<T extends any[]>(array: T, item: T[number], index?: number): T;
15
+ /**
16
+ * Flattens a 2D array into a one-dimensional array.
17
+ * @example
18
+ * flatten2DArray([["a"], ["b"], ["c"]]); // ["a", "b", "c"]
19
+ *
20
+ * @returns {Array} A one-dimensional array.
21
+ */
22
+ export declare function flatten2DArray<T>(array: T[][]): T[];
23
+ /**
24
+ * Immutably reverses an array.
25
+ * @example
26
+ * reverseArray(["a", "b", "c"]); // ["c", "b", "a"]
27
+ * @returns {Array} Reversed array.
28
+ */
29
+ export declare function reverseArray<T>(array: T[]): T[];
package/cjs/utils/dom.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
4
 
@@ -16,9 +16,9 @@
16
16
 
17
17
 
18
18
 
19
- var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
20
- require('../__chunks/72I2GWXF.cjs');
21
19
 
20
+ var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
21
+ require('../__chunks/AV6KTKLE.cjs');
22
22
 
23
23
 
24
24
 
@@ -36,4 +36,5 @@ require('../__chunks/72I2GWXF.cjs');
36
36
 
37
37
 
38
38
 
39
- exports.canUseDOM = _EXM2AW52cjs.canUseDOM; exports.closest = _EXM2AW52cjs.closest; exports.contains = _EXM2AW52cjs.contains; exports.getActiveElement = _EXM2AW52cjs.getActiveElement; exports.getDocument = _EXM2AW52cjs.getDocument; exports.getPopupItemRole = _EXM2AW52cjs.getPopupItemRole; exports.getPopupRole = _EXM2AW52cjs.getPopupRole; exports.getScrollingElement = _EXM2AW52cjs.getScrollingElement; exports.getTextboxSelection = _EXM2AW52cjs.getTextboxSelection; exports.getWindow = _EXM2AW52cjs.getWindow; exports.isButton = _EXM2AW52cjs.isButton; exports.isFrame = _EXM2AW52cjs.isFrame; exports.isPartiallyHidden = _EXM2AW52cjs.isPartiallyHidden; exports.isTextField = _EXM2AW52cjs.isTextField; exports.isVisible = _EXM2AW52cjs.isVisible; exports.matches = _EXM2AW52cjs.matches; exports.scrollIntoViewIfNeeded = _EXM2AW52cjs.scrollIntoViewIfNeeded;
39
+
40
+ exports.canUseDOM = _FTB5CXVBcjs.canUseDOM; exports.closest = _FTB5CXVBcjs.closest; exports.contains = _FTB5CXVBcjs.contains; exports.getActiveElement = _FTB5CXVBcjs.getActiveElement; exports.getDocument = _FTB5CXVBcjs.getDocument; exports.getPopupItemRole = _FTB5CXVBcjs.getPopupItemRole; exports.getPopupRole = _FTB5CXVBcjs.getPopupRole; exports.getScrollingElement = _FTB5CXVBcjs.getScrollingElement; exports.getTextboxSelection = _FTB5CXVBcjs.getTextboxSelection; exports.getWindow = _FTB5CXVBcjs.getWindow; exports.isButton = _FTB5CXVBcjs.isButton; exports.isFrame = _FTB5CXVBcjs.isFrame; exports.isPartiallyHidden = _FTB5CXVBcjs.isPartiallyHidden; exports.isTextField = _FTB5CXVBcjs.isTextField; exports.isVisible = _FTB5CXVBcjs.isVisible; exports.matches = _FTB5CXVBcjs.matches; exports.scrollIntoViewIfNeeded = _FTB5CXVBcjs.scrollIntoViewIfNeeded;
@@ -0,0 +1,105 @@
1
+ import type { AriaHasPopup, AriaRole } from "./types.js";
2
+ /**
3
+ * It's `true` if it is running in a browser environment or `false` if it is not
4
+ * (SSR).
5
+ * @example
6
+ * const title = canUseDOM ? document.title : "";
7
+ */
8
+ export declare const canUseDOM: boolean;
9
+ /**
10
+ * Returns `element.ownerDocument || document`.
11
+ */
12
+ export declare function getDocument(node?: Node | null): Document;
13
+ /**
14
+ * Returns `element.ownerDocument.defaultView || window`.
15
+ */
16
+ export declare function getWindow(node?: Node | null): Window;
17
+ /**
18
+ * Returns `element.ownerDocument.activeElement`.
19
+ */
20
+ export declare function getActiveElement(node?: Node | null, activeDescendant?: boolean): HTMLElement | null;
21
+ /**
22
+ * Similar to `Element.prototype.contains`, but a little bit faster when
23
+ * `element` is the same as `child`.
24
+ * @example
25
+ * contains(
26
+ * document.getElementById("parent"),
27
+ * document.getElementById("child")
28
+ * );
29
+ */
30
+ export declare function contains(parent: Node, child: Node): boolean;
31
+ /**
32
+ * Checks whether `element` is a frame element.
33
+ */
34
+ export declare function isFrame(element: Element): element is HTMLIFrameElement;
35
+ /**
36
+ * Checks whether `element` is a native HTML button element.
37
+ * @example
38
+ * isButton(document.querySelector("button")); // true
39
+ * isButton(document.querySelector("input[type='button']")); // true
40
+ * isButton(document.querySelector("div")); // false
41
+ * isButton(document.querySelector("input[type='text']")); // false
42
+ * isButton(document.querySelector("div[role='button']")); // false
43
+ */
44
+ export declare function isButton(element: {
45
+ tagName: string;
46
+ type?: string;
47
+ }): boolean;
48
+ /**
49
+ * Ponyfill for `Element.prototype.matches`
50
+ *
51
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
52
+ */
53
+ export declare function matches(element: Element, selectors: string): boolean;
54
+ /**
55
+ * Checks if the element is visible or not.
56
+ */
57
+ export declare function isVisible(element: Element): boolean;
58
+ /**
59
+ * Ponyfill for `Element.prototype.closest`
60
+ * @example
61
+ * closest(document.getElementById("id"), "div");
62
+ * // same as
63
+ * document.getElementById("id").closest("div");
64
+ */
65
+ export declare function closest<K extends keyof HTMLElementTagNameMap>(element: Element, selectors: K): HTMLElementTagNameMap[K];
66
+ export declare function closest<K extends keyof SVGElementTagNameMap>(element: Element, selectors: K): SVGElementTagNameMap[K];
67
+ export declare function closest<T extends Element = Element>(element: Element, selectors: string): T | null;
68
+ /**
69
+ * Check whether the given element is a text field, where text field is defined
70
+ * by the ability to select within the input.
71
+ * @example
72
+ * isTextField(document.querySelector("div")); // false
73
+ * isTextField(document.querySelector("input")); // true
74
+ * isTextField(document.querySelector("input[type='button']")); // false
75
+ * isTextField(document.querySelector("textarea")); // true
76
+ */
77
+ export declare function isTextField(element: Element): element is HTMLInputElement | HTMLTextAreaElement;
78
+ /**
79
+ * Returns the element's role attribute, if it has one.
80
+ */
81
+ export declare function getPopupRole(element?: Element | null, fallback?: AriaHasPopup): AriaHasPopup;
82
+ /**
83
+ * Returns the item role attribute based on the popup's role.
84
+ */
85
+ export declare function getPopupItemRole(element?: Element | null, fallback?: AriaRole): string | undefined;
86
+ /**
87
+ * Returns the start and end offsets of the selection in the element.
88
+ */
89
+ export declare function getTextboxSelection(element: HTMLElement): {
90
+ start: number;
91
+ end: number;
92
+ };
93
+ /**
94
+ * Calls `element.scrollIntoView()` if the element is hidden or partly hidden in
95
+ * the viewport.
96
+ */
97
+ export declare function scrollIntoViewIfNeeded(element: Element, arg?: boolean | ScrollIntoViewOptions): void;
98
+ /**
99
+ * Returns the scrolling container element of a given element.
100
+ */
101
+ export declare function getScrollingElement(element?: Element | null): HTMLElement | Element | null;
102
+ /**
103
+ * Determines whether an element is hidden or partially hidden in the viewport.
104
+ */
105
+ export declare function isPartiallyHidden(element: Element): boolean;
@@ -1,18 +1,19 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _EIRIJC7Tcjs = require('../__chunks/EIRIJC7T.cjs');
4
3
 
4
+ var _G5EW4WEDcjs = require('../__chunks/G5EW4WED.cjs');
5
5
 
6
- var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
7
6
 
7
+ var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
8
8
 
9
9
 
10
- var _72I2GWXFcjs = require('../__chunks/72I2GWXF.cjs');
10
+
11
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
11
12
 
12
13
  // src/utils/events.ts
13
14
  function isPortalEvent(event) {
14
15
  return Boolean(
15
- event.currentTarget && !_EXM2AW52cjs.contains.call(void 0, event.currentTarget, event.target)
16
+ event.currentTarget && !_FTB5CXVBcjs.contains.call(void 0, event.currentTarget, event.target)
16
17
  );
17
18
  }
18
19
  function isSelfTarget(event) {
@@ -22,7 +23,7 @@ function isOpeningInNewTab(event) {
22
23
  const element = event.currentTarget;
23
24
  if (!element)
24
25
  return false;
25
- const isAppleDevice = _EIRIJC7Tcjs.isApple.call(void 0, );
26
+ const isAppleDevice = _G5EW4WEDcjs.isApple.call(void 0, );
26
27
  if (isAppleDevice && !event.metaKey)
27
28
  return false;
28
29
  if (!isAppleDevice && !event.ctrlKey)
@@ -58,14 +59,14 @@ function fireEvent(element, type, eventInit) {
58
59
  function fireBlurEvent(element, eventInit) {
59
60
  const event = new FocusEvent("blur", eventInit);
60
61
  const defaultAllowed = element.dispatchEvent(event);
61
- const bubbleInit = _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
62
+ const bubbleInit = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
62
63
  element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
63
64
  return defaultAllowed;
64
65
  }
65
66
  function fireFocusEvent(element, eventInit) {
66
67
  const event = new FocusEvent("focus", eventInit);
67
68
  const defaultAllowed = element.dispatchEvent(event);
68
- const bubbleInit = _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
69
+ const bubbleInit = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, eventInit), { bubbles: true });
69
70
  element.dispatchEvent(new FocusEvent("focusin", bubbleInit));
70
71
  return defaultAllowed;
71
72
  }
@@ -80,7 +81,7 @@ function fireClickEvent(element, eventInit) {
80
81
  function isFocusEventOutside(event, container) {
81
82
  const containerElement = container || event.currentTarget;
82
83
  const relatedTarget = event.relatedTarget;
83
- return !relatedTarget || !_EXM2AW52cjs.contains.call(void 0, containerElement, relatedTarget);
84
+ return !relatedTarget || !_FTB5CXVBcjs.contains.call(void 0, containerElement, relatedTarget);
84
85
  }
85
86
  function queueBeforeEvent(element, type, callback) {
86
87
  const raf = requestAnimationFrame(() => {
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Returns `true` if `event` has been fired within a React Portal element.
3
+ */
4
+ export declare function isPortalEvent(event: Pick<Event, "currentTarget" | "target">): boolean;
5
+ /**
6
+ * Returns `true` if `event.target` and `event.currentTarget` are the same.
7
+ */
8
+ export declare function isSelfTarget(event: Pick<Event, "target" | "currentTarget">): boolean;
9
+ /**
10
+ * Checks whether the user event is triggering a page navigation in a new tab.
11
+ */
12
+ export declare function isOpeningInNewTab(event: Pick<MouseEvent, "currentTarget" | "metaKey" | "ctrlKey">): boolean;
13
+ /**
14
+ * Checks whether the user event is triggering a download.
15
+ */
16
+ export declare function isDownloading(event: Pick<MouseEvent, "altKey" | "currentTarget">): boolean;
17
+ /**
18
+ * Creates and dispatches an event.
19
+ * @example
20
+ * fireEvent(document.getElementById("id"), "blur", {
21
+ * bubbles: true,
22
+ * cancelable: true,
23
+ * });
24
+ */
25
+ export declare function fireEvent(element: Element, type: string, eventInit?: EventInit): boolean;
26
+ /**
27
+ * Creates and dispatches a blur event.
28
+ * @example
29
+ * fireBlurEvent(document.getElementById("id"));
30
+ */
31
+ export declare function fireBlurEvent(element: Element, eventInit?: FocusEventInit): boolean;
32
+ /**
33
+ * Creates and dispatches a focus event.
34
+ * @example
35
+ * fireFocusEvent(document.getElementById("id"));
36
+ */
37
+ export declare function fireFocusEvent(element: Element, eventInit?: FocusEventInit): boolean;
38
+ /**
39
+ * Creates and dispatches a keyboard event.
40
+ * @example
41
+ * fireKeyboardEvent(document.getElementById("id"), "keydown", {
42
+ * key: "ArrowDown",
43
+ * shiftKey: true,
44
+ * });
45
+ */
46
+ export declare function fireKeyboardEvent(element: Element, type: string, eventInit?: KeyboardEventInit): boolean;
47
+ /**
48
+ * Creates and dispatches a click event.
49
+ * @example
50
+ * fireClickEvent(document.getElementById("id"));
51
+ */
52
+ export declare function fireClickEvent(element: Element, eventInit?: PointerEventInit): boolean;
53
+ /**
54
+ * Checks whether the focus/blur event is happening from/to outside of the
55
+ * container element.
56
+ * @example
57
+ * const element = document.getElementById("id");
58
+ * element.addEventListener("blur", (event) => {
59
+ * if (isFocusEventOutside(event)) {
60
+ * // ...
61
+ * }
62
+ * });
63
+ */
64
+ export declare function isFocusEventOutside(event: Pick<FocusEvent, "currentTarget" | "relatedTarget">, container?: Element | null): boolean;
65
+ /**
66
+ * Runs a callback on the next animation frame, but before a certain event.
67
+ */
68
+ export declare function queueBeforeEvent(element: Element, type: string, callback: () => void): number;
69
+ export declare function addGlobalEventListener<K extends keyof DocumentEventMap>(type: K, listener: (event: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
70
+ export declare function addGlobalEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, scope?: Window): () => void;
@@ -1,14 +1,15 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _EXM2AW52cjs = require('../__chunks/EXM2AW52.cjs');
9
8
 
9
+ var _FTB5CXVBcjs = require('../__chunks/FTB5CXVB.cjs');
10
10
 
11
- var _72I2GWXFcjs = require('../__chunks/72I2GWXF.cjs');
11
+
12
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
12
13
 
13
14
  // src/utils/focus.ts
14
15
  var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
@@ -17,11 +18,11 @@ function hasNegativeTabIndex(element) {
17
18
  return tabIndex < 0;
18
19
  }
19
20
  function isFocusable(element) {
20
- if (!_EXM2AW52cjs.matches.call(void 0, element, selector))
21
+ if (!_FTB5CXVBcjs.matches.call(void 0, element, selector))
21
22
  return false;
22
- if (!_EXM2AW52cjs.isVisible.call(void 0, element))
23
+ if (!_FTB5CXVBcjs.isVisible.call(void 0, element))
23
24
  return false;
24
- if (_EXM2AW52cjs.closest.call(void 0, element, "[inert]"))
25
+ if (_FTB5CXVBcjs.closest.call(void 0, element, "[inert]"))
25
26
  return false;
26
27
  return true;
27
28
  }
@@ -43,7 +44,7 @@ function isTabbable(element) {
43
44
  return true;
44
45
  if (!("length" in radioGroup))
45
46
  return true;
46
- const activeElement = _EXM2AW52cjs.getActiveElement.call(void 0, element);
47
+ const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
47
48
  if (!activeElement)
48
49
  return true;
49
50
  if (activeElement === element)
@@ -65,7 +66,7 @@ function getAllFocusableIn(container, includeContainer) {
65
66
  }
66
67
  const focusableElements = elements.filter(isFocusable);
67
68
  focusableElements.forEach((element, i) => {
68
- if (_EXM2AW52cjs.isFrame.call(void 0, element) && element.contentDocument) {
69
+ if (_FTB5CXVBcjs.isFrame.call(void 0, element) && element.contentDocument) {
69
70
  const frameBody = element.contentDocument.body;
70
71
  focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody));
71
72
  }
@@ -91,7 +92,7 @@ function getAllTabbableIn(container, includeContainer, fallbackToFocusable) {
91
92
  tabbableElements.unshift(container);
92
93
  }
93
94
  tabbableElements.forEach((element, i) => {
94
- if (_EXM2AW52cjs.isFrame.call(void 0, element) && element.contentDocument) {
95
+ if (_FTB5CXVBcjs.isFrame.call(void 0, element) && element.contentDocument) {
95
96
  const frameBody = element.contentDocument.body;
96
97
  const allFrameTabbable = getAllTabbableIn(
97
98
  frameBody,
@@ -132,7 +133,7 @@ function getLastTabbable(fallbackToFocusable) {
132
133
  return getLastTabbableIn(document.body, false, fallbackToFocusable);
133
134
  }
134
135
  function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) {
135
- const activeElement = _EXM2AW52cjs.getActiveElement.call(void 0, container);
136
+ const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, container);
136
137
  const allFocusable = getAllFocusableIn(container, includeContainer);
137
138
  const activeIndex = allFocusable.indexOf(activeElement);
138
139
  const nextFocusableElements = allFocusable.slice(activeIndex + 1);
@@ -147,7 +148,7 @@ function getNextTabbable(fallbackToFirst, fallbackToFocusable) {
147
148
  );
148
149
  }
149
150
  function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) {
150
- const activeElement = _EXM2AW52cjs.getActiveElement.call(void 0, container);
151
+ const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, container);
151
152
  const allFocusable = getAllFocusableIn(container, includeContainer).reverse();
152
153
  const activeIndex = allFocusable.indexOf(activeElement);
153
154
  const previousFocusableElements = allFocusable.slice(activeIndex + 1);
@@ -163,12 +164,12 @@ function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) {
163
164
  }
164
165
  function getClosestFocusable(element) {
165
166
  while (element && !isFocusable(element)) {
166
- element = _EXM2AW52cjs.closest.call(void 0, element, selector);
167
+ element = _FTB5CXVBcjs.closest.call(void 0, element, selector);
167
168
  }
168
169
  return element || null;
169
170
  }
170
171
  function hasFocus(element) {
171
- const activeElement = _EXM2AW52cjs.getActiveElement.call(void 0, element);
172
+ const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
172
173
  if (!activeElement)
173
174
  return false;
174
175
  if (activeElement === element)
@@ -179,10 +180,10 @@ function hasFocus(element) {
179
180
  return activeDescendant === element.id;
180
181
  }
181
182
  function hasFocusWithin(element) {
182
- const activeElement = _EXM2AW52cjs.getActiveElement.call(void 0, element);
183
+ const activeElement = _FTB5CXVBcjs.getActiveElement.call(void 0, element);
183
184
  if (!activeElement)
184
185
  return false;
185
- if (_EXM2AW52cjs.contains.call(void 0, element, activeElement))
186
+ if (_FTB5CXVBcjs.contains.call(void 0, element, activeElement))
186
187
  return true;
187
188
  const activeDescendant = activeElement.getAttribute("aria-activedescendant");
188
189
  if (!activeDescendant)
@@ -229,7 +230,7 @@ function focusIntoView(element, options) {
229
230
  element.focus();
230
231
  } else {
231
232
  element.focus({ preventScroll: true });
232
- element.scrollIntoView(_72I2GWXFcjs.__spreadValues.call(void 0, { block: "nearest", inline: "nearest" }, options));
233
+ element.scrollIntoView(_AV6KTKLEcjs.__spreadValues.call(void 0, { block: "nearest", inline: "nearest" }, options));
233
234
  }
234
235
  }
235
236