@fuf-stack/uniform 1.4.1 → 1.5.0

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.
Files changed (187) hide show
  1. package/dist/Checkboxes/index.cjs +16 -0
  2. package/dist/{RadioGroup → Checkboxes}/index.cjs.map +1 -1
  3. package/dist/Checkboxes/index.d.cts +10 -0
  4. package/dist/Checkboxes/index.d.ts +10 -0
  5. package/dist/Checkboxes/index.js +16 -0
  6. package/dist/{CheckboxGroup-B1g42iP0.d.cts → Checkboxes-CR0Uu2g9.d.cts} +9 -9
  7. package/dist/{CheckboxGroup-B1g42iP0.d.ts → Checkboxes-CR0Uu2g9.d.ts} +9 -9
  8. package/dist/FieldArray/index.cjs +5 -5
  9. package/dist/FieldArray/index.d.cts +2 -2
  10. package/dist/FieldArray/index.d.ts +2 -2
  11. package/dist/FieldArray/index.js +4 -4
  12. package/dist/FieldArray-EP4otr2x.d.cts +160 -0
  13. package/dist/FieldArray-EP4otr2x.d.ts +160 -0
  14. package/dist/{FieldValidationError-CU_xw0BL.d.ts → FieldValidationError-DwtLkGMo.d.cts} +2 -2
  15. package/dist/{FieldValidationError-CU_xw0BL.d.cts → FieldValidationError-DwtLkGMo.d.ts} +2 -2
  16. package/dist/Form/index.cjs +6 -4
  17. package/dist/Form/index.cjs.map +1 -1
  18. package/dist/Form/index.js +5 -3
  19. package/dist/Input/index.cjs +5 -5
  20. package/dist/Input/index.d.cts +2 -2
  21. package/dist/Input/index.d.ts +2 -2
  22. package/dist/Input/index.js +4 -4
  23. package/dist/{Input-C6ujfEkn.d.ts → Input-CCIEnvIp.d.ts} +1 -1
  24. package/dist/{Input-BQkZtJx8.d.cts → Input-D7HT_8jf.d.cts} +1 -1
  25. package/dist/RadioBoxes/index.cjs +5 -5
  26. package/dist/RadioBoxes/index.d.cts +3 -2
  27. package/dist/RadioBoxes/index.d.ts +3 -2
  28. package/dist/RadioBoxes/index.js +4 -4
  29. package/dist/{RadioBoxes-CE3mYoFk.d.cts → RadioBoxes-DpkI28l0.d.cts} +3 -2
  30. package/dist/{RadioBoxes-CE3mYoFk.d.ts → RadioBoxes-DpkI28l0.d.ts} +3 -2
  31. package/dist/RadioTabs/index.cjs +5 -5
  32. package/dist/RadioTabs/index.d.cts +2 -2
  33. package/dist/RadioTabs/index.d.ts +2 -2
  34. package/dist/RadioTabs/index.js +4 -4
  35. package/dist/{RadioTabs-BCWW3tru.d.cts → RadioTabs-DTDcAZoH.d.cts} +1 -1
  36. package/dist/{RadioTabs-BCWW3tru.d.ts → RadioTabs-DTDcAZoH.d.ts} +1 -1
  37. package/dist/Radios/index.cjs +16 -0
  38. package/dist/Radios/index.cjs.map +1 -0
  39. package/dist/Radios/index.d.cts +9 -0
  40. package/dist/Radios/index.d.ts +9 -0
  41. package/dist/Radios/index.js +16 -0
  42. package/dist/{RadioGroup-CAOX80Xx.d.cts → Radios-DprlJhoq.d.cts} +9 -9
  43. package/dist/{RadioGroup-CAOX80Xx.d.ts → Radios-DprlJhoq.d.ts} +9 -9
  44. package/dist/Select/index.cjs +5 -5
  45. package/dist/Select/index.d.cts +2 -2
  46. package/dist/Select/index.d.ts +2 -2
  47. package/dist/Select/index.js +4 -4
  48. package/dist/{Select-CTRWinmO.d.cts → Select-CDkZmZp2.d.cts} +1 -1
  49. package/dist/{Select-CTRWinmO.d.ts → Select-CDkZmZp2.d.ts} +1 -1
  50. package/dist/SubmitButton/index.cjs +6 -4
  51. package/dist/SubmitButton/index.cjs.map +1 -1
  52. package/dist/SubmitButton/index.js +5 -3
  53. package/dist/Switch/index.cjs +5 -5
  54. package/dist/Switch/index.js +4 -4
  55. package/dist/TextArea/index.cjs +5 -5
  56. package/dist/TextArea/index.d.cts +4 -2
  57. package/dist/TextArea/index.d.ts +4 -2
  58. package/dist/TextArea/index.js +4 -4
  59. package/dist/TextArea-DhxNWYNg.d.cts +86 -0
  60. package/dist/TextArea-DhxNWYNg.d.ts +86 -0
  61. package/dist/chunk-2DHTL4PW.cjs +117 -0
  62. package/dist/chunk-2DHTL4PW.cjs.map +1 -0
  63. package/dist/{chunk-FOVP54XP.cjs → chunk-3NH4MEMM.cjs} +18 -27
  64. package/dist/chunk-3NH4MEMM.cjs.map +1 -0
  65. package/dist/{chunk-M2DNMSQZ.js → chunk-3Q3IUEGL.js} +52 -49
  66. package/dist/chunk-3Q3IUEGL.js.map +1 -0
  67. package/dist/{chunk-JSQ77E6L.js → chunk-4WRUHOGY.js} +49 -47
  68. package/dist/chunk-4WRUHOGY.js.map +1 -0
  69. package/dist/{chunk-KG4XCEPW.js → chunk-53XSXUNE.js} +42 -40
  70. package/dist/chunk-53XSXUNE.js.map +1 -0
  71. package/dist/{chunk-77C6VN4L.cjs → chunk-5LWD6VRV.cjs} +50 -47
  72. package/dist/chunk-5LWD6VRV.cjs.map +1 -0
  73. package/dist/{chunk-C64RKQEW.cjs → chunk-62AYJT2H.cjs} +3 -3
  74. package/dist/{chunk-C64RKQEW.cjs.map → chunk-62AYJT2H.cjs.map} +1 -1
  75. package/dist/chunk-76KOVUDN.js +138 -0
  76. package/dist/chunk-76KOVUDN.js.map +1 -0
  77. package/dist/{chunk-FHRMVL6B.js → chunk-AYWMAPAX.js} +134 -89
  78. package/dist/chunk-AYWMAPAX.js.map +1 -0
  79. package/dist/chunk-BWPTCHL7.cjs +103 -0
  80. package/dist/chunk-BWPTCHL7.cjs.map +1 -0
  81. package/dist/{chunk-2GYFDVXX.cjs → chunk-C5GIWGQR.cjs} +173 -33
  82. package/dist/chunk-C5GIWGQR.cjs.map +1 -0
  83. package/dist/{chunk-IYDCKENI.js → chunk-CJD3DW4J.js} +166 -26
  84. package/dist/chunk-CJD3DW4J.js.map +1 -0
  85. package/dist/{chunk-N2EEOWEP.cjs → chunk-CW4VK77Z.cjs} +59 -64
  86. package/dist/chunk-CW4VK77Z.cjs.map +1 -0
  87. package/dist/{chunk-LJQ35BUK.js → chunk-D2HI4KE4.js} +2 -2
  88. package/dist/chunk-DYTE5N3B.cjs +684 -0
  89. package/dist/chunk-DYTE5N3B.cjs.map +1 -0
  90. package/dist/chunk-ELYGQTXB.js +47 -0
  91. package/dist/chunk-ELYGQTXB.js.map +1 -0
  92. package/dist/chunk-GST3AQOR.js +684 -0
  93. package/dist/chunk-GST3AQOR.js.map +1 -0
  94. package/dist/{chunk-AYNTZPKL.cjs → chunk-HQNZYWJX.cjs} +132 -87
  95. package/dist/chunk-HQNZYWJX.cjs.map +1 -0
  96. package/dist/chunk-LLQLEDOO.js +103 -0
  97. package/dist/chunk-LLQLEDOO.js.map +1 -0
  98. package/dist/chunk-NHEZXA4H.cjs +47 -0
  99. package/dist/chunk-NHEZXA4H.cjs.map +1 -0
  100. package/dist/{chunk-M7VM7XBE.js → chunk-OCYJFIPV.js} +8 -8
  101. package/dist/chunk-OCYJFIPV.js.map +1 -0
  102. package/dist/{chunk-ORQO6JXK.cjs → chunk-S36CKKDV.cjs} +45 -43
  103. package/dist/chunk-S36CKKDV.cjs.map +1 -0
  104. package/dist/chunk-S7K35LVS.js +117 -0
  105. package/dist/chunk-S7K35LVS.js.map +1 -0
  106. package/dist/{chunk-Y3GELCDP.js → chunk-VLEYEBRE.js} +62 -67
  107. package/dist/chunk-VLEYEBRE.js.map +1 -0
  108. package/dist/{chunk-UGCZORU3.cjs → chunk-YIBISSMT.cjs} +9 -9
  109. package/dist/chunk-YIBISSMT.cjs.map +1 -0
  110. package/dist/chunk-Z353BLWI.cjs +138 -0
  111. package/dist/chunk-Z353BLWI.cjs.map +1 -0
  112. package/dist/{chunk-ULR4573W.cjs → chunk-ZLQCMOVU.cjs} +40 -38
  113. package/dist/chunk-ZLQCMOVU.cjs.map +1 -0
  114. package/dist/{chunk-2B6CDMOZ.js → chunk-ZN3ESUQR.js} +16 -25
  115. package/dist/chunk-ZN3ESUQR.js.map +1 -0
  116. package/dist/helpers/index.cjs +4 -2
  117. package/dist/helpers/index.cjs.map +1 -1
  118. package/dist/helpers/index.d.cts +54 -10
  119. package/dist/helpers/index.d.ts +54 -10
  120. package/dist/helpers/index.js +3 -1
  121. package/dist/hooks/index.cjs +7 -3
  122. package/dist/hooks/index.cjs.map +1 -1
  123. package/dist/hooks/index.d.cts +86 -4
  124. package/dist/hooks/index.d.ts +86 -4
  125. package/dist/hooks/index.js +8 -4
  126. package/dist/index.cjs +20 -16
  127. package/dist/index.cjs.map +1 -1
  128. package/dist/index.d.cts +11 -11
  129. package/dist/index.d.ts +11 -11
  130. package/dist/index.js +30 -26
  131. package/dist/partials/FieldValidationError/index.cjs +2 -2
  132. package/dist/partials/FieldValidationError/index.d.cts +2 -2
  133. package/dist/partials/FieldValidationError/index.d.ts +2 -2
  134. package/dist/partials/FieldValidationError/index.js +1 -1
  135. package/package.json +13 -12
  136. package/dist/CheckboxGroup/index.cjs +0 -16
  137. package/dist/CheckboxGroup/index.cjs.map +0 -1
  138. package/dist/CheckboxGroup/index.d.cts +0 -10
  139. package/dist/CheckboxGroup/index.d.ts +0 -10
  140. package/dist/CheckboxGroup/index.js +0 -16
  141. package/dist/FieldArray-DVQka7Bh.d.cts +0 -130
  142. package/dist/FieldArray-DVQka7Bh.d.ts +0 -130
  143. package/dist/RadioGroup/index.cjs +0 -16
  144. package/dist/RadioGroup/index.d.cts +0 -9
  145. package/dist/RadioGroup/index.d.ts +0 -9
  146. package/dist/RadioGroup/index.js +0 -16
  147. package/dist/TextArea-DnFGyl4a.d.cts +0 -27
  148. package/dist/TextArea-DnFGyl4a.d.ts +0 -27
  149. package/dist/chunk-2B6CDMOZ.js.map +0 -1
  150. package/dist/chunk-2GYFDVXX.cjs.map +0 -1
  151. package/dist/chunk-77C6VN4L.cjs.map +0 -1
  152. package/dist/chunk-AYNTZPKL.cjs.map +0 -1
  153. package/dist/chunk-CQWA2DFV.js +0 -37
  154. package/dist/chunk-CQWA2DFV.js.map +0 -1
  155. package/dist/chunk-EEBHFSBY.cjs +0 -112
  156. package/dist/chunk-EEBHFSBY.cjs.map +0 -1
  157. package/dist/chunk-FHRMVL6B.js.map +0 -1
  158. package/dist/chunk-FOVP54XP.cjs.map +0 -1
  159. package/dist/chunk-IYDCKENI.js.map +0 -1
  160. package/dist/chunk-JSQ77E6L.js.map +0 -1
  161. package/dist/chunk-JZF4HUYO.cjs +0 -409
  162. package/dist/chunk-JZF4HUYO.cjs.map +0 -1
  163. package/dist/chunk-KG4XCEPW.js.map +0 -1
  164. package/dist/chunk-KQN55PEW.js +0 -76
  165. package/dist/chunk-KQN55PEW.js.map +0 -1
  166. package/dist/chunk-M2DNMSQZ.js.map +0 -1
  167. package/dist/chunk-M7VM7XBE.js.map +0 -1
  168. package/dist/chunk-N2EEOWEP.cjs.map +0 -1
  169. package/dist/chunk-NAZIH6HV.js +0 -409
  170. package/dist/chunk-NAZIH6HV.js.map +0 -1
  171. package/dist/chunk-ORQO6JXK.cjs.map +0 -1
  172. package/dist/chunk-RDBCJJI7.cjs +0 -88
  173. package/dist/chunk-RDBCJJI7.cjs.map +0 -1
  174. package/dist/chunk-RF7KNUCI.js +0 -88
  175. package/dist/chunk-RF7KNUCI.js.map +0 -1
  176. package/dist/chunk-UGCZORU3.cjs.map +0 -1
  177. package/dist/chunk-ULR4573W.cjs.map +0 -1
  178. package/dist/chunk-XKMLCM5K.js +0 -112
  179. package/dist/chunk-XKMLCM5K.js.map +0 -1
  180. package/dist/chunk-Y3AB4GV6.cjs +0 -37
  181. package/dist/chunk-Y3AB4GV6.cjs.map +0 -1
  182. package/dist/chunk-Y3GELCDP.js.map +0 -1
  183. package/dist/chunk-YGNY6CKU.cjs +0 -76
  184. package/dist/chunk-YGNY6CKU.cjs.map +0 -1
  185. /package/dist/{CheckboxGroup → Checkboxes}/index.js.map +0 -0
  186. /package/dist/{RadioGroup → Radios}/index.js.map +0 -0
  187. /package/dist/{chunk-LJQ35BUK.js.map → chunk-D2HI4KE4.js.map} +0 -0
