@fuf-stack/uniform 2.0.0-next.1 → 2.0.0-next.4

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 (161) hide show
  1. package/dist/Checkboxes/index.d.mts +47 -27
  2. package/dist/Checkboxes/index.d.mts.map +1 -1
  3. package/dist/Checkboxes/index.mjs +26 -25
  4. package/dist/Checkboxes/index.mjs.map +1 -1
  5. package/dist/DatePicker/index.d.mts +63 -86
  6. package/dist/DatePicker/index.d.mts.map +1 -1
  7. package/dist/DatePicker/index.mjs +43 -49
  8. package/dist/DatePicker/index.mjs.map +1 -1
  9. package/dist/FieldArray/index.d.mts +8 -16
  10. package/dist/FieldArray/index.d.mts.map +1 -1
  11. package/dist/FieldArray/index.mjs +25 -37
  12. package/dist/FieldArray/index.mjs.map +1 -1
  13. package/dist/FieldCard/index.d.mts +0 -4
  14. package/dist/FieldCard/index.d.mts.map +1 -1
  15. package/dist/FieldCard/index.mjs +14 -25
  16. package/dist/FieldCard/index.mjs.map +1 -1
  17. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +3 -5
  18. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs.map → FieldCopyTestIdButton-D3_jZYJ1.mjs.map} +1 -1
  19. package/dist/FieldHelper-B1DWl7eu.mjs +38 -0
  20. package/dist/FieldHelper-B1DWl7eu.mjs.map +1 -0
  21. package/dist/FieldLabel-DMTqq0Jj.mjs +29 -0
  22. package/dist/FieldLabel-DMTqq0Jj.mjs.map +1 -0
  23. package/dist/{FieldLayout-BLW5S-Jm.mjs → FieldLayout-C9MEBZAC.mjs} +11 -19
  24. package/dist/FieldLayout-C9MEBZAC.mjs.map +1 -0
  25. package/dist/FieldReset/index.d.mts +420 -0
  26. package/dist/FieldReset/index.d.mts.map +1 -0
  27. package/dist/FieldReset/index.mjs +258 -0
  28. package/dist/FieldReset/index.mjs.map +1 -0
  29. package/dist/{FieldValidationError-DgkCL3cC.mjs → FieldValidationError-BuLvuRyi.mjs} +5 -7
  30. package/dist/FieldValidationError-BuLvuRyi.mjs.map +1 -0
  31. package/dist/Form/index.d.mts +12 -14
  32. package/dist/Form/index.d.mts.map +1 -1
  33. package/dist/Form/index.mjs +7 -10
  34. package/dist/Form/index.mjs.map +1 -1
  35. package/dist/FormContext-BnNJYZOo.d.mts +124 -0
  36. package/dist/FormContext-BnNJYZOo.d.mts.map +1 -0
  37. package/dist/{FormContext-CHctWFAP.mjs → FormContext-PXkVlBdU.mjs} +5 -9
  38. package/dist/{FormContext-CHctWFAP.mjs.map → FormContext-PXkVlBdU.mjs.map} +1 -1
  39. package/dist/Grid/index.d.mts +0 -2
  40. package/dist/Grid/index.d.mts.map +1 -1
  41. package/dist/Grid/index.mjs +1 -1
  42. package/dist/{Grid-DfcZeuib.mjs → Grid-DBL29Kwb.mjs} +3 -5
  43. package/dist/{Grid-DfcZeuib.mjs.map → Grid-DBL29Kwb.mjs.map} +1 -1
  44. package/dist/Input/index.d.mts +610 -393
  45. package/dist/Input/index.d.mts.map +1 -1
  46. package/dist/Input/index.mjs +24 -31
  47. package/dist/Input/index.mjs.map +1 -1
  48. package/dist/RadioBoxes/index.d.mts +247 -2227
  49. package/dist/RadioBoxes/index.d.mts.map +1 -1
  50. package/dist/RadioBoxes/index.mjs +25 -37
  51. package/dist/RadioBoxes/index.mjs.map +1 -1
  52. package/dist/RadioTabs/index.d.mts +599 -289
  53. package/dist/RadioTabs/index.d.mts.map +1 -1
  54. package/dist/RadioTabs/index.mjs +24 -27
  55. package/dist/RadioTabs/index.mjs.map +1 -1
  56. package/dist/Radios/index.d.mts +164 -2077
  57. package/dist/Radios/index.d.mts.map +1 -1
  58. package/dist/Radios/index.mjs +12 -23
  59. package/dist/Radios/index.mjs.map +1 -1
  60. package/dist/Select/index.d.mts +809 -484
  61. package/dist/Select/index.d.mts.map +1 -1
  62. package/dist/Select/index.mjs +69 -54
  63. package/dist/Select/index.mjs.map +1 -1
  64. package/dist/Slider/index.d.mts +657 -281
  65. package/dist/Slider/index.d.mts.map +1 -1
  66. package/dist/Slider/index.mjs +42 -42
  67. package/dist/Slider/index.mjs.map +1 -1
  68. package/dist/SubmitButton/index.d.mts +0 -2
  69. package/dist/SubmitButton/index.d.mts.map +1 -1
  70. package/dist/SubmitButton/index.mjs +2 -4
  71. package/dist/SubmitButton/index.mjs.map +1 -1
  72. package/dist/Switch/index.d.mts +1 -1
  73. package/dist/Switch/index.mjs +25 -32
  74. package/dist/Switch/index.mjs.map +1 -1
  75. package/dist/Switch-aBYStBoY.d.mts +990 -0
  76. package/dist/Switch-aBYStBoY.d.mts.map +1 -0
  77. package/dist/SwitchBox/index.d.mts +606 -201
  78. package/dist/SwitchBox/index.d.mts.map +1 -1
  79. package/dist/SwitchBox/index.mjs +29 -33
  80. package/dist/SwitchBox/index.mjs.map +1 -1
  81. package/dist/TextArea/index.d.mts +565 -185
  82. package/dist/TextArea/index.d.mts.map +1 -1
  83. package/dist/TextArea/index.mjs +18 -23
  84. package/dist/TextArea/index.mjs.map +1 -1
  85. package/dist/Time/index.d.mts +60 -44
  86. package/dist/Time/index.d.mts.map +1 -1
  87. package/dist/Time/index.mjs +27 -36
  88. package/dist/Time/index.mjs.map +1 -1
  89. package/dist/fieldHelperVariants-ClP8taiS.mjs +20 -0
  90. package/dist/fieldHelperVariants-ClP8taiS.mjs.map +1 -0
  91. package/dist/fieldLabelVariants-C4ZqECec.mjs +13 -0
  92. package/dist/fieldLabelVariants-C4ZqECec.mjs.map +1 -0
  93. package/dist/{FieldDescription-C4l0HKGL.mjs → fieldProps-DWfz2jSO.mjs} +5 -17
  94. package/dist/fieldProps-DWfz2jSO.mjs.map +1 -0
  95. package/dist/helpers/index.d.mts +0 -6
  96. package/dist/helpers/index.d.mts.map +1 -1
  97. package/dist/helpers/index.mjs +3 -6
  98. package/dist/helpers/index.mjs.map +1 -1
  99. package/dist/hooks/useClientValidation/index.d.mts +0 -2
  100. package/dist/hooks/useClientValidation/index.d.mts.map +1 -1
  101. package/dist/hooks/useClientValidation/index.mjs +3 -5
  102. package/dist/hooks/useController/index.d.mts +0 -2
  103. package/dist/hooks/useController/index.d.mts.map +1 -1
  104. package/dist/hooks/useController/index.mjs +2 -3
  105. package/dist/hooks/useFormContext/index.d.mts +31 -52
  106. package/dist/hooks/useFormContext/index.d.mts.map +1 -1
  107. package/dist/hooks/useFormContext/index.mjs +2 -3
  108. package/dist/hooks/useInputValueDebounce/index.d.mts +0 -2
  109. package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
  110. package/dist/hooks/useInputValueDebounce/index.mjs +3 -5
  111. package/dist/hooks/useInputValueTransform/index.d.mts +1 -1
  112. package/dist/hooks/useInputValueTransform/index.mjs +2 -3
  113. package/dist/hooks/useWatchFormReset/index.d.mts +0 -2
  114. package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -1
  115. package/dist/hooks/useWatchFormReset/index.mjs +3 -5
  116. package/dist/hooks/useWatchUserChange/index.d.mts +0 -2
  117. package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
  118. package/dist/hooks/useWatchUserChange/index.mjs +3 -5
  119. package/dist/{index-BS8IoBOn.d.mts → index-cevZBrIN.d.mts} +1 -3
  120. package/dist/index-cevZBrIN.d.mts.map +1 -0
  121. package/dist/partials/FieldCopyTestIdButton/index.d.mts +0 -2
  122. package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -1
  123. package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
  124. package/dist/{Switch-CvPO8IF9.d.mts → partials/FieldHelper/index.d.mts} +309 -361
  125. package/dist/partials/FieldHelper/index.d.mts.map +1 -0
  126. package/dist/partials/FieldHelper/index.mjs +7 -0
  127. package/dist/partials/FieldHelper/index.mjs.map +1 -0
  128. package/dist/partials/FieldLabel/index.d.mts +160 -0
  129. package/dist/partials/FieldLabel/index.d.mts.map +1 -0
  130. package/dist/partials/FieldLabel/index.mjs +7 -0
  131. package/dist/partials/FieldLabel/index.mjs.map +1 -0
  132. package/dist/partials/FieldValidationError/index.d.mts +13 -15
  133. package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
  134. package/dist/partials/FieldValidationError/index.mjs +1 -1
  135. package/dist/{radioControlVariants-Cm6WufWo.mjs → radioControlVariants-CbtG5U4_.mjs} +28 -25
  136. package/dist/radioControlVariants-CbtG5U4_.mjs.map +1 -0
  137. package/dist/{switchVariants-BaQw2DA7.mjs → switchVariants-0Xa7TQYg.mjs} +8 -11
  138. package/dist/switchVariants-0Xa7TQYg.mjs.map +1 -0
  139. package/dist/{timeVariants-B9HDfNYt.mjs → timeVariants-Bkt4iwXx.mjs} +14 -12
  140. package/dist/timeVariants-Bkt4iwXx.mjs.map +1 -0
  141. package/dist/{useController-BCFeZbBZ.mjs → useController-JtIeurpw.mjs} +3 -4
  142. package/dist/{useController-BCFeZbBZ.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
  143. package/dist/{useFormContext-BPjJjNnM.mjs → useFormContext-piqnN2L-.mjs} +3 -4
  144. package/dist/useFormContext-piqnN2L-.mjs.map +1 -0
  145. package/dist/{useInputValueTransform-Mw8YEOXT.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -3
  146. package/dist/{useInputValueTransform-Mw8YEOXT.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
  147. package/dist/{FieldLabel-DKzqkuY1.mjs → useUniformField-TTNPTsVn.mjs} +15 -37
  148. package/dist/useUniformField-TTNPTsVn.mjs.map +1 -0
  149. package/package.json +10 -7
  150. package/dist/FieldDescription-C4l0HKGL.mjs.map +0 -1
  151. package/dist/FieldLabel-DKzqkuY1.mjs.map +0 -1
  152. package/dist/FieldLayout-BLW5S-Jm.mjs.map +0 -1
  153. package/dist/FieldValidationError-DgkCL3cC.mjs.map +0 -1
  154. package/dist/FormContext-CsFiNvuJ.d.mts +0 -19
  155. package/dist/FormContext-CsFiNvuJ.d.mts.map +0 -1
  156. package/dist/Switch-CvPO8IF9.d.mts.map +0 -1
  157. package/dist/index-BS8IoBOn.d.mts.map +0 -1
  158. package/dist/radioControlVariants-Cm6WufWo.mjs.map +0 -1
  159. package/dist/switchVariants-BaQw2DA7.mjs.map +0 -1
  160. package/dist/timeVariants-B9HDfNYt.mjs.map +0 -1
  161. package/dist/useFormContext-BPjJjNnM.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":["JSX"],"sources":["../../src/FieldArray/fieldArrayVariants.ts","../../src/hooks/useUniformFieldArray/types.ts","../../src/FieldArray/types.ts","../../src/FieldArray/FieldArray.tsx"],"mappings":";;;qBAIa,sBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FnB,eAAe,eAAe;KAE9B,YAAY,mBAAmB;;;UClG1B;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;IAEE;;IAEA;;IAEA,SAAS;;IAET;;IAEA;;;;;;KCtBQ,8BACV,MAAM,kCACHA,MAAI;UAEQ;;EAEf;;EAEA;;EAEA;;;;UCLe,wBAAwB,oBAAoB;;EAE3D;;EAEA,UAAU;;EAEV,YAAY;EAEZ;EAKA,sBAAsB;;EAEtB;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;cAII,eAAc,kBAAA,UAAA,WAAA,YAAA,WAAA,qBAAA,sBAAA,qBAAA,MAAA,aAAA,yBAAA,MAAA,aAAA,qBAajB,oCAAe,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/FieldArray/fieldArrayVariants.ts","../../src/hooks/useUniformFieldArray/types.ts","../../src/FieldArray/types.ts","../../src/FieldArray/FieldArray.tsx"],"mappings":";;qBAIa,sBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4FnB,eAAe,eAAe;KAE9B,YAAY,mBAAmB;UClG1B;;EAEf;;EAEA;;EAEA;;EAEA;;;UAIe;;EAEf;;EAEA;;IAEE;;IAEA;;IAEA,SAAS;;IAET;;IAEA;;;;KCtBQ,8BACV,MAAM,kCACH,IAAI;UAEQ;;EAEf;;EAEA;;EAEA;;UCLe,wBAAwB,oBAAoB;;EAE3D;;EAEA,UAAU;;EAEV,YAAY;EAEZ;EAKA,sBAAsB;;EAEtB;;EAEA,QAAQ;;EAER;;EAEA;;EAEA;;;cAII,eAAc,kBAAA,UAAA,WAAA,YAAA,WAAA,qBAAA,sBAAA,qBAAA,MAAA,aAAA,yBAAA,MAAA,aAAA,qBAajB,oCAAe,IAAA"}
@@ -1,9 +1,11 @@
1
1
  import { flatArrayKey, isValueEmpty } from "../helpers/index.mjs";
2
- import { n as FieldValidationError } from "../FieldValidationError-DgkCL3cC.mjs";
3
- import { n as useFormContext$1 } from "../useFormContext-BPjJjNnM.mjs";
4
- import { n as useUniformField, t as FieldLabel } from "../FieldLabel-DKzqkuY1.mjs";
2
+ import { n as useFormContext$1 } from "../useFormContext-piqnN2L-.mjs";
3
+ import { t as useUniformField } from "../useUniformField-TTNPTsVn.mjs";
5
4
  import { useWatchFormReset } from "../hooks/useWatchFormReset/index.mjs";
6
- import { t as Grid_default } from "../Grid-DfcZeuib.mjs";
5
+ import { t as Grid_default } from "../Grid-DBL29Kwb.mjs";
6
+ import { t as FieldLabel } from "../FieldLabel-DMTqq0Jj.mjs";
7
+ import { n as FieldValidationError } from "../FieldValidationError-BuLvuRyi.mjs";
8
+ import { t as fieldHelperVariants } from "../fieldHelperVariants-ClP8taiS.mjs";
7
9
  import { useEffect, useId, useMemo, useRef, useState } from "react";
8
10
  import { Button, Menu } from "@fuf-stack/pixels";
9
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -17,7 +19,7 @@ import { CSS } from "@dnd-kit/utilities";
17
19
  import { VscInsert } from "react-icons/vsc";
18
20
  import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
19
21
  import { restrictToVerticalAxis, restrictToWindowEdges } from "@dnd-kit/modifiers";
20
- //#region src/hooks/useUniformFieldArray/useUniformFieldArray.ts
22
+ // src/hooks/useUniformFieldArray/useUniformFieldArray.ts
21
23
  /**
22
24
  * Enhanced useFieldArray hook with initialization and animation logic.
23
25
  * Based on React Hook Form's useFieldArray with additional features:
@@ -144,8 +146,7 @@ const useUniformFieldArray = (params) => {
144
146
  });
145
147
  return useUniformFieldArrayMethods(params, field);
146
148
  };
147
- //#endregion
148
- //#region src/FieldArray/fieldArrayVariants.ts
149
+ // src/FieldArray/fieldArrayVariants.ts
149
150
  const fieldArrayVariants = tv({
150
151
  slots: {
151
152
  /** class for the actions menu button */
@@ -197,8 +198,7 @@ const fieldArrayVariants = tv({
197
198
  sortDragHandle: "group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none"
198
199
  } } }
199
200
  });
