@fuf-stack/uniform 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/Checkboxes/index.d.cts +1 -1
  2. package/dist/Checkboxes/index.d.ts +1 -1
  3. package/dist/FieldArray/index.cjs +1 -1
  4. package/dist/FieldArray/index.d.cts +1 -1
  5. package/dist/FieldArray/index.d.ts +1 -1
  6. package/dist/FieldArray/index.js +1 -1
  7. package/dist/{FieldArray-DgJgrLOY.cjs → FieldArray-BgvSTDWi.cjs} +3 -3
  8. package/dist/FieldArray-BgvSTDWi.cjs.map +1 -0
  9. package/dist/{FieldArray-Bnv1_-Rl.js → FieldArray-C8Ipn-tM.js} +3 -3
  10. package/dist/FieldArray-C8Ipn-tM.js.map +1 -0
  11. package/dist/FieldCard/index.cjs +1 -1
  12. package/dist/FieldCard/index.d.cts +1 -1
  13. package/dist/FieldCard/index.d.ts +1 -1
  14. package/dist/FieldCard/index.js +1 -1
  15. package/dist/{FieldCard-CLd4PaoX.js → FieldCard-DZSiMFoO.js} +70 -15
  16. package/dist/FieldCard-DZSiMFoO.js.map +1 -0
  17. package/dist/{FieldCard-CeEnVxiB.cjs → FieldCard-DcMORXZR.cjs} +70 -15
  18. package/dist/FieldCard-DcMORXZR.cjs.map +1 -0
  19. package/dist/Form/index.d.cts +1 -1
  20. package/dist/Form/index.d.ts +1 -1
  21. package/dist/Grid/index.d.ts +1 -1
  22. package/dist/Input/index.d.cts +1 -1
  23. package/dist/Input/index.d.ts +1 -1
  24. package/dist/RadioBoxes/index.d.cts +1 -1
  25. package/dist/RadioBoxes/index.d.ts +1 -1
  26. package/dist/RadioTabs/index.d.cts +1 -1
  27. package/dist/RadioTabs/index.d.ts +1 -1
  28. package/dist/Radios/index.d.cts +1 -1
  29. package/dist/Radios/index.d.ts +1 -1
  30. package/dist/Select/index.d.cts +1 -1
  31. package/dist/Select/index.d.ts +1 -1
  32. package/dist/Slider/index.d.cts +1 -1
  33. package/dist/Slider/index.d.ts +1 -1
  34. package/dist/SubmitButton/index.d.cts +1 -1
  35. package/dist/SubmitButton/index.d.ts +1 -1
  36. package/dist/Switch/index.d.cts +1 -1
  37. package/dist/Switch/index.d.ts +1 -1
  38. package/dist/SwitchBox/index.d.cts +1 -1
  39. package/dist/SwitchBox/index.d.ts +1 -1
  40. package/dist/TextArea/index.d.cts +1 -1
  41. package/dist/TextArea/index.d.ts +1 -1
  42. package/dist/hooks/useFormContext/index.d.cts +1 -1
  43. package/dist/hooks/useFormContext/index.d.ts +1 -1
  44. package/dist/hooks/useUniformField/index.d.cts +1 -1
  45. package/dist/hooks/useUniformField/index.d.ts +2 -2
  46. package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
  47. package/dist/hooks/useUniformFieldArray/index.d.ts +20 -20
  48. package/dist/{index-DGryaZXZ.d.ts → index-2SVlCM0Y.d.cts} +21 -21
  49. package/dist/index-2SVlCM0Y.d.cts.map +1 -0
  50. package/dist/{index-BTTo_ufh.d.ts → index-B2IL9Zt7.d.cts} +3 -3
  51. package/dist/{index-_mq7cbF5.d.cts.map → index-B2IL9Zt7.d.cts.map} +1 -1
  52. package/dist/{index-C3yzuYLc.d.cts → index-BDvr4eaz.d.ts} +21 -21
  53. package/dist/index-BDvr4eaz.d.ts.map +1 -0
  54. package/dist/{index-BapBrgmV.d.cts → index-BKCiuwim.d.cts} +46 -46
  55. package/dist/{index-BapBrgmV.d.cts.map → index-BKCiuwim.d.cts.map} +1 -1
  56. package/dist/index-BTr_gid3.d.cts.map +1 -1
  57. package/dist/{index-DMphDWRk.d.ts → index-BZrLB2p0.d.cts} +34 -34
  58. package/dist/index-BZrLB2p0.d.cts.map +1 -0
  59. package/dist/{index-U0Jx25HO.d.cts → index-Bo79xzb4.d.cts} +3 -3
  60. package/dist/{index-U0Jx25HO.d.cts.map → index-Bo79xzb4.d.cts.map} +1 -1
  61. package/dist/{index-DN9Ke6Y8.d.cts → index-BuX42Bbd.d.ts} +7 -6
  62. package/dist/index-BuX42Bbd.d.ts.map +1 -0
  63. package/dist/{index-y2jgEqoM.d.ts → index-CCeHSmIe.d.ts} +3 -3
  64. package/dist/{index-y2jgEqoM.d.ts.map → index-CCeHSmIe.d.ts.map} +1 -1
  65. package/dist/{index-Bs-1Pwc6.d.cts → index-CJ90vm9t.d.ts} +6 -6
  66. package/dist/{index-CODzh0zX.d.ts.map → index-CJ90vm9t.d.ts.map} +1 -1
  67. package/dist/{index-_mq7cbF5.d.cts → index-CPcJGZVS.d.ts} +3 -3
  68. package/dist/{index-BTTo_ufh.d.ts.map → index-CPcJGZVS.d.ts.map} +1 -1
  69. package/dist/index-CRYEKT3o.d.ts +278 -0
  70. package/dist/index-CRYEKT3o.d.ts.map +1 -0
  71. package/dist/{index-pE9osud2.d.ts → index-CVY05bZf.d.ts} +3 -3
  72. package/dist/{index-pE9osud2.d.ts.map → index-CVY05bZf.d.ts.map} +1 -1
  73. package/dist/{index-DLJiYqVE.d.cts → index-CZ5EIIjq.d.cts} +6 -6
  74. package/dist/{index-DLJiYqVE.d.cts.map → index-CZ5EIIjq.d.cts.map} +1 -1
  75. package/dist/{index-RiAo6yCB.d.ts → index-CdXOAPMb.d.ts} +48 -48
  76. package/dist/index-CdXOAPMb.d.ts.map +1 -0
  77. package/dist/{index-BGQrBRyF.d.cts → index-Cj5CLBt2.d.cts} +4 -4
  78. package/dist/{index-BGQrBRyF.d.cts.map → index-Cj5CLBt2.d.cts.map} +1 -1
  79. package/dist/{index-Bfk32Dl3.d.cts → index-CpVfOXNv.d.cts} +3 -3
  80. package/dist/{index-Bfk32Dl3.d.cts.map → index-CpVfOXNv.d.cts.map} +1 -1
  81. package/dist/{index-CODzh0zX.d.ts → index-Ct2YYfiU.d.cts} +6 -6
  82. package/dist/{index-Bs-1Pwc6.d.cts.map → index-Ct2YYfiU.d.cts.map} +1 -1
  83. package/dist/{index-uNWK5Vb5.d.ts → index-D-ucmG60.d.ts} +21 -21
  84. package/dist/index-D-ucmG60.d.ts.map +1 -0
  85. package/dist/{index-BM5ClMN4.d.ts → index-D5rTKWm9.d.cts} +99 -99
  86. package/dist/index-D5rTKWm9.d.cts.map +1 -0
  87. package/dist/{index-CuTHt_2o.d.cts → index-DS4AP9pV.d.ts} +6 -6
  88. package/dist/{index-hK6woeqR.d.ts.map → index-DS4AP9pV.d.ts.map} +1 -1
  89. package/dist/{index-BSZJQBCK.d.ts → index-DW1uBiAf.d.cts} +7 -6
  90. package/dist/index-DW1uBiAf.d.cts.map +1 -0
  91. package/dist/{index-CJse-RZf.d.cts → index-DYErnCVV.d.cts} +36 -36
  92. package/dist/index-DYErnCVV.d.cts.map +1 -0
  93. package/dist/{index-BxV89x6q.d.cts → index-DaBgwR1t.d.cts} +21 -21
  94. package/dist/index-DaBgwR1t.d.cts.map +1 -0
  95. package/dist/{index-drMNLgtV.d.ts → index-Djc5tmi3.d.ts} +36 -36
  96. package/dist/{index-drMNLgtV.d.ts.map → index-Djc5tmi3.d.ts.map} +1 -1
  97. package/dist/{index-DsSuY_wP.d.ts → index-DubKudrE.d.ts} +6 -6
  98. package/dist/{index-DsSuY_wP.d.ts.map → index-DubKudrE.d.ts.map} +1 -1
  99. package/dist/{index-hK6woeqR.d.ts → index-DymdaDrj.d.cts} +6 -6
  100. package/dist/{index-CuTHt_2o.d.cts.map → index-DymdaDrj.d.cts.map} +1 -1
  101. package/dist/{index-DoGBvZ4J.d.ts → index-FHPC_VE1.d.ts} +35 -35
  102. package/dist/{index-DoGBvZ4J.d.ts.map → index-FHPC_VE1.d.ts.map} +1 -1
  103. package/dist/{index-BHMwBAFH.d.cts → index-PU5WNOH9.d.cts} +3 -3
  104. package/dist/{index-BHMwBAFH.d.cts.map → index-PU5WNOH9.d.cts.map} +1 -1
  105. package/dist/{index-Bd-E0JM1.d.ts → index-aHcGnXHf.d.ts} +3 -3
  106. package/dist/{index-Bd-E0JM1.d.ts.map → index-aHcGnXHf.d.ts.map} +1 -1
  107. package/dist/{index-CnIrK5L3.d.cts → index-hacHTzh4.d.cts} +35 -35
  108. package/dist/{index-CnIrK5L3.d.cts.map → index-hacHTzh4.d.cts.map} +1 -1
  109. package/dist/{index-BQDEnYTq.d.ts → index-lot50R9R.d.ts} +3 -3
  110. package/dist/{index-BQDEnYTq.d.ts.map → index-lot50R9R.d.ts.map} +1 -1
  111. package/dist/{index-CCUQ-2Ic.d.cts → index-noH6pESQ.d.ts} +34 -34
  112. package/dist/index-noH6pESQ.d.ts.map +1 -0
  113. package/dist/{index-DvAmzIEe.d.ts → index-tIGuHSXb.d.ts} +4 -4
  114. package/dist/{index-DvAmzIEe.d.ts.map → index-tIGuHSXb.d.ts.map} +1 -1
  115. package/dist/index.cjs +2 -2
  116. package/dist/index.d.cts +19 -19
  117. package/dist/index.d.ts +20 -20
  118. package/dist/index.js +2 -2
  119. package/dist/partials/FieldCopyTestIdButton/index.d.cts +1 -1
  120. package/dist/partials/FieldCopyTestIdButton/index.d.ts +1 -1
  121. package/dist/partials/FieldValidationError/index.d.cts +1 -1
  122. package/dist/partials/FieldValidationError/index.d.ts +1 -1
  123. package/dist/useController-Co8wbo-Y.d.ts.map +1 -1
  124. package/dist/{useFormContext-B7ooPCfd.d.ts → useFormContext-DDx8LD8e.d.ts} +3 -3
  125. package/dist/{useFormContext-B7ooPCfd.d.ts.map → useFormContext-DDx8LD8e.d.ts.map} +1 -1
  126. package/dist/{useFormContext-DihY1N8O.d.cts → useFormContext-oEivkWtB.d.cts} +19 -19
  127. package/dist/{useFormContext-DihY1N8O.d.cts.map → useFormContext-oEivkWtB.d.cts.map} +1 -1
  128. package/dist/{useUniformField-8ODkBNpn.d.cts → useUniformField-DFXQO9dw.d.cts} +2 -2
  129. package/dist/{useUniformField-8ODkBNpn.d.cts.map → useUniformField-DFXQO9dw.d.cts.map} +1 -1
  130. package/dist/{useUniformField-CJX0u3Ou.d.ts → useUniformField-q3GCAV85.d.ts} +2 -2
  131. package/dist/{useUniformField-CJX0u3Ou.d.ts.map → useUniformField-q3GCAV85.d.ts.map} +1 -1
  132. package/dist/{useUniformFieldArray-DF83iIC1.d.cts → useUniformFieldArray-B3smveBW.d.cts} +13 -13
  133. package/dist/{useUniformFieldArray-DF83iIC1.d.cts.map → useUniformFieldArray-B3smveBW.d.cts.map} +1 -1
  134. package/dist/{useUniformFieldArray-DFGgYtxz.d.ts → useUniformFieldArray-CmACueEO.d.ts} +3 -3
  135. package/dist/{useUniformFieldArray-DFGgYtxz.d.ts.map → useUniformFieldArray-CmACueEO.d.ts.map} +1 -1
  136. package/package.json +2 -2
  137. package/dist/FieldArray-Bnv1_-Rl.js.map +0 -1
  138. package/dist/FieldArray-DgJgrLOY.cjs.map +0 -1
  139. package/dist/FieldCard-CLd4PaoX.js.map +0 -1
  140. package/dist/FieldCard-CeEnVxiB.cjs.map +0 -1
  141. package/dist/index-BM5ClMN4.d.ts.map +0 -1
  142. package/dist/index-BSZJQBCK.d.ts.map +0 -1
  143. package/dist/index-BxV89x6q.d.cts.map +0 -1
  144. package/dist/index-C3yzuYLc.d.cts.map +0 -1
  145. package/dist/index-CCUQ-2Ic.d.cts.map +0 -1
  146. package/dist/index-CJse-RZf.d.cts.map +0 -1
  147. package/dist/index-DGryaZXZ.d.ts.map +0 -1
  148. package/dist/index-DMphDWRk.d.ts.map +0 -1
  149. package/dist/index-DN9Ke6Y8.d.cts.map +0 -1
  150. package/dist/index-RiAo6yCB.d.ts.map +0 -1
  151. package/dist/index-eJFvyVyS.d.cts +0 -278
  152. package/dist/index-eJFvyVyS.d.cts.map +0 -1
  153. package/dist/index-uNWK5Vb5.d.ts.map +0 -1
