@fuf-stack/uniform 1.30.0 → 2.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -6
- package/dist/Checkboxes/index.d.mts +178 -274
- package/dist/Checkboxes/index.d.mts.map +1 -1
- package/dist/Checkboxes/index.mjs +294 -94
- package/dist/Checkboxes/index.mjs.map +1 -1
- package/dist/DatePicker/index.d.mts +1963 -148
- package/dist/DatePicker/index.d.mts.map +1 -1
- package/dist/DatePicker/index.mjs +401 -82
- package/dist/DatePicker/index.mjs.map +1 -1
- package/dist/FieldArray/index.d.mts +102 -97
- package/dist/FieldArray/index.d.mts.map +1 -1
- package/dist/FieldArray/index.mjs +340 -195
- package/dist/FieldArray/index.mjs.map +1 -1
- package/dist/FieldCard/index.d.mts +34 -34
- package/dist/FieldCard/index.d.mts.map +1 -1
- package/dist/FieldCard/index.mjs +181 -127
- package/dist/FieldCard/index.mjs.map +1 -1
- package/dist/{FieldCopyTestIdButton-Y9SfvaM9.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +4 -2
- package/dist/FieldCopyTestIdButton-D3_jZYJ1.mjs.map +1 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs +35 -0
- package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
- package/dist/FieldLabel-DrNWJIVh.mjs +128 -0
- package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
- package/dist/FieldLayout-DcvQU0zN.mjs +45 -0
- package/dist/FieldLayout-DcvQU0zN.mjs.map +1 -0
- package/dist/FieldReset/index.d.mts +17 -12
- package/dist/FieldReset/index.d.mts.map +1 -1
- package/dist/FieldReset/index.mjs +50 -33
- package/dist/FieldReset/index.mjs.map +1 -1
- package/dist/FieldValidationError-iAayfTEw.mjs +75 -0
- package/dist/FieldValidationError-iAayfTEw.mjs.map +1 -0
- package/dist/Form/index.d.mts +2 -2
- package/dist/Form/index.d.mts.map +1 -1
- package/dist/Form/index.mjs +9 -7
- package/dist/Form/index.mjs.map +1 -1
- package/dist/{FormContext-Dvt3MiKq.d.mts → FormContext-BnNJYZOo.d.mts} +3 -3
- package/dist/{FormContext-Dvt3MiKq.d.mts.map → FormContext-BnNJYZOo.d.mts.map} +1 -1
- package/dist/{FormContext-B8G_Xxd6.mjs → FormContext-PXkVlBdU.mjs} +6 -2
- package/dist/FormContext-PXkVlBdU.mjs.map +1 -0
- package/dist/Grid/index.mjs +1 -1
- package/dist/{Grid-Us2JFczS.mjs → Grid-DBL29Kwb.mjs} +4 -2
- package/dist/Grid-DBL29Kwb.mjs.map +1 -0
- package/dist/Input/index.d.mts +734 -47
- package/dist/Input/index.d.mts.map +1 -1
- package/dist/Input/index.mjs +411 -168
- package/dist/Input/index.mjs.map +1 -1
- package/dist/RadioBoxes/index.d.mts +300 -98
- package/dist/RadioBoxes/index.d.mts.map +1 -1
- package/dist/RadioBoxes/index.mjs +156 -119
- package/dist/RadioBoxes/index.mjs.map +1 -1
- package/dist/RadioTabs/index.d.mts +302 -76
- package/dist/RadioTabs/index.d.mts.map +1 -1
- package/dist/RadioTabs/index.mjs +274 -87
- package/dist/RadioTabs/index.mjs.map +1 -1
- package/dist/Radios/index.d.mts +314 -78
- package/dist/Radios/index.d.mts.map +1 -1
- package/dist/Radios/index.mjs +90 -44
- package/dist/Radios/index.mjs.map +1 -1
- package/dist/Select/index.d.mts +410 -142
- package/dist/Select/index.d.mts.map +1 -1
- package/dist/Select/index.mjs +284 -157
- package/dist/Select/index.mjs.map +1 -1
- package/dist/Slider/index.d.mts +382 -63
- package/dist/Slider/index.d.mts.map +1 -1
- package/dist/Slider/index.mjs +269 -90
- package/dist/Slider/index.mjs.map +1 -1
- package/dist/SubmitButton/index.d.mts.map +1 -1
- package/dist/SubmitButton/index.mjs +4 -1
- package/dist/SubmitButton/index.mjs.map +1 -1
- package/dist/Switch/index.d.mts +2 -427
- package/dist/Switch/index.mjs +167 -72
- package/dist/Switch/index.mjs.map +1 -1
- package/dist/Switch-Db2dpGz7.d.mts +648 -0
- package/dist/Switch-Db2dpGz7.d.mts.map +1 -0
- package/dist/SwitchBox/index.d.mts +191 -91
- package/dist/SwitchBox/index.d.mts.map +1 -1
- package/dist/SwitchBox/index.mjs +142 -88
- package/dist/SwitchBox/index.mjs.map +1 -1
- package/dist/TextArea/index.d.mts +347 -29
- package/dist/TextArea/index.d.mts.map +1 -1
- package/dist/TextArea/index.mjs +195 -47
- package/dist/TextArea/index.mjs.map +1 -1
- package/dist/Time/index.d.mts +1373 -139
- package/dist/Time/index.d.mts.map +1 -1
- package/dist/Time/index.mjs +160 -77
- package/dist/Time/index.mjs.map +1 -1
- package/dist/helpers/index.d.mts +1 -1
- package/dist/helpers/index.mjs +1 -1
- package/dist/helpers/index.mjs.map +1 -1
- package/dist/hooks/useClientValidation/index.mjs +1 -1
- package/dist/hooks/useController/index.d.mts +29 -2
- package/dist/hooks/useController/index.d.mts.map +1 -0
- package/dist/hooks/useController/index.mjs +1 -1
- package/dist/hooks/useFormContext/index.d.mts +44 -2
- package/dist/hooks/useFormContext/index.d.mts.map +1 -0
- package/dist/hooks/useFormContext/index.mjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.d.mts +9 -3
- package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
- package/dist/hooks/useInputValueDebounce/index.mjs +27 -5
- package/dist/hooks/useInputValueDebounce/index.mjs.map +1 -1
- package/dist/hooks/useInputValueTransform/index.d.mts +1 -2
- package/dist/hooks/useInputValueTransform/index.mjs +1 -1
- package/dist/hooks/useWatchFormReset/index.mjs +1 -1
- package/dist/hooks/useWatchUserChange/index.mjs +1 -1
- package/dist/{useInputValueTransform-cevZBrIN.d.mts → index-cevZBrIN.d.mts} +1 -1
- package/dist/index-cevZBrIN.d.mts.map +1 -0
- package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
- package/dist/partials/FieldValidationError/index.d.mts +637 -3
- package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
- package/dist/partials/FieldValidationError/index.mjs +1 -1
- package/dist/radioControlVariants-BYRfaD6y.mjs +187 -0
- package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
- package/dist/switchVariants-D16b2VaT.mjs +67 -0
- package/dist/switchVariants-D16b2VaT.mjs.map +1 -0
- package/dist/timeVariants-CtXyNKmW.mjs +58 -0
- package/dist/timeVariants-CtXyNKmW.mjs.map +1 -0
- package/dist/{useController-CJjMqXU5.mjs → useController-JtIeurpw.mjs} +2 -2
- package/dist/{useController-CJjMqXU5.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
- package/dist/{useFormContext-BEjPBdzb.mjs → useFormContext-piqnN2L-.mjs} +2 -2
- package/dist/{useFormContext-BEjPBdzb.mjs.map → useFormContext-piqnN2L-.mjs.map} +1 -1
- package/dist/{useInputValueTransform-D44BLp1Z.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -2
- package/dist/{useInputValueTransform-D44BLp1Z.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
- package/package.json +13 -25
- package/dist/FieldCopyTestIdButton-Y9SfvaM9.mjs.map +0 -1
- package/dist/FieldValidationError-BcUV0r1I.mjs +0 -48
- package/dist/FieldValidationError-BcUV0r1I.mjs.map +0 -1
- package/dist/FormContext-B8G_Xxd6.mjs.map +0 -1
- package/dist/Grid-Us2JFczS.mjs.map +0 -1
- package/dist/Switch/index.d.mts.map +0 -1
- package/dist/hooks/useInput/index.d.mts +0 -2
- package/dist/hooks/useInput/index.mjs +0 -5
- package/dist/hooks/useInput/index.mjs.map +0 -1
- package/dist/hooks/useUniformField/index.d.mts +0 -2
- package/dist/hooks/useUniformField/index.mjs +0 -141
- package/dist/hooks/useUniformField/index.mjs.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.d.mts +0 -47
- package/dist/hooks/useUniformFieldArray/index.d.mts.map +0 -1
- package/dist/hooks/useUniformFieldArray/index.mjs +0 -99
- package/dist/hooks/useUniformFieldArray/index.mjs.map +0 -1
- package/dist/index-CaxrMD1A.d.mts +0 -1
- package/dist/index-DsB0_365.d.mts +0 -106
- package/dist/index-DsB0_365.d.mts.map +0 -1
- package/dist/useController-CdFEp-Wa.d.mts +0 -30
- package/dist/useController-CdFEp-Wa.d.mts.map +0 -1
- package/dist/useFormContext-BSSUZ0Md.d.mts +0 -45
- package/dist/useFormContext-BSSUZ0Md.d.mts.map +0 -1
- package/dist/useInput-ClpHDPdr.d.mts +0 -2
- package/dist/useInput-NPbS4w_n.mjs +0 -1
- package/dist/useInputValueTransform-cevZBrIN.d.mts.map +0 -1
|
@@ -1,22 +1,204 @@
|
|
|
1
|
-
import { flatArrayKey } from "../helpers/index.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useState } from "react";
|
|
1
|
+
import { flatArrayKey, isValueEmpty } from "../helpers/index.mjs";
|
|
2
|
+
import { n as useFormContext$1 } from "../useFormContext-piqnN2L-.mjs";
|
|
3
|
+
import { n as useUniformField, t as FieldLabel } from "../FieldLabel-DrNWJIVh.mjs";
|
|
4
|
+
import { useWatchFormReset } from "../hooks/useWatchFormReset/index.mjs";
|
|
5
|
+
import { t as Grid_default } from "../Grid-DBL29Kwb.mjs";
|
|
6
|
+
import { n as FieldValidationError } from "../FieldValidationError-iAayfTEw.mjs";
|
|
7
|
+
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { Button, Menu } from "@fuf-stack/pixels";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { tv } from "@fuf-stack/pixel-utils";
|
|
11
|
+
import { useStyling } from "@fuf-stack/pixels/StylingProvider";
|
|
10
12
|
import { AnimatePresence, motion, useReducedMotion } from "@fuf-stack/pixel-motion";
|
|
11
|
-
import {
|
|
13
|
+
import { useFieldArray } from "react-hook-form";
|
|
12
14
|
import { FaCopy, FaGripVertical, FaPlus, FaTimes } from "react-icons/fa";
|
|
13
15
|
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
14
16
|
import { CSS } from "@dnd-kit/utilities";
|
|
15
17
|
import { VscInsert } from "react-icons/vsc";
|
|
16
18
|
import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
17
19
|
import { restrictToVerticalAxis, restrictToWindowEdges } from "@dnd-kit/modifiers";
|
|
20
|
+
// src/hooks/useUniformFieldArray/useUniformFieldArray.ts
|
|
21
|
+
/**
|
|
22
|
+
* Enhanced useFieldArray hook with initialization and animation logic.
|
|
23
|
+
* Based on React Hook Form's useFieldArray with additional features:
|
|
24
|
+
* - Automatic initialization when lastElementNotRemovable is set
|
|
25
|
+
* - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)
|
|
26
|
+
* - Animation control (disabled during initialization)
|
|
27
|
+
* - Temporary animation disable during reset normalization collapse
|
|
28
|
+
* - Support for flat arrays (arrays of primitives)
|
|
29
|
+
*
|
|
30
|
+
* Note: Automatic validation triggering on length change is disabled to prevent
|
|
31
|
+
* triggering form-wide validation. Array validation still runs on form submission.
|
|
32
|
+
*
|
|
33
|
+
* @see https://react-hook-form.com/docs/usefieldarray
|
|
34
|
+
*/
|
|
35
|
+
const useUniformFieldArrayMethods = ({ name, flat = false, elementInitialValue: _elementInitialValue = null, lastElementNotRemovable = false }, uniformField) => {
|
|
36
|
+
const { control } = uniformField;
|
|
37
|
+
const { fields, append, remove, insert, move, replace } = useFieldArray({
|
|
38
|
+
control,
|
|
39
|
+
name
|
|
40
|
+
});
|
|
41
|
+
const { trigger, setValue, getValues } = useFormContext$1();
|
|
42
|
+
const needsInitialize = useMemo(() => {
|
|
43
|
+
return lastElementNotRemovable && fields.length === 0;
|
|
44
|
+
}, [lastElementNotRemovable, fields.length]);
|
|
45
|
+
const hasInitialized = useRef(!needsInitialize);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (needsInitialize) hasInitialized.current = false;
|
|
48
|
+
}, [needsInitialize]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (hasInitialized.current) setTimeout(() => {
|
|
51
|
+
trigger(name);
|
|
52
|
+
}, 200);
|
|
53
|
+
}, [fields.length]);
|
|
54
|
+
const [disableAnimation, setDisableAnimation] = useState(true);
|
|
55
|
+
const prefersReducedMotion = useReducedMotion();
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (hasInitialized.current) setDisableAnimation(!!prefersReducedMotion);
|
|
58
|
+
}, [prefersReducedMotion]);
|
|
59
|
+
const elementInitialValue = useMemo(() => {
|
|
60
|
+
return flat ? { [flatArrayKey]: _elementInitialValue ?? null } : _elementInitialValue ?? {};
|
|
61
|
+
}, [flat, _elementInitialValue]);
|
|
62
|
+
useWatchFormReset({ onReset: () => {
|
|
63
|
+
const currentValue = getValues(name);
|
|
64
|
+
const valueIsArray = Array.isArray(currentValue);
|
|
65
|
+
const arrayValue = valueIsArray ? currentValue : [];
|
|
66
|
+
const normalizedLength = lastElementNotRemovable ? 1 : 0;
|
|
67
|
+
const alreadyNormalized = valueIsArray && arrayValue.length === normalizedLength;
|
|
68
|
+
if (!(!valueIsArray || arrayValue.length === 0 || arrayValue.every((entry) => {
|
|
69
|
+
return isValueEmpty(entry);
|
|
70
|
+
}))) return;
|
|
71
|
+
if (alreadyNormalized) return;
|
|
72
|
+
setDisableAnimation(true);
|
|
73
|
+
replace(lastElementNotRemovable ? [elementInitialValue] : []);
|
|
74
|
+
if (!prefersReducedMotion) setTimeout(() => {
|
|
75
|
+
setDisableAnimation(false);
|
|
76
|
+
}, 1);
|
|
77
|
+
} });
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (needsInitialize) {
|
|
80
|
+
setValue(name, [elementInitialValue], {
|
|
81
|
+
shouldDirty: false,
|
|
82
|
+
shouldTouch: false
|
|
83
|
+
});
|
|
84
|
+
hasInitialized.current = true;
|
|
85
|
+
if (!prefersReducedMotion && disableAnimation) setTimeout(() => {
|
|
86
|
+
setDisableAnimation(false);
|
|
87
|
+
}, 1);
|
|
88
|
+
}
|
|
89
|
+
}, [needsInitialize]);
|
|
90
|
+
const { testId } = uniformField.field;
|
|
91
|
+
const items = fields.map((row, index) => {
|
|
92
|
+
const elementName = flat ? `${name}.${index}.${flatArrayKey}` : `${name}.${index}`;
|
|
93
|
+
const elementTestId = `${testId}_${index}`;
|
|
94
|
+
return {
|
|
95
|
+
id: row.id,
|
|
96
|
+
renderProps: {
|
|
97
|
+
index,
|
|
98
|
+
length: fields.length,
|
|
99
|
+
methods: {
|
|
100
|
+
append: () => {
|
|
101
|
+
append(elementInitialValue);
|
|
102
|
+
},
|
|
103
|
+
duplicate: () => {
|
|
104
|
+
const currentValue = getValues(name)[index];
|
|
105
|
+
insert(index + 1, flat ? { [flatArrayKey]: currentValue } : currentValue);
|
|
106
|
+
},
|
|
107
|
+
insert: () => {
|
|
108
|
+
insert(index + 1, elementInitialValue);
|
|
109
|
+
},
|
|
110
|
+
remove: () => {
|
|
111
|
+
remove(index);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
name: elementName,
|
|
115
|
+
testId: elementTestId
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
const appendItem = () => {
|
|
120
|
+
append(elementInitialValue);
|
|
121
|
+
};
|
|
122
|
+
const moveItem = (from, to) => {
|
|
123
|
+
move(from, to);
|
|
124
|
+
trigger(name);
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
fields,
|
|
128
|
+
append,
|
|
129
|
+
appendItem,
|
|
130
|
+
items,
|
|
131
|
+
remove,
|
|
132
|
+
insert,
|
|
133
|
+
move,
|
|
134
|
+
moveItem,
|
|
135
|
+
disableAnimation,
|
|
136
|
+
elementInitialValue,
|
|
137
|
+
...uniformField
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
const useUniformFieldArray = (params) => {
|
|
141
|
+
const field = useUniformField({
|
|
142
|
+
...params,
|
|
143
|
+
name: params.name
|
|
144
|
+
});
|
|
145
|
+
return useUniformFieldArrayMethods(params, field);
|
|
146
|
+
};
|
|
147
|
+
// src/FieldArray/fieldArrayVariants.ts
|
|
148
|
+
const fieldArrayVariants = tv({
|
|
149
|
+
slots: {
|
|
150
|
+
/** class for the actions menu button */
|
|
151
|
+
actionsMenuButton: [
|
|
152
|
+
"flex items-center justify-center text-default-600",
|
|
153
|
+
"h-full rounded-none",
|
|
154
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
155
|
+
],
|
|
156
|
+
/** class for the append button */
|
|
157
|
+
appendButton: [
|
|
158
|
+
"w-full justify-start rounded-b-small rounded-t-none font-semibold",
|
|
159
|
+
"!h-[48px] !min-h-0",
|
|
160
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
161
|
+
],
|
|
162
|
+
/** base class for the field array wrapper */
|
|
163
|
+
base: ["overflow-hidden rounded-small border border-divider bg-content1", "divide-y divide-divider"],
|
|
164
|
+
/** class for the element fields grid */
|
|
165
|
+
elementFieldsGrid: ["w-full grow p-3"],
|
|
166
|
+
/** class for the label */
|
|
167
|
+
label: [
|
|
168
|
+
"pointer-events-auto! static! z-auto! block! w-full!",
|
|
169
|
+
"translate-x-0! translate-y-0! transform-none!",
|
|
170
|
+
"rounded-t-small p-3 font-semibold text-medium"
|
|
171
|
+
],
|
|
172
|
+
/** class for the list */
|
|
173
|
+
list: ["overflow-hidden"],
|
|
174
|
+
/** class for the list item (performs motion animations) */
|
|
175
|
+
listItem: ["group relative flex flex-row", "first:-mt-px"],
|
|
176
|
+
/** class for the list item inner */
|
|
177
|
+
listItemInner: ["flex w-full flex-row items-stretch divide-divider bg-content1", "divide-x divide-solid border-b border-t border-divider"],
|
|
178
|
+
/** class for the list wrapper */
|
|
179
|
+
listWrapper: ["overflow-hidden"],
|
|
180
|
+
/** class for the remove button */
|
|
181
|
+
removeButton: [
|
|
182
|
+
"flex items-center justify-center",
|
|
183
|
+
"!h-full !min-h-0 !rounded-none px-3",
|
|
184
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
185
|
+
],
|
|
186
|
+
/** class for the sort drag handle */
|
|
187
|
+
sortDragHandle: [
|
|
188
|
+
"flex cursor-grab items-center justify-center px-2 text-default-600 transition-colors",
|
|
189
|
+
"hover:bg-default-100 active:cursor-grabbing group-data-[dragging=true]:bg-default-100",
|
|
190
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
variants: { hasLabel: { false: {
|
|
194
|
+
actionsMenuButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
|
|
195
|
+
removeButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
|
|
196
|
+
sortDragHandle: "group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none"
|
|
197
|
+
} } }
|
|
198
|
+
});
|
|
18
199
|
// src/FieldArray/subcomponents/ElementAppendButton.tsx
|
|
19
200
|
const ElementAppendButton = ({ appendButtonText = "Add Element", className = void 0, onClick, testId = void 0 }) => {
|
|
201
|
+
const { cn } = useStyling();
|
|
20
202
|
return /* @__PURE__ */ jsxs(Button, {
|
|
21
203
|
className: cn(className),
|
|
22
204
|
disableAnimation: true,
|
|
@@ -32,6 +214,7 @@ const ElementAppendButton = ({ appendButtonText = "Add Element", className = voi
|
|
|
32
214
|
* Menu component for field array element actions (remove, duplicate, insert after)
|
|
33
215
|
*/
|
|
34
216
|
const ElementActionsMenu = ({ className = void 0, duplicate = false, insertAfter = false, showRemove = true, methods, testId = void 0 }) => {
|
|
217
|
+
const { cn } = useStyling();
|
|
35
218
|
const handleAction = (key) => {
|
|
36
219
|
switch (key) {
|
|
37
220
|
case "remove":
|
|
@@ -76,6 +259,7 @@ const ElementActionsMenu = ({ className = void 0, duplicate = false, insertAfter
|
|
|
76
259
|
};
|
|
77
260
|
// src/FieldArray/subcomponents/ElementRemoveButton.tsx
|
|
78
261
|
const ElementRemoveButton = ({ className = void 0, disableAnimation = false, onClick, testId = void 0 }) => {
|
|
262
|
+
const { cn } = useStyling();
|
|
79
263
|
const button = /* @__PURE__ */ jsx(Button, {
|
|
80
264
|
ariaLabel: "remove element",
|
|
81
265
|
className: cn(className),
|
|
@@ -111,12 +295,14 @@ const ElementRemoveButton = ({ className = void 0, disableAnimation = false, onC
|
|
|
111
295
|
* Renders a vertical grip icon that can be used to reorder items.
|
|
112
296
|
*/
|
|
113
297
|
const SortDragHandle = ({ className = void 0, id, testId = void 0 }) => {
|
|
298
|
+
const { cn } = useStyling();
|
|
114
299
|
const { attributes, listeners } = useSortable({ id });
|
|
115
300
|
return /* @__PURE__ */ jsx("div", {
|
|
116
301
|
className: cn(className),
|
|
117
302
|
"data-testid": testId,
|
|
118
303
|
...attributes,
|
|
119
304
|
...listeners,
|
|
305
|
+
"aria-label": "Reorder item",
|
|
120
306
|
children: /* @__PURE__ */ jsx(FaGripVertical, {})
|
|
121
307
|
});
|
|
122
308
|
};
|
|
@@ -127,18 +313,53 @@ const SortDragHandle = ({ className = void 0, id, testId = void 0 }) => {
|
|
|
127
313
|
* improve the user experience and provide a better visual feedback.
|
|
128
314
|
*/
|
|
129
315
|
const FieldArrayElement = ({ children, className, disableAnimation = false, duplicate = false, elementMarginBottom: _elementMarginBottom = void 0, fields, id, index: _index, insertAfter = false, lastNotDeletable = true, methods, sortable = false, testId = void 0 }) => {
|
|
316
|
+
const { cn } = useStyling();
|
|
130
317
|
const { setNodeRef, transform, transition, isDragging } = useSortable({ id });
|
|
318
|
+
const [isVisible, setIsVisible] = useState(true);
|
|
131
319
|
const sortingStyle = sortable ? {
|
|
132
320
|
transform: CSS.Translate.toString(transform),
|
|
133
321
|
transition,
|
|
134
322
|
zIndex: isDragging ? 50 : void 0
|
|
135
323
|
} : void 0;
|
|
136
|
-
const
|
|
324
|
+
const listItemMotionVariants = {
|
|
325
|
+
hidden: {
|
|
326
|
+
opacity: 0,
|
|
327
|
+
height: 0,
|
|
328
|
+
marginBottom: 0
|
|
329
|
+
},
|
|
330
|
+
visible: {
|
|
331
|
+
opacity: 1,
|
|
332
|
+
height: "auto",
|
|
333
|
+
transition: {
|
|
334
|
+
duration: .2,
|
|
335
|
+
ease: "circOut"
|
|
336
|
+
},
|
|
337
|
+
marginBottom: "-1px"
|
|
338
|
+
},
|
|
339
|
+
exit: {
|
|
340
|
+
opacity: 0,
|
|
341
|
+
height: 0,
|
|
342
|
+
marginBottom: 0,
|
|
343
|
+
transition: {
|
|
344
|
+
opacity: {
|
|
345
|
+
duration: .1,
|
|
346
|
+
ease: "circOut"
|
|
347
|
+
},
|
|
348
|
+
height: {
|
|
349
|
+
delay: .1,
|
|
350
|
+
duration: .2,
|
|
351
|
+
ease: "circOut"
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const handleRemove = () => {
|
|
357
|
+
if (disableAnimation) methods.remove();
|
|
358
|
+
else setIsVisible(false);
|
|
359
|
+
};
|
|
137
360
|
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
138
361
|
mode: "wait",
|
|
139
|
-
onExitComplete:
|
|
140
|
-
methods.remove();
|
|
141
|
-
},
|
|
362
|
+
onExitComplete: methods.remove,
|
|
142
363
|
children: isVisible ? /* @__PURE__ */ jsx(motion.li, {
|
|
143
364
|
ref: setNodeRef,
|
|
144
365
|
animate: disableAnimation ? void 0 : "visible",
|
|
@@ -148,38 +369,7 @@ const FieldArrayElement = ({ children, className, disableAnimation = false, dupl
|
|
|
148
369
|
exit: disableAnimation ? void 0 : "exit",
|
|
149
370
|
initial: disableAnimation ? false : "hidden",
|
|
150
371
|
style: sortingStyle,
|
|
151
|
-
variants: disableAnimation ? void 0 :
|
|
152
|
-
hidden: {
|
|
153
|
-
opacity: 0,
|
|
154
|
-
height: 0,
|
|
155
|
-
marginBottom: 0
|
|
156
|
-
},
|
|
157
|
-
visible: {
|
|
158
|
-
opacity: 1,
|
|
159
|
-
height: "auto",
|
|
160
|
-
transition: {
|
|
161
|
-
duration: .2,
|
|
162
|
-
ease: "circOut"
|
|
163
|
-
},
|
|
164
|
-
marginBottom: "-1px"
|
|
165
|
-
},
|
|
166
|
-
exit: {
|
|
167
|
-
opacity: 0,
|
|
168
|
-
height: 0,
|
|
169
|
-
marginBottom: 0,
|
|
170
|
-
transition: {
|
|
171
|
-
opacity: {
|
|
172
|
-
duration: .1,
|
|
173
|
-
ease: "circOut"
|
|
174
|
-
},
|
|
175
|
-
height: {
|
|
176
|
-
delay: .1,
|
|
177
|
-
duration: .2,
|
|
178
|
-
ease: "circOut"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
372
|
+
variants: disableAnimation ? void 0 : listItemMotionVariants,
|
|
183
373
|
children: /* @__PURE__ */ jsxs("div", {
|
|
184
374
|
className: cn(className.listItemInner),
|
|
185
375
|
children: [
|
|
@@ -199,10 +389,7 @@ const FieldArrayElement = ({ children, className, disableAnimation = false, dupl
|
|
|
199
389
|
insertAfter,
|
|
200
390
|
methods: {
|
|
201
391
|
...methods,
|
|
202
|
-
remove:
|
|
203
|
-
if (disableAnimation) methods.remove();
|
|
204
|
-
else setIsVisible(false);
|
|
205
|
-
}
|
|
392
|
+
remove: handleRemove
|
|
206
393
|
},
|
|
207
394
|
showRemove: !(lastNotDeletable && fields.length === 1),
|
|
208
395
|
testId: `${testId}_actions_menu`
|
|
@@ -211,10 +398,7 @@ const FieldArrayElement = ({ children, className, disableAnimation = false, dupl
|
|
|
211
398
|
children: lastNotDeletable && fields.length === 1 ? null : /* @__PURE__ */ jsx(ElementRemoveButton, {
|
|
212
399
|
className: className.removeButton,
|
|
213
400
|
disableAnimation,
|
|
214
|
-
onClick:
|
|
215
|
-
if (disableAnimation) methods.remove();
|
|
216
|
-
else setIsVisible(false);
|
|
217
|
-
},
|
|
401
|
+
onClick: handleRemove,
|
|
218
402
|
testId: `${testId}_remove_button`
|
|
219
403
|
}, "remove-button")
|
|
220
404
|
}) })
|
|
@@ -228,23 +412,30 @@ const FieldArrayElement = ({ children, className, disableAnimation = false, dupl
|
|
|
228
412
|
* Renders the label for a FieldArray component.
|
|
229
413
|
*
|
|
230
414
|
* This component handles displaying the array label with proper accessibility
|
|
231
|
-
* attributes using
|
|
415
|
+
* attributes using owned heading markup and field state.
|
|
232
416
|
*/
|
|
233
|
-
const FieldArrayLabel = ({ className = void 0, label
|
|
234
|
-
const {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
if (!_label) return null;
|
|
239
|
-
const hasErrors = invalid && error?._errors;
|
|
240
|
-
return /* @__PURE__ */ jsx("div", {
|
|
241
|
-
...getLabelProps(),
|
|
417
|
+
const FieldArrayLabel = ({ className = void 0, id = void 0, label, invalid, required }) => {
|
|
418
|
+
const { cn } = useStyling();
|
|
419
|
+
if (!label) return null;
|
|
420
|
+
const hasErrors = invalid;
|
|
421
|
+
return /* @__PURE__ */ jsx(FieldLabel, {
|
|
242
422
|
"aria-level": 3,
|
|
243
|
-
|
|
423
|
+
as: "div",
|
|
424
|
+
className: cn("block max-w-full overflow-hidden text-ellipsis subpixel-antialiased text-small", hasErrors ? "text-danger!" : void 0, className, { "text-foreground!": !hasErrors }),
|
|
425
|
+
id,
|
|
426
|
+
required,
|
|
427
|
+
requiredClassName: "ms-0.5 text-danger",
|
|
244
428
|
role: "heading",
|
|
245
429
|
children: label
|
|
246
430
|
});
|
|
247
431
|
};
|
|
432
|
+
// src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts
|
|
433
|
+
const fieldArrayValidationErrorVariants = tv({ slots: {
|
|
434
|
+
/** Container for array-level validation messages */
|
|
435
|
+
errorMessage: "text-danger text-tiny",
|
|
436
|
+
/** Padded footer containing array-level validation */
|
|
437
|
+
helperWrapper: ["relative flex-col gap-1.5", "block px-3 pb-2 pt-1"]
|
|
438
|
+
} });
|
|
248
439
|
// src/FieldArray/subcomponents/FieldArrayValidationError.tsx
|
|
249
440
|
/**
|
|
250
441
|
* Renders array-level validation errors for FieldArray.
|
|
@@ -256,13 +447,15 @@ const FieldArrayLabel = ({ className = void 0, label: _label, name }) => {
|
|
|
256
447
|
* The component wraps errors in the proper accessibility markup and animates
|
|
257
448
|
* them in/out using Framer Motion when they appear or are resolved.
|
|
258
449
|
*/
|
|
259
|
-
const FieldArrayValidationError = ({
|
|
260
|
-
const
|
|
450
|
+
const FieldArrayValidationError = ({ error, ids, invalid, testId }) => {
|
|
451
|
+
const styling = useStyling();
|
|
261
452
|
const disableAnimation = useReducedMotion();
|
|
262
|
-
const
|
|
453
|
+
const variants = styling.resolve(fieldArrayValidationErrorVariants);
|
|
454
|
+
const classNames = styling.variantsToClassNames(variants);
|
|
455
|
+
const objectErrors = error?._errors;
|
|
263
456
|
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
264
457
|
initial: !disableAnimation,
|
|
265
|
-
children:
|
|
458
|
+
children: invalid && objectErrors ? /* @__PURE__ */ jsx(motion.div, {
|
|
266
459
|
animate: disableAnimation ? void 0 : {
|
|
267
460
|
opacity: 1,
|
|
268
461
|
height: "auto"
|
|
@@ -281,14 +474,13 @@ const FieldArrayValidationError = ({ name }) => {
|
|
|
281
474
|
ease: "circOut"
|
|
282
475
|
},
|
|
283
476
|
children: /* @__PURE__ */ jsx("div", {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
children: /* @__PURE__ */ jsx(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
})
|
|
477
|
+
className: classNames.helperWrapper,
|
|
478
|
+
"data-slot": "helper-wrapper",
|
|
479
|
+
children: /* @__PURE__ */ jsx(FieldValidationError, {
|
|
480
|
+
className: { wrapper: classNames.errorMessage },
|
|
481
|
+
error: objectErrors,
|
|
482
|
+
id: ids.error,
|
|
483
|
+
testId
|
|
292
484
|
})
|
|
293
485
|
})
|
|
294
486
|
}, "field-array-errors") : null
|
|
@@ -303,8 +495,7 @@ const FieldArrayValidationError = ({ name }) => {
|
|
|
303
495
|
* drag-and-drop reordering of form fields. It supports both pointer (mouse/touch)
|
|
304
496
|
* and keyboard interactions for accessibility.
|
|
305
497
|
*/
|
|
306
|
-
const SortContext = ({ children, fields, move,
|
|
307
|
-
const { trigger } = useFormContext();
|
|
498
|
+
const SortContext = ({ children, fields, move, sortable }) => {
|
|
308
499
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));
|
|
309
500
|
if (!sortable) return children;
|
|
310
501
|
/**
|
|
@@ -313,14 +504,11 @@ const SortContext = ({ children, fields, move, name, sortable }) => {
|
|
|
313
504
|
*/
|
|
314
505
|
const handleDragEnd = (event) => {
|
|
315
506
|
const { active, over } = event;
|
|
316
|
-
if (active.id !== over?.id) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}));
|
|
322
|
-
trigger(name);
|
|
323
|
-
}
|
|
507
|
+
if (active.id !== over?.id) move(fields.findIndex((field) => {
|
|
508
|
+
return field.id === active.id;
|
|
509
|
+
}), fields.findIndex((field) => {
|
|
510
|
+
return field.id === over?.id;
|
|
511
|
+
}));
|
|
324
512
|
};
|
|
325
513
|
return /* @__PURE__ */ jsx(DndContext, {
|
|
326
514
|
collisionDetection: closestCenter,
|
|
@@ -336,145 +524,102 @@ const SortContext = ({ children, fields, move, name, sortable }) => {
|
|
|
336
524
|
})
|
|
337
525
|
});
|
|
338
526
|
};
|
|
339
|
-
// src/FieldArray/
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
/** class for the append button */
|
|
351
|
-
appendButton: [
|
|
352
|
-
"w-full justify-start rounded-b-small rounded-t-none font-semibold",
|
|
353
|
-
"!h-[48px] !min-h-0",
|
|
354
|
-
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
355
|
-
],
|
|
356
|
-
/** class for the element fields grid */
|
|
357
|
-
elementFieldsGrid: ["w-full grow p-3"],
|
|
358
|
-
/** class for the label */
|
|
359
|
-
label: [
|
|
360
|
-
"pointer-events-auto! static! z-auto! block! w-full!",
|
|
361
|
-
"translate-x-0! translate-y-0! transform-none!",
|
|
362
|
-
"rounded-t-small p-3 font-semibold text-medium"
|
|
363
|
-
],
|
|
364
|
-
/** class for the list */
|
|
365
|
-
list: ["overflow-hidden"],
|
|
366
|
-
/** class for the list wrapper */
|
|
367
|
-
listWrapper: ["overflow-hidden"],
|
|
368
|
-
/** class for the list item (performs motion animations) */
|
|
369
|
-
listItem: ["group relative flex flex-row", "first:-mt-px"],
|
|
370
|
-
/** class for the list item inner */
|
|
371
|
-
listItemInner: ["flex w-full flex-row items-stretch divide-divider bg-content1", "divide-x divide-solid border-b border-t border-divider"],
|
|
372
|
-
/** class for the remove button */
|
|
373
|
-
removeButton: [
|
|
374
|
-
"flex items-center justify-center",
|
|
375
|
-
"!h-full !min-h-0 !rounded-none px-3",
|
|
376
|
-
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
377
|
-
],
|
|
378
|
-
/** class for the sort drag handle */
|
|
379
|
-
sortDragHandle: [
|
|
380
|
-
"flex cursor-grab items-center justify-center px-2 text-default-600 transition-colors",
|
|
381
|
-
"hover:bg-default-100 active:cursor-grabbing group-data-[dragging=true]:bg-default-100",
|
|
382
|
-
"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus"
|
|
383
|
-
]
|
|
384
|
-
},
|
|
385
|
-
variants: { hasLabel: { false: {
|
|
386
|
-
actionsMenuButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
|
|
387
|
-
removeButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
|
|
388
|
-
sortDragHandle: "group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none"
|
|
389
|
-
} } }
|
|
390
|
-
});
|
|
391
|
-
/**
|
|
392
|
-
* FieldArray component based in [RHF useFieldArray](https://react-hook-form.com/docs/usefieldarray)
|
|
393
|
-
*/
|
|
394
|
-
const FieldArray = ({ appendButtonText = "Add Element", children, className: _className = void 0, duplicate = false, elementInitialValue: _elementInitialValue = null, elementMarginBottom = void 0, flat = false, insertAfter = false, lastElementNotRemovable = false, name, sortable = false, ...uniformFieldProps }) => {
|
|
395
|
-
const { fields, append, remove, insert, move, disableAnimation, elementInitialValue, getValues, testId } = useUniformFieldArray({
|
|
396
|
-
name,
|
|
397
|
-
flat,
|
|
398
|
-
elementInitialValue: _elementInitialValue,
|
|
399
|
-
lastElementNotRemovable,
|
|
400
|
-
...uniformFieldProps
|
|
401
|
-
});
|
|
402
|
-
const variants = fieldArrayVariants({ hasLabel: !!uniformFieldProps.label });
|
|
403
|
-
const className = variantsToClassNames(variants, _className, "base");
|
|
527
|
+
// src/FieldArray/subcomponents/FieldArrayControl.tsx
|
|
528
|
+
/** Array group presentation with row controls, sorting and validation messages */
|
|
529
|
+
const FieldArrayControl = ({ field, appendButtonText, children, className, disableAnimation, duplicate, elementMarginBottom, fields, items, insertAfter, lastElementNotRemovable, onAppend, onMove, sortable = false }) => {
|
|
530
|
+
const { error, ids, invalid, name, required, testId } = field;
|
|
531
|
+
const label = field.hasLabel ? field.label : void 0;
|
|
532
|
+
const styling = useStyling();
|
|
533
|
+
const labelId = useId();
|
|
534
|
+
const hasArrayErrors = !!(invalid && error?._errors);
|
|
535
|
+
const { cn } = styling;
|
|
536
|
+
const variants = styling.resolve(fieldArrayVariants, { hasLabel: !!label });
|
|
537
|
+
const classNames = styling.variantsToClassNames(variants, className, "base");
|
|
404
538
|
return /* @__PURE__ */ jsxs("div", {
|
|
405
|
-
|
|
539
|
+
"aria-label": !label ? name : void 0,
|
|
540
|
+
"aria-labelledby": label ? labelId : void 0,
|
|
541
|
+
className: classNames.base,
|
|
542
|
+
"data-component": "field-array",
|
|
543
|
+
role: "group",
|
|
406
544
|
children: [
|
|
407
545
|
/* @__PURE__ */ jsx(FieldArrayLabel, {
|
|
408
|
-
className:
|
|
409
|
-
|
|
410
|
-
|
|
546
|
+
className: classNames.label,
|
|
547
|
+
id: labelId,
|
|
548
|
+
invalid: hasArrayErrors,
|
|
549
|
+
label,
|
|
550
|
+
required
|
|
411
551
|
}),
|
|
412
552
|
fields.length ? /* @__PURE__ */ jsx("div", {
|
|
413
|
-
className: cn(
|
|
553
|
+
className: cn(classNames.listWrapper),
|
|
414
554
|
children: /* @__PURE__ */ jsx(SortContext, {
|
|
415
555
|
fields,
|
|
416
|
-
move,
|
|
417
|
-
name,
|
|
556
|
+
move: onMove,
|
|
418
557
|
sortable,
|
|
419
558
|
children: /* @__PURE__ */ jsx("ul", {
|
|
420
|
-
className:
|
|
559
|
+
className: classNames.list,
|
|
421
560
|
"data-testid": testId,
|
|
422
|
-
children:
|
|
423
|
-
const elementName = flat ? `${name}.${index}.${flatArrayKey}` : `${name}.${index}`;
|
|
424
|
-
const elementTestId = `${testId}_${index}`;
|
|
425
|
-
const elementMethods = {
|
|
426
|
-
append: () => {
|
|
427
|
-
append(elementInitialValue);
|
|
428
|
-
},
|
|
429
|
-
duplicate: () => {
|
|
430
|
-
const currentValue = getValues(name)[index];
|
|
431
|
-
const nextValue = flat ? { [flatArrayKey]: currentValue } : currentValue;
|
|
432
|
-
insert(index + 1, nextValue);
|
|
433
|
-
},
|
|
434
|
-
insert: () => {
|
|
435
|
-
insert(index + 1, elementInitialValue);
|
|
436
|
-
},
|
|
437
|
-
remove: () => {
|
|
438
|
-
remove(index);
|
|
439
|
-
}
|
|
440
|
-
};
|
|
561
|
+
children: items.map(({ id, renderProps }) => {
|
|
441
562
|
return /* @__PURE__ */ jsx(FieldArrayElement, {
|
|
442
|
-
className,
|
|
563
|
+
className: classNames,
|
|
443
564
|
disableAnimation,
|
|
444
565
|
duplicate,
|
|
445
566
|
elementMarginBottom,
|
|
446
567
|
fields,
|
|
447
|
-
id
|
|
448
|
-
index,
|
|
568
|
+
id,
|
|
569
|
+
index: renderProps.index,
|
|
449
570
|
insertAfter,
|
|
450
571
|
lastNotDeletable: lastElementNotRemovable,
|
|
451
|
-
methods:
|
|
572
|
+
methods: renderProps.methods,
|
|
452
573
|
sortable,
|
|
453
|
-
testId:
|
|
454
|
-
children: children(
|
|
455
|
-
|
|
456
|
-
length: fields.length,
|
|
457
|
-
methods: elementMethods,
|
|
458
|
-
name: elementName,
|
|
459
|
-
testId: elementTestId
|
|
460
|
-
})
|
|
461
|
-
}, field.id);
|
|
574
|
+
testId: renderProps.testId,
|
|
575
|
+
children: children(renderProps)
|
|
576
|
+
}, id);
|
|
462
577
|
})
|
|
463
578
|
})
|
|
464
579
|
})
|
|
465
580
|
}) : null,
|
|
466
|
-
/* @__PURE__ */ jsx(FieldArrayValidationError, {
|
|
581
|
+
/* @__PURE__ */ jsx(FieldArrayValidationError, {
|
|
582
|
+
error,
|
|
583
|
+
ids,
|
|
584
|
+
invalid,
|
|
585
|
+
testId
|
|
586
|
+
}),
|
|
467
587
|
/* @__PURE__ */ jsx(ElementAppendButton, {
|
|
468
588
|
appendButtonText,
|
|
469
|
-
className:
|
|
470
|
-
onClick:
|
|
471
|
-
append(elementInitialValue);
|
|
472
|
-
},
|
|
589
|
+
className: classNames.appendButton,
|
|
590
|
+
onClick: onAppend,
|
|
473
591
|
testId: `${testId}_append_button`
|
|
474
592
|
})
|
|
475
593
|
]
|
|
476
594
|
});
|
|
477
595
|
};
|
|
596
|
+
// src/FieldArray/FieldArray.tsx
|
|
597
|
+
/** Form field group for adding, removing and reordering array entries */
|
|
598
|
+
const FieldArray = ({ appendButtonText = "Add Element", children, className: _className = void 0, duplicate = false, elementInitialValue: _elementInitialValue = null, elementMarginBottom = void 0, flat = false, insertAfter = false, lastElementNotRemovable = false, name, sortable = false, ...uniformFieldProps }) => {
|
|
599
|
+
const { field, fields, appendItem, items, moveItem, disableAnimation } = useUniformFieldArray({
|
|
600
|
+
...uniformFieldProps,
|
|
601
|
+
elementInitialValue: _elementInitialValue,
|
|
602
|
+
flat,
|
|
603
|
+
lastElementNotRemovable,
|
|
604
|
+
name
|
|
605
|
+
});
|
|
606
|
+
return /* @__PURE__ */ jsx(FieldArrayControl, {
|
|
607
|
+
appendButtonText,
|
|
608
|
+
className: _className,
|
|
609
|
+
disableAnimation,
|
|
610
|
+
duplicate,
|
|
611
|
+
elementMarginBottom,
|
|
612
|
+
field,
|
|
613
|
+
fields,
|
|
614
|
+
insertAfter,
|
|
615
|
+
items,
|
|
616
|
+
lastElementNotRemovable,
|
|
617
|
+
onAppend: appendItem,
|
|
618
|
+
onMove: moveItem,
|
|
619
|
+
sortable,
|
|
620
|
+
children
|
|
621
|
+
});
|
|
622
|
+
};
|
|
478
623
|
// src/FieldArray/index.ts
|
|
479
624
|
var FieldArray_default = FieldArray;
|
|
480
625
|
export { FieldArray_default as default, fieldArrayVariants };
|