@ariakit/core 0.3.9 → 0.3.10
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/{2UK5WUJX.cjs → 5CBCKBZ2.cjs} +0 -2
- package/cjs/__chunks/{UTICNXST.cjs → CWDUO5EV.cjs} +4 -4
- package/cjs/__chunks/{5SIVMOID.cjs → HMO4CKUP.cjs} +4 -4
- package/cjs/__chunks/{2LS4JJ4S.cjs → MFSCSSBJ.cjs} +2 -2
- package/cjs/__chunks/{GJFZ5ZPP.cjs → MWNFQD55.cjs} +11 -11
- package/cjs/__chunks/{EFIT5L4X.cjs → Y6PHIDP6.cjs} +7 -7
- package/cjs/__chunks/{UCLKUBNP.cjs → YLMJBIQM.cjs} +16 -12
- package/cjs/__chunks/{JNFZSNOI.cjs → ZXCB7MXN.cjs} +6 -6
- package/cjs/checkbox/checkbox-store.cjs +3 -3
- package/cjs/checkbox/checkbox-store.d.cts +5 -2
- package/cjs/checkbox/checkbox-store.d.ts +5 -2
- package/cjs/collection/collection-store.cjs +3 -3
- package/cjs/collection/collection-store.d.cts +11 -11
- package/cjs/collection/collection-store.d.ts +11 -11
- package/cjs/combobox/combobox-store.cjs +20 -20
- 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 +5 -5
- package/cjs/composite/composite-store.cjs +4 -4
- package/cjs/composite/composite-store.d.cts +128 -54
- package/cjs/composite/composite-store.d.ts +128 -54
- package/cjs/dialog/dialog-store.cjs +4 -4
- package/cjs/disclosure/disclosure-store.cjs +3 -3
- package/cjs/disclosure/disclosure-store.d.cts +33 -27
- package/cjs/disclosure/disclosure-store.d.ts +33 -27
- package/cjs/form/form-store.cjs +7 -7
- package/cjs/form/form-store.d.cts +34 -25
- package/cjs/form/form-store.d.ts +34 -25
- package/cjs/hovercard/hovercard-store.cjs +6 -6
- package/cjs/menu/menu-bar-store.cjs +5 -5
- package/cjs/menu/menu-store.cjs +18 -18
- package/cjs/menubar/menubar-store.cjs +5 -5
- package/cjs/popover/popover-store.cjs +5 -5
- package/cjs/radio/radio-store.cjs +5 -5
- package/cjs/select/select-store.cjs +18 -18
- package/cjs/tab/tab-store.cjs +15 -15
- package/cjs/tab/tab-store.d.cts +15 -4
- package/cjs/tab/tab-store.d.ts +15 -4
- package/cjs/toolbar/toolbar-store.cjs +4 -4
- package/cjs/tooltip/tooltip-store.cjs +7 -7
- package/cjs/utils/store.cjs +2 -2
- package/esm/__chunks/{LT2OYWRD.js → 25MEC56I.js} +1 -1
- package/esm/__chunks/{J6JIOWCS.js → AKMSZ36N.js} +2 -2
- package/esm/__chunks/{A2J4XZ5T.js → K6ELJFXN.js} +0 -2
- package/esm/__chunks/{NKLTHWCR.js → L5RYKTVQ.js} +1 -1
- package/esm/__chunks/{TLN4ALYH.js → MYUKSFP5.js} +10 -6
- package/esm/__chunks/{T3DVYGXI.js → QJ5CUA32.js} +2 -2
- package/esm/__chunks/{EZ2TTBAQ.js → UUFF4PQ6.js} +2 -2
- package/esm/__chunks/{DLX2AS6C.js → VEUNYQYR.js} +2 -2
- package/esm/checkbox/checkbox-store.d.ts +5 -2
- package/esm/checkbox/checkbox-store.js +1 -1
- package/esm/collection/collection-store.d.ts +11 -11
- package/esm/collection/collection-store.js +2 -2
- package/esm/combobox/combobox-store.d.ts +3 -1
- package/esm/combobox/combobox-store.js +6 -6
- package/esm/composite/composite-overflow-store.js +4 -4
- package/esm/composite/composite-store.d.ts +128 -54
- package/esm/composite/composite-store.js +3 -3
- package/esm/dialog/dialog-store.js +3 -3
- package/esm/disclosure/disclosure-store.d.ts +33 -27
- package/esm/disclosure/disclosure-store.js +2 -2
- package/esm/form/form-store.d.ts +34 -25
- package/esm/form/form-store.js +2 -2
- package/esm/hovercard/hovercard-store.js +5 -5
- package/esm/menu/menu-bar-store.js +4 -4
- package/esm/menu/menu-store.js +7 -7
- package/esm/menubar/menubar-store.js +4 -4
- package/esm/popover/popover-store.js +4 -4
- package/esm/radio/radio-store.js +3 -3
- package/esm/select/select-store.js +6 -6
- package/esm/tab/tab-store.d.ts +15 -4
- package/esm/tab/tab-store.js +3 -3
- package/esm/toolbar/toolbar-store.js +3 -3
- package/esm/tooltip/tooltip-store.js +5 -5
- package/esm/utils/store.js +1 -1
- package/package.json +1 -1
package/cjs/form/form-store.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _YLMJBIQMcjs = require('../__chunks/YLMJBIQM.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _5CBCKBZ2cjs = require('../__chunks/5CBCKBZ2.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -114,9 +114,9 @@ function createNames() {
|
|
|
114
114
|
}
|
|
115
115
|
function createFormStore(props = {}) {
|
|
116
116
|
var _a;
|
|
117
|
-
|
|
117
|
+
_5CBCKBZ2cjs.throwOnConflictingProps.call(void 0, props, props.store);
|
|
118
118
|
const syncState = (_a = props.store) == null ? void 0 : _a.getState();
|
|
119
|
-
const collection =
|
|
119
|
+
const collection = _YLMJBIQMcjs.createCollectionStore.call(void 0, props);
|
|
120
120
|
const values = _3UT5FE6Kcjs.defaultValue.call(void 0,
|
|
121
121
|
props.values,
|
|
122
122
|
syncState == null ? void 0 : syncState.values,
|
|
@@ -145,15 +145,15 @@ function createFormStore(props = {}) {
|
|
|
145
145
|
submitFailed: _3UT5FE6Kcjs.defaultValue.call(void 0, syncState == null ? void 0 : syncState.submitFailed, 0),
|
|
146
146
|
valid: !hasMessages(errors)
|
|
147
147
|
});
|
|
148
|
-
const form =
|
|
148
|
+
const form = _5CBCKBZ2cjs.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 = _5CBCKBZ2cjs.createStore.call(void 0, callbacksInitialState, syncCallbacks);
|
|
156
|
+
_5CBCKBZ2cjs.setup.call(void 0, form, () => _5CBCKBZ2cjs.init.call(void 0, callbacks));
|
|
157
157
|
const validate = async () => {
|
|
158
158
|
form.setState("validating", true);
|
|
159
159
|
form.setState("errors", {});
|
|
@@ -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
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) => {
|
package/cjs/form/form-store.d.ts
CHANGED
|
@@ -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
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) => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
8
|
-
require('../__chunks/
|
|
4
|
+
var _HMO4CKUPcjs = require('../__chunks/HMO4CKUP.cjs');
|
|
5
|
+
require('../__chunks/Y6PHIDP6.cjs');
|
|
6
|
+
require('../__chunks/MFSCSSBJ.cjs');
|
|
7
|
+
require('../__chunks/MWNFQD55.cjs');
|
|
8
|
+
require('../__chunks/5CBCKBZ2.cjs');
|
|
9
9
|
require('../__chunks/3UT5FE6K.cjs');
|
|
10
10
|
require('../__chunks/AV6KTKLE.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
exports.createHovercardStore =
|
|
13
|
+
exports.createHovercardStore = _HMO4CKUPcjs.createHovercardStore;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
4
|
+
var _CWDUO5EVcjs = require('../__chunks/CWDUO5EV.cjs');
|
|
5
|
+
require('../__chunks/ZXCB7MXN.cjs');
|
|
6
|
+
require('../__chunks/YLMJBIQM.cjs');
|
|
7
|
+
require('../__chunks/5CBCKBZ2.cjs');
|
|
8
8
|
require('../__chunks/3UT5FE6K.cjs');
|
|
9
9
|
require('../__chunks/5F4DVUNS.cjs');
|
|
10
10
|
require('../__chunks/ULSPM3Y3.cjs');
|
|
@@ -12,7 +12,7 @@ require('../__chunks/AV6KTKLE.cjs');
|
|
|
12
12
|
|
|
13
13
|
// src/menu/menu-bar-store.ts
|
|
14
14
|
function createMenuBarStore(props = {}) {
|
|
15
|
-
return
|
|
15
|
+
return _CWDUO5EVcjs.createMenubarStore.call(void 0, props);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
|
package/cjs/menu/menu-store.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
4
|
+
var _HMO4CKUPcjs = require('../__chunks/HMO4CKUP.cjs');
|
|
5
|
+
require('../__chunks/Y6PHIDP6.cjs');
|
|
6
|
+
require('../__chunks/MFSCSSBJ.cjs');
|
|
7
|
+
require('../__chunks/MWNFQD55.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('../__chunks/
|
|
10
|
+
var _ZXCB7MXNcjs = require('../__chunks/ZXCB7MXN.cjs');
|
|
11
|
+
require('../__chunks/YLMJBIQM.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ require('../__chunks/UCLKUBNP.cjs');
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _5CBCKBZ2cjs = require('../__chunks/5CBCKBZ2.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -42,10 +42,10 @@ function createMenuStore(_a = {}) {
|
|
|
42
42
|
"menubar"
|
|
43
43
|
]);
|
|
44
44
|
const parentIsMenubar = !!menubar && !parent;
|
|
45
|
-
const store =
|
|
45
|
+
const store = _5CBCKBZ2cjs.mergeStore.call(void 0,
|
|
46
46
|
props.store,
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
_5CBCKBZ2cjs.pick.call(void 0, parent, ["values"]),
|
|
48
|
+
_5CBCKBZ2cjs.omit.call(void 0, combobox, [
|
|
49
49
|
"arrowElement",
|
|
50
50
|
"anchorElement",
|
|
51
51
|
"contentElement",
|
|
@@ -53,9 +53,9 @@ function createMenuStore(_a = {}) {
|
|
|
53
53
|
"disclosureElement"
|
|
54
54
|
])
|
|
55
55
|
);
|
|
56
|
-
|
|
56
|
+
_5CBCKBZ2cjs.throwOnConflictingProps.call(void 0, props, store);
|
|
57
57
|
const syncState = store.getState();
|
|
58
|
-
const composite =
|
|
58
|
+
const composite = _ZXCB7MXNcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
59
59
|
store,
|
|
60
60
|
orientation: _3UT5FE6Kcjs.defaultValue.call(void 0,
|
|
61
61
|
props.orientation,
|
|
@@ -63,7 +63,7 @@ function createMenuStore(_a = {}) {
|
|
|
63
63
|
"vertical"
|
|
64
64
|
)
|
|
65
65
|
}));
|
|
66
|
-
const hovercard =
|
|
66
|
+
const hovercard = _HMO4CKUPcjs.createHovercardStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
67
67
|
store,
|
|
68
68
|
placement: _3UT5FE6Kcjs.defaultValue.call(void 0,
|
|
69
69
|
props.placement,
|
|
@@ -86,18 +86,18 @@ function createMenuStore(_a = {}) {
|
|
|
86
86
|
{}
|
|
87
87
|
)
|
|
88
88
|
});
|
|
89
|
-
const menu =
|
|
90
|
-
|
|
89
|
+
const menu = _5CBCKBZ2cjs.createStore.call(void 0, initialState, composite, hovercard, store);
|
|
90
|
+
_5CBCKBZ2cjs.setup.call(void 0,
|
|
91
91
|
menu,
|
|
92
|
-
() =>
|
|
92
|
+
() => _5CBCKBZ2cjs.sync.call(void 0, menu, ["mounted"], (state) => {
|
|
93
93
|
if (state.mounted)
|
|
94
94
|
return;
|
|
95
95
|
menu.setState("activeId", null);
|
|
96
96
|
})
|
|
97
97
|
);
|
|
98
|
-
|
|
98
|
+
_5CBCKBZ2cjs.setup.call(void 0,
|
|
99
99
|
menu,
|
|
100
|
-
() =>
|
|
100
|
+
() => _5CBCKBZ2cjs.sync.call(void 0, parent, ["orientation"], (state) => {
|
|
101
101
|
menu.setState(
|
|
102
102
|
"placement",
|
|
103
103
|
state.orientation === "vertical" ? "right-start" : "bottom-start"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
4
|
+
var _CWDUO5EVcjs = require('../__chunks/CWDUO5EV.cjs');
|
|
5
|
+
require('../__chunks/ZXCB7MXN.cjs');
|
|
6
|
+
require('../__chunks/YLMJBIQM.cjs');
|
|
7
|
+
require('../__chunks/5CBCKBZ2.cjs');
|
|
8
8
|
require('../__chunks/3UT5FE6K.cjs');
|
|
9
9
|
require('../__chunks/5F4DVUNS.cjs');
|
|
10
10
|
require('../__chunks/ULSPM3Y3.cjs');
|
|
11
11
|
require('../__chunks/AV6KTKLE.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.createMenubarStore =
|
|
14
|
+
exports.createMenubarStore = _CWDUO5EVcjs.createMenubarStore;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
6
|
-
require('../__chunks/
|
|
7
|
-
require('../__chunks/
|
|
4
|
+
var _Y6PHIDP6cjs = require('../__chunks/Y6PHIDP6.cjs');
|
|
5
|
+
require('../__chunks/MFSCSSBJ.cjs');
|
|
6
|
+
require('../__chunks/MWNFQD55.cjs');
|
|
7
|
+
require('../__chunks/5CBCKBZ2.cjs');
|
|
8
8
|
require('../__chunks/3UT5FE6K.cjs');
|
|
9
9
|
require('../__chunks/AV6KTKLE.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.createPopoverStore =
|
|
12
|
+
exports.createPopoverStore = _Y6PHIDP6cjs.createPopoverStore;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../__chunks/
|
|
4
|
+
var _ZXCB7MXNcjs = require('../__chunks/ZXCB7MXN.cjs');
|
|
5
|
+
require('../__chunks/YLMJBIQM.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _5CBCKBZ2cjs = require('../__chunks/5CBCKBZ2.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _3UT5FE6Kcjs = require('../__chunks/3UT5FE6K.cjs');
|
|
@@ -22,7 +22,7 @@ function createRadioStore(_a = {}) {
|
|
|
22
22
|
var props = _AV6KTKLEcjs.__objRest.call(void 0, _a, []);
|
|
23
23
|
var _a2;
|
|
24
24
|
const syncState = (_a2 = props.store) == null ? void 0 : _a2.getState();
|
|
25
|
-
const composite =
|
|
25
|
+
const composite = _ZXCB7MXNcjs.createCompositeStore.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
|
|
26
26
|
focusLoop: _3UT5FE6Kcjs.defaultValue.call(void 0, props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true)
|
|
27
27
|
}));
|
|
28
28
|
const initialState = _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite.getState()), {
|
|
@@ -33,7 +33,7 @@ function createRadioStore(_a = {}) {
|
|
|
33
33
|
null
|
|
34
34
|
)
|
|
35
35
|
});
|
|
36
|
-
const radio =
|
|
36
|
+
const radio = _5CBCKBZ2cjs.createStore.call(void 0, initialState, composite, props.store);
|
|
37
37
|
return _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, composite), radio), {
|
|
38
38
|
setValue: (value) => radio.setState("value", value)
|
|
39
39
|
});
|