200
- //#endregion
201
- //#region src/FieldArray/subcomponents/ElementAppendButton.tsx
201
+ // src/FieldArray/subcomponents/ElementAppendButton.tsx
202
202
  const ElementAppendButton = ({ appendButtonText = "Add Element", className = void 0, onClick, testId = void 0 }) => {
203
203
  const { cn } = useStyling();
204
204
  return /* @__PURE__ */ jsxs(Button, {
@@ -211,8 +211,7 @@ const ElementAppendButton = ({ appendButtonText = "Add Element", className = voi
211
211
  children: [/* @__PURE__ */ jsx(FaPlus, {}), /* @__PURE__ */ jsx("span", { children: appendButtonText })]
212
212
  });
213
213
  };
214
- //#endregion
215
- //#region src/FieldArray/subcomponents/ElementActionsMenu.tsx
214
+ // src/FieldArray/subcomponents/ElementActionsMenu.tsx
216
215
  /**
217
216
  * Menu component for field array element actions (remove, duplicate, insert after)
218
217
  */
@@ -260,8 +259,7 @@ const ElementActionsMenu = ({ className = void 0, duplicate = false, insertAfter
260
259
  }
261
260
  });
262
261
  };
263
- //#endregion
264
- //#region src/FieldArray/subcomponents/ElementRemoveButton.tsx
262
+ // src/FieldArray/subcomponents/ElementRemoveButton.tsx
265
263
  const ElementRemoveButton = ({ className = void 0, disableAnimation = false, onClick, testId = void 0 }) => {
266
264
  const { cn } = useStyling();
267
265
  const button = /* @__PURE__ */ jsx(Button, {
@@ -293,8 +291,7 @@ const ElementRemoveButton = ({ className = void 0, disableAnimation = false, onC
293
291
  children: button
294
292
  });
295
293
  };
296
- //#endregion
297
- //#region src/FieldArray/subcomponents/SortDragHandle.tsx
294
+ // src/FieldArray/subcomponents/SortDragHandle.tsx
298
295
  /**
299
296
  * Drag handle component that integrates with dnd-kit sortable functionality.
300
297
  * Renders a vertical grip icon that can be used to reorder items.
@@ -311,8 +308,7 @@ const SortDragHandle = ({ className = void 0, id, testId = void 0 }) => {
311
308
  children: /* @__PURE__ */ jsx(FaGripVertical, {})
312
309
  });
313
310
  };
