@ariakit/core 0.4.18 → 0.4.19
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 +5 -0
- package/cjs/__chunks/{MJNGPYVQ.cjs → 2RUCRSRF.cjs} +16 -16
- package/cjs/__chunks/{6BYUUR4M.cjs → 4TRESXTO.cjs} +7 -1
- package/cjs/__chunks/{AOXAROPF.cjs → 75F3RDBE.cjs} +14 -14
- package/cjs/__chunks/{SHOLYDNP.cjs → CTEQSOKZ.cjs} +2 -2
- package/cjs/__chunks/{T247D7JS.cjs → CVLMIMPT.cjs} +2 -2
- package/cjs/__chunks/{JNPL5IHP.cjs → G2CSOTWZ.cjs} +7 -7
- package/cjs/__chunks/{4ITB54IT.cjs → I4CBIWTX.cjs} +2 -3
- package/cjs/__chunks/{JNYCP2QO.cjs → LS2SNHDM.cjs} +6 -6
- package/cjs/__chunks/{UROTDZFK.cjs → R37KOEUW.cjs} +10 -10
- package/cjs/__chunks/{OYTZFOIJ.cjs → UGAVMSQJ.cjs} +18 -18
- package/cjs/__chunks/{HGVIF2R4.cjs → VC22SYOD.cjs} +24 -21
- package/cjs/__chunks/{WPBYRKFQ.cjs → WMTGHDLE.cjs} +15 -15
- package/cjs/checkbox/checkbox-store.cjs +5 -5
- package/cjs/checkbox/checkbox-store.d.cts +5 -5
- package/cjs/checkbox/checkbox-store.d.ts +5 -5
- package/cjs/collection/collection-store.cjs +5 -5
- package/cjs/collection/collection-store.d.cts +5 -5
- package/cjs/collection/collection-store.d.ts +5 -5
- package/cjs/combobox/combobox-store.cjs +40 -40
- package/cjs/combobox/combobox-store.d.cts +26 -26
- package/cjs/combobox/combobox-store.d.ts +26 -26
- package/cjs/composite/composite-overflow-store.cjs +6 -6
- package/cjs/composite/composite-store.cjs +6 -6
- package/cjs/composite/composite-store.d.cts +62 -54
- package/cjs/composite/composite-store.d.ts +62 -54
- package/cjs/dialog/dialog-store.cjs +5 -5
- package/cjs/disclosure/disclosure-store.cjs +4 -4
- package/cjs/disclosure/disclosure-store.d.cts +22 -22
- package/cjs/disclosure/disclosure-store.d.ts +22 -22
- package/cjs/form/form-store.cjs +41 -37
- package/cjs/form/form-store.d.cts +14 -14
- package/cjs/form/form-store.d.ts +14 -14
- package/cjs/hovercard/hovercard-store.cjs +7 -7
- package/cjs/hovercard/hovercard-store.d.cts +10 -10
- package/cjs/hovercard/hovercard-store.d.ts +10 -10
- package/cjs/menu/menu-bar-store.cjs +7 -7
- package/cjs/menu/menu-store.cjs +27 -27
- package/cjs/menu/menu-store.d.cts +10 -10
- package/cjs/menu/menu-store.d.ts +10 -10
- package/cjs/menubar/menubar-store.cjs +7 -7
- package/cjs/popover/popover-store.cjs +6 -6
- package/cjs/popover/popover-store.d.cts +17 -17
- package/cjs/popover/popover-store.d.ts +17 -17
- package/cjs/radio/radio-store.cjs +9 -9
- package/cjs/radio/radio-store.d.cts +1 -1
- package/cjs/radio/radio-store.d.ts +1 -1
- package/cjs/select/select-store.cjs +32 -32
- package/cjs/select/select-store.d.cts +17 -17
- package/cjs/select/select-store.d.ts +17 -17
- package/cjs/tab/tab-store.cjs +32 -32
- package/cjs/tab/tab-store.d.cts +20 -20
- package/cjs/tab/tab-store.d.ts +20 -20
- package/cjs/tag/tag-store.cjs +16 -16
- package/cjs/tag/tag-store.d.cts +5 -5
- package/cjs/tag/tag-store.d.ts +5 -5
- package/cjs/toolbar/toolbar-store.cjs +8 -8
- package/cjs/tooltip/tooltip-store.cjs +13 -13
- package/cjs/utils/dom.cjs +2 -2
- package/cjs/utils/events.cjs +6 -6
- package/cjs/utils/focus.cjs +12 -13
- package/cjs/utils/misc.cjs +4 -2
- package/cjs/utils/misc.d.cts +4 -0
- package/cjs/utils/misc.d.ts +4 -0
- package/cjs/utils/platform.cjs +3 -3
- package/cjs/utils/store.cjs +3 -3
- package/cjs/utils/store.d.cts +1 -1
- package/cjs/utils/store.d.ts +1 -1
- package/cjs/utils/undo.cjs +2 -2
- package/esm/__chunks/{KMAUV3TY.js → 7KNZCZ55.js} +1 -1
- package/esm/__chunks/{3DNM6L6E.js → G7XPWBXK.js} +1 -2
- package/esm/__chunks/{SNHYQNEZ.js → GMGLSF2B.js} +1 -1
- package/esm/__chunks/{WSDJ6ZRB.js → H7R2CY4Q.js} +3 -3
- package/esm/__chunks/{75BJEVSH.js → IHNLLH3I.js} +2 -2
- package/esm/__chunks/{N5XGANPW.js → KZX46JDB.js} +11 -8
- package/esm/__chunks/{BFGNM53A.js → MJ4ZJEIM.js} +5 -5
- package/esm/__chunks/{TIQDSBWP.js → TEVO2DMI.js} +3 -3
- package/esm/__chunks/{7LM4Q2XB.js → U4NM2NCP.js} +1 -1
- package/esm/__chunks/{RVTIKFRL.js → UNDE2QJS.js} +3 -3
- package/esm/__chunks/{XMCVU3LR.js → UWJK2WK2.js} +6 -0
- package/esm/__chunks/{SXKM4CGU.js → XTZ53NXG.js} +4 -4
- package/esm/checkbox/checkbox-store.d.ts +5 -5
- package/esm/checkbox/checkbox-store.js +2 -2
- package/esm/collection/collection-store.d.ts +5 -5
- package/esm/collection/collection-store.js +4 -4
- package/esm/combobox/combobox-store.d.ts +26 -26
- package/esm/combobox/combobox-store.js +9 -9
- package/esm/composite/composite-overflow-store.js +5 -5
- package/esm/composite/composite-store.d.ts +62 -54
- package/esm/composite/composite-store.js +5 -5
- package/esm/dialog/dialog-store.js +4 -4
- package/esm/disclosure/disclosure-store.d.ts +22 -22
- package/esm/disclosure/disclosure-store.js +3 -3
- package/esm/form/form-store.d.ts +14 -14
- package/esm/form/form-store.js +19 -15
- package/esm/hovercard/hovercard-store.d.ts +10 -10
- package/esm/hovercard/hovercard-store.js +6 -6
- package/esm/menu/menu-bar-store.js +6 -6
- package/esm/menu/menu-store.d.ts +10 -10
- package/esm/menu/menu-store.js +9 -9
- package/esm/menubar/menubar-store.js +6 -6
- package/esm/popover/popover-store.d.ts +17 -17
- package/esm/popover/popover-store.js +5 -5
- package/esm/radio/radio-store.d.ts +1 -1
- package/esm/radio/radio-store.js +5 -5
- package/esm/select/select-store.d.ts +17 -17
- package/esm/select/select-store.js +8 -8
- package/esm/tab/tab-store.d.ts +20 -20
- package/esm/tab/tab-store.js +5 -5
- package/esm/tag/tag-store.d.ts +5 -5
- package/esm/tag/tag-store.js +7 -7
- package/esm/toolbar/toolbar-store.js +5 -5
- package/esm/tooltip/tooltip-store.js +7 -7
- package/esm/utils/dom.js +1 -1
- package/esm/utils/events.js +4 -4
- package/esm/utils/focus.js +2 -3
- package/esm/utils/misc.d.ts +4 -0
- package/esm/utils/misc.js +3 -1
- package/esm/utils/platform.js +2 -2
- package/esm/utils/store.d.ts +1 -1
- package/esm/utils/store.js +2 -2
- package/esm/utils/undo.js +1 -1
- package/package.json +20 -21
- package/tsconfig.build.json +7 -2
- package/tsconfig.node.json +5 -0
- package/tsconfig.test.json +5 -0
|
@@ -9,25 +9,25 @@ export interface DisclosureStoreState {
|
|
|
9
9
|
* Whether the content is visible.
|
|
10
10
|
*
|
|
11
11
|
* Live examples:
|
|
12
|
-
* - [Combobox with links](https://ariakit.
|
|
12
|
+
* - [Combobox with links](https://ariakit.com/examples/combobox-links)
|
|
13
13
|
* - [Dialog with React
|
|
14
|
-
* Router](https://ariakit.
|
|
15
|
-
* - [Menu with
|
|
16
|
-
* Motion](https://ariakit.
|
|
17
|
-
* - [Lazy Popover](https://ariakit.
|
|
14
|
+
* Router](https://ariakit.com/examples/dialog-react-router)
|
|
15
|
+
* - [Menu with
|
|
16
|
+
* Motion](https://ariakit.com/examples/menu-framer-motion)
|
|
17
|
+
* - [Lazy Popover](https://ariakit.com/examples/popover-lazy)
|
|
18
18
|
* @default false
|
|
19
19
|
*/
|
|
20
20
|
open: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* The mounted state usually matches the
|
|
23
|
-
* [`open`](https://ariakit.
|
|
23
|
+
* [`open`](https://ariakit.com/reference/disclosure-provider#open) value.
|
|
24
24
|
* However, if the content element is animated, it waits for the animation to
|
|
25
25
|
* finish before turning `false`. This ensures the content element doesn't get
|
|
26
26
|
* unmounted during the animation.
|
|
27
27
|
*
|
|
28
28
|
* Live examples:
|
|
29
|
-
* - [Navigation Menubar](https://ariakit.
|
|
30
|
-
* - [Responsive Popover](https://ariakit.
|
|
29
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
30
|
+
* - [Responsive Popover](https://ariakit.com/examples/popover-responsive)
|
|
31
31
|
*/
|
|
32
32
|
mounted: boolean;
|
|
33
33
|
/**
|
|
@@ -55,43 +55,43 @@ export interface DisclosureStoreState {
|
|
|
55
55
|
}
|
|
56
56
|
export interface DisclosureStoreFunctions extends Pick<DisclosureStoreOptions, "disclosure"> {
|
|
57
57
|
/**
|
|
58
|
-
* Sets the [`open`](https://ariakit.
|
|
58
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
59
59
|
* state.
|
|
60
60
|
*
|
|
61
61
|
* Live examples:
|
|
62
62
|
* - [Textarea with inline
|
|
63
|
-
* Combobox](https://ariakit.
|
|
63
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
64
64
|
* @example
|
|
65
65
|
* store.setOpen(true);
|
|
66
66
|
* store.setOpen((open) => !open);
|
|
67
67
|
*/
|
|
68
68
|
setOpen: SetState<DisclosureStoreState["open"]>;
|
|
69
69
|
/**
|
|
70
|
-
* Sets the [`open`](https://ariakit.
|
|
70
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
71
71
|
* state to `true`.
|
|
72
72
|
*
|
|
73
73
|
* Live examples:
|
|
74
74
|
* - [Textarea with inline
|
|
75
|
-
* Combobox](https://ariakit.
|
|
76
|
-
* - [Dialog with
|
|
77
|
-
* Motion](https://ariakit.
|
|
78
|
-
* - [Context Menu](https://ariakit.
|
|
79
|
-
* - [Navigation Menubar](https://ariakit.
|
|
75
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
76
|
+
* - [Dialog with
|
|
77
|
+
* Motion](https://ariakit.com/examples/dialog-framer-motion)
|
|
78
|
+
* - [Context Menu](https://ariakit.com/examples/menu-context-menu)
|
|
79
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
80
80
|
*/
|
|
81
81
|
show: () => void;
|
|
82
82
|
/**
|
|
83
|
-
* Sets the [`open`](https://ariakit.
|
|
83
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
84
84
|
* state to `false`.
|
|
85
85
|
*
|
|
86
86
|
* Live examples:
|
|
87
87
|
* - [Textarea with inline
|
|
88
|
-
* Combobox](https://ariakit.
|
|
89
|
-
* - [Sliding Menu](https://ariakit.
|
|
88
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
89
|
+
* - [Sliding Menu](https://ariakit.com/examples/menu-slide)
|
|
90
90
|
*/
|
|
91
91
|
hide: () => void;
|
|
92
92
|
/**
|
|
93
93
|
* Toggles the
|
|
94
|
-
* [`open`](https://ariakit.
|
|
94
|
+
* [`open`](https://ariakit.com/reference/disclosure-provider#open) state.
|
|
95
95
|
*/
|
|
96
96
|
toggle: () => void;
|
|
97
97
|
/**
|
|
@@ -109,7 +109,7 @@ export interface DisclosureStoreFunctions extends Pick<DisclosureStoreOptions, "
|
|
|
109
109
|
* Sets the `disclosureElement` state.
|
|
110
110
|
*
|
|
111
111
|
* Live examples:
|
|
112
|
-
* - [Navigation Menubar](https://ariakit.
|
|
112
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
113
113
|
*/
|
|
114
114
|
setDisclosureElement: SetState<DisclosureStoreState["disclosureElement"]>;
|
|
115
115
|
}
|
|
@@ -128,7 +128,7 @@ export interface DisclosureStoreOptions extends StoreOptions<DisclosureStoreStat
|
|
|
128
128
|
* A reference to another disclosure store that controls another disclosure
|
|
129
129
|
* component to keep them in sync. Element states like `contentElement` and
|
|
130
130
|
* `disclosureElement` won't be synced. For that, use the
|
|
131
|
-
* [`store`](https://ariakit.
|
|
131
|
+
* [`store`](https://ariakit.com/reference/disclosure-provider#store) prop
|
|
132
132
|
* instead.
|
|
133
133
|
*/
|
|
134
134
|
disclosure?: DisclosureStore | null;
|
|
@@ -9,25 +9,25 @@ export interface DisclosureStoreState {
|
|
|
9
9
|
* Whether the content is visible.
|
|
10
10
|
*
|
|
11
11
|
* Live examples:
|
|
12
|
-
* - [Combobox with links](https://ariakit.
|
|
12
|
+
* - [Combobox with links](https://ariakit.com/examples/combobox-links)
|
|
13
13
|
* - [Dialog with React
|
|
14
|
-
* Router](https://ariakit.
|
|
15
|
-
* - [Menu with
|
|
16
|
-
* Motion](https://ariakit.
|
|
17
|
-
* - [Lazy Popover](https://ariakit.
|
|
14
|
+
* Router](https://ariakit.com/examples/dialog-react-router)
|
|
15
|
+
* - [Menu with
|
|
16
|
+
* Motion](https://ariakit.com/examples/menu-framer-motion)
|
|
17
|
+
* - [Lazy Popover](https://ariakit.com/examples/popover-lazy)
|
|
18
18
|
* @default false
|
|
19
19
|
*/
|
|
20
20
|
open: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* The mounted state usually matches the
|
|
23
|
-
* [`open`](https://ariakit.
|
|
23
|
+
* [`open`](https://ariakit.com/reference/disclosure-provider#open) value.
|
|
24
24
|
* However, if the content element is animated, it waits for the animation to
|
|
25
25
|
* finish before turning `false`. This ensures the content element doesn't get
|
|
26
26
|
* unmounted during the animation.
|
|
27
27
|
*
|
|
28
28
|
* Live examples:
|
|
29
|
-
* - [Navigation Menubar](https://ariakit.
|
|
30
|
-
* - [Responsive Popover](https://ariakit.
|
|
29
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
30
|
+
* - [Responsive Popover](https://ariakit.com/examples/popover-responsive)
|
|
31
31
|
*/
|
|
32
32
|
mounted: boolean;
|
|
33
33
|
/**
|
|
@@ -55,43 +55,43 @@ export interface DisclosureStoreState {
|
|
|
55
55
|
}
|
|
56
56
|
export interface DisclosureStoreFunctions extends Pick<DisclosureStoreOptions, "disclosure"> {
|
|
57
57
|
/**
|
|
58
|
-
* Sets the [`open`](https://ariakit.
|
|
58
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
59
59
|
* state.
|
|
60
60
|
*
|
|
61
61
|
* Live examples:
|
|
62
62
|
* - [Textarea with inline
|
|
63
|
-
* Combobox](https://ariakit.
|
|
63
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
64
64
|
* @example
|
|
65
65
|
* store.setOpen(true);
|
|
66
66
|
* store.setOpen((open) => !open);
|
|
67
67
|
*/
|
|
68
68
|
setOpen: SetState<DisclosureStoreState["open"]>;
|
|
69
69
|
/**
|
|
70
|
-
* Sets the [`open`](https://ariakit.
|
|
70
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
71
71
|
* state to `true`.
|
|
72
72
|
*
|
|
73
73
|
* Live examples:
|
|
74
74
|
* - [Textarea with inline
|
|
75
|
-
* Combobox](https://ariakit.
|
|
76
|
-
* - [Dialog with
|
|
77
|
-
* Motion](https://ariakit.
|
|
78
|
-
* - [Context Menu](https://ariakit.
|
|
79
|
-
* - [Navigation Menubar](https://ariakit.
|
|
75
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
76
|
+
* - [Dialog with
|
|
77
|
+
* Motion](https://ariakit.com/examples/dialog-framer-motion)
|
|
78
|
+
* - [Context Menu](https://ariakit.com/examples/menu-context-menu)
|
|
79
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
80
80
|
*/
|
|
81
81
|
show: () => void;
|
|
82
82
|
/**
|
|
83
|
-
* Sets the [`open`](https://ariakit.
|
|
83
|
+
* Sets the [`open`](https://ariakit.com/reference/disclosure-provider#open)
|
|
84
84
|
* state to `false`.
|
|
85
85
|
*
|
|
86
86
|
* Live examples:
|
|
87
87
|
* - [Textarea with inline
|
|
88
|
-
* Combobox](https://ariakit.
|
|
89
|
-
* - [Sliding Menu](https://ariakit.
|
|
88
|
+
* Combobox](https://ariakit.com/examples/combobox-textarea)
|
|
89
|
+
* - [Sliding Menu](https://ariakit.com/examples/menu-slide)
|
|
90
90
|
*/
|
|
91
91
|
hide: () => void;
|
|
92
92
|
/**
|
|
93
93
|
* Toggles the
|
|
94
|
-
* [`open`](https://ariakit.
|
|
94
|
+
* [`open`](https://ariakit.com/reference/disclosure-provider#open) state.
|
|
95
95
|
*/
|
|
96
96
|
toggle: () => void;
|
|
97
97
|
/**
|
|
@@ -109,7 +109,7 @@ export interface DisclosureStoreFunctions extends Pick<DisclosureStoreOptions, "
|
|
|
109
109
|
* Sets the `disclosureElement` state.
|
|
110
110
|
*
|
|
111
111
|
* Live examples:
|
|
112
|
-
* - [Navigation Menubar](https://ariakit.
|
|
112
|
+
* - [Navigation Menubar](https://ariakit.com/examples/menubar-navigation)
|
|
113
113
|
*/
|
|
114
114
|
setDisclosureElement: SetState<DisclosureStoreState["disclosureElement"]>;
|
|
115
115
|
}
|
|
@@ -128,7 +128,7 @@ export interface DisclosureStoreOptions extends StoreOptions<DisclosureStoreStat
|
|
|
128
128
|
* A reference to another disclosure store that controls another disclosure
|
|
129
129
|
* component to keep them in sync. Element states like `contentElement` and
|
|
130
130
|
* `disclosureElement` won't be synced. For that, use the
|
|
131
|
-
* [`store`](https://ariakit.
|
|
131
|
+
* [`store`](https://ariakit.com/reference/disclosure-provider#store) prop
|
|
132
132
|
* instead.
|
|
133
133
|
*/
|
|
134
134
|
disclosure?: DisclosureStore | null;
|
package/cjs/form/form-store.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../__chunks/
|
|
3
|
+
var _VC22SYODcjs = require('../__chunks/VC22SYOD.cjs');
|
|
4
|
+
require('../__chunks/I4CBIWTX.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _WMTGHDLEcjs = require('../__chunks/WMTGHDLE.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var _4TRESXTOcjs = require('../__chunks/4TRESXTO.cjs');
|
|
18
18
|
|
|
19
19
|
// src/form/form-store.ts
|
|
20
20
|
function nextFrame() {
|
|
@@ -22,45 +22,49 @@ function nextFrame() {
|
|
|
22
22
|
}
|
|
23
23
|
function hasMessages(object) {
|
|
24
24
|
return Object.keys(object).some((key) => {
|
|
25
|
-
if (
|
|
25
|
+
if (_4TRESXTOcjs.isObject.call(void 0, object[key])) {
|
|
26
26
|
return hasMessages(object[key]);
|
|
27
27
|
}
|
|
28
28
|
return !!object[key];
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
function get(values, path, defaultValue2) {
|
|
32
|
-
|
|
33
|
-
const [key, ...rest] = Array.isArray(path) ? path : `${path}`.split(".");
|
|
32
|
+
const [key, ...rest] = Array.isArray(path) ? path : String(path).split(".");
|
|
34
33
|
if (key == null || !values) {
|
|
35
34
|
return defaultValue2;
|
|
36
35
|
}
|
|
37
36
|
if (!rest.length) {
|
|
38
|
-
return (
|
|
37
|
+
return _nullishCoalesce(values[key], () => ( defaultValue2));
|
|
39
38
|
}
|
|
40
39
|
return get(values[key], rest, defaultValue2);
|
|
41
40
|
}
|
|
41
|
+
function getOrCreateNested(nestedValues, nextKey) {
|
|
42
|
+
if (Array.isArray(nestedValues) || _4TRESXTOcjs.isObject.call(void 0, nestedValues)) {
|
|
43
|
+
return nestedValues;
|
|
44
|
+
}
|
|
45
|
+
return _4TRESXTOcjs.isInteger.call(void 0, nextKey) ? [] : {};
|
|
46
|
+
}
|
|
42
47
|
function set(values, path, value) {
|
|
43
|
-
const [k, ...rest] = Array.isArray(path) ? path :
|
|
48
|
+
const [k, ...rest] = Array.isArray(path) ? path : String(path).split(".");
|
|
44
49
|
if (k == null) return values;
|
|
45
50
|
const key = k;
|
|
46
|
-
const isIntegerKey =
|
|
51
|
+
const isIntegerKey = _4TRESXTOcjs.isInteger.call(void 0, key);
|
|
47
52
|
const nextValues = isIntegerKey ? values || [] : values || {};
|
|
48
53
|
const nestedValues = nextValues[key];
|
|
49
|
-
const
|
|
54
|
+
const nextKey = rest[0];
|
|
55
|
+
const result = rest.length && nextKey != null ? set(getOrCreateNested(nestedValues, nextKey), rest, value) : value;
|
|
50
56
|
if (isIntegerKey) {
|
|
51
57
|
const index = Number(key);
|
|
52
58
|
if (values && Array.isArray(values)) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...values.slice(index + 1)
|
|
57
|
-
];
|
|
59
|
+
const copy = [...values];
|
|
60
|
+
copy[index] = result;
|
|
61
|
+
return copy;
|
|
58
62
|
}
|
|
59
63
|
const nextValues2 = [];
|
|
60
64
|
nextValues2[index] = result;
|
|
61
65
|
return nextValues2;
|
|
62
66
|
}
|
|
63
|
-
return {
|
|
67
|
+
return Object.assign({}, values, { [key]: result });
|
|
64
68
|
}
|
|
65
69
|
function setAll(values, value) {
|
|
66
70
|
const result = {};
|
|
@@ -69,12 +73,12 @@ function setAll(values, value) {
|
|
|
69
73
|
const currentValue = values[key];
|
|
70
74
|
if (Array.isArray(currentValue)) {
|
|
71
75
|
result[key] = currentValue.map((v) => {
|
|
72
|
-
if (
|
|
76
|
+
if (_4TRESXTOcjs.isObject.call(void 0, v)) {
|
|
73
77
|
return setAll(v, value);
|
|
74
78
|
}
|
|
75
79
|
return value;
|
|
76
80
|
});
|
|
77
|
-
} else if (
|
|
81
|
+
} else if (_4TRESXTOcjs.isObject.call(void 0, currentValue)) {
|
|
78
82
|
result[key] = setAll(currentValue, value);
|
|
79
83
|
} else {
|
|
80
84
|
result[key] = value;
|
|
@@ -109,22 +113,22 @@ function createNames() {
|
|
|
109
113
|
}
|
|
110
114
|
function createFormStore(props = {}) {
|
|
111
115
|
var _a;
|
|
112
|
-
|
|
116
|
+
_WMTGHDLEcjs.throwOnConflictingProps.call(void 0, props, props.store);
|
|
113
117
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
114
|
-
const collection =
|
|
115
|
-
const values =
|
|
118
|
+
const collection = _VC22SYODcjs.createCollectionStore.call(void 0, props);
|
|
119
|
+
const values = _4TRESXTOcjs.defaultValue.call(void 0,
|
|
116
120
|
props.values,
|
|
117
121
|
syncState == null ? void 0 : syncState.values,
|
|
118
122
|
props.defaultValues,
|
|
119
123
|
{}
|
|
120
124
|
);
|
|
121
|
-
const errors =
|
|
125
|
+
const errors = _4TRESXTOcjs.defaultValue.call(void 0,
|
|
122
126
|
props.errors,
|
|
123
127
|
syncState == null ? void 0 : syncState.errors,
|
|
124
128
|
props.defaultErrors,
|
|
125
129
|
{}
|
|
126
130
|
);
|
|
127
|
-
const touched =
|
|
131
|
+
const touched = _4TRESXTOcjs.defaultValue.call(void 0,
|
|
128
132
|
props.touched,
|
|
129
133
|
syncState == null ? void 0 : syncState.touched,
|
|
130
134
|
props.defaultTouched,
|
|
@@ -135,24 +139,24 @@ function createFormStore(props = {}) {
|
|
|
135
139
|
values,
|
|
136
140
|
errors,
|
|
137
141
|
touched,
|
|
138
|
-
validating:
|
|
139
|
-
submitting:
|
|
140
|
-
submitSucceed:
|
|
141
|
-
submitFailed:
|
|
142
|
+
validating: _4TRESXTOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.validating, false),
|
|
143
|
+
submitting: _4TRESXTOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitting, false),
|
|
144
|
+
submitSucceed: _4TRESXTOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitSucceed, 0),
|
|
145
|
+
submitFailed: _4TRESXTOcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
|
|
142
146
|
valid: !hasMessages(errors)
|
|
143
147
|
};
|
|
144
|
-
const form =
|
|
148
|
+
const form = _WMTGHDLEcjs.createStore.call(void 0, initialState, collection, props.store);
|
|
145
149
|
const syncCallbacks = getStoreCallbacks(props.store);
|
|
146
150
|
const syncCallbacksState = syncCallbacks == null ? void 0 : syncCallbacks.getState();
|
|
147
151
|
const callbacksInitialState = {
|
|
148
152
|
validate: (syncCallbacksState == null ? void 0 : syncCallbacksState.validate) || [],
|
|
149
153
|
submit: (syncCallbacksState == null ? void 0 : syncCallbacksState.submit) || []
|
|
150
154
|
};
|
|
151
|
-
const callbacks =
|
|
152
|
-
|
|
153
|
-
|
|
155
|
+
const callbacks = _WMTGHDLEcjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
|
|
156
|
+
_WMTGHDLEcjs.setup.call(void 0, form, () => _WMTGHDLEcjs.init.call(void 0, callbacks));
|
|
157
|
+
_WMTGHDLEcjs.setup.call(void 0,
|
|
154
158
|
form,
|
|
155
|
-
() =>
|
|
159
|
+
() => _WMTGHDLEcjs.sync.call(void 0, form, ["validating", "errors"], (state) => {
|
|
156
160
|
if (state.validating) return;
|
|
157
161
|
form.setState("valid", !hasMessages(state.errors));
|
|
158
162
|
})
|
|
@@ -179,7 +183,7 @@ function createFormStore(props = {}) {
|
|
|
179
183
|
getValue: (name) => get(form.getState().values, name),
|
|
180
184
|
setValue: (name, value) => form.setState("values", (values2) => {
|
|
181
185
|
const prevValue = get(values2, name);
|
|
182
|
-
const nextValue =
|
|
186
|
+
const nextValue = _4TRESXTOcjs.applyState.call(void 0, value, prevValue);
|
|
183
187
|
if (nextValue === prevValue) return values2;
|
|
184
188
|
return set(values2, name, nextValue);
|
|
185
189
|
}),
|
|
@@ -199,7 +203,7 @@ function createFormStore(props = {}) {
|
|
|
199
203
|
getError: (name) => get(form.getState().errors, name),
|
|
200
204
|
setError: (name, error) => form.setState("errors", (errors2) => {
|
|
201
205
|
const prevError = get(errors2, name);
|
|
202
|
-
const nextError =
|
|
206
|
+
const nextError = _4TRESXTOcjs.applyState.call(void 0, error, prevError);
|
|
203
207
|
if (nextError === prevError) return errors2;
|
|
204
208
|
return set(errors2, name, nextError);
|
|
205
209
|
}),
|
|
@@ -207,7 +211,7 @@ function createFormStore(props = {}) {
|
|
|
207
211
|
getFieldTouched: (name) => !!get(form.getState().touched, name),
|
|
208
212
|
setFieldTouched: (name, value) => form.setState("touched", (touched2) => {
|
|
209
213
|
const prevValue = get(touched2, name);
|
|
210
|
-
const nextValue =
|
|
214
|
+
const nextValue = _4TRESXTOcjs.applyState.call(void 0, value, prevValue);
|
|
211
215
|
if (nextValue === prevValue) return touched2;
|
|
212
216
|
return set(touched2, name, nextValue);
|
|
213
217
|
}),
|
|
@@ -21,8 +21,8 @@ export interface FormStoreState<T extends FormStoreValues = FormStoreValues> ext
|
|
|
21
21
|
* Form values.
|
|
22
22
|
*
|
|
23
23
|
* Live examples:
|
|
24
|
-
* - [FormRadio](https://ariakit.
|
|
25
|
-
* - [FormSelect](https://ariakit.
|
|
24
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
25
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
26
26
|
* @default {}
|
|
27
27
|
*/
|
|
28
28
|
values: T;
|
|
@@ -48,13 +48,13 @@ export interface FormStoreState<T extends FormStoreValues = FormStoreValues> ext
|
|
|
48
48
|
submitting: boolean;
|
|
49
49
|
/**
|
|
50
50
|
* The number of times
|
|
51
|
-
* [`submit`](https://ariakit.
|
|
51
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) has been
|
|
52
52
|
* called with a successful response.
|
|
53
53
|
*/
|
|
54
54
|
submitSucceed: number;
|
|
55
55
|
/**
|
|
56
56
|
* The number of times
|
|
57
|
-
* [`submit`](https://ariakit.
|
|
57
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) has been
|
|
58
58
|
* called with an error response.
|
|
59
59
|
*/
|
|
60
60
|
submitFailed: number;
|
|
@@ -64,8 +64,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
64
64
|
* An object containing the names of the form fields for type safety.
|
|
65
65
|
*
|
|
66
66
|
* Live examples:
|
|
67
|
-
* - [FormRadio](https://ariakit.
|
|
68
|
-
* - [FormSelect](https://ariakit.
|
|
67
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
68
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
69
69
|
* @example
|
|
70
70
|
* store.names.name; // "name"
|
|
71
71
|
* store.names.name.first; // "name.first"
|
|
@@ -73,7 +73,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
73
73
|
*/
|
|
74
74
|
names: Names<T>;
|
|
75
75
|
/**
|
|
76
|
-
* Sets the [`values`](https://ariakit.
|
|
76
|
+
* Sets the [`values`](https://ariakit.com/reference/form-provider#values)
|
|
77
77
|
* state.
|
|
78
78
|
* @example
|
|
79
79
|
* store.setValues({ name: "John" });
|
|
@@ -84,7 +84,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
84
84
|
* Retrieves a field value.
|
|
85
85
|
*
|
|
86
86
|
* Live examples:
|
|
87
|
-
* - [FormRadio](https://ariakit.
|
|
87
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
88
88
|
* @example
|
|
89
89
|
* const nameValue = store.getValue("name");
|
|
90
90
|
* // Can also use store.names for type-safety.
|
|
@@ -95,7 +95,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
95
95
|
* Sets a field value.
|
|
96
96
|
*
|
|
97
97
|
* Live examples:
|
|
98
|
-
* - [FormSelect](https://ariakit.
|
|
98
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
99
99
|
* @example
|
|
100
100
|
* store.setValue("name", "John");
|
|
101
101
|
* store.setValue("name", (value) => value + " Doe");
|
|
@@ -122,7 +122,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
122
122
|
*/
|
|
123
123
|
removeValue: (name: StringLike, index: number) => void;
|
|
124
124
|
/**
|
|
125
|
-
* Sets the [`errors`](https://ariakit.
|
|
125
|
+
* Sets the [`errors`](https://ariakit.com/reference/form-provider#errors)
|
|
126
126
|
* state.
|
|
127
127
|
* @example
|
|
128
128
|
* store.setErrors({ name: "Name is required" });
|
|
@@ -141,7 +141,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
141
141
|
* Sets a field error.
|
|
142
142
|
*
|
|
143
143
|
* Live examples:
|
|
144
|
-
* - [FormRadio](https://ariakit.
|
|
144
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
145
145
|
* @example
|
|
146
146
|
* store.setError("name", "Name is required");
|
|
147
147
|
* store.setError("name", (error) => error + "!");
|
|
@@ -150,7 +150,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
150
150
|
*/
|
|
151
151
|
setError: (name: StringLike, error: SetStateAction<ErrorMessage>) => void;
|
|
152
152
|
/**
|
|
153
|
-
* Sets the [`touched`](https://ariakit.
|
|
153
|
+
* Sets the [`touched`](https://ariakit.com/reference/form-provider#touched)
|
|
154
154
|
* state.
|
|
155
155
|
* @example
|
|
156
156
|
* store.setTouched({ name: true });
|
|
@@ -176,7 +176,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
176
176
|
setFieldTouched: (name: StringLike, value: SetStateAction<boolean>) => void;
|
|
177
177
|
/**
|
|
178
178
|
* Function that accepts a callback that will be used to validate the form
|
|
179
|
-
* when [`validate`](https://ariakit.
|
|
179
|
+
* when [`validate`](https://ariakit.com/reference/use-form-store#validate) is
|
|
180
180
|
* called. It returns a cleanup function that will remove the callback.
|
|
181
181
|
* @example
|
|
182
182
|
* const cleanup = store.onValidate(async (state) => {
|
|
@@ -189,7 +189,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
189
189
|
onValidate: (callback: FormStoreCallback<FormStoreState<T>>) => () => void;
|
|
190
190
|
/**
|
|
191
191
|
* Function that accepts a callback that will be used to submit the form when
|
|
192
|
-
* [`submit`](https://ariakit.
|
|
192
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) is called.
|
|
193
193
|
* It returns a cleanup function that will remove the callback.
|
|
194
194
|
* @param callback The callback function.
|
|
195
195
|
* @example
|
package/cjs/form/form-store.d.ts
CHANGED
|
@@ -21,8 +21,8 @@ export interface FormStoreState<T extends FormStoreValues = FormStoreValues> ext
|
|
|
21
21
|
* Form values.
|
|
22
22
|
*
|
|
23
23
|
* Live examples:
|
|
24
|
-
* - [FormRadio](https://ariakit.
|
|
25
|
-
* - [FormSelect](https://ariakit.
|
|
24
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
25
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
26
26
|
* @default {}
|
|
27
27
|
*/
|
|
28
28
|
values: T;
|
|
@@ -48,13 +48,13 @@ export interface FormStoreState<T extends FormStoreValues = FormStoreValues> ext
|
|
|
48
48
|
submitting: boolean;
|
|
49
49
|
/**
|
|
50
50
|
* The number of times
|
|
51
|
-
* [`submit`](https://ariakit.
|
|
51
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) has been
|
|
52
52
|
* called with a successful response.
|
|
53
53
|
*/
|
|
54
54
|
submitSucceed: number;
|
|
55
55
|
/**
|
|
56
56
|
* The number of times
|
|
57
|
-
* [`submit`](https://ariakit.
|
|
57
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) has been
|
|
58
58
|
* called with an error response.
|
|
59
59
|
*/
|
|
60
60
|
submitFailed: number;
|
|
@@ -64,8 +64,8 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
64
64
|
* An object containing the names of the form fields for type safety.
|
|
65
65
|
*
|
|
66
66
|
* Live examples:
|
|
67
|
-
* - [FormRadio](https://ariakit.
|
|
68
|
-
* - [FormSelect](https://ariakit.
|
|
67
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
68
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
69
69
|
* @example
|
|
70
70
|
* store.names.name; // "name"
|
|
71
71
|
* store.names.name.first; // "name.first"
|
|
@@ -73,7 +73,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
73
73
|
*/
|
|
74
74
|
names: Names<T>;
|
|
75
75
|
/**
|
|
76
|
-
* Sets the [`values`](https://ariakit.
|
|
76
|
+
* Sets the [`values`](https://ariakit.com/reference/form-provider#values)
|
|
77
77
|
* state.
|
|
78
78
|
* @example
|
|
79
79
|
* store.setValues({ name: "John" });
|
|
@@ -84,7 +84,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
84
84
|
* Retrieves a field value.
|
|
85
85
|
*
|
|
86
86
|
* Live examples:
|
|
87
|
-
* - [FormRadio](https://ariakit.
|
|
87
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
88
88
|
* @example
|
|
89
89
|
* const nameValue = store.getValue("name");
|
|
90
90
|
* // Can also use store.names for type-safety.
|
|
@@ -95,7 +95,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
95
95
|
* Sets a field value.
|
|
96
96
|
*
|
|
97
97
|
* Live examples:
|
|
98
|
-
* - [FormSelect](https://ariakit.
|
|
98
|
+
* - [FormSelect](https://ariakit.com/examples/form-select)
|
|
99
99
|
* @example
|
|
100
100
|
* store.setValue("name", "John");
|
|
101
101
|
* store.setValue("name", (value) => value + " Doe");
|
|
@@ -122,7 +122,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
122
122
|
*/
|
|
123
123
|
removeValue: (name: StringLike, index: number) => void;
|
|
124
124
|
/**
|
|
125
|
-
* Sets the [`errors`](https://ariakit.
|
|
125
|
+
* Sets the [`errors`](https://ariakit.com/reference/form-provider#errors)
|
|
126
126
|
* state.
|
|
127
127
|
* @example
|
|
128
128
|
* store.setErrors({ name: "Name is required" });
|
|
@@ -141,7 +141,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
141
141
|
* Sets a field error.
|
|
142
142
|
*
|
|
143
143
|
* Live examples:
|
|
144
|
-
* - [FormRadio](https://ariakit.
|
|
144
|
+
* - [FormRadio](https://ariakit.com/examples/form-radio)
|
|
145
145
|
* @example
|
|
146
146
|
* store.setError("name", "Name is required");
|
|
147
147
|
* store.setError("name", (error) => error + "!");
|
|
@@ -150,7 +150,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
150
150
|
*/
|
|
151
151
|
setError: (name: StringLike, error: SetStateAction<ErrorMessage>) => void;
|
|
152
152
|
/**
|
|
153
|
-
* Sets the [`touched`](https://ariakit.
|
|
153
|
+
* Sets the [`touched`](https://ariakit.com/reference/form-provider#touched)
|
|
154
154
|
* state.
|
|
155
155
|
* @example
|
|
156
156
|
* store.setTouched({ name: true });
|
|
@@ -176,7 +176,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
176
176
|
setFieldTouched: (name: StringLike, value: SetStateAction<boolean>) => void;
|
|
177
177
|
/**
|
|
178
178
|
* Function that accepts a callback that will be used to validate the form
|
|
179
|
-
* when [`validate`](https://ariakit.
|
|
179
|
+
* when [`validate`](https://ariakit.com/reference/use-form-store#validate) is
|
|
180
180
|
* called. It returns a cleanup function that will remove the callback.
|
|
181
181
|
* @example
|
|
182
182
|
* const cleanup = store.onValidate(async (state) => {
|
|
@@ -189,7 +189,7 @@ export interface FormStoreFunctions<T extends FormStoreValues = FormStoreValues>
|
|
|
189
189
|
onValidate: (callback: FormStoreCallback<FormStoreState<T>>) => () => void;
|
|
190
190
|
/**
|
|
191
191
|
* Function that accepts a callback that will be used to submit the form when
|
|
192
|
-
* [`submit`](https://ariakit.
|
|
192
|
+
* [`submit`](https://ariakit.com/reference/use-form-store#submit) is called.
|
|
193
193
|
* It returns a cleanup function that will remove the callback.
|
|
194
194
|
* @param callback The callback function.
|
|
195
195
|
* @example
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../__chunks/
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
8
|
-
require('../__chunks/
|
|
3
|
+
var _R37KOEUWcjs = require('../__chunks/R37KOEUW.cjs');
|
|
4
|
+
require('../__chunks/75F3RDBE.cjs');
|
|
5
|
+
require('../__chunks/CVLMIMPT.cjs');
|
|
6
|
+
require('../__chunks/2RUCRSRF.cjs');
|
|
7
|
+
require('../__chunks/WMTGHDLE.cjs');
|
|
8
|
+
require('../__chunks/4TRESXTO.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
exports.createHovercardStore =
|
|
11
|
+
exports.createHovercardStore = _R37KOEUWcjs.createHovercardStore;
|