@@ -1,2 +1,2 @@
1
- import { n as Checkboxes, r as CheckboxesProps, t as CheckboxOption } from "../index-DLJiYqVE.cjs";
1
+ import { n as Checkboxes, r as CheckboxesProps, t as CheckboxOption } from "../index-CZ5EIIjq.cjs";
2
2
  export { CheckboxOption, Checkboxes, Checkboxes as default, CheckboxesProps };
@@ -1,2 +1,2 @@
1
- import { n as Checkboxes, r as CheckboxesProps, t as CheckboxOption } from "../index-DsSuY_wP.js";
1
+ import { n as Checkboxes, r as CheckboxesProps, t as CheckboxOption } from "../index-DubKudrE.js";
2
2
  export { CheckboxOption, Checkboxes, Checkboxes as default, CheckboxesProps };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_FieldArray = require('../FieldArray-DgJgrLOY.cjs');
2
+ const require_FieldArray = require('../FieldArray-BgvSTDWi.cjs');
3
3
 
4
4
  exports.FieldArray = require_FieldArray.FieldArray_default$1;
5
5
  exports.default = require_FieldArray.FieldArray_default;
@@ -1,2 +1,2 @@
1
- import { i as FieldArrayProps, n as FieldArrayChildrenRenderFn, r as FieldArrayFeatures, t as FieldArray } from "../index-Bs-1Pwc6.cjs";
1
+ import { i as FieldArrayProps, n as FieldArrayChildrenRenderFn, r as FieldArrayFeatures, t as FieldArray } from "../index-Ct2YYfiU.cjs";
2
2
  export { FieldArray, FieldArray as default, FieldArrayChildrenRenderFn, FieldArrayFeatures, FieldArrayProps };