314
- //#endregion
315
- //#region src/FieldArray/subcomponents/FieldArrayElement.tsx
311
+ // src/FieldArray/subcomponents/FieldArrayElement.tsx
316
312
  /**
317
313
  * Form array element component using react-hook-form with drag-drop sorting
318
314
  * and validation capabilities. Animations when elements are added or removed
@@ -413,8 +409,7 @@ const FieldArrayElement = ({ children, className, disableAnimation = false, dupl
413
409
  }, id) : null
414
410
  });
415
411
  };
416
- //#endregion
417
- //#region src/FieldArray/subcomponents/FieldArrayLabel.tsx
412
+ // src/FieldArray/subcomponents/FieldArrayLabel.tsx
418
413
  /**
419
414
  * Renders the label for a FieldArray component.
420
415
  *
@@ -436,16 +431,14 @@ const FieldArrayLabel = ({ className = void 0, id = void 0, label, invalid, requ
436
431
  children: label
437
432
  });
438
433
  };
439
- //#endregion
440
- //#region src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts
441
- const fieldArrayValidationErrorVariants = tv({ slots: {
442
- /** Container for array-level validation messages */
443
- errorMessage: "text-danger text-tiny",
434
+ // src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts
435
+ const fieldArrayValidationErrorVariants = tv({
436
+ extend: fieldHelperVariants,
437
+ slots: {
444
438
  /** Padded footer containing array-level validation */
445
- helperWrapper: ["relative flex-col gap-1.5", "block px-3 pb-2 pt-1"]
446
- } });
447
- //#endregion
448
- //#region src/FieldArray/subcomponents/FieldArrayValidationError.tsx
439
+ helperWrapper: "px-3 pb-2 pt-1" }
440
+ });
441
+ // src/FieldArray/subcomponents/FieldArrayValidationError.tsx
449
442
  /**
450
443
  * Renders array-level validation errors for FieldArray.
451
444
  *
@@ -495,8 +488,7 @@ const FieldArrayValidationError = ({ error, ids, invalid, testId }) => {
495
488
  }, "field-array-errors") : null
496
489
  });
497
490
  };
498
- //#endregion
499
- //#region src/FieldArray/subcomponents/SortContext.tsx
491
+ // src/FieldArray/subcomponents/SortContext.tsx
500
492
  /**
501
493
  * A wrapper component that provides drag-and-drop sorting functionality for field arrays
502
494
  * using dnd-kit and react-hook-form.
@@ -534,8 +526,7 @@ const SortContext = ({ children, fields, move, sortable }) => {
534
526
  })
535
527
  });
536
528
  };
537
- //#endregion
538
- //#region src/FieldArray/subcomponents/FieldArrayControl.tsx
529
+ // src/FieldArray/subcomponents/FieldArrayControl.tsx
539
530
  /** Array group presentation with row controls, sorting and validation messages */
540
531
  const FieldArrayControl = ({ field, appendButtonText, children, className, disableAnimation, duplicate, elementMarginBottom, fields, items, insertAfter, lastElementNotRemovable, onAppend, onMove, sortable = false }) => {
541
532
  const { error, ids, invalid, name, required, testId } = field;
@@ -604,8 +595,7 @@ const FieldArrayControl = ({ field, appendButtonText, children, className, disab
604
595
  ]
605
596
  });
606
597
  };
607
- //#endregion
608
- //#region src/FieldArray/FieldArray.tsx
598
+ // src/FieldArray/FieldArray.tsx
609
599
  /** Form field group for adding, removing and reordering array entries */
