@fuf-stack/uniform 2.0.0-next.3 → 2.0.0-next.5

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 (117) hide show
  1. package/dist/Checkboxes/index.d.mts +50 -50
  2. package/dist/Checkboxes/index.d.mts.map +1 -1
  3. package/dist/Checkboxes/index.mjs +14 -12
  4. package/dist/Checkboxes/index.mjs.map +1 -1
  5. package/dist/DatePicker/index.d.mts +27 -90
  6. package/dist/DatePicker/index.d.mts.map +1 -1
  7. package/dist/DatePicker/index.mjs +31 -39
  8. package/dist/DatePicker/index.mjs.map +1 -1
  9. package/dist/FieldArray/index.d.mts +6 -6
  10. package/dist/FieldArray/index.mjs +19 -17
  11. package/dist/FieldArray/index.mjs.map +1 -1
  12. package/dist/FieldCard/index.mjs +10 -13
  13. package/dist/FieldCard/index.mjs.map +1 -1
  14. package/dist/FieldHelper-B1DWl7eu.mjs +38 -0
  15. package/dist/FieldHelper-B1DWl7eu.mjs.map +1 -0
  16. package/dist/FieldLabel-DMTqq0Jj.mjs +29 -0
  17. package/dist/FieldLabel-DMTqq0Jj.mjs.map +1 -0
  18. package/dist/{FieldLayout-DcvQU0zN.mjs → FieldLayout-C9MEBZAC.mjs} +10 -17
  19. package/dist/FieldLayout-C9MEBZAC.mjs.map +1 -0
  20. package/dist/FieldReset/index.d.mts +1 -1
  21. package/dist/FieldReset/index.mjs +1 -1
  22. package/dist/{FieldValidationError-iAayfTEw.mjs → FieldValidationError-BuLvuRyi.mjs} +3 -3
  23. package/dist/FieldValidationError-BuLvuRyi.mjs.map +1 -0
  24. package/dist/Form/index.d.mts +2 -2
  25. package/dist/Form/index.mjs +4 -4
  26. package/dist/Form/index.mjs.map +1 -1
  27. package/dist/{FormContext-PXkVlBdU.mjs → FormContext-CVq3glVW.mjs} +5 -5
  28. package/dist/FormContext-CVq3glVW.mjs.map +1 -0
  29. package/dist/{FormContext-BnNJYZOo.d.mts → FormContext-Dvt3MiKq.d.mts} +3 -3
  30. package/dist/{FormContext-BnNJYZOo.d.mts.map → FormContext-Dvt3MiKq.d.mts.map} +1 -1
  31. package/dist/Input/index.d.mts +583 -418
  32. package/dist/Input/index.d.mts.map +1 -1
  33. package/dist/Input/index.mjs +16 -19
  34. package/dist/Input/index.mjs.map +1 -1
  35. package/dist/RadioBoxes/index.d.mts +101 -85
  36. package/dist/RadioBoxes/index.d.mts.map +1 -1
  37. package/dist/RadioBoxes/index.mjs +6 -14
  38. package/dist/RadioBoxes/index.mjs.map +1 -1
  39. package/dist/RadioTabs/index.d.mts +590 -335
  40. package/dist/RadioTabs/index.d.mts.map +1 -1
  41. package/dist/RadioTabs/index.mjs +15 -15
  42. package/dist/RadioTabs/index.mjs.map +1 -1
  43. package/dist/Radios/index.d.mts +52 -49
  44. package/dist/Radios/index.d.mts.map +1 -1
  45. package/dist/Radios/index.mjs +5 -13
  46. package/dist/Radios/index.mjs.map +1 -1
  47. package/dist/Select/index.d.mts +762 -570
  48. package/dist/Select/index.d.mts.map +1 -1
  49. package/dist/Select/index.mjs +14 -15
  50. package/dist/Select/index.mjs.map +1 -1
  51. package/dist/Slider/index.d.mts +658 -348
  52. package/dist/Slider/index.d.mts.map +1 -1
  53. package/dist/Slider/index.mjs +24 -32
  54. package/dist/Slider/index.mjs.map +1 -1
  55. package/dist/Switch/index.d.mts +1 -1
  56. package/dist/Switch/index.mjs +12 -17
  57. package/dist/Switch/index.mjs.map +1 -1
  58. package/dist/Switch-3ujfKWwt.d.mts +990 -0
  59. package/dist/{Switch-Db2dpGz7.d.mts.map → Switch-3ujfKWwt.d.mts.map} +1 -1
  60. package/dist/SwitchBox/index.d.mts +583 -221
  61. package/dist/SwitchBox/index.d.mts.map +1 -1
  62. package/dist/SwitchBox/index.mjs +14 -18
  63. package/dist/SwitchBox/index.mjs.map +1 -1
  64. package/dist/TextArea/index.d.mts +544 -207
  65. package/dist/TextArea/index.d.mts.map +1 -1
  66. package/dist/TextArea/index.mjs +13 -16
  67. package/dist/TextArea/index.mjs.map +1 -1
  68. package/dist/Time/index.d.mts +47 -47
  69. package/dist/Time/index.d.mts.map +1 -1
  70. package/dist/Time/index.mjs +17 -22
  71. package/dist/Time/index.mjs.map +1 -1
  72. package/dist/fieldHelperVariants-ClP8taiS.mjs +20 -0
  73. package/dist/fieldHelperVariants-ClP8taiS.mjs.map +1 -0
  74. package/dist/fieldLabelVariants-C4ZqECec.mjs +13 -0
  75. package/dist/fieldLabelVariants-C4ZqECec.mjs.map +1 -0
  76. package/dist/{FieldDescription-X_0s1Lhu.mjs → fieldProps-DWfz2jSO.mjs} +2 -13
  77. package/dist/fieldProps-DWfz2jSO.mjs.map +1 -0
  78. package/dist/hooks/useClientValidation/index.mjs +1 -1
  79. package/dist/hooks/useController/index.mjs +1 -1
  80. package/dist/hooks/useFormContext/index.d.mts +1 -1
  81. package/dist/hooks/useFormContext/index.mjs +1 -1
  82. package/dist/hooks/useInputValueDebounce/index.mjs +1 -1
  83. package/dist/hooks/useWatchFormReset/index.mjs +1 -1
  84. package/dist/hooks/useWatchUserChange/index.mjs +1 -1
  85. package/dist/{Switch-Db2dpGz7.d.mts → partials/FieldHelper/index.d.mts} +308 -407
  86. package/dist/partials/FieldHelper/index.d.mts.map +1 -0
  87. package/dist/partials/FieldHelper/index.mjs +7 -0
  88. package/dist/partials/FieldHelper/index.mjs.map +1 -0
  89. package/dist/partials/FieldLabel/index.d.mts +160 -0
  90. package/dist/partials/FieldLabel/index.d.mts.map +1 -0
  91. package/dist/partials/FieldLabel/index.mjs +7 -0
  92. package/dist/partials/FieldLabel/index.mjs.map +1 -0
  93. package/dist/partials/FieldValidationError/index.d.mts +13 -13
  94. package/dist/partials/FieldValidationError/index.mjs +1 -1
  95. package/dist/{radioControlVariants-BYRfaD6y.mjs → radioControlVariants-CxA0og5-.mjs} +16 -12
  96. package/dist/radioControlVariants-CxA0og5-.mjs.map +1 -0
  97. package/dist/{switchVariants-D16b2VaT.mjs → switchVariants-B8dq8DYP.mjs} +12 -15
  98. package/dist/switchVariants-B8dq8DYP.mjs.map +1 -0
  99. package/dist/{timeVariants-CtXyNKmW.mjs → timeVariants-CIX6R59-.mjs} +17 -15
  100. package/dist/timeVariants-CIX6R59-.mjs.map +1 -0
  101. package/dist/{useController-JtIeurpw.mjs → useController-SEAuP3G4.mjs} +6 -6
  102. package/dist/useController-SEAuP3G4.mjs.map +1 -0
  103. package/dist/{useFormContext-piqnN2L-.mjs → useFormContext-CQzJhAU4.mjs} +12 -8
  104. package/dist/useFormContext-CQzJhAU4.mjs.map +1 -0
  105. package/dist/{FieldLabel-DrNWJIVh.mjs → useUniformField-BvPoQyLL.mjs} +6 -31
  106. package/dist/useUniformField-BvPoQyLL.mjs.map +1 -0
  107. package/package.json +6 -4
  108. package/dist/FieldDescription-X_0s1Lhu.mjs.map +0 -1
  109. package/dist/FieldLabel-DrNWJIVh.mjs.map +0 -1
  110. package/dist/FieldLayout-DcvQU0zN.mjs.map +0 -1
  111. package/dist/FieldValidationError-iAayfTEw.mjs.map +0 -1
  112. package/dist/FormContext-PXkVlBdU.mjs.map +0 -1
  113. package/dist/radioControlVariants-BYRfaD6y.mjs.map +0 -1
  114. package/dist/switchVariants-D16b2VaT.mjs.map +0 -1
  115. package/dist/timeVariants-CtXyNKmW.mjs.map +0 -1
  116. package/dist/useController-JtIeurpw.mjs.map +0 -1
  117. package/dist/useFormContext-piqnN2L-.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["useRHFFieldArray","useFormContext","Grid"],"sources":["../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../src/FieldArray/fieldArrayVariants.ts","../../src/FieldArray/subcomponents/ElementAppendButton.tsx","../../src/FieldArray/subcomponents/ElementActionsMenu.tsx","../../src/FieldArray/subcomponents/ElementRemoveButton.tsx","../../src/FieldArray/subcomponents/SortDragHandle.tsx","../../src/FieldArray/subcomponents/FieldArrayElement.tsx","../../src/FieldArray/subcomponents/FieldArrayLabel.tsx","../../src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts","../../src/FieldArray/subcomponents/FieldArrayValidationError.tsx","../../src/FieldArray/subcomponents/SortContext.tsx","../../src/FieldArray/subcomponents/FieldArrayControl.tsx","../../src/FieldArray/FieldArray.tsx","../../src/FieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n FieldArray as ArrayElement,\n ArrayPath,\n FieldValues,\n Path,\n UseFieldArrayReturn,\n} from 'react-hook-form';\nimport type { UniformFieldState } from '../useUniformField/types';\nimport type { FieldArrayElementMethods, FieldArrayItem } from './types';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport useUniformField from '../useUniformField/useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Disable the field */\n disabled?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n}\n\n/**\n * Return type of `useUniformFieldArrayMethods` and `useUniformFieldArray`.\n *\n * Declared explicitly so the published declarations only reference types that\n * react-hook-form exports from its package root.\n */\nexport type UseUniformFieldArrayReturn<\n TFieldValues extends FieldValues = FieldValues,\n> = Pick<\n UseFieldArrayReturn<TFieldValues, ArrayPath<TFieldValues>>,\n 'append' | 'fields' | 'insert' | 'move' | 'remove'\n> &\n UniformFieldState<TFieldValues> & {\n /** Appends an element using the configured initial value */\n appendItem: () => void;\n /** Disables element animations during initialization, reset and reduced motion */\n disableAnimation: boolean;\n /** Value used for newly added array elements */\n elementInitialValue: NonNullable<unknown>;\n /** Bound operations and identification for each array row */\n items: FieldArrayItem[];\n /** Moves an element and validates the array afterwards */\n moveItem: (from: number, to: number) => void;\n };\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArrayMethods = <\n TFieldValues extends FieldValues = FieldValues,\n>(\n {\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n }: UseUniformFieldArrayProps<TFieldValues>,\n uniformField: UniformFieldState<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n const { testId } = uniformField.field;\n\n // bind row identification and operations for the renderer\n const items: FieldArrayItem[] = fields.map((row, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n const methods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n },\n duplicate: () => {\n const values = getValues(name as Path<TFieldValues>);\n const currentValue = (values as unknown as unknown[])[index];\n\n insert(\n index + 1,\n (flat\n ? { [flatArrayKey]: currentValue }\n : currentValue) as ArrayElement<TFieldValues>,\n );\n },\n insert: () => {\n insert(index + 1, elementInitialValue as ArrayElement<TFieldValues>);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return {\n id: row.id,\n renderProps: {\n index,\n length: fields.length,\n methods,\n name: elementName,\n testId: elementTestId,\n },\n };\n });\n\n // append an element using the configured initial value\n const appendItem = () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n };\n\n // validate the array after its row order changes\n const moveItem = (from: number, to: number) => {\n move(from, to);\n trigger(name as Path<TFieldValues>);\n };\n\n return {\n // Field array methods and state\n fields,\n append,\n appendItem,\n items,\n remove,\n insert,\n move,\n moveItem,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n\nconst useUniformFieldArray = <TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldArrayProps<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const field = useUniformField<TFieldValues>({\n ...params,\n name: params.name as Path<TFieldValues> & string,\n });\n return useUniformFieldArrayMethods(params, field);\n};\nexport default useUniformFieldArray;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nexport const fieldArrayVariants = tv({\n slots: {\n /** class for the actions menu button */\n actionsMenuButton: [\n // base styles\n 'flex items-center justify-center text-default-600',\n // fixed height/no round corners/center align\n 'h-full rounded-none',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the append button */\n appendButton: [\n // base styles\n 'w-full justify-start rounded-b-small rounded-t-none font-semibold',\n // match label height (p-3 = 12px vertical padding + text-base line height)\n '!h-[48px] !min-h-0',\n // focus styles - inset ring with rounded bottom corners to match container\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** base class for the field array wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border border-divider bg-content1',\n // divider between items\n 'divide-y divide-divider',\n ],\n /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) instead of text-base for correct 48px height\n 'rounded-t-small p-3 font-semibold text-medium',\n ],\n /** class for the list */\n list: ['overflow-hidden'],\n /** class for the list item (performs motion animations) */\n listItem: [\n // base styles\n 'group relative flex flex-row',\n // overlap borders by shifting first item up 1px (similar to how last item overlaps with append button)\n 'first:-mt-px',\n ],\n /** class for the list item inner */\n listItemInner: [\n // base styles\n 'flex w-full flex-row items-stretch divide-divider bg-content1',\n // x division and borders\n 'divide-x divide-solid border-b border-t border-divider',\n ],\n /** class for the list wrapper */\n listWrapper: ['overflow-hidden'],\n /** class for the remove button */\n removeButton: [\n // base styles\n 'flex items-center justify-center',\n // fixed height/no round corners\n '!h-full !min-h-0 !rounded-none px-3',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n /** class for the sort drag handle */\n sortDragHandle: [\n // base styles\n 'flex cursor-grab items-center justify-center px-2 text-default-600 transition-colors',\n // hover and dragging state\n 'hover:bg-default-100 active:cursor-grabbing group-data-[dragging=true]:bg-default-100',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus',\n ],\n },\n variants: {\n hasLabel: {\n false: {\n // focus styles - when there is no label, the first item actions menu button should have rounded top right corners\n actionsMenuButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item remove button focus ring should have rounded top right corners\n removeButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item sort drag handle focus ring should have rounded top left corners\n sortDragHandle:\n 'group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof fieldArrayVariants>;\n\nexport type ClassName = TVClassName<typeof fieldArrayVariants>;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementAppendButtonProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** CSS class name */\n className?: ClassValue;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n className={cn(className)}\n disableAnimation\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n >\n <FaPlus />\n <span>{appendButtonText}</span>\n </Button>\n );\n};\n\nexport default ElementAppendButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { MenuItem } from '@fuf-stack/pixels';\nimport type { Key } from 'react';\nimport type { FieldArrayElementMethods } from './FieldArrayElement';\n\nimport { FaCopy, FaTimes } from 'react-icons/fa';\nimport { VscInsert } from 'react-icons/vsc';\n\nimport { Menu } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nexport interface ElementActionsMenuProps {\n /** CSS class name */\n className?: ClassValue;\n /** Whether duplicate action is available */\n duplicate?: boolean;\n /** Whether insert after action is available */\n insertAfter?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Menu component for field array element actions (remove, duplicate, insert after)\n */\nconst ElementActionsMenu = ({\n className = undefined,\n duplicate = false,\n insertAfter = false,\n showRemove = true,\n methods,\n testId = undefined,\n}: ElementActionsMenuProps) => {\n const { cn } = useStyling();\n\n // dispatch the selected row action\n const handleAction = (key: Key) => {\n switch (key) {\n case 'remove':\n methods.remove();\n break;\n case 'duplicate':\n methods.duplicate();\n break;\n case 'insertAfter':\n methods.insert();\n break;\n default:\n break;\n }\n };\n\n // include the enabled row actions\n const menuItems: MenuItem[] = [];\n\n if (duplicate) {\n menuItems.push({\n key: 'duplicate',\n label: 'Duplicate',\n icon: <FaCopy />,\n });\n }\n\n if (insertAfter) {\n menuItems.push({\n key: 'insertAfter',\n label: 'Insert After',\n icon: <VscInsert />,\n });\n }\n\n if (showRemove) {\n menuItems.push({\n key: 'remove',\n className: 'text-danger',\n label: 'Remove',\n icon: <FaTimes />,\n });\n }\n\n return (\n <Menu\n ariaLabel=\"Element actions\"\n items={menuItems}\n onAction={handleAction}\n placement=\"right\"\n testId={testId}\n triggerButtonProps={{\n className: cn(className),\n disableRipple: true,\n size: 'md',\n variant: 'light',\n }}\n />\n );\n};\n\nexport default ElementActionsMenu;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaTimes } from 'react-icons/fa';\n\nimport { motion } from '@fuf-stack/pixel-motion';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementRemoveButtonProps {\n /** CSS class name */\n className?: ClassValue;\n /** Globally disable animations (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\n const { cn } = useStyling();\n\n const button = (\n <Button\n ariaLabel=\"remove element\"\n className={cn(className)}\n color=\"danger\"\n icon={<FaTimes />}\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n />\n );\n\n if (disableAnimation) {\n return button;\n }\n\n return (\n <motion.div\n animate={{ opacity: 1, width: 'auto' }}\n className=\"flex\"\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n transition={{ duration: 0.2 }}\n >\n {button}\n </motion.div>\n );\n};\n\nexport default ElementRemoveButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaGripVertical } from 'react-icons/fa';\n\nimport { useSortable } from '@dnd-kit/sortable';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface SortDragHandleProps {\n /** CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Drag handle component that integrates with dnd-kit sortable functionality.\n * Renders a vertical grip icon that can be used to reorder items.\n */\nconst SortDragHandle = ({\n className = undefined,\n id,\n testId = undefined,\n}: SortDragHandleProps) => {\n const { cn } = useStyling();\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\n aria-label=\"Reorder item\"\n >\n <FaGripVertical />\n </div>\n );\n};\n\nexport default SortDragHandle;\n","import type { Variants as MotionVariants } from '@fuf-stack/pixel-motion';\nimport type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayFeatures } from '../types';\n\nimport { useState } from 'react';\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\n\nimport { AnimatePresence, motion } from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport Grid from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class name */\n className: {\n /** Class of wrapper grid inside the li that wraps the rendered element fields directly */\n elementFieldsGrid?: ClassValue;\n /** Class for the li (performs motion animations) */\n listItem?: ClassValue;\n /** Class for the li inner div (wraps the rendered element fields) */\n listItemInner?: ClassValue;\n /** Class for the actions menu button */\n actionsMenuButton?: ClassValue;\n /** Class for the remove element button (when menu is not used) */\n removeButton?: ClassValue;\n /** Class for the drag handle when sorting enabled */\n sortDragHandle?: ClassValue;\n };\n /** Globally disable animations for this item (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** Bottom margin for elements (for backwards compatibility) */\n elementMarginBottom?: React.CSSProperties['marginBottom'];\n /** All fields in the form array */\n fields: Record<'id', string>[];\n /** Unique identifier for drag/drop */\n id: string | number;\n /** Field index in array */\n index: number;\n /** Prevent deletion of last remaining element */\n lastNotDeletable?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Form array element component using react-hook-form with drag-drop sorting\n * and validation capabilities. Animations when elements are added or removed\n * improve the user experience and provide a better visual feedback.\n */\nconst FieldArrayElement = ({\n children,\n className,\n disableAnimation = false,\n duplicate = false,\n elementMarginBottom: _elementMarginBottom = undefined,\n fields,\n id,\n index: _index,\n insertAfter = false,\n lastNotDeletable = true,\n methods,\n sortable = false,\n testId = undefined,\n}: FieldArrayElementProps) => {\n const { cn } = useStyling();\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n // keep the row mounted until its exit animation finishes\n const [isVisible, setIsVisible] = useState(true);\n\n // apply drag positioning only when sorting is enabled\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // animate row insertion and removal\n const listItemMotionVariants: MotionVariants = {\n hidden: { opacity: 0, height: 0, marginBottom: 0 },\n visible: {\n opacity: 1,\n height: 'auto',\n transition: { duration: 0.2, ease: 'circOut' },\n // push last visible item down to overlap with append button (hide double border)\n marginBottom: '-1px',\n },\n exit: {\n opacity: 0,\n height: 0,\n marginBottom: 0,\n transition: {\n // on exit first fade out, then shrink\n opacity: { duration: 0.1, ease: 'circOut' },\n height: { delay: 0.1, duration: 0.2, ease: 'circOut' },\n },\n },\n };\n\n // let the exit animation finish before removing the registered row\n const handleRemove = () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n };\n\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={methods.remove}\n >\n {isVisible ? (\n <motion.li\n key={id}\n ref={setNodeRef}\n animate={disableAnimation ? undefined : 'visible'}\n className={cn(className.listItem)}\n data-dragging={isDragging}\n data-testid={`${testId}_element`}\n exit={disableAnimation ? undefined : 'exit'}\n initial={disableAnimation ? false : 'hidden'}\n style={sortingStyle}\n variants={disableAnimation ? undefined : listItemMotionVariants}\n >\n <div className={cn(className.listItemInner)}>\n {/** sorting drag handle */}\n {sortable ? (\n <SortDragHandle\n className={className.sortDragHandle}\n id={id}\n testId={`${testId}_sort_drag_handle`}\n />\n ) : null}\n\n {/** render element fields in Grid component */}\n <Grid\n className={cn(className.elementFieldsGrid)}\n testId={`${testId}_element_fields_grid`}\n >\n {/* render actual fields */}\n {children}\n </Grid>\n\n {/** actions menu when duplicate or insertAfter is enabled */}\n {duplicate || insertAfter ? (\n <ElementActionsMenu\n className={className.actionsMenuButton}\n duplicate={duplicate}\n insertAfter={insertAfter}\n methods={{\n ...methods,\n remove: handleRemove,\n }}\n showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n />\n ) : (\n <>\n {/** remove element button (when menu is not used) */}\n <AnimatePresence initial={false}>\n {lastNotDeletable && fields.length === 1 ? null : (\n <ElementRemoveButton\n key=\"remove-button\"\n className={className.removeButton}\n disableAnimation={disableAnimation}\n onClick={handleRemove}\n testId={`${testId}_remove_button`}\n />\n )}\n </AnimatePresence>\n </>\n )}\n </div>\n </motion.li>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayElement;\n","import type { ReactNode } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Optional heading ID supplied by the owning group. */\n id?: string;\n /** Shows an array-level validation failure */\n invalid: boolean;\n /** Field label */\n label: ReactNode;\n /** Marks the array as required */\n required: boolean;\n}\n\n/**\n * Renders the label for a FieldArray component.\n *\n * This component handles displaying the array label with proper accessibility\n * attributes using owned heading markup and field state.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n id = undefined,\n label,\n invalid,\n required,\n}: FieldArrayLabelProps) => {\n const { cn } = useStyling();\n\n // when no label is provided, don't render anything\n if (!label) {\n return null;\n }\n\n const hasErrors = invalid;\n\n return (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={cn(\n 'block max-w-full overflow-hidden text-ellipsis subpixel-antialiased text-small',\n hasErrors ? 'text-danger!' : undefined,\n className,\n {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n },\n )}\n id={id}\n required={required}\n requiredClassName=\"ms-0.5 text-danger\"\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n );\n};\n\nexport default FieldArrayLabel;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nconst fieldArrayValidationErrorVariants = tv({\n slots: {\n /** Container for array-level validation messages */\n errorMessage: 'text-danger text-tiny',\n /** Padded footer containing array-level validation */\n helperWrapper: ['relative flex-col gap-1.5', 'block px-3 pb-2 pt-1'],\n },\n});\n\nexport default fieldArrayValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\nimport type { FieldIds } from '../../partials/types';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldArrayValidationErrorVariants from './fieldArrayValidationErrorVariants';\n\nexport interface FieldArrayValidationErrorProps {\n /** Array-level validation errors */\n error: FieldError[] | undefined;\n /** IDs shared with the owning field */\n ids: FieldIds;\n /** Shows array-level validation failure */\n invalid: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Renders array-level validation errors for FieldArray.\n *\n * This component handles validation errors that apply to the entire array\n * (e.g., \"Array must contain at least 3 elements\", \"Array elements are not unique\"),\n * as opposed to field-level errors which apply to individual array elements.\n *\n * The component wraps errors in the proper accessibility markup and animates\n * them in/out using Framer Motion when they appear or are resolved.\n */\nconst FieldArrayValidationError = ({\n error,\n ids,\n invalid,\n testId,\n}: FieldArrayValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants);\n\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = invalid && objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={ids.error}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayValidationError;\n","import type { DragEndEvent } from '@dnd-kit/core';\nimport type { ReactNode } from 'react';\nimport type { UseFieldArrayMove } from 'react-hook-form';\n\nimport {\n closestCenter,\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\n\ninterface SortContextProps {\n /** child components */\n children: ReactNode;\n /** Array of objects containing unique IDs for sortable items */\n fields: Record<'id', string>[];\n /** react-hook-form's move function to update field array indices */\n move: UseFieldArrayMove;\n /** enable/disable sorting functionality */\n sortable: boolean;\n}\n\n/**\n * A wrapper component that provides drag-and-drop sorting functionality for field arrays\n * using dnd-kit and react-hook-form.\n *\n * This component integrates with react-hook-form's field arrays to enable vertical\n * drag-and-drop reordering of form fields. It supports both pointer (mouse/touch)\n * and keyboard interactions for accessibility.\n */\nconst SortContext = ({\n children,\n fields,\n move,\n sortable,\n}: SortContextProps): ReactNode => {\n // Initialize sensors for both pointer (mouse/touch) and keyboard interactions\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\n );\n\n // Early return if sorting is disabled\n if (!sortable) {\n return children;\n }\n\n /**\n * Handles the end of a drag operation by updating field positions\n * @param event - The drag end event containing active and over elements\n */\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n // Only move if dropping over a different item\n if (active.id !== over?.id) {\n // Find the indices of the dragged item and drop target\n const oldIndex = fields.findIndex((field) => {\n return field.id === active.id;\n });\n const newIndex = fields.findIndex((field) => {\n return field.id === over?.id;\n });\n // Update the field array order using react-hook-form's move function\n move(oldIndex, newIndex);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n items={fields.map((field) => {\n return field.id;\n })}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayProps } from '../FieldArray';\n\nimport { useId } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { fieldArrayVariants } from '../fieldArrayVariants';\nimport ElementAppendButton from './ElementAppendButton';\nimport FieldArrayElement from './FieldArrayElement';\nimport FieldArrayLabel from './FieldArrayLabel';\nimport FieldArrayValidationError from './FieldArrayValidationError';\nimport SortContext from './SortContext';\n\nexport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayControlProps extends Pick<\n FieldArrayProps,\n | 'appendButtonText'\n | 'children'\n | 'className'\n | 'duplicate'\n | 'elementMarginBottom'\n | 'insertAfter'\n | 'lastElementNotRemovable'\n | 'sortable'\n> {\n /** Disables animation during array initialization */\n disableAnimation: boolean;\n /** Bound field values, interactions and metadata */\n field: UniformField;\n /** Stable row IDs used by the sorting engine */\n fields: Record<'id', string>[];\n /** Bound rows to arrange in the list */\n items: FieldArrayItem[];\n /** Callback when the append button is activated */\n onAppend: () => void;\n /** Callback when sorting moves a row */\n onMove: (from: number, to: number) => void;\n}\n\n/** Array group presentation with row controls, sorting and validation messages */\nconst FieldArrayControl = ({\n field,\n appendButtonText,\n children,\n className,\n disableAnimation,\n duplicate,\n elementMarginBottom,\n fields,\n items,\n insertAfter,\n lastElementNotRemovable,\n onAppend,\n onMove,\n sortable = false,\n}: FieldArrayControlProps) => {\n const { error, ids, invalid, name, required, testId } = field;\n\n // keep the array heading hidden when only debug label content exists\n const label = field.hasLabel ? field.label : undefined;\n\n const styling = useStyling();\n const labelId = useId();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasArrayErrors = !!(invalid && error?._errors);\n\n const { cn } = styling;\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayVariants, { hasLabel: !!label });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-label={!label ? name : undefined}\n aria-labelledby={label ? labelId : undefined}\n className={classNames.base}\n data-component=\"field-array\"\n role=\"group\"\n >\n {/* field array label */}\n <FieldArrayLabel\n className={classNames.label}\n id={labelId}\n invalid={hasArrayErrors}\n label={label}\n required={required}\n />\n\n {fields.length ? (\n /* sortable rows */\n <div className={cn(classNames.listWrapper)}>\n <SortContext fields={fields} move={onMove} sortable={sortable}>\n <ul className={classNames.list} data-testid={testId}>\n {items.map(({ id, renderProps }) => {\n return (\n <FieldArrayElement\n key={id}\n className={classNames}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={id}\n index={renderProps.index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={renderProps.methods}\n sortable={sortable}\n testId={renderProps.testId}\n >\n {children(renderProps)}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError\n error={error}\n ids={ids}\n invalid={invalid}\n testId={testId}\n />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={classNames.appendButton}\n onClick={onAppend}\n testId={`${testId}_append_button`}\n />\n </div>\n );\n};\n\nexport default FieldArrayControl;\n","import type { CSSProperties, ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './fieldArrayVariants';\nimport type { FieldArrayChildrenRenderFn, FieldArrayFeatures } from './types';\n\nimport useUniformFieldArray from '../hooks/useUniformFieldArray/useUniformFieldArray';\nimport FieldArrayControl from './subcomponents/FieldArrayControl';\n\nexport { fieldArrayVariants } from './fieldArrayVariants';\n\nexport interface FieldArrayProps extends FieldArrayFeatures, VariantProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** function that renders the children with provided Properties. */\n children: FieldArrayChildrenRenderFn;\n /** CSS class name */\n className?: ClassName;\n /* initial value of a filed that is created in the array */\n elementInitialValue?: unknown;\n /*\n * bottom margin of a list element (default 1rem), this needs to be set as a prop (and not via className slot)\n * because the margin bottom needs to be animated when elements are added or removed\n */\n elementMarginBottom?: CSSProperties['marginBottom'];\n /** when true, array stores primitives as wrapper objects: { __FLAT__: value } */\n flat?: boolean;\n /** Field label */\n label?: ReactNode;\n /** when true (default false) last element can not be removed and will be shown even if field array is empty */\n lastElementNotRemovable?: boolean;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/** Form field group for adding, removing and reordering array entries */\nconst FieldArray = ({\n appendButtonText = 'Add Element',\n children,\n className: _className = undefined,\n duplicate = false,\n elementInitialValue: _elementInitialValue = null,\n elementMarginBottom = undefined,\n flat = false,\n insertAfter = false,\n lastElementNotRemovable = false,\n name,\n sortable = false,\n ...uniformFieldProps\n}: FieldArrayProps) => {\n const { field, fields, appendItem, items, moveItem, disableAnimation } =\n useUniformFieldArray({\n ...uniformFieldProps,\n elementInitialValue: _elementInitialValue,\n flat,\n lastElementNotRemovable,\n name,\n });\n\n return (\n <FieldArrayControl\n appendButtonText={appendButtonText}\n className={_className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n field={field}\n fields={fields}\n insertAfter={insertAfter}\n items={items}\n lastElementNotRemovable={lastElementNotRemovable}\n onAppend={appendItem}\n onMove={moveItem}\n sortable={sortable}\n >\n {children}\n </FieldArrayControl>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { fieldArrayVariants } from './FieldArray';\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAa,+BAGX,EACE,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,SAE5B,iBAC6C;CAC7C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,YAAYA,cAAiB;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,iBAA6B;CAStE,MAAM,kBAAkB,cAAc;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,iBAAiB,OAAO,CAAC,eAAe;CAK9C,gBAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,gBAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MAAM,CAAC,kBAAkB,uBAAuB,SAAS,IAAI;CAI7D,MAAM,uBAAuB,iBAAiB;CAC9C,gBAAgB;EACd,IAAI,eAAe,SACjB,oBAAoB,CAAC,CAAC,oBAAoB;CAE9C,GAAG,CAAC,oBAAoB,CAAC;CAKzB,MAAM,sBAAsB,cAAc;EACxC,OAAO,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F;IACG;GACX,CAAA;GAEA,OAAO,SAEN,oBAAC,OAAD;IAAK,WAAW,GAAG,WAAW,WAAW;IACvC,UAAA,oBAAC,aAAD;KAAqB;KAAQ,MAAM;KAAkB;KACnD,UAAA,oBAAC,MAAD;MAAI,WAAW,WAAW;MAAM,eAAa;MAC1C,UAAA,MAAM,KAAK,EAAE,IAAI,kBAAkB;OAClC,OACE,oBAAC,mBAAD;QAEE,WAAW;QACO;QACP;QACU;QACb;QACJ;QACJ,OAAO,YAAY;QACN;QACb,kBAAkB;QAClB,SAAS,YAAY;QACX;QACV,QAAQ,YAAY;QAEnB,UAAA,SAAS,WAAW;OACJ,GAfZ,EAeY;MAEvB,CAAC;KACC,CAAA;IACO,CAAA;GACV,CAAA,IACH;GAGJ,oBAAC,2BAAD;IACS;IACF;IACI;IACD;GACT,CAAA;GAGD,oBAAC,qBAAD;IACoB;IAClB,WAAW,WAAW;IACtB,SAAS;IACT,QAAQ,GAAG,OAAO;GACnB,CAAA;EACE;;AAET;;;ACzGA,MAAM,cAAc,EAClB,mBAAmB,eACnB,UACA,WAAW,aAAa,KAAA,GACxB,YAAY,OACZ,qBAAqB,uBAAuB,MAC5C,sBAAsB,KAAA,GACtB,OAAO,OACP,cAAc,OACd,0BAA0B,OAC1B,MACA,WAAW,OACX,GAAG,wBACkB;CACrB,MAAM,EAAE,OAAO,QAAQ,YAAY,OAAO,UAAU,qBAClD,qBAAqB;EACnB,GAAG;EACH,qBAAqB;EACrB;EACA;EACA;CACF,CAAC;CAEH,OACE,oBAAC,mBAAD;EACoB;EAClB,WAAW;EACO;EACP;EACU;EACd;EACC;EACK;EACN;EACkB;EACzB,UAAU;EACV,QAAQ;EACE;EAET;CACgB,CAAA;AAEvB;;ACxEA,IAAA,qBAAe"}
