@ariakit/core 0.3.9 → 0.3.11
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 +15 -0
- package/cjs/__chunks/{JNFZSNOI.cjs → BFE5R4EZ.cjs} +17 -17
- package/cjs/__chunks/{EFIT5L4X.cjs → E53JW5BD.cjs} +12 -12
- package/cjs/__chunks/{2UK5WUJX.cjs → F6HPKLO2.cjs} +12 -14
- package/cjs/__chunks/{2LS4JJ4S.cjs → I3Y4EXEF.cjs} +2 -2
- package/cjs/__chunks/{3UT5FE6K.cjs → KBNYGXWI.cjs} +3 -0
- package/cjs/__chunks/{UCLKUBNP.cjs → MI6NUQYQ.cjs} +31 -18
- package/cjs/__chunks/{UTICNXST.cjs → NOFH2BLB.cjs} +7 -7
- package/cjs/__chunks/{GJFZ5ZPP.cjs → OTVLDMN2.cjs} +16 -16
- package/cjs/__chunks/{5SIVMOID.cjs → TQTGWD5K.cjs} +10 -10
- package/cjs/checkbox/checkbox-store.cjs +5 -5
- package/cjs/checkbox/checkbox-store.d.cts +5 -2
- package/cjs/checkbox/checkbox-store.d.ts +5 -2
- package/cjs/collection/collection-store.cjs +4 -4
- package/cjs/collection/collection-store.d.cts +11 -11
- package/cjs/collection/collection-store.d.ts +11 -11
- package/cjs/combobox/combobox-store.cjs +32 -32
- package/cjs/combobox/combobox-store.d.cts +3 -1
- package/cjs/combobox/combobox-store.d.ts +3 -1
- package/cjs/composite/composite-overflow-store.cjs +6 -6
- package/cjs/composite/composite-store.cjs +5 -5
- package/cjs/composite/composite-store.d.cts +128 -54
- package/cjs/composite/composite-store.d.ts +128 -54
- package/cjs/dialog/dialog-store.cjs +5 -5
- package/cjs/disclosure/disclosure-store.cjs +4 -4
- package/cjs/disclosure/disclosure-store.d.cts +33 -27
- package/cjs/disclosure/disclosure-store.d.ts +33 -27
- package/cjs/form/form-store.cjs +23 -23
- package/cjs/form/form-store.d.cts +35 -26
- package/cjs/form/form-store.d.ts +35 -26
- package/cjs/hovercard/hovercard-store.cjs +7 -7
- package/cjs/hovercard/hovercard-store.d.cts +14 -7
- package/cjs/hovercard/hovercard-store.d.ts +14 -7
- package/cjs/menu/menu-bar-store.cjs +6 -6
- package/cjs/menu/menu-store.cjs +26 -26
- package/cjs/menu/menu-store.d.cts +16 -7
- package/cjs/menu/menu-store.d.ts +16 -7
- package/cjs/menubar/menubar-store.cjs +6 -6
- package/cjs/popover/popover-store.cjs +6 -6
- package/cjs/popover/popover-store.d.cts +31 -6
- package/cjs/popover/popover-store.d.ts +31 -6
- package/cjs/radio/radio-store.cjs +8 -8
- package/cjs/radio/radio-store.d.cts +2 -1
- package/cjs/radio/radio-store.d.ts +2 -1
- package/cjs/select/select-store.cjs +28 -28
- package/cjs/select/select-store.d.cts +2 -1
- package/cjs/select/select-store.d.ts +2 -1
- package/cjs/tab/tab-store.cjs +20 -20
- package/cjs/tab/tab-store.d.cts +20 -15
- package/cjs/tab/tab-store.d.ts +20 -15
- package/cjs/toolbar/toolbar-store.cjs +7 -7
- package/cjs/toolbar/toolbar-store.d.cts +2 -6
- package/cjs/toolbar/toolbar-store.d.ts +2 -6
- package/cjs/tooltip/tooltip-store.cjs +12 -12
- package/cjs/tooltip/tooltip-store.d.cts +6 -4
- package/cjs/tooltip/tooltip-store.d.ts +6 -4
- package/cjs/utils/misc.cjs +2 -2
- package/cjs/utils/store.cjs +3 -3
- package/esm/__chunks/{TLN4ALYH.js → 22K762VQ.js} +22 -9
- package/esm/__chunks/{J6JIOWCS.js → AF6IUUFN.js} +3 -3
- package/esm/__chunks/{A2J4XZ5T.js → EAHJFCU4.js} +1 -3
- package/esm/__chunks/{DLX2AS6C.js → IERTEJ3A.js} +3 -3
- package/esm/__chunks/{T3DVYGXI.js → SOLWE6E5.js} +3 -3
- package/esm/__chunks/{LT2OYWRD.js → SX2XFD6A.js} +1 -1
- package/esm/__chunks/{EZ2TTBAQ.js → XU3EOSCU.js} +3 -3
- package/esm/__chunks/{I2VQ3XGR.js → Y3OOHFCN.js} +3 -0
- package/esm/__chunks/{NKLTHWCR.js → Z5IGYIPT.js} +2 -2
- package/esm/checkbox/checkbox-store.d.ts +5 -2
- package/esm/checkbox/checkbox-store.js +2 -2
- package/esm/collection/collection-store.d.ts +11 -11
- package/esm/collection/collection-store.js +3 -3
- package/esm/combobox/combobox-store.d.ts +3 -1
- package/esm/combobox/combobox-store.js +7 -7
- package/esm/composite/composite-overflow-store.js +5 -5
- package/esm/composite/composite-store.d.ts +128 -54
- package/esm/composite/composite-store.js +4 -4
- package/esm/dialog/dialog-store.js +4 -4
- package/esm/disclosure/disclosure-store.d.ts +33 -27
- package/esm/disclosure/disclosure-store.js +3 -3
- package/esm/form/form-store.d.ts +35 -26
- package/esm/form/form-store.js +3 -3
- package/esm/hovercard/hovercard-store.d.ts +14 -7
- package/esm/hovercard/hovercard-store.js +6 -6
- package/esm/menu/menu-bar-store.js +5 -5
- package/esm/menu/menu-store.d.ts +16 -7
- package/esm/menu/menu-store.js +8 -8
- package/esm/menubar/menubar-store.js +5 -5
- package/esm/popover/popover-store.d.ts +31 -6
- package/esm/popover/popover-store.js +5 -5
- package/esm/radio/radio-store.d.ts +2 -1
- package/esm/radio/radio-store.js +4 -4
- package/esm/select/select-store.d.ts +2 -1
- package/esm/select/select-store.js +7 -7
- package/esm/tab/tab-store.d.ts +20 -15
- package/esm/tab/tab-store.js +4 -4
- package/esm/toolbar/toolbar-store.d.ts +2 -6
- package/esm/toolbar/toolbar-store.js +4 -4
- package/esm/tooltip/tooltip-store.d.ts +6 -4
- package/esm/tooltip/tooltip-store.js +6 -6
- package/esm/utils/misc.js +1 -1
- package/esm/utils/store.js +2 -2
- package/package.json +1 -1
|
@@ -6,40 +6,38 @@ import type { SetState } from "../utils/types.js";
|
|
|
6
6
|
export declare function createDisclosureStore(props?: DisclosureStoreProps): DisclosureStore;
|
|
7
7
|
export interface DisclosureStoreState {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Whether the content is visible.
|
|
10
10
|
*
|
|
11
11
|
* Live examples:
|
|
12
|
+
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
12
13
|
* - [Dialog with React
|
|
13
14
|
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
15
|
+
* - [Menu with Framer
|
|
16
|
+
* Motion](https://ariakit.org/examples/menu-framer-motion)
|
|
17
|
+
* - [Lazy Popover](https://ariakit.org/examples/popover-lazy)
|
|
14
18
|
* @default false
|
|
15
19
|
*/
|
|
16
20
|
open: boolean;
|
|
17
21
|
/**
|
|
18
|
-
* The mounted state
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* The mounted state usually matches the
|
|
23
|
+
* [`open`](https://ariakit.org/reference/disclosure-provider#open) value.
|
|
24
|
+
* However, if the content element is animated, it waits for the animation to
|
|
25
|
+
* finish before turning `false`. This ensures the content element doesn't get
|
|
26
|
+
* unmounted during the animation.
|
|
22
27
|
*
|
|
23
28
|
* Live examples:
|
|
24
|
-
* - [
|
|
25
|
-
* - [
|
|
26
|
-
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
29
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
30
|
+
* - [Responsive Popover](https://ariakit.org/examples/popover-responsive)
|
|
27
31
|
*/
|
|
28
32
|
mounted: boolean;
|
|
29
33
|
/**
|
|
30
34
|
* Determines whether the content should animate when it is shown or hidden.
|
|
31
35
|
* - If `true`, the `animating` state will be `true` when the content is shown
|
|
32
|
-
* or hidden and it will wait for
|
|
33
|
-
*
|
|
36
|
+
* or hidden and it will wait for a CSS animation/transition to end before
|
|
37
|
+
* becoming `false`.
|
|
34
38
|
* - If it's set to a number, the `animating` state will be `true` when the
|
|
35
39
|
* content is shown or hidden and it will wait for the number of
|
|
36
40
|
* milliseconds to pass before becoming `false`.
|
|
37
|
-
*
|
|
38
|
-
* Live examples:
|
|
39
|
-
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
40
|
-
* - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
|
|
41
|
-
* - [Animated Dialog](https://ariakit.org/examples/dialog-animated)
|
|
42
|
-
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
|
43
41
|
* @default false
|
|
44
42
|
*/
|
|
45
43
|
animated: boolean | number;
|
|
@@ -58,46 +56,50 @@ export interface DisclosureStoreState {
|
|
|
58
56
|
}
|
|
59
57
|
export interface DisclosureStoreFunctions {
|
|
60
58
|
/**
|
|
61
|
-
* Sets the `open`
|
|
59
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
60
|
+
* state.
|
|
62
61
|
*
|
|
63
62
|
* Live examples:
|
|
64
63
|
* - [Textarea with inline
|
|
65
64
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
66
|
-
* - [Dialog with React
|
|
67
|
-
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
68
65
|
* @example
|
|
69
66
|
* store.setOpen(true);
|
|
70
67
|
* store.setOpen((open) => !open);
|
|
71
68
|
*/
|
|
72
69
|
setOpen: SetState<DisclosureStoreState["open"]>;
|
|
73
70
|
/**
|
|
74
|
-
* Sets the `open`
|
|
71
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
72
|
+
* state to `true`.
|
|
75
73
|
*
|
|
76
74
|
* Live examples:
|
|
77
|
-
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
78
75
|
* - [Textarea with inline
|
|
79
76
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
77
|
+
* - [Dialog with Framer
|
|
78
|
+
* Motion](https://ariakit.org/examples/dialog-framer-motion)
|
|
79
|
+
* - [Context Menu](https://ariakit.org/examples/menu-context-menu)
|
|
80
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
80
81
|
*/
|
|
81
82
|
show: () => void;
|
|
82
83
|
/**
|
|
83
|
-
* Sets the `open`
|
|
84
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
85
|
+
* state to `false`.
|
|
84
86
|
*
|
|
85
87
|
* Live examples:
|
|
86
88
|
* - [Textarea with inline
|
|
87
89
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
88
|
-
* - [Dialog with React
|
|
89
|
-
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
90
90
|
* - [Sliding Menu](https://ariakit.org/examples/menu-slide)
|
|
91
91
|
*/
|
|
92
92
|
hide: () => void;
|
|
93
93
|
/**
|
|
94
|
-
* Toggles the
|
|
94
|
+
* Toggles the
|
|
95
|
+
* [`open`](https://ariakit.org/reference/disclosure-provider#open) state.
|
|
95
96
|
*/
|
|
96
97
|
toggle: () => void;
|
|
97
98
|
/**
|
|
98
99
|
* Sets the `animating` state to `false`, which will automatically set the
|
|
99
100
|
* `mounted` state to `false` if it was `true`. This means that the content
|
|
100
101
|
* element can be safely unmounted.
|
|
102
|
+
* @deprecated Use `setState("animating", false)` instead.
|
|
101
103
|
*/
|
|
102
104
|
stopAnimation: () => void;
|
|
103
105
|
/**
|
|
@@ -106,19 +108,23 @@ export interface DisclosureStoreFunctions {
|
|
|
106
108
|
setContentElement: SetState<DisclosureStoreState["contentElement"]>;
|
|
107
109
|
/**
|
|
108
110
|
* Sets the `disclosureElement` state.
|
|
111
|
+
*
|
|
112
|
+
* Live examples:
|
|
113
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
109
114
|
*/
|
|
110
115
|
setDisclosureElement: SetState<DisclosureStoreState["disclosureElement"]>;
|
|
111
116
|
}
|
|
112
117
|
export interface DisclosureStoreOptions extends StoreOptions<DisclosureStoreState, "open" | "animated"> {
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
119
|
+
* Whether the content should be visible by default.
|
|
115
120
|
* @default false
|
|
116
121
|
*/
|
|
117
122
|
defaultOpen?: DisclosureStoreState["open"];
|
|
118
123
|
/**
|
|
119
124
|
* A reference to another disclosure store that controls another disclosure
|
|
120
125
|
* component to keep them in sync. Element states like `contentElement` and
|
|
121
|
-
* `disclosureElement` won't be synced. For that, use the
|
|
126
|
+
* `disclosureElement` won't be synced. For that, use the
|
|
127
|
+
* [`store`](https://ariakit.org/reference/disclosure-provider#store) prop
|
|
122
128
|
* instead.
|
|
123
129
|
*/
|
|
124
130
|
disclosure?: DisclosureStore | null;
|
|
@@ -6,40 +6,38 @@ import type { SetState } from "../utils/types.js";
|
|
|
6
6
|
export declare function createDisclosureStore(props?: DisclosureStoreProps): DisclosureStore;
|
|
7
7
|
export interface DisclosureStoreState {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Whether the content is visible.
|
|
10
10
|
*
|
|
11
11
|
* Live examples:
|
|
12
|
+
* - [Combobox with links](https://ariakit.org/examples/combobox-links)
|
|
12
13
|
* - [Dialog with React
|
|
13
14
|
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
15
|
+
* - [Menu with Framer
|
|
16
|
+
* Motion](https://ariakit.org/examples/menu-framer-motion)
|
|
17
|
+
* - [Lazy Popover](https://ariakit.org/examples/popover-lazy)
|
|
14
18
|
* @default false
|
|
15
19
|
*/
|
|
16
20
|
open: boolean;
|
|
17
21
|
/**
|
|
18
|
-
* The mounted state
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* The mounted state usually matches the
|
|
23
|
+
* [`open`](https://ariakit.org/reference/disclosure-provider#open) value.
|
|
24
|
+
* However, if the content element is animated, it waits for the animation to
|
|
25
|
+
* finish before turning `false`. This ensures the content element doesn't get
|
|
26
|
+
* unmounted during the animation.
|
|
22
27
|
*
|
|
23
28
|
* Live examples:
|
|
24
|
-
* - [
|
|
25
|
-
* - [
|
|
26
|
-
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
29
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
30
|
+
* - [Responsive Popover](https://ariakit.org/examples/popover-responsive)
|
|
27
31
|
*/
|
|
28
32
|
mounted: boolean;
|
|
29
33
|
/**
|
|
30
34
|
* Determines whether the content should animate when it is shown or hidden.
|
|
31
35
|
* - If `true`, the `animating` state will be `true` when the content is shown
|
|
32
|
-
* or hidden and it will wait for
|
|
33
|
-
*
|
|
36
|
+
* or hidden and it will wait for a CSS animation/transition to end before
|
|
37
|
+
* becoming `false`.
|
|
34
38
|
* - If it's set to a number, the `animating` state will be `true` when the
|
|
35
39
|
* content is shown or hidden and it will wait for the number of
|
|
36
40
|
* milliseconds to pass before becoming `false`.
|
|
37
|
-
*
|
|
38
|
-
* Live examples:
|
|
39
|
-
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
40
|
-
* - [Animated Combobox](https://ariakit.org/examples/combobox-animated)
|
|
41
|
-
* - [Animated Dialog](https://ariakit.org/examples/dialog-animated)
|
|
42
|
-
* - [Animated Select](https://ariakit.org/examples/select-animated)
|
|
43
41
|
* @default false
|
|
44
42
|
*/
|
|
45
43
|
animated: boolean | number;
|
|
@@ -58,46 +56,50 @@ export interface DisclosureStoreState {
|
|
|
58
56
|
}
|
|
59
57
|
export interface DisclosureStoreFunctions {
|
|
60
58
|
/**
|
|
61
|
-
* Sets the `open`
|
|
59
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
60
|
+
* state.
|
|
62
61
|
*
|
|
63
62
|
* Live examples:
|
|
64
63
|
* - [Textarea with inline
|
|
65
64
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
66
|
-
* - [Dialog with React
|
|
67
|
-
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
68
65
|
* @example
|
|
69
66
|
* store.setOpen(true);
|
|
70
67
|
* store.setOpen((open) => !open);
|
|
71
68
|
*/
|
|
72
69
|
setOpen: SetState<DisclosureStoreState["open"]>;
|
|
73
70
|
/**
|
|
74
|
-
* Sets the `open`
|
|
71
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
72
|
+
* state to `true`.
|
|
75
73
|
*
|
|
76
74
|
* Live examples:
|
|
77
|
-
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
78
75
|
* - [Textarea with inline
|
|
79
76
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
77
|
+
* - [Dialog with Framer
|
|
78
|
+
* Motion](https://ariakit.org/examples/dialog-framer-motion)
|
|
79
|
+
* - [Context Menu](https://ariakit.org/examples/menu-context-menu)
|
|
80
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
80
81
|
*/
|
|
81
82
|
show: () => void;
|
|
82
83
|
/**
|
|
83
|
-
* Sets the `open`
|
|
84
|
+
* Sets the [`open`](https://ariakit.org/reference/disclosure-provider#open)
|
|
85
|
+
* state to `false`.
|
|
84
86
|
*
|
|
85
87
|
* Live examples:
|
|
86
88
|
* - [Textarea with inline
|
|
87
89
|
* Combobox](https://ariakit.org/examples/combobox-textarea)
|
|
88
|
-
* - [Dialog with React
|
|
89
|
-
* Router](https://ariakit.org/examples/dialog-react-router)
|
|
90
90
|
* - [Sliding Menu](https://ariakit.org/examples/menu-slide)
|
|
91
91
|
*/
|
|
92
92
|
hide: () => void;
|
|
93
93
|
/**
|
|
94
|
-
* Toggles the
|
|
94
|
+
* Toggles the
|
|
95
|
+
* [`open`](https://ariakit.org/reference/disclosure-provider#open) state.
|
|
95
96
|
*/
|
|
96
97
|
toggle: () => void;
|
|
97
98
|
/**
|
|
98
99
|
* Sets the `animating` state to `false`, which will automatically set the
|
|
99
100
|
* `mounted` state to `false` if it was `true`. This means that the content
|
|
100
101
|
* element can be safely unmounted.
|
|
102
|
+
* @deprecated Use `setState("animating", false)` instead.
|
|
101
103
|
*/
|
|
102
104
|
stopAnimation: () => void;
|
|
103
105
|
/**
|
|
@@ -106,19 +108,23 @@ export interface DisclosureStoreFunctions {
|
|
|
106
108
|
setContentElement: SetState<DisclosureStoreState["contentElement"]>;
|
|
107
109
|
/**
|
|
108
110
|
* Sets the `disclosureElement` state.
|
|
111
|
+
*
|
|
112
|
+
* Live examples:
|
|
113
|
+
* - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
|
|
109
114
|
*/
|
|
110
115
|
setDisclosureElement: SetState<DisclosureStoreState["disclosureElement"]>;
|
|
111
116
|
}
|
|
112
117
|
export interface DisclosureStoreOptions extends StoreOptions<DisclosureStoreState, "open" | "animated"> {
|
|
113
118
|
/**
|
|
114
|
-
*
|
|
119
|
+
* Whether the content should be visible by default.
|
|
115
120
|
* @default false
|
|
116
121
|
*/
|
|
117
122
|
defaultOpen?: DisclosureStoreState["open"];
|
|
118
123
|
/**
|
|
119
124
|
* A reference to another disclosure store that controls another disclosure
|
|
120
125
|
* component to keep them in sync. Element states like `contentElement` and
|
|
121
|
-
* `disclosureElement` won't be synced. For that, use the
|
|
126
|
+
* `disclosureElement` won't be synced. For that, use the
|
|
127
|
+
* [`store`](https://ariakit.org/reference/disclosure-provider#store) prop
|
|
122
128
|
* instead.
|
|
123
129
|
*/
|
|
124
130
|
disclosure?: DisclosureStore | null;
|
package/cjs/form/form-store.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _MI6NUQYQcjs = require('../__chunks/MI6NUQYQ.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _F6HPKLO2cjs = require('../__chunks/F6HPKLO2.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _KBNYGXWIcjs = require('../__chunks/KBNYGXWI.cjs');
|
|
17
17
|
require('../__chunks/5F4DVUNS.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
@@ -26,7 +26,7 @@ function nextFrame() {
|
|
|
26
26
|
}
|
|
27
27
|
function hasMessages(object) {
|
|
28
28
|
return Object.keys(object).some((key) => {
|
|
29
|
-
if (
|
|
29
|
+
if (_KBNYGXWIcjs.isObject.call(void 0, object[key])) {
|
|
30
30
|
return hasMessages(object[key]);
|
|
31
31
|
}
|
|
32
32
|
return !!object[key];
|
|
@@ -48,10 +48,10 @@ function set(values, path, value) {
|
|
|
48
48
|
if (k == null)
|
|
49
49
|
return values;
|
|
50
50
|
const key = k;
|
|
51
|
-
const isIntegerKey =
|
|
51
|
+
const isIntegerKey = _KBNYGXWIcjs.isInteger.call(void 0, key);
|
|
52
52
|
const nextValues = isIntegerKey ? values || [] : values || {};
|
|
53
53
|
const nestedValues = nextValues[key];
|
|
54
|
-
const result = rest.length && (Array.isArray(nestedValues) ||
|
|
54
|
+
const result = rest.length && (Array.isArray(nestedValues) || _KBNYGXWIcjs.isObject.call(void 0, nestedValues)) ? set(nestedValues, rest, value) : value;
|
|
55
55
|
if (isIntegerKey) {
|
|
56
56
|
const index = Number(key);
|
|
57
57
|
if (values && Array.isArray(values)) {
|
|
@@ -74,12 +74,12 @@ function setAll(values, value) {
|
|
|
74
74
|
const currentValue = values[key];
|
|
75
75
|
if (Array.isArray(currentValue)) {
|
|
76
76
|
result[key] = currentValue.map((v) => {
|
|
77
|
-
if (
|
|
77
|
+
if (_KBNYGXWIcjs.isObject.call(void 0, v)) {
|
|
78
78
|
return setAll(v, value);
|
|
79
79
|
}
|
|
80
80
|
return value;
|
|
81
81
|
});
|
|
82
|
-
} else if (
|
|
82
|
+
} else if (_KBNYGXWIcjs.isObject.call(void 0, currentValue)) {
|
|
83
83
|
result[key] = setAll(currentValue, value);
|
|
84
84
|
} else {
|
|
85
85
|
result[key] = value;
|
|
@@ -114,22 +114,22 @@ function createNames() {
|
|
|
114
114
|
}
|
|
115
115
|
function createFormStore(props = {}) {
|
|
116
116
|
var _a;
|
|
117
|
-
|
|
117
|
+
_F6HPKLO2cjs.throwOnConflictingProps.call(void 0, props, props.store);
|
|
118
118
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
119
|
-
const collection =
|
|
120
|
-
const values =
|
|
119
|
+
const collection = _MI6NUQYQcjs.createCollectionStore.call(void 0, props);
|
|
120
|
+
const values = _KBNYGXWIcjs.defaultValue.call(void 0,
|
|
121
121
|
props.values,
|
|
122
122
|
syncState == null ? void 0 : syncState.values,
|
|
123
123
|
props.defaultValues,
|
|
124
124
|
{}
|
|
125
125
|
);
|
|
126
|
-
const errors =
|
|
126
|
+
const errors = _KBNYGXWIcjs.defaultValue.call(void 0,
|
|
127
127
|
props.errors,
|
|
128
128
|
syncState == null ? void 0 : syncState.errors,
|
|
129
129
|
props.defaultErrors,
|
|
130
130
|
{}
|
|
131
131
|
);
|
|
132
|
-
const touched =
|
|
132
|
+
const touched = _KBNYGXWIcjs.defaultValue.call(void 0,
|
|
133
133
|
props.touched,
|
|
134
134
|
syncState == null ? void 0 : syncState.touched,
|
|
135
135
|
props.defaultTouched,
|
|
@@ -139,21 +139,21 @@ function createFormStore(props = {}) {
|
|
|
139
139
|
values,
|
|
140
140
|
errors,
|
|
141
141
|
touched,
|
|
142
|
-
validating:
|
|
143
|
-
submitting:
|
|
144
|
-
submitSucceed:
|
|
145
|
-
submitFailed:
|
|
142
|
+
validating: _KBNYGXWIcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.validating, false),
|
|
143
|
+
submitting: _KBNYGXWIcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitting, false),
|
|
144
|
+
submitSucceed: _KBNYGXWIcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitSucceed, 0),
|
|
145
|
+
submitFailed: _KBNYGXWIcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
|
|
146
146
|
valid: !hasMessages(errors)
|
|
147
147
|
});
|
|
148
|
-
const form =
|
|
148
|
+
const form = _F6HPKLO2cjs.createStore.call(void 0, initialState, collection, props.store);
|
|
149
149
|
const syncCallbacks = getStoreCallbacks(props.store);
|
|
150
150
|
const syncCallbacksState = syncCallbacks == null ? void 0 : syncCallbacks.getState();
|
|
151
151
|
const callbacksInitialState = {
|
|
152
152
|
validate: (syncCallbacksState == null ? void 0 : syncCallbacksState.validate) || [],
|
|
153
153
|
submit: (syncCallbacksState == null ? void 0 : syncCallbacksState.submit) || []
|
|
154
154
|
};
|
|
155
|
-
const callbacks =
|
|
156
|
-
|
|
155
|
+
const callbacks = _F6HPKLO2cjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
|
|
156
|
+
_F6HPKLO2cjs.setup.call(void 0, form, () => _F6HPKLO2cjs.init.call(void 0, callbacks));
|
|
157
157
|
const validate = async () => {
|
|
158
158
|
form.setState("validating", true);
|
|
159
159
|
form.setState("errors", {});
|
|
@@ -174,7 +174,7 @@ function createFormStore(props = {}) {
|
|
|
174
174
|
getValue: (name) => get(form.getState().values, name),
|
|
175
175
|
setValue: (name, value) => form.setState("values", (values2) => {
|
|
176
176
|
const prevValue = get(values2, name);
|
|
177
|
-
const nextValue =
|
|
177
|
+
const nextValue = _KBNYGXWIcjs.applyState.call(void 0, value, prevValue);
|
|
178
178
|
if (nextValue === prevValue)
|
|
179
179
|
return values2;
|
|
180
180
|
return set(values2, name, nextValue);
|
|
@@ -195,7 +195,7 @@ function createFormStore(props = {}) {
|
|
|
195
195
|
getError: (name) => get(form.getState().errors, name),
|
|
196
196
|
setError: (name, error) => form.setState("errors", (errors2) => {
|
|
197
197
|
const prevError = get(errors2, name);
|
|
198
|
-
const nextError =
|
|
198
|
+
const nextError = _KBNYGXWIcjs.applyState.call(void 0, error, prevError);
|
|
199
199
|
if (nextError === prevError)
|
|
200
200
|
return errors2;
|
|
201
201
|
return set(errors2, name, nextError);
|
|
@@ -204,7 +204,7 @@ function createFormStore(props = {}) {
|
|
|
204
204
|
getFieldTouched: (name) => !!get(form.getState().touched, name),
|
|
205
205
|
setFieldTouched: (name, value) => form.setState("touched", (touched2) => {
|
|
206
206
|
const prevValue = get(touched2, name);
|
|
207
|
-
const nextValue =
|
|
207
|
+
const nextValue = _KBNYGXWIcjs.applyState.call(void 0, value, prevValue);
|
|
208
208
|
if (nextValue === prevValue)
|
|
209
209
|
return touched2;
|
|
210
210
|
return set(touched2, name, nextValue);
|
|
@@ -19,6 +19,10 @@ export interface FormStoreItem extends CollectionStoreItem {
|
|
|
19
19
|
export interface FormStoreState<T extends FormStoreValues = FormStoreValues> extends CollectionStoreState<FormStoreItem> {
|
|
20
20
|
/**
|
|
21
21
|
* Form values.
|
|
22
|
+
*
|
|
23
|
+
* Live examples:
|
|
24
|
+
* - [FormRadio](https://ariakit.org/examples/form-radio)
|
|
25
|
+
* - [FormSelect](https://ariakit.org/examples/form-select)
|
|
22
26
|
* @default {}
|
|
23
27
|
*/
|
|
24
28
|
values: T;
|
|
@@ -43,18 +47,25 @@ export interface FormStoreState<T extends FormStoreValues = FormStoreValues> ext
|
|
|
43
47
|
*/
|
|
44
48
|
submitting: boolean;
|
|
45
49
|
/**
|
|
46
|
-
* The number of times
|
|
47
|
-
*
|
|
50
|
+
* The number of times
|
|
51
|
+
* [`submit`](https://ariakit.org/reference/use-form-store#submit) has been
|
|
52
|
+
* called with a successful response.
|
|
48
53
|
*/
|
|
49
54
|
submitSucceed: number;
|
|
50
55
|
/**
|
|
51
|
-
* The number of times
|
|
56
|
+
* The number of times
|
|
57
|
+
* [`submit`](https://ariakit.org/reference/use-form-store#submit) has been
|
|
58
|
+
* called with an error response.
|
|
52
59
|
*/
|
|
53
60
|
submitFailed: number;
|
|
54
61
|
}
|
|
55
62
|
export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues> extends CollectionStoreFunctions<FormStoreItem> {
|
|
56
63
|
/**
|
|
57
|
-
* An object containing the names of the form fields for type
|
|
64
|
+
* An object containing the names of the form fields for type safety.
|
|
65
|
+
*
|
|
66
|
+
* Live examples:
|
|
67
|
+
* - [FormRadio](https://ariakit.org/examples/form-radio)
|
|
68
|
+
* - [FormSelect](https://ariakit.org/examples/form-select)
|
|
58
69
|
* @example
|
|
59
70
|
* store.names.name; // "name"
|
|
60
71
|
* store.names.name.first; // "name.first"
|
|
@@ -62,7 +73,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
62
73
|
*/
|
|
63
74
|
names: Names<T>;
|
|
64
75
|
/**
|
|
65
|
-
* Sets the `values`
|
|
76
|
+
* Sets the [`values`](https://ariakit.org/reference/form-provider#values)
|
|
77
|
+
* state.
|
|
66
78
|
* @example
|
|
67
79
|
* store.setValues({ name: "John" });
|
|
68
80
|
* store.setValues((values) => ({ ...values, name: "John" }));
|
|
@@ -70,7 +82,9 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
70
82
|
setValues: SetState<FormStoreState<T>["values"]>;
|
|
71
83
|
/**
|
|
72
84
|
* Retrieves a field value.
|
|
73
|
-
*
|
|
85
|
+
*
|
|
86
|
+
* Live examples:
|
|
87
|
+
* - [FormRadio](https://ariakit.org/examples/form-radio)
|
|
74
88
|
* @example
|
|
75
89
|
* const nameValue = store.getValue("name");
|
|
76
90
|
* // Can also use store.names for type-safety.
|
|
@@ -79,8 +93,9 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
79
93
|
getValue: <T = any>(name: StringLike) => T;
|
|
80
94
|
/**
|
|
81
95
|
* Sets a field value.
|
|
82
|
-
*
|
|
83
|
-
*
|
|
96
|
+
*
|
|
97
|
+
* Live examples:
|
|
98
|
+
* - [FormSelect](https://ariakit.org/examples/form-select)
|
|
84
99
|
* @example
|
|
85
100
|
* store.setValue("name", "John");
|
|
86
101
|
* store.setValue("name", (value) => value + " Doe");
|
|
@@ -90,8 +105,6 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
90
105
|
setValue: <T>(name: StringLike, value: SetStateAction<T>) => void;
|
|
91
106
|
/**
|
|
92
107
|
* Pushes a value to an array field.
|
|
93
|
-
* @param name The array field name.
|
|
94
|
-
* @param value The value to push.
|
|
95
108
|
* @example
|
|
96
109
|
* store.pushValue("tags", "new tag");
|
|
97
110
|
* store.pushValue("tags", { id: 1, name: "new tag" });
|
|
@@ -101,8 +114,6 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
101
114
|
pushValue: <T>(name: StringLike, value: T) => void;
|
|
102
115
|
/**
|
|
103
116
|
* Removes a value from an array field.
|
|
104
|
-
* @param name The array field name.
|
|
105
|
-
* @param index The index of the value to remove.
|
|
106
117
|
* @example
|
|
107
118
|
* store.removeValue("tags", 0);
|
|
108
119
|
* store.removeValue("tags", 1);
|
|
@@ -111,7 +122,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
111
122
|
*/
|
|
112
123
|
removeValue: (name: StringLike, index: number) => void;
|
|
113
124
|
/**
|
|
114
|
-
* Sets the `errors`
|
|
125
|
+
* Sets the [`errors`](https://ariakit.org/reference/form-provider#errors)
|
|
126
|
+
* state.
|
|
115
127
|
* @example
|
|
116
128
|
* store.setErrors({ name: "Name is required" });
|
|
117
129
|
* store.setErrors((errors) => ({ ...errors, name: "Name is required" }));
|
|
@@ -119,7 +131,6 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
119
131
|
setErrors: SetState<FormStoreState<T>["errors"]>;
|
|
120
132
|
/**
|
|
121
133
|
* Retrieves a field error.
|
|
122
|
-
* @param name The field name.
|
|
123
134
|
* @example
|
|
124
135
|
* const nameError = store.getError("name");
|
|
125
136
|
* // Can also use store.names for type-safety.
|
|
@@ -128,8 +139,9 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
128
139
|
getError: (name: StringLike) => ErrorMessage;
|
|
129
140
|
/**
|
|
130
141
|
* Sets a field error.
|
|
131
|
-
*
|
|
132
|
-
*
|
|
142
|
+
*
|
|
143
|
+
* Live examples:
|
|
144
|
+
* - [FormRadio](https://ariakit.org/examples/form-radio)
|
|
133
145
|
* @example
|
|
134
146
|
* store.setError("name", "Name is required");
|
|
135
147
|
* store.setError("name", (error) => error + "!");
|
|
@@ -138,7 +150,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
138
150
|
*/
|
|
139
151
|
setError: (name: StringLike, error: SetStateAction<ErrorMessage>) => void;
|
|
140
152
|
/**
|
|
141
|
-
* Sets the `touched`
|
|
153
|
+
* Sets the [`touched`](https://ariakit.org/reference/form-provider#touched)
|
|
154
|
+
* state.
|
|
142
155
|
* @example
|
|
143
156
|
* store.setTouched({ name: true });
|
|
144
157
|
* store.setTouched((touched) => ({ ...touched, name: true }));
|
|
@@ -146,7 +159,6 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
146
159
|
setTouched: SetState<FormStoreState<T>["touched"]>;
|
|
147
160
|
/**
|
|
148
161
|
* Retrieves a field touched state.
|
|
149
|
-
* @param name The field name.
|
|
150
162
|
* @example
|
|
151
163
|
* const nameTouched = store.getFieldTouched("name");
|
|
152
164
|
* // Can also use store.names for type-safety.
|
|
@@ -155,8 +167,6 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
155
167
|
getFieldTouched: (name: StringLike) => boolean;
|
|
156
168
|
/**
|
|
157
169
|
* Sets a field touched state.
|
|
158
|
-
* @param name The field name.
|
|
159
|
-
* @param value The field touched state.
|
|
160
170
|
* @example
|
|
161
171
|
* store.setFieldTouched("name", true);
|
|
162
172
|
* store.setFieldTouched("name", (value) => !value);
|
|
@@ -166,9 +176,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
166
176
|
setFieldTouched: (name: StringLike, value: SetStateAction<boolean>) => void;
|
|
167
177
|
/**
|
|
168
178
|
* Function that accepts a callback that will be used to validate the form
|
|
169
|
-
* when `validate` is
|
|
170
|
-
* the callback.
|
|
171
|
-
* @param callback The callback function.
|
|
179
|
+
* when [`validate`](https://ariakit.org/reference/use-form-store#validate) is
|
|
180
|
+
* called. It returns a cleanup function that will remove the callback.
|
|
172
181
|
* @example
|
|
173
182
|
* const cleanup = store.onValidate(async (state) => {
|
|
174
183
|
* const errors = await api.validate(state.values);
|
|
@@ -179,9 +188,9 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
179
188
|
*/
|
|
180
189
|
onValidate: (callback: FormStoreCallback<FormStoreState<T>>) => void;
|
|
181
190
|
/**
|
|
182
|
-
* Function that accepts a callback that will be used to submit the form
|
|
183
|
-
*
|
|
184
|
-
* the callback.
|
|
191
|
+
* Function that accepts a callback that will be used to submit the form when
|
|
192
|
+
* [`submit`](https://ariakit.org/reference/use-form-store#submit) is called.
|
|
193
|
+
* It returns a cleanup function that will remove the callback.
|
|
185
194
|
* @param callback The callback function.
|
|
186
195
|
* @example
|
|
187
196
|
* const cleanup = store.onSubmit(async (state) => {
|