610
600
  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 }) => {
611
601
  const { field, fields, appendItem, items, moveItem, disableAnimation } = useUniformFieldArray({
@@ -632,10 +622,8 @@ const FieldArray = ({ appendButtonText = "Add Element", children, className: _cl
632
622
  children
633
623
  });
634
624
  };
635
- //#endregion
636
- //#region src/FieldArray/index.ts
625
+ // src/FieldArray/index.ts
637
626
  var FieldArray_default = FieldArray;
638
- //#endregion
639
627
  export { FieldArray_default as default, fieldArrayVariants };
640
628
 
641
629
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["useRHFFieldArray","useFormContext","Grid"],"sources":["../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../src/FieldArray/fieldArrayVariants.ts","../../src/FieldArray/subcomponents/ElementAppendButton.tsx","../../src/FieldArray/subcomponents/ElementActionsMenu.tsx","../../src/FieldArray/subcomponents/ElementRemoveButton.tsx","../../src/FieldArray/subcomponents/SortDragHandle.tsx","../../src/FieldArray/subcomponents/FieldArrayElement.tsx","../../src/FieldArray/subcomponents/FieldArrayLabel.tsx","../../src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts","../../src/FieldArray/subcomponents/FieldArrayValidationError.tsx","../../src/FieldArray/subcomponents/SortContext.tsx","../../src/FieldArray/subcomponents/FieldArrayControl.tsx","../../src/FieldArray/FieldArray.tsx","../../src/FieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n FieldArray as ArrayElement,\n ArrayPath,\n FieldValues,\n Path,\n} from 'react-hook-form';\nimport type { UniformFieldState } from '../useUniformField/types';\nimport type { FieldArrayElementMethods, FieldArrayItem } from './types';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport useUniformField from '../useUniformField/useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Disable the field */\n disabled?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArrayMethods = <\n TFieldValues extends FieldValues = FieldValues,\n>(\n {\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n }: UseUniformFieldArrayProps<TFieldValues>,\n uniformField: UniformFieldState<TFieldValues>,\n) => {\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n const { testId } = uniformField.field;\n\n // bind row identification and operations for the renderer\n const items: FieldArrayItem[] = fields.map((row, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n const methods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n },\n duplicate: () => {\n const values = getValues(name as Path<TFieldValues>);\n const currentValue = (values as unknown as unknown[])[index];\n\n insert(\n index + 1,\n (flat\n ? { [flatArrayKey]: currentValue }\n : currentValue) as ArrayElement<TFieldValues>,\n );\n },\n insert: () => {\n insert(index + 1, elementInitialValue as ArrayElement<TFieldValues>);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return {\n id: row.id,\n renderProps: {\n index,\n length: fields.length,\n methods,\n name: elementName,\n testId: elementTestId,\n },\n };\n });\n\n // append an element using the configured initial value\n const appendItem = () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n };\n\n // validate the array after its row order changes\n const moveItem = (from: number, to: number) => {\n move(from, to);\n trigger(name as Path<TFieldValues>);\n };\n\n return {\n // Field array methods and state\n fields,\n append,\n appendItem,\n items,\n remove,\n insert,\n move,\n moveItem,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n\nconst useUniformFieldArray = <TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldArrayProps<TFieldValues>,\n) => {\n const field = useUniformField<TFieldValues>({\n ...params,\n name: params.name as Path<TFieldValues> & string,\n });\n return useUniformFieldArrayMethods(params, field);\n};\nexport default useUniformFieldArray;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nexport const fieldArrayVariants = tv({\n slots: {\n /** class for the actions menu button */\n actionsMenuButton: [\n // base styles\n 'flex items-center justify-center text-default-600',\n // fixed height/no round corners/center align\n 'h-full rounded-none',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the append button */\n appendButton: [\n // base styles\n 'w-full justify-start rounded-b-small rounded-t-none font-semibold',\n // match label height (p-3 = 12px vertical padding + text-base line height)\n '!h-[48px] !min-h-0',\n // focus styles - inset ring with rounded bottom corners to match container\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** base class for the field array wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border border-divider bg-content1',\n // divider between items\n 'divide-y divide-divider',\n ],\n /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) instead of text-base for correct 48px height\n 'rounded-t-small p-3 font-semibold text-medium',\n ],\n /** class for the list */\n list: ['overflow-hidden'],\n /** class for the list item (performs motion animations) */\n listItem: [\n // base styles\n 'group relative flex flex-row',\n // overlap borders by shifting first item up 1px (similar to how last item overlaps with append button)\n 'first:-mt-px',\n ],\n /** class for the list item inner */\n listItemInner: [\n // base styles\n 'flex w-full flex-row items-stretch divide-divider bg-content1',\n // x division and borders\n 'divide-x divide-solid border-b border-t border-divider',\n ],\n /** class for the list wrapper */\n listWrapper: ['overflow-hidden'],\n /** class for the remove button */\n removeButton: [\n // base styles\n 'flex items-center justify-center',\n // fixed height/no round corners\n '!h-full !min-h-0 !rounded-none px-3',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the sort drag handle */\n sortDragHandle: [\n // base styles\n 'flex cursor-grab items-center justify-center px-2 text-default-600 transition-colors',\n // hover and dragging state\n 'hover:bg-default-100 active:cursor-grabbing group-data-[dragging=true]:bg-default-100',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n },\n variants: {\n hasLabel: {\n false: {\n // focus styles - when there is no label, the first item actions menu button should have rounded top right corners\n actionsMenuButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item remove button focus ring should have rounded top right corners\n removeButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item sort drag handle focus ring should have rounded top left corners\n sortDragHandle:\n 'group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof fieldArrayVariants>;\n\nexport type ClassName = TVClassName<typeof fieldArrayVariants>;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementAppendButtonProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** CSS class name */\n className?: ClassValue;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n className={cn(className)}\n disableAnimation\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n >\n <FaPlus />\n <span>{appendButtonText}</span>\n </Button>\n );\n};\n\nexport default ElementAppendButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { MenuItem } from '@fuf-stack/pixels';\nimport type { Key } from 'react';\nimport type { FieldArrayElementMethods } from './FieldArrayElement';\n\nimport { FaCopy, FaTimes } from 'react-icons/fa';\nimport { VscInsert } from 'react-icons/vsc';\n\nimport { Menu } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nexport interface ElementActionsMenuProps {\n /** CSS class name */\n className?: ClassValue;\n /** Whether duplicate action is available */\n duplicate?: boolean;\n /** Whether insert after action is available */\n insertAfter?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Menu component for field array element actions (remove, duplicate, insert after)\n */\nconst ElementActionsMenu = ({\n className = undefined,\n duplicate = false,\n insertAfter = false,\n showRemove = true,\n methods,\n testId = undefined,\n}: ElementActionsMenuProps) => {\n const { cn } = useStyling();\n\n // dispatch the selected row action\n const handleAction = (key: Key) => {\n switch (key) {\n case 'remove':\n methods.remove();\n break;\n case 'duplicate':\n methods.duplicate();\n break;\n case 'insertAfter':\n methods.insert();\n break;\n default:\n break;\n }\n };\n\n // include the enabled row actions\n const menuItems: MenuItem[] = [];\n\n if (duplicate) {\n menuItems.push({\n key: 'duplicate',\n label: 'Duplicate',\n icon: <FaCopy />,\n });\n }\n\n if (insertAfter) {\n menuItems.push({\n key: 'insertAfter',\n label: 'Insert After',\n icon: <VscInsert />,\n });\n }\n\n if (showRemove) {\n menuItems.push({\n key: 'remove',\n className: 'text-danger',\n label: 'Remove',\n icon: <FaTimes />,\n });\n }\n\n return (\n <Menu\n ariaLabel=\"Element actions\"\n items={menuItems}\n onAction={handleAction}\n placement=\"right\"\n testId={testId}\n triggerButtonProps={{\n className: cn(className),\n disableRipple: true,\n size: 'md',\n variant: 'light',\n }}\n />\n );\n};\n\nexport default ElementActionsMenu;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaTimes } from 'react-icons/fa';\n\nimport { motion } from '@fuf-stack/pixel-motion';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementRemoveButtonProps {\n /** CSS class name */\n className?: ClassValue;\n /** Globally disable animations (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\n const { cn } = useStyling();\n\n const button = (\n <Button\n ariaLabel=\"remove element\"\n className={cn(className)}\n color=\"danger\"\n icon={<FaTimes />}\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n />\n );\n\n if (disableAnimation) {\n return button;\n }\n\n return (\n <motion.div\n animate={{ opacity: 1, width: 'auto' }}\n className=\"flex\"\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n transition={{ duration: 0.2 }}\n >\n {button}\n </motion.div>\n );\n};\n\nexport default ElementRemoveButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaGripVertical } from 'react-icons/fa';\n\nimport { useSortable } from '@dnd-kit/sortable';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface SortDragHandleProps {\n /** CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Drag handle component that integrates with dnd-kit sortable functionality.\n * Renders a vertical grip icon that can be used to reorder items.\n */\nconst SortDragHandle = ({\n className = undefined,\n id,\n testId = undefined,\n}: SortDragHandleProps) => {\n const { cn } = useStyling();\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\n aria-label=\"Reorder item\"\n >\n <FaGripVertical />\n </div>\n );\n};\n\nexport default SortDragHandle;\n","import type { Variants as MotionVariants } from '@fuf-stack/pixel-motion';\nimport type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayFeatures } from '../types';\n\nimport { useState } from 'react';\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\n\nimport { AnimatePresence, motion } from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport Grid from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class name */\n className: {\n /** Class of wrapper grid inside the li that wraps the rendered element fields directly */\n elementFieldsGrid?: ClassValue;\n /** Class for the li (performs motion animations) */\n listItem?: ClassValue;\n /** Class for the li inner div (wraps the rendered element fields) */\n listItemInner?: ClassValue;\n /** Class for the actions menu button */\n actionsMenuButton?: ClassValue;\n /** Class for the remove element button (when menu is not used) */\n removeButton?: ClassValue;\n /** Class for the drag handle when sorting enabled */\n sortDragHandle?: ClassValue;\n };\n /** Globally disable animations for this item (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** Bottom margin for elements (for backwards compatibility) */\n elementMarginBottom?: React.CSSProperties['marginBottom'];\n /** All fields in the form array */\n fields: Record<'id', string>[];\n /** Unique identifier for drag/drop */\n id: string | number;\n /** Field index in array */\n index: number;\n /** Prevent deletion of last remaining element */\n lastNotDeletable?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Form array element component using react-hook-form with drag-drop sorting\n * and validation capabilities. Animations when elements are added or removed\n * improve the user experience and provide a better visual feedback.\n */\nconst FieldArrayElement = ({\n children,\n className,\n disableAnimation = false,\n duplicate = false,\n elementMarginBottom: _elementMarginBottom = undefined,\n fields,\n id,\n index: _index,\n insertAfter = false,\n lastNotDeletable = true,\n methods,\n sortable = false,\n testId = undefined,\n}: FieldArrayElementProps) => {\n const { cn } = useStyling();\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n // keep the row mounted until its exit animation finishes\n const [isVisible, setIsVisible] = useState(true);\n\n // apply drag positioning only when sorting is enabled\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // animate row insertion and removal\n const listItemMotionVariants: MotionVariants = {\n hidden: { opacity: 0, height: 0, marginBottom: 0 },\n visible: {\n opacity: 1,\n height: 'auto',\n transition: { duration: 0.2, ease: 'circOut' },\n // push last visible item down to overlap with append button (hide double border)\n marginBottom: '-1px',\n },\n exit: {\n opacity: 0,\n height: 0,\n marginBottom: 0,\n transition: {\n // on exit first fade out, then shrink\n opacity: { duration: 0.1, ease: 'circOut' },\n height: { delay: 0.1, duration: 0.2, ease: 'circOut' },\n },\n },\n };\n\n // let the exit animation finish before removing the registered row\n const handleRemove = () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n };\n\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={methods.remove}\n >\n {isVisible ? (\n <motion.li\n key={id}\n ref={setNodeRef}\n animate={disableAnimation ? undefined : 'visible'}\n className={cn(className.listItem)}\n data-dragging={isDragging}\n data-testid={`${testId}_element`}\n exit={disableAnimation ? undefined : 'exit'}\n initial={disableAnimation ? false : 'hidden'}\n style={sortingStyle}\n variants={disableAnimation ? undefined : listItemMotionVariants}\n >\n <div className={cn(className.listItemInner)}>\n {/** sorting drag handle */}\n {sortable ? (\n <SortDragHandle\n className={className.sortDragHandle}\n id={id}\n testId={`${testId}_sort_drag_handle`}\n />\n ) : null}\n\n {/** render element fields in Grid component */}\n <Grid\n className={cn(className.elementFieldsGrid)}\n testId={`${testId}_element_fields_grid`}\n >\n {/* render actual fields */}\n {children}\n </Grid>\n\n {/** actions menu when duplicate or insertAfter is enabled */}\n {duplicate || insertAfter ? (\n <ElementActionsMenu\n className={className.actionsMenuButton}\n duplicate={duplicate}\n insertAfter={insertAfter}\n methods={{\n ...methods,\n remove: handleRemove,\n }}\n showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n />\n ) : (\n <>\n {/** remove element button (when menu is not used) */}\n <AnimatePresence initial={false}>\n {lastNotDeletable && fields.length === 1 ? null : (\n <ElementRemoveButton\n key=\"remove-button\"\n className={className.removeButton}\n disableAnimation={disableAnimation}\n onClick={handleRemove}\n testId={`${testId}_remove_button`}\n />\n )}\n </AnimatePresence>\n </>\n )}\n </div>\n </motion.li>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayElement;\n","import type { ReactNode } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Optional heading ID supplied by the owning group. */\n id?: string;\n /** Shows an array-level validation failure */\n invalid: boolean;\n /** Field label */\n label: ReactNode;\n /** Marks the array as required */\n required: boolean;\n}\n\n/**\n * Renders the label for a FieldArray component.\n *\n * This component handles displaying the array label with proper accessibility\n * attributes using owned heading markup and field state.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n id = undefined,\n label,\n invalid,\n required,\n}: FieldArrayLabelProps) => {\n const { cn } = useStyling();\n\n // when no label is provided, don't render anything\n if (!label) {\n return null;\n }\n\n const hasErrors = invalid;\n\n return (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={cn(\n 'block max-w-full overflow-hidden text-ellipsis subpixel-antialiased text-small',\n hasErrors ? 'text-danger!' : undefined,\n className,\n {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n },\n )}\n id={id}\n required={required}\n requiredClassName=\"ms-0.5 text-danger\"\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n );\n};\n\nexport default FieldArrayLabel;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nconst fieldArrayValidationErrorVariants = tv({\n slots: {\n /** Container for array-level validation messages */\n errorMessage: 'text-danger text-tiny',\n /** Padded footer containing array-level validation */\n helperWrapper: ['relative flex-col gap-1.5', 'block px-3 pb-2 pt-1'],\n },\n});\n\nexport default fieldArrayValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\nimport type { FieldIds } from '../../partials/types';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldArrayValidationErrorVariants from './fieldArrayValidationErrorVariants';\n\nexport interface FieldArrayValidationErrorProps {\n /** Array-level validation errors */\n error: FieldError[] | undefined;\n /** IDs shared with the owning field */\n ids: FieldIds;\n /** Shows array-level validation failure */\n invalid: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Renders array-level validation errors for FieldArray.\n *\n * This component handles validation errors that apply to the entire array\n * (e.g., \"Array must contain at least 3 elements\", \"Array elements are not unique\"),\n * as opposed to field-level errors which apply to individual array elements.\n *\n * The component wraps errors in the proper accessibility markup and animates\n * them in/out using Framer Motion when they appear or are resolved.\n */\nconst FieldArrayValidationError = ({\n error,\n ids,\n invalid,\n testId,\n}: FieldArrayValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants);\n\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = invalid && objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={ids.error}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayValidationError;\n","import type { DragEndEvent } from '@dnd-kit/core';\nimport type { ReactNode } from 'react';\nimport type { UseFieldArrayMove } from 'react-hook-form';\n\nimport {\n closestCenter,\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\n\ninterface SortContextProps {\n /** child components */\n children: ReactNode;\n /** Array of objects containing unique IDs for sortable items */\n fields: Record<'id', string>[];\n /** react-hook-form's move function to update field array indices */\n move: UseFieldArrayMove;\n /** enable/disable sorting functionality */\n sortable: boolean;\n}\n\n/**\n * A wrapper component that provides drag-and-drop sorting functionality for field arrays\n * using dnd-kit and react-hook-form.\n *\n * This component integrates with react-hook-form's field arrays to enable vertical\n * drag-and-drop reordering of form fields. It supports both pointer (mouse/touch)\n * and keyboard interactions for accessibility.\n */\nconst SortContext = ({\n children,\n fields,\n move,\n sortable,\n}: SortContextProps): ReactNode => {\n // Initialize sensors for both pointer (mouse/touch) and keyboard interactions\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\n );\n\n // Early return if sorting is disabled\n if (!sortable) {\n return children;\n }\n\n /**\n * Handles the end of a drag operation by updating field positions\n * @param event - The drag end event containing active and over elements\n */\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n // Only move if dropping over a different item\n if (active.id !== over?.id) {\n // Find the indices of the dragged item and drop target\n const oldIndex = fields.findIndex((field) => {\n return field.id === active.id;\n });\n const newIndex = fields.findIndex((field) => {\n return field.id === over?.id;\n });\n // Update the field array order using react-hook-form's move function\n move(oldIndex, newIndex);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n items={fields.map((field) => {\n return field.id;\n })}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayProps } from '../FieldArray';\n\nimport { useId } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { fieldArrayVariants } from '../fieldArrayVariants';\nimport ElementAppendButton from './ElementAppendButton';\nimport FieldArrayElement from './FieldArrayElement';\nimport FieldArrayLabel from './FieldArrayLabel';\nimport FieldArrayValidationError from './FieldArrayValidationError';\nimport SortContext from './SortContext';\n\nexport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayControlProps extends Pick<\n FieldArrayProps,\n | 'appendButtonText'\n | 'children'\n | 'className'\n | 'duplicate'\n | 'elementMarginBottom'\n | 'insertAfter'\n | 'lastElementNotRemovable'\n | 'sortable'\n> {\n /** Disables animation during array initialization */\n disableAnimation: boolean;\n /** Bound field values, interactions and metadata */\n field: UniformField;\n /** Stable row IDs used by the sorting engine */\n fields: Record<'id', string>[];\n /** Bound rows to arrange in the list */\n items: FieldArrayItem[];\n /** Callback when the append button is activated */\n onAppend: () => void;\n /** Callback when sorting moves a row */\n onMove: (from: number, to: number) => void;\n}\n\n/** Array group presentation with row controls, sorting and validation messages */\nconst FieldArrayControl = ({\n field,\n appendButtonText,\n children,\n className,\n disableAnimation,\n duplicate,\n elementMarginBottom,\n fields,\n items,\n insertAfter,\n lastElementNotRemovable,\n onAppend,\n onMove,\n sortable = false,\n}: FieldArrayControlProps) => {\n const { error, ids, invalid, name, required, testId } = field;\n\n // keep the array heading hidden when only debug label content exists\n const label = field.hasLabel ? field.label : undefined;\n\n const styling = useStyling();\n const labelId = useId();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasArrayErrors = !!(invalid && error?._errors);\n\n const { cn } = styling;\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayVariants, { hasLabel: !!label });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-label={!label ? name : undefined}\n aria-labelledby={label ? labelId : undefined}\n className={classNames.base}\n data-component=\"field-array\"\n role=\"group\"\n >\n {/* field array label */}\n <FieldArrayLabel\n className={classNames.label}\n id={labelId}\n invalid={hasArrayErrors}\n label={label}\n required={required}\n />\n\n {fields.length ? (\n /* sortable rows */\n <div className={cn(classNames.listWrapper)}>\n <SortContext fields={fields} move={onMove} sortable={sortable}>\n <ul className={classNames.list} data-testid={testId}>\n {items.map(({ id, renderProps }) => {\n return (\n <FieldArrayElement\n key={id}\n className={classNames}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={id}\n index={renderProps.index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={renderProps.methods}\n sortable={sortable}\n testId={renderProps.testId}\n >\n {children(renderProps)}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError\n error={error}\n ids={ids}\n invalid={invalid}\n testId={testId}\n />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={classNames.appendButton}\n onClick={onAppend}\n testId={`${testId}_append_button`}\n />\n </div>\n );\n};\n\nexport default FieldArrayControl;\n","import type { CSSProperties, ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './fieldArrayVariants';\nimport type { FieldArrayChildrenRenderFn, FieldArrayFeatures } from './types';\n\nimport useUniformFieldArray from '../hooks/useUniformFieldArray/useUniformFieldArray';\nimport FieldArrayControl from './subcomponents/FieldArrayControl';\n\nexport { fieldArrayVariants } from './fieldArrayVariants';\n\nexport interface FieldArrayProps extends FieldArrayFeatures, VariantProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** function that renders the children with provided Properties. */\n children: FieldArrayChildrenRenderFn;\n /** CSS class name */\n className?: ClassName;\n /* initial value of a filed that is created in the array */\n elementInitialValue?: unknown;\n /*\n * bottom margin of a list element (default 1rem), this needs to be set as a prop (and not via className slot)\n * because the margin bottom needs to be animated when elements are added or removed\n */\n elementMarginBottom?: CSSProperties['marginBottom'];\n /** when true, array stores primitives as wrapper objects: { __FLAT__: value } */\n flat?: boolean;\n /** Field label */\n label?: ReactNode;\n /** when true (default false) last element can not be removed and will be shown even if field array is empty */\n lastElementNotRemovable?: boolean;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/** Form field group for adding, removing and reordering array entries */\nconst FieldArray = ({\n appendButtonText = 'Add Element',\n children,\n className: _className = undefined,\n duplicate = false,\n elementInitialValue: _elementInitialValue = null,\n elementMarginBottom = undefined,\n flat = false,\n insertAfter = false,\n lastElementNotRemovable = false,\n name,\n sortable = false,\n ...uniformFieldProps\n}: FieldArrayProps) => {\n const { field, fields, appendItem, items, moveItem, disableAnimation } =\n useUniformFieldArray({\n ...uniformFieldProps,\n elementInitialValue: _elementInitialValue,\n flat,\n lastElementNotRemovable,\n name,\n });\n\n return (\n <FieldArrayControl\n appendButtonText={appendButtonText}\n className={_className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n field={field}\n fields={fields}\n insertAfter={insertAfter}\n items={items}\n lastElementNotRemovable={lastElementNotRemovable}\n onAppend={appendItem}\n onMove={moveItem}\n sortable={sortable}\n >\n {children}\n </FieldArrayControl>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { fieldArrayVariants } from './FieldArray';\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAa,+BAGX,EACE,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,SAE5B,iBACG;CACH,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,YAAYA,cAAiB;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,iBAA6B;CAStE,MAAM,kBAAkB,cAAc;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,iBAAiB,OAAO,CAAC,eAAe;CAK9C,gBAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,gBAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,IAAI;CAI7D,MAAM,uBAAuB,iBAAiB;CAC9C,gBAAgB;EACd,IAAI,eAAe,SACjB,oBAAoB,CAAC,CAAC,oBAAoB;CAE9C,GAAG,CAAC,oBAAoB,CAAC;CAKzB,MAAM,sBAAsB,cAAc;EACxC,OAAO,OACH,GAAG,eAAe,wBAAwB,KAAK,IAC9C,wBAAwB,CAAC;CAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;CAY/B,kBAAkB,EAChB,eAAe;EACb,MAAM,eAAe,UAAU,IAA0B;EACzD,MAAM,eAAe,MAAM,QAAQ,YAA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MAAM,eAAa;MAC1C,UAAA,MAAM,KAAK,EAAE,IAAI,kBAAkB;OAClC,OACE,oBAAC,mBAAD;QAEE,WAAW;QACO;QACP;QACU;QACb;QACJ;QACJ,OAAO,YAAY;QACN;QACb,kBAAkB;QAClB,SAAS,YAAY;QACX;QACV,QAAQ,YAAY;QAEnB,UAAA,SAAS,WAAW;OACJ,GAfZ,EAeY;MAEvB,CAAC;KACC,CAAA;IACO,CAAA;GACV,CAAA,IACH;GAGJ,oBAAC,2BAAD;IACS;IACF;IACI;IACD;GACT,CAAA;GAGD,oBAAC,qBAAD;IACoB;IAClB,WAAW,WAAW;IACtB,SAAS;IACT,QAAQ,GAAG,OAAO;GACnB,CAAA;EACE;;AAET;;;;ACzGA,MAAM,cAAc,EAClB,mBAAmB,eACnB,UACA,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,qBAAqB,uBAAuB,MAC5C,sBAAsB,KAAA,GACtB,OAAO,OACP,cAAc,OACd,0BAA0B,OAC1B,MACA,WAAW,OACX,GAAG,wBACkB;CACrB,MAAM,EAAE,OAAO,QAAQ,YAAY,OAAO,UAAU,qBAClD,qBAAqB;EACnB,GAAG;EACH,qBAAqB;EACrB;EACA;EACA;CACF,CAAC;CAEH,OACE,oBAAC,mBAAD;EACoB;EAClB,WAAW;EACO;EACP;EACU;EACd;EACC;EACK;EACN;EACkB;EACzB,UAAU;EACV,QAAQ;EACE;EAET;CACgB,CAAA;AAEvB;;;ACxEA,IAAA,qBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["useRHFFieldArray","useFormContext","Grid"],"sources":["../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../src/FieldArray/fieldArrayVariants.ts","../../src/FieldArray/subcomponents/ElementAppendButton.tsx","../../src/FieldArray/subcomponents/ElementActionsMenu.tsx","../../src/FieldArray/subcomponents/ElementRemoveButton.tsx","../../src/FieldArray/subcomponents/SortDragHandle.tsx","../../src/FieldArray/subcomponents/FieldArrayElement.tsx","../../src/FieldArray/subcomponents/FieldArrayLabel.tsx","../../src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts","../../src/FieldArray/subcomponents/FieldArrayValidationError.tsx","../../src/FieldArray/subcomponents/SortContext.tsx","../../src/FieldArray/subcomponents/FieldArrayControl.tsx","../../src/FieldArray/FieldArray.tsx","../../src/FieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n FieldArray as ArrayElement,\n ArrayPath,\n FieldValues,\n Path,\n UseFieldArrayReturn,\n} from 'react-hook-form';\nimport type { UniformFieldState } from '../useUniformField/types';\nimport type { FieldArrayElementMethods, FieldArrayItem } from './types';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport useUniformField from '../useUniformField/useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Disable the field */\n disabled?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n}\n\n/**\n * Return type of `useUniformFieldArrayMethods` and `useUniformFieldArray`.\n *\n * Declared explicitly so the published declarations only reference types that\n * react-hook-form exports from its package root.\n */\nexport type UseUniformFieldArrayReturn<\n TFieldValues extends FieldValues = FieldValues,\n> = Pick<\n UseFieldArrayReturn<TFieldValues, ArrayPath<TFieldValues>>,\n 'append' | 'fields' | 'insert' | 'move' | 'remove'\n> &\n UniformFieldState<TFieldValues> & {\n /** Appends an element using the configured initial value */\n appendItem: () => void;\n /** Disables element animations during initialization, reset and reduced motion */\n disableAnimation: boolean;\n /** Value used for newly added array elements */\n elementInitialValue: NonNullable<unknown>;\n /** Bound operations and identification for each array row */\n items: FieldArrayItem[];\n /** Moves an element and validates the array afterwards */\n moveItem: (from: number, to: number) => void;\n };\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArrayMethods = <\n TFieldValues extends FieldValues = FieldValues,\n>(\n {\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n }: UseUniformFieldArrayProps<TFieldValues>,\n uniformField: UniformFieldState<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n const { testId } = uniformField.field;\n\n // bind row identification and operations for the renderer\n const items: FieldArrayItem[] = fields.map((row, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n const methods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n },\n duplicate: () => {\n const values = getValues(name as Path<TFieldValues>);\n const currentValue = (values as unknown as unknown[])[index];\n\n insert(\n index + 1,\n (flat\n ? { [flatArrayKey]: currentValue }\n : currentValue) as ArrayElement<TFieldValues>,\n );\n },\n insert: () => {\n insert(index + 1, elementInitialValue as ArrayElement<TFieldValues>);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return {\n id: row.id,\n renderProps: {\n index,\n length: fields.length,\n methods,\n name: elementName,\n testId: elementTestId,\n },\n };\n });\n\n // append an element using the configured initial value\n const appendItem = () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n };\n\n // validate the array after its row order changes\n const moveItem = (from: number, to: number) => {\n move(from, to);\n trigger(name as Path<TFieldValues>);\n };\n\n return {\n // Field array methods and state\n fields,\n append,\n appendItem,\n items,\n remove,\n insert,\n move,\n moveItem,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n\nconst useUniformFieldArray = <TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldArrayProps<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const field = useUniformField<TFieldValues>({\n ...params,\n name: params.name as Path<TFieldValues> & string,\n });\n return useUniformFieldArrayMethods(params, field);\n};\nexport default useUniformFieldArray;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nexport const fieldArrayVariants = tv({\n slots: {\n /** class for the actions menu button */\n actionsMenuButton: [\n // base styles\n 'flex items-center justify-center text-default-600',\n // fixed height/no round corners/center align\n 'h-full rounded-none',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the append button */\n appendButton: [\n // base styles\n 'w-full justify-start rounded-b-small rounded-t-none font-semibold',\n // match label height (p-3 = 12px vertical padding + text-base line height)\n '!h-[48px] !min-h-0',\n // focus styles - inset ring with rounded bottom corners to match container\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** base class for the field array wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border border-divider bg-content1',\n // divider between items\n 'divide-y divide-divider',\n ],\n /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) instead of text-base for correct 48px height\n 'rounded-t-small p-3 font-semibold text-medium',\n ],\n /** class for the list */\n list: ['overflow-hidden'],\n /** class for the list item (performs motion animations) */\n listItem: [\n // base styles\n 'group relative flex flex-row',\n // overlap borders by shifting first item up 1px (similar to how last item overlaps with append button)\n 'first:-mt-px',\n ],\n /** class for the list item inner */\n listItemInner: [\n // base styles\n 'flex w-full flex-row items-stretch divide-divider bg-content1',\n // x division and borders\n 'divide-x divide-solid border-b border-t border-divider',\n ],\n /** class for the list wrapper */\n listWrapper: ['overflow-hidden'],\n /** class for the remove button */\n removeButton: [\n // base styles\n 'flex items-center justify-center',\n // fixed height/no round corners\n '!h-full !min-h-0 !rounded-none px-3',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the sort drag handle */\n sortDragHandle: [\n // base styles\n 'flex cursor-grab items-center justify-center px-2 text-default-600 transition-colors',\n // hover and dragging state\n 'hover:bg-default-100 active:cursor-grabbing group-data-[dragging=true]:bg-default-100',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n },\n variants: {\n hasLabel: {\n false: {\n // focus styles - when there is no label, the first item actions menu button should have rounded top right corners\n actionsMenuButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item remove button focus ring should have rounded top right corners\n removeButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item sort drag handle focus ring should have rounded top left corners\n sortDragHandle:\n 'group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof fieldArrayVariants>;\n\nexport type ClassName = TVClassName<typeof fieldArrayVariants>;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementAppendButtonProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** CSS class name */\n className?: ClassValue;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n className={cn(className)}\n disableAnimation\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n >\n <FaPlus />\n <span>{appendButtonText}</span>\n </Button>\n );\n};\n\nexport default ElementAppendButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { MenuItem } from '@fuf-stack/pixels';\nimport type { Key } from 'react';\nimport type { FieldArrayElementMethods } from './FieldArrayElement';\n\nimport { FaCopy, FaTimes } from 'react-icons/fa';\nimport { VscInsert } from 'react-icons/vsc';\n\nimport { Menu } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nexport interface ElementActionsMenuProps {\n /** CSS class name */\n className?: ClassValue;\n /** Whether duplicate action is available */\n duplicate?: boolean;\n /** Whether insert after action is available */\n insertAfter?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Menu component for field array element actions (remove, duplicate, insert after)\n */\nconst ElementActionsMenu = ({\n className = undefined,\n duplicate = false,\n insertAfter = false,\n showRemove = true,\n methods,\n testId = undefined,\n}: ElementActionsMenuProps) => {\n const { cn } = useStyling();\n\n // dispatch the selected row action\n const handleAction = (key: Key) => {\n switch (key) {\n case 'remove':\n methods.remove();\n break;\n case 'duplicate':\n methods.duplicate();\n break;\n case 'insertAfter':\n methods.insert();\n break;\n default:\n break;\n }\n };\n\n // include the enabled row actions\n const menuItems: MenuItem[] = [];\n\n if (duplicate) {\n menuItems.push({\n key: 'duplicate',\n label: 'Duplicate',\n icon: <FaCopy />,\n });\n }\n\n if (insertAfter) {\n menuItems.push({\n key: 'insertAfter',\n label: 'Insert After',\n icon: <VscInsert />,\n });\n }\n\n if (showRemove) {\n menuItems.push({\n key: 'remove',\n className: 'text-danger',\n label: 'Remove',\n icon: <FaTimes />,\n });\n }\n\n return (\n <Menu\n ariaLabel=\"Element actions\"\n items={menuItems}\n onAction={handleAction}\n placement=\"right\"\n testId={testId}\n triggerButtonProps={{\n className: cn(className),\n disableRipple: true,\n size: 'md',\n variant: 'light',\n }}\n />\n );\n};\n\nexport default ElementActionsMenu;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaTimes } from 'react-icons/fa';\n\nimport { motion } from '@fuf-stack/pixel-motion';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementRemoveButtonProps {\n /** CSS class name */\n className?: ClassValue;\n /** Globally disable animations (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\n const { cn } = useStyling();\n\n const button = (\n <Button\n ariaLabel=\"remove element\"\n className={cn(className)}\n color=\"danger\"\n icon={<FaTimes />}\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n />\n );\n\n if (disableAnimation) {\n return button;\n }\n\n return (\n <motion.div\n animate={{ opacity: 1, width: 'auto' }}\n className=\"flex\"\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n transition={{ duration: 0.2 }}\n >\n {button}\n </motion.div>\n );\n};\n\nexport default ElementRemoveButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaGripVertical } from 'react-icons/fa';\n\nimport { useSortable } from '@dnd-kit/sortable';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface SortDragHandleProps {\n /** CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Drag handle component that integrates with dnd-kit sortable functionality.\n * Renders a vertical grip icon that can be used to reorder items.\n */\nconst SortDragHandle = ({\n className = undefined,\n id,\n testId = undefined,\n}: SortDragHandleProps) => {\n const { cn } = useStyling();\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\n aria-label=\"Reorder item\"\n >\n <FaGripVertical />\n </div>\n );\n};\n\nexport default SortDragHandle;\n","import type { Variants as MotionVariants } from '@fuf-stack/pixel-motion';\nimport type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayFeatures } from '../types';\n\nimport { useState } from 'react';\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\n\nimport { AnimatePresence, motion } from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport Grid from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class name */\n className: {\n /** Class of wrapper grid inside the li that wraps the rendered element fields directly */\n elementFieldsGrid?: ClassValue;\n /** Class for the li (performs motion animations) */\n listItem?: ClassValue;\n /** Class for the li inner div (wraps the rendered element fields) */\n listItemInner?: ClassValue;\n /** Class for the actions menu button */\n actionsMenuButton?: ClassValue;\n /** Class for the remove element button (when menu is not used) */\n removeButton?: ClassValue;\n /** Class for the drag handle when sorting enabled */\n sortDragHandle?: ClassValue;\n };\n /** Globally disable animations for this item (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** Bottom margin for elements (for backwards compatibility) */\n elementMarginBottom?: React.CSSProperties['marginBottom'];\n /** All fields in the form array */\n fields: Record<'id', string>[];\n /** Unique identifier for drag/drop */\n id: string | number;\n /** Field index in array */\n index: number;\n /** Prevent deletion of last remaining element */\n lastNotDeletable?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Form array element component using react-hook-form with drag-drop sorting\n * and validation capabilities. Animations when elements are added or removed\n * improve the user experience and provide a better visual feedback.\n */\nconst FieldArrayElement = ({\n children,\n className,\n disableAnimation = false,\n duplicate = false,\n elementMarginBottom: _elementMarginBottom = undefined,\n fields,\n id,\n index: _index,\n insertAfter = false,\n lastNotDeletable = true,\n methods,\n sortable = false,\n testId = undefined,\n}: FieldArrayElementProps) => {\n const { cn } = useStyling();\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n // keep the row mounted until its exit animation finishes\n const [isVisible, setIsVisible] = useState(true);\n\n // apply drag positioning only when sorting is enabled\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // animate row insertion and removal\n const listItemMotionVariants: MotionVariants = {\n hidden: { opacity: 0, height: 0, marginBottom: 0 },\n visible: {\n opacity: 1,\n height: 'auto',\n transition: { duration: 0.2, ease: 'circOut' },\n // push last visible item down to overlap with append button (hide double border)\n marginBottom: '-1px',\n },\n exit: {\n opacity: 0,\n height: 0,\n marginBottom: 0,\n transition: {\n // on exit first fade out, then shrink\n opacity: { duration: 0.1, ease: 'circOut' },\n height: { delay: 0.1, duration: 0.2, ease: 'circOut' },\n },\n },\n };\n\n // let the exit animation finish before removing the registered row\n const handleRemove = () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n };\n\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={methods.remove}\n >\n {isVisible ? (\n <motion.li\n key={id}\n ref={setNodeRef}\n animate={disableAnimation ? undefined : 'visible'}\n className={cn(className.listItem)}\n data-dragging={isDragging}\n data-testid={`${testId}_element`}\n exit={disableAnimation ? undefined : 'exit'}\n initial={disableAnimation ? false : 'hidden'}\n style={sortingStyle}\n variants={disableAnimation ? undefined : listItemMotionVariants}\n >\n <div className={cn(className.listItemInner)}>\n {/** sorting drag handle */}\n {sortable ? (\n <SortDragHandle\n className={className.sortDragHandle}\n id={id}\n testId={`${testId}_sort_drag_handle`}\n />\n ) : null}\n\n {/** render element fields in Grid component */}\n <Grid\n className={cn(className.elementFieldsGrid)}\n testId={`${testId}_element_fields_grid`}\n >\n {/* render actual fields */}\n {children}\n </Grid>\n\n {/** actions menu when duplicate or insertAfter is enabled */}\n {duplicate || insertAfter ? (\n <ElementActionsMenu\n className={className.actionsMenuButton}\n duplicate={duplicate}\n insertAfter={insertAfter}\n methods={{\n ...methods,\n remove: handleRemove,\n }}\n showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n />\n ) : (\n <>\n {/** remove element button (when menu is not used) */}\n <AnimatePresence initial={false}>\n {lastNotDeletable && fields.length === 1 ? null : (\n <ElementRemoveButton\n key=\"remove-button\"\n className={className.removeButton}\n disableAnimation={disableAnimation}\n onClick={handleRemove}\n testId={`${testId}_remove_button`}\n />\n )}\n </AnimatePresence>\n </>\n )}\n </div>\n </motion.li>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayElement;\n","import type { ReactNode } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Optional heading ID supplied by the owning group. */\n id?: string;\n /** Shows an array-level validation failure */\n invalid: boolean;\n /** Field label */\n label: ReactNode;\n /** Marks the array as required */\n required: boolean;\n}\n\n/**\n * Renders the label for a FieldArray component.\n *\n * This component handles displaying the array label with proper accessibility\n * attributes using owned heading markup and field state.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n id = undefined,\n label,\n invalid,\n required,\n}: FieldArrayLabelProps) => {\n const { cn } = useStyling();\n\n // when no label is provided, don't render anything\n if (!label) {\n return null;\n }\n\n const hasErrors = invalid;\n\n return (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={cn(\n 'block max-w-full overflow-hidden text-ellipsis subpixel-antialiased text-small',\n hasErrors ? 'text-danger!' : undefined,\n className,\n {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n },\n )}\n id={id}\n required={required}\n requiredClassName=\"ms-0.5 text-danger\"\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n );\n};\n\nexport default FieldArrayLabel;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nimport { fieldHelperVariants } from '../../partials/FieldHelper/fieldHelperVariants';\n\nconst fieldArrayValidationErrorVariants = tv({\n extend: fieldHelperVariants,\n slots: {\n /** Padded footer containing array-level validation */\n helperWrapper: 'px-3 pb-2 pt-1',\n },\n});\n\nexport default fieldArrayValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\nimport type { FieldIds } from '../../partials/types';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldArrayValidationErrorVariants from './fieldArrayValidationErrorVariants';\n\nexport interface FieldArrayValidationErrorProps {\n /** Array-level validation errors */\n error: FieldError[] | undefined;\n /** IDs shared with the owning field */\n ids: FieldIds;\n /** Shows array-level validation failure */\n invalid: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Renders array-level validation errors for FieldArray.\n *\n * This component handles validation errors that apply to the entire array\n * (e.g., \"Array must contain at least 3 elements\", \"Array elements are not unique\"),\n * as opposed to field-level errors which apply to individual array elements.\n *\n * The component wraps errors in the proper accessibility markup and animates\n * them in/out using Framer Motion when they appear or are resolved.\n */\nconst FieldArrayValidationError = ({\n error,\n ids,\n invalid,\n testId,\n}: FieldArrayValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants);\n\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = invalid && objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={ids.error}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayValidationError;\n","import type { DragEndEvent } from '@dnd-kit/core';\nimport type { ReactNode } from 'react';\nimport type { UseFieldArrayMove } from 'react-hook-form';\n\nimport {\n closestCenter,\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\n\ninterface SortContextProps {\n /** child components */\n children: ReactNode;\n /** Array of objects containing unique IDs for sortable items */\n fields: Record<'id', string>[];\n /** react-hook-form's move function to update field array indices */\n move: UseFieldArrayMove;\n /** enable/disable sorting functionality */\n sortable: boolean;\n}\n\n/**\n * A wrapper component that provides drag-and-drop sorting functionality for field arrays\n * using dnd-kit and react-hook-form.\n *\n * This component integrates with react-hook-form's field arrays to enable vertical\n * drag-and-drop reordering of form fields. It supports both pointer (mouse/touch)\n * and keyboard interactions for accessibility.\n */\nconst SortContext = ({\n children,\n fields,\n move,\n sortable,\n}: SortContextProps): ReactNode => {\n // Initialize sensors for both pointer (mouse/touch) and keyboard interactions\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\n );\n\n // Early return if sorting is disabled\n if (!sortable) {\n return children;\n }\n\n /**\n * Handles the end of a drag operation by updating field positions\n * @param event - The drag end event containing active and over elements\n */\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n // Only move if dropping over a different item\n if (active.id !== over?.id) {\n // Find the indices of the dragged item and drop target\n const oldIndex = fields.findIndex((field) => {\n return field.id === active.id;\n });\n const newIndex = fields.findIndex((field) => {\n return field.id === over?.id;\n });\n // Update the field array order using react-hook-form's move function\n move(oldIndex, newIndex);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n items={fields.map((field) => {\n return field.id;\n })}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayProps } from '../FieldArray';\n\nimport { useId } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { fieldArrayVariants } from '../fieldArrayVariants';\nimport ElementAppendButton from './ElementAppendButton';\nimport FieldArrayElement from './FieldArrayElement';\nimport FieldArrayLabel from './FieldArrayLabel';\nimport FieldArrayValidationError from './FieldArrayValidationError';\nimport SortContext from './SortContext';\n\nexport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayControlProps extends Pick<\n FieldArrayProps,\n | 'appendButtonText'\n | 'children'\n | 'className'\n | 'duplicate'\n | 'elementMarginBottom'\n | 'insertAfter'\n | 'lastElementNotRemovable'\n | 'sortable'\n> {\n /** Disables animation during array initialization */\n disableAnimation: boolean;\n /** Bound field values, interactions and metadata */\n field: UniformField;\n /** Stable row IDs used by the sorting engine */\n fields: Record<'id', string>[];\n /** Bound rows to arrange in the list */\n items: FieldArrayItem[];\n /** Callback when the append button is activated */\n onAppend: () => void;\n /** Callback when sorting moves a row */\n onMove: (from: number, to: number) => void;\n}\n\n/** Array group presentation with row controls, sorting and validation messages */\nconst FieldArrayControl = ({\n field,\n appendButtonText,\n children,\n className,\n disableAnimation,\n duplicate,\n elementMarginBottom,\n fields,\n items,\n insertAfter,\n lastElementNotRemovable,\n onAppend,\n onMove,\n sortable = false,\n}: FieldArrayControlProps) => {\n const { error, ids, invalid, name, required, testId } = field;\n\n // keep the array heading hidden when only debug label content exists\n const label = field.hasLabel ? field.label : undefined;\n\n const styling = useStyling();\n const labelId = useId();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasArrayErrors = !!(invalid && error?._errors);\n\n const { cn } = styling;\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayVariants, { hasLabel: !!label });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-label={!label ? name : undefined}\n aria-labelledby={label ? labelId : undefined}\n className={classNames.base}\n data-component=\"field-array\"\n role=\"group\"\n >\n {/* field array label */}\n <FieldArrayLabel\n className={classNames.label}\n id={labelId}\n invalid={hasArrayErrors}\n label={label}\n required={required}\n />\n\n {fields.length ? (\n /* sortable rows */\n <div className={cn(classNames.listWrapper)}>\n <SortContext fields={fields} move={onMove} sortable={sortable}>\n <ul className={classNames.list} data-testid={testId}>\n {items.map(({ id, renderProps }) => {\n return (\n <FieldArrayElement\n key={id}\n className={classNames}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={id}\n index={renderProps.index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={renderProps.methods}\n sortable={sortable}\n testId={renderProps.testId}\n >\n {children(renderProps)}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError\n error={error}\n ids={ids}\n invalid={invalid}\n testId={testId}\n />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={classNames.appendButton}\n onClick={onAppend}\n testId={`${testId}_append_button`}\n />\n </div>\n );\n};\n\nexport default FieldArrayControl;\n","import type { CSSProperties, ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './fieldArrayVariants';\nimport type { FieldArrayChildrenRenderFn, FieldArrayFeatures } from './types';\n\nimport useUniformFieldArray from '../hooks/useUniformFieldArray/useUniformFieldArray';\nimport FieldArrayControl from './subcomponents/FieldArrayControl';\n\nexport { fieldArrayVariants } from './fieldArrayVariants';\n\nexport interface FieldArrayProps extends FieldArrayFeatures, VariantProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** function that renders the children with provided Properties. */\n children: FieldArrayChildrenRenderFn;\n /** CSS class name */\n className?: ClassName;\n /* initial value of a filed that is created in the array */\n elementInitialValue?: unknown;\n /*\n * bottom margin of a list element (default 1rem), this needs to be set as a prop (and not via className slot)\n * because the margin bottom needs to be animated when elements are added or removed\n */\n elementMarginBottom?: CSSProperties['marginBottom'];\n /** when true, array stores primitives as wrapper objects: { __FLAT__: value } */\n flat?: boolean;\n /** Field label */\n label?: ReactNode;\n /** when true (default false) last element can not be removed and will be shown even if field array is empty */\n lastElementNotRemovable?: boolean;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/** Form field group for adding, removing and reordering array entries */\nconst FieldArray = ({\n appendButtonText = 'Add Element',\n children,\n className: _className = undefined,\n duplicate = false,\n elementInitialValue: _elementInitialValue = null,\n elementMarginBottom = undefined,\n flat = false,\n insertAfter = false,\n lastElementNotRemovable = false,\n name,\n sortable = false,\n ...uniformFieldProps\n}: FieldArrayProps) => {\n const { field, fields, appendItem, items, moveItem, disableAnimation } =\n useUniformFieldArray({\n ...uniformFieldProps,\n elementInitialValue: _elementInitialValue,\n flat,\n lastElementNotRemovable,\n name,\n });\n\n return (\n <FieldArrayControl\n appendButtonText={appendButtonText}\n className={_className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n field={field}\n fields={fields}\n insertAfter={insertAfter}\n items={items}\n lastElementNotRemovable={lastElementNotRemovable}\n onAppend={appendItem}\n onMove={moveItem}\n sortable={sortable}\n >\n {children}\n </FieldArrayControl>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { fieldArrayVariants } from './FieldArray';\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAa,+BAGX,EACE,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,SAE5B,iBAC6C;CAC7C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,YAAYA,cAAiB;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,iBAA6B;CAStE,MAAM,kBAAkB,cAAc;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,iBAAiB,OAAO,CAAC,eAAe;CAK9C,gBAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,gBAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,IAAI;CAI7D,MAAM,uBAAuB,iBAAiB;CAC9C,gBAAgB;EACd,IAAI,eAAe,SACjB,oBAAoB,CAAC,CAAC,oBAAoB;CAE9C,GAAG,CAAC,oBAAoB,CAAC;CAKz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J,SAAS;IACF;IACG;GACX,CAAA;GAEA,OAAO,SAEN,oBAAC,OAAD;IAAK,WAAW,GAAG,WAAW,WAAW;IACvC,UAAA,oBAAC,aAAD;KAAqB;KAAQ,MAAM;KAAkB;KACnD,UAAA,oBAAC,MAAD;MAAI,WAAW,WAAW;MAAM,eAAa;MAC1C,UAAA,MAAM,KAAK,EAAE,IAAI,kBAAkB;OAClC,OACE,oBAAC,mBAAD;QAEE,WAAW;QACO;QACP;QACU;QACb;QACJ;QACJ,OAAO,YAAY;QACN;QACb,kBAAkB;QAClB,SAAS,YAAY;QACX;QACV,QAAQ,YAAY;QAEnB,UAAA,SAAS,WAAW;OACJ,GAfZ,EAeY;MAEvB,CAAC;KACC,CAAA;IACO,CAAA;GACV,CAAA,IACH;GAGJ,oBAAC,2BAAD;IACS;IACF;IACI;IACD;GACT,CAAA;GAGD,oBAAC,qBAAD;IACoB;IAClB,WAAW,WAAW;IACtB,SAAS;IACT,QAAQ,GAAG,OAAO;GACnB,CAAA;EACE;;AAET;;;ACzGA,MAAM,cAAc,EAClB,mBAAmB,eACnB,UACA,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,qBAAqB,uBAAuB,MAC5C,sBAAsB,KAAA,GACtB,OAAO,OACP,cAAc,OACd,0BAA0B,OAC1B,MACA,WAAW,OACX,GAAG,wBACkB;CACrB,MAAM,EAAE,OAAO,QAAQ,YAAY,OAAO,UAAU,qBAClD,qBAAqB;EACnB,GAAG;EACH,qBAAqB;EACrB;EACA;EACA;CACF,CAAC;CAEH,OACE,oBAAC,mBAAD;EACoB;EAClB,WAAW;EACO;EACP;EACU;EACd;EACC;EACK;EACN;EACkB;EACzB,UAAU;EACV,QAAQ;EACE;EAET;CACgB,CAAA;AAEvB;;ACxEA,IAAA,qBAAe"}
@@ -1,6 +1,5 @@
1
1
  import { ReactNode } from "react";
2
2
  import { TVClassName } from "@fuf-stack/pixel-utils";
3
- //#region src/FieldCard/fieldCardVariants.d.ts
4
3
  export declare const fieldCardVariants: ((props?: ({
5
4
  invalid?: boolean | undefined;
6
5
  } & ({
@@ -291,8 +290,6 @@ export declare const fieldCardVariants: ((props?: ({
291
290
  variantKeys: "invalid"[];
292
291
  };
293
292
  type ClassName = TVClassName<typeof fieldCardVariants>;
294
- //#endregion
295
- //#region src/FieldCard/FieldCard.d.ts
296
293
  interface FieldCardProps {
297
294
  /** Content to render inside the card */
298
295
  children: ReactNode;
@@ -315,6 +312,5 @@ interface FieldCardProps {
315
312
  * outline follows child interaction and form submission
316
313
  */
317
314
  declare const FieldCard: ({ children, className: _className, name, ...uniformFieldProps }: FieldCardProps) => import("react").JSX.Element;
318
- //#endregion
319
315
  export { type FieldCardProps, FieldCard as default };
320
316
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/FieldCard/fieldCardVariants.ts","../../src/FieldCard/FieldCard.tsx"],"mappings":";;;qBAIa,qBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DlB,YAAY,mBAAmB;;;UCjD1B;;EAEf,UAAU;;EAEV,YAAY;;EAEZ,OAAO;;EAEP;;EAEA;;;;;;;;;;;cAYI,cAAa,UAAA,WAAA,YAAA,SAAA,qBAKhB,mCAAc,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/FieldCard/fieldCardVariants.ts","../../src/FieldCard/FieldCard.tsx"],"mappings":";;qBAIa,qBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DlB,YAAY,mBAAmB;UCjD1B;;EAEf,UAAU;;EAEV,YAAY;;EAEZ,OAAO;;EAEP;;EAEA;;;;;;;;;;;cAYI,cAAa,UAAA,WAAA,YAAA,SAAA,qBAKhB,mCAAc,IAAA"}
@@ -1,12 +1,14 @@
1
- import { n as FieldValidationError } from "../FieldValidationError-DgkCL3cC.mjs";
2
- import { n as useFormContext, t as checkFieldIsRequired } from "../useFormContext-BPjJjNnM.mjs";
3
- import { n as useUniformField, t as FieldLabel } from "../FieldLabel-DKzqkuY1.mjs";
1
+ import { t as useUniformField } from "../useUniformField-TTNPTsVn.mjs";
2
+ import { n as useFormContext, t as checkFieldIsRequired } from "../useFormContext-piqnN2L-.mjs";
3
+ import { t as FieldLabel } from "../FieldLabel-DMTqq0Jj.mjs";
4
+ import { n as FieldValidationError } from "../FieldValidationError-BuLvuRyi.mjs";
5
+ import { t as fieldHelperVariants } from "../fieldHelperVariants-ClP8taiS.mjs";
4
6
  import { useDebounce } from "@fuf-stack/pixels";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  import { tv } from "@fuf-stack/pixel-utils";
7
9
  import { useStyling } from "@fuf-stack/pixels/StylingProvider";
8
10
  import { AnimatePresence, motion, useReducedMotion } from "@fuf-stack/pixel-motion";
9
- //#region src/FieldCard/fieldCardValidation.ts
11
+ // src/FieldCard/fieldCardValidation.ts
10
12
  /**
11
13
  * Recursively checks if any child field has an error (regardless of touched state).
12
14
  * Returns true if at least one child has an error.
@@ -71,8 +73,7 @@ const getNestedValue = (obj, path) => {
71
73
  });
72
74
  return current;
73
75
  };
74
- //#endregion
75
- //#region src/FieldCard/hooks/useFieldCardValidation.ts
76
+ // src/FieldCard/hooks/useFieldCardValidation.ts
76
77
  /**
77
78
  * Derives the card's required and invalid states from its nested fields
78
79
  *
@@ -110,8 +111,7 @@ const useFieldCardValidation = (field) => {
110
111
  required: isRequired
111
112
  };
112
113
  };
113
- //#endregion
114
- //#region src/FieldCard/fieldCardVariants.ts
114
+ // src/FieldCard/fieldCardVariants.ts
115
115
  const fieldCardVariants = tv({
116
116
  slots: {
117
117
  /** base class for the field card wrapper */
@@ -150,16 +150,9 @@ const fieldCardVariants = tv({
150
150
  } },
151
151
  defaultVariants: { invalid: false }
152
152
  });
153
- //#endregion
154
- //#region src/FieldCard/subcomponents/fieldCardValidationErrorVariants.ts
155
- const fieldCardValidationErrorVariants = tv({ slots: {
156
- /** Container for card-level validation messages */
157
- errorMessage: "text-danger text-tiny",
158
- /** Footer containing card-level validation */
159
- helperWrapper: "relative flex flex-col gap-1.5 p-0"
160
- } });
161
- //#endregion
162
- //#region src/FieldCard/subcomponents/FieldCardValidationError.tsx
153
+ // src/FieldCard/subcomponents/fieldCardValidationErrorVariants.ts
154
+ const fieldCardValidationErrorVariants = tv({ extend: fieldHelperVariants });
155
+ // src/FieldCard/subcomponents/FieldCardValidationError.tsx
163
156
  /**
164
157
  * Renders validation errors in the footer of a FieldCard component.
165
158
  *
@@ -212,8 +205,7 @@ const FieldCardValidationError = ({ className = void 0, error = void 0, errorTex
212
205
  }, "field-card-errors") : null
213
206
  });
214
207
  };
215
- //#endregion
216
- //#region src/FieldCard/subcomponents/FieldCardControl.tsx
208
+ // src/FieldCard/subcomponents/FieldCardControl.tsx
217
209
  /** Card presentation with an accessible heading, content and animated error footer */
218
210
  const FieldCardControl = ({ field, children, className }) => {
219
211
  const { ariaLabel, error, ids, invalid, label, required, testId } = field;
@@ -252,8 +244,7 @@ const FieldCardControl = ({ field, children, className }) => {
252
244
  ]
253
245
  });
254
246
  };
255
- //#endregion
256
- //#region src/FieldCard/FieldCard.tsx
247
+ // src/FieldCard/FieldCard.tsx
257
248
  /**
258
249
  * Groups related form fields in a card with a heading and validation footer
259
250
  *
@@ -278,10 +269,8 @@ const FieldCard = ({ children, className: _className = void 0, name, ...uniformF
278
269
  children
279
270
  });
280
271
  };
281
- //#endregion
282
- //#region src/FieldCard/index.ts
272
+ // src/FieldCard/index.ts
283
273
  var FieldCard_default = FieldCard;
284
- //#endregion
285
274
  export { FieldCard_default as default, fieldCardVariants };
286
275
 
287
276
  //# sourceMappingURL=index.mjs.map