@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,206 @@
1
+ import type { CollectionStoreFunctions, CollectionStoreItem, CollectionStoreOptions, CollectionStoreState } from "../collection/collection-store.js";
2
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
3
+ import type { SetState } from "../utils/types.js";
4
+ type Orientation = "horizontal" | "vertical" | "both";
5
+ type Item = CollectionStoreItem & {
6
+ rowId?: string;
7
+ disabled?: boolean;
8
+ children?: string;
9
+ };
10
+ /**
11
+ * Creates a composite store.
12
+ */
13
+ export declare function createCompositeStore<T extends Item = Item>(props?: CompositeStoreProps<T>): CompositeStore<T>;
14
+ export type CompositeStoreOrientation = Orientation;
15
+ export type CompositeStoreItem = Item;
16
+ export interface CompositeStoreState<T extends Item = Item> extends CollectionStoreState<T> {
17
+ /**
18
+ * The composite element.
19
+ */
20
+ baseElement: HTMLElement | null;
21
+ /**
22
+ * If enabled, the composite element will act as an
23
+ * [aria-activedescendant](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_activedescendant)
24
+ * container instead of [roving
25
+ * tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex).
26
+ * DOM focus will remain on the composite element while its items receive
27
+ * virtual focus.
28
+ *
29
+ * Live examples:
30
+ * - [Multi-selectable
31
+ * Combobox](https://ariakit.org/examples/combobox-multiple)
32
+ * @default false
33
+ */
34
+ virtualFocus: boolean;
35
+ /**
36
+ * Defines the orientation of the composite widget. If the composite has a
37
+ * single row or column (one-dimensional), the `orientation` value determines
38
+ * which arrow keys can be used to move focus:
39
+ * - `both`: all arrow keys work.
40
+ * - `horizontal`: only left and right arrow keys work.
41
+ * - `vertical`: only up and down arrow keys work.
42
+ *
43
+ * It doesn't have any effect on two-dimensional composites.
44
+ * @default "both"
45
+ */
46
+ orientation: Orientation;
47
+ /**
48
+ * Determines how the `next` and `previous` functions will behave. If `rtl` is
49
+ * set to `true`, they will be inverted. This only affects the composite
50
+ * widget behavior. You still need to set `dir="rtl"` on HTML/CSS.
51
+ * @default false
52
+ */
53
+ rtl: boolean;
54
+ /**
55
+ * Determines how the focus behaves when the user reaches the end of the
56
+ * composite widget.
57
+ *
58
+ * On one-dimensional composites:
59
+ * - `true` loops from the last item to the first item and vice-versa.
60
+ * - `horizontal` loops only if `orientation` is `horizontal` or not set.
61
+ * - `vertical` loops only if `orientation` is `vertical` or not set.
62
+ * - If `includesBaseElement` is set to `true` (or `activeId` is initially set
63
+ * to `null`), the composite element will be focused in between the last and
64
+ * first items.
65
+ *
66
+ * On two-dimensional composites (when using `CompositeRow`):
67
+ * - `true` loops from the last row/column item to the first item in the same
68
+ * row/column and vice-versa. If it's the last item in the last row, it
69
+ * moves to the first item in the first row and vice-versa.
70
+ * - `horizontal` loops only from the last row item to the first item in the
71
+ * same row.
72
+ * - `vertical` loops only from the last column item to the first item in the
73
+ * column row.
74
+ * - If `includesBaseElement` is set to `true` (or `activeId` is initially set
75
+ * to `null`), vertical loop will have no effect as moving down from the
76
+ * last row or up from the first row will focus the composite element.
77
+ * - If `focusWrap` matches the value of `focusLoop`, it'll wrap between the
78
+ * last item in the last row or column and the first item in the first row
79
+ * or column and vice-versa.
80
+ * @default false
81
+ */
82
+ focusLoop: boolean | Orientation;
83
+ /**
84
+ * **Works only on two-dimensional composites**. If enabled, moving to the
85
+ * next item from the last one in a row or column will focus the first item in
86
+ * the next row or column and vice-versa.
87
+ * - `true` wraps between rows and columns.
88
+ * - `horizontal` wraps only between rows.
89
+ * - `vertical` wraps only between columns.
90
+ * - If `focusLoop` matches the value of `focusWrap`, it'll wrap between the
91
+ * last item in the last row or column and the first item in the first row
92
+ * or column and vice-versa.
93
+ * @default false
94
+ */
95
+ focusWrap: boolean | Orientation;
96
+ /**
97
+ * **Works only on two-dimensional composites**. If enabled, moving up or down
98
+ * when there's no next item or when the next item is disabled will shift to
99
+ * the item right before it.
100
+ * @default false
101
+ */
102
+ focusShift: boolean;
103
+ /**
104
+ * The number of times the `move` function has been called.
105
+ */
106
+ moves: number;
107
+ /**
108
+ * Indicates whether the composite element should be included in the focus
109
+ * order.
110
+ * @default false
111
+ */
112
+ includesBaseElement: boolean;
113
+ /**
114
+ * The current focused item `id`.
115
+ * - `null` focuses the base composite element and users will be able to
116
+ * navigate out of it using arrow keys.
117
+ * - If `activeId` is initially set to `null`, the `includesBaseElement` prop
118
+ * will also default to `true`, which means the base composite element
119
+ * itself will have focus and users will be able to navigate to it using
120
+ * arrow keys.
121
+ */
122
+ activeId: string | null | undefined;
123
+ }
124
+ export interface CompositeStoreFunctions<T extends Item = Item> extends CollectionStoreFunctions<T> {
125
+ /**
126
+ * Sets the `baseElement`.
127
+ */
128
+ setBaseElement: SetState<CompositeStoreState<T>["baseElement"]>;
129
+ /**
130
+ * Sets the `activeId` state without moving focus. If you want to move focus,
131
+ * use the `move` function instead.
132
+ * @example
133
+ * // Sets the composite element as the active item
134
+ * store.setActiveId(null);
135
+ * // Sets the item with id "item-1" as the active item
136
+ * store.setActiveId("item-1");
137
+ * // Sets the next item as the active item
138
+ * store.setActiveId(store.next());
139
+ */
140
+ setActiveId: SetState<CompositeStoreState<T>["activeId"]>;
141
+ /**
142
+ * Moves focus to a given item id and sets it as the active item. Passing
143
+ * `null` will focus the composite element itself.
144
+ * @param id The item id to move focus to.
145
+ * @example
146
+ * // Moves focus to the composite element
147
+ * store.move(null);
148
+ * // Moves focus to the item with id "item-1"
149
+ * store.move("item-1");
150
+ * // Moves focus to the next item
151
+ * store.move(store.next());
152
+ */
153
+ move: (id?: string | null) => void;
154
+ /**
155
+ * Returns the id of the next item based on the current `activeId` state.
156
+ * @param skip The number of items to skip. Defaults to 1.
157
+ * @example
158
+ * const nextId = store.next();
159
+ * const nextNextId = store.next(2);
160
+ */
161
+ next: (skip?: number) => string | null | undefined;
162
+ /**
163
+ * Returns the id of the previous item based on the current `activeId` state.
164
+ * @param skip The number of items to skip. Defaults to 1.
165
+ * @example
166
+ * const previousId = store.previous();
167
+ * const previousPreviousId = store.previous(2);
168
+ */
169
+ previous: (skip?: number) => string | null | undefined;
170
+ /**
171
+ * Returns the id of the item above based on the current `activeId` state.
172
+ * @param skip The number of items to skip. Defaults to 1.
173
+ * @example
174
+ * const upId = store.up();
175
+ * const upUpId = store.up(2);
176
+ */
177
+ up: (skip?: number) => string | null | undefined;
178
+ /**
179
+ * Returns the id of the item below based on the current `activeId` state.
180
+ * @param skip The number of items to skip. Defaults to 1.
181
+ * @example
182
+ * const downId = store.down();
183
+ * const downDownId = store.down(2);
184
+ */
185
+ down: (skip?: number) => string | null | undefined;
186
+ /**
187
+ * Returns the id of the first item.
188
+ */
189
+ first: () => string | null | undefined;
190
+ /**
191
+ * Returns the id of the last item.
192
+ */
193
+ last: () => string | null | undefined;
194
+ }
195
+ export interface CompositeStoreOptions<T extends Item = Item> extends StoreOptions<CompositeStoreState<T>, "virtualFocus" | "orientation" | "rtl" | "focusLoop" | "focusWrap" | "focusShift" | "includesBaseElement" | "activeId">, CollectionStoreOptions<T> {
196
+ /**
197
+ * The composite item id that should be active by default when the composite
198
+ * widget is rendered. If `null`, the composite element itself will have focus
199
+ * and users will be able to navigate to it using arrow keys. If `undefined`,
200
+ * the first enabled item will be focused.
201
+ */
202
+ defaultActiveId?: CompositeStoreState<T>["activeId"];
203
+ }
204
+ export type CompositeStoreProps<T extends Item = Item> = CompositeStoreOptions<T> & StoreProps<CompositeStoreState<T>>;
205
+ export type CompositeStore<T extends Item = Item> = CompositeStoreFunctions<T> & Store<CompositeStoreState<T>>;
206
+ export {};
@@ -1,10 +1,11 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _DFFIYGBScjs = require('../__chunks/DFFIYGBS.cjs');
4
- require('../__chunks/A7K3KZJL.cjs');
5
- require('../__chunks/A4GDJCZB.cjs');
6
- require('../__chunks/RCYVACJO.cjs');
7
- require('../__chunks/72I2GWXF.cjs');
8
3
 