1
+ {"version":3,"file":"index.mjs","names":["useRHFFieldArray","useFormContext","Grid"],"sources":["../../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../../src/FieldArray/fieldArrayVariants.ts","../../src/FieldArray/subcomponents/ElementAppendButton.tsx","../../src/FieldArray/subcomponents/ElementActionsMenu.tsx","../../src/FieldArray/subcomponents/ElementRemoveButton.tsx","../../src/FieldArray/subcomponents/SortDragHandle.tsx","../../src/FieldArray/subcomponents/FieldArrayElement.tsx","../../src/FieldArray/subcomponents/FieldArrayLabel.tsx","../../src/FieldArray/subcomponents/fieldArrayValidationErrorVariants.ts","../../src/FieldArray/subcomponents/FieldArrayValidationError.tsx","../../src/FieldArray/subcomponents/SortContext.tsx","../../src/FieldArray/subcomponents/FieldArrayControl.tsx","../../src/FieldArray/FieldArray.tsx","../../src/FieldArray/index.ts"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type {\n FieldArray as ArrayElement,\n ArrayPath,\n FieldValues,\n Path,\n UseFieldArrayReturn,\n} from 'react-hook-form';\nimport type { UniformFieldState } from '../useUniformField/types';\nimport type { FieldArrayElementMethods, FieldArrayItem } from './types';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey, isValueEmpty } from '../../helpers';\nimport { useFormContext } from '../useFormContext';\nimport useUniformField from '../useUniformField/useUniformField';\nimport { useWatchFormReset } from '../useWatchFormReset';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Disable the field */\n disabled?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Optional label content */\n label?: ReactNode;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n}\n\n/**\n * Return type of `useUniformFieldArrayMethods` and `useUniformFieldArray`.\n *\n * Declared explicitly so the published declarations only reference types that\n * react-hook-form exports from its package root.\n */\nexport type UseUniformFieldArrayReturn<\n TFieldValues extends FieldValues = FieldValues,\n> = Pick<\n UseFieldArrayReturn<TFieldValues, ArrayPath<TFieldValues>>,\n 'append' | 'fields' | 'insert' | 'move' | 'remove'\n> &\n UniformFieldState<TFieldValues> & {\n /** Appends an element using the configured initial value */\n appendItem: () => void;\n /** Disables element animations during initialization, reset and reduced motion */\n disableAnimation: boolean;\n /** Value used for newly added array elements */\n elementInitialValue: NonNullable<unknown>;\n /** Bound operations and identification for each array row */\n items: FieldArrayItem[];\n /** Moves an element and validates the array afterwards */\n moveItem: (from: number, to: number) => void;\n };\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Reset-only normalization for stale empty placeholder rows (via useWatchFormReset)\n * - Animation control (disabled during initialization)\n * - Temporary animation disable during reset normalization collapse\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArrayMethods = <\n TFieldValues extends FieldValues = FieldValues,\n>(\n {\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n }: UseUniformFieldArrayProps<TFieldValues>,\n uniformField: UniformFieldState<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move, replace } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue, getValues } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // lastElementNotRemovable is purely a minimum-count guarantee: when there are\n // no rows, add one. This handles both:\n // - Initial mount: fields.length starts at 0\n // - Form reset to an empty array: fields.length becomes 0 again\n // It intentionally does NOT inspect row contents, so manually added empty rows\n // are never collapsed.\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // This ensures min/max errors appear instantly when user adds/removes items.\n // Note: Child field validation also runs, but new empty fields won't show as invalid\n // because useFormContext only sets invalid=true for touched fields or after form submission.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Reset normalization:\n // Run ONLY when an actual form reset is emitted (via useWatchFormReset), not\n // on regular field edits. This does not collapse rows users add manually.\n //\n // Why this exists:\n // RHF can keep stale field-array rows after reset when array defaults are\n // missing (e.g. value becomes undefined or [null, null] while UI still has\n // multiple rows). We normalize this reset-only state to:\n // - one row when lastElementNotRemovable is enabled\n // - zero rows otherwise\n useWatchFormReset({\n onReset: () => {\n const currentValue = getValues(name as Path<TFieldValues>) as unknown;\n const valueIsArray = Array.isArray(currentValue);\n const arrayValue = valueIsArray ? (currentValue as unknown[]) : [];\n const normalizedLength = lastElementNotRemovable ? 1 : 0;\n const alreadyNormalized =\n valueIsArray && arrayValue.length === normalizedLength;\n\n // Treat these as \"effectively empty after reset\":\n // - value missing/not-array\n // - empty array\n // - array where all entries are empty placeholders\n const isEffectivelyEmptyAfterReset =\n !valueIsArray ||\n arrayValue.length === 0 ||\n arrayValue.every((entry) => {\n return isValueEmpty(entry);\n });\n\n // Nothing to fix when the reset restored real values (e.g. from defaults).\n if (!isEffectivelyEmptyAfterReset) {\n return;\n }\n\n // Already normalized to the target row count.\n if (alreadyNormalized) {\n return;\n }\n\n // Avoid collapse animation flicker during reset normalization.\n setDisableAnimation(true);\n\n // use replace so the RHF field-array length actually matches the target.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n replace((lastElementNotRemovable ? [elementInitialValue] : []) as any);\n\n // Restore normal animation state right after normalization.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n },\n });\n\n // Initialization/Re-initialization: add one element only when array length is 0.\n // This is the min-count behavior for lastElementNotRemovable and is intentionally\n // separate from reset normalization above.\n //\n // Reset behavior in this hook is split into two phases:\n // 1) Reset normalization (useWatchFormReset): collapse stale placeholder rows\n // left by reset edge cases.\n // 2) Length-based initialization (this effect): ensure a min-one array when\n // the field array is truly empty.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n const { testId } = uniformField.field;\n\n // bind row identification and operations for the renderer\n const items: FieldArrayItem[] = fields.map((row, index) => {\n const elementName = flat\n ? `${name}.${index}.${flatArrayKey}`\n : `${name}.${index}`;\n const elementTestId = `${testId}_${index}`;\n\n const methods: FieldArrayElementMethods = {\n append: () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n },\n duplicate: () => {\n const values = getValues(name as Path<TFieldValues>);\n const currentValue = (values as unknown as unknown[])[index];\n\n insert(\n index + 1,\n (flat\n ? { [flatArrayKey]: currentValue }\n : currentValue) as ArrayElement<TFieldValues>,\n );\n },\n insert: () => {\n insert(index + 1, elementInitialValue as ArrayElement<TFieldValues>);\n },\n remove: () => {\n remove(index);\n },\n };\n\n return {\n id: row.id,\n renderProps: {\n index,\n length: fields.length,\n methods,\n name: elementName,\n testId: elementTestId,\n },\n };\n });\n\n // append an element using the configured initial value\n const appendItem = () => {\n append(elementInitialValue as ArrayElement<TFieldValues>);\n };\n\n // validate the array after its row order changes\n const moveItem = (from: number, to: number) => {\n move(from, to);\n trigger(name as Path<TFieldValues>);\n };\n\n return {\n // Field array methods and state\n fields,\n append,\n appendItem,\n items,\n remove,\n insert,\n move,\n moveItem,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n\nconst useUniformFieldArray = <TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldArrayProps<TFieldValues>,\n): UseUniformFieldArrayReturn<TFieldValues> => {\n const field = useUniformField<TFieldValues>({\n ...params,\n name: params.name as Path<TFieldValues> & string,\n });\n return useUniformFieldArrayMethods(params, field);\n};\nexport default useUniformFieldArray;\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nexport const fieldArrayVariants = tv({\n slots: {\n /** class for the actions menu button */\n actionsMenuButton: [\n // base styles\n 'flex items-center justify-center text-default-600',\n // fixed height/no round corners/center align\n 'h-full rounded-none',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset',\n ],\n /** class for the append button */\n appendButton: [\n // base styles\n 'w-full justify-start rounded-t-none rounded-b-small 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-focus focus-visible:ring-inset',\n ],\n /** base class for the field array wrapper */\n base: [\n // base styles\n 'overflow-hidden rounded-small border border-divider bg-content1',\n // divider between items\n 'divide-y divide-divider',\n ],\n /** class for the element fields grid */\n elementFieldsGrid: ['w-full grow p-3'],\n /** class for the label */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) instead of text-base for correct 48px height\n 'rounded-t-small p-3 text-medium font-semibold',\n ],\n /** class for the list */\n list: ['overflow-hidden'],\n /** class for the list item (performs motion animations) */\n listItem: [\n // base styles\n 'group relative flex flex-row',\n // overlap borders by shifting first item up 1px (similar to how last item overlaps with append button)\n 'first:-mt-px',\n ],\n /** class for the list item inner */\n listItemInner: [\n // base styles\n 'flex w-full flex-row items-stretch divide-divider bg-content1',\n // x division and borders\n 'divide-x divide-solid border-t border-b border-divider',\n ],\n /** class for the list wrapper */\n listWrapper: ['overflow-hidden'],\n /** class for the remove button */\n removeButton: [\n // base styles\n 'flex items-center justify-center',\n // fixed height/no round corners\n '!h-full !min-h-0 !rounded-none px-3',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset',\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 'group-data-[dragging=true]:bg-default-100 hover:bg-default-100 active:cursor-grabbing',\n // focus styles - inset ring\n 'outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset',\n ],\n },\n variants: {\n hasLabel: {\n false: {\n // focus styles - when there is no label, the first item actions menu button should have rounded top right corners\n actionsMenuButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item remove button focus ring should have rounded top right corners\n removeButton:\n 'group-[:first-child]:!rounded-tr-small group-[:first-child]:group-data-[dragging=true]:!rounded-tr-none',\n // focus styles - when there is no label, the first item sort drag handle focus ring should have rounded top left corners\n sortDragHandle:\n 'group-[:first-child]:rounded-tl-small group-[:first-child]:group-data-[dragging=true]:rounded-tl-none',\n },\n },\n },\n});\n\nexport type VariantProps = TVProps<typeof fieldArrayVariants>;\n\nexport type ClassName = TVClassName<typeof fieldArrayVariants>;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaPlus } from 'react-icons/fa';\n\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementAppendButtonProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** CSS class name */\n className?: ClassValue;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementAppendButton = ({\n appendButtonText = 'Add Element',\n className = undefined,\n onClick,\n testId = undefined,\n}: ElementAppendButtonProps) => {\n const { cn } = useStyling();\n return (\n <Button\n className={cn(className)}\n disableAnimation\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n >\n <FaPlus />\n <span>{appendButtonText}</span>\n </Button>\n );\n};\n\nexport default ElementAppendButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { MenuItem } from '@fuf-stack/pixels';\nimport type { Key } from 'react';\nimport type { FieldArrayElementMethods } from './FieldArrayElement';\n\nimport { FaCopy, FaTimes } from 'react-icons/fa';\nimport { VscInsert } from 'react-icons/vsc';\n\nimport { Menu } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nexport interface ElementActionsMenuProps {\n /** CSS class name */\n className?: ClassValue;\n /** Whether duplicate action is available */\n duplicate?: boolean;\n /** Whether insert after action is available */\n insertAfter?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** Whether to show remove button (false when last element is not deletable) */\n showRemove?: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Menu component for field array element actions (remove, duplicate, insert after)\n */\nconst ElementActionsMenu = ({\n className = undefined,\n duplicate = false,\n insertAfter = false,\n showRemove = true,\n methods,\n testId = undefined,\n}: ElementActionsMenuProps) => {\n const { cn } = useStyling();\n\n // dispatch the selected row action\n const handleAction = (key: Key) => {\n switch (key) {\n case 'remove':\n methods.remove();\n break;\n case 'duplicate':\n methods.duplicate();\n break;\n case 'insertAfter':\n methods.insert();\n break;\n default:\n break;\n }\n };\n\n // include the enabled row actions\n const menuItems: MenuItem[] = [];\n\n if (duplicate) {\n menuItems.push({\n key: 'duplicate',\n label: 'Duplicate',\n icon: <FaCopy />,\n });\n }\n\n if (insertAfter) {\n menuItems.push({\n key: 'insertAfter',\n label: 'Insert After',\n icon: <VscInsert />,\n });\n }\n\n if (showRemove) {\n menuItems.push({\n key: 'remove',\n className: 'text-danger',\n label: 'Remove',\n icon: <FaTimes />,\n });\n }\n\n return (\n <Menu\n ariaLabel=\"Element actions\"\n items={menuItems}\n onAction={handleAction}\n placement=\"right\"\n testId={testId}\n triggerButtonProps={{\n className: cn(className),\n disableRipple: true,\n size: 'md',\n variant: 'light',\n }}\n />\n );\n};\n\nexport default ElementActionsMenu;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaTimes } from 'react-icons/fa';\n\nimport { motion } from '@fuf-stack/pixel-motion';\nimport { Button } from '@fuf-stack/pixels';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface ElementRemoveButtonProps {\n /** CSS class name */\n className?: ClassValue;\n /** Globally disable animations (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** click handler */\n onClick: () => void;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\nconst ElementRemoveButton = ({\n className = undefined,\n disableAnimation = false,\n onClick,\n testId = undefined,\n}: ElementRemoveButtonProps) => {\n const { cn } = useStyling();\n\n const button = (\n <Button\n ariaLabel=\"remove element\"\n className={cn(className)}\n color=\"danger\"\n icon={<FaTimes />}\n onClick={onClick}\n size=\"sm\"\n testId={testId}\n variant=\"light\"\n />\n );\n\n if (disableAnimation) {\n return button;\n }\n\n return (\n <motion.div\n animate={{ opacity: 1, width: 'auto' }}\n className=\"flex\"\n exit={{ opacity: 0, width: 0 }}\n initial={{ opacity: 0, width: 0 }}\n transition={{ duration: 0.2 }}\n >\n {button}\n </motion.div>\n );\n};\n\nexport default ElementRemoveButton;\n","import type { ClassValue } from '@fuf-stack/pixel-utils';\n\nimport { FaGripVertical } from 'react-icons/fa';\n\nimport { useSortable } from '@dnd-kit/sortable';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\ninterface SortDragHandleProps {\n /** CSS class name */\n className?: ClassValue;\n /** Unique identifier for sortable item */\n id: string | number;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Drag handle component that integrates with dnd-kit sortable functionality.\n * Renders a vertical grip icon that can be used to reorder items.\n */\nconst SortDragHandle = ({\n className = undefined,\n id,\n testId = undefined,\n}: SortDragHandleProps) => {\n const { cn } = useStyling();\n const { attributes, listeners } = useSortable({ id });\n\n return (\n <div\n className={cn(className)}\n data-testid={testId}\n {...attributes}\n {...listeners}\n aria-label=\"Reorder item\"\n >\n <FaGripVertical />\n </div>\n );\n};\n\nexport default SortDragHandle;\n","import type { Variants as MotionVariants } from '@fuf-stack/pixel-motion';\nimport type { ClassValue } from '@fuf-stack/pixel-utils';\nimport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayFeatures } from '../types';\n\nimport { useState } from 'react';\n\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\n\nimport { AnimatePresence, motion } from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport Grid from '../../Grid';\nimport ElementActionsMenu from './ElementActionsMenu';\nimport ElementRemoveButton from './ElementRemoveButton';\nimport SortDragHandle from './SortDragHandle';\n\nexport type { FieldArrayElementMethods } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayElementProps extends FieldArrayFeatures {\n /** Form elements to render inside array element */\n children: React.ReactNode;\n /** CSS class name */\n className: {\n /** Class of wrapper grid inside the li that wraps the rendered element fields directly */\n elementFieldsGrid?: ClassValue;\n /** Class for the li (performs motion animations) */\n listItem?: ClassValue;\n /** Class for the li inner div (wraps the rendered element fields) */\n listItemInner?: ClassValue;\n /** Class for the actions menu button */\n actionsMenuButton?: ClassValue;\n /** Class for the remove element button (when menu is not used) */\n removeButton?: ClassValue;\n /** Class for the drag handle when sorting enabled */\n sortDragHandle?: ClassValue;\n };\n /** Globally disable animations for this item (used for first render or prefers-reduced-motion) */\n disableAnimation?: boolean;\n /** Bottom margin for elements (for backwards compatibility) */\n elementMarginBottom?: React.CSSProperties['marginBottom'];\n /** All fields in the form array */\n fields: Record<'id', string>[];\n /** Unique identifier for drag/drop */\n id: string | number;\n /** Field index in array */\n index: number;\n /** Prevent deletion of last remaining element */\n lastNotDeletable?: boolean;\n /** Field array operation methods */\n methods: FieldArrayElementMethods;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Form array element component using react-hook-form with drag-drop sorting\n * and validation capabilities. Animations when elements are added or removed\n * improve the user experience and provide a better visual feedback.\n */\nconst FieldArrayElement = ({\n children,\n className,\n disableAnimation = false,\n duplicate = false,\n elementMarginBottom: _elementMarginBottom = undefined,\n fields,\n id,\n index: _index,\n insertAfter = false,\n lastNotDeletable = true,\n methods,\n sortable = false,\n testId = undefined,\n}: FieldArrayElementProps) => {\n const { cn } = useStyling();\n const { setNodeRef, transform, transition, isDragging } = useSortable({ id });\n // keep the row mounted until its exit animation finishes\n const [isVisible, setIsVisible] = useState(true);\n\n // apply drag positioning only when sorting is enabled\n const sortingStyle = sortable\n ? {\n transform: CSS.Translate.toString(transform),\n transition,\n zIndex: isDragging ? 50 : undefined,\n }\n : undefined;\n\n // animate row insertion and removal\n const listItemMotionVariants: MotionVariants = {\n hidden: { opacity: 0, height: 0, marginBottom: 0 },\n visible: {\n opacity: 1,\n height: 'auto',\n transition: { duration: 0.2, ease: 'circOut' },\n // push last visible item down to overlap with append button (hide double border)\n marginBottom: '-1px',\n },\n exit: {\n opacity: 0,\n height: 0,\n marginBottom: 0,\n transition: {\n // on exit first fade out, then shrink\n opacity: { duration: 0.1, ease: 'circOut' },\n height: { delay: 0.1, duration: 0.2, ease: 'circOut' },\n },\n },\n };\n\n // let the exit animation finish before removing the registered row\n const handleRemove = () => {\n if (disableAnimation) {\n methods.remove();\n } else {\n setIsVisible(false);\n }\n };\n\n return (\n <AnimatePresence\n mode=\"wait\"\n // remove from RHF state after exit animation\n onExitComplete={methods.remove}\n >\n {isVisible ? (\n <motion.li\n key={id}\n ref={setNodeRef}\n animate={disableAnimation ? undefined : 'visible'}\n className={cn(className.listItem)}\n data-dragging={isDragging}\n data-testid={`${testId}_element`}\n exit={disableAnimation ? undefined : 'exit'}\n initial={disableAnimation ? false : 'hidden'}\n style={sortingStyle}\n variants={disableAnimation ? undefined : listItemMotionVariants}\n >\n <div className={cn(className.listItemInner)}>\n {/** sorting drag handle */}\n {sortable ? (\n <SortDragHandle\n className={className.sortDragHandle}\n id={id}\n testId={`${testId}_sort_drag_handle`}\n />\n ) : null}\n\n {/** render element fields in Grid component */}\n <Grid\n className={cn(className.elementFieldsGrid)}\n testId={`${testId}_element_fields_grid`}\n >\n {/* render actual fields */}\n {children}\n </Grid>\n\n {/** actions menu when duplicate or insertAfter is enabled */}\n {duplicate || insertAfter ? (\n <ElementActionsMenu\n className={className.actionsMenuButton}\n duplicate={duplicate}\n insertAfter={insertAfter}\n methods={{\n ...methods,\n remove: handleRemove,\n }}\n showRemove={!(lastNotDeletable && fields.length === 1)}\n testId={`${testId}_actions_menu`}\n />\n ) : (\n <>\n {/** remove element button (when menu is not used) */}\n <AnimatePresence initial={false}>\n {lastNotDeletable && fields.length === 1 ? null : (\n <ElementRemoveButton\n key=\"remove-button\"\n className={className.removeButton}\n disableAnimation={disableAnimation}\n onClick={handleRemove}\n testId={`${testId}_remove_button`}\n />\n )}\n </AnimatePresence>\n </>\n )}\n </div>\n </motion.li>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayElement;\n","import type { ReactNode } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\n\nexport interface FieldArrayLabelProps {\n /** CSS class name */\n className?: string;\n /** Optional heading ID supplied by the owning group. */\n id?: string;\n /** Shows an array-level validation failure */\n invalid: boolean;\n /** Field label */\n label: ReactNode;\n /** Marks the array as required */\n required: boolean;\n}\n\n/**\n * Renders the label for a FieldArray component.\n *\n * This component handles displaying the array label with proper accessibility\n * attributes using owned heading markup and field state.\n */\nconst FieldArrayLabel = ({\n className = undefined,\n id = undefined,\n label,\n invalid,\n required,\n}: FieldArrayLabelProps) => {\n const { cn } = useStyling();\n\n // when no label is provided, don't render anything\n if (!label) {\n return null;\n }\n\n const hasErrors = invalid;\n\n return (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={cn(\n 'block max-w-full overflow-hidden text-small text-ellipsis subpixel-antialiased',\n hasErrors ? 'text-danger!' : undefined,\n className,\n {\n // when there are no array level errors, the label should have foreground color\n 'text-foreground!': !hasErrors,\n },\n )}\n id={id}\n required={required}\n requiredClassName=\"ms-0.5 text-danger\"\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n );\n};\n\nexport default FieldArrayLabel;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nimport { fieldHelperVariants } from '../../partials/FieldHelper/fieldHelperVariants';\n\nconst fieldArrayValidationErrorVariants = tv({\n extend: fieldHelperVariants,\n slots: {\n /** Padded footer containing array-level validation */\n helperWrapper: 'px-3 pt-1 pb-2',\n },\n});\n\nexport default fieldArrayValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\nimport type { FieldIds } from '../../partials/types';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldArrayValidationErrorVariants from './fieldArrayValidationErrorVariants';\n\nexport interface FieldArrayValidationErrorProps {\n /** Array-level validation errors */\n error: FieldError[] | undefined;\n /** IDs shared with the owning field */\n ids: FieldIds;\n /** Shows array-level validation failure */\n invalid: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId: string;\n}\n\n/**\n * Renders array-level validation errors for FieldArray.\n *\n * This component handles validation errors that apply to the entire array\n * (e.g., \"Array must contain at least 3 elements\", \"Array elements are not unique\"),\n * as opposed to field-level errors which apply to individual array elements.\n *\n * The component wraps errors in the proper accessibility markup and animates\n * them in/out using Framer Motion when they appear or are resolved.\n */\nconst FieldArrayValidationError = ({\n error,\n ids,\n invalid,\n testId,\n}: FieldArrayValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants);\n\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = invalid && objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-array-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={ids.error}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldArrayValidationError;\n","import type { DragEndEvent } from '@dnd-kit/core';\nimport type { ReactNode } from 'react';\nimport type { UseFieldArrayMove } from 'react-hook-form';\n\nimport {\n closestCenter,\n DndContext,\n KeyboardSensor,\n PointerSensor,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport {\n restrictToVerticalAxis,\n restrictToWindowEdges,\n} from '@dnd-kit/modifiers';\nimport {\n SortableContext,\n verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\n\ninterface SortContextProps {\n /** child components */\n children: ReactNode;\n /** Array of objects containing unique IDs for sortable items */\n fields: Record<'id', string>[];\n /** react-hook-form's move function to update field array indices */\n move: UseFieldArrayMove;\n /** enable/disable sorting functionality */\n sortable: boolean;\n}\n\n/**\n * A wrapper component that provides drag-and-drop sorting functionality for field arrays\n * using dnd-kit and react-hook-form.\n *\n * This component integrates with react-hook-form's field arrays to enable vertical\n * drag-and-drop reordering of form fields. It supports both pointer (mouse/touch)\n * and keyboard interactions for accessibility.\n */\nconst SortContext = ({\n children,\n fields,\n move,\n sortable,\n}: SortContextProps): ReactNode => {\n // Initialize sensors for both pointer (mouse/touch) and keyboard interactions\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor),\n );\n\n // Early return if sorting is disabled\n if (!sortable) {\n return children;\n }\n\n /**\n * Handles the end of a drag operation by updating field positions\n * @param event - The drag end event containing active and over elements\n */\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n\n // Only move if dropping over a different item\n if (active.id !== over?.id) {\n // Find the indices of the dragged item and drop target\n const oldIndex = fields.findIndex((field) => {\n return field.id === active.id;\n });\n const newIndex = fields.findIndex((field) => {\n return field.id === over?.id;\n });\n // Update the field array order using react-hook-form's move function\n move(oldIndex, newIndex);\n }\n };\n\n return (\n <DndContext\n collisionDetection={closestCenter}\n modifiers={[restrictToVerticalAxis, restrictToWindowEdges]}\n onDragEnd={handleDragEnd}\n sensors={sensors}\n >\n <SortableContext\n items={fields.map((field) => {\n return field.id;\n })}\n strategy={verticalListSortingStrategy}\n >\n {children}\n </SortableContext>\n </DndContext>\n );\n};\n\nexport default SortContext;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\nimport type { FieldArrayProps } from '../FieldArray';\n\nimport { useId } from 'react';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport { fieldArrayVariants } from '../fieldArrayVariants';\nimport ElementAppendButton from './ElementAppendButton';\nimport FieldArrayElement from './FieldArrayElement';\nimport FieldArrayLabel from './FieldArrayLabel';\nimport FieldArrayValidationError from './FieldArrayValidationError';\nimport SortContext from './SortContext';\n\nexport type { FieldArrayItem } from '../../hooks/useUniformFieldArray/types';\n\ninterface FieldArrayControlProps extends Pick<\n FieldArrayProps,\n | 'appendButtonText'\n | 'children'\n | 'className'\n | 'duplicate'\n | 'elementMarginBottom'\n | 'insertAfter'\n | 'lastElementNotRemovable'\n | 'sortable'\n> {\n /** Disables animation during array initialization */\n disableAnimation: boolean;\n /** Bound field values, interactions and metadata */\n field: UniformField;\n /** Stable row IDs used by the sorting engine */\n fields: Record<'id', string>[];\n /** Bound rows to arrange in the list */\n items: FieldArrayItem[];\n /** Callback when the append button is activated */\n onAppend: () => void;\n /** Callback when sorting moves a row */\n onMove: (from: number, to: number) => void;\n}\n\n/** Array group presentation with row controls, sorting and validation messages */\nconst FieldArrayControl = ({\n field,\n appendButtonText,\n children,\n className,\n disableAnimation,\n duplicate,\n elementMarginBottom,\n fields,\n items,\n insertAfter,\n lastElementNotRemovable,\n onAppend,\n onMove,\n sortable = false,\n}: FieldArrayControlProps) => {\n const { error, ids, invalid, name, required, testId } = field;\n\n // keep the array heading hidden when only debug label content exists\n const label = field.hasLabel ? field.label : undefined;\n\n const styling = useStyling();\n const labelId = useId();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasArrayErrors = !!(invalid && error?._errors);\n\n const { cn } = styling;\n\n // classNames from slots\n const variants = styling.resolve(fieldArrayVariants, { hasLabel: !!label });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-label={!label ? name : undefined}\n aria-labelledby={label ? labelId : undefined}\n className={classNames.base}\n data-component=\"field-array\"\n role=\"group\"\n >\n {/* field array label */}\n <FieldArrayLabel\n className={classNames.label}\n id={labelId}\n invalid={hasArrayErrors}\n label={label}\n required={required}\n />\n\n {fields.length ? (\n /* sortable rows */\n <div className={cn(classNames.listWrapper)}>\n <SortContext fields={fields} move={onMove} sortable={sortable}>\n <ul className={classNames.list} data-testid={testId}>\n {items.map(({ id, renderProps }) => {\n return (\n <FieldArrayElement\n key={id}\n className={classNames}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n fields={fields}\n id={id}\n index={renderProps.index}\n insertAfter={insertAfter}\n lastNotDeletable={lastElementNotRemovable}\n methods={renderProps.methods}\n sortable={sortable}\n testId={renderProps.testId}\n >\n {children(renderProps)}\n </FieldArrayElement>\n );\n })}\n </ul>\n </SortContext>\n </div>\n ) : null}\n\n {/* top level field array errors */}\n <FieldArrayValidationError\n error={error}\n ids={ids}\n invalid={invalid}\n testId={testId}\n />\n\n {/* append elements button */}\n <ElementAppendButton\n appendButtonText={appendButtonText}\n className={classNames.appendButton}\n onClick={onAppend}\n testId={`${testId}_append_button`}\n />\n </div>\n );\n};\n\nexport default FieldArrayControl;\n","import type { CSSProperties, ReactNode } from 'react';\nimport type { ClassName, VariantProps } from './fieldArrayVariants';\nimport type { FieldArrayChildrenRenderFn, FieldArrayFeatures } from './types';\n\nimport useUniformFieldArray from '../hooks/useUniformFieldArray/useUniformFieldArray';\nimport FieldArrayControl from './subcomponents/FieldArrayControl';\n\nexport { fieldArrayVariants } from './fieldArrayVariants';\n\nexport interface FieldArrayProps extends FieldArrayFeatures, VariantProps {\n /** text of the append element button */\n appendButtonText?: string;\n /** function that renders the children with provided Properties. */\n children: FieldArrayChildrenRenderFn;\n /** CSS class name */\n className?: ClassName;\n /* initial value of a filed that is created in the array */\n elementInitialValue?: unknown;\n /*\n * bottom margin of a list element (default 1rem), this needs to be set as a prop (and not via className slot)\n * because the margin bottom needs to be animated when elements are added or removed\n */\n elementMarginBottom?: CSSProperties['marginBottom'];\n /** when true, array stores primitives as wrapper objects: { __FLAT__: value } */\n flat?: boolean;\n /** Field label */\n label?: ReactNode;\n /** when true (default false) last element can not be removed and will be shown even if field array is empty */\n lastElementNotRemovable?: boolean;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/** Form field group for adding, removing and reordering array entries */\nconst FieldArray = ({\n appendButtonText = 'Add Element',\n children,\n className: _className = undefined,\n duplicate = false,\n elementInitialValue: _elementInitialValue = null,\n elementMarginBottom = undefined,\n flat = false,\n insertAfter = false,\n lastElementNotRemovable = false,\n name,\n sortable = false,\n ...uniformFieldProps\n}: FieldArrayProps) => {\n const { field, fields, appendItem, items, moveItem, disableAnimation } =\n useUniformFieldArray({\n ...uniformFieldProps,\n elementInitialValue: _elementInitialValue,\n flat,\n lastElementNotRemovable,\n name,\n });\n\n return (\n <FieldArrayControl\n appendButtonText={appendButtonText}\n className={_className}\n disableAnimation={disableAnimation}\n duplicate={duplicate}\n elementMarginBottom={elementMarginBottom}\n field={field}\n fields={fields}\n insertAfter={insertAfter}\n items={items}\n lastElementNotRemovable={lastElementNotRemovable}\n onAppend={appendItem}\n onMove={moveItem}\n sortable={sortable}\n >\n {children}\n </FieldArrayControl>\n );\n};\n\nexport default FieldArray;\n","import FieldArray from './FieldArray';\n\nexport type * from './types';\n\nexport { fieldArrayVariants } from './FieldArray';\n\nexport default FieldArray;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,MAAa,+BAGX,EACE,MACA,OAAO,OACP,qBAAqB,uBAAuB,MAC5C,0BAA0B,SAE5B,iBAC6C;CAC7C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,QAAQ,QAAQ,QAAQ,QAAQ,MAAM,YAAYA,cAAiB;EACzE;EACA;CACF,CAAC;CAED,MAAM,EAAE,SAAS,UAAU,cAAcC,iBAA6B;CAStE,MAAM,kBAAkB,cAAc;EACpC,OAAO,2BAA2B,OAAO,WAAW;CACtD,GAAG,CAAC,yBAAyB,OAAO,MAAM,CAAC;CAS3C,MAAM,iBAAiB,OAAO,CAAC,eAAe;CAK9C,gBAAgB;EACd,IAAI,iBACF,eAAe,UAAU;CAE7B,GAAG,CAAC,eAAe,CAAC;CAOpB,gBAAgB;EACd,IAAI,eAAe,SACjB,iBAAiB;GACf,QAAQ,IAA0B;EACpC,GAAG,GAAG;CAGV,GAAG,CAAC,OAAO,MAAM,CAAC;CAIlB,MA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EAET;CACgB,CAAA;AAEvB;;ACxEA,IAAA,qBAAe"}
@@ -1,6 +1,8 @@
1
- import { n as useUniformField, t as FieldLabel } from "../FieldLabel-DrNWJIVh.mjs";
2
- import { n as useFormContext, t as checkFieldIsRequired } from "../useFormContext-piqnN2L-.mjs";
3
- import { n as FieldValidationError } from "../FieldValidationError-iAayfTEw.mjs";
1
+ import { t as useUniformField } from "../useUniformField-BvPoQyLL.mjs";
2
+ import { n as useFormContext, t as checkFieldIsRequired } from "../useFormContext-CQzJhAU4.mjs";
3
+ import { t as FieldLabel } from "../FieldLabel-DMTqq0Jj.mjs";
4
+ import { n as FieldValidationError } from "../FieldValidationError-BuLvuRyi.mjs";
5
+ import { t as fieldHelperVariants } from "../fieldHelperVariants-ClP8taiS.mjs";
4
6
  import { useDebounce } from "@fuf-stack/pixels";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  import { tv } from "@fuf-stack/pixel-utils";
