mal-ui 0.1.3
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/README.md +244 -0
- package/dist/carousel/extensions.d.ts +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +424 -0
- package/dist/carousel/index.js.map +15 -0
- package/dist/charts/extensions.d.ts +1 -0
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +3499 -0
- package/dist/charts/index.js.map +53 -0
- package/dist/chunks/index-3ffbn0gc.js +29976 -0
- package/dist/chunks/index-3ffbn0gc.js.map +637 -0
- package/dist/chunks/index-6b5mapr4.js +2 -0
- package/dist/chunks/index-6b5mapr4.js.map +9 -0
- package/dist/chunks/index-6tm93gww.js +38 -0
- package/dist/chunks/index-6tm93gww.js.map +10 -0
- package/dist/chunks/index-cg10ezdx.js +2 -0
- package/dist/chunks/index-cg10ezdx.js.map +9 -0
- package/dist/chunks/index-mc01z7m9.js +48 -0
- package/dist/chunks/index-mc01z7m9.js.map +9 -0
- package/dist/chunks/index-rz8zh7g4.js +5015 -0
- package/dist/chunks/index-rz8zh7g4.js.map +113 -0
- package/dist/chunks/index-syjq3515.js +4893 -0
- package/dist/chunks/index-syjq3515.js.map +101 -0
- package/dist/chunks/index-w9ekv5h5.js +733 -0
- package/dist/chunks/index-w9ekv5h5.js.map +17 -0
- package/dist/code-highlight/extensions.d.ts +1 -0
- package/dist/code-highlight/index.d.ts +2 -0
- package/dist/code-highlight/index.js +1685 -0
- package/dist/code-highlight/index.js.map +25 -0
- package/dist/core/extensions.d.ts +2 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +844 -0
- package/dist/core/index.js.map +9 -0
- package/dist/dates/extensions.d.ts +1 -0
- package/dist/dates/index.d.ts +2 -0
- package/dist/dates/index.js +107 -0
- package/dist/dates/index.js.map +9 -0
- package/dist/dropzone/extensions.d.ts +1 -0
- package/dist/dropzone/index.d.ts +2 -0
- package/dist/dropzone/index.js +2681 -0
- package/dist/dropzone/index.js.map +21 -0
- package/dist/form/extensions.d.ts +1 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/form/index.js +1605 -0
- package/dist/form/index.js.map +51 -0
- package/dist/hooks/extensions.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +214 -0
- package/dist/hooks/index.js.map +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1052 -0
- package/dist/index.js.map +9 -0
- package/dist/modals/extensions.d.ts +1 -0
- package/dist/modals/index.d.ts +2 -0
- package/dist/modals/index.js +387 -0
- package/dist/modals/index.js.map +15 -0
- package/dist/notifications/extensions.d.ts +1 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +1122 -0
- package/dist/notifications/index.js.map +28 -0
- package/dist/nprogress/extensions.d.ts +1 -0
- package/dist/nprogress/index.d.ts +2 -0
- package/dist/nprogress/index.js +207 -0
- package/dist/nprogress/index.js.map +12 -0
- package/dist/schedule/extensions.d.ts +1 -0
- package/dist/schedule/index.d.ts +2 -0
- package/dist/schedule/index.js +8569 -0
- package/dist/schedule/index.js.map +135 -0
- package/dist/spotlight/extensions.d.ts +1 -0
- package/dist/spotlight/index.d.ts +2 -0
- package/dist/spotlight/index.js +666 -0
- package/dist/spotlight/index.js.map +24 -0
- package/dist/styles.css +1 -0
- package/dist/theme/index.d.ts +13 -0
- package/dist/theme/index.js +202 -0
- package/dist/theme/index.js.map +11 -0
- package/dist/theme/tokens.d.ts +65 -0
- package/dist/tiptap/extensions.d.ts +1 -0
- package/dist/tiptap/index.d.ts +2 -0
- package/dist/tiptap/index.js +1549 -0
- package/dist/tiptap/index.js.map +25 -0
- package/package.json +163 -0
|
@@ -0,0 +1,1605 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
__commonJS,
|
|
4
|
+
__toESM
|
|
5
|
+
} from "../chunks/index-mc01z7m9.js";
|
|
6
|
+
|
|
7
|
+
// node_modules/fast-deep-equal/index.js
|
|
8
|
+
var require_fast_deep_equal = __commonJS((exports, module) => {
|
|
9
|
+
module.exports = function equal(a, b) {
|
|
10
|
+
if (a === b)
|
|
11
|
+
return true;
|
|
12
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
13
|
+
if (a.constructor !== b.constructor)
|
|
14
|
+
return false;
|
|
15
|
+
var length, i, keys;
|
|
16
|
+
if (Array.isArray(a)) {
|
|
17
|
+
length = a.length;
|
|
18
|
+
if (length != b.length)
|
|
19
|
+
return false;
|
|
20
|
+
for (i = length;i-- !== 0; )
|
|
21
|
+
if (!equal(a[i], b[i]))
|
|
22
|
+
return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (a.constructor === RegExp)
|
|
26
|
+
return a.source === b.source && a.flags === b.flags;
|
|
27
|
+
if (a.valueOf !== Object.prototype.valueOf)
|
|
28
|
+
return a.valueOf() === b.valueOf();
|
|
29
|
+
if (a.toString !== Object.prototype.toString)
|
|
30
|
+
return a.toString() === b.toString();
|
|
31
|
+
keys = Object.keys(a);
|
|
32
|
+
length = keys.length;
|
|
33
|
+
if (length !== Object.keys(b).length)
|
|
34
|
+
return false;
|
|
35
|
+
for (i = length;i-- !== 0; )
|
|
36
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
37
|
+
return false;
|
|
38
|
+
for (i = length;i-- !== 0; ) {
|
|
39
|
+
var key = keys[i];
|
|
40
|
+
if (!equal(a[key], b[key]))
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return a !== a && b !== b;
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// node_modules/@mantine/form/esm/actions/actions.mjs
|
|
50
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
51
|
+
|
|
52
|
+
function dispatchEvent(type, detail) {
|
|
53
|
+
window.dispatchEvent(new CustomEvent(type, { detail }));
|
|
54
|
+
}
|
|
55
|
+
function validateFormName(name) {
|
|
56
|
+
if (!/^[0-9a-zA-Z-]+$/.test(name))
|
|
57
|
+
throw new Error(`[@mantine/use-form] Form name "${name}" is invalid, it should contain only letters, numbers and dashes`);
|
|
58
|
+
}
|
|
59
|
+
var useIsomorphicEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
60
|
+
function createFormActions(name) {
|
|
61
|
+
validateFormName(name);
|
|
62
|
+
const setFieldValue = (path, value) => dispatchEvent(`mantine-form:${name}:set-field-value`, {
|
|
63
|
+
path,
|
|
64
|
+
value
|
|
65
|
+
});
|
|
66
|
+
const setValues = (values) => dispatchEvent(`mantine-form:${name}:set-values`, values);
|
|
67
|
+
const setInitialValues = (values) => dispatchEvent(`mantine-form:${name}:set-initial-values`, values);
|
|
68
|
+
const setErrors = (errors) => dispatchEvent(`mantine-form:${name}:set-errors`, errors);
|
|
69
|
+
const setFieldError = (path, error) => dispatchEvent(`mantine-form:${name}:set-field-error`, {
|
|
70
|
+
path,
|
|
71
|
+
error
|
|
72
|
+
});
|
|
73
|
+
const clearFieldError = (path) => dispatchEvent(`mantine-form:${name}:clear-field-error`, path);
|
|
74
|
+
const clearErrors = () => dispatchEvent(`mantine-form:${name}:clear-errors`);
|
|
75
|
+
const reset = () => dispatchEvent(`mantine-form:${name}:reset`);
|
|
76
|
+
const validate = () => dispatchEvent(`mantine-form:${name}:validate`);
|
|
77
|
+
const validateField = (path) => dispatchEvent(`mantine-form:${name}:validate-field`, path);
|
|
78
|
+
const reorderListItem = (path, payload) => dispatchEvent(`mantine-form:${name}:reorder-list-item`, {
|
|
79
|
+
path,
|
|
80
|
+
payload
|
|
81
|
+
});
|
|
82
|
+
const removeListItem = (path, index) => dispatchEvent(`mantine-form:${name}:remove-list-item`, {
|
|
83
|
+
path,
|
|
84
|
+
index
|
|
85
|
+
});
|
|
86
|
+
const insertListItem = (path, item, index) => dispatchEvent(`mantine-form:${name}:insert-list-item`, {
|
|
87
|
+
path,
|
|
88
|
+
index,
|
|
89
|
+
item
|
|
90
|
+
});
|
|
91
|
+
const setDirty = (value) => dispatchEvent(`mantine-form:${name}:set-dirty`, value);
|
|
92
|
+
const setTouched = (value) => dispatchEvent(`mantine-form:${name}:set-touched`, value);
|
|
93
|
+
const resetDirty = (values) => dispatchEvent(`mantine-form:${name}:reset-dirty`, values);
|
|
94
|
+
const resetTouched = () => dispatchEvent(`mantine-form:${name}:reset-touched`);
|
|
95
|
+
return {
|
|
96
|
+
setFieldValue,
|
|
97
|
+
setValues,
|
|
98
|
+
setInitialValues,
|
|
99
|
+
setErrors,
|
|
100
|
+
setFieldError,
|
|
101
|
+
clearFieldError,
|
|
102
|
+
clearErrors,
|
|
103
|
+
reset,
|
|
104
|
+
validate,
|
|
105
|
+
validateField,
|
|
106
|
+
reorderListItem,
|
|
107
|
+
removeListItem,
|
|
108
|
+
insertListItem,
|
|
109
|
+
setDirty,
|
|
110
|
+
setTouched,
|
|
111
|
+
resetDirty,
|
|
112
|
+
resetTouched
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function useFormEvent(eventKey, handler) {
|
|
116
|
+
useIsomorphicEffect(() => {
|
|
117
|
+
if (eventKey) {
|
|
118
|
+
window.addEventListener(eventKey, handler);
|
|
119
|
+
return () => window.removeEventListener(eventKey, handler);
|
|
120
|
+
}
|
|
121
|
+
}, [eventKey]);
|
|
122
|
+
}
|
|
123
|
+
function useFormActions(name, form) {
|
|
124
|
+
if (name)
|
|
125
|
+
validateFormName(name);
|
|
126
|
+
useFormEvent(`mantine-form:${name}:set-field-value`, (event) => form.setFieldValue(event.detail.path, event.detail.value));
|
|
127
|
+
useFormEvent(`mantine-form:${name}:set-values`, (event) => form.setValues(event.detail));
|
|
128
|
+
useFormEvent(`mantine-form:${name}:set-initial-values`, (event) => form.setInitialValues(event.detail));
|
|
129
|
+
useFormEvent(`mantine-form:${name}:set-errors`, (event) => form.setErrors(event.detail));
|
|
130
|
+
useFormEvent(`mantine-form:${name}:set-field-error`, (event) => form.setFieldError(event.detail.path, event.detail.error));
|
|
131
|
+
useFormEvent(`mantine-form:${name}:clear-field-error`, (event) => form.clearFieldError(event.detail));
|
|
132
|
+
useFormEvent(`mantine-form:${name}:clear-errors`, form.clearErrors);
|
|
133
|
+
useFormEvent(`mantine-form:${name}:reset`, form.reset);
|
|
134
|
+
useFormEvent(`mantine-form:${name}:validate`, form.validate);
|
|
135
|
+
useFormEvent(`mantine-form:${name}:validate-field`, (event) => form.validateField(event.detail));
|
|
136
|
+
useFormEvent(`mantine-form:${name}:reorder-list-item`, (event) => form.reorderListItem(event.detail.path, event.detail.payload));
|
|
137
|
+
useFormEvent(`mantine-form:${name}:remove-list-item`, (event) => form.removeListItem(event.detail.path, event.detail.index));
|
|
138
|
+
useFormEvent(`mantine-form:${name}:insert-list-item`, (event) => form.insertListItem(event.detail.path, event.detail.item, event.detail.index));
|
|
139
|
+
useFormEvent(`mantine-form:${name}:set-dirty`, (event) => form.setDirty(event.detail));
|
|
140
|
+
useFormEvent(`mantine-form:${name}:set-touched`, (event) => form.setTouched(event.detail));
|
|
141
|
+
useFormEvent(`mantine-form:${name}:reset-dirty`, (event) => form.resetDirty(event.detail));
|
|
142
|
+
useFormEvent(`mantine-form:${name}:reset-touched`, form.resetTouched);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// node_modules/@mantine/form/esm/hooks/use-form-errors/filter-errors/filter-errors.mjs
|
|
146
|
+
|
|
147
|
+
function filterErrors(errors) {
|
|
148
|
+
if (errors === null || typeof errors !== "object")
|
|
149
|
+
return {};
|
|
150
|
+
return Object.keys(errors).reduce((acc, key) => {
|
|
151
|
+
const errorValue = errors[key];
|
|
152
|
+
if (errorValue !== undefined && errorValue !== null && errorValue !== false)
|
|
153
|
+
acc[key] = errorValue;
|
|
154
|
+
return acc;
|
|
155
|
+
}, {});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// node_modules/@mantine/form/esm/paths/get-splitted-path.mjs
|
|
159
|
+
|
|
160
|
+
function getSplittedPath(path) {
|
|
161
|
+
if (typeof path !== "string")
|
|
162
|
+
return [];
|
|
163
|
+
return path.split(".");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// node_modules/@mantine/form/esm/paths/get-path.mjs
|
|
167
|
+
|
|
168
|
+
function getPath(path, values) {
|
|
169
|
+
const splittedPath = getSplittedPath(path);
|
|
170
|
+
if (splittedPath.length === 0 || typeof values !== "object" || values === null)
|
|
171
|
+
return;
|
|
172
|
+
let value = values[splittedPath[0]];
|
|
173
|
+
for (let i = 1;i < splittedPath.length; i += 1) {
|
|
174
|
+
if (value == null)
|
|
175
|
+
break;
|
|
176
|
+
value = value[splittedPath[i]];
|
|
177
|
+
}
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// node_modules/@mantine/form/esm/validate/validate-values.mjs
|
|
182
|
+
|
|
183
|
+
var formRootRule = Symbol("root-rule");
|
|
184
|
+
function getValidationResults(errors) {
|
|
185
|
+
const filteredErrors = filterErrors(errors);
|
|
186
|
+
return {
|
|
187
|
+
hasErrors: Object.keys(filteredErrors).length > 0,
|
|
188
|
+
errors: filteredErrors
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function validateRulesRecord(rules, values, resolveValidationError, signal, path = "", errors = {}) {
|
|
192
|
+
if (typeof rules !== "object" || rules === null)
|
|
193
|
+
return errors;
|
|
194
|
+
const asyncTasks = [];
|
|
195
|
+
const pendingRecursions = [];
|
|
196
|
+
for (const ruleKey of Object.keys(rules)) {
|
|
197
|
+
const rule = rules[ruleKey];
|
|
198
|
+
const rulePath = `${path === "" ? "" : `${path}.`}${ruleKey}`;
|
|
199
|
+
const value = getPath(rulePath, values);
|
|
200
|
+
let arrayValidation = false;
|
|
201
|
+
if (typeof rule === "function") {
|
|
202
|
+
const result = rule(value, values, rulePath, signal);
|
|
203
|
+
if (result instanceof Promise)
|
|
204
|
+
asyncTasks.push({
|
|
205
|
+
rulePath,
|
|
206
|
+
promise: result
|
|
207
|
+
});
|
|
208
|
+
else
|
|
209
|
+
errors[rulePath] = result;
|
|
210
|
+
}
|
|
211
|
+
if (typeof rule === "object" && Array.isArray(value)) {
|
|
212
|
+
arrayValidation = true;
|
|
213
|
+
for (let index = 0;index < value.length; index++) {
|
|
214
|
+
const recursionResult = validateRulesRecord(rule, values, resolveValidationError, signal, `${rulePath}.${index}`, errors);
|
|
215
|
+
if (recursionResult instanceof Promise)
|
|
216
|
+
pendingRecursions.push(recursionResult);
|
|
217
|
+
}
|
|
218
|
+
if (formRootRule in rule) {
|
|
219
|
+
const rootResult = rule[formRootRule](value, values, rulePath, signal);
|
|
220
|
+
if (rootResult instanceof Promise)
|
|
221
|
+
asyncTasks.push({
|
|
222
|
+
rulePath,
|
|
223
|
+
promise: rootResult
|
|
224
|
+
});
|
|
225
|
+
else
|
|
226
|
+
errors[rulePath] = rootResult;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (typeof rule === "object" && typeof value === "object" && value !== null) {
|
|
230
|
+
if (!arrayValidation) {
|
|
231
|
+
const recursionResult = validateRulesRecord(rule, values, resolveValidationError, signal, rulePath, errors);
|
|
232
|
+
if (recursionResult instanceof Promise)
|
|
233
|
+
pendingRecursions.push(recursionResult);
|
|
234
|
+
}
|
|
235
|
+
if (formRootRule in rule) {
|
|
236
|
+
const rootResult = rule[formRootRule](value, values, rulePath, signal);
|
|
237
|
+
if (rootResult instanceof Promise)
|
|
238
|
+
asyncTasks.push({
|
|
239
|
+
rulePath,
|
|
240
|
+
promise: rootResult
|
|
241
|
+
});
|
|
242
|
+
else
|
|
243
|
+
errors[rulePath] = rootResult;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (asyncTasks.length === 0 && pendingRecursions.length === 0)
|
|
248
|
+
return errors;
|
|
249
|
+
return (async () => {
|
|
250
|
+
await Promise.all(pendingRecursions);
|
|
251
|
+
if (asyncTasks.length > 0)
|
|
252
|
+
(await Promise.allSettled(asyncTasks.map((t) => t.promise))).forEach((result, index) => {
|
|
253
|
+
const { rulePath } = asyncTasks[index];
|
|
254
|
+
if (result.status === "fulfilled")
|
|
255
|
+
errors[rulePath] = result.value;
|
|
256
|
+
else
|
|
257
|
+
errors[rulePath] = resolveValidationError(result.reason);
|
|
258
|
+
});
|
|
259
|
+
return errors;
|
|
260
|
+
})();
|
|
261
|
+
}
|
|
262
|
+
var defaultResolveError = (err) => err instanceof Error ? err.message : String(err);
|
|
263
|
+
function validateValues(validate, values, resolveValidationError = defaultResolveError, signal = new AbortController().signal) {
|
|
264
|
+
if (typeof validate === "function") {
|
|
265
|
+
const result = validate(values);
|
|
266
|
+
if (result instanceof Promise)
|
|
267
|
+
return result.then(getValidationResults);
|
|
268
|
+
return getValidationResults(result);
|
|
269
|
+
}
|
|
270
|
+
const errorsResult = validateRulesRecord(validate, values, resolveValidationError, signal);
|
|
271
|
+
if (errorsResult instanceof Promise)
|
|
272
|
+
return errorsResult.then(getValidationResults);
|
|
273
|
+
return getValidationResults(errorsResult);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// node_modules/@mantine/form/esm/form-index.mjs
|
|
277
|
+
|
|
278
|
+
var FORM_INDEX = "__MANTINE_FORM_INDEX__";
|
|
279
|
+
|
|
280
|
+
// node_modules/@mantine/form/esm/get-input-on-change/get-input-on-change.mjs
|
|
281
|
+
|
|
282
|
+
function getInputOnChange(setValue) {
|
|
283
|
+
return (val) => {
|
|
284
|
+
if (!val)
|
|
285
|
+
setValue(val);
|
|
286
|
+
else if (typeof val === "function")
|
|
287
|
+
setValue(val);
|
|
288
|
+
else if (typeof val === "object" && "nativeEvent" in val) {
|
|
289
|
+
const { currentTarget } = val;
|
|
290
|
+
if (currentTarget instanceof HTMLInputElement)
|
|
291
|
+
if (currentTarget.type === "checkbox")
|
|
292
|
+
setValue(currentTarget.checked);
|
|
293
|
+
else
|
|
294
|
+
setValue(currentTarget.value);
|
|
295
|
+
else if (currentTarget instanceof HTMLTextAreaElement || currentTarget instanceof HTMLSelectElement)
|
|
296
|
+
setValue(currentTarget.value);
|
|
297
|
+
} else
|
|
298
|
+
setValue(val);
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// node_modules/@mantine/form/esm/hooks/use-form-errors/use-form-errors.mjs
|
|
303
|
+
import { useCallback, useRef, useState } from "react";
|
|
304
|
+
|
|
305
|
+
function useFormErrors(initialErrors) {
|
|
306
|
+
const [errorsState, setErrorsState] = useState(filterErrors(initialErrors));
|
|
307
|
+
const errorsRef = useRef(errorsState);
|
|
308
|
+
const setErrors = useCallback((errors) => {
|
|
309
|
+
setErrorsState((current) => {
|
|
310
|
+
const newErrors = filterErrors(typeof errors === "function" ? errors(current) : errors);
|
|
311
|
+
errorsRef.current = newErrors;
|
|
312
|
+
return newErrors;
|
|
313
|
+
});
|
|
314
|
+
}, []);
|
|
315
|
+
const clearErrors = useCallback(() => setErrors({}), []);
|
|
316
|
+
const clearFieldError = useCallback((path) => {
|
|
317
|
+
if (errorsRef.current[path] === undefined)
|
|
318
|
+
return;
|
|
319
|
+
setErrors((current) => {
|
|
320
|
+
const errors = { ...current };
|
|
321
|
+
delete errors[path];
|
|
322
|
+
return errors;
|
|
323
|
+
});
|
|
324
|
+
}, [errorsState]);
|
|
325
|
+
return {
|
|
326
|
+
errorsState,
|
|
327
|
+
setErrors,
|
|
328
|
+
clearErrors,
|
|
329
|
+
setFieldError: useCallback((path, error) => {
|
|
330
|
+
if (error == null || error === false)
|
|
331
|
+
clearFieldError(path);
|
|
332
|
+
else if (errorsRef.current[path] !== error)
|
|
333
|
+
setErrors((current) => ({
|
|
334
|
+
...current,
|
|
335
|
+
[path]: error
|
|
336
|
+
}));
|
|
337
|
+
}, [errorsState]),
|
|
338
|
+
clearFieldError
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// node_modules/@mantine/form/esm/paths/get-data-path.mjs
|
|
343
|
+
|
|
344
|
+
function getDataPath(formName, fieldPath) {
|
|
345
|
+
return formName ? `${formName}-${fieldPath.toString()}` : fieldPath.toString();
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// node_modules/@mantine/form/esm/lists/clear-list-state.mjs
|
|
349
|
+
|
|
350
|
+
function clearListState(field, state) {
|
|
351
|
+
if (state === null || typeof state !== "object")
|
|
352
|
+
return {};
|
|
353
|
+
const clone = { ...state };
|
|
354
|
+
Object.keys(state).forEach((errorKey) => {
|
|
355
|
+
if (errorKey.includes(`${String(field)}.`))
|
|
356
|
+
delete clone[errorKey];
|
|
357
|
+
});
|
|
358
|
+
return clone;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// node_modules/@mantine/form/esm/lists/change-error-indices.mjs
|
|
362
|
+
|
|
363
|
+
function getIndexFromKeyAfterPath(key, path) {
|
|
364
|
+
const split = key.substring(path.length + 1).split(".")[0];
|
|
365
|
+
return parseInt(split, 10);
|
|
366
|
+
}
|
|
367
|
+
function changeErrorIndices(path, index, errors, change) {
|
|
368
|
+
if (index === undefined)
|
|
369
|
+
return errors;
|
|
370
|
+
const pathString = `${String(path)}`;
|
|
371
|
+
let clearedErrors = errors;
|
|
372
|
+
if (change === -1)
|
|
373
|
+
clearedErrors = clearListState(`${pathString}.${index}`, clearedErrors);
|
|
374
|
+
const cloned = { ...clearedErrors };
|
|
375
|
+
const changedKeys = /* @__PURE__ */ new Set;
|
|
376
|
+
Object.entries(clearedErrors).filter(([key]) => {
|
|
377
|
+
if (!key.startsWith(`${pathString}.`))
|
|
378
|
+
return false;
|
|
379
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
380
|
+
if (Number.isNaN(currIndex))
|
|
381
|
+
return false;
|
|
382
|
+
return currIndex >= index;
|
|
383
|
+
}).forEach(([key, value]) => {
|
|
384
|
+
const currIndex = getIndexFromKeyAfterPath(key, pathString);
|
|
385
|
+
const newKey = key.replace(`${pathString}.${currIndex}`, `${pathString}.${currIndex + change}`);
|
|
386
|
+
cloned[newKey] = value;
|
|
387
|
+
changedKeys.add(newKey);
|
|
388
|
+
if (!changedKeys.has(key))
|
|
389
|
+
delete cloned[key];
|
|
390
|
+
});
|
|
391
|
+
return cloned;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// node_modules/@mantine/form/esm/lists/reorder-errors.mjs
|
|
395
|
+
|
|
396
|
+
function reorderErrors(path, { from, to }, errors) {
|
|
397
|
+
const oldKeyStart = `${path}.${from}`;
|
|
398
|
+
const newKeyStart = `${path}.${to}`;
|
|
399
|
+
const clone = { ...errors };
|
|
400
|
+
const processedKeys = /* @__PURE__ */ new Set;
|
|
401
|
+
Object.keys(errors).forEach((key) => {
|
|
402
|
+
if (processedKeys.has(key))
|
|
403
|
+
return;
|
|
404
|
+
let oldKey;
|
|
405
|
+
let newKey;
|
|
406
|
+
if (key.startsWith(oldKeyStart)) {
|
|
407
|
+
oldKey = key;
|
|
408
|
+
newKey = key.replace(oldKeyStart, newKeyStart);
|
|
409
|
+
} else if (key.startsWith(newKeyStart)) {
|
|
410
|
+
oldKey = key.replace(newKeyStart, oldKeyStart);
|
|
411
|
+
newKey = key;
|
|
412
|
+
}
|
|
413
|
+
if (oldKey && newKey) {
|
|
414
|
+
const value1 = clone[oldKey];
|
|
415
|
+
const value2 = clone[newKey];
|
|
416
|
+
value2 === undefined ? delete clone[oldKey] : clone[oldKey] = value2;
|
|
417
|
+
value1 === undefined ? delete clone[newKey] : clone[newKey] = value1;
|
|
418
|
+
processedKeys.add(oldKey);
|
|
419
|
+
processedKeys.add(newKey);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return clone;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// node_modules/klona/full/index.mjs
|
|
426
|
+
function set(obj, key, val) {
|
|
427
|
+
if (typeof val.value === "object")
|
|
428
|
+
val.value = klona(val.value);
|
|
429
|
+
if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
|
|
430
|
+
Object.defineProperty(obj, key, val);
|
|
431
|
+
} else
|
|
432
|
+
obj[key] = val.value;
|
|
433
|
+
}
|
|
434
|
+
function klona(x) {
|
|
435
|
+
if (typeof x !== "object")
|
|
436
|
+
return x;
|
|
437
|
+
var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
|
|
438
|
+
if (str === "[object Object]") {
|
|
439
|
+
tmp = Object.create(x.__proto__ || null);
|
|
440
|
+
} else if (str === "[object Array]") {
|
|
441
|
+
tmp = Array(x.length);
|
|
442
|
+
} else if (str === "[object Set]") {
|
|
443
|
+
tmp = new Set;
|
|
444
|
+
x.forEach(function(val) {
|
|
445
|
+
tmp.add(klona(val));
|
|
446
|
+
});
|
|
447
|
+
} else if (str === "[object Map]") {
|
|
448
|
+
tmp = new Map;
|
|
449
|
+
x.forEach(function(val, key) {
|
|
450
|
+
tmp.set(klona(key), klona(val));
|
|
451
|
+
});
|
|
452
|
+
} else if (str === "[object Date]") {
|
|
453
|
+
tmp = new Date(+x);
|
|
454
|
+
} else if (str === "[object RegExp]") {
|
|
455
|
+
tmp = new RegExp(x.source, x.flags);
|
|
456
|
+
} else if (str === "[object DataView]") {
|
|
457
|
+
tmp = new x.constructor(klona(x.buffer));
|
|
458
|
+
} else if (str === "[object ArrayBuffer]") {
|
|
459
|
+
tmp = x.slice(0);
|
|
460
|
+
} else if (str.slice(-6) === "Array]") {
|
|
461
|
+
tmp = new x.constructor(x);
|
|
462
|
+
}
|
|
463
|
+
if (tmp) {
|
|
464
|
+
for (list = Object.getOwnPropertySymbols(x);i < list.length; i++) {
|
|
465
|
+
set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
|
|
466
|
+
}
|
|
467
|
+
for (i = 0, list = Object.getOwnPropertyNames(x);i < list.length; i++) {
|
|
468
|
+
if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k])
|
|
469
|
+
continue;
|
|
470
|
+
set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return tmp || x;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// node_modules/@mantine/form/esm/paths/set-path.mjs
|
|
477
|
+
|
|
478
|
+
function setPath(path, value, values) {
|
|
479
|
+
const splittedPath = getSplittedPath(path);
|
|
480
|
+
if (splittedPath.length === 0)
|
|
481
|
+
return values;
|
|
482
|
+
const cloned = klona(values);
|
|
483
|
+
if (splittedPath.length === 1) {
|
|
484
|
+
cloned[splittedPath[0]] = value;
|
|
485
|
+
return cloned;
|
|
486
|
+
}
|
|
487
|
+
let val = cloned[splittedPath[0]];
|
|
488
|
+
for (let i = 1;i < splittedPath.length - 1; i += 1) {
|
|
489
|
+
if (val === undefined)
|
|
490
|
+
return cloned;
|
|
491
|
+
val = val[splittedPath[i]];
|
|
492
|
+
}
|
|
493
|
+
val[splittedPath[splittedPath.length - 1]] = value;
|
|
494
|
+
return cloned;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// node_modules/@mantine/form/esm/paths/reorder-path.mjs
|
|
498
|
+
|
|
499
|
+
function reorderPath(path, { from, to }, values) {
|
|
500
|
+
const currentValue = getPath(path, values);
|
|
501
|
+
if (!Array.isArray(currentValue))
|
|
502
|
+
return values;
|
|
503
|
+
const cloned = [...currentValue];
|
|
504
|
+
const item = currentValue[from];
|
|
505
|
+
cloned.splice(from, 1);
|
|
506
|
+
cloned.splice(to, 0, item);
|
|
507
|
+
return setPath(path, cloned, values);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// node_modules/@mantine/form/esm/paths/insert-path.mjs
|
|
511
|
+
|
|
512
|
+
function insertPath(path, value, index, values) {
|
|
513
|
+
const currentValue = getPath(path, values);
|
|
514
|
+
if (!Array.isArray(currentValue))
|
|
515
|
+
return values;
|
|
516
|
+
const cloned = [...currentValue];
|
|
517
|
+
cloned.splice(typeof index === "number" ? index : cloned.length, 0, value);
|
|
518
|
+
return setPath(path, cloned, values);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// node_modules/@mantine/form/esm/paths/remove-path.mjs
|
|
522
|
+
|
|
523
|
+
function removePath(path, index, values) {
|
|
524
|
+
const currentValue = getPath(path, values);
|
|
525
|
+
if (!Array.isArray(currentValue))
|
|
526
|
+
return values;
|
|
527
|
+
return setPath(path, currentValue.filter((_, itemIndex) => itemIndex !== index), values);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// node_modules/@mantine/form/esm/paths/replace-path.mjs
|
|
531
|
+
|
|
532
|
+
function replacePath(path, item, index, values) {
|
|
533
|
+
const currentValue = getPath(path, values);
|
|
534
|
+
if (!Array.isArray(currentValue))
|
|
535
|
+
return values;
|
|
536
|
+
if (currentValue.length <= index)
|
|
537
|
+
return values;
|
|
538
|
+
const cloned = [...currentValue];
|
|
539
|
+
cloned[index] = item;
|
|
540
|
+
return setPath(path, cloned, values);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// node_modules/@mantine/form/esm/hooks/use-form-list/use-form-list.mjs
|
|
544
|
+
import { useCallback as useCallback2 } from "react";
|
|
545
|
+
|
|
546
|
+
function useFormList({ $values, $errors, $status, $watch }) {
|
|
547
|
+
return {
|
|
548
|
+
reorderListItem: useCallback2((path, payload) => {
|
|
549
|
+
const previousValues = $values.refValues.current;
|
|
550
|
+
$status.clearFieldDirty(path);
|
|
551
|
+
$errors.setErrors((errs) => reorderErrors(path, payload, errs));
|
|
552
|
+
$values.setValues({
|
|
553
|
+
values: reorderPath(path, payload, $values.refValues.current),
|
|
554
|
+
updateState: true
|
|
555
|
+
});
|
|
556
|
+
$watch.notifyWatchSubscribers(previousValues);
|
|
557
|
+
}, []),
|
|
558
|
+
removeListItem: useCallback2((path, index) => {
|
|
559
|
+
const previousValues = $values.refValues.current;
|
|
560
|
+
$status.clearFieldDirty(path);
|
|
561
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, -1));
|
|
562
|
+
$values.setValues({
|
|
563
|
+
values: removePath(path, index, $values.refValues.current),
|
|
564
|
+
updateState: true
|
|
565
|
+
});
|
|
566
|
+
$watch.notifyWatchSubscribers(previousValues);
|
|
567
|
+
}, []),
|
|
568
|
+
insertListItem: useCallback2((path, item, index) => {
|
|
569
|
+
const previousValues = $values.refValues.current;
|
|
570
|
+
$status.clearFieldDirty(path);
|
|
571
|
+
$errors.setErrors((errs) => changeErrorIndices(path, index, errs, 1));
|
|
572
|
+
$values.setValues({
|
|
573
|
+
values: insertPath(path, item, index, $values.refValues.current),
|
|
574
|
+
updateState: true
|
|
575
|
+
});
|
|
576
|
+
$watch.notifyWatchSubscribers(previousValues);
|
|
577
|
+
}, []),
|
|
578
|
+
replaceListItem: useCallback2((path, index, item) => {
|
|
579
|
+
const previousValues = $values.refValues.current;
|
|
580
|
+
$status.clearFieldDirty(path);
|
|
581
|
+
$values.setValues({
|
|
582
|
+
values: replacePath(path, item, index, $values.refValues.current),
|
|
583
|
+
updateState: true
|
|
584
|
+
});
|
|
585
|
+
$watch.notifyWatchSubscribers(previousValues);
|
|
586
|
+
}, [])
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
// node_modules/@mantine/form/esm/get-status/get-status.mjs
|
|
591
|
+
|
|
592
|
+
function getStatus(status, path) {
|
|
593
|
+
const paths = Object.keys(status);
|
|
594
|
+
if (typeof path === "string") {
|
|
595
|
+
const nestedPaths = paths.filter((statusPath) => statusPath.startsWith(`${path}.`));
|
|
596
|
+
return status[path] || nestedPaths.some((statusPath) => status[statusPath]) || false;
|
|
597
|
+
}
|
|
598
|
+
return paths.some((statusPath) => status[statusPath]);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// node_modules/@mantine/form/esm/hooks/use-form-status/use-form-status.mjs
|
|
602
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal(), 1);
|
|
603
|
+
import { useCallback as useCallback3, useRef as useRef2, useState as useState2 } from "react";
|
|
604
|
+
|
|
605
|
+
function useFormStatus({ initialDirty, initialTouched, mode, $values }) {
|
|
606
|
+
const [touchedState, setTouchedState] = useState2(initialTouched);
|
|
607
|
+
const [dirtyState, setDirtyState] = useState2(initialDirty);
|
|
608
|
+
const touchedRef = useRef2(initialTouched);
|
|
609
|
+
const dirtyRef = useRef2(initialDirty);
|
|
610
|
+
const setTouched = useCallback3((values) => {
|
|
611
|
+
const resolvedValues = typeof values === "function" ? values(touchedRef.current) : values;
|
|
612
|
+
touchedRef.current = resolvedValues;
|
|
613
|
+
if (mode === "controlled")
|
|
614
|
+
setTouchedState(resolvedValues);
|
|
615
|
+
}, []);
|
|
616
|
+
const setDirty = useCallback3((values, forceUpdate = false) => {
|
|
617
|
+
const resolvedValues = typeof values === "function" ? values(dirtyRef.current) : values;
|
|
618
|
+
dirtyRef.current = resolvedValues;
|
|
619
|
+
if (mode === "controlled" || forceUpdate)
|
|
620
|
+
setDirtyState(resolvedValues);
|
|
621
|
+
}, []);
|
|
622
|
+
const resetTouched = useCallback3(() => setTouched({}), []);
|
|
623
|
+
const resetDirty = useCallback3((values) => {
|
|
624
|
+
const newSnapshot = values ? {
|
|
625
|
+
...$values.refValues.current,
|
|
626
|
+
...values
|
|
627
|
+
} : $values.refValues.current;
|
|
628
|
+
$values.setValuesSnapshot(newSnapshot);
|
|
629
|
+
setDirty({});
|
|
630
|
+
}, []);
|
|
631
|
+
const setFieldTouched = useCallback3((path, touched) => {
|
|
632
|
+
setTouched((currentTouched) => {
|
|
633
|
+
if (getStatus(currentTouched, path) === touched)
|
|
634
|
+
return currentTouched;
|
|
635
|
+
return {
|
|
636
|
+
...currentTouched,
|
|
637
|
+
[path]: touched
|
|
638
|
+
};
|
|
639
|
+
});
|
|
640
|
+
}, []);
|
|
641
|
+
const setFieldDirty = useCallback3((path, dirty, forceUpdate) => {
|
|
642
|
+
setDirty((currentDirty) => {
|
|
643
|
+
if (getStatus(currentDirty, path) === dirty)
|
|
644
|
+
return currentDirty;
|
|
645
|
+
return {
|
|
646
|
+
...currentDirty,
|
|
647
|
+
[path]: dirty
|
|
648
|
+
};
|
|
649
|
+
}, forceUpdate);
|
|
650
|
+
}, []);
|
|
651
|
+
const setCalculatedFieldDirty = useCallback3((path, value) => {
|
|
652
|
+
const currentDirty = getStatus(dirtyRef.current, path);
|
|
653
|
+
const dirty = !import_fast_deep_equal.default(getPath(path, $values.getValuesSnapshot()), value);
|
|
654
|
+
const clearedState = clearListState(path, dirtyRef.current);
|
|
655
|
+
clearedState[path] = dirty;
|
|
656
|
+
setDirty(clearedState, currentDirty !== dirty);
|
|
657
|
+
}, []);
|
|
658
|
+
return {
|
|
659
|
+
touchedState,
|
|
660
|
+
dirtyState,
|
|
661
|
+
touchedRef,
|
|
662
|
+
dirtyRef,
|
|
663
|
+
setTouched,
|
|
664
|
+
setDirty,
|
|
665
|
+
resetDirty,
|
|
666
|
+
resetTouched,
|
|
667
|
+
isTouched: useCallback3((path) => getStatus(touchedRef.current, path), []),
|
|
668
|
+
setFieldTouched,
|
|
669
|
+
setFieldDirty,
|
|
670
|
+
setTouchedState,
|
|
671
|
+
setDirtyState,
|
|
672
|
+
clearFieldDirty: useCallback3((path) => setDirty((current) => {
|
|
673
|
+
if (typeof path !== "string")
|
|
674
|
+
return current;
|
|
675
|
+
const result = clearListState(path, current);
|
|
676
|
+
delete result[path];
|
|
677
|
+
if (import_fast_deep_equal.default(result, current))
|
|
678
|
+
return current;
|
|
679
|
+
return result;
|
|
680
|
+
}), []),
|
|
681
|
+
isDirty: useCallback3((path) => {
|
|
682
|
+
if (path) {
|
|
683
|
+
const overriddenValue = getPath(path, dirtyRef.current);
|
|
684
|
+
if (typeof overriddenValue === "boolean")
|
|
685
|
+
return overriddenValue;
|
|
686
|
+
return !import_fast_deep_equal.default(getPath(path, $values.refValues.current), getPath(path, $values.valuesSnapshot.current));
|
|
687
|
+
}
|
|
688
|
+
if (Object.keys(dirtyRef.current).length > 0)
|
|
689
|
+
return getStatus(dirtyRef.current);
|
|
690
|
+
return !import_fast_deep_equal.default($values.refValues.current, $values.valuesSnapshot.current);
|
|
691
|
+
}, []),
|
|
692
|
+
getDirty: useCallback3(() => dirtyRef.current, []),
|
|
693
|
+
getTouched: useCallback3(() => touchedRef.current, []),
|
|
694
|
+
setCalculatedFieldDirty
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// node_modules/@mantine/form/esm/hooks/use-form-validating/use-form-validating.mjs
|
|
699
|
+
import { useCallback as useCallback4, useRef as useRef3, useState as useState3 } from "react";
|
|
700
|
+
|
|
701
|
+
function useFormValidating() {
|
|
702
|
+
const [validatingFields, setValidatingFields] = useState3({});
|
|
703
|
+
const [formValidating, setFormValidatingState] = useState3(false);
|
|
704
|
+
const validatingRef = useRef3({});
|
|
705
|
+
const formValidatingRef = useRef3(false);
|
|
706
|
+
const abortControllers = useRef3({});
|
|
707
|
+
const setFieldValidating = useCallback4((path, value) => {
|
|
708
|
+
validatingRef.current = {
|
|
709
|
+
...validatingRef.current,
|
|
710
|
+
[path]: value
|
|
711
|
+
};
|
|
712
|
+
setValidatingFields({ ...validatingRef.current });
|
|
713
|
+
}, []);
|
|
714
|
+
const setFormValidating = useCallback4((value) => {
|
|
715
|
+
formValidatingRef.current = value;
|
|
716
|
+
setFormValidatingState(value);
|
|
717
|
+
}, []);
|
|
718
|
+
const isValidating = useCallback4((path) => {
|
|
719
|
+
if (path)
|
|
720
|
+
return !!validatingRef.current[path];
|
|
721
|
+
if (formValidatingRef.current)
|
|
722
|
+
return true;
|
|
723
|
+
return Object.values(validatingRef.current).some(Boolean);
|
|
724
|
+
}, []);
|
|
725
|
+
const getAbortSignal = useCallback4((path) => {
|
|
726
|
+
abortControllers.current[path]?.abort();
|
|
727
|
+
abortControllers.current[path] = new AbortController;
|
|
728
|
+
return abortControllers.current[path].signal;
|
|
729
|
+
}, []);
|
|
730
|
+
const clearValidating = useCallback4(() => {
|
|
731
|
+
validatingRef.current = {};
|
|
732
|
+
setValidatingFields({});
|
|
733
|
+
formValidatingRef.current = false;
|
|
734
|
+
setFormValidatingState(false);
|
|
735
|
+
Object.values(abortControllers.current).forEach((c) => c.abort());
|
|
736
|
+
abortControllers.current = {};
|
|
737
|
+
}, []);
|
|
738
|
+
return {
|
|
739
|
+
validating: formValidating || Object.values(validatingFields).some(Boolean),
|
|
740
|
+
isValidating,
|
|
741
|
+
setFieldValidating,
|
|
742
|
+
setFormValidating,
|
|
743
|
+
getAbortSignal,
|
|
744
|
+
clearValidating
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// node_modules/@mantine/form/esm/hooks/use-form-values/use-form-values.mjs
|
|
749
|
+
import { useCallback as useCallback5, useRef as useRef4, useState as useState4 } from "react";
|
|
750
|
+
|
|
751
|
+
function useFormValues({ initialValues, onValuesChange, mode }) {
|
|
752
|
+
const initialized = useRef4(false);
|
|
753
|
+
const [stateValues, setStateValues] = useState4(initialValues || {});
|
|
754
|
+
const refValues = useRef4(stateValues);
|
|
755
|
+
const valuesSnapshot = useRef4(stateValues);
|
|
756
|
+
const setValues = useCallback5(({ values, subscribers, updateState = true, mergeWithPreviousValues = true }) => {
|
|
757
|
+
const previousValues = refValues.current;
|
|
758
|
+
const resolvedValues = values instanceof Function ? values(refValues.current) : values;
|
|
759
|
+
const updatedValues = mergeWithPreviousValues ? {
|
|
760
|
+
...previousValues,
|
|
761
|
+
...resolvedValues
|
|
762
|
+
} : resolvedValues;
|
|
763
|
+
refValues.current = updatedValues;
|
|
764
|
+
if (updateState) {
|
|
765
|
+
setStateValues(updatedValues);
|
|
766
|
+
if (mode === "uncontrolled")
|
|
767
|
+
refValues.current = updatedValues;
|
|
768
|
+
}
|
|
769
|
+
onValuesChange?.(updatedValues, previousValues);
|
|
770
|
+
subscribers?.filter(Boolean).forEach((subscriber) => subscriber({
|
|
771
|
+
updatedValues,
|
|
772
|
+
previousValues
|
|
773
|
+
}));
|
|
774
|
+
}, [onValuesChange]);
|
|
775
|
+
const setFieldValue = useCallback5((payload) => {
|
|
776
|
+
const currentValue = getPath(payload.path, refValues.current);
|
|
777
|
+
const updatedValue = payload.value instanceof Function ? payload.value(currentValue) : payload.value;
|
|
778
|
+
if (currentValue !== updatedValue) {
|
|
779
|
+
const previousValues = refValues.current;
|
|
780
|
+
const updatedValues = setPath(payload.path, updatedValue, refValues.current);
|
|
781
|
+
setValues({
|
|
782
|
+
values: updatedValues,
|
|
783
|
+
updateState: payload.updateState
|
|
784
|
+
});
|
|
785
|
+
payload.subscribers?.filter(Boolean).forEach((subscriber) => subscriber({
|
|
786
|
+
path: payload.path,
|
|
787
|
+
updatedValues,
|
|
788
|
+
previousValues
|
|
789
|
+
}));
|
|
790
|
+
}
|
|
791
|
+
}, [setValues]);
|
|
792
|
+
const setValuesSnapshot = useCallback5((payload) => {
|
|
793
|
+
valuesSnapshot.current = payload;
|
|
794
|
+
}, []);
|
|
795
|
+
const initialize = useCallback5((values, onInitialize) => {
|
|
796
|
+
if (!initialized.current) {
|
|
797
|
+
initialized.current = true;
|
|
798
|
+
setValues({
|
|
799
|
+
values,
|
|
800
|
+
updateState: mode === "controlled"
|
|
801
|
+
});
|
|
802
|
+
setValuesSnapshot(values);
|
|
803
|
+
onInitialize();
|
|
804
|
+
}
|
|
805
|
+
}, [setValues]);
|
|
806
|
+
return {
|
|
807
|
+
initialized,
|
|
808
|
+
stateValues,
|
|
809
|
+
refValues,
|
|
810
|
+
valuesSnapshot,
|
|
811
|
+
setValues,
|
|
812
|
+
setFieldValue,
|
|
813
|
+
resetValues: useCallback5(() => {
|
|
814
|
+
setValues({
|
|
815
|
+
values: valuesSnapshot.current,
|
|
816
|
+
updateState: true,
|
|
817
|
+
mergeWithPreviousValues: false
|
|
818
|
+
});
|
|
819
|
+
}, [setValues]),
|
|
820
|
+
setValuesSnapshot,
|
|
821
|
+
initialize,
|
|
822
|
+
getValues: useCallback5(() => refValues.current, []),
|
|
823
|
+
getValuesSnapshot: useCallback5(() => valuesSnapshot.current, []),
|
|
824
|
+
resetField: useCallback5((path, subscribers) => {
|
|
825
|
+
const snapshotValue = getPath(path, valuesSnapshot.current);
|
|
826
|
+
if (typeof snapshotValue === "undefined")
|
|
827
|
+
return;
|
|
828
|
+
setFieldValue({
|
|
829
|
+
path,
|
|
830
|
+
value: snapshotValue,
|
|
831
|
+
updateState: mode === "controlled",
|
|
832
|
+
subscribers
|
|
833
|
+
});
|
|
834
|
+
}, [setFieldValue, mode])
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// node_modules/@mantine/form/esm/hooks/use-form-watch/use-form-watch.mjs
|
|
839
|
+
import { useCallback as useCallback6, useEffect as useEffect2, useRef as useRef5 } from "react";
|
|
840
|
+
|
|
841
|
+
function useFormWatch({ $values, $status, cascadeUpdates }) {
|
|
842
|
+
const subscribers = useRef5({});
|
|
843
|
+
return {
|
|
844
|
+
subscribers,
|
|
845
|
+
watch: useCallback6((path, callback) => {
|
|
846
|
+
useEffect2(() => {
|
|
847
|
+
subscribers.current[path] = subscribers.current[path] || [];
|
|
848
|
+
subscribers.current[path].push(callback);
|
|
849
|
+
return () => {
|
|
850
|
+
subscribers.current[path] = subscribers.current[path].filter((cb) => cb !== callback);
|
|
851
|
+
};
|
|
852
|
+
}, [callback]);
|
|
853
|
+
}, []),
|
|
854
|
+
getFieldSubscribers: useCallback6((path) => {
|
|
855
|
+
const result = subscribers.current[path]?.map((callback) => (input) => callback({
|
|
856
|
+
previousValue: getPath(path, input.previousValues),
|
|
857
|
+
value: getPath(path, input.updatedValues),
|
|
858
|
+
touched: $status.isTouched(path),
|
|
859
|
+
dirty: $status.isDirty(path)
|
|
860
|
+
})) ?? [];
|
|
861
|
+
for (const subscriptionKey in subscribers.current) {
|
|
862
|
+
const isParent = String(path).startsWith(`${subscriptionKey}.`);
|
|
863
|
+
const isChild = String(subscriptionKey).startsWith(`${path}.`);
|
|
864
|
+
if (isParent || cascadeUpdates && isChild)
|
|
865
|
+
result.push(...subscribers.current[subscriptionKey].map((cb) => (input) => cb({
|
|
866
|
+
previousValue: getPath(subscriptionKey, input.previousValues),
|
|
867
|
+
value: getPath(subscriptionKey, input.updatedValues),
|
|
868
|
+
touched: $status.isTouched(subscriptionKey),
|
|
869
|
+
dirty: $status.isDirty(subscriptionKey)
|
|
870
|
+
})));
|
|
871
|
+
}
|
|
872
|
+
return result;
|
|
873
|
+
}, []),
|
|
874
|
+
notifyWatchSubscribers: useCallback6((previousValues) => {
|
|
875
|
+
Object.keys(subscribers.current).forEach((path) => {
|
|
876
|
+
if (getPath(path, $values.refValues.current) !== getPath(path, previousValues))
|
|
877
|
+
subscribers.current[path]?.forEach((cb) => cb({
|
|
878
|
+
previousValue: getPath(path, previousValues),
|
|
879
|
+
value: getPath(path, $values.refValues.current),
|
|
880
|
+
touched: $status.isTouched(path),
|
|
881
|
+
dirty: $status.isDirty(path)
|
|
882
|
+
}));
|
|
883
|
+
});
|
|
884
|
+
}, [])
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// node_modules/@mantine/form/esm/validate/get-rule-for-path.mjs
|
|
889
|
+
|
|
890
|
+
function getRuleForPath(path, rules) {
|
|
891
|
+
if (!rules)
|
|
892
|
+
return null;
|
|
893
|
+
const segments = path.split(".");
|
|
894
|
+
let current = rules;
|
|
895
|
+
for (let i = 0;i < segments.length; i++) {
|
|
896
|
+
const segment = segments[i];
|
|
897
|
+
if (/^\d+$/.test(segment))
|
|
898
|
+
continue;
|
|
899
|
+
if (current == null || typeof current !== "object")
|
|
900
|
+
return null;
|
|
901
|
+
current = current[segment];
|
|
902
|
+
}
|
|
903
|
+
if (typeof current === "function")
|
|
904
|
+
return current;
|
|
905
|
+
return null;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
// node_modules/@mantine/form/esm/validate/validate-field-value.mjs
|
|
909
|
+
|
|
910
|
+
var defaultResolveError2 = (err) => err instanceof Error ? err.message : String(err);
|
|
911
|
+
function fieldResultFromErrors(path, errors) {
|
|
912
|
+
const pathInError = Object.keys(errors).find((errorKey) => path.split(".").every((pathPart, i) => pathPart === errorKey.split(".")[i]));
|
|
913
|
+
return {
|
|
914
|
+
hasError: !!pathInError,
|
|
915
|
+
error: pathInError ? errors[pathInError] : null
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function validateFieldValue(path, rules, values, resolveValidationError = defaultResolveError2, signal = new AbortController().signal) {
|
|
919
|
+
if (typeof path !== "string")
|
|
920
|
+
return {
|
|
921
|
+
hasError: false,
|
|
922
|
+
error: null
|
|
923
|
+
};
|
|
924
|
+
if (typeof rules === "function") {
|
|
925
|
+
const results2 = validateValues(rules, values, resolveValidationError, signal);
|
|
926
|
+
if (results2 instanceof Promise)
|
|
927
|
+
return results2.then((r) => fieldResultFromErrors(path, r.errors));
|
|
928
|
+
return fieldResultFromErrors(path, results2.errors);
|
|
929
|
+
}
|
|
930
|
+
const rule = getRuleForPath(path, rules);
|
|
931
|
+
if (rule) {
|
|
932
|
+
const value = getPath(path, values);
|
|
933
|
+
try {
|
|
934
|
+
const result = rule(value, values, path, signal);
|
|
935
|
+
if (result instanceof Promise)
|
|
936
|
+
return result.then((error) => {
|
|
937
|
+
if (error)
|
|
938
|
+
return {
|
|
939
|
+
hasError: true,
|
|
940
|
+
error
|
|
941
|
+
};
|
|
942
|
+
return {
|
|
943
|
+
hasError: false,
|
|
944
|
+
error: null
|
|
945
|
+
};
|
|
946
|
+
}, (err) => ({
|
|
947
|
+
hasError: true,
|
|
948
|
+
error: resolveValidationError(err)
|
|
949
|
+
}));
|
|
950
|
+
if (result)
|
|
951
|
+
return {
|
|
952
|
+
hasError: true,
|
|
953
|
+
error: result
|
|
954
|
+
};
|
|
955
|
+
return {
|
|
956
|
+
hasError: false,
|
|
957
|
+
error: null
|
|
958
|
+
};
|
|
959
|
+
} catch (err) {
|
|
960
|
+
return {
|
|
961
|
+
hasError: true,
|
|
962
|
+
error: resolveValidationError(err)
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
const results = validateValues(rules, values, resolveValidationError, signal);
|
|
967
|
+
if (results instanceof Promise)
|
|
968
|
+
return results.then((r) => fieldResultFromErrors(path, r.errors));
|
|
969
|
+
return fieldResultFromErrors(path, results.errors);
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// node_modules/@mantine/form/esm/validate/should-validate-on-change.mjs
|
|
973
|
+
|
|
974
|
+
function shouldValidateOnChange(path, validateInputOnChange) {
|
|
975
|
+
if (!validateInputOnChange)
|
|
976
|
+
return false;
|
|
977
|
+
if (typeof validateInputOnChange === "boolean")
|
|
978
|
+
return validateInputOnChange;
|
|
979
|
+
if (Array.isArray(validateInputOnChange))
|
|
980
|
+
return validateInputOnChange.includes(path.replace(/[.][0-9]+/g, `.${FORM_INDEX}`));
|
|
981
|
+
return false;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
// node_modules/@mantine/form/esm/use-form.mjs
|
|
985
|
+
import { useCallback as useCallback7, useMemo, useRef as useRef6, useState as useState5 } from "react";
|
|
986
|
+
|
|
987
|
+
var defaultResolveValidationError = (err) => err instanceof Error ? err.message : String(err);
|
|
988
|
+
function useForm({ name, mode = "controlled", initialValues, initialErrors = {}, initialDirty = {}, initialTouched = {}, clearInputErrorOnChange = true, validateInputOnChange = false, validateInputOnBlur = false, onValuesChange, transformValues = (values) => values, enhanceGetInputProps, validate: rules, onSubmitPreventDefault = "always", touchTrigger = "change", cascadeUpdates = false, validateDebounce = 0, resolveValidationError = defaultResolveValidationError } = {}) {
|
|
989
|
+
const $errors = useFormErrors(initialErrors);
|
|
990
|
+
const $values = useFormValues({
|
|
991
|
+
initialValues,
|
|
992
|
+
onValuesChange,
|
|
993
|
+
mode
|
|
994
|
+
});
|
|
995
|
+
const $status = useFormStatus({
|
|
996
|
+
initialDirty,
|
|
997
|
+
initialTouched,
|
|
998
|
+
$values,
|
|
999
|
+
mode
|
|
1000
|
+
});
|
|
1001
|
+
const $watch = useFormWatch({
|
|
1002
|
+
$values,
|
|
1003
|
+
$status,
|
|
1004
|
+
cascadeUpdates
|
|
1005
|
+
});
|
|
1006
|
+
const $list = useFormList({
|
|
1007
|
+
$values,
|
|
1008
|
+
$errors,
|
|
1009
|
+
$status,
|
|
1010
|
+
$watch
|
|
1011
|
+
});
|
|
1012
|
+
const $validating = useFormValidating();
|
|
1013
|
+
const [formKey, setFormKey] = useState5(0);
|
|
1014
|
+
const [fieldKeys, setFieldKeys] = useState5({});
|
|
1015
|
+
const [submitting, setSubmitting] = useState5(false);
|
|
1016
|
+
const validateGeneration = useRef6(0);
|
|
1017
|
+
const reset = useCallback7(() => {
|
|
1018
|
+
$values.resetValues();
|
|
1019
|
+
$errors.clearErrors();
|
|
1020
|
+
$status.resetDirty();
|
|
1021
|
+
$status.resetTouched();
|
|
1022
|
+
$validating.clearValidating();
|
|
1023
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
1024
|
+
}, []);
|
|
1025
|
+
const handleValuesChanges = useCallback7((previousValues) => {
|
|
1026
|
+
clearInputErrorOnChange && $errors.clearErrors();
|
|
1027
|
+
mode === "uncontrolled" && setFormKey((key2) => key2 + 1);
|
|
1028
|
+
$watch.notifyWatchSubscribers(previousValues);
|
|
1029
|
+
}, [clearInputErrorOnChange]);
|
|
1030
|
+
const initialize = useCallback7((values) => {
|
|
1031
|
+
const previousValues = $values.refValues.current;
|
|
1032
|
+
$values.initialize(values, () => mode === "uncontrolled" && setFormKey((key2) => key2 + 1));
|
|
1033
|
+
handleValuesChanges(previousValues);
|
|
1034
|
+
}, [handleValuesChanges]);
|
|
1035
|
+
const debouncedValidateField = useMemo(() => {
|
|
1036
|
+
const timers = {};
|
|
1037
|
+
const handleValidation = (path) => {
|
|
1038
|
+
const signal = $validating.getAbortSignal(path);
|
|
1039
|
+
const result = validateFieldValue(path, rules, $values.refValues.current, resolveValidationError, signal);
|
|
1040
|
+
const applyResult = (results) => {
|
|
1041
|
+
if (signal.aborted)
|
|
1042
|
+
return;
|
|
1043
|
+
if (results.hasError)
|
|
1044
|
+
$errors.setFieldError(path, results.error);
|
|
1045
|
+
else
|
|
1046
|
+
$errors.clearFieldError(path);
|
|
1047
|
+
};
|
|
1048
|
+
const cleanup = () => {
|
|
1049
|
+
if (!signal.aborted)
|
|
1050
|
+
$validating.setFieldValidating(path, false);
|
|
1051
|
+
};
|
|
1052
|
+
if (result instanceof Promise) {
|
|
1053
|
+
$validating.setFieldValidating(path, true);
|
|
1054
|
+
result.then(applyResult).finally(cleanup);
|
|
1055
|
+
} else
|
|
1056
|
+
applyResult(result);
|
|
1057
|
+
};
|
|
1058
|
+
return (path) => {
|
|
1059
|
+
clearTimeout(timers[path]);
|
|
1060
|
+
if (validateDebounce > 0)
|
|
1061
|
+
timers[path] = setTimeout(() => handleValidation(path), validateDebounce);
|
|
1062
|
+
else
|
|
1063
|
+
handleValidation(path);
|
|
1064
|
+
};
|
|
1065
|
+
}, [
|
|
1066
|
+
validateDebounce,
|
|
1067
|
+
rules,
|
|
1068
|
+
resolveValidationError
|
|
1069
|
+
]);
|
|
1070
|
+
const setFieldValue = useCallback7((path, value, options) => {
|
|
1071
|
+
const shouldValidate = shouldValidateOnChange(path, validateInputOnChange);
|
|
1072
|
+
const resolvedValue = value instanceof Function ? value(getPath(path, $values.refValues.current)) : value;
|
|
1073
|
+
$status.setCalculatedFieldDirty(path, resolvedValue);
|
|
1074
|
+
touchTrigger === "change" && $status.setFieldTouched(path, true);
|
|
1075
|
+
!shouldValidate && clearInputErrorOnChange && $errors.clearFieldError(path);
|
|
1076
|
+
$values.setFieldValue({
|
|
1077
|
+
path,
|
|
1078
|
+
value,
|
|
1079
|
+
updateState: mode === "controlled",
|
|
1080
|
+
subscribers: [
|
|
1081
|
+
...$watch.getFieldSubscribers(path),
|
|
1082
|
+
shouldValidate ? () => debouncedValidateField(String(path)) : null,
|
|
1083
|
+
options?.forceUpdate !== false && mode !== "controlled" ? () => setFieldKeys((keys) => ({
|
|
1084
|
+
...keys,
|
|
1085
|
+
[path]: (keys[path] || 0) + 1
|
|
1086
|
+
})) : null
|
|
1087
|
+
]
|
|
1088
|
+
});
|
|
1089
|
+
}, [
|
|
1090
|
+
onValuesChange,
|
|
1091
|
+
rules,
|
|
1092
|
+
debouncedValidateField
|
|
1093
|
+
]);
|
|
1094
|
+
const setValues = useCallback7((values) => {
|
|
1095
|
+
const previousValues = $values.refValues.current;
|
|
1096
|
+
$values.setValues({
|
|
1097
|
+
values,
|
|
1098
|
+
updateState: mode === "controlled"
|
|
1099
|
+
});
|
|
1100
|
+
handleValuesChanges(previousValues);
|
|
1101
|
+
}, [onValuesChange, handleValuesChanges]);
|
|
1102
|
+
const validate = useCallback7(() => {
|
|
1103
|
+
const generation = ++validateGeneration.current;
|
|
1104
|
+
const signal = $validating.getAbortSignal("__form__");
|
|
1105
|
+
const handleResult = (results) => {
|
|
1106
|
+
if (generation !== validateGeneration.current)
|
|
1107
|
+
return {
|
|
1108
|
+
hasErrors: false,
|
|
1109
|
+
errors: {}
|
|
1110
|
+
};
|
|
1111
|
+
$errors.setErrors(results.errors);
|
|
1112
|
+
return results;
|
|
1113
|
+
};
|
|
1114
|
+
const cleanup = () => {
|
|
1115
|
+
if (generation === validateGeneration.current)
|
|
1116
|
+
$validating.setFormValidating(false);
|
|
1117
|
+
};
|
|
1118
|
+
const result = validateValues(rules, $values.refValues.current, resolveValidationError, signal);
|
|
1119
|
+
if (result instanceof Promise) {
|
|
1120
|
+
$validating.setFormValidating(true);
|
|
1121
|
+
return result.then(handleResult).finally(cleanup);
|
|
1122
|
+
}
|
|
1123
|
+
return handleResult(result);
|
|
1124
|
+
}, [rules, resolveValidationError]);
|
|
1125
|
+
const validateField = useCallback7((path) => {
|
|
1126
|
+
const signal = $validating.getAbortSignal(String(path));
|
|
1127
|
+
const applyResult = (results) => {
|
|
1128
|
+
if (signal.aborted)
|
|
1129
|
+
return {
|
|
1130
|
+
hasError: false,
|
|
1131
|
+
error: null
|
|
1132
|
+
};
|
|
1133
|
+
if (results.hasError)
|
|
1134
|
+
$errors.setFieldError(path, results.error);
|
|
1135
|
+
else
|
|
1136
|
+
$errors.clearFieldError(path);
|
|
1137
|
+
return results;
|
|
1138
|
+
};
|
|
1139
|
+
const cleanup = () => {
|
|
1140
|
+
if (!signal.aborted)
|
|
1141
|
+
$validating.setFieldValidating(String(path), false);
|
|
1142
|
+
};
|
|
1143
|
+
const result = validateFieldValue(path, rules, $values.refValues.current, resolveValidationError, signal);
|
|
1144
|
+
if (result instanceof Promise) {
|
|
1145
|
+
$validating.setFieldValidating(String(path), true);
|
|
1146
|
+
return result.then(applyResult).finally(cleanup);
|
|
1147
|
+
}
|
|
1148
|
+
return applyResult(result);
|
|
1149
|
+
}, [rules, resolveValidationError]);
|
|
1150
|
+
const getInputProps = (path, { type = "input", withError = true, withFocus, ...otherOptions } = {}) => {
|
|
1151
|
+
const _withFocus = withFocus ?? type !== "radio";
|
|
1152
|
+
const payload = {
|
|
1153
|
+
onChange: getInputOnChange((value) => setFieldValue(path, value, { forceUpdate: false })),
|
|
1154
|
+
"data-path": getDataPath(name, path)
|
|
1155
|
+
};
|
|
1156
|
+
if (withError)
|
|
1157
|
+
payload.error = $errors.errorsState[path];
|
|
1158
|
+
if (type === "checkbox")
|
|
1159
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(path, $values.refValues.current);
|
|
1160
|
+
else if (type === "radio") {
|
|
1161
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = getPath(path, $values.refValues.current) === otherOptions.value;
|
|
1162
|
+
payload.value = otherOptions.value;
|
|
1163
|
+
} else
|
|
1164
|
+
payload[mode === "controlled" ? "value" : "defaultValue"] = getPath(path, $values.refValues.current);
|
|
1165
|
+
if (_withFocus) {
|
|
1166
|
+
payload.onFocus = () => $status.setFieldTouched(path, true);
|
|
1167
|
+
payload.onBlur = () => {
|
|
1168
|
+
if (shouldValidateOnChange(path, validateInputOnBlur))
|
|
1169
|
+
debouncedValidateField(String(path));
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
return Object.assign(payload, enhanceGetInputProps?.({
|
|
1173
|
+
inputProps: payload,
|
|
1174
|
+
field: path,
|
|
1175
|
+
options: {
|
|
1176
|
+
type,
|
|
1177
|
+
withError,
|
|
1178
|
+
withFocus: _withFocus,
|
|
1179
|
+
...otherOptions
|
|
1180
|
+
},
|
|
1181
|
+
form
|
|
1182
|
+
}));
|
|
1183
|
+
};
|
|
1184
|
+
const onSubmit = (handleSubmit, handleValidationFailure) => (event) => {
|
|
1185
|
+
if (onSubmitPreventDefault === "always")
|
|
1186
|
+
event?.preventDefault();
|
|
1187
|
+
setSubmitting(true);
|
|
1188
|
+
const handleValidation = (results) => {
|
|
1189
|
+
if (results.hasErrors) {
|
|
1190
|
+
if (onSubmitPreventDefault === "validation-failed")
|
|
1191
|
+
event?.preventDefault();
|
|
1192
|
+
handleValidationFailure?.(results.errors, $values.refValues.current, event);
|
|
1193
|
+
setSubmitting(false);
|
|
1194
|
+
} else {
|
|
1195
|
+
const submitResult = handleSubmit?.(transformValues($values.refValues.current), event);
|
|
1196
|
+
if (submitResult instanceof Promise)
|
|
1197
|
+
submitResult.finally(() => setSubmitting(false));
|
|
1198
|
+
else
|
|
1199
|
+
setSubmitting(false);
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
const result = validate();
|
|
1203
|
+
if (result instanceof Promise)
|
|
1204
|
+
result.then(handleValidation).catch(() => {
|
|
1205
|
+
setSubmitting(false);
|
|
1206
|
+
});
|
|
1207
|
+
else
|
|
1208
|
+
handleValidation(result);
|
|
1209
|
+
};
|
|
1210
|
+
const getTransformedValues = (input) => transformValues(input || $values.refValues.current);
|
|
1211
|
+
const onReset = useCallback7((event) => {
|
|
1212
|
+
event.preventDefault();
|
|
1213
|
+
reset();
|
|
1214
|
+
}, []);
|
|
1215
|
+
const isValid = useCallback7((path) => {
|
|
1216
|
+
const signal = new AbortController().signal;
|
|
1217
|
+
if (path) {
|
|
1218
|
+
const result2 = validateFieldValue(path, rules, $values.refValues.current, resolveValidationError, signal);
|
|
1219
|
+
if (result2 instanceof Promise)
|
|
1220
|
+
return result2.then((r) => !r.hasError);
|
|
1221
|
+
return !result2.hasError;
|
|
1222
|
+
}
|
|
1223
|
+
const result = validateValues(rules, $values.refValues.current, resolveValidationError, signal);
|
|
1224
|
+
if (result instanceof Promise)
|
|
1225
|
+
return result.then((r) => !r.hasErrors);
|
|
1226
|
+
return !result.hasErrors;
|
|
1227
|
+
}, [rules, resolveValidationError]);
|
|
1228
|
+
const key = (path) => `${formKey}-${String(path)}-${fieldKeys[String(path)] || 0}`;
|
|
1229
|
+
const getInputNode = useCallback7((path) => document.querySelector(`[data-path="${getDataPath(name, path)}"]`), []);
|
|
1230
|
+
const resetField = useCallback7((path) => {
|
|
1231
|
+
$values.resetField(path, [mode !== "controlled" ? () => setFieldKeys((keys) => ({
|
|
1232
|
+
...keys,
|
|
1233
|
+
[path]: (keys[path] || 0) + 1
|
|
1234
|
+
})) : null]);
|
|
1235
|
+
}, [
|
|
1236
|
+
$values.resetField,
|
|
1237
|
+
mode,
|
|
1238
|
+
setFieldKeys
|
|
1239
|
+
]);
|
|
1240
|
+
const form = {
|
|
1241
|
+
watch: $watch.watch,
|
|
1242
|
+
initialized: $values.initialized.current,
|
|
1243
|
+
values: mode === "uncontrolled" ? $values.refValues.current : $values.stateValues,
|
|
1244
|
+
getValues: $values.getValues,
|
|
1245
|
+
getInitialValues: $values.getValuesSnapshot,
|
|
1246
|
+
setInitialValues: $values.setValuesSnapshot,
|
|
1247
|
+
resetField,
|
|
1248
|
+
initialize,
|
|
1249
|
+
setValues,
|
|
1250
|
+
setFieldValue,
|
|
1251
|
+
submitting,
|
|
1252
|
+
setSubmitting,
|
|
1253
|
+
validating: $validating.validating,
|
|
1254
|
+
isValidating: $validating.isValidating,
|
|
1255
|
+
errors: $errors.errorsState,
|
|
1256
|
+
setErrors: $errors.setErrors,
|
|
1257
|
+
setFieldError: $errors.setFieldError,
|
|
1258
|
+
clearFieldError: $errors.clearFieldError,
|
|
1259
|
+
clearErrors: $errors.clearErrors,
|
|
1260
|
+
resetDirty: $status.resetDirty,
|
|
1261
|
+
setTouched: $status.setTouched,
|
|
1262
|
+
setDirty: $status.setDirty,
|
|
1263
|
+
isTouched: $status.isTouched,
|
|
1264
|
+
resetTouched: $status.resetTouched,
|
|
1265
|
+
isDirty: $status.isDirty,
|
|
1266
|
+
getTouched: $status.getTouched,
|
|
1267
|
+
getDirty: $status.getDirty,
|
|
1268
|
+
reorderListItem: $list.reorderListItem,
|
|
1269
|
+
insertListItem: $list.insertListItem,
|
|
1270
|
+
removeListItem: $list.removeListItem,
|
|
1271
|
+
replaceListItem: $list.replaceListItem,
|
|
1272
|
+
reset,
|
|
1273
|
+
validate,
|
|
1274
|
+
validateField,
|
|
1275
|
+
getInputProps,
|
|
1276
|
+
onSubmit,
|
|
1277
|
+
onReset,
|
|
1278
|
+
isValid,
|
|
1279
|
+
getTransformedValues,
|
|
1280
|
+
key,
|
|
1281
|
+
getInputNode
|
|
1282
|
+
};
|
|
1283
|
+
useFormActions(name, form);
|
|
1284
|
+
return form;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
// node_modules/@mantine/form/esm/FormProvider/FormProvider.mjs
|
|
1288
|
+
import { createContext, use } from "react";
|
|
1289
|
+
import { jsx } from "react/jsx-runtime";
|
|
1290
|
+
|
|
1291
|
+
function createFormContext() {
|
|
1292
|
+
const FormContext = createContext(null);
|
|
1293
|
+
function FormProvider({ form, children }) {
|
|
1294
|
+
return /* @__PURE__ */ jsx(FormContext, {
|
|
1295
|
+
value: form,
|
|
1296
|
+
children
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
function useFormContext() {
|
|
1300
|
+
const ctx = use(FormContext);
|
|
1301
|
+
if (!ctx)
|
|
1302
|
+
throw new Error("useFormContext was called outside of FormProvider context");
|
|
1303
|
+
return ctx;
|
|
1304
|
+
}
|
|
1305
|
+
return [
|
|
1306
|
+
FormProvider,
|
|
1307
|
+
useFormContext,
|
|
1308
|
+
useForm
|
|
1309
|
+
];
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
// node_modules/@mantine/form/esm/validators/is-not-empty/is-not-empty.mjs
|
|
1313
|
+
|
|
1314
|
+
function isNotEmpty(error) {
|
|
1315
|
+
const _error = error || true;
|
|
1316
|
+
return (value) => {
|
|
1317
|
+
if (typeof value === "string")
|
|
1318
|
+
return value.trim().length > 0 ? null : _error;
|
|
1319
|
+
if (Array.isArray(value))
|
|
1320
|
+
return value.length > 0 ? null : _error;
|
|
1321
|
+
if (value === null || value === undefined)
|
|
1322
|
+
return _error;
|
|
1323
|
+
if (value === false)
|
|
1324
|
+
return _error;
|
|
1325
|
+
return null;
|
|
1326
|
+
};
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
// node_modules/@mantine/form/esm/validators/matches/matches.mjs
|
|
1330
|
+
|
|
1331
|
+
function matches(regexp, error) {
|
|
1332
|
+
const _error = error || true;
|
|
1333
|
+
return (value) => {
|
|
1334
|
+
if (typeof value !== "string")
|
|
1335
|
+
return _error;
|
|
1336
|
+
return regexp.test(value) ? null : _error;
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// node_modules/@mantine/form/esm/validators/is-email/is-email.mjs
|
|
1341
|
+
|
|
1342
|
+
function isEmail(error) {
|
|
1343
|
+
return matches(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, error);
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
// node_modules/@mantine/form/esm/validators/has-length/has-length.mjs
|
|
1347
|
+
|
|
1348
|
+
function isLengthValid(payload, value) {
|
|
1349
|
+
if (typeof payload === "number")
|
|
1350
|
+
return value.length === payload;
|
|
1351
|
+
const { max, min } = payload;
|
|
1352
|
+
let valid = true;
|
|
1353
|
+
if (typeof max === "number" && value.length > max)
|
|
1354
|
+
valid = false;
|
|
1355
|
+
if (typeof min === "number" && value.length < min)
|
|
1356
|
+
valid = false;
|
|
1357
|
+
return valid;
|
|
1358
|
+
}
|
|
1359
|
+
function hasLength(payload, error) {
|
|
1360
|
+
const _error = error || true;
|
|
1361
|
+
return (value) => {
|
|
1362
|
+
if (typeof value === "string")
|
|
1363
|
+
return isLengthValid(payload, value.trim()) ? null : _error;
|
|
1364
|
+
if (typeof value === "object" && value !== null && "length" in value)
|
|
1365
|
+
return isLengthValid(payload, value) ? null : _error;
|
|
1366
|
+
return _error;
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// node_modules/@mantine/form/esm/validators/is-in-range/is-in-range.mjs
|
|
1371
|
+
|
|
1372
|
+
function isInRange({ min, max }, error) {
|
|
1373
|
+
const _error = error || true;
|
|
1374
|
+
return (value) => {
|
|
1375
|
+
if (typeof value !== "number")
|
|
1376
|
+
return _error;
|
|
1377
|
+
let valid = true;
|
|
1378
|
+
if (typeof min === "number" && value < min)
|
|
1379
|
+
valid = false;
|
|
1380
|
+
if (typeof max === "number" && value > max)
|
|
1381
|
+
valid = false;
|
|
1382
|
+
return valid ? null : _error;
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
// node_modules/@mantine/form/esm/validators/matches-field/matches-field.mjs
|
|
1387
|
+
|
|
1388
|
+
function matchesField(field, error) {
|
|
1389
|
+
const _error = error || true;
|
|
1390
|
+
return (value, values) => {
|
|
1391
|
+
if (!values || !(field in values))
|
|
1392
|
+
return _error;
|
|
1393
|
+
return value === values[field] ? null : _error;
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
// node_modules/@mantine/form/esm/validators/is-not-empty-html/is-not-empty-html.mjs
|
|
1398
|
+
|
|
1399
|
+
function removeHtmlTags(input) {
|
|
1400
|
+
return input.replace(/<\/?[^>]+(>|$)/g, "");
|
|
1401
|
+
}
|
|
1402
|
+
function isNotEmptyHTML(error) {
|
|
1403
|
+
const _error = error || true;
|
|
1404
|
+
return (value) => {
|
|
1405
|
+
if (typeof value === "string")
|
|
1406
|
+
return removeHtmlTags(value).trim().length > 0 ? null : _error;
|
|
1407
|
+
return _error;
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
// node_modules/@mantine/form/esm/validators/is-json-string/is-json-string.mjs
|
|
1412
|
+
|
|
1413
|
+
function isJSONString(error) {
|
|
1414
|
+
const _error = error || true;
|
|
1415
|
+
return (value) => {
|
|
1416
|
+
if (typeof value === "string")
|
|
1417
|
+
try {
|
|
1418
|
+
JSON.parse(value);
|
|
1419
|
+
return null;
|
|
1420
|
+
} catch (e) {
|
|
1421
|
+
return _error;
|
|
1422
|
+
}
|
|
1423
|
+
return _error;
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// node_modules/@mantine/form/esm/validators/is-url/is-url.mjs
|
|
1428
|
+
|
|
1429
|
+
function isUrl(optionsOrError, error) {
|
|
1430
|
+
let _options = {};
|
|
1431
|
+
let _error;
|
|
1432
|
+
if (optionsOrError !== null && optionsOrError !== undefined && typeof optionsOrError === "object" && !Array.isArray(optionsOrError) && (("protocols" in optionsOrError) || ("allowLocalhost" in optionsOrError))) {
|
|
1433
|
+
_options = optionsOrError;
|
|
1434
|
+
_error = error || true;
|
|
1435
|
+
} else
|
|
1436
|
+
_error = optionsOrError || true;
|
|
1437
|
+
const protocols = _options.protocols ?? ["http", "https"];
|
|
1438
|
+
const allowLocalhost = _options.allowLocalhost ?? false;
|
|
1439
|
+
return (value) => {
|
|
1440
|
+
if (typeof value !== "string")
|
|
1441
|
+
return _error;
|
|
1442
|
+
try {
|
|
1443
|
+
const url = new URL(value);
|
|
1444
|
+
const protocol = url.protocol.replace(":", "");
|
|
1445
|
+
if (!protocols.includes(protocol))
|
|
1446
|
+
return _error;
|
|
1447
|
+
if (!allowLocalhost && url.hostname === "localhost")
|
|
1448
|
+
return _error;
|
|
1449
|
+
return null;
|
|
1450
|
+
} catch {
|
|
1451
|
+
return _error;
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// node_modules/@mantine/form/esm/validators/is-one-of/is-one-of.mjs
|
|
1457
|
+
|
|
1458
|
+
function isOneOf(values, error) {
|
|
1459
|
+
const _error = error || true;
|
|
1460
|
+
return (value) => {
|
|
1461
|
+
return values.includes(value) ? null : _error;
|
|
1462
|
+
};
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
// node_modules/@mantine/form/esm/use-field.mjs
|
|
1466
|
+
import { useCallback as useCallback8, useMemo as useMemo2, useRef as useRef7, useState as useState6 } from "react";
|
|
1467
|
+
|
|
1468
|
+
function useField({ mode = "controlled", clearErrorOnChange = true, initialValue, initialError = null, initialTouched = false, onValueChange, validateOnChange = false, validateOnBlur = false, validate, resolveValidationError, type = "input" }) {
|
|
1469
|
+
const [valueState, setValueState] = useState6(initialValue);
|
|
1470
|
+
const valueRef = useRef7(valueState);
|
|
1471
|
+
const [key, setKey] = useState6(0);
|
|
1472
|
+
const [error, setError] = useState6(initialError || null);
|
|
1473
|
+
const touchedRef = useRef7(initialTouched || false);
|
|
1474
|
+
const [, setTouchedState] = useState6(touchedRef.current);
|
|
1475
|
+
const [isValidating, setIsValidating] = useState6(false);
|
|
1476
|
+
const errorResolver = useMemo2(() => resolveValidationError || ((err) => err), [resolveValidationError]);
|
|
1477
|
+
const setTouched = useCallback8((val, { updateState = mode === "controlled" } = {}) => {
|
|
1478
|
+
touchedRef.current = val;
|
|
1479
|
+
updateState && setTouchedState(val);
|
|
1480
|
+
}, []);
|
|
1481
|
+
const setValue = useCallback8((value, { updateKey = mode === "uncontrolled", updateState = mode === "controlled" } = {}) => {
|
|
1482
|
+
if (valueRef.current === value)
|
|
1483
|
+
return;
|
|
1484
|
+
valueRef.current = value;
|
|
1485
|
+
onValueChange?.(value);
|
|
1486
|
+
if (clearErrorOnChange && error !== null)
|
|
1487
|
+
setError(null);
|
|
1488
|
+
if (updateState)
|
|
1489
|
+
setValueState(value);
|
|
1490
|
+
if (updateKey)
|
|
1491
|
+
setKey((currentKey) => currentKey + 1);
|
|
1492
|
+
if (validateOnChange)
|
|
1493
|
+
_validate();
|
|
1494
|
+
}, [
|
|
1495
|
+
error,
|
|
1496
|
+
clearErrorOnChange,
|
|
1497
|
+
onValueChange
|
|
1498
|
+
]);
|
|
1499
|
+
const reset = useCallback8(() => {
|
|
1500
|
+
setValue(initialValue);
|
|
1501
|
+
setError(null);
|
|
1502
|
+
setTouched(false);
|
|
1503
|
+
}, [initialValue]);
|
|
1504
|
+
const getValue = useCallback8(() => valueRef.current, []);
|
|
1505
|
+
const isTouched = useCallback8(() => touchedRef.current, []);
|
|
1506
|
+
const isDirty = useCallback8(() => valueRef.current !== initialValue, [initialValue]);
|
|
1507
|
+
const _validate = useCallback8(async () => {
|
|
1508
|
+
const validationResult = validate?.(valueRef.current);
|
|
1509
|
+
if (validationResult instanceof Promise) {
|
|
1510
|
+
setIsValidating(true);
|
|
1511
|
+
try {
|
|
1512
|
+
const result = await validationResult;
|
|
1513
|
+
setIsValidating(false);
|
|
1514
|
+
setError(result);
|
|
1515
|
+
} catch (err) {
|
|
1516
|
+
setIsValidating(false);
|
|
1517
|
+
const resolvedError = errorResolver(err);
|
|
1518
|
+
setError(resolvedError);
|
|
1519
|
+
return resolvedError;
|
|
1520
|
+
}
|
|
1521
|
+
} else {
|
|
1522
|
+
setError(validationResult);
|
|
1523
|
+
return validationResult;
|
|
1524
|
+
}
|
|
1525
|
+
}, []);
|
|
1526
|
+
const getInputProps = ({ withError = true, withFocus = true, ...otherOptions } = {}) => {
|
|
1527
|
+
const payload = { onChange: getInputOnChange((val) => setValue(val, { updateKey: false })) };
|
|
1528
|
+
if (withError)
|
|
1529
|
+
payload.error = error;
|
|
1530
|
+
if (type === "checkbox")
|
|
1531
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = valueRef.current;
|
|
1532
|
+
else if (type === "radio") {
|
|
1533
|
+
payload[mode === "controlled" ? "checked" : "defaultChecked"] = valueRef.current === otherOptions.value;
|
|
1534
|
+
payload.value = otherOptions.value;
|
|
1535
|
+
} else
|
|
1536
|
+
payload[mode === "controlled" ? "value" : "defaultValue"] = valueRef.current;
|
|
1537
|
+
if (withFocus) {
|
|
1538
|
+
payload.onFocus = () => {
|
|
1539
|
+
setTouched(true);
|
|
1540
|
+
};
|
|
1541
|
+
payload.onBlur = () => {
|
|
1542
|
+
if (shouldValidateOnChange("", !!validateOnBlur))
|
|
1543
|
+
_validate();
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
return payload;
|
|
1547
|
+
};
|
|
1548
|
+
return {
|
|
1549
|
+
key,
|
|
1550
|
+
getValue,
|
|
1551
|
+
setValue,
|
|
1552
|
+
reset,
|
|
1553
|
+
getInputProps,
|
|
1554
|
+
isValidating,
|
|
1555
|
+
validate: _validate,
|
|
1556
|
+
error,
|
|
1557
|
+
setError,
|
|
1558
|
+
isTouched,
|
|
1559
|
+
isDirty,
|
|
1560
|
+
resetTouched: useCallback8(() => setTouched(false), [])
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// node_modules/@mantine/form/esm/schema-resolver.mjs
|
|
1565
|
+
|
|
1566
|
+
function issuesToFormErrors(issues) {
|
|
1567
|
+
const errors = {};
|
|
1568
|
+
for (const issue of issues) {
|
|
1569
|
+
const path = issue.path ? issue.path.map((segment) => typeof segment === "object" ? segment.key : segment).join(".") : "";
|
|
1570
|
+
if (!errors[path])
|
|
1571
|
+
errors[path] = issue.message;
|
|
1572
|
+
}
|
|
1573
|
+
return filterErrors(errors);
|
|
1574
|
+
}
|
|
1575
|
+
function schemaResolver(schema, _options) {
|
|
1576
|
+
const sync = _options?.sync ?? false;
|
|
1577
|
+
return (values) => {
|
|
1578
|
+
const result = schema["~standard"].validate(values);
|
|
1579
|
+
if (result instanceof Promise)
|
|
1580
|
+
return result.then((resolved) => resolved.issues ? issuesToFormErrors(resolved.issues) : {});
|
|
1581
|
+
const errors = result.issues ? issuesToFormErrors(result.issues) : {};
|
|
1582
|
+
return sync ? errors : Promise.resolve(errors);
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
export {
|
|
1586
|
+
useForm,
|
|
1587
|
+
useField,
|
|
1588
|
+
schemaResolver,
|
|
1589
|
+
matchesField,
|
|
1590
|
+
matches,
|
|
1591
|
+
isUrl,
|
|
1592
|
+
isOneOf,
|
|
1593
|
+
isNotEmptyHTML,
|
|
1594
|
+
isNotEmpty,
|
|
1595
|
+
isJSONString,
|
|
1596
|
+
isInRange,
|
|
1597
|
+
isEmail,
|
|
1598
|
+
hasLength,
|
|
1599
|
+
formRootRule,
|
|
1600
|
+
createFormContext,
|
|
1601
|
+
createFormActions,
|
|
1602
|
+
FORM_INDEX
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
//# debugId=EE2EA1E0683CD80964756E2164756E21
|