4
+ var _MYTMMWXIcjs = require('../__chunks/MYTMMWXI.cjs');
5
+ require('../__chunks/F6Q5QSXF.cjs');
6
+ require('../__chunks/FJSZTIOU.cjs');
7
+ require('../__chunks/3UT5FE6K.cjs');
8
+ require('../__chunks/AV6KTKLE.cjs');
9
9
 
10
- exports.createDialogStore = _DFFIYGBScjs.createDialogStore;
10
+
11
+ exports.createDialogStore = _MYTMMWXIcjs.createDialogStore;
@@ -0,0 +1,10 @@
1
+ import type { DisclosureStore, DisclosureStoreFunctions, DisclosureStoreOptions, DisclosureStoreProps, DisclosureStoreState } from "../disclosure/disclosure-store.js";
2
+ /**
3
+ * Creates a dialog store.
4
+ */
5
+ export declare function createDialogStore(props?: DialogStoreProps): DialogStore;
6
+ export type DialogStoreState = DisclosureStoreState;
7
+ export type DialogStoreFunctions = DisclosureStoreFunctions;
8
+ export type DialogStoreOptions = DisclosureStoreOptions;
9
+ export type DialogStoreProps = DisclosureStoreProps;
10
+ export type DialogStore = DisclosureStore;
@@ -1,9 +1,10 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _A7K3KZJLcjs = require('../__chunks/A7K3KZJL.cjs');
4
- require('../__chunks/A4GDJCZB.cjs');
5
- require('../__chunks/RCYVACJO.cjs');
6
- require('../__chunks/72I2GWXF.cjs');
7
3
 