@@ -119,7 +121,7 @@ const fieldCardVariants = tv({
119
121
  /** class for the error footer wrapper */
120
122
  errorFooter: [
121
123
  "border-t",
122
- "block px-3 pb-2 pt-1",
124
+ "block px-3 pt-1 pb-2",
123
125
  "transition-colors duration-150 motion-reduce:transition-none"
124
126
  ],
125
127
  /** class for the error text (empty base, color controlled by variant) */
@@ -128,7 +130,7 @@ const fieldCardVariants = tv({
128
130
  label: [
129
131
  "pointer-events-auto! static! z-auto! block! w-full!",
130
132
  "translate-x-0! translate-y-0! transform-none!",
131
- "rounded-t-small border-b p-3 font-semibold text-medium",
133
+ "rounded-t-small border-b p-3 text-medium font-semibold",
132
134
  "transition-colors duration-150 motion-reduce:transition-none"
133
135
  ]
134
136
  },
@@ -136,25 +138,20 @@ const fieldCardVariants = tv({
136
138
  false: {
137
139
  base: "border-divider",
138
140
  errorFooter: "border-divider",
139
- errorText: "!text-foreground-500 text-tiny",
141
+ errorText: "text-tiny !text-foreground-500",
140
142
  label: "border-divider text-foreground"
141
143
  },
142
144
  true: {
143
145
  base: "border-danger-200",
144
146
  errorFooter: "border-danger-200",
145
- errorText: "!text-danger text-tiny",
147
+ errorText: "text-tiny !text-danger",
146
148
  label: "border-danger-200 text-danger"
147
149
  }
148
150
  } },
149
151
  defaultVariants: { invalid: false }
150
152
  });
151
153
  // src/FieldCard/subcomponents/fieldCardValidationErrorVariants.ts
152
- const fieldCardValidationErrorVariants = tv({ slots: {
153
- /** Container for card-level validation messages */
154
- errorMessage: "text-danger text-tiny",
155
- /** Footer containing card-level validation */
156
- helperWrapper: "relative flex flex-col gap-1.5 p-0"
157
- } });
154
+ const fieldCardValidationErrorVariants = tv({ extend: fieldHelperVariants });
158
155
  // src/FieldCard/subcomponents/FieldCardValidationError.tsx
159
156
  /**
160
157
  * Renders validation errors in the footer of a FieldCard component.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/FieldCard/fieldCardValidation.ts","../../src/FieldCard/hooks/useFieldCardValidation.ts","../../src/FieldCard/fieldCardVariants.ts","../../src/FieldCard/subcomponents/fieldCardValidationErrorVariants.ts","../../src/FieldCard/subcomponents/FieldCardValidationError.tsx","../../src/FieldCard/subcomponents/FieldCardControl.tsx","../../src/FieldCard/FieldCard.tsx","../../src/FieldCard/index.ts"],"sourcesContent":["/**\n * Recursively checks if any child field has an error (regardless of touched state).\n * Returns true if at least one child has an error.\n */\nexport const hasAnyChildErrors = (\n errors: Record<string, unknown> | undefined,\n): boolean => {\n if (!errors) {\n return false;\n }\n\n return Object.keys(errors)\n .filter((key) => {\n return key !== '_errors';\n })\n .some((key) => {\n const errorValue = errors[key];\n if (errorValue === undefined) {\n return false;\n }\n // If errorValue is an array, it's a leaf field error\n if (Array.isArray(errorValue)) {\n return true;\n }\n // Recursively check nested objects\n if (typeof errorValue === 'object' && errorValue !== null) {\n return hasAnyChildErrors(errorValue as Record<string, unknown>);\n }\n return false;\n });\n};\n\n/**\n * Recursively checks if any child field is touched.\n * Returns true if at least one child is touched.\n */\nexport const hasAnyChildTouched = (\n touched: Record<string, unknown> | undefined,\n): boolean => {\n if (!touched) {\n return false;\n }\n\n return Object.keys(touched)\n .filter((key) => {\n return key !== '_errors';\n })\n .some((key) => {\n const touchedValue = touched[key];\n if (touchedValue === undefined) {\n return false;\n }\n // If touchedValue is truthy (boolean true), field is touched\n if (touchedValue === true) {\n return true;\n }\n // Recursively check nested objects\n if (typeof touchedValue === 'object' && touchedValue !== null) {\n return hasAnyChildTouched(touchedValue as Record<string, unknown>);\n }\n return false;\n });\n};\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\n/** Reads nested child touched state for a dotted field path */\nexport 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","import type { UniformField } from '../../hooks/useUniformField/types';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport {\n checkFieldIsRequired,\n useFormContext,\n} from '../../hooks/useFormContext';\nimport {\n getNestedValue,\n hasAnyChildErrors,\n hasAnyChildTouched,\n hasVisibleChildErrors,\n} from '../fieldCardValidation';\n\n/**\n * Derives the card's required and invalid states from its nested fields\n *\n * A card groups independently registered inputs, so its own field state does\n * not tell us whether a child is required or which child errors are visible\n * Required state comes from registered descendants and their validation schema\n *\n * Child errors become visible after that child is touched or the form is submitted\n * Object-level errors follow child interaction or submission when no child errors\n * exist, so they do not reveal untouched child failures early\n *\n * Debounces invalid-state changes to prevent flickering during validation updates\n */\nconst useFieldCardValidation = (\n field: Pick<UniformField, 'error' | 'name'>,\n) => {\n const { error, name } = field;\n\n const {\n control,\n formState: { touchedFields, submitCount },\n validation,\n } = useFormContext();\n\n // inspect registered children for required fields\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 // resolve touched state for nested children\n const fieldTouched = getNestedValue(touchedFields, name);\n\n // retain object-level errors alongside child errors\n // @ts-expect-error - error._errors exists but not typed\n const hasObjectErrors = !!error?._errors;\n\n const errorRecord = error as unknown as Record<string, unknown>;\n\n const hasChildErrors = hasAnyChildErrors(errorRecord);\n const isAnyChildTouched = hasAnyChildTouched(fieldTouched);\n\n // reveal child errors after interaction or submission\n const rawShowInvalid =\n (hasChildErrors &&\n (hasVisibleChildErrors(errorRecord, fieldTouched) || submitCount > 0)) ||\n (hasObjectErrors &&\n !hasChildErrors &&\n (isAnyChildTouched || submitCount > 0));\n\n // prevent flickering during rapid validation updates\n const showInvalid = useDebounce(rawShowInvalid, 200);\n\n return { invalid: showInvalid, required: isRequired };\n};\n\nexport default useFieldCardValidation;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\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 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 /** class for the error text (empty base, color controlled by variant) */\n errorText: [],\n /** class for the label/header */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) 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 },\n variants: {\n invalid: {\n false: {\n base: 'border-divider',\n errorFooter: 'border-divider',\n errorText: '!text-foreground-500 text-tiny',\n label: 'border-divider text-foreground',\n },\n true: {\n base: 'border-danger-200',\n errorFooter: 'border-danger-200',\n errorText: '!text-danger text-tiny',\n label: 'border-danger-200 text-danger',\n },\n },\n },\n defaultVariants: {\n invalid: false,\n },\n});\n\nexport type ClassName = TVClassName<typeof fieldCardVariants>;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nconst fieldCardValidationErrorVariants = tv({\n slots: {\n /** Container for card-level validation messages */\n errorMessage: 'text-danger text-tiny',\n /** Footer containing card-level validation */\n helperWrapper: 'relative flex flex-col gap-1.5 p-0',\n },\n});\n\nexport default fieldCardValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldCardValidationErrorVariants from './fieldCardValidationErrorVariants';\n\nexport interface FieldCardValidationErrorProps {\n /** CSS class name */\n className?: string;\n /** Error object from parent FieldCard (passed directly to avoid duplicate hook calls) */\n error?: FieldError[] | undefined;\n /** Optional error association ID supplied by the owning group. */\n errorId: string;\n /** CSS class name for the error text (controls color based on invalid state) */\n errorTextClassName?: string;\n /** HTML data-testid attribute for e2e tests */\n testId: 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 *\n * Note: Object-level errors (_errors) are always shown when they exist,\n * but the danger styling is controlled by the parent FieldCard based on\n * whether child fields have been touched.\n */\nconst FieldCardValidationError = ({\n className = undefined,\n error = undefined,\n errorTextClassName = undefined,\n errorId,\n testId,\n}: FieldCardValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldCardValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants, {\n errorMessage: errorTextClassName,\n helperWrapper: className,\n });\n\n // show object-level errors whenever they exist\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = !!objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-card-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={errorId}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldCardValidationError;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldCardProps } from '../FieldCard';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { fieldCardVariants } from '../fieldCardVariants';\nimport FieldCardValidationError from './FieldCardValidationError';\n\ninterface FieldCardControlProps extends Pick<\n FieldCardProps,\n 'children' | 'className'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField;\n}\n\n/** Card presentation with an accessible heading, content and animated error footer */\nconst FieldCardControl = ({\n field,\n children,\n className,\n}: FieldCardControlProps) => {\n const { ariaLabel, error, ids, invalid, label, required, testId } = field;\n\n const styling = useStyling();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasObjectErrors = !!error?._errors;\n\n // classNames from slots\n const variants = styling.resolve(fieldCardVariants, { invalid });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-describedby={hasObjectErrors ? ids.error : undefined}\n aria-label={!label ? ariaLabel : undefined}\n aria-labelledby={label ? ids.label : undefined}\n className={classNames.base}\n data-component=\"field-card\"\n role=\"group\"\n >\n {/* card header with label */}\n {label ? (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={classNames.label}\n id={ids.label}\n required={required}\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n ) : null}\n\n {/* card content */}\n <div className={classNames.content}>{children}</div>\n\n {/* card footer with object-level validation messages */}\n <FieldCardValidationError\n className={classNames.errorFooter}\n error={error}\n errorId={ids.error}\n errorTextClassName={classNames.errorText}\n testId={testId}\n />\n </div>\n );\n};\n\nexport default FieldCardControl;\n","import type { ReactNode } from 'react';\nimport type { ClassName } from './fieldCardVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport useFieldCardValidation from './hooks/useFieldCardValidation';\nimport FieldCardControl from './subcomponents/FieldCardControl';\n\nexport { fieldCardVariants } from './fieldCardVariants';\nexport {\n hasAnyChildErrors,\n hasAnyChildTouched,\n hasVisibleChildErrors,\n} from './fieldCardValidation';\n\nexport interface FieldCardProps {\n /** Content to render inside the card */\n children: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Field label */\n label: ReactNode;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Groups related form fields in a card with a heading and validation footer\n *\n * Renders nested fields in the body and object-level validation messages in the\n * footer. Individual fields retain their own validation messages\n *\n * The card's required indicator reflects its nested fields, and its danger\n * outline follows child interaction and form submission\n */\nconst FieldCard = ({\n children,\n className: _className = undefined,\n name,\n ...uniformFieldProps\n}: FieldCardProps) => {\n const { field } = useUniformField({\n ...uniformFieldProps,\n name,\n });\n\n const validation = useFieldCardValidation(field);\n\n return (\n <FieldCardControl\n className={_className}\n field={{ ...field, ...validation }}\n >\n {children}\n </FieldCardControl>\n );\n};\n\nexport default FieldCard;\n","import FieldCard from './FieldCard';\n\nexport type { FieldCardProps } from './FieldCard';\n\nexport { fieldCardVariants } from './FieldCard';\n\nexport default FieldCard;\n"],"mappings":";;;;;;;;;;;;;AAIA,MAAa,qBACX,WACY;CACZ,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,KAAK,MAAM,CAAC,CACvB,QAAQ,QAAQ;EACf,OAAO,QAAQ;CACjB,CAAC,CAAC,CACD,MAAM,QAAQ;EACb,MAAM,aAAa,OAAO;EAC1B,IAAI,eAAe,KAAA,GACjB,OAAO;EAGT,IAAI,MAAM,QAAQ,UAAU,GAC1B,OAAO;EAGT,IAAI,OAAO,eAAe,YAAY,eAAe,MACnD,OAAO,kBAAkB,UAAqC;EAEhE,OAAO;CACT,CAAC;AACL;;;;;AAMA,MAAa,sBACX,YACY;CACZ,IAAI,CAAC,SACH,OAAO;CAGT,OAAO,OAAO,KAAK,OAAO,CAAC,CACxB,QAAQ,QAAQ;EACf,OAAO,QAA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,MAAK;IAEJ,UAAA;GACS,CAAA,IACV;GAGJ,oBAAC,OAAD;IAAK,WAAW,WAAW;IAAU;GAAc,CAAA;GAGnD,oBAAC,0BAAD;IACE,WAAW,WAAW;IACf;IACP,SAAS,IAAI;IACb,oBAAoB,WAAW;IACvB;GACT,CAAA;EACE;;AAET;;;;;;;;;;;AClCA,MAAM,aAAa,EACjB,UACA,WAAW,aAAa,KAAA,GACxB,MACA,GAAG,wBACiB;CACpB,MAAM,EAAE,UAAU,gBAAgB;EAChC,GAAG;EACH;CACF,CAAC;CAED,MAAM,aAAa,uBAAuB,KAAK;CAE/C,OACE,oBAAC,kBAAD;EACE,WAAW;EACX,OAAO;GAAE,GAAG;GAAO,GAAG;EAAW;EAEhC;CACe,CAAA;AAEtB;;ACnDA,IAAA,oBAAe"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/FieldCard/fieldCardValidation.ts","../../src/FieldCard/hooks/useFieldCardValidation.ts","../../src/FieldCard/fieldCardVariants.ts","../../src/FieldCard/subcomponents/fieldCardValidationErrorVariants.ts","../../src/FieldCard/subcomponents/FieldCardValidationError.tsx","../../src/FieldCard/subcomponents/FieldCardControl.tsx","../../src/FieldCard/FieldCard.tsx","../../src/FieldCard/index.ts"],"sourcesContent":["/**\n * Recursively checks if any child field has an error (regardless of touched state).\n * Returns true if at least one child has an error.\n */\nexport const hasAnyChildErrors = (\n errors: Record<string, unknown> | undefined,\n): boolean => {\n if (!errors) {\n return false;\n }\n\n return Object.keys(errors)\n .filter((key) => {\n return key !== '_errors';\n })\n .some((key) => {\n const errorValue = errors[key];\n if (errorValue === undefined) {\n return false;\n }\n // If errorValue is an array, it's a leaf field error\n if (Array.isArray(errorValue)) {\n return true;\n }\n // Recursively check nested objects\n if (typeof errorValue === 'object' && errorValue !== null) {\n return hasAnyChildErrors(errorValue as Record<string, unknown>);\n }\n return false;\n });\n};\n\n/**\n * Recursively checks if any child field is touched.\n * Returns true if at least one child is touched.\n */\nexport const hasAnyChildTouched = (\n touched: Record<string, unknown> | undefined,\n): boolean => {\n if (!touched) {\n return false;\n }\n\n return Object.keys(touched)\n .filter((key) => {\n return key !== '_errors';\n })\n .some((key) => {\n const touchedValue = touched[key];\n if (touchedValue === undefined) {\n return false;\n }\n // If touchedValue is truthy (boolean true), field is touched\n if (touchedValue === true) {\n return true;\n }\n // Recursively check nested objects\n if (typeof touchedValue === 'object' && touchedValue !== null) {\n return hasAnyChildTouched(touchedValue as Record<string, unknown>);\n }\n return false;\n });\n};\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\n/** Reads nested child touched state for a dotted field path */\nexport 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","import type { UniformField } from '../../hooks/useUniformField/types';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport {\n checkFieldIsRequired,\n useFormContext,\n} from '../../hooks/useFormContext';\nimport {\n getNestedValue,\n hasAnyChildErrors,\n hasAnyChildTouched,\n hasVisibleChildErrors,\n} from '../fieldCardValidation';\n\n/**\n * Derives the card's required and invalid states from its nested fields\n *\n * A card groups independently registered inputs, so its own field state does\n * not tell us whether a child is required or which child errors are visible\n * Required state comes from registered descendants and their validation schema\n *\n * Child errors become visible after that child is touched or the form is submitted\n * Object-level errors follow child interaction or submission when no child errors\n * exist, so they do not reveal untouched child failures early\n *\n * Debounces invalid-state changes to prevent flickering during validation updates\n */\nconst useFieldCardValidation = (\n field: Pick<UniformField, 'error' | 'name'>,\n) => {\n const { error, name } = field;\n\n const {\n control,\n formState: { touchedFields, submitCount },\n validation,\n } = useFormContext();\n\n // inspect registered children for required fields\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 // resolve touched state for nested children\n const fieldTouched = getNestedValue(touchedFields, name);\n\n // retain object-level errors alongside child errors\n // @ts-expect-error - error._errors exists but not typed\n const hasObjectErrors = !!error?._errors;\n\n const errorRecord = error as unknown as Record<string, unknown>;\n\n const hasChildErrors = hasAnyChildErrors(errorRecord);\n const isAnyChildTouched = hasAnyChildTouched(fieldTouched);\n\n // reveal child errors after interaction or submission\n const rawShowInvalid =\n (hasChildErrors &&\n (hasVisibleChildErrors(errorRecord, fieldTouched) || submitCount > 0)) ||\n (hasObjectErrors &&\n !hasChildErrors &&\n (isAnyChildTouched || submitCount > 0));\n\n // prevent flickering during rapid validation updates\n const showInvalid = useDebounce(rawShowInvalid, 200);\n\n return { invalid: showInvalid, required: isRequired };\n};\n\nexport default useFieldCardValidation;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\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 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 pt-1 pb-2',\n // animate border color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n /** class for the error text (empty base, color controlled by variant) */\n errorText: [],\n /** class for the label/header */\n label: [\n // keep the label in normal flow at full width\n 'pointer-events-auto! static! z-auto! block! w-full!',\n // reset any transforms or translations\n 'translate-x-0! translate-y-0! transform-none!',\n // card header styling - use text-medium (16px) for proper header size\n 'rounded-t-small border-b p-3 text-medium font-semibold',\n // animate border and text color change, respect reduced motion\n 'transition-colors duration-150 motion-reduce:transition-none',\n ],\n },\n variants: {\n invalid: {\n false: {\n base: 'border-divider',\n errorFooter: 'border-divider',\n errorText: 'text-tiny !text-foreground-500',\n label: 'border-divider text-foreground',\n },\n true: {\n base: 'border-danger-200',\n errorFooter: 'border-danger-200',\n errorText: 'text-tiny !text-danger',\n label: 'border-danger-200 text-danger',\n },\n },\n },\n defaultVariants: {\n invalid: false,\n },\n});\n\nexport type ClassName = TVClassName<typeof fieldCardVariants>;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nimport { fieldHelperVariants } from '../../partials/FieldHelper/fieldHelperVariants';\n\n// own recipe identity, so styling can target FieldCard errors separately\nconst fieldCardValidationErrorVariants = tv({ extend: fieldHelperVariants });\n\nexport default fieldCardValidationErrorVariants;\n","import type { FieldError } from 'react-hook-form';\n\nimport {\n AnimatePresence,\n motion,\n useReducedMotion,\n} from '@fuf-stack/pixel-motion';\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldValidationError from '../../partials/FieldValidationError/FieldValidationError';\nimport fieldCardValidationErrorVariants from './fieldCardValidationErrorVariants';\n\nexport interface FieldCardValidationErrorProps {\n /** CSS class name */\n className?: string;\n /** Error object from parent FieldCard (passed directly to avoid duplicate hook calls) */\n error?: FieldError[] | undefined;\n /** Optional error association ID supplied by the owning group. */\n errorId: string;\n /** CSS class name for the error text (controls color based on invalid state) */\n errorTextClassName?: string;\n /** HTML data-testid attribute for e2e tests */\n testId: 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 *\n * Note: Object-level errors (_errors) are always shown when they exist,\n * but the danger styling is controlled by the parent FieldCard based on\n * whether child fields have been touched.\n */\nconst FieldCardValidationError = ({\n className = undefined,\n error = undefined,\n errorTextClassName = undefined,\n errorId,\n testId,\n}: FieldCardValidationErrorProps) => {\n const styling = useStyling();\n const disableAnimation = useReducedMotion();\n\n // classNames from slots\n const variants = styling.resolve(fieldCardValidationErrorVariants);\n const classNames = styling.variantsToClassNames(variants, {\n errorMessage: errorTextClassName,\n helperWrapper: className,\n });\n\n // show object-level errors whenever they exist\n const objectErrors = (error as unknown as { _errors?: FieldError[] })\n ?._errors;\n const hasErrors = !!objectErrors;\n\n return (\n <AnimatePresence initial={!disableAnimation}>\n {hasErrors ? (\n <motion.div\n key=\"field-card-errors\"\n animate={\n disableAnimation ? undefined : { opacity: 1, height: 'auto' }\n }\n exit={disableAnimation ? undefined : { opacity: 0, height: 0 }}\n initial={disableAnimation ? false : { height: 0, opacity: 0 }}\n style={{ overflow: 'hidden' }}\n transition={{ duration: 0.4, ease: 'circOut' }}\n >\n <div className={classNames.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldValidationError\n className={{ wrapper: classNames.errorMessage }}\n error={objectErrors}\n id={errorId}\n testId={testId}\n />\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n};\n\nexport default FieldCardValidationError;\n","import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldCardProps } from '../FieldCard';\n\nimport { useStyling } from '@fuf-stack/pixels/StylingProvider';\n\nimport FieldLabel from '../../partials/FieldLabel/FieldLabel';\nimport { fieldCardVariants } from '../fieldCardVariants';\nimport FieldCardValidationError from './FieldCardValidationError';\n\ninterface FieldCardControlProps extends Pick<\n FieldCardProps,\n 'children' | 'className'\n> {\n /** Bound field values, interactions and metadata */\n field: UniformField;\n}\n\n/** Card presentation with an accessible heading, content and animated error footer */\nconst FieldCardControl = ({\n field,\n children,\n className,\n}: FieldCardControlProps) => {\n const { ariaLabel, error, ids, invalid, label, required, testId } = field;\n\n const styling = useStyling();\n\n // @ts-expect-error - object-level errors include an _errors property\n const hasObjectErrors = !!error?._errors;\n\n // classNames from slots\n const variants = styling.resolve(fieldCardVariants, { invalid });\n const classNames = styling.variantsToClassNames(variants, className, 'base');\n\n return (\n <div\n aria-describedby={hasObjectErrors ? ids.error : undefined}\n aria-label={!label ? ariaLabel : undefined}\n aria-labelledby={label ? ids.label : undefined}\n className={classNames.base}\n data-component=\"field-card\"\n role=\"group\"\n >\n {/* card header with label */}\n {label ? (\n <FieldLabel\n aria-level={3}\n as=\"div\"\n className={classNames.label}\n id={ids.label}\n required={required}\n role=\"heading\"\n >\n {label}\n </FieldLabel>\n ) : null}\n\n {/* card content */}\n <div className={classNames.content}>{children}</div>\n\n {/* card footer with object-level validation messages */}\n <FieldCardValidationError\n className={classNames.errorFooter}\n error={error}\n errorId={ids.error}\n errorTextClassName={classNames.errorText}\n testId={testId}\n />\n </div>\n );\n};\n\nexport default FieldCardControl;\n","import type { ReactNode } from 'react';\nimport type { ClassName } from './fieldCardVariants';\n\nimport useUniformField from '../hooks/useUniformField/useUniformField';\nimport useFieldCardValidation from './hooks/useFieldCardValidation';\nimport FieldCardControl from './subcomponents/FieldCardControl';\n\nexport { fieldCardVariants } from './fieldCardVariants';\nexport {\n hasAnyChildErrors,\n hasAnyChildTouched,\n hasVisibleChildErrors,\n} from './fieldCardValidation';\n\nexport interface FieldCardProps {\n /** Content to render inside the card */\n children: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** Field label */\n label: ReactNode;\n /** Field name */\n name: string;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n}\n\n/**\n * Groups related form fields in a card with a heading and validation footer\n *\n * Renders nested fields in the body and object-level validation messages in the\n * footer. Individual fields retain their own validation messages\n *\n * The card's required indicator reflects its nested fields, and its danger\n * outline follows child interaction and form submission\n */\nconst FieldCard = ({\n children,\n className: _className = undefined,\n name,\n ...uniformFieldProps\n}: FieldCardProps) => {\n const { field } = useUniformField({\n ...uniformFieldProps,\n name,\n });\n\n const validation = useFieldCardValidation(field);\n\n return (\n <FieldCardControl\n className={_className}\n field={{ ...field, ...validation }}\n >\n {children}\n </FieldCardControl>\n );\n};\n\nexport default FieldCard;\n","import FieldCard from './FieldCard';\n\nexport type { FieldCardProps } from './FieldCard';\n\nexport { fieldCardVariants } from './FieldCard';\n\nexport default FieldCard;\n"],"mappings":";;;;;;;;;;;;;;;AAIA,MAAa,qBACX,WACY;CACZ,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,KAAK,MAAM,CAAC,CACvB,QAAQ,QAAQ;EACf,OAAO,QAAQ;CACjB,CAAC,CAAC,CACD,MAAM,QAAQ;EACb,MAAM,aAAa,OAAO;EAC1B,IAAI,eAAe,KAAA,GACjB,OAAO;EAGT,IAAI,MAAM,QAAQ,UAAU,GAC1B,OAAO;EAGT,IAAI,OAAO,eAAe,YAAY,eAAe,MACnD,OAAO,kBAAkB,UAAqC;EAEhE,OAAO;CACT,CAAC;AACL;;;;;AAMA,MAAa,sBACX,YACY;CACZ,IAAI,CAAC,SACH,OAAO;CAGT,OAAO,OAAO,KAAK,OAAO,CAAC,CACxB,QAAQ,QAAQ;EACf,OAAO,QAAQ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,IACV;GAGJ,oBAAC,OAAD;IAAK,WAAW,WAAW;IAAU;GAAc,CAAA;GAGnD,oBAAC,0BAAD;IACE,WAAW,WAAW;IACf;IACP,SAAS,IAAI;IACb,oBAAoB,WAAW;IACvB;GACT,CAAA;EACE;;AAET;;;;;;;;;;;AClCA,MAAM,aAAa,EACjB,UACA,WAAW,aAAa,KAAA,GACxB,MACA,GAAG,wBACiB;CACpB,MAAM,EAAE,UAAU,gBAAgB;EAChC,GAAG;EACH;CACF,CAAC;CAED,MAAM,aAAa,uBAAuB,KAAK;CAE/C,OACE,oBAAC,kBAAD;EACE,WAAW;EACX,OAAO;GAAE,GAAG;GAAO,GAAG;EAAW;EAEhC;CACe,CAAA;AAEtB;;ACnDA,IAAA,oBAAe"}
@@ -0,0 +1,38 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ // src/partials/FieldDescription/FieldDescription.tsx
3
+ /** Help text associated with a field through its description ID */
4
+ const FieldDescription = ({ children, ...props }) => {
5
+ if (!children) return null;
6
+ return /* @__PURE__ */ jsx("div", {
7
+ "data-slot": "description",
8
+ ...props,
9
+ children
10
+ });
11
+ };
12
+ // src/partials/FieldHelper/FieldHelper.tsx
13
+ /**
14
+ * Help text and validation messages below a field
15
+ *
16
+ * Renders nothing without help text or visible validation. The IDs match the
17
+ * control's aria-describedby associations.
18
+ */
19
+ const FieldHelper = ({ className = {}, description = void 0, errorMessage = void 0, ids, invalid }) => {
20
+ if (!description && !invalid) return null;
21
+ return /* @__PURE__ */ jsxs("div", {
22
+ className: className.helperWrapper,
23
+ "data-slot": "helper-wrapper",
24
+ children: [/* @__PURE__ */ jsx(FieldDescription, {
25
+ className: className.description,
26
+ id: ids.description,
27
+ children: description
28
+ }), invalid ? /* @__PURE__ */ jsx("div", {
29
+ className: className.errorMessage,
30
+ "data-slot": "error-message",
31
+ id: ids.error,
32
+ children: errorMessage
33
+ }) : null]
34
+ });
35
+ };
36
+ export { FieldDescription as n, FieldHelper as t };
37
+
38
+ //# sourceMappingURL=FieldHelper-B1DWl7eu.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldHelper-B1DWl7eu.mjs","names":[],"sources":["../src/partials/FieldDescription/FieldDescription.tsx","../src/partials/FieldHelper/FieldHelper.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react';\n\ninterface FieldDescriptionProps extends HTMLAttributes<HTMLDivElement> {\n /** Help text */\n children: ReactNode;\n /** CSS class name */\n className?: string;\n}\n\n/** Help text associated with a field through its description ID */\nconst FieldDescription = ({ children, ...props }: FieldDescriptionProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <div data-slot=\"description\" {...props}>\n {children}\n </div>\n );\n};\n\nexport default FieldDescription;\n","import type { ReactNode } from 'react';\nimport type { FieldIds } from '../types';\n\nimport FieldDescription from '../FieldDescription/FieldDescription';\n\ntype ClassName = Partial<\n Record<'description' | 'errorMessage' | 'helperWrapper', string>\n>;\n\nexport interface FieldHelperProps {\n /** CSS class name */\n className?: ClassName;\n /** Help text */\n description?: ReactNode;\n /** Rendered validation messages */\n errorMessage?: ReactNode;\n /** IDs of the help text and validation message */\n ids: Pick<FieldIds, 'description' | 'error'>;\n /** Shows the validation message */\n invalid: boolean;\n}\n\n/**\n * Help text and validation messages below a field\n *\n * Renders nothing without help text or visible validation. The IDs match the\n * control's aria-describedby associations.\n */\nconst FieldHelper = ({\n className = {},\n description = undefined,\n errorMessage = undefined,\n ids,\n invalid,\n}: FieldHelperProps) => {\n if (!description && !invalid) {\n return null;\n }\n\n return (\n <div className={className.helperWrapper} data-slot=\"helper-wrapper\">\n <FieldDescription className={className.description} id={ids.description}>\n {description}\n </FieldDescription>\n {invalid ? (\n <div\n className={className.errorMessage}\n data-slot=\"error-message\"\n id={ids.error}\n >\n {errorMessage}\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default FieldHelper;\n"],"mappings":";;;AAUA,MAAM,oBAAoB,EAAE,UAAU,GAAG,YAAmC;CAC1E,IAAI,CAAC,UACH,OAAO;CAGT,OACE,oBAAC,OAAD;EAAK,aAAU;EAAc,GAAI;EAC9B;CACE,CAAA;AAET;;;;;;;;ACQA,MAAM,eAAe,EACnB,YAAY,CAAC,GACb,cAAc,KAAA,GACd,eAAe,KAAA,GACf,KACA,cACsB;CACtB,IAAI,CAAC,eAAe,CAAC,SACnB,OAAO;CAGT,OACE,qBAAC,OAAD;EAAK,WAAW,UAAU;EAAe,aAAU;EAAnD,UAAA,CACE,oBAAC,kBAAD;GAAkB,WAAW,UAAU;GAAa,IAAI,IAAI;GACzD,UAAA;EACe,CAAA,GACjB,UACC,oBAAC,OAAD;GACE,WAAW,UAAU;GACrB,aAAU;GACV,IAAI,IAAI;GAEP,UAAA;EACE,CAAA,IACH,IACD;;AAET"}
@@ -0,0 +1,29 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ // src/partials/FieldLabel/FieldLabel.tsx
3
+ /**
4
+ * Shared field label and required indicator
5
+ *
6
+ * Uses a native label by default, with span/div hosts for nested labels and
7
+ * headings, or React Aria Label for fields that supply label context
8
+ *
9
+ * @see https://react-aria.adobe.com/TextField
10
+ * @see https://react-aria.adobe.com/CheckboxGroup
11
+ */
12
+ const FieldLabel = ({ as: Component = "label", children, className = void 0, htmlFor = void 0, id = void 0, required = false, requiredClassName = "ml-0.5 text-danger", ...props }) => {
13
+ if (!children) return null;
14
+ return /* @__PURE__ */ jsxs(Component, {
15
+ ...props,
16
+ className,
17
+ "data-slot": "label",
18
+ htmlFor,
19
+ id,
20
+ children: [children, required ? /* @__PURE__ */ jsx("span", {
21
+ "aria-hidden": true,
22
+ className: requiredClassName,
23
+ children: "*"
24
+ }) : null]
25
+ });
26
+ };
27
+ export { FieldLabel as t };
28
+
29
+ //# sourceMappingURL=FieldLabel-DMTqq0Jj.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldLabel-DMTqq0Jj.mjs","names":[],"sources":["../src/partials/FieldLabel/FieldLabel.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from 'react';\nimport type { Label as AriaLabel } from 'react-aria-components';\n\nexport interface FieldLabelProps extends Pick<\n HTMLAttributes<HTMLElement>,\n 'aria-level' | 'role'\n> {\n /** Label element, React Aria Label preserves the surrounding field context */\n as?: 'label' | 'div' | 'span' | typeof AriaLabel;\n /** Label content */\n children: ReactNode;\n /** CSS class name */\n className?: string;\n /** ID of the labeled control */\n htmlFor?: string;\n /** Label ID */\n id?: string;\n /** Shows the required indicator */\n required?: boolean;\n /** Required indicator CSS class name */\n requiredClassName?: string;\n}\n\n/**\n * Shared field label and required indicator\n *\n * Uses a native label by default, with span/div hosts for nested labels and\n * headings, or React Aria Label for fields that supply label context\n *\n * @see https://react-aria.adobe.com/TextField\n * @see https://react-aria.adobe.com/CheckboxGroup\n */\nconst FieldLabel = ({\n as: Component = 'label',\n children,\n className = undefined,\n htmlFor = undefined,\n id = undefined,\n required = false,\n requiredClassName = 'ml-0.5 text-danger',\n ...props\n}: FieldLabelProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <Component\n {...props}\n className={className}\n data-slot=\"label\"\n htmlFor={htmlFor}\n id={id}\n >\n {children}\n {required ? (\n <span aria-hidden className={requiredClassName}>\n *\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default FieldLabel;\n"],"mappings":";;;;;;;;;;;AAgCA,MAAM,cAAc,EAClB,IAAI,YAAY,SAChB,UACA,YAAY,KAAA,GACZ,UAAU,KAAA,GACV,KAAK,KAAA,GACL,WAAW,OACX,oBAAoB,sBACpB,GAAG,YACkB;CACrB,IAAI,CAAC,UACH,OAAO;CAGT,OACE,qBAAC,WAAD;EACE,GAAI;EACO;EACX,aAAU;EACD;EACL;EALN,UAAA,CAOG,UACA,WACC,oBAAC,QAAD;GAAM,eAAA;GAAY,WAAW;GAAmB,UAAA;EAE1C,CAAA,IACJ,IACK;;AAEf"}
@@ -1,5 +1,5 @@
1
- import { t as FieldDescription } from "./FieldDescription-X_0s1Lhu.mjs";
2
- import { t as FieldLabel } from "./FieldLabel-DrNWJIVh.mjs";
1
+ import { t as FieldHelper } from "./FieldHelper-B1DWl7eu.mjs";
2
+ import { t as FieldLabel } from "./FieldLabel-DMTqq0Jj.mjs";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  // src/partials/FieldLayout/FieldLayout.tsx
5
5
  /**
@@ -23,23 +23,16 @@ const FieldLayout = ({ baseAs = void 0, baseProps = void 0, children, className,
23
23
  children: label
24
24
  }),
25
25
  children,
26
- description || invalid ? /* @__PURE__ */ jsxs("div", {
27
- className: className.helperWrapper,
28
- "data-slot": "helper-wrapper",
29
- children: [/* @__PURE__ */ jsx(FieldDescription, {
30
- className: className.description,
31
- id: ids.description,
32
- children: description
33
- }), invalid ? /* @__PURE__ */ jsx("div", {
34
- className: className.errorMessage,
35
- "data-slot": "error-message",
36
- id: ids.error,
37
- children: errorMessage
38
- }) : null]
39
- }) : null
26
+ /* @__PURE__ */ jsx(FieldHelper, {
27
+ className,
28
+ description,
29
+ errorMessage,
30
+ ids,
31
+ invalid
32
+ })
40
33
  ]
41
34
  });
42
35
  };