@@ -0,0 +1,684 @@
1
+ import {
2
+ Grid_default
3
+ } from "./chunk-B62HKKMS.js";
4
+ import {
5
+ useFieldArray,
6
+ useFormContext,
7
+ useUniformField
8
+ } from "./chunk-CJD3DW4J.js";
9
+ import {
10
+ FieldValidationError_default
11
+ } from "./chunk-ELYGQTXB.js";
12
+ import {
13
+ flatArrayKey
14
+ } from "./chunk-76KOVUDN.js";
15
+ import {
16
+ __objRest,
17
+ __spreadProps,
18
+ __spreadValues
19
+ } from "./chunk-K2V4ULA2.js";
20
+
21
+ // src/FieldArray/FieldArray.tsx
22
+ import { useEffect, useRef } from "react";
23
+ import { useReducedMotion as useReducedMotion2 } from "@fuf-stack/pixel-motion";
24
+ import { cn as cn8, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
25
+
26
+ // src/FieldArray/subcomponents/ElementAppendButton.tsx
27
+ import { FaPlus } from "react-icons/fa";
28
+ import { cn } from "@fuf-stack/pixel-utils";
29
+ import { Button } from "@fuf-stack/pixels";
30
+ import { jsx, jsxs } from "react/jsx-runtime";
31
+ var ElementAppendButton = ({
32
+ appendButtonText = "Add Element",
33
+ className = void 0,
34
+ onClick,
35
+ testId = void 0
36
+ }) => {
37
+ return /* @__PURE__ */ jsxs(
38
+ Button,
39
+ {
40
+ disableAnimation: true,
41
+ className: cn(className),
42
+ onClick,
43
+ size: "sm",
44
+ testId,
45
+ variant: "light",
46
+ children: [
47
+ /* @__PURE__ */ jsx(FaPlus, {}),
48
+ /* @__PURE__ */ jsx("span", { children: appendButtonText })
49
+ ]
50
+ }
51
+ );
52
+ };
53
+ var ElementAppendButton_default = ElementAppendButton;
54
+
55
+ // src/FieldArray/subcomponents/FieldArrayElement.tsx
56
+ import { useState } from "react";
57
+ import { useSortable as useSortable2 } from "@dnd-kit/sortable";
58
+ import { CSS } from "@dnd-kit/utilities";
59
+ import { AnimatePresence, motion } from "@fuf-stack/pixel-motion";
60
+ import { cn as cn5 } from "@fuf-stack/pixel-utils";
61
+
62
+ // src/FieldArray/subcomponents/ElementActionsMenu.tsx
63
+ import { FaCopy, FaTimes } from "react-icons/fa";
64
+ import { VscInsert } from "react-icons/vsc";
65
+ import { cn as cn2 } from "@fuf-stack/pixel-utils";
66
+ import { Menu } from "@fuf-stack/pixels";
67
+ import { jsx as jsx2 } from "react/jsx-runtime";
68
+ var ElementActionsMenu = ({
69
+ className = void 0,
70
+ duplicate = false,
71
+ insertAfter = false,
72
+ showRemove = true,
73
+ methods,
74
+ testId = void 0
75
+ }) => {
76
+ const handleAction = (key) => {
77
+ switch (key) {
78
+ case "remove":
79
+ methods.remove();
80
+ break;
81
+ case "duplicate":
82
+ methods.duplicate();
83
+ break;
84
+ case "insertAfter":
85
+ methods.insert();
86
+ break;
87
+ default:
88
+ break;
89
+ }
90
+ };
91
+ const menuItems = [];
92
+ if (duplicate) {
93
+ menuItems.push({
94
+ key: "duplicate",
95
+ label: "Duplicate",
96
+ icon: /* @__PURE__ */ jsx2(FaCopy, {})
97
+ });
98
+ }
99
+ if (insertAfter) {
100
+ menuItems.push({
101
+ key: "insertAfter",
102
+ label: "Insert After",
103
+ icon: /* @__PURE__ */ jsx2(VscInsert, {})
104
+ });
105
+ }
106
+ if (showRemove) {
107
+ menuItems.push({
108
+ key: "remove",
109
+ className: "text-danger",
110
+ label: "Remove",
111
+ icon: /* @__PURE__ */ jsx2(FaTimes, {})
112
+ });
113
+ }
114
+ return /* @__PURE__ */ jsx2(
115
+ Menu,
116
+ {
117
+ ariaLabel: "Element actions",
118
+ items: menuItems,
119
+ onAction: handleAction,
120
+ placement: "right",
121
+ testId,
122
+ triggerButtonProps: {
123
+ className: cn2(className),
124
+ disableRipple: true,
125
+ size: "md",
126
+ variant: "light"
127
+ }
128
+ }
129
+ );
130
+ };
131
+ var ElementActionsMenu_default = ElementActionsMenu;
132
+
133
+ // src/FieldArray/subcomponents/ElementRemoveButton.tsx
134
+ import { FaTimes as FaTimes2 } from "react-icons/fa";
135
+ import { cn as cn3 } from "@fuf-stack/pixel-utils";
136
+ import { Button as Button2 } from "@fuf-stack/pixels";
137
+ import { jsx as jsx3 } from "react/jsx-runtime";
138
+ var ElementRemoveButton = ({
139
+ className = void 0,
140
+ onClick,
141
+ testId = void 0
142
+ }) => {
143
+ return /* @__PURE__ */ jsx3(
144
+ Button2,
145
+ {
146
+ ariaLabel: "remove element",
147
+ className: cn3(className),
148
+ color: "danger",
149
+ icon: /* @__PURE__ */ jsx3(FaTimes2, {}),
150
+ onClick,
151
+ size: "sm",
152
+ testId,
153
+ variant: "light"
154
+ }
155
+ );
156
+ };
157
+ var ElementRemoveButton_default = ElementRemoveButton;
158
+
159
+ // src/FieldArray/subcomponents/SortDragHandle.tsx
160
+ import { FaGripVertical } from "react-icons/fa";
161
+ import { useSortable } from "@dnd-kit/sortable";
162
+ import { cn as cn4 } from "@fuf-stack/pixel-utils";
163
+ import { jsx as jsx4 } from "react/jsx-runtime";
164
+ var SortDragHandle = ({
165
+ className = void 0,
166
+ id,
167
+ testId = void 0
168
+ }) => {
169
+ const { attributes, listeners } = useSortable({ id });
170
+ return /* @__PURE__ */ jsx4(
171
+ "div",
172
+ __spreadProps(__spreadValues(__spreadValues({
173
+ className: cn4(className),
174
+ "data-testid": testId
175
+ }, attributes), listeners), {
176
+ children: /* @__PURE__ */ jsx4(FaGripVertical, {})
177
+ })
178
+ );
179
+ };
180
+ var SortDragHandle_default = SortDragHandle;
181
+
182
+ // src/FieldArray/subcomponents/FieldArrayElement.tsx
183
+ import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
184
+ var FieldArrayElement = ({
185
+ children,
186
+ className,
187
+ disableAnimation = false,
188
+ duplicate = false,
189
+ elementMarginBottom: _elementMarginBottom = void 0,
190
+ fields,
191
+ id,
192
+ index: _index,
193
+ insertAfter = false,
194
+ lastNotDeletable = true,
195
+ methods,
196
+ sortable = false,
197
+ testId = void 0
198
+ }) => {
199
+ const { setNodeRef, transform, transition, isDragging } = useSortable2({ id });
200
+ const sortingStyle = sortable ? {
201
+ transform: CSS.Translate.toString(transform),
202
+ transition,
203
+ zIndex: isDragging ? 50 : void 0
204
+ } : void 0;
205
+ const [isVisible, setIsVisible] = useState(true);
206
+ const listItemMotionVariants = {
207
+ hidden: { opacity: 0, height: 0, marginBottom: 0 },
208
+ visible: {
209
+ opacity: 1,
210
+ height: "auto",
211
+ transition: { duration: 0.2, ease: "circOut" },
212
+ // push last visible item down to overlap with append button (hide double border)
213
+ marginBottom: "-1px"
214
+ },
215
+ exit: {
216
+ opacity: 0,
217
+ height: 0,
218
+ marginBottom: 0,
219
+ transition: {
220
+ // on exit first fade out, then shrink
221
+ opacity: { duration: 0.1, ease: "circOut" },
222
+ height: { delay: 0.1, duration: 0.2, ease: "circOut" }
223
+ }
224
+ }
225
+ };
226
+ return /* @__PURE__ */ jsx5(
227
+ AnimatePresence,
228
+ {
229
+ mode: "wait",
230
+ onExitComplete: () => {
231
+ methods.remove();
232
+ },
233
+ children: isVisible ? /* @__PURE__ */ jsx5(
234
+ motion.li,
235
+ {
236
+ ref: setNodeRef,
237
+ animate: disableAnimation ? void 0 : "visible",
238
+ className: cn5(className.listItem),
239
+ "data-dragging": isDragging,
240
+ "data-testid": `${testId}_element`,
241
+ exit: disableAnimation ? void 0 : "exit",
242
+ initial: disableAnimation ? false : "hidden",
243
+ style: sortingStyle,
244
+ variants: disableAnimation ? void 0 : listItemMotionVariants,
245
+ children: /* @__PURE__ */ jsxs2("div", { className: cn5(className.listItemInner), children: [
246
+ sortable ? /* @__PURE__ */ jsx5(
247
+ SortDragHandle_default,
248
+ {
249
+ className: className.sortDragHandle,
250
+ id,
251
+ testId: `${testId}_sort_drag_handle`
252
+ }
253
+ ) : null,
254
+ /* @__PURE__ */ jsx5(
255
+ Grid_default,
256
+ {
257
+ className: cn5(className.elementFieldsGrid),
258
+ testId: `${testId}_element_fields_grid`,
259
+ children
260
+ }
261
+ ),
262
+ duplicate || insertAfter ? /* @__PURE__ */ jsx5(
263
+ ElementActionsMenu_default,
264
+ {
265
+ className: className.actionsMenuButton,
266
+ duplicate,
267
+ insertAfter,
268
+ showRemove: !(lastNotDeletable && fields.length === 1),
269
+ testId: `${testId}_actions_menu`,
270
+ methods: __spreadProps(__spreadValues({}, methods), {
271
+ remove: () => {
272
+ if (disableAnimation) {
273
+ methods.remove();
274
+ } else {
275
+ setIsVisible(false);
276
+ }
277
+ }
278
+ })
279
+ }
280
+ ) : /* @__PURE__ */ jsx5(Fragment, { children: lastNotDeletable && fields.length === 1 ? null : /* @__PURE__ */ jsx5(
281
+ ElementRemoveButton_default,
282
+ {
283
+ className: className.removeButton,
284
+ testId: `${testId}_remove_button`,
285
+ onClick: () => {
286
+ if (disableAnimation) {
287
+ methods.remove();
288
+ } else {
289
+ setIsVisible(false);
290
+ }
291
+ }
292
+ }
293
+ ) })
294
+ ] })
295
+ },
296
+ id
297
+ ) : null
298
+ }
299
+ );
300
+ };
301
+ var FieldArrayElement_default = FieldArrayElement;
302
+
303
+ // src/FieldArray/subcomponents/FieldArrayLabel.tsx
304
+ import { cn as cn6 } from "@fuf-stack/pixel-utils";
305
+ import { jsx as jsx6 } from "react/jsx-runtime";
306
+ var FieldArrayLabel = ({
307
+ className = void 0,
308
+ label: _label,
309
+ name
310
+ }) => {
311
+ var _a;
312
+ const { error, getLabelProps, invalid, label } = useUniformField({
313
+ name,
314
+ showInvalidWhen: "immediate",
315
+ label: _label
316
+ });
317
+ if (!_label) {
318
+ return null;
319
+ }
320
+ const hasErrors = invalid && (error == null ? void 0 : error._errors);
321
+ return /* @__PURE__ */ jsx6(
322
+ "div",
323
+ __spreadProps(__spreadValues({}, getLabelProps()), {
324
+ "aria-level": 3,
325
+ role: "heading",
326
+ className: cn6((_a = getLabelProps()) == null ? void 0 : _a.className, className, {
327
+ // when there are no array level errors, the label should have foreground color
328
+ "text-foreground!": !hasErrors
329
+ }),
330
+ children: label
331
+ })
332
+ );
333
+ };
334
+ var FieldArrayLabel_default = FieldArrayLabel;
335
+
336
+ // src/FieldArray/subcomponents/FieldArrayValidationError.tsx
337
+ import {
338
+ AnimatePresence as AnimatePresence2,
339
+ motion as motion2,
340
+ useReducedMotion
341
+ } from "@fuf-stack/pixel-motion";
342
+ import { cn as cn7 } from "@fuf-stack/pixel-utils";
343
+ import { jsx as jsx7 } from "react/jsx-runtime";
344
+ var FieldArrayValidationError = ({
345
+ name
346
+ }) => {
347
+ var _a;
348
+ const {
349
+ error,
350
+ getErrorMessageProps,
351
+ getHelperWrapperProps,
352
+ invalid,
353
+ testId
354
+ } = useUniformField({
355
+ name,
356
+ showInvalidWhen: "immediate"
357
+ });
358
+ const disableAnimation = useReducedMotion();
359
+ const hasErrors = invalid && (error == null ? void 0 : error._errors);
360
+ return /* @__PURE__ */ jsx7(AnimatePresence2, { initial: !disableAnimation, children: hasErrors ? /* @__PURE__ */ jsx7(
361
+ motion2.div,
362
+ {
363
+ exit: disableAnimation ? void 0 : { opacity: 0, height: 0 },
364
+ initial: disableAnimation ? false : { height: 0, opacity: 0 },
365
+ style: { overflow: "hidden" },
366
+ transition: { duration: 0.2, ease: "circOut" },
367
+ animate: disableAnimation ? void 0 : { opacity: 1, height: "auto" },
368
+ children: /* @__PURE__ */ jsx7(
369
+ "div",
370
+ __spreadProps(__spreadValues({}, getHelperWrapperProps()), {
371
+ className: cn7(
372
+ (_a = getHelperWrapperProps()) == null ? void 0 : _a.className,
373
+ // force helper to be visible (for some reason it's hidden by default) and add padding/rounded corners
374
+ "rounded-b-small block px-3 py-2"
375
+ ),
376
+ children: /* @__PURE__ */ jsx7("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: /* @__PURE__ */ jsx7(
377
+ FieldValidationError_default,
378
+ {
379
+ error: error._errors,
380
+ testId
381
+ }
382
+ ) }))
383
+ })
384
+ )
385
+ },
386
+ "field-array-errors"
387
+ ) : null });
388
+ };
389
+ var FieldArrayValidationError_default = FieldArrayValidationError;
390
+
391
+ // src/FieldArray/subcomponents/SortContext.tsx
392
+ import {
393
+ closestCenter,
394
+ DndContext,
395
+ KeyboardSensor,
396
+ PointerSensor,
397
+ useSensor,
398
+ useSensors
399
+ } from "@dnd-kit/core";
400
+ import {
401
+ restrictToVerticalAxis,
402
+ restrictToWindowEdges
403
+ } from "@dnd-kit/modifiers";
404
+ import {
405
+ SortableContext,
406
+ verticalListSortingStrategy
407
+ } from "@dnd-kit/sortable";
408
+ import { jsx as jsx8 } from "react/jsx-runtime";
409
+ var SortContext = ({
410
+ children,
411
+ sortable,
412
+ fields,
413
+ move
414
+ }) => {
415
+ const sensors = useSensors(
416
+ useSensor(PointerSensor),
417
+ useSensor(KeyboardSensor)
418
+ );
419
+ if (!sortable) {
420
+ return children;
421
+ }
422
+ const handleDragEnd = (event) => {
423
+ const { active, over } = event;
424
+ if (active.id !== (over == null ? void 0 : over.id)) {
425
+ const oldIndex = fields.findIndex((field) => {
426
+ return field.id === active.id;
427
+ });
428
+ const newIndex = fields.findIndex((field) => {
429
+ return field.id === (over == null ? void 0 : over.id);
430
+ });
431
+ move(oldIndex, newIndex);
432
+ }
433
+ };
434
+ return /* @__PURE__ */ jsx8(
435
+ DndContext,
436
+ {
437
+ collisionDetection: closestCenter,
438
+ modifiers: [restrictToVerticalAxis, restrictToWindowEdges],
439
+ onDragEnd: handleDragEnd,
440
+ sensors,
441
+ children: /* @__PURE__ */ jsx8(
442
+ SortableContext,
443
+ {
444
+ strategy: verticalListSortingStrategy,
445
+ items: fields.map((field) => {
446
+ return field.id;
447
+ }),
448
+ children
449
+ }
450
+ )
451
+ }
452
+ );
453
+ };
454
+ var SortContext_default = SortContext;
455
+
456
+ // src/FieldArray/FieldArray.tsx
457
+ import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
458
+ var fieldArrayVariants = tv({
459
+ slots: {
460
+ /** base class for the field array wrapper */
461
+ base: [
462
+ // base styles
463
+ "rounded-small border-divider bg-content1 overflow-hidden border",
464
+ // divider between items
465
+ "divide-divider divide-y"
466
+ ],
467
+ /** class for the actions menu button */
468
+ actionsMenuButton: [
469
+ // base styles
470
+ "text-default-600 flex items-center justify-center",
471
+ // fixed height/no round corners/center align
472
+ "h-full rounded-none"
473
+ ],
474
+ /** class for the append button */
475
+ appendButton: [
476
+ // base styles
477
+ "rounded-b-small w-full rounded-t-none",
478
+ // match label height (p-3 = 12px vertical padding + text-base line height)
479
+ "!h-[48px] !min-h-0",
480
+ // focus styles - inset ring with rounded bottom corners to match container
481
+ "focus-visible:ring-focus outline-none focus-visible:ring-2 focus-visible:ring-inset"
482
+ ],
483
+ /** class for the element fields grid */
484
+ elementFieldsGrid: ["w-full grow p-3"],
485
+ /** class for the label */
486
+ label: [
487
+ // override HeroUI label positioning and display
488
+ "pointer-events-auto! static! z-auto! block! w-full!",
489
+ // reset any transforms or translations
490
+ "translate-x-0! translate-y-0! transform-none!",
491
+ // card header styling - use text-medium (16px) instead of text-base for correct 48px height
492
+ "rounded-t-small text-medium p-3 font-semibold"
493
+ ],
494
+ /** class for the list */
495
+ list: ["overflow-hidden"],
496
+ /** class for the list wrapper */
497
+ listWrapper: ["overflow-hidden"],
498
+ /** class for the list item (performs motion animations) */
499
+ listItem: [
500
+ // base styles
501
+ "group relative flex flex-row",
502
+ // overlap borders by shifting first item up 1px (similar to how last item overlaps with append button)
503
+ "first:-mt-px"
504
+ ],
505
+ /** class for the list item inner */
506
+ listItemInner: [
507
+ // base styles
508
+ "bg-content1 divide-divider flex w-full flex-row items-stretch",
509
+ // x division and borders
510
+ "border-divider divide-x divide-solid border-t border-b"
511
+ ],
512
+ /** class for the remove button */
513
+ removeButton: [
514
+ // base styles
515
+ "flex items-center justify-center",
516
+ // fixed height/no round corners
517
+ "!h-full !min-h-0 !rounded-none px-3",
518
+ // focus styles - inset ring
519
+ "focus-visible:ring-focus outline-none focus-visible:ring-2 focus-visible:ring-inset"
520
+ ],
521
+ /** class for the sort drag handle */
522
+ sortDragHandle: [
523
+ // base styles
524
+ "text-default-600 flex cursor-grab items-center justify-center px-2 transition-colors",
525
+ // hover and dragging state
526
+ "hover:bg-default-100 group-data-[dragging=true]:bg-default-100 active:cursor-grabbing",
527
+ // focus styles - inset ring
528
+ "focus-visible:ring-focus outline-none focus-visible:ring-2 focus-visible:ring-inset"
529
+ ]
530
+ },
531
+ variants: {
532
+ hasLabel: {
533
+ false: {
534
+ // focus styles - when there is no label, the first item actions menu button should have rounded top right corners
535
+ actionsMenuButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
536
+ // focus styles - when there is no label, the first item remove button focus ring should have rounded top right corners
537
+ removeButton: "group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none",
538
+ // focus styles - when there is no label, the first item sort drag handle focus ring should have rounded top left corners
539
+ sortDragHandle: "group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none"
540
+ }
541
+ }
542
+ }
543
+ });
544
+ var FieldArray = (_a) => {
545
+ var _b = _a, {
546
+ appendButtonText = "Add Element",
547
+ children,
548
+ className: _className = void 0,
549
+ duplicate = false,
550
+ elementInitialValue: _elementInitialValue = null,
551
+ elementMarginBottom = void 0,
552
+ flat = false,
553
+ insertAfter = false,
554
+ lastElementNotRemovable = false,
555
+ name,
556
+ sortable = false
557
+ } = _b, uniformFieldProps = __objRest(_b, [
558
+ "appendButtonText",
559
+ "children",
560
+ "className",
561
+ "duplicate",
562
+ "elementInitialValue",
563
+ "elementMarginBottom",
564
+ "flat",
565
+ "insertAfter",
566
+ "lastElementNotRemovable",
567
+ "name",
568
+ "sortable"
569
+ ]);
570
+ const { control, error, getValues, invalid, testId } = useUniformField(__spreadValues({
571
+ name,
572
+ showInvalidWhen: "immediate"
573
+ }, uniformFieldProps));
574
+ const { fields, append, remove, insert, move } = useFieldArray({
575
+ control,
576
+ name
577
+ });
578
+ const { trigger } = useFormContext();
579
+ useEffect(() => {
580
+ setTimeout(() => {
581
+ trigger(name);
582
+ }, 200);
583
+ }, [fields.length]);
584
+ const elementInitialValue = flat ? { [flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
585
+ const prefersReducedMotion = useReducedMotion2();
586
+ const disableAnimationRef = useRef(true);
587
+ useEffect(() => {
588
+ if (!prefersReducedMotion) {
589
+ disableAnimationRef.current = false;
590
+ }
591
+ }, [prefersReducedMotion]);
592
+ if (lastElementNotRemovable && fields.length === 0) {
593
+ append(elementInitialValue);
594
+ }
595
+ const variants = fieldArrayVariants({ hasLabel: !!uniformFieldProps.label });
596
+ const className = variantsToClassNames(variants, _className, "base");
597
+ return /* @__PURE__ */ jsxs3("div", { className: className.base, children: [
598
+ /* @__PURE__ */ jsx9(
599
+ FieldArrayLabel_default,
600
+ {
601
+ className: className.label,
602
+ label: uniformFieldProps.label,
603
+ name
604
+ }
605
+ ),
606
+ fields.length ? (
607
+ /* list wrapper */
608
+ /* @__PURE__ */ jsx9("div", { className: cn8(className.listWrapper), children: /* @__PURE__ */ jsx9(SortContext_default, { fields, move, sortable, children: /* @__PURE__ */ jsx9("ul", { className: className.list, "data-testid": testId, children: fields.map((field, index) => {
609
+ const elementName = flat ? `${name}.${index}.${flatArrayKey}` : `${name}.${index}`;
610
+ const elementTestId = `${testId}_${index}`;
611
+ const elementMethods = {
612
+ append: () => {
613
+ append(elementInitialValue);
614
+ },
615
+ duplicate: () => {
616
+ const values = getValues(name);
617
+ const currentValue = values[index];
618
+ const nextValue = flat ? { [flatArrayKey]: currentValue } : currentValue;
619
+ insert(index + 1, nextValue);
620
+ },
621
+ insert: () => {
622
+ insert(index + 1, elementInitialValue);
623
+ },
624
+ remove: () => {
625
+ remove(index);
626
+ }
627
+ };
628
+ return /* @__PURE__ */ jsx9(
629
+ FieldArrayElement_default,
630
+ {
631
+ className,
632
+ disableAnimation: disableAnimationRef.current,
633
+ duplicate,
634
+ elementMarginBottom,
635
+ fields,
636
+ id: field.id,
637
+ index,
638
+ insertAfter,
639
+ lastNotDeletable: lastElementNotRemovable,
640
+ methods: elementMethods,
641
+ sortable,
642
+ testId: elementTestId,
643
+ children: children({
644
+ index,
645
+ length: fields.length,
646
+ methods: elementMethods,
647
+ name: elementName,
648
+ testId: elementTestId
649
+ })
650
+ },
651
+ field.id
652
+ );
653
+ }) }) }) })
654
+ ) : null,
655
+ /* @__PURE__ */ jsx9(
656
+ ElementAppendButton_default,
657
+ {
658
+ appendButtonText,
659
+ testId: `${testId}_append_button`,
660
+ className: cn8(
661
+ className.appendButton,
662
+ // only round bottom corners if there are no errors below
663
+ // @ts-expect-error - error._errors exists but not typed
664
+ // eslint-disable-next-line no-underscore-dangle
665
+ { "rounded-none": invalid && (error == null ? void 0 : error._errors) }
666
+ ),
667
+ onClick: () => {
668
+ append(elementInitialValue);
669
+ }
670
+ }
671
+ ),
672
+ /* @__PURE__ */ jsx9(FieldArrayValidationError_default, { name })
673
+ ] });
674
+ };
675
+ var FieldArray_default = FieldArray;
676
+
677
+ // src/FieldArray/index.ts
678
+ var FieldArray_default2 = FieldArray_default;
679
+
680
+ export {
681
+ FieldArray_default,
682
+ FieldArray_default2
683
+ };
684
+ //# sourceMappingURL=chunk-GST3AQOR.js.map