@ariakit/core 0.3.2 → 0.3.4
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 +20 -0
- package/cjs/__chunks/{4L3HCXJY.cjs → 25WWT2VO.cjs} +17 -16
- package/cjs/__chunks/{EXM2AW52.cjs → FTB5CXVB.cjs} +3 -1
- package/cjs/__chunks/{EIRIJC7T.cjs → G5EW4WED.cjs} +8 -7
- package/cjs/__chunks/{RCYVACJO.cjs → LMT335NJ.cjs} +9 -4
- package/cjs/__chunks/LUOEAZGU.cjs +42 -0
- package/cjs/__chunks/{4OD4ZFRG.cjs → M44E4T5A.cjs} +30 -29
- package/cjs/__chunks/{GHET3DES.cjs → MLPOXRDT.cjs} +4 -3
- package/cjs/__chunks/{7GWXP6CQ.cjs → OASSVCYR.cjs} +43 -29
- package/cjs/__chunks/{AIHTEA5D.cjs → ROX3MRGO.cjs} +18 -17
- package/cjs/__chunks/{GDZQUFNP.cjs → ULSPM3Y3.cjs} +3 -1
- package/cjs/__chunks/{72I2GWXF.cjs → WYXAWBLE.cjs} +2 -1
- package/cjs/__chunks/{52LQV3SV.cjs → YXSGST3H.cjs} +23 -23
- package/cjs/checkbox/checkbox-store.cjs +9 -8
- package/cjs/checkbox/checkbox-store.d.cts +41 -0
- package/cjs/collection/collection-store.cjs +8 -7
- package/cjs/collection/collection-store.d.cts +65 -0
- package/cjs/combobox/combobox-store.cjs +37 -36
- package/cjs/combobox/combobox-store.d.cts +77 -0
- package/cjs/composite/composite-overflow-store.cjs +9 -8
- package/cjs/composite/composite-overflow-store.d.cts +10 -0
- package/cjs/composite/composite-store.cjs +10 -9
- package/cjs/composite/composite-store.d.cts +206 -0
- package/cjs/dialog/dialog-store.cjs +8 -7
- package/cjs/dialog/dialog-store.d.cts +10 -0
- package/cjs/disclosure/disclosure-store.cjs +7 -6
- package/cjs/disclosure/disclosure-store.d.cts +125 -0
- package/cjs/disclosure/disclosure-store.d.ts +1 -0
- package/cjs/form/form-store.cjs +30 -29
- package/cjs/form/form-store.d.cts +236 -0
- package/cjs/form/types.cjs +1 -1
- package/cjs/form/types.d.cts +38 -0
- package/cjs/hovercard/hovercard-store.cjs +10 -9
- package/cjs/hovercard/hovercard-store.d.cts +46 -0
- package/cjs/index.cjs +2 -1
- package/cjs/index.d.cts +2 -0
- package/cjs/menu/menu-bar-store.cjs +12 -11
- package/cjs/menu/menu-bar-store.d.cts +10 -0
- package/cjs/menu/menu-store.cjs +35 -34
- package/cjs/menu/menu-store.d.cts +78 -0
- package/cjs/popover/popover-store.cjs +9 -8
- package/cjs/popover/popover-store.d.cts +69 -0
- package/cjs/radio/radio-store.cjs +16 -15
- package/cjs/radio/radio-store.d.cts +36 -0
- package/cjs/select/select-store.cjs +37 -36
- package/cjs/select/select-store.d.cts +93 -0
- package/cjs/tab/tab-store.cjs +28 -27
- package/cjs/tab/tab-store.d.cts +87 -0
- package/cjs/toolbar/toolbar-store.cjs +12 -11
- package/cjs/toolbar/toolbar-store.d.cts +21 -0
- package/cjs/tooltip/tooltip-store.cjs +17 -16
- package/cjs/tooltip/tooltip-store.d.cts +29 -0
- package/cjs/utils/array.cjs +5 -4
- package/cjs/utils/array.d.cts +29 -0
- package/cjs/utils/dom.cjs +5 -4
- package/cjs/utils/dom.d.cts +105 -0
- package/cjs/utils/events.cjs +10 -9
- package/cjs/utils/events.d.cts +70 -0
- package/cjs/utils/focus.cjs +17 -16
- package/cjs/utils/focus.d.cts +117 -0
- package/cjs/utils/misc.cjs +7 -4
- package/cjs/utils/misc.d.cts +124 -0
- package/cjs/utils/misc.d.ts +7 -0
- package/cjs/utils/platform.cjs +6 -5
- package/cjs/utils/platform.d.cts +20 -0
- package/cjs/utils/store.cjs +6 -5
- package/cjs/utils/store.d.cts +71 -0
- package/cjs/utils/types.cjs +1 -1
- package/cjs/utils/types.d.cts +74 -0
- package/esm/__chunks/{PNRLI7OV.js → 2SMRF6AD.js} +1 -0
- package/esm/__chunks/{UCFCIHEU.js → 5UJPJ37G.js} +2 -1
- package/esm/__chunks/{5XEKIOCW.js → 7PRQYBBV.js} +2 -0
- package/esm/__chunks/{WVTCK5PV.js → D23ES3Z4.js} +6 -1
- package/esm/__chunks/{BL2LUIIN.js → FGW7QUD2.js} +6 -5
- package/esm/__chunks/{DEGIJZ7N.js → GME4NYXR.js} +28 -14
- package/esm/__chunks/{BE4I5ZDQ.js → I7YGHQ4Z.js} +2 -1
- package/esm/__chunks/{A2JA3CYE.js → LWQU4J4N.js} +5 -4
- package/esm/__chunks/{O35LWD4W.js → NIF7E7VE.js} +2 -0
- package/esm/__chunks/{STQCKYT6.js → Q332EHXG.js} +5 -4
- package/esm/__chunks/{OZ4NH3RO.js → TEJLMP2M.js} +8 -8
- package/esm/__chunks/{LTJQMYBN.js → VEWADM34.js} +5 -4
- package/esm/checkbox/checkbox-store.js +4 -3
- package/esm/collection/collection-store.js +6 -5
- package/esm/combobox/combobox-store.js +12 -11
- package/esm/composite/composite-overflow-store.js +7 -6
- package/esm/composite/composite-store.js +8 -7
- package/esm/dialog/dialog-store.js +6 -5
- package/esm/disclosure/disclosure-store.d.ts +1 -0
- package/esm/disclosure/disclosure-store.js +5 -4
- package/esm/form/form-store.js +6 -5
- package/esm/form/types.js +1 -0
- package/esm/hovercard/hovercard-store.js +8 -7
- package/esm/index.js +2 -1
- package/esm/menu/menu-bar-store.js +8 -7
- package/esm/menu/menu-store.js +12 -11
- package/esm/popover/popover-store.js +7 -6
- package/esm/radio/radio-store.js +8 -7
- package/esm/select/select-store.js +11 -10
- package/esm/tab/tab-store.js +8 -7
- package/esm/toolbar/toolbar-store.js +8 -7
- package/esm/tooltip/tooltip-store.js +8 -7
- package/esm/utils/array.js +3 -2
- package/esm/utils/dom.js +3 -2
- package/esm/utils/events.js +4 -3
- package/esm/utils/focus.js +3 -2
- package/esm/utils/misc.d.ts +7 -0
- package/esm/utils/misc.js +5 -2
- package/esm/utils/platform.js +4 -3
- package/esm/utils/store.js +4 -3
- package/esm/utils/types.js +1 -0
- package/package.json +109 -28
- package/cjs/__chunks/ZRCUNIY2.cjs +0 -41
- package/cjs/tsconfig.build.tsbuildinfo +0 -1
- 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 _GHET3DEScjs = require('../__chunks/GHET3DES.cjs');
|
|
4
|
-
require('../__chunks/52LQV3SV.cjs');
|
|
5
|
-
require('../__chunks/7GWXP6CQ.cjs');
|
|
6
|
-
require('../__chunks/RCYVACJO.cjs');
|
|
7
|
-
require('../__chunks/72I2GWXF.cjs');
|
|
8
3
|
|
|
4
|
+
var _MLPOXRDTcjs = require('../__chunks/MLPOXRDT.cjs');
|
|
5
|
+
require('../__chunks/YXSGST3H.cjs');
|
|
6
|
+
require('../__chunks/OASSVCYR.cjs');
|
|
7
|
+
require('../__chunks/LMT335NJ.cjs');
|
|
8
|
+
require('../__chunks/WYXAWBLE.cjs');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
|
|
11
|
+
exports.createDialogStore = _MLPOXRDTcjs.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 _52LQV3SVcjs = require('../__chunks/52LQV3SV.cjs');
|
|
4
|
-
require('../__chunks/7GWXP6CQ.cjs');
|
|
5
|
-
require('../__chunks/RCYVACJO.cjs');
|
|
6
|
-
require('../__chunks/72I2GWXF.cjs');
|
|
7
3
|
|
|
4
|
+
var _YXSGST3Hcjs = require('../__chunks/YXSGST3H.cjs');
|
|
5
|
+
require('../__chunks/OASSVCYR.cjs');
|
|
6
|
+
require('../__chunks/LMT335NJ.cjs');
|
|
7
|
+
require('../__chunks/WYXAWBLE.cjs');
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
exports.createDisclosureStore = _YXSGST3Hcjs.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>;
|
|
@@ -85,6 +85,7 @@ export interface DisclosureStoreFunctions {
|
|
|
85
85
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
86
86
|
* - [Dialog with React
|
|
87
87
|
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
88
|
+
* - [Sliding Menu](https://ariakit.org/examples/menu-slide)
|
|
88
89
|
*/
|
|
89
90
|
hide: () => void;
|
|
90
91
|
/**
|
package/cjs/form/form-store.cjs
CHANGED
|
@@ -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 _4L3HCXJYcjs = require('../__chunks/4L3HCXJY.cjs');
|
|
4
3
|
|
|
4
|
+
var _25WWT2VOcjs = require('../__chunks/25WWT2VO.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var _7GWXP6CQcjs = require('../__chunks/7GWXP6CQ.cjs');
|
|
10
9
|
|
|
10
|
+
var _OASSVCYRcjs = require('../__chunks/OASSVCYR.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 _LMT335NJcjs = require('../__chunks/LMT335NJ.cjs');
|
|
17
|
+
require('../__chunks/FTB5CXVB.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
var _WYXAWBLEcjs = require('../__chunks/WYXAWBLE.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 (
|
|
29
|
+
if (_LMT335NJcjs.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 =
|
|
51
|
+
const isIntegerKey = _LMT335NJcjs.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) ||
|
|
54
|
+
const result = rest.length && (Array.isArray(nestedValues) || _LMT335NJcjs.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
|
|
68
|
+
return _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__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 (
|
|
77
|
+
if (_LMT335NJcjs.isObject.call(void 0, v)) {
|
|
77
78
|
return setAll(v, value);
|
|
78
79
|
}
|
|
79
80
|
return value;
|
|
80
81
|
});
|
|
81
|
-
} else if (
|
|
82
|
+
} else if (_LMT335NJcjs.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
|
-
|
|
117
|
+
_OASSVCYRcjs.throwOnConflictingProps.call(void 0, props, props.store);
|
|
117
118
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
118
|
-
const collection =
|
|
119
|
-
const values =
|
|
119
|
+
const collection = _25WWT2VOcjs.createCollectionStore.call(void 0, props);
|
|
120
|
+
const values = _LMT335NJcjs.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 =
|
|
126
|
+
const errors = _LMT335NJcjs.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 =
|
|
132
|
+
const touched = _LMT335NJcjs.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 =
|
|
138
|
+
const initialState = _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, {}, collection.getState()), {
|
|
138
139
|
values,
|
|
139
140
|
errors,
|
|
140
141
|
touched,
|
|
141
|
-
validating:
|
|
142
|
-
submitting:
|
|
143
|
-
submitSucceed:
|
|
144
|
-
submitFailed:
|
|
142
|
+
validating: _LMT335NJcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.validating, false),
|
|
143
|
+
submitting: _LMT335NJcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitting, false),
|
|
144
|
+
submitSucceed: _LMT335NJcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitSucceed, 0),
|
|
145
|
+
submitFailed: _LMT335NJcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
|
|
145
146
|
valid: !hasMessages(errors)
|
|
146
147
|
});
|
|
147
|
-
const form =
|
|
148
|
+
const form = _OASSVCYRcjs.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 =
|
|
155
|
-
|
|
155
|
+
const callbacks = _OASSVCYRcjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
|
|
156
|
+
_OASSVCYRcjs.setup.call(void 0, form, () => _OASSVCYRcjs.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
|
|
171
|
+
return _WYXAWBLEcjs.__spreadProps.call(void 0, _WYXAWBLEcjs.__spreadValues.call(void 0, _WYXAWBLEcjs.__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 =
|
|
177
|
+
const nextValue = _LMT335NJcjs.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 =
|
|
198
|
+
const nextError = _LMT335NJcjs.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 =
|
|
207
|
+
const nextValue = _LMT335NJcjs.applyState.call(void 0, value, prevValue);
|
|
207
208
|
if (nextValue === prevValue)
|
|
208
209
|
return touched2;
|
|
209
210
|
return set(touched2, name, nextValue);
|