43
36
  export { FieldLayout as t };
44
37
 
45
- //# sourceMappingURL=FieldLayout-DcvQU0zN.mjs.map
38
+ //# sourceMappingURL=FieldLayout-C9MEBZAC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldLayout-C9MEBZAC.mjs","names":[],"sources":["../src/partials/FieldLayout/FieldLayout.tsx"],"sourcesContent":["import type {\n ComponentProps,\n ComponentPropsWithRef,\n ElementType,\n ReactNode,\n} from 'react';\nimport type { FieldIds } from '../types';\n\nimport FieldHelper from '../FieldHelper/FieldHelper';\nimport FieldLabel from '../FieldLabel/FieldLabel';\n\ntype ClassName = Partial<\n Record<\n 'base' | 'description' | 'errorMessage' | 'helperWrapper' | 'label',\n string\n >\n>;\n\ntype BaseProps<TBase extends ElementType> = Omit<\n ComponentPropsWithRef<TBase>,\n 'children' | 'className' | 'dangerouslySetInnerHTML'\n> &\n Record<`data-${string}`, string | number | boolean | undefined>;\n\n// require the configuration when the base has props the layout cannot supply\ntype BaseConfiguration<TBase extends ElementType> =\n Record<never, never> extends BaseProps<TBase>\n ? { baseProps?: BaseProps<TBase> }\n : { baseProps: BaseProps<TBase> };\n\ninterface FieldLayoutProps<TBase extends ElementType> {\n /** Component or element used for the base slot */\n baseAs?: TBase;\n /** Attributes, interactions and ref for the base element */\n baseProps?: BaseProps<NoInfer<TBase>>;\n /** Editable field content */\n children: ReactNode;\n /** CSS class name */\n className: ClassName;\n /** Help text */\n description?: ReactNode;\n /** Rendered validation messages */\n errorMessage: ReactNode;\n /** IDs shared with the editable control */\n ids: FieldIds;\n /** Shows the validation message */\n invalid: boolean;\n /** Field label */\n label?: ReactNode;\n /** Label element, use React Aria Label inside group engines */\n labelAs?: ComponentProps<typeof FieldLabel>['as'];\n /** Shows the required indicator */\n required?: boolean;\n}\n\n/**\n * Default arrangement of a field label, editable content and supporting messages\n *\n * Renders the base component around the label, content and messages\n * Receives IDs, resolved classes and validation state\n */\nconst FieldLayout = <TBase extends ElementType = 'div'>({\n baseAs = undefined,\n baseProps = undefined,\n children,\n className,\n description = undefined,\n errorMessage,\n ids,\n invalid,\n label = undefined,\n labelAs = 'label',\n required = false,\n}: FieldLayoutProps<TBase> & BaseConfiguration<NoInfer<TBase>>) => {\n const Base = baseAs ?? 'div';\n\n return (\n <Base {...baseProps} className={className.base} data-slot=\"base\">\n {/* field label */}\n <FieldLabel\n as={labelAs}\n className={className.label}\n htmlFor={labelAs === 'label' ? ids.control : undefined}\n id={ids.label}\n required={required}\n >\n {label}\n </FieldLabel>\n\n {/* editable content */}\n {children}\n\n {/* help text and validation messages */}\n <FieldHelper\n className={className}\n description={description}\n errorMessage={errorMessage}\n ids={ids}\n invalid={invalid}\n />\n </Base>\n );\n};\n\nexport default FieldLayout;\n"],"mappings":";;;;;;;;;;AA6DA,MAAM,eAAkD,EACtD,SAAS,KAAA,GACT,YAAY,KAAA,GACZ,UACA,WACA,cAAc,KAAA,GACd,cACA,KACA,SACA,QAAQ,KAAA,GACR,UAAU,SACV,WAAW,YACsD;CAGjE,OACE,qBAHW,UAAU,OAGrB;EAAM,GAAI;EAAW,WAAW,UAAU;EAAM,aAAU;EAA1D,UAAA;GAEE,oBAAC,YAAD;IACE,IAAI;IACJ,WAAW,UAAU;IACrB,SAAS,YAAY,UAAU,IAAI,UAAU,KAAA;IAC7C,IAAI,IAAI;IACE;IAET,UAAA;GACS,CAAA;GAGX;GAGD,oBAAC,aAAD;IACa;IACE;IACC;IACT;IACI;GACV,CAAA;EACG;;AAEV"}
@@ -387,7 +387,7 @@ export declare const fieldResetVariants: ((props?: ({
387
387
  class?: never;
388
388
  className?: string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | readonly (string | false | 0 | 0n | /*elided*/ any | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined)[] | null | undefined;
389
389
  }))))[];
390
- variantKeys: never[] | (string | number)[];
390
+ variantKeys: (string | number)[] | never[];
391
391
  };
392
392
  type ClassName = TVClassName<typeof fieldResetVariants>;
393
393
  interface FieldResetRenderProps<TDisplay = string> {