@@ -1,2 +1,2 @@
1
- import { i as FieldArrayProps, n as FieldArrayChildrenRenderFn, r as FieldArrayFeatures, t as FieldArray } from "../index-CODzh0zX.js";
1
+ import { i as FieldArrayProps, n as FieldArrayChildrenRenderFn, r as FieldArrayFeatures, t as FieldArray } from "../index-CJ90vm9t.js";
2
2
  export { FieldArray, FieldArray as default, FieldArrayChildrenRenderFn, FieldArrayFeatures, FieldArrayProps };
@@ -1,3 +1,3 @@
1
- import { n as FieldArray_default, t as FieldArray_default$1 } from "../FieldArray-Bnv1_-Rl.js";
1
+ import { n as FieldArray_default, t as FieldArray_default$1 } from "../FieldArray-C8Ipn-tM.js";
2
2
 
3
3
  export { FieldArray_default as FieldArray, FieldArray_default$1 as default };
@@ -297,7 +297,7 @@ const FieldArrayValidationError = ({ name }) => {
297
297
  },
298
298
  style: { overflow: "hidden" },
299
299
  transition: {
300
- duration: .2,
300
+ duration: .4,
301
301
  ease: "circOut"
302
302
  },
303
303
  animate: disableAnimation ? void 0 : {
@@ -306,7 +306,7 @@ const FieldArrayValidationError = ({ name }) => {
306
306
  },
307
307
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
308
308
  ...getHelperWrapperProps(),
309
- className: (0, _fuf_stack_pixel_utils.cn)(getHelperWrapperProps()?.className, "block px-3 py-2"),
309
+ className: (0, _fuf_stack_pixel_utils.cn)(getHelperWrapperProps()?.className, "block px-3 pb-2 pt-1"),
310
310
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
311
311
  ...getErrorMessageProps(),
312
312
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_FieldValidationError.FieldValidationError_default$1, {
@@ -512,4 +512,4 @@ Object.defineProperty(exports, 'FieldArray_default$1', {
512
512
  return FieldArray_default$1;
513
513
  }
514
514
  });
515
- //# sourceMappingURL=FieldArray-DgJgrLOY.cjs.map
515
+ //# sourceMappingURL=FieldArray-BgvSTDWi.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldArray-BgvSTDWi.cjs","names":["Button","FaPlus","FaCopy","VscInsert","FaTimes","Menu","Button","FaTimes","motion","FaGripVertical","CSS","AnimatePresence","motion","SortDragHandle","Grid","ElementActionsMenu","ElementRemoveButton","useUniformField","useUniformField","AnimatePresence","motion","FieldValidationError","PointerSensor","KeyboardSensor","DndContext","closestCenter","restrictToVerticalAxis","restrictToWindowEdges","SortableContext","verticalListSortingStrategy","useUniformFieldArray","FieldArrayLabel","SortContext","flatArrayKey","FieldArrayElement","FieldArrayValidationError","ElementAppendButton","FieldArray"],"sources":["../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/FieldArrayValidationError.tsx","../src/FieldArray/subcomponents/SortContext.tsx","../src/FieldArray/FieldArray.tsx","../src/FieldArray/index.ts"],"sourcesContent":["import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\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 used in e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n return (\n <Button\n disableAnimation\n className={cn(className)}\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 { cn } from '@fuf-stack/pixel-utils';\nimport { Menu } from '@fuf-stack/pixels';\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 /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute used in 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 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 // Build menu items based on available 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 { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\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 used in e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\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 { cn } from '@fuf-stack/pixel-utils';\n\ninterface SortDragHandleProps {\n /** Optional CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute used in 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 // Get dnd-kit sortable attributes and listeners\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\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 { 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 { cn } from '@fuf-stack/pixel-utils';\n\nimport { Grid } from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport interface FieldArrayElementMethods {\n /** Add new element at end */\n append: () => void;\n /** Clone current element */\n duplicate: () => void;\n /** Add new element after current */\n insert: () => void;\n /** Remove current element */\n remove: () => void;\n}\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class names for component parts */\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 of the element */\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 // Apply transform styles when sortable is enabled for smooth drag animations\n // transform: handles the item's position during drag\n // transition: controls the animation timing when dropping\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // Local visibility to allow exit animation before removing from RHF state\n const [isVisible, setIsVisible] = useState(true);\n\n // Motion variants for the list item\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 // Height animation handled on <motion.li> using overflow hidden\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={() => {\n methods.remove();\n }}\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 showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n methods={{\n ...methods,\n remove: () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n },\n }}\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 testId={`${testId}_remove_button`}\n onClick={() => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n }}\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 { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Label content */\n label: ReactNode;\n /** Field name */\n name: string;\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 the label props from useUniformField.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n label: _label,\n name,\n}: FieldArrayLabelProps) => {\n const { error, getLabelProps, invalid, label } = useUniformField({\n name,\n label: _label,\n });\n\n // when no label is provided, don't render anything\n if (!_label) {\n return null;\n }\n\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = invalid && error?._errors;\n\n return (\n <div\n {...getLabelProps()}\n aria-level={3}\n role=\"heading\"\n className={cn(getLabelProps()?.className, className, {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n })}\n >\n {label}\n </div>\n );\n};\n\nexport default FieldArrayLabel;\n","import {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\n\nexport interface FieldArrayValidationErrorProps {\n /** Field name */\n name: 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 name,\n}: FieldArrayValidationErrorProps) => {\n const {\n error,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n testId,\n } = useUniformField({\n name,\n });\n\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = invalid && error?._errors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\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 animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n >\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible and add padding (pt-1 to compensate for inner content's top padding)\n 'block px-3 pb-2 pt-1',\n )}\n >\n <div {...getErrorMessageProps()}>\n <FieldValidationError\n // @ts-expect-error - error._errors exists but not typed\n error={error._errors}\n testId={testId}\n />\n </div>\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 { useFormContext } 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 /** name of the field array */\n name: 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 name,\n sortable,\n}: SortContextProps): ReactNode => {\n const { trigger } = useFormContext();\n\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 // Finally trigger validation for the array field,\n // so validation errors are updated for the new order\n trigger(name);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n strategy={verticalListSortingStrategy}\n items={fields.map((field) => {\n return field.id;\n })}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { FieldArrayElementMethods } from './subcomponents/FieldArrayElement';\nimport type { FieldArrayProps } from './types';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { flatArrayKey } from '../helpers';\nimport { useUniformFieldArray } from '../hooks/useUniformFieldArray';\nimport ElementAppendButton from './subcomponents/ElementAppendButton';\nimport FieldArrayElement from './subcomponents/FieldArrayElement';\nimport FieldArrayLabel from './subcomponents/FieldArrayLabel';\nimport FieldArrayValidationError from './subcomponents/FieldArrayValidationError';\nimport SortContext from './subcomponents/SortContext';\n\nexport const fieldArrayVariants = tv({\n slots: {\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 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 /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // override HeroUI label positioning and display\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 wrapper */\n listWrapper: ['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 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\n/**\n * FieldArray component based in [RHF useFieldArray](https://react-hook-form.com/docs/usefieldarray)\n */\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 {\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n getValues,\n testId,\n } = useUniformFieldArray({\n name,\n flat,\n elementInitialValue: _elementInitialValue,\n lastElementNotRemovable,\n ...uniformFieldProps,\n });\n\n // className from slots\n const variants = fieldArrayVariants({ hasLabel: !!uniformFieldProps.label });\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base}>\n {/* field array label */}\n <FieldArrayLabel\n className={className.label}\n label={uniformFieldProps.label}\n name={name}\n />\n\n {fields.length ? (\n /* list wrapper */\n <div className={cn(className.listWrapper)}>\n {/* sortable context */}\n <SortContext\n fields={fields}\n move={move}\n name={name}\n sortable={sortable}\n >\n {/* list container */}\n <ul className={className.list} data-testid={testId}>\n {/* fields / list elements */}\n {fields.map((field, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n // create methods for element\n const elementMethods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue);\n },\n duplicate: () => {\n const values = getValues(name);\n const currentValue = (values as unknown[])[index];\n const nextValue = flat\n ? { [flatArrayKey]: currentValue }\n : currentValue;\n insert(index + 1, nextValue);\n },\n insert: () => {\n insert(index + 1, elementInitialValue);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return (\n <FieldArrayElement\n key={field.id}\n className={className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={field.id}\n index={index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={elementMethods}\n sortable={sortable}\n testId={elementTestId}\n >\n {children({\n index,\n length: fields.length,\n methods: elementMethods,\n name: elementName,\n testId: elementTestId,\n })}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError name={name} />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={className.appendButton}\n testId={`${testId}_append_button`}\n onClick={() => {\n append(elementInitialValue);\n }}\n />\n </div>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { FieldArray };\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAM,uBAAuB,EAC3B,mBAAmB,eACnB,YAAY,QACZ,SACA,SAAS,aACqB;AAC9B,QACE,4CAACA;EACC;EACA,0CAAc,UAAU;EACf;EACT,MAAK;EACG;EACR,SAAQ;aAER,2CAACC,0BAAS,EACV,2CAAC,oBAAM,mBAAwB;GACxB;;AAIb,kCAAe;;;;;;;ACVf,MAAM,sBAAsB,EAC1B,YAAY,QACZ,YAAY,OACZ,cAAc,OACd,aAAa,MACb,SACA,SAAS,aACoB;CAC7B,MAAM,gBAAgB,QAAa;AACjC,UAAQ,KAAR;GACE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hB;AAED,cACE,2CAACC;QAEY;QACO;QACP;QACU;QACb;QACR,IAAI,MAAM;QACH;QACM;QACb,kBAAkB;QAClB,SAAS;QACC;QACV,QAAQ;kBAEP,SAAS;SACR;SACA,QAAQ,OAAO;SACf,SAAS;SACT,MAAM;SACN,QAAQ;SACT,CAAC;UApBG,MAAM,GAqBO;QAEtB;OACC;MACO;KACV,GACJ;GAGJ,2CAACC,qCAAgC,OAAQ;GAGzC,2CAACC;IACmB;IAClB,WAAW,UAAU;IACrB,QAAQ,GAAG,OAAO;IAClB,eAAe;AACb,YAAO,oBAAoB;;KAE7B;;GACE;;AAIV,2BAAe;;;;AC1Of,yBAAeC"}
@@ -296,7 +296,7 @@ const FieldArrayValidationError = ({ name }) => {
296
296
  },
297
297
  style: { overflow: "hidden" },
298
298
  transition: {
299
- duration: .2,
299
+ duration: .4,
300
300
  ease: "circOut"
301
301
  },
302
302
  animate: disableAnimation ? void 0 : {
@@ -305,7 +305,7 @@ const FieldArrayValidationError = ({ name }) => {
305
305
  },
306
306
  children: /* @__PURE__ */ jsx("div", {
307
307
  ...getHelperWrapperProps(),
308
- className: cn(getHelperWrapperProps()?.className, "block px-3 py-2"),
308
+ className: cn(getHelperWrapperProps()?.className, "block px-3 pb-2 pt-1"),
309
309
  children: /* @__PURE__ */ jsx("div", {
310
310
  ...getErrorMessageProps(),
311
311
  children: /* @__PURE__ */ jsx(FieldValidationError_default, {
@@ -500,4 +500,4 @@ var FieldArray_default = FieldArray_default$1;
500
500
 
501
501
  //#endregion
502
502
  export { FieldArray_default$1 as n, FieldArray_default as t };
503
- //# sourceMappingURL=FieldArray-Bnv1_-Rl.js.map
503
+ //# sourceMappingURL=FieldArray-C8Ipn-tM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldArray-C8Ipn-tM.js","names":["SortDragHandle","Grid","ElementActionsMenu","ElementRemoveButton","FieldValidationError","FieldArrayLabel","SortContext","FieldArrayElement","FieldArrayValidationError","ElementAppendButton","FieldArray"],"sources":["../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/FieldArrayValidationError.tsx","../src/FieldArray/subcomponents/SortContext.tsx","../src/FieldArray/FieldArray.tsx","../src/FieldArray/index.ts"],"sourcesContent":["import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\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 used in e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n return (\n <Button\n disableAnimation\n className={cn(className)}\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 { cn } from '@fuf-stack/pixel-utils';\nimport { Menu } from '@fuf-stack/pixels';\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 /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute used in 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 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 // Build menu items based on available 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 { cn } from '@fuf-stack/pixel-utils';\nimport { Button } from '@fuf-stack/pixels';\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 used in e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\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 { cn } from '@fuf-stack/pixel-utils';\n\ninterface SortDragHandleProps {\n /** Optional CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute used in 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 // Get dnd-kit sortable attributes and listeners\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\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 { 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 { cn } from '@fuf-stack/pixel-utils';\n\nimport { Grid } from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport interface FieldArrayElementMethods {\n /** Add new element at end */\n append: () => void;\n /** Clone current element */\n duplicate: () => void;\n /** Add new element after current */\n insert: () => void;\n /** Remove current element */\n remove: () => void;\n}\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class names for component parts */\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 of the element */\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 // Apply transform styles when sortable is enabled for smooth drag animations\n // transform: handles the item's position during drag\n // transition: controls the animation timing when dropping\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // Local visibility to allow exit animation before removing from RHF state\n const [isVisible, setIsVisible] = useState(true);\n\n // Motion variants for the list item\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 // Height animation handled on <motion.li> using overflow hidden\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={() => {\n methods.remove();\n }}\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 showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n methods={{\n ...methods,\n remove: () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n },\n }}\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 testId={`${testId}_remove_button`}\n onClick={() => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n }}\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 { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Label content */\n label: ReactNode;\n /** Field name */\n name: string;\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 the label props from useUniformField.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n label: _label,\n name,\n}: FieldArrayLabelProps) => {\n const { error, getLabelProps, invalid, label } = useUniformField({\n name,\n label: _label,\n });\n\n // when no label is provided, don't render anything\n if (!_label) {\n return null;\n }\n\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = invalid && error?._errors;\n\n return (\n <div\n {...getLabelProps()}\n aria-level={3}\n role=\"heading\"\n className={cn(getLabelProps()?.className, className, {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n })}\n >\n {label}\n </div>\n );\n};\n\nexport default FieldArrayLabel;\n","import {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\n\nexport interface FieldArrayValidationErrorProps {\n /** Field name */\n name: 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 name,\n}: FieldArrayValidationErrorProps) => {\n const {\n error,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n testId,\n } = useUniformField({\n name,\n });\n\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = invalid && error?._errors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\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 animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n >\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible and add padding (pt-1 to compensate for inner content's top padding)\n 'block px-3 pb-2 pt-1',\n )}\n >\n <div {...getErrorMessageProps()}>\n <FieldValidationError\n // @ts-expect-error - error._errors exists but not typed\n error={error._errors}\n testId={testId}\n />\n </div>\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 { useFormContext } 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 /** name of the field array */\n name: 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 name,\n sortable,\n}: SortContextProps): ReactNode => {\n const { trigger } = useFormContext();\n\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 // Finally trigger validation for the array field,\n // so validation errors are updated for the new order\n trigger(name);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n strategy={verticalListSortingStrategy}\n items={fields.map((field) => {\n return field.id;\n })}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { FieldArrayElementMethods } from './subcomponents/FieldArrayElement';\nimport type { FieldArrayProps } from './types';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { flatArrayKey } from '../helpers';\nimport { useUniformFieldArray } from '../hooks/useUniformFieldArray';\nimport ElementAppendButton from './subcomponents/ElementAppendButton';\nimport FieldArrayElement from './subcomponents/FieldArrayElement';\nimport FieldArrayLabel from './subcomponents/FieldArrayLabel';\nimport FieldArrayValidationError from './subcomponents/FieldArrayValidationError';\nimport SortContext from './subcomponents/SortContext';\n\nexport const fieldArrayVariants = tv({\n slots: {\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 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 /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // override HeroUI label positioning and display\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 wrapper */\n listWrapper: ['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 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\n/**\n * FieldArray component based in [RHF useFieldArray](https://react-hook-form.com/docs/usefieldarray)\n */\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 {\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n getValues,\n testId,\n } = useUniformFieldArray({\n name,\n flat,\n elementInitialValue: _elementInitialValue,\n lastElementNotRemovable,\n ...uniformFieldProps,\n });\n\n // className from slots\n const variants = fieldArrayVariants({ hasLabel: !!uniformFieldProps.label });\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base}>\n {/* field array label */}\n <FieldArrayLabel\n className={className.label}\n label={uniformFieldProps.label}\n name={name}\n />\n\n {fields.length ? (\n /* list wrapper */\n <div className={cn(className.listWrapper)}>\n {/* sortable context */}\n <SortContext\n fields={fields}\n move={move}\n name={name}\n sortable={sortable}\n >\n {/* list container */}\n <ul className={className.list} data-testid={testId}>\n {/* fields / list elements */}\n {fields.map((field, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n // create methods for element\n const elementMethods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue);\n },\n duplicate: () => {\n const values = getValues(name);\n const currentValue = (values as unknown[])[index];\n const nextValue = flat\n ? { [flatArrayKey]: currentValue }\n : currentValue;\n insert(index + 1, nextValue);\n },\n insert: () => {\n insert(index + 1, elementInitialValue);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return (\n <FieldArrayElement\n key={field.id}\n className={className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={field.id}\n index={index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={elementMethods}\n sortable={sortable}\n testId={elementTestId}\n >\n {children({\n index,\n length: fields.length,\n methods: elementMethods,\n name: elementName,\n testId: elementTestId,\n })}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError name={name} />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={className.appendButton}\n testId={`${testId}_append_button`}\n onClick={() => {\n append(elementInitialValue);\n }}\n />\n </div>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { FieldArray };\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAM,uBAAuB,EAC3B,mBAAmB,eACnB,YAAY,QACZ,SACA,SAAS,aACqB;AAC9B,QACE,qBAAC;EACC;EACA,WAAW,GAAG,UAAU;EACf;EACT,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f,MAAM,gBAAgB,GAAG,OAAO,GAAG;OAGnC,MAAM,iBAA2C;QAC/C,cAAc;AACZ,gBAAO,oBAAoB;;QAE7B,iBAAiB;SAEf,MAAM,eADS,UAAU,KAAK,CACa;SAC3C,MAAM,YAAY,OACd,GAAG,eAAe,cAAc,GAChC;AACJ,gBAAO,QAAQ,GAAG,UAAU;;QAE9B,cAAc;AACZ,gBAAO,QAAQ,GAAG,oBAAoB;;QAExC,cAAc;AACZ,gBAAO,MAAM;;QAEhB;AAED,cACE,oBAACC;QAEY;QACO;QACP;QACU;QACb;QACR,IAAI,MAAM;QACH;QACM;QACb,kBAAkB;QAClB,SAAS;QACC;QACV,QAAQ;kBAEP,SAAS;SACR;SACA,QAAQ,OAAO;SACf,SAAS;SACT,MAAM;SACN,QAAQ;SACT,CAAC;UApBG,MAAM,GAqBO;QAEtB;OACC;MACO;KACV,GACJ;GAGJ,oBAACC,qCAAgC,OAAQ;GAGzC,oBAACC;IACmB;IAClB,WAAW,UAAU;IACrB,QAAQ,GAAG,OAAO;IAClB,eAAe;AACb,YAAO,oBAAoB;;KAE7B;;GACE;;AAIV,2BAAe;;;;AC1Of,yBAAeC"}
@@ -1,4 +1,4 @@
1
- const require_FieldCard = require('../FieldCard-CeEnVxiB.cjs');
1
+ const require_FieldCard = require('../FieldCard-DcMORXZR.cjs');
2
2
 
3
3
  exports.FieldCard = require_FieldCard.FieldCard_default;
4
4
  exports.fieldCardVariants = require_FieldCard.fieldCardVariants;
@@ -1,2 +1,2 @@
1
- import { n as FieldCardProps, r as fieldCardVariants, t as FieldCard } from "../index-DN9Ke6Y8.cjs";
1
+ import { n as FieldCardProps, r as fieldCardVariants, t as FieldCard } from "../index-DW1uBiAf.cjs";
2
2
  export { FieldCard, FieldCardProps, fieldCardVariants };
@@ -1,2 +1,2 @@
1
- import { n as FieldCardProps, r as fieldCardVariants, t as FieldCard } from "../index-BSZJQBCK.js";
1
+ import { n as FieldCardProps, r as fieldCardVariants, t as FieldCard } from "../index-BuX42Bbd.js";
2
2
  export { FieldCard, FieldCardProps, fieldCardVariants };
@@ -1,3 +1,3 @@
1
- import { n as fieldCardVariants, t as FieldCard_default } from "../FieldCard-CLd4PaoX.js";
1
+ import { n as fieldCardVariants, t as FieldCard_default } from "../FieldCard-DZSiMFoO.js";
2
2
 
3
3
  export { FieldCard_default as FieldCard, fieldCardVariants };
@@ -1,4 +1,5 @@
1
1
  import { n as FieldValidationError_default } from "./FieldValidationError-BYwitb_B.js";
2
+ import { n as useFormContext, t as checkFieldIsRequired } from "./useFormContext-UFBqUfOr.js";
2
3
  import { t as useUniformField } from "./useUniformField-C6oSAFa3.js";
3
4
  import { cn, tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -12,9 +13,9 @@ import { AnimatePresence, motion, useReducedMotion } from "@fuf-stack/pixel-moti
12
13
  * accessibility attributes and animates them in/out using Framer Motion.
13
14
  */
14
15
  const FieldCardValidationError = ({ className = void 0, name }) => {
15
- const { error, getErrorMessageProps, getHelperWrapperProps, invalid, testId } = useUniformField({ name });
16
+ const { error, getErrorMessageProps, getHelperWrapperProps, testId } = useUniformField({ name });
16
17
  const disableAnimation = useReducedMotion();
17
- const hasErrors = invalid && error?._errors;
18
+ const hasErrors = !!error?._errors;
18
19
  return /* @__PURE__ */ jsx(AnimatePresence, {
19
20
  initial: !disableAnimation,
20
21
  children: hasErrors ? /* @__PURE__ */ jsx(motion.div, {
@@ -28,7 +29,7 @@ const FieldCardValidationError = ({ className = void 0, name }) => {
28
29
  },
29
30
  style: { overflow: "hidden" },
30
31
  transition: {
31
- duration: .2,
32
+ duration: .4,
32
33
  ease: "circOut"
33
34
  },
34
35
  animate: disableAnimation ? void 0 : {
@@ -53,22 +54,44 @@ var FieldCardValidationError_default = FieldCardValidationError;
53
54
 
54
55
  //#endregion
55
56
  //#region src/FieldCard/FieldCard.tsx
57
+ /**
58
+ * Recursively checks if any child field with an error is also touched.
59
+ * Returns true if at least one touched child has an error.
60
+ */
61
+ const hasVisibleChildErrors = (errors, touched) => {
62
+ if (!errors || !touched) return false;
63
+ return Object.keys(errors).filter((key) => {
64
+ return key !== "_errors";
65
+ }).some((key) => {
66
+ const errorValue = errors[key];
67
+ const touchedValue = touched[key];
68
+ if (errorValue === void 0 || touchedValue === void 0) return false;
69
+ if (Array.isArray(errorValue)) return !!touchedValue;
70
+ if (typeof errorValue === "object" && errorValue !== null) return hasVisibleChildErrors(errorValue, touchedValue);
71
+ return false;
72
+ });
73
+ };
56
74
  const fieldCardVariants = tv({
57
75
  slots: {
58
- base: ["overflow-hidden rounded-small border bg-content1"],
76
+ base: ["overflow-hidden rounded-small border bg-content1", "transition-colors duration-150 motion-reduce:transition-none"],
59
77
  label: [
60
78
  "pointer-events-auto! static! z-auto! block! w-full!",
61
79
  "translate-x-0! translate-y-0! transform-none!",
62
- "rounded-t-small border-b p-3 font-semibold text-medium"
80
+ "rounded-t-small border-b p-3 font-semibold text-medium",
81
+ "transition-colors duration-150 motion-reduce:transition-none"
63
82
  ],
64
83
  content: ["p-3", "grid gap-4"],
65
- errorFooter: ["border-t", "block px-3 py-2"]
84
+ errorFooter: [
85
+ "border-t",
86
+ "block px-3 pb-2 pt-1",
87
+ "transition-colors duration-150 motion-reduce:transition-none"
88
+ ]
66
89
  },
67
90
  variants: { invalid: {
68
91
  true: {
69
- base: "border-danger",
70
- label: "border-danger text-danger",
71
- errorFooter: "border-danger"
92
+ base: "border-danger-200",
93
+ label: "border-danger-200 text-danger",
94
+ errorFooter: "border-danger-200"
72
95
  },
73
96
  false: {
74
97
  base: "border-divider",
@@ -88,20 +111,52 @@ const fieldCardVariants = tv({
88
111
  * - Danger outline when validation errors exist
89
112
  */
90
113
  const FieldCard = ({ children, className: _className = void 0, name, ...uniformFieldProps }) => {
91
- const { error, getLabelProps, invalid, label } = useUniformField({
114
+ const { error, getLabelProps, label } = useUniformField({
92
115
  name,
93
116
  ...uniformFieldProps
94
117
  });
95
- const className = variantsToClassNames(fieldCardVariants({ invalid: invalid && error?._errors }), _className, "base");
118
+ const { control, formState: { touchedFields, submitCount }, validation } = useFormContext();
119
+ const validationInstance = validation?.baseInstance ?? validation?.instance;
120
+ const registeredFields = Array.from(control._names?.mount ?? []);
121
+ const childFieldPrefix = `${name}.`;
122
+ const isRequired = validationInstance ? registeredFields.filter((f) => {
123
+ return f.startsWith(childFieldPrefix);
124
+ }).some((f) => {
125
+ return checkFieldIsRequired(validationInstance, f.split(".").filter((k) => {
126
+ return k !== "";
127
+ }));
128
+ }) : false;
129
+ const getNestedValue = (obj, path) => {
130
+ if (!obj) return;
131
+ const keys = path.split(".");
132
+ let current = obj;
133
+ keys.every((key) => {
134
+ if (current && typeof current === "object") {
135
+ current = current[key];
136
+ return true;
137
+ }
138
+ current = void 0;
139
+ return false;
140
+ });
141
+ return current;
142
+ };
143
+ const fieldTouched = getNestedValue(touchedFields, name);
144
+ const hasObjectErrors = !!error?._errors;
145
+ const hasChildErrors = submitCount > 0 || hasVisibleChildErrors(error, fieldTouched);
146
+ const className = variantsToClassNames(fieldCardVariants({ invalid: hasObjectErrors || hasChildErrors }), _className, "base");
96
147
  return /* @__PURE__ */ jsxs("div", {
97
148
  className: className.base,
98
149
  children: [
99
- label ? /* @__PURE__ */ jsx("div", {
150
+ label ? /* @__PURE__ */ jsxs("div", {
100
151
  ...getLabelProps(),
101
152
  "aria-level": 3,
102
- className: cn(getLabelProps()?.className, className.label),
153
+ className: className.label,
103
154
  role: "heading",
104
- children: label
155
+ children: [label, isRequired ? /* @__PURE__ */ jsx("span", {
156
+ "aria-hidden": "true",
157
+ className: "ml-0.5 text-danger",
158
+ children: "*"
159
+ }) : null]
105
160
  }) : null,
106
161
  /* @__PURE__ */ jsx("div", {
107
162
  className: className.content,
@@ -118,4 +173,4 @@ var FieldCard_default = FieldCard;
118
173
 
119
174
  //#endregion
120
175
  export { fieldCardVariants as n, FieldCard_default as t };
121
- //# sourceMappingURL=FieldCard-CLd4PaoX.js.map
176
+ //# sourceMappingURL=FieldCard-DZSiMFoO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldCard-DZSiMFoO.js","names":["FieldValidationError","FieldCardValidationError"],"sources":["../src/FieldCard/subcomponents/FieldCardValidationError.tsx","../src/FieldCard/FieldCard.tsx"],"sourcesContent":["import {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { cn } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../../hooks/useUniformField';\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\n\nexport interface FieldCardValidationErrorProps {\n /** CSS class name for the error footer wrapper */\n className?: string;\n /** Field name */\n name: string;\n}\n\n/**\n * Renders validation errors in the footer of a FieldCard component.\n *\n * This component handles displaying field-level validation errors with proper\n * accessibility attributes and animates them in/out using Framer Motion.\n */\nconst FieldCardValidationError = ({\n className = undefined,\n name,\n}: FieldCardValidationErrorProps) => {\n const { error, getErrorMessageProps, getHelperWrapperProps, testId } =\n useUniformField({\n name,\n });\n\n // disable all animation if user prefers reduced motion\n const disableAnimation = useReducedMotion();\n\n // Always show object-level errors (_errors) as they represent explicit\n // validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasErrors = !!error?._errors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-card-errors\"\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 animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n >\n <div\n {...getHelperWrapperProps()}\n className={cn(getHelperWrapperProps()?.className, className)}\n >\n <div {...getErrorMessageProps()}>\n <FieldValidationError\n // @ts-expect-error - error._errors exists but not typed\n error={error._errors}\n testId={testId}\n />\n </div>\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldCardValidationError;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { checkFieldIsRequired, useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\nimport FieldCardValidationError from './subcomponents/FieldCardValidationError';\n\n/**\n * Recursively checks if any child field with an error is also touched.\n * Returns true if at least one touched child has an error.\n */\nexport const hasVisibleChildErrors = (\n errors: Record<string, unknown> | undefined,\n touched: Record<string, unknown> | undefined,\n): boolean => {\n if (!errors || !touched) {\n return false;\n }\n\n return Object.keys(errors)\n .filter((key) => {\n // Skip object-level errors (_errors) - those are handled separately\n return key !== '_errors';\n })\n .some((key) => {\n const errorValue = errors[key];\n const touchedValue = touched[key];\n\n // If this key doesn't exist in both errors and touched, skip\n if (errorValue === undefined || touchedValue === undefined) {\n return false;\n }\n\n // If errorValue is an array, it's a leaf field error\n if (Array.isArray(errorValue)) {\n // touchedValue being truthy means the field is touched\n return !!touchedValue;\n }\n\n // Recursively check nested objects\n if (typeof errorValue === 'object' && errorValue !== null) {\n return hasVisibleChildErrors(\n errorValue as Record<string, unknown>,\n touchedValue as Record<string, unknown>,\n );\n }\n\n return false;\n });\n};\n\nexport const fieldCardVariants = tv({\n slots: {\n /** base class for the field card wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border bg-content1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the label/header */\n label: [\n // override HeroUI label positioning and display\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) for proper header size\n 'rounded-t-small border-b p-3 font-semibold text-medium',\n // animate border and text color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the content */\n content: [\n // same as p-3 of Card component\n 'p-3',\n // default grid for form components (see Grid component)\n 'grid gap-4',\n ],\n /** class for the error footer wrapper */\n errorFooter: [\n 'border-t',\n // force helper to be visible and add padding (pt-1 to compensate for inner content's top padding)\n 'block px-3 pb-2 pt-1',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n },\n variants: {\n invalid: {\n true: {\n base: 'border-danger-200',\n label: 'border-danger-200 text-danger',\n errorFooter: 'border-danger-200',\n },\n false: {\n base: 'border-divider',\n label: 'border-divider text-foreground',\n errorFooter: 'border-divider',\n },\n },\n },\n defaultVariants: {\n invalid: false,\n },\n});\n\ntype ClassName = TVClassName<typeof fieldCardVariants>;\n\nexport interface FieldCardProps {\n /** Content to render inside the card */\n children: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Label content for the card header */\n label: ReactNode;\n /** Field name for validation */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\n/**\n * FieldCard component - A card-styled container with label header and error footer\n *\n * Displays form field content in a card layout with:\n * - Label/title in the header\n * - Content in the body\n * - Validation errors in the footer\n * - Danger outline when validation errors exist\n */\nconst FieldCard = ({\n children,\n className: _className = undefined,\n name,\n ...uniformFieldProps\n}: FieldCardProps) => {\n const { error, getLabelProps, label } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n const {\n control,\n formState: { touchedFields, submitCount },\n validation,\n } = useFormContext();\n\n // Check if any registered child field is required\n const validationInstance = validation?.baseInstance ?? validation?.instance;\n const registeredFields: string[] = Array.from(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (control as any)._names?.mount ?? [],\n );\n const childFieldPrefix = `${name}.`;\n const isRequired = validationInstance\n ? registeredFields\n .filter((f) => {\n return f.startsWith(childFieldPrefix);\n })\n .some((f) => {\n return checkFieldIsRequired(\n validationInstance,\n f.split('.').filter((k) => {\n return k !== '';\n }),\n );\n })\n : false;\n\n // Get touched state for this field's children by traversing the path\n const getNestedValue = (\n obj: Record<string, unknown> | undefined,\n path: string,\n ): Record<string, unknown> | undefined => {\n if (!obj) {\n return undefined;\n }\n const keys = path.split('.');\n let current: unknown = obj;\n keys.every((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n return true;\n }\n current = undefined;\n return false;\n });\n return current as Record<string, unknown> | undefined;\n };\n\n const fieldTouched = getNestedValue(\n touchedFields as Record<string, unknown>,\n name,\n );\n\n // Check for object-level errors (_errors) - always show these as they represent\n // explicit object-level validation rules (e.g., refineObject custom validators)\n // @ts-expect-error - error._errors exists but not typed\n const hasObjectErrors = !!error?._errors;\n\n // Check if any child field with an error is also touched\n const hasChildErrors =\n submitCount > 0 ||\n hasVisibleChildErrors(\n error as unknown as Record<string, unknown>,\n fieldTouched,\n );\n\n // Show invalid state if there are object errors or visible child errors\n const showInvalid = hasObjectErrors || hasChildErrors;\n\n // className from slots\n const variants = fieldCardVariants({ invalid: showInvalid });\n const className = variantsToClassNames(variants, _className, 'base');\n\n return (\n <div className={className.base}>\n {/* card header with label */}\n {label ? (\n <div\n {...getLabelProps()}\n aria-level={3}\n // Override getLabelProps className to use our own invalid styling based on hasErrors,\n // not HeroUI's which is based on any child field being invalid\n className={className.label}\n role=\"heading\"\n >\n {label}\n {/* Manual asterisk: getLabelProps uses schema-required for the object itself,\n but FieldCard needs asterisk based on whether any CHILD field is required */}\n {isRequired ? (\n <span aria-hidden=\"true\" className=\"ml-0.5 text-danger\">\n *\n </span>\n ) : null}\n </div>\n ) : null}\n\n {/* card content */}\n <div className={className.content}>{children}</div>\n\n {/* card footer with validation errors */}\n <FieldCardValidationError className={className.errorFooter} name={name} />\n </div>\n );\n};\n\nexport default FieldCard;\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,4BAA4B,EAChC,YAAY,QACZ,WACmC;CACnC,MAAM,EAAE,OAAO,sBAAsB,uBAAuB,WAC1D,gBAAgB,EACd,MACD,CAAC;CAGJ,MAAM,mBAAmB,kBAAkB;CAK3C,MAAM,YAAY,CAAC,CAAC,OAAO;AAE3B,QACE,oBAA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I,WAAW,UAAU;IAAU;KAAe;GAGnD,oBAACC;IAAyB,WAAW,UAAU;IAAmB;KAAQ;;GACtE;;AAIV,wBAAe"}
@@ -1,5 +1,6 @@
1
1
  const require_FormContext = require('./FormContext-CeFKQmVH.cjs');
2
2
  const require_FieldValidationError = require('./FieldValidationError-A384-L3Y.cjs');
3
+ const require_useFormContext = require('./useFormContext-DJiJlfGJ.cjs');
3
4
  const require_useUniformField = require('./useUniformField-Dd3AnpgE.cjs');
4
5
  let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -13,9 +14,9 @@ let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
13
14
  * accessibility attributes and animates them in/out using Framer Motion.
14
15
  */
15
16
  const FieldCardValidationError = ({ className = void 0, name }) => {
16
- const { error, getErrorMessageProps, getHelperWrapperProps, invalid, testId } = require_useUniformField.useUniformField({ name });
17
+ const { error, getErrorMessageProps, getHelperWrapperProps, testId } = require_useUniformField.useUniformField({ name });
17
18
  const disableAnimation = (0, _fuf_stack_pixel_motion.useReducedMotion)();
18
- const hasErrors = invalid && error?._errors;
19
+ const hasErrors = !!error?._errors;
19
20
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixel_motion.AnimatePresence, {
20
21
  initial: !disableAnimation,
21
22
  children: hasErrors ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixel_motion.motion.div, {
@@ -29,7 +30,7 @@ const FieldCardValidationError = ({ className = void 0, name }) => {
29
30
  },
30
31
  style: { overflow: "hidden" },
31
32
  transition: {
32
- duration: .2,
33
+ duration: .4,
33
34
  ease: "circOut"
34
35
  },
35
36
  animate: disableAnimation ? void 0 : {
@@ -54,22 +55,44 @@ var FieldCardValidationError_default = FieldCardValidationError;
54
55
 
55
56
  //#endregion
56
57
  //#region src/FieldCard/FieldCard.tsx
58
+ /**
59
+ * Recursively checks if any child field with an error is also touched.
60
+ * Returns true if at least one touched child has an error.
61
+ */
62
+ const hasVisibleChildErrors = (errors, touched) => {
63
+ if (!errors || !touched) return false;
64
+ return Object.keys(errors).filter((key) => {
65
+ return key !== "_errors";
66
+ }).some((key) => {
67
+ const errorValue = errors[key];
68
+ const touchedValue = touched[key];
69
+ if (errorValue === void 0 || touchedValue === void 0) return false;
70
+ if (Array.isArray(errorValue)) return !!touchedValue;
71
+ if (typeof errorValue === "object" && errorValue !== null) return hasVisibleChildErrors(errorValue, touchedValue);
72
+ return false;
73
+ });
74
+ };
57
75
  const fieldCardVariants = (0, _fuf_stack_pixel_utils.tv)({
58
76
  slots: {
59
- base: ["overflow-hidden rounded-small border bg-content1"],
77
+ base: ["overflow-hidden rounded-small border bg-content1", "transition-colors duration-150 motion-reduce:transition-none"],
60
78
  label: [
61
79
  "pointer-events-auto! static! z-auto! block! w-full!",
62
80
  "translate-x-0! translate-y-0! transform-none!",
63
- "rounded-t-small border-b p-3 font-semibold text-medium"
81
+ "rounded-t-small border-b p-3 font-semibold text-medium",
82
+ "transition-colors duration-150 motion-reduce:transition-none"
64
83
  ],
65
84
  content: ["p-3", "grid gap-4"],
66
- errorFooter: ["border-t", "block px-3 py-2"]
85
+ errorFooter: [
86
+ "border-t",
87
+ "block px-3 pb-2 pt-1",
88
+ "transition-colors duration-150 motion-reduce:transition-none"
89
+ ]
67
90
  },
68
91
  variants: { invalid: {
69
92
  true: {
70
- base: "border-danger",
71
- label: "border-danger text-danger",
72
- errorFooter: "border-danger"
93
+ base: "border-danger-200",
94
+ label: "border-danger-200 text-danger",
95
+ errorFooter: "border-danger-200"
73
96
  },
74
97
  false: {
75
98
  base: "border-divider",
@@ -89,20 +112,52 @@ const fieldCardVariants = (0, _fuf_stack_pixel_utils.tv)({
89
112
  * - Danger outline when validation errors exist
90
113
  */
91
114
  const FieldCard = ({ children, className: _className = void 0, name, ...uniformFieldProps }) => {
92
- const { error, getLabelProps, invalid, label } = require_useUniformField.useUniformField({
115
+ const { error, getLabelProps, label } = require_useUniformField.useUniformField({
93
116
  name,
94
117
  ...uniformFieldProps
95
118
  });
96
- const className = (0, _fuf_stack_pixel_utils.variantsToClassNames)(fieldCardVariants({ invalid: invalid && error?._errors }), _className, "base");
119
+ const { control, formState: { touchedFields, submitCount }, validation } = require_useFormContext.useFormContext();
120
+ const validationInstance = validation?.baseInstance ?? validation?.instance;
121
+ const registeredFields = Array.from(control._names?.mount ?? []);
122
+ const childFieldPrefix = `${name}.`;
123
+ const isRequired = validationInstance ? registeredFields.filter((f) => {
124
+ return f.startsWith(childFieldPrefix);
125
+ }).some((f) => {
126
+ return require_useFormContext.checkFieldIsRequired(validationInstance, f.split(".").filter((k) => {
127
+ return k !== "";
128
+ }));
129
+ }) : false;
130
+ const getNestedValue = (obj, path) => {
131
+ if (!obj) return;
132
+ const keys = path.split(".");
133
+ let current = obj;
134
+ keys.every((key) => {
135
+ if (current && typeof current === "object") {
136
+ current = current[key];
137
+ return true;
138
+ }
139
+ current = void 0;
140
+ return false;
141
+ });
142
+ return current;
143
+ };
144
+ const fieldTouched = getNestedValue(touchedFields, name);
145
+ const hasObjectErrors = !!error?._errors;
146
+ const hasChildErrors = submitCount > 0 || hasVisibleChildErrors(error, fieldTouched);
147
+ const className = (0, _fuf_stack_pixel_utils.variantsToClassNames)(fieldCardVariants({ invalid: hasObjectErrors || hasChildErrors }), _className, "base");
97
148
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
98
149
  className: className.base,
99
150
  children: [
100
- label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
151
+ label ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
101
152
  ...getLabelProps(),
102
153
  "aria-level": 3,
103
- className: (0, _fuf_stack_pixel_utils.cn)(getLabelProps()?.className, className.label),
154
+ className: className.label,
104
155
  role: "heading",
105
- children: label
156
+ children: [label, isRequired ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
157
+ "aria-hidden": "true",
158
+ className: "ml-0.5 text-danger",
159
+ children: "*"
160
+ }) : null]
106
161
  }) : null,
107
162
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
108
163
  className: className.content,
@@ -130,4 +185,4 @@ Object.defineProperty(exports, 'fieldCardVariants', {
130
185
  return fieldCardVariants;
131
186
  }
132
187
  });
133
- //# sourceMappingURL=FieldCard-CeEnVxiB.cjs.map
188
+ //# sourceMappingURL=FieldCard-DcMORXZR.cjs.map