4
+ var _F6Q5QSXFcjs = require('../__chunks/F6Q5QSXF.cjs');
5
+ require('../__chunks/FJSZTIOU.cjs');
6
+ require('../__chunks/3UT5FE6K.cjs');
7
+ require('../__chunks/AV6KTKLE.cjs');
8
8
 
9
- exports.createDisclosureStore = _A7K3KZJLcjs.createDisclosureStore;
9
+
10
+ exports.createDisclosureStore = _F6Q5QSXFcjs.createDisclosureStore;
@@ -0,0 +1,125 @@
1
+ import type { Store, StoreOptions, StoreProps } from "../utils/store.js";
2
+ import type { SetState } from "../utils/types.js";
3
+ /**
4
+ * Creates a disclosure store.
5
+ */
6
+ export declare function createDisclosureStore(props?: DisclosureStoreProps): DisclosureStore;
7
+ export interface DisclosureStoreState {
8
+ /**
9
+ * The visibility state of the content.
10
+ *
11
+ * Live examples:
12
+ * - [Dialog with React
13
+ * Router](https://ariakit.org/examples/dialog-react-router)
14
+ * @default false
15
+ */
16
+ open: boolean;
17
+ /**
18
+ * The mounted state of the content. If `animated` is `false` or not defined,
19
+ * this will be the same as `open`. Otherwise, it will wait for the animation
20
+ * to complete before becoming `false` so the content is not unmounted while
21
+ * animating.
22
+ *
23
+ * Live examples:
24
+ * - [Combobox with links](https://ariakit.org/examples/combobox-links)
25
+ * - [Textarea with inline
26
+ * Combobox](https://ariakit.org/examples/combobox-textarea)
27
+ */
28
+ mounted: boolean;
29
+ /**
30
+ * Determines whether the content should animate when it is shown or hidden.
31
+ * - If `true`, the `animating` state will be `true` when the content is shown
32
+ * or hidden and it will wait for `stopAnimation` to be called or a CSS
33
+ * animation/transition to end before becoming `false`.
34
+ * - If it's set to a number, the `animating` state will be `true` when the
35
+ * content is shown or hidden and it will wait for the number of
36
+ * milliseconds to pass before becoming `false`.
37
+ *
38
+ * Live examples:
39
+ * - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
40
+ * - [Animated Dialog](https://ariakit.org/examples/dialog-animated)
41
+ * - [Animated Select](https://ariakit.org/examples/select-animated)
42
+ * @default false
43
+ */
44
+ animated: boolean | number;
45
+ /**
46
+ * Whether the content is currently animating.
47
+ */
48
+ animating: boolean;
49
+ /**
50
+ * The content element that is being shown or hidden.
51
+ */
52
+ contentElement: HTMLElement | null;
53
+ /**
54
+ * The disclosure button element that toggles the content.
55
+ */
56
+ disclosureElement: HTMLElement | null;
57
+ }
58
+ export interface DisclosureStoreFunctions {
59
+ /**
60
+ * Sets the `open` state.
61
+ *
62
+ * Live examples:
63
+ * - [Textarea with inline
64
+ * Combobox](https://ariakit.org/examples/combobox-textarea)
65
+ * - [Dialog with React
66
+ * Router](https://ariakit.org/examples/dialog-react-router)
67
+ * @example
68
+ * store.setOpen(true);
69
+ * store.setOpen((open) => !open);
70
+ */
71
+ setOpen: SetState<DisclosureStoreState["open"]>;
72
+ /**
73
+ * Sets the `open` state to `true`.
74
+ *
75
+ * Live examples:
76
+ * - [Textarea with inline
77
+ * Combobox](https://ariakit.org/examples/combobox-textarea)
78
+ */
79
+ show: () => void;
80
+ /**
81
+ * Sets the `open` state to `false`.
82
+ *
83
+ * Live examples:
84
+ * - [Textarea with inline
85
+ * Combobox](https://ariakit.org/examples/combobox-textarea)
86
+ * - [Dialog with React
87
+ * Router](https://ariakit.org/examples/dialog-react-router)
88
+ * - [Sliding Menu](https://ariakit.org/examples/menu-slide)
89
+ */
90
+ hide: () => void;
91
+ /**
92
+ * Toggles the `open` state.
93
+ */
94
+ toggle: () => void;
95
+ /**
96
+ * Sets the `animating` state to `false`, which will automatically set the
97
+ * `mounted` state to `false` if it was `true`. This means that the content
98
+ * element can be safely unmounted.
99
+ */
100
+ stopAnimation: () => void;
101
+ /**
102
+ * Sets the `contentElement` state.
103
+ */
104
+ setContentElement: SetState<DisclosureStoreState["contentElement"]>;
105
+ /**
106
+ * Sets the `disclosureElement` state.
107
+ */
108
+ setDisclosureElement: SetState<DisclosureStoreState["disclosureElement"]>;
109
+ }
110
+ export interface DisclosureStoreOptions extends StoreOptions<DisclosureStoreState, "open" | "animated"> {
111
+ /**
112
+ * The default visibility state of the content.
113
+ * @default false
114
+ */
115
+ defaultOpen?: DisclosureStoreState["open"];
116
+ /**
117
+ * A reference to another disclosure store that controls another disclosure
118
+ * component to keep them in sync. Element states like `contentElement` and
119
+ * `disclosureElement` won't be synced. For that, use the `store` prop
120
+ * instead.
121
+ */
122
+ disclosure?: DisclosureStore | null;
123
+ }
124
+ export type DisclosureStoreProps = DisclosureStoreOptions & StoreProps<DisclosureStoreState>;
125
+ export type DisclosureStore = DisclosureStoreFunctions & Store<DisclosureStoreState>;
@@ -1,23 +1,24 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
- var _W5IQT6Z2cjs = require('../__chunks/W5IQT6Z2.cjs');
4
3
 
