@overmap-ai/forms 1.0.32-react-flow-david-fixes.11 → 1.0.32-react-flow-david-fixes.13
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/dist/form/builder/components/FieldBuilder.d.ts +1 -2
- package/dist/form/builder/components/index.d.ts +1 -2
- package/dist/form/conditions/DateFieldCondition/DateFieldCondition.d.ts +6 -6
- package/dist/form/conditions/NumberFieldCondition/NumberFieldCondition.d.ts +16 -16
- package/dist/form/conditions/OTPFieldCondition/OTPFieldCondition.d.ts +1 -1
- package/dist/form/conditions/OTPFieldCondition/typings.d.ts +1 -2
- package/dist/form/conditions/RadioFieldCondition/RadioFieldCondition.d.ts +4 -4
- package/dist/form/conditions/SelectFieldCondition/SelectFieldCondition.d.ts +4 -4
- package/dist/form/conditions/components/RemoveConditionButton.d.ts +1 -1
- package/dist/form/fields/BaseField/BaseField.d.ts +7 -5
- package/dist/form/fields/BaseField/index.d.ts +0 -1
- package/dist/form/fields/BaseField/typings.d.ts +2 -1
- package/dist/form/fields/BaseFormElement/BaseFormElement.d.ts +1 -2
- package/dist/form/fields/BaseFormElement/typings.d.ts +8 -2
- package/dist/form/fields/BaseStringField/BaseStringField.d.ts +5 -2
- package/dist/form/fields/BooleanField/BooleanField.d.ts +6 -2
- package/dist/form/fields/BooleanField/BooleanInput.d.ts +1 -1
- package/dist/form/fields/CheckboxListField/CheckboxListField.d.ts +5 -1
- package/dist/form/fields/CheckboxListField/CheckboxListInput.d.ts +1 -1
- package/dist/form/fields/DateField/DateField.d.ts +9 -6
- package/dist/form/fields/DateField/DateInput.d.ts +1 -1
- package/dist/form/fields/FieldSection/FieldSection.d.ts +3 -4
- package/dist/form/fields/FieldSection/FieldSectionLayout.d.ts +1 -1
- package/dist/form/fields/FieldSection/typings.d.ts +1 -1
- package/dist/form/fields/MultiSelectField/MultiSelectField.d.ts +5 -3
- package/dist/form/fields/MultiSelectField/MultiSelectInput.d.ts +1 -1
- package/dist/form/fields/MultiStringField/MultiStringField.d.ts +6 -4
- package/dist/form/fields/MultiStringField/MultiStringInput.d.ts +1 -1
- package/dist/form/fields/NumberField/NumberField.d.ts +11 -7
- package/dist/form/fields/NumberField/NumberInput.d.ts +1 -1
- package/dist/form/fields/OneTimePasswordField/OTPField.d.ts +6 -2
- package/dist/form/fields/OneTimePasswordField/OTPInput.d.ts +1 -1
- package/dist/form/fields/RadioField/RadioField.d.ts +9 -5
- package/dist/form/fields/RadioField/RadioInput.d.ts +1 -1
- package/dist/form/fields/ScanField/ScanField.d.ts +5 -1
- package/dist/form/fields/ScanField/ScanInput.d.ts +1 -1
- package/dist/form/fields/SelectField/SelectField.d.ts +9 -5
- package/dist/form/fields/SelectField/SelectInput.d.ts +1 -1
- package/dist/form/fields/StringField/StringField.d.ts +1 -1
- package/dist/form/fields/StringField/StringInput.d.ts +1 -1
- package/dist/form/fields/TextField/TextField.d.ts +1 -1
- package/dist/form/fields/TextField/TextInput.d.ts +1 -1
- package/dist/form/fields/UploadField/UploadField.d.ts +6 -4
- package/dist/form/fields/UploadField/UploadInput.d.ts +1 -1
- package/dist/form/fields/UploadField/utils.d.ts +2 -0
- package/dist/form/fields/_utils.d.ts +2 -0
- package/dist/form/fields/hooks.d.ts +398 -2
- package/dist/form/fields/index.d.ts +2 -0
- package/dist/form/fields/typings.d.ts +2 -10
- package/dist/form/fields/utils.d.ts +3 -1
- package/dist/form/index.d.ts +1 -1
- package/dist/form/typings.d.ts +1 -1
- package/dist/form/utils.d.ts +6 -7
- package/dist/forms.js +698 -567
- package/dist/forms.umd.cjs +698 -567
- package/package.json +1 -1
- package/dist/form/fields/BaseField/hooks.d.ts +0 -397
- /package/dist/form/builder/{components → list}/FieldSectionBuilder.d.ts +0 -0
- /package/dist/form/builder/{components → list}/FieldSectionWithActions.d.ts +0 -0
package/dist/forms.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(global2, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("class-variance-authority"), require("react"), require("@xyflow/react/dist/style.css"), require("@xyflow/react"), require("formik"), require("graphology"), require("graphology-dag"), require("uuid"), require("@hello-pangea/dnd"), require("lucide-react"), require("react-dom"), require("file-saver"), require("react-zxing"), require("lodash.get"), require("
|
|
3
|
-
})(this, function(exports2, jsxRuntime, blocks, classVarianceAuthority, React, style_css, react, formik, graphology, graphologyDag, uuid, dnd, lucideReact, ReactDOM, fileSaver, reactZxing, get,
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("class-variance-authority"), require("react"), require("@xyflow/react/dist/style.css"), require("@xyflow/react"), require("formik"), require("graphology"), require("graphology-dag"), require("uuid"), require("@hello-pangea/dnd"), require("lucide-react"), require("react-dom"), require("file-saver"), require("react-zxing"), require("lodash.get"), require("@dagrejs/dagre"), require("lodash.set")) : typeof define === "function" && define.amd ? define(["exports", "react/jsx-runtime", "@overmap-ai/blocks", "class-variance-authority", "react", "@xyflow/react/dist/style.css", "@xyflow/react", "formik", "graphology", "graphology-dag", "uuid", "@hello-pangea/dnd", "lucide-react", "react-dom", "file-saver", "react-zxing", "lodash.get", "@dagrejs/dagre", "lodash.set"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.forms = {}, global2.jsxRuntime, global2.blocks, global2.classVarianceAuthority, global2.React, null, global2.react, global2.formik, global2.graphology, global2.graphologyDag, global2.uuid, global2.dnd, global2.lucideReact, global2.ReactDOM, global2.fileSaver, global2.reactZxing, global2.get, global2.Dagre, global2.set));
|
|
3
|
+
})(this, function(exports2, jsxRuntime, blocks, classVarianceAuthority, React, style_css, react, formik, graphology, graphologyDag, uuid, dnd, lucideReact, ReactDOM, fileSaver, reactZxing, get, Dagre, set) {
|
|
4
4
|
"use strict";var __defProp = Object.defineProperty;
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -40,6 +40,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
40
40
|
info: "base",
|
|
41
41
|
success: "success"
|
|
42
42
|
};
|
|
43
|
+
function isStringArray(value) {
|
|
44
|
+
if (!Array.isArray(value)) return false;
|
|
45
|
+
return value.every((item) => typeof item === "string");
|
|
46
|
+
}
|
|
47
|
+
function isFilePromiseArray(value) {
|
|
48
|
+
if (!Array.isArray(value)) return false;
|
|
49
|
+
return value.every((item) => item instanceof Promise || item instanceof File);
|
|
50
|
+
}
|
|
43
51
|
class Observable {
|
|
44
52
|
constructor() {
|
|
45
53
|
__publicField(this, "observers", /* @__PURE__ */ new Set());
|
|
@@ -101,14 +109,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
101
109
|
this.image = image;
|
|
102
110
|
this.fieldValidators = fieldValidators;
|
|
103
111
|
}
|
|
104
|
-
isBlank(value) {
|
|
105
|
-
return value === void 0;
|
|
106
|
-
}
|
|
107
|
-
isEqual(value1, value2) {
|
|
108
|
-
return value1 === value2;
|
|
109
|
-
}
|
|
110
112
|
getError(value) {
|
|
111
|
-
if (this.required && this.
|
|
113
|
+
if (this.required && this.isValueBlank(value)) {
|
|
112
114
|
return "This field is required.";
|
|
113
115
|
}
|
|
114
116
|
for (const validator of this.getFieldValidators()) {
|
|
@@ -144,59 +146,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
144
146
|
this.fieldValidators = fieldValidators ?? this.fieldValidators;
|
|
145
147
|
super.setOptions(base);
|
|
146
148
|
}
|
|
149
|
+
isValueBlank(value) {
|
|
150
|
+
return this.areValuesEqual(value, this.blankValue());
|
|
151
|
+
}
|
|
147
152
|
getFieldValidators() {
|
|
148
153
|
return [...this.fieldValidators];
|
|
149
154
|
}
|
|
150
155
|
}
|
|
151
156
|
__publicField(BaseField, "fieldTypeName");
|
|
152
157
|
__publicField(BaseField, "fieldTypeDescription");
|
|
153
|
-
const useFormikInput = (props) => {
|
|
154
|
-
const { field, size, showInputOnly, onValuesChange, ...rest } = props;
|
|
155
|
-
const [fieldProps, meta, helpers] = formik.useField(field.identifier);
|
|
156
|
-
const { touched } = meta;
|
|
157
|
-
const helpText = meta.error ?? field.description;
|
|
158
|
-
const severity = meta.error ? "danger" : void 0;
|
|
159
|
-
const inputId = field.identifier;
|
|
160
|
-
const labelId = `${inputId}-label`;
|
|
161
|
-
const label = field.required ? `${field.label} *` : field.label;
|
|
162
|
-
const fieldPropsWithValidation = React.useMemo(() => {
|
|
163
|
-
const handleChange = (value) => {
|
|
164
|
-
helpers.setValue(value, false).then();
|
|
165
|
-
onValuesChange == null ? void 0 : onValuesChange(field.identifier, value);
|
|
166
|
-
if (touched || !field.onlyValidateAfterTouched) {
|
|
167
|
-
helpers.setError(field.getError(value));
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const handleBlur = (value) => {
|
|
171
|
-
void helpers.setTouched(true, false).then();
|
|
172
|
-
helpers.setError(field.getError(value));
|
|
173
|
-
};
|
|
174
|
-
return {
|
|
175
|
-
...fieldProps,
|
|
176
|
-
// name and value not being overridden
|
|
177
|
-
onChange: handleChange,
|
|
178
|
-
onBlur: handleBlur
|
|
179
|
-
};
|
|
180
|
-
}, [field, fieldProps, helpers, onValuesChange, touched]);
|
|
181
|
-
return [
|
|
182
|
-
{
|
|
183
|
-
helpText,
|
|
184
|
-
size,
|
|
185
|
-
severity,
|
|
186
|
-
inputId,
|
|
187
|
-
labelId,
|
|
188
|
-
label,
|
|
189
|
-
showInputOnly,
|
|
190
|
-
fieldProps: fieldPropsWithValidation,
|
|
191
|
-
helpers,
|
|
192
|
-
field,
|
|
193
|
-
touched
|
|
194
|
-
},
|
|
195
|
-
/* Props that should be spread on the html element representing the field */
|
|
196
|
-
{ ...rest, "aria-labelledby": labelId }
|
|
197
|
-
];
|
|
198
|
-
};
|
|
199
|
-
const EMPTY_ARRAY = [];
|
|
200
158
|
const InputWithHelpText = (props) => {
|
|
201
159
|
const { helpText, children, severity } = props;
|
|
202
160
|
const color = severity ? SEVERITY_COLOR_MAPPING[severity] : "base";
|
|
@@ -2306,14 +2264,70 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2306
2264
|
const { children, ...restProps } = props;
|
|
2307
2265
|
return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
|
|
2308
2266
|
};
|
|
2267
|
+
const useFieldInput = (field, props) => {
|
|
2268
|
+
return React.useMemo(() => {
|
|
2269
|
+
if (!props || !field) return null;
|
|
2270
|
+
return field.render(props);
|
|
2271
|
+
}, [field, props]);
|
|
2272
|
+
};
|
|
2273
|
+
const useFieldInputs = (fields, props) => {
|
|
2274
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: fields.map((field) => {
|
|
2275
|
+
return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: field.render(props) }, field.identifier);
|
|
2276
|
+
}) });
|
|
2277
|
+
};
|
|
2278
|
+
const useFormikInput = (props) => {
|
|
2279
|
+
const { field, size, showInputOnly, onValuesChange, ...rest } = props;
|
|
2280
|
+
const [fieldProps, meta, helpers] = formik.useField(field.identifier);
|
|
2281
|
+
const { touched } = meta;
|
|
2282
|
+
const helpText = meta.error ?? field.description;
|
|
2283
|
+
const severity = meta.error ? "danger" : void 0;
|
|
2284
|
+
const inputId = field.identifier;
|
|
2285
|
+
const labelId = `${inputId}-label`;
|
|
2286
|
+
const label = field.required ? `${field.label} *` : field.label;
|
|
2287
|
+
const fieldPropsWithValidation = React.useMemo(() => {
|
|
2288
|
+
const handleChange = (value) => {
|
|
2289
|
+
helpers.setValue(value, false).then();
|
|
2290
|
+
onValuesChange == null ? void 0 : onValuesChange(field.identifier, value);
|
|
2291
|
+
if (touched || !field.onlyValidateAfterTouched) {
|
|
2292
|
+
helpers.setError(field.getError(value));
|
|
2293
|
+
}
|
|
2294
|
+
};
|
|
2295
|
+
const handleBlur = (value) => {
|
|
2296
|
+
void helpers.setTouched(true, false).then();
|
|
2297
|
+
helpers.setError(field.getError(value));
|
|
2298
|
+
};
|
|
2299
|
+
return {
|
|
2300
|
+
...fieldProps,
|
|
2301
|
+
// name and value not being overridden
|
|
2302
|
+
onChange: handleChange,
|
|
2303
|
+
onBlur: handleBlur
|
|
2304
|
+
};
|
|
2305
|
+
}, [field, fieldProps, helpers, onValuesChange, touched]);
|
|
2306
|
+
return [
|
|
2307
|
+
{
|
|
2308
|
+
helpText,
|
|
2309
|
+
size,
|
|
2310
|
+
severity,
|
|
2311
|
+
inputId,
|
|
2312
|
+
labelId,
|
|
2313
|
+
label,
|
|
2314
|
+
showInputOnly,
|
|
2315
|
+
fieldProps: fieldPropsWithValidation,
|
|
2316
|
+
helpers,
|
|
2317
|
+
field,
|
|
2318
|
+
touched
|
|
2319
|
+
},
|
|
2320
|
+
/* Props that should be spread on the html element representing the field */
|
|
2321
|
+
{ ...rest, "aria-labelledby": labelId }
|
|
2322
|
+
];
|
|
2323
|
+
};
|
|
2309
2324
|
const MultiStringInput = React.memo((props) => {
|
|
2310
2325
|
const [{ inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps }, rest] = useFormikInput(props);
|
|
2311
2326
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
2312
2327
|
const computedLabel = showInputOnly ? "" : label;
|
|
2313
|
-
const { name, onChange, onBlur } = fieldProps;
|
|
2328
|
+
const { value, name, onChange, onBlur } = fieldProps;
|
|
2314
2329
|
const droppableId = `${inputId}-droppable`;
|
|
2315
2330
|
const { disabled } = rest;
|
|
2316
|
-
const value = fieldProps.value ?? EMPTY_ARRAY;
|
|
2317
2331
|
const [intermediateValue, setIntermediateValue] = React.useState("");
|
|
2318
2332
|
const [internalError, setInternalError] = React.useState("");
|
|
2319
2333
|
const updatedHelpText = internalError || computedHelpText;
|
|
@@ -2527,14 +2541,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2527
2541
|
deserializeValue(value) {
|
|
2528
2542
|
return value;
|
|
2529
2543
|
}
|
|
2530
|
-
isBlank(value) {
|
|
2531
|
-
return super.isBlank(value) || (value == null ? void 0 : value.length) === 0;
|
|
2532
|
-
}
|
|
2533
|
-
isEqual(value1, value2) {
|
|
2534
|
-
if (value1 === void 0 && value2 === void 0) return true;
|
|
2535
|
-
if (value1 === void 0 || value2 === void 0) return false;
|
|
2536
|
-
return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
|
|
2537
|
-
}
|
|
2538
2544
|
getFieldValidators() {
|
|
2539
2545
|
const validators = super.getFieldValidators();
|
|
2540
2546
|
validators.push((value) => {
|
|
@@ -2552,6 +2558,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2552
2558
|
static deserialize(data) {
|
|
2553
2559
|
return new _MultiStringField(data);
|
|
2554
2560
|
}
|
|
2561
|
+
isSerializedValueValid(value) {
|
|
2562
|
+
return isStringArray(value);
|
|
2563
|
+
}
|
|
2564
|
+
isValueValid(value) {
|
|
2565
|
+
return isStringArray(value);
|
|
2566
|
+
}
|
|
2567
|
+
blankValue() {
|
|
2568
|
+
return [];
|
|
2569
|
+
}
|
|
2570
|
+
areValuesEqual(value1, value2) {
|
|
2571
|
+
return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
|
|
2572
|
+
}
|
|
2555
2573
|
};
|
|
2556
2574
|
__publicField(_MultiStringField, "fieldTypeName", "Multi-string");
|
|
2557
2575
|
__publicField(_MultiStringField, "fieldTypeDescription", "Allows the user to provide multiple unique strings.");
|
|
@@ -2657,10 +2675,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2657
2675
|
__publicField(this, "type", "boolean");
|
|
2658
2676
|
__publicField(this, "onlyValidateAfterTouched", false);
|
|
2659
2677
|
}
|
|
2660
|
-
// if a BooleanField is required, `false` is considered blank
|
|
2661
|
-
isBlank(value) {
|
|
2662
|
-
return this.required && !value;
|
|
2663
|
-
}
|
|
2664
2678
|
serialize() {
|
|
2665
2679
|
return super.serialize();
|
|
2666
2680
|
}
|
|
@@ -2689,6 +2703,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2689
2703
|
render(props) {
|
|
2690
2704
|
return /* @__PURE__ */ jsxRuntime.jsx(BooleanInput, { ...props, field: this });
|
|
2691
2705
|
}
|
|
2706
|
+
isSerializedValueValid(value) {
|
|
2707
|
+
return typeof value === "boolean";
|
|
2708
|
+
}
|
|
2709
|
+
isValueValid(value) {
|
|
2710
|
+
return typeof value === "boolean";
|
|
2711
|
+
}
|
|
2712
|
+
blankValue() {
|
|
2713
|
+
return false;
|
|
2714
|
+
}
|
|
2715
|
+
areValuesEqual(value1, value2) {
|
|
2716
|
+
return value1 === value2;
|
|
2717
|
+
}
|
|
2692
2718
|
};
|
|
2693
2719
|
__publicField(_BooleanField, "fieldTypeName", "Checkbox");
|
|
2694
2720
|
__publicField(_BooleanField, "fieldTypeDescription", "Perfect for both optional and required yes/no questions.");
|
|
@@ -2701,14 +2727,14 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2701
2727
|
const { name, onBlur, onChange, value } = fieldProps;
|
|
2702
2728
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
2703
2729
|
const computedLabel = showInputOnly ? "" : label;
|
|
2704
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
2730
|
+
const [internalValue, setInternalValue] = React.useState(null);
|
|
2705
2731
|
React.useEffect(() => {
|
|
2706
2732
|
setInternalValue(value);
|
|
2707
2733
|
}, [value]);
|
|
2708
2734
|
const handleChange = React.useCallback(
|
|
2709
2735
|
(e) => {
|
|
2710
2736
|
const number = e.target.valueAsNumber;
|
|
2711
|
-
const value2 =
|
|
2737
|
+
const value2 = !isNaN(number) ? number : null;
|
|
2712
2738
|
setInternalValue(value2);
|
|
2713
2739
|
if (touched || !field.onlyValidateAfterTouched) {
|
|
2714
2740
|
helpers.setError(field.getError(value2));
|
|
@@ -2876,6 +2902,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2876
2902
|
render(props) {
|
|
2877
2903
|
return /* @__PURE__ */ jsxRuntime.jsx(NumberInput, { field: this, ...props });
|
|
2878
2904
|
}
|
|
2905
|
+
isSerializedValueValid(value) {
|
|
2906
|
+
return typeof value === "number" || value === null;
|
|
2907
|
+
}
|
|
2908
|
+
isValueValid(value) {
|
|
2909
|
+
return typeof value === "number" || value === null;
|
|
2910
|
+
}
|
|
2911
|
+
areValuesEqual(value1, value2) {
|
|
2912
|
+
return value1 === value2;
|
|
2913
|
+
}
|
|
2914
|
+
blankValue() {
|
|
2915
|
+
return null;
|
|
2916
|
+
}
|
|
2879
2917
|
};
|
|
2880
2918
|
__publicField(_NumberField, "fieldTypeName", "Number");
|
|
2881
2919
|
__publicField(_NumberField, "fieldTypeDescription", "Allows specifying a number within a given range.");
|
|
@@ -2973,18 +3011,28 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
2973
3011
|
deserializeValue(value) {
|
|
2974
3012
|
return value;
|
|
2975
3013
|
}
|
|
3014
|
+
isSerializedValueValid(value) {
|
|
3015
|
+
return typeof value === "string";
|
|
3016
|
+
}
|
|
3017
|
+
isValueValid(value) {
|
|
3018
|
+
return typeof value === "string";
|
|
3019
|
+
}
|
|
3020
|
+
blankValue() {
|
|
3021
|
+
return "";
|
|
3022
|
+
}
|
|
3023
|
+
areValuesEqual(value1, value2) {
|
|
3024
|
+
return value1 === value2;
|
|
3025
|
+
}
|
|
2976
3026
|
}
|
|
2977
3027
|
const CheckboxListInput = React.memo((props) => {
|
|
2978
3028
|
const [{ inputId, labelId, size, severity, field, showInputOnly, helpText, label, fieldProps }, rest] = useFormikInput(props);
|
|
2979
|
-
const { name, onChange, onBlur } = fieldProps;
|
|
3029
|
+
const { value, name, onChange, onBlur } = fieldProps;
|
|
2980
3030
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
2981
3031
|
const computedLabel = showInputOnly ? "" : label;
|
|
2982
|
-
const value = fieldProps.value ?? EMPTY_ARRAY;
|
|
2983
3032
|
const handleChange = React.useCallback(
|
|
2984
3033
|
(value2) => {
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
onBlur(newValue);
|
|
3034
|
+
onChange(value2);
|
|
3035
|
+
onBlur(value2);
|
|
2988
3036
|
},
|
|
2989
3037
|
[onBlur, onChange]
|
|
2990
3038
|
);
|
|
@@ -3049,20 +3097,31 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3049
3097
|
render(props) {
|
|
3050
3098
|
return /* @__PURE__ */ jsxRuntime.jsx(CheckboxListInput, { field: this, ...props });
|
|
3051
3099
|
}
|
|
3100
|
+
isSerializedValueValid(value) {
|
|
3101
|
+
return isStringArray(value);
|
|
3102
|
+
}
|
|
3103
|
+
isValueValid(value) {
|
|
3104
|
+
return isStringArray(value);
|
|
3105
|
+
}
|
|
3106
|
+
blankValue() {
|
|
3107
|
+
return [];
|
|
3108
|
+
}
|
|
3109
|
+
areValuesEqual(value1, value2) {
|
|
3110
|
+
return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
|
|
3111
|
+
}
|
|
3052
3112
|
};
|
|
3053
3113
|
__publicField(_CheckboxListField, "fieldTypeName", "Checkbox list");
|
|
3054
3114
|
__publicField(_CheckboxListField, "fieldTypeDescription", "Allows the user to select a multiple options from a list.");
|
|
3055
3115
|
let CheckboxListField = _CheckboxListField;
|
|
3056
3116
|
const DateInput = React.memo((props) => {
|
|
3057
3117
|
const [{ inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps }, rest] = useFormikInput(props);
|
|
3058
|
-
const { name, onChange, onBlur } = fieldProps;
|
|
3118
|
+
const { value, name, onChange, onBlur } = fieldProps;
|
|
3059
3119
|
const [popoverOpen, setPopoverOpen] = React.useState(false);
|
|
3060
3120
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
3061
3121
|
const computedLabel = showInputOnly ? "" : label;
|
|
3062
|
-
const value = fieldProps.value ? new Date(fieldProps.value) : void 0;
|
|
3063
3122
|
const handleValueChange = React.useCallback(
|
|
3064
3123
|
(date) => {
|
|
3065
|
-
onChange(date);
|
|
3124
|
+
onChange(date ?? null);
|
|
3066
3125
|
setPopoverOpen(false);
|
|
3067
3126
|
},
|
|
3068
3127
|
[onChange]
|
|
@@ -3111,7 +3170,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3111
3170
|
required: false,
|
|
3112
3171
|
mode: "single",
|
|
3113
3172
|
variant: "solid",
|
|
3114
|
-
selected: value,
|
|
3173
|
+
selected: value ?? void 0,
|
|
3115
3174
|
onSelect: handleValueChange
|
|
3116
3175
|
}
|
|
3117
3176
|
) })
|
|
@@ -3145,34 +3204,41 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3145
3204
|
super.setOptions(options2);
|
|
3146
3205
|
}
|
|
3147
3206
|
serializeValue(value) {
|
|
3148
|
-
return value.toISOString();
|
|
3207
|
+
return value ? value.toISOString() : null;
|
|
3149
3208
|
}
|
|
3150
3209
|
deserializeValue(value) {
|
|
3151
|
-
return new Date(value);
|
|
3152
|
-
}
|
|
3153
|
-
isEqual(value1, value2) {
|
|
3154
|
-
if (value1 === void 0 && value2 === void 0) return true;
|
|
3155
|
-
if (!value1 || !value2) return false;
|
|
3156
|
-
return value1.getTime() === value2.getTime();
|
|
3210
|
+
return value ? new Date(value) : null;
|
|
3157
3211
|
}
|
|
3158
3212
|
render(props) {
|
|
3159
3213
|
return /* @__PURE__ */ jsxRuntime.jsx(DateInput, { field: this, ...props });
|
|
3160
3214
|
}
|
|
3215
|
+
isSerializedValueValid(value) {
|
|
3216
|
+
return typeof value === "string" || value === null;
|
|
3217
|
+
}
|
|
3218
|
+
isValueValid(value) {
|
|
3219
|
+
return value instanceof Date || value === null;
|
|
3220
|
+
}
|
|
3221
|
+
blankValue() {
|
|
3222
|
+
return null;
|
|
3223
|
+
}
|
|
3224
|
+
areValuesEqual(value1, value2) {
|
|
3225
|
+
if (!value1 && !value2) return true;
|
|
3226
|
+
if (!value1 || !value2) return false;
|
|
3227
|
+
return value1.getTime() === value2.getTime();
|
|
3228
|
+
}
|
|
3161
3229
|
};
|
|
3162
3230
|
__publicField(_DateField, "fieldTypeName", "Date");
|
|
3163
3231
|
__publicField(_DateField, "fieldTypeDescription", "Allows specifying a date.");
|
|
3164
3232
|
let DateField = _DateField;
|
|
3165
3233
|
const MultiSelectInput = React.memo((props) => {
|
|
3166
3234
|
const [{ inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps }, rest] = useFormikInput(props);
|
|
3167
|
-
const { name, onChange, onBlur } = fieldProps;
|
|
3235
|
+
const { value, name, onChange, onBlur } = fieldProps;
|
|
3168
3236
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
3169
3237
|
const computedLabel = showInputOnly ? "" : label;
|
|
3170
|
-
const value = fieldProps.value ?? EMPTY_ARRAY;
|
|
3171
3238
|
const handleChange = React.useCallback(
|
|
3172
3239
|
(value2) => {
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
onBlur(newValue);
|
|
3240
|
+
onChange(value2);
|
|
3241
|
+
onBlur(value2);
|
|
3176
3242
|
},
|
|
3177
3243
|
[onBlur, onChange]
|
|
3178
3244
|
);
|
|
@@ -3239,14 +3305,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3239
3305
|
__publicField(this, "placeholder");
|
|
3240
3306
|
this.placeholder = placeholder;
|
|
3241
3307
|
}
|
|
3242
|
-
isBlank(value) {
|
|
3243
|
-
return super.isBlank(value) || (value == null ? void 0 : value.length) === 0;
|
|
3244
|
-
}
|
|
3245
|
-
isEqual(value1, value2) {
|
|
3246
|
-
if (value1 === void 0 && value2 === void 0) return true;
|
|
3247
|
-
if (value1 === void 0 || value2 === void 0) return false;
|
|
3248
|
-
return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
|
|
3249
|
-
}
|
|
3250
3308
|
serialize() {
|
|
3251
3309
|
return super.serialize();
|
|
3252
3310
|
}
|
|
@@ -3279,6 +3337,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3279
3337
|
render(props) {
|
|
3280
3338
|
return /* @__PURE__ */ jsxRuntime.jsx(MultiSelectInput, { field: this, ...props });
|
|
3281
3339
|
}
|
|
3340
|
+
isSerializedValueValid(value) {
|
|
3341
|
+
return isStringArray(value);
|
|
3342
|
+
}
|
|
3343
|
+
isValueValid(value) {
|
|
3344
|
+
return isStringArray(value);
|
|
3345
|
+
}
|
|
3346
|
+
blankValue() {
|
|
3347
|
+
return [];
|
|
3348
|
+
}
|
|
3349
|
+
areValuesEqual(value1, value2) {
|
|
3350
|
+
return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
|
|
3351
|
+
}
|
|
3282
3352
|
};
|
|
3283
3353
|
__publicField(_MultiSelectField, "fieldTypeName", "Multi-select");
|
|
3284
3354
|
__publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
|
|
@@ -3290,8 +3360,8 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3290
3360
|
const computedLabel = showInputOnly ? "" : label;
|
|
3291
3361
|
const handleChange = React.useCallback(
|
|
3292
3362
|
(value2) => {
|
|
3293
|
-
onChange(value2);
|
|
3294
|
-
onBlur(value2);
|
|
3363
|
+
onChange(value2 ?? null);
|
|
3364
|
+
onBlur(value2 ?? null);
|
|
3295
3365
|
},
|
|
3296
3366
|
[onBlur, onChange]
|
|
3297
3367
|
);
|
|
@@ -3374,6 +3444,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3374
3444
|
render(props) {
|
|
3375
3445
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectInput, { field: this, ...props });
|
|
3376
3446
|
}
|
|
3447
|
+
isSerializedValueValid(value) {
|
|
3448
|
+
return typeof value === "string" || value === null;
|
|
3449
|
+
}
|
|
3450
|
+
isValueValid(value) {
|
|
3451
|
+
return typeof value === "string" || value === null;
|
|
3452
|
+
}
|
|
3453
|
+
blankValue() {
|
|
3454
|
+
return null;
|
|
3455
|
+
}
|
|
3456
|
+
areValuesEqual(value1, value2) {
|
|
3457
|
+
return value1 === value2;
|
|
3458
|
+
}
|
|
3377
3459
|
};
|
|
3378
3460
|
__publicField(_SelectField, "fieldTypeName", "Dropdown");
|
|
3379
3461
|
__publicField(_SelectField, "fieldTypeDescription", "Allows the user to select a single option from a list of options.");
|
|
@@ -3386,16 +3468,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3386
3468
|
const { name, onBlur, onChange, value } = fieldProps;
|
|
3387
3469
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
3388
3470
|
const computedLabel = showInputOnly ? "" : label;
|
|
3389
|
-
const [internalValue, setInternalValue] = React.useState();
|
|
3471
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
3390
3472
|
const inputUuids = React.useMemo(() => Array.from({ length: field.length }, () => uuid.v4()), [field.length]);
|
|
3391
3473
|
React.useEffect(() => {
|
|
3392
3474
|
setInternalValue(value);
|
|
3393
3475
|
}, [value]);
|
|
3394
3476
|
const handleChange = React.useCallback(
|
|
3395
3477
|
(value2) => {
|
|
3396
|
-
setInternalValue(value2
|
|
3478
|
+
setInternalValue(value2);
|
|
3397
3479
|
if (touched || !field.onlyValidateAfterTouched) {
|
|
3398
|
-
helpers.setError(field.getError(value2
|
|
3480
|
+
helpers.setError(field.getError(value2));
|
|
3399
3481
|
}
|
|
3400
3482
|
},
|
|
3401
3483
|
[field, helpers, touched]
|
|
@@ -3425,7 +3507,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3425
3507
|
{
|
|
3426
3508
|
id: inputId,
|
|
3427
3509
|
name,
|
|
3428
|
-
value: internalValue
|
|
3510
|
+
value: internalValue,
|
|
3429
3511
|
onValueChange: handleChange,
|
|
3430
3512
|
validationType: field.validationType,
|
|
3431
3513
|
form: formId2,
|
|
@@ -3508,7 +3590,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3508
3590
|
const validators = super.getFieldValidators();
|
|
3509
3591
|
const length = this.length;
|
|
3510
3592
|
validators.push((value) => {
|
|
3511
|
-
if (
|
|
3593
|
+
if (!this.isValueBlank(value) && (value.length < length || value.length > length)) {
|
|
3512
3594
|
return `Must be ${length} characters.`;
|
|
3513
3595
|
}
|
|
3514
3596
|
});
|
|
@@ -3552,6 +3634,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3552
3634
|
render(props) {
|
|
3553
3635
|
return /* @__PURE__ */ jsxRuntime.jsx(OTPInput, { field: this, ...props });
|
|
3554
3636
|
}
|
|
3637
|
+
isSerializedValueValid(value) {
|
|
3638
|
+
return typeof value === "string";
|
|
3639
|
+
}
|
|
3640
|
+
isValueValid(value) {
|
|
3641
|
+
return typeof value === "string";
|
|
3642
|
+
}
|
|
3643
|
+
blankValue() {
|
|
3644
|
+
return "";
|
|
3645
|
+
}
|
|
3646
|
+
areValuesEqual(value1, value2) {
|
|
3647
|
+
return value1 === value2;
|
|
3648
|
+
}
|
|
3555
3649
|
};
|
|
3556
3650
|
__publicField(_OTPField, "fieldTypeName", "OTP");
|
|
3557
3651
|
__publicField(_OTPField, "fieldTypeDescription", "Allows specifying a number within a given range.");
|
|
@@ -3563,14 +3657,14 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3563
3657
|
const computedLabel = showInputOnly ? "" : label;
|
|
3564
3658
|
const handleChange = React.useCallback(
|
|
3565
3659
|
(value2) => {
|
|
3566
|
-
onChange(value2
|
|
3567
|
-
onBlur(value2
|
|
3660
|
+
onChange(value2);
|
|
3661
|
+
onBlur(value2);
|
|
3568
3662
|
},
|
|
3569
3663
|
[onBlur, onChange]
|
|
3570
3664
|
);
|
|
3571
3665
|
const handleClear = React.useCallback(() => {
|
|
3572
|
-
onChange(
|
|
3573
|
-
onBlur(
|
|
3666
|
+
onChange(null);
|
|
3667
|
+
onBlur(null);
|
|
3574
3668
|
}, [onBlur, onChange]);
|
|
3575
3669
|
return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: computedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3576
3670
|
InputWithLabel,
|
|
@@ -3653,6 +3747,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
3653
3747
|
render(props) {
|
|
3654
3748
|
return /* @__PURE__ */ jsxRuntime.jsx(RadioInput, { field: this, ...props });
|
|
3655
3749
|
}
|
|
3750
|
+
isSerializedValueValid(value) {
|
|
3751
|
+
return typeof value === "string" || value === "null";
|
|
3752
|
+
}
|
|
3753
|
+
isValueValid(value) {
|
|
3754
|
+
return typeof value === "string" || value === "null";
|
|
3755
|
+
}
|
|
3756
|
+
blankValue() {
|
|
3757
|
+
return null;
|
|
3758
|
+
}
|
|
3759
|
+
areValuesEqual(value1, value2) {
|
|
3760
|
+
return value1 === value2;
|
|
3761
|
+
}
|
|
3656
3762
|
};
|
|
3657
3763
|
__publicField(_RadioField, "fieldTypeName", "Option list");
|
|
3658
3764
|
__publicField(_RadioField, "fieldTypeDescription", "Allows the user to select a single option from a list of options.");
|
|
@@ -31753,15 +31859,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
31753
31859
|
const [showScanner, setShowScanner] = React.useState(false);
|
|
31754
31860
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
31755
31861
|
const computedLabel = showInputOnly ? "" : label;
|
|
31756
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
31862
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
31757
31863
|
React.useEffect(() => {
|
|
31758
31864
|
setInternalValue(value);
|
|
31759
31865
|
}, [value]);
|
|
31760
31866
|
const handleChange = React.useCallback(
|
|
31761
31867
|
(e) => {
|
|
31762
|
-
|
|
31868
|
+
const value2 = e.target.value;
|
|
31869
|
+
setInternalValue(value2);
|
|
31763
31870
|
if (touched || !field.onlyValidateAfterTouched) {
|
|
31764
|
-
helpers.setError(field.getError(
|
|
31871
|
+
helpers.setError(field.getError(value2));
|
|
31765
31872
|
}
|
|
31766
31873
|
},
|
|
31767
31874
|
[field, helpers, touched]
|
|
@@ -31806,7 +31913,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
31806
31913
|
size: "sm",
|
|
31807
31914
|
id: inputId,
|
|
31808
31915
|
name,
|
|
31809
|
-
value: internalValue
|
|
31916
|
+
value: internalValue,
|
|
31810
31917
|
placeholder: "Enter a qr or barcode",
|
|
31811
31918
|
onChange: handleChange,
|
|
31812
31919
|
onBlur: handleBlur,
|
|
@@ -31911,6 +32018,18 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
31911
32018
|
render(props) {
|
|
31912
32019
|
return /* @__PURE__ */ jsxRuntime.jsx(ScanInput, { ...props, field: this });
|
|
31913
32020
|
}
|
|
32021
|
+
isSerializedValueValid(value) {
|
|
32022
|
+
return typeof value === "string";
|
|
32023
|
+
}
|
|
32024
|
+
isValueValid(value) {
|
|
32025
|
+
return typeof value === "string";
|
|
32026
|
+
}
|
|
32027
|
+
blankValue() {
|
|
32028
|
+
return "";
|
|
32029
|
+
}
|
|
32030
|
+
areValuesEqual(value1, value2) {
|
|
32031
|
+
return value1 === value2;
|
|
32032
|
+
}
|
|
31914
32033
|
};
|
|
31915
32034
|
__publicField(_ScanField, "fieldTypeName", "Scan");
|
|
31916
32035
|
__publicField(_ScanField, "fieldTypeDescription", "Used for scanning/reading QR and barcodes.");
|
|
@@ -31924,15 +32043,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
31924
32043
|
const { name, onBlur, onChange, value } = fieldProps;
|
|
31925
32044
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
31926
32045
|
const computedLabel = showInputOnly ? "" : label;
|
|
31927
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
32046
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
31928
32047
|
React.useEffect(() => {
|
|
31929
32048
|
setInternalValue(value);
|
|
31930
32049
|
}, [value]);
|
|
31931
32050
|
const handleChange = React.useCallback(
|
|
31932
32051
|
(e) => {
|
|
31933
|
-
|
|
32052
|
+
const value2 = e.target.value;
|
|
32053
|
+
setInternalValue(value2);
|
|
31934
32054
|
if (touched || !field.onlyValidateAfterTouched) {
|
|
31935
|
-
helpers.setError(field.getError(
|
|
32055
|
+
helpers.setError(field.getError(value2));
|
|
31936
32056
|
}
|
|
31937
32057
|
},
|
|
31938
32058
|
[field, helpers, touched]
|
|
@@ -31956,7 +32076,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
31956
32076
|
id: inputId,
|
|
31957
32077
|
className: "truncate",
|
|
31958
32078
|
name,
|
|
31959
|
-
value: internalValue
|
|
32079
|
+
value: internalValue,
|
|
31960
32080
|
type: "text",
|
|
31961
32081
|
placeholder: field.placeholder,
|
|
31962
32082
|
onChange: handleChange,
|
|
@@ -32016,15 +32136,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32016
32136
|
const { name, onBlur, onChange, value } = fieldProps;
|
|
32017
32137
|
const computedHelpText = showInputOnly ? null : helpText;
|
|
32018
32138
|
const computedLabel = showInputOnly ? "" : label;
|
|
32019
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
32139
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
32020
32140
|
React.useEffect(() => {
|
|
32021
32141
|
setInternalValue(value);
|
|
32022
32142
|
}, [value]);
|
|
32023
32143
|
const handleChange = React.useCallback(
|
|
32024
32144
|
(e) => {
|
|
32025
|
-
|
|
32145
|
+
const value2 = e.target.value;
|
|
32146
|
+
setInternalValue(value2);
|
|
32026
32147
|
if (touched || !field.onlyValidateAfterTouched) {
|
|
32027
|
-
helpers.setError(field.getError(
|
|
32148
|
+
helpers.setError(field.getError(value2));
|
|
32028
32149
|
}
|
|
32029
32150
|
},
|
|
32030
32151
|
[field, helpers, touched]
|
|
@@ -32046,7 +32167,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32046
32167
|
blocks.TextArea,
|
|
32047
32168
|
{
|
|
32048
32169
|
id: inputId,
|
|
32049
|
-
value: internalValue
|
|
32170
|
+
value: internalValue,
|
|
32050
32171
|
name,
|
|
32051
32172
|
onChange: handleChange,
|
|
32052
32173
|
onBlur: handleBlur,
|
|
@@ -32154,11 +32275,25 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32154
32275
|
});
|
|
32155
32276
|
return formatter.format(sizeInUnit);
|
|
32156
32277
|
};
|
|
32278
|
+
function areFilesEqual(file1, file2) {
|
|
32279
|
+
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
32280
|
+
}
|
|
32281
|
+
function seprateFilesFromPromises(filesOrPromises) {
|
|
32282
|
+
const files = [];
|
|
32283
|
+
const promises = [];
|
|
32284
|
+
for (const fileOrPromise of filesOrPromises) {
|
|
32285
|
+
if (fileOrPromise instanceof Promise) {
|
|
32286
|
+
promises.push(fileOrPromise);
|
|
32287
|
+
} else {
|
|
32288
|
+
files.push(fileOrPromise);
|
|
32289
|
+
}
|
|
32290
|
+
}
|
|
32291
|
+
return [files, promises];
|
|
32292
|
+
}
|
|
32157
32293
|
const UploadInput = React.memo((props) => {
|
|
32158
32294
|
var _a2;
|
|
32159
32295
|
const [{ inputId, labelId, label, size, severity, helpText, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
|
|
32160
|
-
const { name, onChange, onBlur } = fieldProps;
|
|
32161
|
-
const value = fieldProps.value ?? EMPTY_ARRAY;
|
|
32296
|
+
const { value, name, onChange, onBlur } = fieldProps;
|
|
32162
32297
|
const input = React.useRef(null);
|
|
32163
32298
|
const updatedHelpText = React.useMemo(() => {
|
|
32164
32299
|
if (showInputOnly) return null;
|
|
@@ -32188,7 +32323,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32188
32323
|
(index) => {
|
|
32189
32324
|
const files = [...value];
|
|
32190
32325
|
files.splice(index, 1);
|
|
32191
|
-
onChange(files
|
|
32326
|
+
onChange(files);
|
|
32192
32327
|
},
|
|
32193
32328
|
[value, onChange]
|
|
32194
32329
|
);
|
|
@@ -32198,7 +32333,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32198
32333
|
input.current.addEventListener(
|
|
32199
32334
|
"cancel",
|
|
32200
32335
|
() => {
|
|
32201
|
-
onBlur(
|
|
32336
|
+
onBlur([...value]);
|
|
32202
32337
|
},
|
|
32203
32338
|
{
|
|
32204
32339
|
signal: abortController.signal
|
|
@@ -32357,21 +32492,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32357
32492
|
) : /* @__PURE__ */ jsxRuntime.jsx(FileCard, { file: resolvedFile, error: error ?? void 0, rightSlot: rightSlotContent });
|
|
32358
32493
|
});
|
|
32359
32494
|
DisplayFile.displayName = "DisplayFile";
|
|
32360
|
-
function areFilesEqual(file1, file2) {
|
|
32361
|
-
return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
|
|
32362
|
-
}
|
|
32363
|
-
function seprateFilesFromPromises(filesOrPromises) {
|
|
32364
|
-
const files = [];
|
|
32365
|
-
const promises = [];
|
|
32366
|
-
for (const fileOrPromise of filesOrPromises) {
|
|
32367
|
-
if (fileOrPromise instanceof Promise) {
|
|
32368
|
-
promises.push(fileOrPromise);
|
|
32369
|
-
} else {
|
|
32370
|
-
files.push(fileOrPromise);
|
|
32371
|
-
}
|
|
32372
|
-
}
|
|
32373
|
-
return [files, promises];
|
|
32374
|
-
}
|
|
32375
32495
|
const _UploadField = class _UploadField extends BaseField {
|
|
32376
32496
|
constructor(options2) {
|
|
32377
32497
|
const { extensions, maximum_files, maximum_size, ...base } = options2;
|
|
@@ -32385,20 +32505,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32385
32505
|
this.maxFiles = Math.max(typeof maximum_files === "number" ? maximum_files : 1, 1);
|
|
32386
32506
|
this.extensions = extensions;
|
|
32387
32507
|
}
|
|
32388
|
-
isBlank(value) {
|
|
32389
|
-
return super.isBlank(value) || (value == null ? void 0 : value.length) === 0;
|
|
32390
|
-
}
|
|
32391
|
-
isEqual(value1, value2) {
|
|
32392
|
-
if (value1 === void 0 && value2 === void 0) return true;
|
|
32393
|
-
if (value1 === void 0 || value2 === void 0) return false;
|
|
32394
|
-
const [files1, promises1] = seprateFilesFromPromises(value1);
|
|
32395
|
-
const [files2, promises2] = seprateFilesFromPromises(value2);
|
|
32396
|
-
if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
|
|
32397
|
-
if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
|
|
32398
|
-
if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
|
|
32399
|
-
if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
|
|
32400
|
-
return true;
|
|
32401
|
-
}
|
|
32402
32508
|
static getFieldCreationSchema(parentPath = "") {
|
|
32403
32509
|
const path = parentPath && `${parentPath}.`;
|
|
32404
32510
|
return [
|
|
@@ -32517,6 +32623,24 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32517
32623
|
render(props) {
|
|
32518
32624
|
return /* @__PURE__ */ jsxRuntime.jsx(UploadInput, { field: this, ...props });
|
|
32519
32625
|
}
|
|
32626
|
+
isSerializedValueValid(value) {
|
|
32627
|
+
return Array.isArray(value) && value.length === 0;
|
|
32628
|
+
}
|
|
32629
|
+
isValueValid(value) {
|
|
32630
|
+
return isFilePromiseArray(value);
|
|
32631
|
+
}
|
|
32632
|
+
areValuesEqual(value1, value2) {
|
|
32633
|
+
const [files1, promises1] = seprateFilesFromPromises(value1);
|
|
32634
|
+
const [files2, promises2] = seprateFilesFromPromises(value2);
|
|
32635
|
+
if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
|
|
32636
|
+
if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
|
|
32637
|
+
if (!promises1.every((promise1) => promises2.some((promise2) => promise1 === promise2))) return false;
|
|
32638
|
+
if (!promises2.every((promise2) => promises1.some((promise1) => promise1 === promise2))) return false;
|
|
32639
|
+
return true;
|
|
32640
|
+
}
|
|
32641
|
+
blankValue() {
|
|
32642
|
+
return [];
|
|
32643
|
+
}
|
|
32520
32644
|
};
|
|
32521
32645
|
__publicField(_UploadField, "fieldTypeName", "Upload");
|
|
32522
32646
|
__publicField(_UploadField, "fieldTypeDescription", "Allows a file to be uploaded.");
|
|
@@ -32555,60 +32679,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32555
32679
|
const maxFileSizeMB = 50;
|
|
32556
32680
|
const maxFileSizeKB = maxFileSizeMB * 1e3;
|
|
32557
32681
|
const maxFileSizeB = maxFileSizeKB * 1e3;
|
|
32558
|
-
class BaseCondition extends Observable {
|
|
32559
|
-
constructor(config) {
|
|
32560
|
-
const { id, field, conditionValue, conditionModifier } = config;
|
|
32561
|
-
super();
|
|
32562
|
-
__publicField(this, "id");
|
|
32563
|
-
__publicField(this, "conditionValue");
|
|
32564
|
-
__publicField(this, "conditionModifier");
|
|
32565
|
-
__publicField(this, "field");
|
|
32566
|
-
__publicField(this, "getConditionValue", () => {
|
|
32567
|
-
return this.conditionValue;
|
|
32568
|
-
});
|
|
32569
|
-
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
32570
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32571
|
-
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
32572
|
-
this.conditionValue = conditionValue;
|
|
32573
|
-
this.notify(this);
|
|
32574
|
-
});
|
|
32575
|
-
__publicField(this, "getConditionModifier", () => {
|
|
32576
|
-
return this.conditionModifier;
|
|
32577
|
-
});
|
|
32578
|
-
__publicField(this, "setConditionModifier", (modifier) => {
|
|
32579
|
-
const foundModifier = this.modifiers[modifier];
|
|
32580
|
-
const filterValue = this.getConditionValue();
|
|
32581
|
-
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
32582
|
-
this.conditionValue = void 0;
|
|
32583
|
-
}
|
|
32584
|
-
this.conditionModifier = modifier;
|
|
32585
|
-
this.notify(this);
|
|
32586
|
-
});
|
|
32587
|
-
__publicField(this, "getConditionModifiers", () => {
|
|
32588
|
-
return Object.entries(this.modifiers);
|
|
32589
|
-
});
|
|
32590
|
-
__publicField(this, "apply", (value) => {
|
|
32591
|
-
const modifier = this.modifiers[this.conditionModifier];
|
|
32592
|
-
const conditionValue = this.getConditionValue();
|
|
32593
|
-
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
32594
|
-
if (!modifier.isValueValid(value)) return false;
|
|
32595
|
-
return modifier.modifier.modifierFn(value, conditionValue);
|
|
32596
|
-
});
|
|
32597
|
-
this.id = id;
|
|
32598
|
-
this.field = field;
|
|
32599
|
-
this.conditionValue = conditionValue;
|
|
32600
|
-
this.conditionModifier = conditionModifier;
|
|
32601
|
-
}
|
|
32602
|
-
serialize() {
|
|
32603
|
-
return {
|
|
32604
|
-
id: this.id,
|
|
32605
|
-
type: this.field.type,
|
|
32606
|
-
fieldId: this.field.identifier,
|
|
32607
|
-
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
32608
|
-
conditionModifier: this.conditionModifier
|
|
32609
|
-
};
|
|
32610
|
-
}
|
|
32611
|
-
}
|
|
32612
32682
|
class ConditionModifier {
|
|
32613
32683
|
constructor(config) {
|
|
32614
32684
|
__publicField(this, "id");
|
|
@@ -32915,6 +32985,60 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
32915
32985
|
deserialize: (filterValue) => filterValue
|
|
32916
32986
|
});
|
|
32917
32987
|
const createConditionModifierConfig = (conifg) => conifg;
|
|
32988
|
+
class BaseCondition extends Observable {
|
|
32989
|
+
constructor(config) {
|
|
32990
|
+
const { id, field, conditionValue, conditionModifier } = config;
|
|
32991
|
+
super();
|
|
32992
|
+
__publicField(this, "id");
|
|
32993
|
+
__publicField(this, "conditionValue");
|
|
32994
|
+
__publicField(this, "conditionModifier");
|
|
32995
|
+
__publicField(this, "field");
|
|
32996
|
+
__publicField(this, "getConditionValue", () => {
|
|
32997
|
+
return this.conditionValue;
|
|
32998
|
+
});
|
|
32999
|
+
__publicField(this, "setConditionValue", (conditionValue) => {
|
|
33000
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
33001
|
+
if (conditionValue !== void 0 && !modifier.isConditionValueValid(conditionValue)) return;
|
|
33002
|
+
this.conditionValue = conditionValue;
|
|
33003
|
+
this.notify(this);
|
|
33004
|
+
});
|
|
33005
|
+
__publicField(this, "getConditionModifier", () => {
|
|
33006
|
+
return this.conditionModifier;
|
|
33007
|
+
});
|
|
33008
|
+
__publicField(this, "setConditionModifier", (modifier) => {
|
|
33009
|
+
const foundModifier = this.modifiers[modifier];
|
|
33010
|
+
const filterValue = this.getConditionValue();
|
|
33011
|
+
if (filterValue && !foundModifier.isConditionValueValid(filterValue)) {
|
|
33012
|
+
this.conditionValue = void 0;
|
|
33013
|
+
}
|
|
33014
|
+
this.conditionModifier = modifier;
|
|
33015
|
+
this.notify(this);
|
|
33016
|
+
});
|
|
33017
|
+
__publicField(this, "getConditionModifiers", () => {
|
|
33018
|
+
return Object.entries(this.modifiers);
|
|
33019
|
+
});
|
|
33020
|
+
__publicField(this, "apply", (value) => {
|
|
33021
|
+
const modifier = this.modifiers[this.conditionModifier];
|
|
33022
|
+
const conditionValue = this.getConditionValue();
|
|
33023
|
+
if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
|
|
33024
|
+
if (!modifier.isValueValid(value)) return false;
|
|
33025
|
+
return modifier.modifier.modifierFn(value, conditionValue);
|
|
33026
|
+
});
|
|
33027
|
+
this.id = id;
|
|
33028
|
+
this.field = field;
|
|
33029
|
+
this.conditionValue = conditionValue;
|
|
33030
|
+
this.conditionModifier = conditionModifier;
|
|
33031
|
+
}
|
|
33032
|
+
serialize() {
|
|
33033
|
+
return {
|
|
33034
|
+
id: this.id,
|
|
33035
|
+
type: this.field.type,
|
|
33036
|
+
fieldId: this.field.identifier,
|
|
33037
|
+
conditionValue: this.modifiers[this.conditionModifier].modifier.serialize(this.conditionValue),
|
|
33038
|
+
conditionModifier: this.conditionModifier
|
|
33039
|
+
};
|
|
33040
|
+
}
|
|
33041
|
+
}
|
|
32918
33042
|
const formId = "form-builder";
|
|
32919
33043
|
const UNLABELLED_FIELD_LABEL = "Unlabelled";
|
|
32920
33044
|
const UNLABELLED_SECTION_LABEL = "Unlabelled";
|
|
@@ -33655,19 +33779,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
33655
33779
|
const modifiers$7 = {
|
|
33656
33780
|
equals: createConditionModifierConfig({
|
|
33657
33781
|
modifier: NumberEqualsConditionModifier,
|
|
33658
|
-
isValueValid: (
|
|
33782
|
+
isValueValid: (value) => typeof value === "number",
|
|
33659
33783
|
isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
|
|
33660
33784
|
isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
|
|
33661
33785
|
}),
|
|
33662
33786
|
notEquals: createConditionModifierConfig({
|
|
33663
33787
|
modifier: NumberNotEqualsConditionModifier,
|
|
33664
|
-
isValueValid: (
|
|
33788
|
+
isValueValid: (value) => typeof value === "number",
|
|
33665
33789
|
isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
|
|
33666
33790
|
isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
|
|
33667
33791
|
}),
|
|
33668
33792
|
lessThan: createConditionModifierConfig({
|
|
33669
33793
|
modifier: NumberLessThanConditionModifier,
|
|
33670
|
-
isValueValid: (
|
|
33794
|
+
isValueValid: (value) => typeof value === "number",
|
|
33671
33795
|
isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
|
|
33672
33796
|
isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
|
|
33673
33797
|
}),
|
|
@@ -33878,25 +34002,25 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
33878
34002
|
const modifiers$5 = {
|
|
33879
34003
|
equals: createConditionModifierConfig({
|
|
33880
34004
|
modifier: StringEqualsConditionModifier,
|
|
33881
|
-
isValueValid: (
|
|
34005
|
+
isValueValid: (value) => typeof value === "string",
|
|
33882
34006
|
isConditionValueValid: (conditionValue) => !Array.isArray(conditionValue),
|
|
33883
34007
|
isSerializedValueValid: (serializedConditionValue) => !Array.isArray(serializedConditionValue)
|
|
33884
34008
|
}),
|
|
33885
34009
|
notEquals: createConditionModifierConfig({
|
|
33886
34010
|
modifier: StringNotEqualsConditionModifier,
|
|
33887
|
-
isValueValid: (
|
|
34011
|
+
isValueValid: (value) => typeof value === "string",
|
|
33888
34012
|
isConditionValueValid: (conditionValue) => !Array.isArray(conditionValue),
|
|
33889
34013
|
isSerializedValueValid: (serializedConditionValue) => !Array.isArray(serializedConditionValue)
|
|
33890
34014
|
}),
|
|
33891
34015
|
includes: createConditionModifierConfig({
|
|
33892
34016
|
modifier: StringArrayIncludesConditionModifier,
|
|
33893
|
-
isValueValid: (
|
|
34017
|
+
isValueValid: (value) => typeof value === "string",
|
|
33894
34018
|
isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
|
|
33895
34019
|
isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
|
|
33896
34020
|
}),
|
|
33897
34021
|
excludes: createConditionModifierConfig({
|
|
33898
34022
|
modifier: StringArrayExcludesConditionModifier,
|
|
33899
|
-
isValueValid: (
|
|
34023
|
+
isValueValid: (value) => typeof value === "string",
|
|
33900
34024
|
isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
|
|
33901
34025
|
isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
|
|
33902
34026
|
})
|
|
@@ -34077,25 +34201,25 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34077
34201
|
const modifiers$3 = {
|
|
34078
34202
|
equals: createConditionModifierConfig({
|
|
34079
34203
|
modifier: StringEqualsConditionModifier,
|
|
34080
|
-
isValueValid: (
|
|
34204
|
+
isValueValid: (value) => typeof value === "string",
|
|
34081
34205
|
isConditionValueValid: (conditionValue) => !Array.isArray(conditionValue),
|
|
34082
34206
|
isSerializedValueValid: (serializedConditionValue) => !Array.isArray(serializedConditionValue)
|
|
34083
34207
|
}),
|
|
34084
34208
|
notEquals: createConditionModifierConfig({
|
|
34085
34209
|
modifier: StringNotEqualsConditionModifier,
|
|
34086
|
-
isValueValid: (
|
|
34210
|
+
isValueValid: (value) => typeof value === "string",
|
|
34087
34211
|
isConditionValueValid: (conditionValue) => !Array.isArray(conditionValue),
|
|
34088
34212
|
isSerializedValueValid: (serializedConditionValue) => !Array.isArray(serializedConditionValue)
|
|
34089
34213
|
}),
|
|
34090
34214
|
includes: createConditionModifierConfig({
|
|
34091
34215
|
modifier: StringArrayIncludesConditionModifier,
|
|
34092
|
-
isValueValid: (
|
|
34216
|
+
isValueValid: (value) => typeof value === "string",
|
|
34093
34217
|
isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
|
|
34094
34218
|
isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
|
|
34095
34219
|
}),
|
|
34096
34220
|
excludes: createConditionModifierConfig({
|
|
34097
34221
|
modifier: StringArrayExcludesConditionModifier,
|
|
34098
|
-
isValueValid: (
|
|
34222
|
+
isValueValid: (value) => typeof value === "string",
|
|
34099
34223
|
isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
|
|
34100
34224
|
isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
|
|
34101
34225
|
})
|
|
@@ -34418,15 +34542,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34418
34542
|
return OTPField.deserialize(serializedField);
|
|
34419
34543
|
}
|
|
34420
34544
|
};
|
|
34545
|
+
function deserializeFields(fields) {
|
|
34546
|
+
return fields.map(deserialize);
|
|
34547
|
+
}
|
|
34421
34548
|
const deserialize = (serialized) => {
|
|
34422
34549
|
if (serialized.type === "section") {
|
|
34423
34550
|
return FieldSection.deserialize(serialized);
|
|
34424
34551
|
}
|
|
34425
34552
|
return deserializeField(serialized);
|
|
34426
34553
|
};
|
|
34427
|
-
function deserializeFields(fields) {
|
|
34428
|
-
return fields.map(deserialize);
|
|
34429
|
-
}
|
|
34430
34554
|
function deserializeOnlyFields(fields) {
|
|
34431
34555
|
return fields.map(deserializeField);
|
|
34432
34556
|
}
|
|
@@ -34452,33 +34576,44 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34452
34576
|
return result;
|
|
34453
34577
|
}
|
|
34454
34578
|
function serializeFieldValues(fields, values) {
|
|
34579
|
+
const cleanValues = cleanFieldValues(fields, values);
|
|
34455
34580
|
const ret = {};
|
|
34456
34581
|
for (const field of fields) {
|
|
34457
|
-
const value =
|
|
34582
|
+
const value = cleanValues[field.identifier];
|
|
34583
|
+
if (!field.isValueValid(value)) continue;
|
|
34458
34584
|
ret[field.identifier] = field.serializeValue(value);
|
|
34459
34585
|
}
|
|
34460
34586
|
return ret;
|
|
34461
34587
|
}
|
|
34462
34588
|
function deserializeFieldValues(fields, values) {
|
|
34589
|
+
const cleanValues = cleanSerializedFieldValues(fields, values);
|
|
34463
34590
|
const ret = {};
|
|
34464
34591
|
for (const field of fields) {
|
|
34465
|
-
const value =
|
|
34592
|
+
const value = cleanValues[field.identifier];
|
|
34593
|
+
if (!field.isSerializedValueValid(value)) continue;
|
|
34466
34594
|
ret[field.identifier] = field.deserializeValue(value);
|
|
34467
34595
|
}
|
|
34468
34596
|
return ret;
|
|
34469
34597
|
}
|
|
34598
|
+
function cleanFieldValues(fields, values) {
|
|
34599
|
+
const ret = {};
|
|
34600
|
+
for (const field of fields) {
|
|
34601
|
+
const value = values[field.identifier];
|
|
34602
|
+
if (!field.isSerializedValueValid(value)) continue;
|
|
34603
|
+
ret[field.identifier] = value;
|
|
34604
|
+
}
|
|
34605
|
+
return ret;
|
|
34606
|
+
}
|
|
34607
|
+
function cleanSerializedFieldValues(fields, values) {
|
|
34608
|
+
const ret = {};
|
|
34609
|
+
for (const field of fields) {
|
|
34610
|
+
const value = values[field.identifier];
|
|
34611
|
+
if (!field.isSerializedValueValid(value)) continue;
|
|
34612
|
+
ret[field.identifier] = value;
|
|
34613
|
+
}
|
|
34614
|
+
return ret;
|
|
34615
|
+
}
|
|
34470
34616
|
const RendererContext = React.createContext({});
|
|
34471
|
-
const useFieldInput = (field, props) => {
|
|
34472
|
-
return React.useMemo(() => {
|
|
34473
|
-
if (!props || !field) return null;
|
|
34474
|
-
return field.render(props);
|
|
34475
|
-
}, [field, props]);
|
|
34476
|
-
};
|
|
34477
|
-
const useFieldInputs = (fields, props) => {
|
|
34478
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: fields.map((field) => {
|
|
34479
|
-
return /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: field.render(props) }, field.identifier);
|
|
34480
|
-
}) });
|
|
34481
|
-
};
|
|
34482
34617
|
const FieldSectionLayout = React.memo((props) => {
|
|
34483
34618
|
const { fieldSection: section, ...rest } = props;
|
|
34484
34619
|
const { label, description } = section;
|
|
@@ -34585,13 +34720,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34585
34720
|
this.conditions = conditions || this.conditions;
|
|
34586
34721
|
super.setOptions(base);
|
|
34587
34722
|
}
|
|
34588
|
-
getErrors(
|
|
34723
|
+
getErrors(values) {
|
|
34589
34724
|
const errors = {};
|
|
34590
34725
|
for (const field of this.fields) {
|
|
34591
|
-
const
|
|
34592
|
-
const error = field.getError(get(allValues, id));
|
|
34726
|
+
const error = field.getError(values[field.identifier]);
|
|
34593
34727
|
if (error) {
|
|
34594
|
-
|
|
34728
|
+
errors[field.identifier] = error;
|
|
34595
34729
|
}
|
|
34596
34730
|
}
|
|
34597
34731
|
return errors;
|
|
@@ -34746,124 +34880,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
34746
34880
|
}
|
|
34747
34881
|
const FieldSchemaContext = React.createContext(new FieldSchema([]));
|
|
34748
34882
|
const FormBuilderContext = React.createContext({});
|
|
34749
|
-
const hasKeys = (errors) => {
|
|
34750
|
-
return Object.keys(errors).length > 0;
|
|
34751
|
-
};
|
|
34752
|
-
const validateFields = (fields, values) => {
|
|
34753
|
-
const errors = {};
|
|
34754
|
-
const sectionElements = fields.filter((f) => f instanceof FieldSection);
|
|
34755
|
-
for (const field of fields) {
|
|
34756
|
-
if (field instanceof FieldSection) {
|
|
34757
|
-
const conditionalSections = sectionElements.filter((section) => field.identifier in section.conditions);
|
|
34758
|
-
const conditionMet = conditionalSections.length > 0 ? conditionalSections.some(
|
|
34759
|
-
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier), values)
|
|
34760
|
-
) : true;
|
|
34761
|
-
if (!conditionMet) continue;
|
|
34762
|
-
Object.assign(errors, field.getErrors(values));
|
|
34763
|
-
} else {
|
|
34764
|
-
if (!(field instanceof BaseField)) {
|
|
34765
|
-
throw new Error("Invalid field type");
|
|
34766
|
-
}
|
|
34767
|
-
const id = field.identifier;
|
|
34768
|
-
const error = field.getError(get(values, id));
|
|
34769
|
-
if (error) set(errors, id, error);
|
|
34770
|
-
}
|
|
34771
|
-
}
|
|
34772
|
-
if (hasKeys(errors)) return errors;
|
|
34773
|
-
};
|
|
34774
|
-
const initializeFieldValues = (fields, values) => {
|
|
34775
|
-
return fields.reduce((acc, field) => {
|
|
34776
|
-
if (field instanceof FieldSection) {
|
|
34777
|
-
return { ...acc, ...initializeFieldValues(field.fields, values) };
|
|
34778
|
-
}
|
|
34779
|
-
const identifier = field.identifier;
|
|
34780
|
-
const value = acc[identifier];
|
|
34781
|
-
switch (value) {
|
|
34782
|
-
case "":
|
|
34783
|
-
acc[identifier] = void 0;
|
|
34784
|
-
break;
|
|
34785
|
-
case []:
|
|
34786
|
-
acc[identifier] = void 0;
|
|
34787
|
-
break;
|
|
34788
|
-
default:
|
|
34789
|
-
acc[identifier] = value ?? void 0;
|
|
34790
|
-
}
|
|
34791
|
-
return acc;
|
|
34792
|
-
}, values);
|
|
34793
|
-
};
|
|
34794
|
-
const changedFieldValues = (fields, values1, values2) => {
|
|
34795
|
-
return fields.reduce((acc, field) => {
|
|
34796
|
-
if (field instanceof FieldSection) {
|
|
34797
|
-
return { ...acc, ...changedFieldValues(field.fields, values1, values2) };
|
|
34798
|
-
}
|
|
34799
|
-
if (field instanceof BaseField) {
|
|
34800
|
-
const identifier = field.identifier;
|
|
34801
|
-
const value1 = values1[identifier];
|
|
34802
|
-
const value2 = values2[identifier];
|
|
34803
|
-
if (!field.isEqual(value1, value2)) {
|
|
34804
|
-
acc[identifier] = value2;
|
|
34805
|
-
}
|
|
34806
|
-
}
|
|
34807
|
-
return acc;
|
|
34808
|
-
}, {});
|
|
34809
|
-
};
|
|
34810
|
-
const isArrayOfFiles = (value) => {
|
|
34811
|
-
return Array.isArray(value) && value[0] instanceof File;
|
|
34812
|
-
};
|
|
34813
|
-
const separateFilesFromFieldValues = (values) => {
|
|
34814
|
-
const files = {};
|
|
34815
|
-
const newValues = {};
|
|
34816
|
-
for (const key in values) {
|
|
34817
|
-
const value = values[key];
|
|
34818
|
-
if (value instanceof File) {
|
|
34819
|
-
files[key] = [value];
|
|
34820
|
-
} else if (isArrayOfFiles(value)) {
|
|
34821
|
-
files[key] = value;
|
|
34822
|
-
} else if (value !== void 0) {
|
|
34823
|
-
newValues[key] = value;
|
|
34824
|
-
}
|
|
34825
|
-
}
|
|
34826
|
-
return { values: newValues, files };
|
|
34827
|
-
};
|
|
34828
|
-
const separateFilesFromFields = async (fields) => {
|
|
34829
|
-
const images = {};
|
|
34830
|
-
const newFields = [];
|
|
34831
|
-
for (const section of fields) {
|
|
34832
|
-
if (section.type !== "section") {
|
|
34833
|
-
throw new Error(`Expected ISerializedField type to be a section. Got ${section.type} instead.`);
|
|
34834
|
-
}
|
|
34835
|
-
const { fields: sectionFields } = section;
|
|
34836
|
-
const newSectionFields = [];
|
|
34837
|
-
for (const field of sectionFields) {
|
|
34838
|
-
if (field.image) {
|
|
34839
|
-
if (field.image instanceof Promise) {
|
|
34840
|
-
try {
|
|
34841
|
-
images[field.identifier] = await field.image;
|
|
34842
|
-
} catch (e) {
|
|
34843
|
-
console.error("Failed to get image from promise", e);
|
|
34844
|
-
}
|
|
34845
|
-
} else {
|
|
34846
|
-
images[field.identifier] = field.image;
|
|
34847
|
-
}
|
|
34848
|
-
delete field.image;
|
|
34849
|
-
}
|
|
34850
|
-
newSectionFields.push(field);
|
|
34851
|
-
}
|
|
34852
|
-
newFields.push({ ...section, fields: newSectionFields });
|
|
34853
|
-
}
|
|
34854
|
-
return { fields: newFields, images };
|
|
34855
|
-
};
|
|
34856
|
-
async function awaitPromisesFromFieldValues(values) {
|
|
34857
|
-
const valuesWithoutFiles = {};
|
|
34858
|
-
for (const [key, value] of Object.entries(values)) {
|
|
34859
|
-
if (Array.isArray(value) && value.every((item) => item instanceof Promise)) {
|
|
34860
|
-
valuesWithoutFiles[key] = await Promise.all(value);
|
|
34861
|
-
} else {
|
|
34862
|
-
valuesWithoutFiles[key] = value;
|
|
34863
|
-
}
|
|
34864
|
-
}
|
|
34865
|
-
return valuesWithoutFiles;
|
|
34866
|
-
}
|
|
34867
34883
|
const createField = (type) => {
|
|
34868
34884
|
switch (type) {
|
|
34869
34885
|
case "text":
|
|
@@ -35136,7 +35152,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35136
35152
|
const showPopoverInputs = popoverFields.length > 0;
|
|
35137
35153
|
const popoverHasErrors = popoverFields.some((field2) => {
|
|
35138
35154
|
const error = get(errors, field2.identifier);
|
|
35139
|
-
return error && (typeof error !== "object" ||
|
|
35155
|
+
return error && (typeof error !== "object" || Object.values(error).length > 0);
|
|
35140
35156
|
});
|
|
35141
35157
|
const previewInput = useFieldInput(field, { formId, showInputOnly: false });
|
|
35142
35158
|
const handleFieldImageClick = React.useCallback(() => {
|
|
@@ -35240,45 +35256,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35240
35256
|
] });
|
|
35241
35257
|
});
|
|
35242
35258
|
FieldDropdownMenu.displayName = "IssueDataFilterMenu";
|
|
35243
|
-
const FieldSectionConditionalItem = React.memo((props) => {
|
|
35244
|
-
const { sourceFieldSection, targetFieldSection } = props;
|
|
35245
|
-
const conditions = React.useMemo(() => {
|
|
35246
|
-
return sourceFieldSection.getConditions(targetFieldSection.identifier);
|
|
35247
|
-
}, [sourceFieldSection, targetFieldSection.identifier]);
|
|
35248
|
-
const handleDelete = React.useCallback(() => {
|
|
35249
|
-
sourceFieldSection.removeConditional(targetFieldSection.identifier);
|
|
35250
|
-
}, [sourceFieldSection, targetFieldSection.identifier]);
|
|
35251
|
-
const handleSelectField = React.useCallback(
|
|
35252
|
-
(field) => {
|
|
35253
|
-
sourceFieldSection.addCondition(targetFieldSection.identifier, createCondition(field));
|
|
35254
|
-
},
|
|
35255
|
-
[sourceFieldSection, targetFieldSection.identifier]
|
|
35256
|
-
);
|
|
35257
|
-
const handleDeleteCondition = React.useCallback(
|
|
35258
|
-
(condition) => {
|
|
35259
|
-
sourceFieldSection.removeCondition(targetFieldSection.identifier, condition);
|
|
35260
|
-
},
|
|
35261
|
-
[sourceFieldSection, targetFieldSection.identifier]
|
|
35262
|
-
);
|
|
35263
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { className: "flex flex-col gap-2", children: [
|
|
35264
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "justify-between gap-2 flex", size: "sm", accentColor: "base", variant: "soft", children: [
|
|
35265
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { accentColor: "base", variant: "soft", size: "sm", children: [
|
|
35266
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons.section }),
|
|
35267
|
-
sourceFieldSection.label ?? UNLABELLED_SECTION_LABEL
|
|
35268
|
-
] }),
|
|
35269
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDelete, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
|
|
35270
|
-
] }),
|
|
35271
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-max w-full flex-wrap gap-2", children: [
|
|
35272
|
-
conditions.map((condition) => {
|
|
35273
|
-
return condition.render({
|
|
35274
|
-
onRemove: handleDeleteCondition
|
|
35275
|
-
});
|
|
35276
|
-
}),
|
|
35277
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldDropdownMenu, { fields: sourceFieldSection.fields, onSelectField: handleSelectField, align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", size: "sm", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }) }) })
|
|
35278
|
-
] })
|
|
35279
|
-
] });
|
|
35280
|
-
});
|
|
35281
|
-
FieldSectionConditionalItem.displayName = "FieldSectionConditionalItem";
|
|
35282
35259
|
const FieldSectionDropdownMenu = React.memo((props) => {
|
|
35283
35260
|
const { children, variant, size, accentColor, fieldSections, onSelectFieldCondition, ...rest } = props;
|
|
35284
35261
|
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
|
|
@@ -35292,169 +35269,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35292
35269
|
] });
|
|
35293
35270
|
});
|
|
35294
35271
|
FieldSectionDropdownMenu.displayName = "IssueDataFilterMenu";
|
|
35295
|
-
const FieldSectionBuilder = React.memo((props) => {
|
|
35296
|
-
const { fieldSection } = props;
|
|
35297
|
-
const fieldSchema = React.use(FieldSchemaContext);
|
|
35298
|
-
const conditionalSections = React.useMemo(() => {
|
|
35299
|
-
return fieldSchema.fields.filter((section) => fieldSection.identifier in section.conditions);
|
|
35300
|
-
}, [fieldSchema.fields, fieldSection.identifier]);
|
|
35301
|
-
const handleAddConditional = React.useCallback(
|
|
35302
|
-
(conditionalSection) => {
|
|
35303
|
-
conditionalSection.addConditional(fieldSection.identifier);
|
|
35304
|
-
},
|
|
35305
|
-
[fieldSection.identifier]
|
|
35306
|
-
);
|
|
35307
|
-
const validFieldSections = React.useMemo(() => {
|
|
35308
|
-
const graph = new graphology.DirectedGraph({});
|
|
35309
|
-
for (const sourceSection of fieldSchema.fields) {
|
|
35310
|
-
for (const targetSectionId of Object.keys(sourceSection.conditions)) {
|
|
35311
|
-
graph.mergeEdge(sourceSection.identifier, targetSectionId);
|
|
35312
|
-
}
|
|
35313
|
-
}
|
|
35314
|
-
return fieldSchema.fields.filter(
|
|
35315
|
-
(sourceSection) => !graphologyDag.willCreateCycle(graph, sourceSection.identifier, fieldSection.identifier)
|
|
35316
|
-
);
|
|
35317
|
-
}, [fieldSchema.fields, fieldSection.identifier]);
|
|
35318
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow w-full flex-col gap-4", children: [
|
|
35319
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full overflow-hidden", children: [
|
|
35320
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Input.Root, { variant: "outline", size: "md", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35321
|
-
blocks.Input.Field,
|
|
35322
|
-
{
|
|
35323
|
-
placeholder: "Enter a section label (optional)",
|
|
35324
|
-
value: fieldSection.label ?? "",
|
|
35325
|
-
onChange: (event) => fieldSection.setOptions({ label: event.target.value }),
|
|
35326
|
-
maxLength: 200
|
|
35327
|
-
}
|
|
35328
|
-
) }),
|
|
35329
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35330
|
-
blocks.TextArea,
|
|
35331
|
-
{
|
|
35332
|
-
className: "field-sizing-content",
|
|
35333
|
-
placeholder: "Enter a section description (optional)",
|
|
35334
|
-
value: fieldSection.description ?? "",
|
|
35335
|
-
onChange: (event) => fieldSection.setOptions({ description: event.target.value }),
|
|
35336
|
-
maxLength: 1e3,
|
|
35337
|
-
resize: "vertical",
|
|
35338
|
-
size: "md"
|
|
35339
|
-
}
|
|
35340
|
-
)
|
|
35341
|
-
] }),
|
|
35342
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "full" }),
|
|
35343
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
35344
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
35345
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", children: "Conditions" }),
|
|
35346
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35347
|
-
FieldSectionDropdownMenu,
|
|
35348
|
-
{
|
|
35349
|
-
fieldSections: validFieldSections,
|
|
35350
|
-
onSelectFieldCondition: handleAddConditional,
|
|
35351
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", className: "w-max", children: [
|
|
35352
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35353
|
-
"Add condition"
|
|
35354
|
-
] })
|
|
35355
|
-
}
|
|
35356
|
-
)
|
|
35357
|
-
] }),
|
|
35358
|
-
conditionalSections.map((section) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35359
|
-
FieldSectionConditionalItem,
|
|
35360
|
-
{
|
|
35361
|
-
sourceFieldSection: section,
|
|
35362
|
-
targetFieldSection: fieldSection
|
|
35363
|
-
},
|
|
35364
|
-
section.identifier
|
|
35365
|
-
))
|
|
35366
|
-
] }),
|
|
35367
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "full" })
|
|
35368
|
-
] });
|
|
35369
|
-
});
|
|
35370
|
-
FieldSectionBuilder.displayName = "FieldSectionBuilder";
|
|
35371
|
-
const useFieldTypeItems = (onSelect = () => null) => {
|
|
35372
|
-
return React.useMemo(() => {
|
|
35373
|
-
const entries = Object.entries(FieldTypeToClsMapping);
|
|
35374
|
-
return entries.map(([type, fieldClass]) => ({
|
|
35375
|
-
children: fieldClass.fieldTypeName,
|
|
35376
|
-
icon: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[type] }),
|
|
35377
|
-
value: type,
|
|
35378
|
-
onSelect: () => {
|
|
35379
|
-
onSelect(type);
|
|
35380
|
-
}
|
|
35381
|
-
}));
|
|
35382
|
-
}, [onSelect]);
|
|
35383
|
-
};
|
|
35384
|
-
const FieldSectionWithActions = React.memo((props) => {
|
|
35385
|
-
const { fieldSection, index: sectionIndex } = props;
|
|
35386
|
-
const fieldSchema = React.use(FieldSchemaContext);
|
|
35387
|
-
const removeField = React.useCallback(
|
|
35388
|
-
(field) => {
|
|
35389
|
-
fieldSection.removeField(field);
|
|
35390
|
-
},
|
|
35391
|
-
[fieldSection]
|
|
35392
|
-
);
|
|
35393
|
-
const removeSection = React.useCallback(() => {
|
|
35394
|
-
fieldSchema.removeField(fieldSection);
|
|
35395
|
-
}, [fieldSchema, fieldSection]);
|
|
35396
|
-
const moveSection = React.useCallback(
|
|
35397
|
-
(direction) => {
|
|
35398
|
-
const targetIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
|
|
35399
|
-
fieldSchema.moveField(sectionIndex, targetIndex);
|
|
35400
|
-
},
|
|
35401
|
-
[fieldSchema, sectionIndex]
|
|
35402
|
-
);
|
|
35403
|
-
const duplicateSection = React.useCallback(() => {
|
|
35404
|
-
fieldSchema.addField(fieldSection.duplicate(uuid.v4()));
|
|
35405
|
-
}, [fieldSchema, fieldSection]);
|
|
35406
|
-
const handleCreateField = React.useCallback(
|
|
35407
|
-
(type) => {
|
|
35408
|
-
fieldSection.addField(createField(type));
|
|
35409
|
-
},
|
|
35410
|
-
[fieldSection]
|
|
35411
|
-
);
|
|
35412
|
-
const handleMoveUp = React.useCallback(() => {
|
|
35413
|
-
moveSection("up");
|
|
35414
|
-
}, [moveSection]);
|
|
35415
|
-
const handleMoveDown = React.useCallback(() => {
|
|
35416
|
-
moveSection("down");
|
|
35417
|
-
}, [moveSection]);
|
|
35418
|
-
const fieldTypeItems = useFieldTypeItems(handleCreateField);
|
|
35419
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { variant: "outline", className: "flex items-center justify-between gap-4 w-full", children: [
|
|
35420
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow flex-col gap-4 w-full", children: [
|
|
35421
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldSectionBuilder, { fieldSection }),
|
|
35422
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full", children: [
|
|
35423
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
35424
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", size: "md", children: "Fields" }),
|
|
35425
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
|
|
35426
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", children: [
|
|
35427
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35428
|
-
" Add field"
|
|
35429
|
-
] }) }),
|
|
35430
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fieldTypeItems.flat().map((item) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: item.onSelect, children: [
|
|
35431
|
-
item.icon,
|
|
35432
|
-
item.children
|
|
35433
|
-
] }, item.value)) }) })
|
|
35434
|
-
] })
|
|
35435
|
-
] }),
|
|
35436
|
-
fieldSection.fields.map((child, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35437
|
-
FieldWithActions,
|
|
35438
|
-
{
|
|
35439
|
-
field: child,
|
|
35440
|
-
fieldSection,
|
|
35441
|
-
index,
|
|
35442
|
-
sectionIndex,
|
|
35443
|
-
remove: removeField
|
|
35444
|
-
},
|
|
35445
|
-
child.identifier
|
|
35446
|
-
))
|
|
35447
|
-
] })
|
|
35448
|
-
] }),
|
|
35449
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex-col gap-0.5 flex", variant: "ghost", accentColor: "base", size: "sm", children: [
|
|
35450
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-up" }) }),
|
|
35451
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-down" }) }),
|
|
35452
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }),
|
|
35453
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: removeSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
|
|
35454
|
-
] })
|
|
35455
|
-
] });
|
|
35456
|
-
});
|
|
35457
|
-
FieldSectionWithActions.displayName = "FieldSectionWithActions";
|
|
35458
35272
|
const FieldWithActions = React.memo((props) => {
|
|
35459
35273
|
const { field, fieldSection, index, sectionIndex, remove } = props;
|
|
35460
35274
|
const { showError } = blocks.useToast();
|
|
@@ -35596,6 +35410,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35596
35410
|
] });
|
|
35597
35411
|
});
|
|
35598
35412
|
FieldSectionConditionEdgeComponent.displayName = "FieldSectionConditionEdgeComponent";
|
|
35413
|
+
const useFieldTypeItems = (onSelect = () => null) => {
|
|
35414
|
+
return React.useMemo(() => {
|
|
35415
|
+
const entries = Object.entries(FieldTypeToClsMapping);
|
|
35416
|
+
return entries.map(([type, fieldClass]) => ({
|
|
35417
|
+
children: fieldClass.fieldTypeName,
|
|
35418
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[type] }),
|
|
35419
|
+
value: type,
|
|
35420
|
+
onSelect: () => {
|
|
35421
|
+
onSelect(type);
|
|
35422
|
+
}
|
|
35423
|
+
}));
|
|
35424
|
+
}, [onSelect]);
|
|
35425
|
+
};
|
|
35599
35426
|
const FieldSectionNodeComponent = React.memo((props) => {
|
|
35600
35427
|
const { data, selected } = props;
|
|
35601
35428
|
const { fieldSection, index: sectionIndex, layoutDirection } = data;
|
|
@@ -35942,6 +35769,195 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
35942
35769
|
] });
|
|
35943
35770
|
});
|
|
35944
35771
|
FormBuilderFlowBuilder.displayName = "FormBuilderFlowBuilder";
|
|
35772
|
+
const FieldSectionConditionalItem = React.memo((props) => {
|
|
35773
|
+
const { sourceFieldSection, targetFieldSection } = props;
|
|
35774
|
+
const conditions = React.useMemo(() => {
|
|
35775
|
+
return sourceFieldSection.getConditions(targetFieldSection.identifier);
|
|
35776
|
+
}, [sourceFieldSection, targetFieldSection.identifier]);
|
|
35777
|
+
const handleDelete = React.useCallback(() => {
|
|
35778
|
+
sourceFieldSection.removeConditional(targetFieldSection.identifier);
|
|
35779
|
+
}, [sourceFieldSection, targetFieldSection.identifier]);
|
|
35780
|
+
const handleSelectField = React.useCallback(
|
|
35781
|
+
(field) => {
|
|
35782
|
+
sourceFieldSection.addCondition(targetFieldSection.identifier, createCondition(field));
|
|
35783
|
+
},
|
|
35784
|
+
[sourceFieldSection, targetFieldSection.identifier]
|
|
35785
|
+
);
|
|
35786
|
+
const handleDeleteCondition = React.useCallback(
|
|
35787
|
+
(condition) => {
|
|
35788
|
+
sourceFieldSection.removeCondition(targetFieldSection.identifier, condition);
|
|
35789
|
+
},
|
|
35790
|
+
[sourceFieldSection, targetFieldSection.identifier]
|
|
35791
|
+
);
|
|
35792
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { className: "flex flex-col gap-2", children: [
|
|
35793
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "justify-between gap-2 flex", size: "sm", accentColor: "base", variant: "soft", children: [
|
|
35794
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { accentColor: "base", variant: "soft", size: "sm", children: [
|
|
35795
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons.section }),
|
|
35796
|
+
sourceFieldSection.label ?? UNLABELLED_SECTION_LABEL
|
|
35797
|
+
] }),
|
|
35798
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDelete, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
|
|
35799
|
+
] }),
|
|
35800
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-max w-full flex-wrap gap-2", children: [
|
|
35801
|
+
conditions.map((condition) => {
|
|
35802
|
+
return condition.render({
|
|
35803
|
+
onRemove: handleDeleteCondition
|
|
35804
|
+
});
|
|
35805
|
+
}),
|
|
35806
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldDropdownMenu, { fields: sourceFieldSection.fields, onSelectField: handleSelectField, align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", size: "sm", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }) }) })
|
|
35807
|
+
] })
|
|
35808
|
+
] });
|
|
35809
|
+
});
|
|
35810
|
+
FieldSectionConditionalItem.displayName = "FieldSectionConditionalItem";
|
|
35811
|
+
const FieldSectionBuilder = React.memo((props) => {
|
|
35812
|
+
const { fieldSection } = props;
|
|
35813
|
+
const fieldSchema = React.use(FieldSchemaContext);
|
|
35814
|
+
const conditionalSections = React.useMemo(() => {
|
|
35815
|
+
return fieldSchema.fields.filter((section) => fieldSection.identifier in section.conditions);
|
|
35816
|
+
}, [fieldSchema.fields, fieldSection.identifier]);
|
|
35817
|
+
const handleAddConditional = React.useCallback(
|
|
35818
|
+
(conditionalSection) => {
|
|
35819
|
+
conditionalSection.addConditional(fieldSection.identifier);
|
|
35820
|
+
},
|
|
35821
|
+
[fieldSection.identifier]
|
|
35822
|
+
);
|
|
35823
|
+
const validFieldSections = React.useMemo(() => {
|
|
35824
|
+
const graph = new graphology.DirectedGraph({});
|
|
35825
|
+
for (const sourceSection of fieldSchema.fields) {
|
|
35826
|
+
for (const targetSectionId of Object.keys(sourceSection.conditions)) {
|
|
35827
|
+
graph.mergeEdge(sourceSection.identifier, targetSectionId);
|
|
35828
|
+
}
|
|
35829
|
+
}
|
|
35830
|
+
return fieldSchema.fields.filter(
|
|
35831
|
+
(sourceSection) => !graphologyDag.willCreateCycle(graph, sourceSection.identifier, fieldSection.identifier)
|
|
35832
|
+
);
|
|
35833
|
+
}, [fieldSchema.fields, fieldSection.identifier]);
|
|
35834
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow w-full flex-col gap-4", children: [
|
|
35835
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full overflow-hidden", children: [
|
|
35836
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Input.Root, { variant: "outline", size: "md", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
35837
|
+
blocks.Input.Field,
|
|
35838
|
+
{
|
|
35839
|
+
placeholder: "Enter a section label (optional)",
|
|
35840
|
+
value: fieldSection.label ?? "",
|
|
35841
|
+
onChange: (event) => fieldSection.setOptions({ label: event.target.value }),
|
|
35842
|
+
maxLength: 200
|
|
35843
|
+
}
|
|
35844
|
+
) }),
|
|
35845
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35846
|
+
blocks.TextArea,
|
|
35847
|
+
{
|
|
35848
|
+
className: "field-sizing-content",
|
|
35849
|
+
placeholder: "Enter a section description (optional)",
|
|
35850
|
+
value: fieldSection.description ?? "",
|
|
35851
|
+
onChange: (event) => fieldSection.setOptions({ description: event.target.value }),
|
|
35852
|
+
maxLength: 1e3,
|
|
35853
|
+
resize: "vertical",
|
|
35854
|
+
size: "md"
|
|
35855
|
+
}
|
|
35856
|
+
)
|
|
35857
|
+
] }),
|
|
35858
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "full" }),
|
|
35859
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
35860
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
35861
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", children: "Conditions" }),
|
|
35862
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
35863
|
+
FieldSectionDropdownMenu,
|
|
35864
|
+
{
|
|
35865
|
+
fieldSections: validFieldSections,
|
|
35866
|
+
onSelectFieldCondition: handleAddConditional,
|
|
35867
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", className: "w-max", children: [
|
|
35868
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35869
|
+
"Add condition"
|
|
35870
|
+
] })
|
|
35871
|
+
}
|
|
35872
|
+
)
|
|
35873
|
+
] }),
|
|
35874
|
+
conditionalSections.map((section) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35875
|
+
FieldSectionConditionalItem,
|
|
35876
|
+
{
|
|
35877
|
+
sourceFieldSection: section,
|
|
35878
|
+
targetFieldSection: fieldSection
|
|
35879
|
+
},
|
|
35880
|
+
section.identifier
|
|
35881
|
+
))
|
|
35882
|
+
] }),
|
|
35883
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "full" })
|
|
35884
|
+
] });
|
|
35885
|
+
});
|
|
35886
|
+
FieldSectionBuilder.displayName = "FieldSectionBuilder";
|
|
35887
|
+
const FieldSectionWithActions = React.memo((props) => {
|
|
35888
|
+
const { fieldSection, index: sectionIndex } = props;
|
|
35889
|
+
const fieldSchema = React.use(FieldSchemaContext);
|
|
35890
|
+
const removeField = React.useCallback(
|
|
35891
|
+
(field) => {
|
|
35892
|
+
fieldSection.removeField(field);
|
|
35893
|
+
},
|
|
35894
|
+
[fieldSection]
|
|
35895
|
+
);
|
|
35896
|
+
const removeSection = React.useCallback(() => {
|
|
35897
|
+
fieldSchema.removeField(fieldSection);
|
|
35898
|
+
}, [fieldSchema, fieldSection]);
|
|
35899
|
+
const moveSection = React.useCallback(
|
|
35900
|
+
(direction) => {
|
|
35901
|
+
const targetIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
|
|
35902
|
+
fieldSchema.moveField(sectionIndex, targetIndex);
|
|
35903
|
+
},
|
|
35904
|
+
[fieldSchema, sectionIndex]
|
|
35905
|
+
);
|
|
35906
|
+
const duplicateSection = React.useCallback(() => {
|
|
35907
|
+
fieldSchema.addField(fieldSection.duplicate(uuid.v4()));
|
|
35908
|
+
}, [fieldSchema, fieldSection]);
|
|
35909
|
+
const handleCreateField = React.useCallback(
|
|
35910
|
+
(type) => {
|
|
35911
|
+
fieldSection.addField(createField(type));
|
|
35912
|
+
},
|
|
35913
|
+
[fieldSection]
|
|
35914
|
+
);
|
|
35915
|
+
const handleMoveUp = React.useCallback(() => {
|
|
35916
|
+
moveSection("up");
|
|
35917
|
+
}, [moveSection]);
|
|
35918
|
+
const handleMoveDown = React.useCallback(() => {
|
|
35919
|
+
moveSection("down");
|
|
35920
|
+
}, [moveSection]);
|
|
35921
|
+
const fieldTypeItems = useFieldTypeItems(handleCreateField);
|
|
35922
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { variant: "outline", className: "flex items-center justify-between gap-4 w-full", children: [
|
|
35923
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow flex-col gap-4 w-full", children: [
|
|
35924
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldSectionBuilder, { fieldSection }),
|
|
35925
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full", children: [
|
|
35926
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
|
|
35927
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", size: "md", children: "Fields" }),
|
|
35928
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
|
|
35929
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", children: [
|
|
35930
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
|
|
35931
|
+
" Add field"
|
|
35932
|
+
] }) }),
|
|
35933
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fieldTypeItems.flat().map((item) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: item.onSelect, children: [
|
|
35934
|
+
item.icon,
|
|
35935
|
+
item.children
|
|
35936
|
+
] }, item.value)) }) })
|
|
35937
|
+
] })
|
|
35938
|
+
] }),
|
|
35939
|
+
fieldSection.fields.map((child, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
35940
|
+
FieldWithActions,
|
|
35941
|
+
{
|
|
35942
|
+
field: child,
|
|
35943
|
+
fieldSection,
|
|
35944
|
+
index,
|
|
35945
|
+
sectionIndex,
|
|
35946
|
+
remove: removeField
|
|
35947
|
+
},
|
|
35948
|
+
child.identifier
|
|
35949
|
+
))
|
|
35950
|
+
] })
|
|
35951
|
+
] }),
|
|
35952
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex-col gap-0.5 flex", variant: "ghost", accentColor: "base", size: "sm", children: [
|
|
35953
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-up" }) }),
|
|
35954
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-down" }) }),
|
|
35955
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }),
|
|
35956
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: removeSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
|
|
35957
|
+
] })
|
|
35958
|
+
] });
|
|
35959
|
+
});
|
|
35960
|
+
FieldSectionWithActions.displayName = "FieldSectionWithActions";
|
|
35945
35961
|
const FormBuilderListBuilder = React.memo(() => {
|
|
35946
35962
|
const { handleSubmit, errors } = formik.useFormikContext();
|
|
35947
35963
|
const { hideTitle, hideDescription, onCancel } = React.use(FormBuilderContext);
|
|
@@ -36011,6 +36027,113 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36011
36027
|
] });
|
|
36012
36028
|
});
|
|
36013
36029
|
FormBuilderListBuilder.displayName = "FormBuilderListBuilder";
|
|
36030
|
+
const validateFields = (fields, values) => {
|
|
36031
|
+
const errors = {};
|
|
36032
|
+
const sectionElements = fields.filter((f) => f instanceof FieldSection);
|
|
36033
|
+
for (const field of fields) {
|
|
36034
|
+
if (field instanceof FieldSection) {
|
|
36035
|
+
const conditionalSections = sectionElements.filter((section) => field.identifier in section.conditions);
|
|
36036
|
+
const conditionMet = conditionalSections.length > 0 ? conditionalSections.some(
|
|
36037
|
+
(conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier), values)
|
|
36038
|
+
) : true;
|
|
36039
|
+
if (!conditionMet) continue;
|
|
36040
|
+
Object.assign(errors, field.getErrors(values));
|
|
36041
|
+
} else {
|
|
36042
|
+
if (!(field instanceof BaseField)) {
|
|
36043
|
+
throw new Error("Invalid field type");
|
|
36044
|
+
}
|
|
36045
|
+
const id = field.identifier;
|
|
36046
|
+
const error = field.getError(get(values, id));
|
|
36047
|
+
if (error) set(errors, id, error);
|
|
36048
|
+
}
|
|
36049
|
+
}
|
|
36050
|
+
if (Object.keys(errors).length > 0) return errors;
|
|
36051
|
+
};
|
|
36052
|
+
const initializeFieldValues = (fields, values) => {
|
|
36053
|
+
const ret = {};
|
|
36054
|
+
for (const field of fields) {
|
|
36055
|
+
const value = values[field.identifier];
|
|
36056
|
+
ret[field.identifier] = value !== void 0 ? value : field.blankValue();
|
|
36057
|
+
}
|
|
36058
|
+
return ret;
|
|
36059
|
+
};
|
|
36060
|
+
const changedFieldValues = (fields, values1, values2) => {
|
|
36061
|
+
const ret = {};
|
|
36062
|
+
for (const field of fields) {
|
|
36063
|
+
const value1 = values1[field.identifier];
|
|
36064
|
+
const value2 = values2[field.identifier];
|
|
36065
|
+
if (field.areValuesEqual(value1, value2)) continue;
|
|
36066
|
+
ret[field.identifier] = value2;
|
|
36067
|
+
}
|
|
36068
|
+
return ret;
|
|
36069
|
+
};
|
|
36070
|
+
const unchangedFieldValues = (fields, values1, values2) => {
|
|
36071
|
+
const ret = {};
|
|
36072
|
+
for (const field of fields) {
|
|
36073
|
+
const value1 = values1[field.identifier];
|
|
36074
|
+
const value2 = values2[field.identifier];
|
|
36075
|
+
if (!field.areValuesEqual(value1, value2)) continue;
|
|
36076
|
+
ret[field.identifier] = value2;
|
|
36077
|
+
}
|
|
36078
|
+
return ret;
|
|
36079
|
+
};
|
|
36080
|
+
const isArrayOfFiles = (value) => {
|
|
36081
|
+
return Array.isArray(value) && value[0] instanceof File;
|
|
36082
|
+
};
|
|
36083
|
+
const separateFilesFromFieldValues = (values) => {
|
|
36084
|
+
const files = {};
|
|
36085
|
+
const newValues = {};
|
|
36086
|
+
for (const key in values) {
|
|
36087
|
+
const value = values[key];
|
|
36088
|
+
if (value instanceof File) {
|
|
36089
|
+
files[key] = [value];
|
|
36090
|
+
} else if (isArrayOfFiles(value)) {
|
|
36091
|
+
files[key] = value;
|
|
36092
|
+
} else if (value !== void 0) {
|
|
36093
|
+
newValues[key] = value;
|
|
36094
|
+
}
|
|
36095
|
+
}
|
|
36096
|
+
return { values: newValues, files };
|
|
36097
|
+
};
|
|
36098
|
+
const separateFilesFromFields = async (fields) => {
|
|
36099
|
+
const images = {};
|
|
36100
|
+
const newFields = [];
|
|
36101
|
+
for (const section of fields) {
|
|
36102
|
+
if (section.type !== "section") {
|
|
36103
|
+
throw new Error(`Expected ISerializedField type to be a section. Got ${section.type} instead.`);
|
|
36104
|
+
}
|
|
36105
|
+
const { fields: sectionFields } = section;
|
|
36106
|
+
const newSectionFields = [];
|
|
36107
|
+
for (const field of sectionFields) {
|
|
36108
|
+
if (field.image) {
|
|
36109
|
+
if (field.image instanceof Promise) {
|
|
36110
|
+
try {
|
|
36111
|
+
images[field.identifier] = await field.image;
|
|
36112
|
+
} catch (e) {
|
|
36113
|
+
console.error("Failed to get image from promise", e);
|
|
36114
|
+
}
|
|
36115
|
+
} else {
|
|
36116
|
+
images[field.identifier] = field.image;
|
|
36117
|
+
}
|
|
36118
|
+
delete field.image;
|
|
36119
|
+
}
|
|
36120
|
+
newSectionFields.push(field);
|
|
36121
|
+
}
|
|
36122
|
+
newFields.push({ ...section, fields: newSectionFields });
|
|
36123
|
+
}
|
|
36124
|
+
return { fields: newFields, images };
|
|
36125
|
+
};
|
|
36126
|
+
async function awaitPromisesFromFieldValues(values) {
|
|
36127
|
+
const valuesWithoutFiles = {};
|
|
36128
|
+
for (const [key, value] of Object.entries(values)) {
|
|
36129
|
+
if (Array.isArray(value) && value.every((item) => item instanceof Promise)) {
|
|
36130
|
+
valuesWithoutFiles[key] = await Promise.all(value);
|
|
36131
|
+
} else {
|
|
36132
|
+
valuesWithoutFiles[key] = value;
|
|
36133
|
+
}
|
|
36134
|
+
}
|
|
36135
|
+
return valuesWithoutFiles;
|
|
36136
|
+
}
|
|
36014
36137
|
const FormRenderer = React.memo(
|
|
36015
36138
|
React.forwardRef((props, ref) => {
|
|
36016
36139
|
const {
|
|
@@ -36034,11 +36157,13 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36034
36157
|
const { readonly } = schema.meta;
|
|
36035
36158
|
const formId2 = React.useId();
|
|
36036
36159
|
const initialValues = React.useMemo(() => {
|
|
36037
|
-
return initializeFieldValues(schema.fields, values);
|
|
36160
|
+
return initializeFieldValues(flattenFields(schema.fields), values);
|
|
36038
36161
|
}, [schema.fields, values]);
|
|
36039
36162
|
const handleSubmit = React.useCallback(
|
|
36040
36163
|
(values2) => {
|
|
36041
|
-
onSubmit == null ? void 0 : onSubmit(
|
|
36164
|
+
onSubmit == null ? void 0 : onSubmit(
|
|
36165
|
+
excludeUnchangedFields ? changedFieldValues(flattenFields(schema.fields), initialValues, values2) : values2
|
|
36166
|
+
);
|
|
36042
36167
|
},
|
|
36043
36168
|
[excludeUnchangedFields, initialValues, onSubmit, schema.fields]
|
|
36044
36169
|
);
|
|
@@ -36062,7 +36187,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36062
36187
|
const handleValuesChange = React.useCallback(
|
|
36063
36188
|
(identifier, value) => {
|
|
36064
36189
|
const field = getFieldsMapping(schema.fields)[identifier];
|
|
36065
|
-
if (field.
|
|
36190
|
+
if (field.areValuesEqual(initialValues[identifier], value)) return;
|
|
36066
36191
|
onValuesChange == null ? void 0 : onValuesChange({ ...formik$1.values, [identifier]: value }, { [identifier]: value });
|
|
36067
36192
|
},
|
|
36068
36193
|
[formik$1.values, initialValues, onValuesChange, schema.fields]
|
|
@@ -36175,7 +36300,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36175
36300
|
if (fieldErrors) {
|
|
36176
36301
|
errors.fields = fieldErrors.fields;
|
|
36177
36302
|
}
|
|
36178
|
-
if (
|
|
36303
|
+
if (Object.keys(errors).length > 0) {
|
|
36179
36304
|
showError({
|
|
36180
36305
|
title: "Some form settings are invalid",
|
|
36181
36306
|
description: "Please check settings highlighted in red."
|
|
@@ -36334,6 +36459,9 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36334
36459
|
exports2.UploadInput = UploadInput;
|
|
36335
36460
|
exports2.applyConditions = applyConditions;
|
|
36336
36461
|
exports2.awaitPromisesFromFieldValues = awaitPromisesFromFieldValues;
|
|
36462
|
+
exports2.changedFieldValues = changedFieldValues;
|
|
36463
|
+
exports2.cleanFieldValues = cleanFieldValues;
|
|
36464
|
+
exports2.cleanSerializedFieldValues = cleanSerializedFieldValues;
|
|
36337
36465
|
exports2.createCondition = createCondition;
|
|
36338
36466
|
exports2.createConditionModifierConfig = createConditionModifierConfig;
|
|
36339
36467
|
exports2.createField = createField;
|
|
@@ -36348,12 +36476,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
36348
36476
|
exports2.flattenFields = flattenFields;
|
|
36349
36477
|
exports2.getFieldsMapping = getFieldsMapping;
|
|
36350
36478
|
exports2.initializeFieldValues = initializeFieldValues;
|
|
36479
|
+
exports2.isFilePromiseArray = isFilePromiseArray;
|
|
36480
|
+
exports2.isStringArray = isStringArray;
|
|
36351
36481
|
exports2.maxFileSizeB = maxFileSizeB;
|
|
36352
36482
|
exports2.maxFileSizeKB = maxFileSizeKB;
|
|
36353
36483
|
exports2.maxFileSizeMB = maxFileSizeMB;
|
|
36354
36484
|
exports2.separateFilesFromFieldValues = separateFilesFromFieldValues;
|
|
36355
36485
|
exports2.separateFilesFromFields = separateFilesFromFields;
|
|
36356
36486
|
exports2.serializeFieldValues = serializeFieldValues;
|
|
36487
|
+
exports2.unchangedFieldValues = unchangedFieldValues;
|
|
36357
36488
|
exports2.useFieldInput = useFieldInput;
|
|
36358
36489
|
exports2.useFieldInputs = useFieldInputs;
|
|
36359
36490
|
exports2.useFormikInput = useFormikInput;
|