4
+ var _FFY2GSOGcjs = require('../__chunks/FFY2GSOG.cjs');
5
5
 
6
6
 
7
7
 
8
8
 
9
- var _A4GDJCZBcjs = require('../__chunks/A4GDJCZB.cjs');
10
9
 
10
+ var _FJSZTIOUcjs = require('../__chunks/FJSZTIOU.cjs');
11
11
 
12
12
 
13
13
 
14
14
 
15
- var _RCYVACJOcjs = require('../__chunks/RCYVACJO.cjs');
16
- require('../__chunks/EXM2AW52.cjs');
17
15
 
16
+ var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
17
+ require('../__chunks/FTB5CXVB.cjs');
18
18
 
19
19
 
20
- var _72I2GWXFcjs = require('../__chunks/72I2GWXF.cjs');
20
+
21
+ var _AV6KTKLEcjs = require('../__chunks/AV6KTKLE.cjs');
21
22
 
22
23
  // src/form/form-store.ts
23
24
  function nextFrame() {
@@ -25,7 +26,7 @@ function nextFrame() {
25
26
  }
26
27
  function hasMessages(object) {
27
28
  return Object.keys(object).some((key) => {
28
- if (_RCYVACJOcjs.isObject.call(void 0, object[key])) {
29
+ if (_3UT5FE6Kcjs.isObject.call(void 0, object[key])) {
29
30
  return hasMessages(object[key]);
30
31
  }
31
32
  return !!object[key];
@@ -47,10 +48,10 @@ function set(values, path, value) {
47
48
  if (k == null)
48
49
  return values;
49
50
  const key = k;
50
- const isIntegerKey = _RCYVACJOcjs.isInteger.call(void 0, key);
51
+ const isIntegerKey = _3UT5FE6Kcjs.isInteger.call(void 0, key);
51
52
  const nextValues = isIntegerKey ? values || [] : values || {};
52
53
  const nestedValues = nextValues[key];
53
- const result = rest.length && (Array.isArray(nestedValues) || _RCYVACJOcjs.isObject.call(void 0, nestedValues)) ? set(nestedValues, rest, value) : value;
54
+ const result = rest.length && (Array.isArray(nestedValues) || _3UT5FE6Kcjs.isObject.call(void 0, nestedValues)) ? set(nestedValues, rest, value) : value;
54
55
  if (isIntegerKey) {
55
56
  const index = Number(key);
56
57
  if (values && Array.isArray(values)) {
@@ -64,7 +65,7 @@ function set(values, path, value) {
64
65
  nextValues2[index] = result;
65
66
  return nextValues2;
66
67
  }
67
- return _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, values), { [key]: result });
68
+ return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, values), { [key]: result });
68
69
  }
69
70
  function setAll(values, value) {
70
71
  const result = {};
@@ -73,12 +74,12 @@ function setAll(values, value) {
73
74
  const currentValue = values[key];
74
75
  if (Array.isArray(currentValue)) {
75
76
  result[key] = currentValue.map((v) => {
76
- if (_RCYVACJOcjs.isObject.call(void 0, v)) {
77
+ if (_3UT5FE6Kcjs.isObject.call(void 0, v)) {
77
78
  return setAll(v, value);
78
79
  }
79
80
  return value;
80
81
  });
81
- } else if (_RCYVACJOcjs.isObject.call(void 0, currentValue)) {
82
+ } else if (_3UT5FE6Kcjs.isObject.call(void 0, currentValue)) {
82
83
  result[key] = setAll(currentValue, value);
83
84
  } else {
84
85
  result[key] = value;
@@ -113,46 +114,46 @@ function createNames() {
113
114
  }
114
115
  function createFormStore(props = {}) {
115
116
  var _a;
116
- _A4GDJCZBcjs.throwOnConflictingProps.call(void 0, props, props.store);
117
+ _FJSZTIOUcjs.throwOnConflictingProps.call(void 0, props, props.store);
117
118
  const syncState = (_a = props.store) == null ? void 0 : _a.getState();
118
- const collection = _W5IQT6Z2cjs.createCollectionStore.call(void 0, props);
119
- const values = _RCYVACJOcjs.defaultValue.call(void 0,
119
+ const collection = _FFY2GSOGcjs.createCollectionStore.call(void 0, props);
120
+ const values = _3UT5FE6Kcjs.defaultValue.call(void 0,
120
121
  props.values,
121
122
  syncState == null ? void 0 : syncState.values,
122
123
  props.defaultValues,
123
124
  {}
124
125
  );
125
- const errors = _RCYVACJOcjs.defaultValue.call(void 0,
126
+ const errors = _3UT5FE6Kcjs.defaultValue.call(void 0,
126
127
  props.errors,
127
128
  syncState == null ? void 0 : syncState.errors,
128
129
  props.defaultErrors,
129
130
  {}
130
131
  );
131
- const touched = _RCYVACJOcjs.defaultValue.call(void 0,
132
+ const touched = _3UT5FE6Kcjs.defaultValue.call(void 0,
132
133
  props.touched,
133
134
  syncState == null ? void 0 : syncState.touched,
134
135
  props.defaultTouched,
135
136
  {}
136
137
  );
137
- const initialState = _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, collection.getState()), {
138
+ const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, collection.getState()), {
138
139
  values,
139
140
  errors,
140
141
  touched,
141
- validating: _RCYVACJOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.validating, false),
142
- submitting: _RCYVACJOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitting, false),
143
- submitSucceed: _RCYVACJOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitSucceed, 0),
144
- submitFailed: _RCYVACJOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
142
+ validating: _3UT5FE6Kcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.validating, false),
143
+ submitting: _3UT5FE6Kcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitting, false),
144
+ submitSucceed: _3UT5FE6Kcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitSucceed, 0),
145
+ submitFailed: _3UT5FE6Kcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
145
146
  valid: !hasMessages(errors)
146
147
  });
147
- const form = _A4GDJCZBcjs.createStore.call(void 0, initialState, collection, props.store);
148
+ const form = _FJSZTIOUcjs.createStore.call(void 0, initialState, collection, props.store);
148
149
  const syncCallbacks = getStoreCallbacks(props.store);
149
150
  const syncCallbacksState = syncCallbacks == null ? void 0 : syncCallbacks.getState();
150
151
  const callbacksInitialState = {
151
152
  validate: (syncCallbacksState == null ? void 0 : syncCallbacksState.validate) || [],
152
153
  submit: (syncCallbacksState == null ? void 0 : syncCallbacksState.submit) || []
153
154
  };
154
- const callbacks = _A4GDJCZBcjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
155
- _A4GDJCZBcjs.setup.call(void 0, form, () => _A4GDJCZBcjs.init.call(void 0, callbacks));
155
+ const callbacks = _FJSZTIOUcjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
156
+ _FJSZTIOUcjs.setup.call(void 0, form, () => _FJSZTIOUcjs.init.call(void 0, callbacks));
156
157
  const validate = async () => {
157
158
  form.setState("validating", true);
158
159
  form.setState("errors", {});
@@ -167,13 +168,13 @@ function createFormStore(props = {}) {
167
168
  form.setState("validating", false);
168
169
  }
169
170
  };
170
- return _72I2GWXFcjs.__spreadProps.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, _72I2GWXFcjs.__spreadValues.call(void 0, {}, collection), form), {
171
+ return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, collection), form), {
171
172
  names: createNames(),
172
173
  setValues: (values2) => form.setState("values", values2),
173
174
  getValue: (name) => get(form.getState().values, name),
174
175
  setValue: (name, value) => form.setState("values", (values2) => {
175
176
  const prevValue = get(values2, name);
176
- const nextValue = _RCYVACJOcjs.applyState.call(void 0, value, prevValue);
177
+ const nextValue = _3UT5FE6Kcjs.applyState.call(void 0, value, prevValue);
177
178
  if (nextValue === prevValue)
178
179
  return values2;
179
180
  return set(values2, name, nextValue);
@@ -194,7 +195,7 @@ function createFormStore(props = {}) {
194
195
  getError: (name) => get(form.getState().errors, name),
195
196
  setError: (name, error) => form.setState("errors", (errors2) => {
196
197
  const prevError = get(errors2, name);
197
- const nextError = _RCYVACJOcjs.applyState.call(void 0, error, prevError);
198
+ const nextError = _3UT5FE6Kcjs.applyState.call(void 0, error, prevError);
198
199
  if (nextError === prevError)
199
200
  return errors2;
200
201
  return set(errors2, name, nextError);
@@ -203,7 +204,7 @@ function createFormStore(props = {}) {
203
204
  getFieldTouched: (name) => !!get(form.getState().touched, name),
204
205
  setFieldTouched: (name, value) => form.setState("touched", (touched2) => {
205
206
  const prevValue = get(touched2, name);
206
- const nextValue = _RCYVACJOcjs.applyState.call(void 0, value, prevValue);
207
+ const nextValue = _3UT5FE6Kcjs.applyState.call(void 0, value, prevValue);
207
208
  if (nextValue === prevValue)
208
209
  return touched2;
209
210
  return set(touched2, name, nextValue);