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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/Checkboxes/index.d.mts +57 -37
  2. package/dist/Checkboxes/index.d.mts.map +1 -1
  3. package/dist/Checkboxes/index.mjs +19 -20
  4. package/dist/Checkboxes/index.mjs.map +1 -1
  5. package/dist/DatePicker/index.d.mts +71 -31
  6. package/dist/DatePicker/index.d.mts.map +1 -1
  7. package/dist/DatePicker/index.mjs +31 -29
  8. package/dist/DatePicker/index.mjs.map +1 -1
  9. package/dist/FieldArray/index.d.mts +8 -16
  10. package/dist/FieldArray/index.d.mts.map +1 -1
  11. package/dist/FieldArray/index.mjs +18 -32
  12. package/dist/FieldArray/index.mjs.map +1 -1
  13. package/dist/FieldCard/index.d.mts +0 -4
  14. package/dist/FieldCard/index.d.mts.map +1 -1
  15. package/dist/FieldCard/index.mjs +11 -19
  16. package/dist/FieldCard/index.mjs.map +1 -1
  17. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs → FieldCopyTestIdButton-D3_jZYJ1.mjs} +3 -5
  18. package/dist/{FieldCopyTestIdButton-DV0tkdh2.mjs.map → FieldCopyTestIdButton-D3_jZYJ1.mjs.map} +1 -1
  19. package/dist/{FieldDescription-C4l0HKGL.mjs → FieldDescription-X_0s1Lhu.mjs} +5 -6
  20. package/dist/FieldDescription-X_0s1Lhu.mjs.map +1 -0
  21. package/dist/{FieldLabel-DKzqkuY1.mjs → FieldLabel-DrNWJIVh.mjs} +15 -12
  22. package/dist/FieldLabel-DrNWJIVh.mjs.map +1 -0
  23. package/dist/{FieldLayout-BLW5S-Jm.mjs → FieldLayout-DcvQU0zN.mjs} +4 -5
  24. package/dist/{FieldLayout-BLW5S-Jm.mjs.map → FieldLayout-DcvQU0zN.mjs.map} +1 -1
  25. package/dist/FieldReset/index.d.mts +420 -0
  26. package/dist/FieldReset/index.d.mts.map +1 -0
  27. package/dist/FieldReset/index.mjs +258 -0
  28. package/dist/FieldReset/index.mjs.map +1 -0
  29. package/dist/{FieldValidationError-DgkCL3cC.mjs → FieldValidationError-iAayfTEw.mjs} +3 -5
  30. package/dist/{FieldValidationError-DgkCL3cC.mjs.map → FieldValidationError-iAayfTEw.mjs.map} +1 -1
  31. package/dist/Form/index.d.mts +12 -14
  32. package/dist/Form/index.d.mts.map +1 -1
  33. package/dist/Form/index.mjs +7 -10
  34. package/dist/Form/index.mjs.map +1 -1
  35. package/dist/FormContext-BnNJYZOo.d.mts +124 -0
  36. package/dist/FormContext-BnNJYZOo.d.mts.map +1 -0
  37. package/dist/{FormContext-CHctWFAP.mjs → FormContext-PXkVlBdU.mjs} +5 -9
  38. package/dist/{FormContext-CHctWFAP.mjs.map → FormContext-PXkVlBdU.mjs.map} +1 -1
  39. package/dist/Grid/index.d.mts +0 -2
  40. package/dist/Grid/index.d.mts.map +1 -1
  41. package/dist/Grid/index.mjs +1 -1
  42. package/dist/{Grid-DfcZeuib.mjs → Grid-DBL29Kwb.mjs} +3 -5
  43. package/dist/{Grid-DfcZeuib.mjs.map → Grid-DBL29Kwb.mjs.map} +1 -1
  44. package/dist/Input/index.d.mts +167 -115
  45. package/dist/Input/index.d.mts.map +1 -1
  46. package/dist/Input/index.mjs +20 -24
  47. package/dist/Input/index.mjs.map +1 -1
  48. package/dist/RadioBoxes/index.d.mts +226 -2222
  49. package/dist/RadioBoxes/index.d.mts.map +1 -1
  50. package/dist/RadioBoxes/index.mjs +24 -28
  51. package/dist/RadioBoxes/index.mjs.map +1 -1
  52. package/dist/RadioTabs/index.d.mts +121 -66
  53. package/dist/RadioTabs/index.d.mts.map +1 -1
  54. package/dist/RadioTabs/index.mjs +16 -19
  55. package/dist/RadioTabs/index.mjs.map +1 -1
  56. package/dist/Radios/index.d.mts +140 -2056
  57. package/dist/Radios/index.d.mts.map +1 -1
  58. package/dist/Radios/index.mjs +11 -14
  59. package/dist/Radios/index.mjs.map +1 -1
  60. package/dist/Select/index.d.mts +154 -21
  61. package/dist/Select/index.d.mts.map +1 -1
  62. package/dist/Select/index.mjs +65 -49
  63. package/dist/Select/index.mjs.map +1 -1
  64. package/dist/Slider/index.d.mts +143 -77
  65. package/dist/Slider/index.d.mts.map +1 -1
  66. package/dist/Slider/index.mjs +26 -18
  67. package/dist/Slider/index.mjs.map +1 -1
  68. package/dist/SubmitButton/index.d.mts +0 -2
  69. package/dist/SubmitButton/index.d.mts.map +1 -1
  70. package/dist/SubmitButton/index.mjs +2 -4
  71. package/dist/SubmitButton/index.mjs.map +1 -1
  72. package/dist/Switch/index.d.mts +1 -1
  73. package/dist/Switch/index.mjs +16 -18
  74. package/dist/Switch/index.mjs.map +1 -1
  75. package/dist/{Switch-CvPO8IF9.d.mts → Switch-Db2dpGz7.d.mts} +115 -68
  76. package/dist/{Switch-CvPO8IF9.d.mts.map → Switch-Db2dpGz7.d.mts.map} +1 -1
  77. package/dist/SwitchBox/index.d.mts +169 -126
  78. package/dist/SwitchBox/index.d.mts.map +1 -1
  79. package/dist/SwitchBox/index.mjs +18 -18
  80. package/dist/SwitchBox/index.mjs.map +1 -1
  81. package/dist/TextArea/index.d.mts +100 -57
  82. package/dist/TextArea/index.d.mts.map +1 -1
  83. package/dist/TextArea/index.mjs +14 -16
  84. package/dist/TextArea/index.mjs.map +1 -1
  85. package/dist/Time/index.d.mts +44 -28
  86. package/dist/Time/index.d.mts.map +1 -1
  87. package/dist/Time/index.mjs +13 -17
  88. package/dist/Time/index.mjs.map +1 -1
  89. package/dist/helpers/index.d.mts +0 -6
  90. package/dist/helpers/index.d.mts.map +1 -1
  91. package/dist/helpers/index.mjs +3 -6
  92. package/dist/helpers/index.mjs.map +1 -1
  93. package/dist/hooks/useClientValidation/index.d.mts +0 -2
  94. package/dist/hooks/useClientValidation/index.d.mts.map +1 -1
  95. package/dist/hooks/useClientValidation/index.mjs +3 -5
  96. package/dist/hooks/useController/index.d.mts +0 -2
  97. package/dist/hooks/useController/index.d.mts.map +1 -1
  98. package/dist/hooks/useController/index.mjs +2 -3
  99. package/dist/hooks/useFormContext/index.d.mts +31 -52
  100. package/dist/hooks/useFormContext/index.d.mts.map +1 -1
  101. package/dist/hooks/useFormContext/index.mjs +2 -3
  102. package/dist/hooks/useInputValueDebounce/index.d.mts +0 -2
  103. package/dist/hooks/useInputValueDebounce/index.d.mts.map +1 -1
  104. package/dist/hooks/useInputValueDebounce/index.mjs +3 -5
  105. package/dist/hooks/useInputValueTransform/index.d.mts +1 -1
  106. package/dist/hooks/useInputValueTransform/index.mjs +2 -3
  107. package/dist/hooks/useWatchFormReset/index.d.mts +0 -2
  108. package/dist/hooks/useWatchFormReset/index.d.mts.map +1 -1
  109. package/dist/hooks/useWatchFormReset/index.mjs +3 -5
  110. package/dist/hooks/useWatchUserChange/index.d.mts +0 -2
  111. package/dist/hooks/useWatchUserChange/index.d.mts.map +1 -1
  112. package/dist/hooks/useWatchUserChange/index.mjs +3 -5
  113. package/dist/{index-BS8IoBOn.d.mts → index-cevZBrIN.d.mts} +1 -3
  114. package/dist/index-cevZBrIN.d.mts.map +1 -0
  115. package/dist/partials/FieldCopyTestIdButton/index.d.mts +0 -2
  116. package/dist/partials/FieldCopyTestIdButton/index.d.mts.map +1 -1
  117. package/dist/partials/FieldCopyTestIdButton/index.mjs +1 -1
  118. package/dist/partials/FieldValidationError/index.d.mts +11 -13
  119. package/dist/partials/FieldValidationError/index.d.mts.map +1 -1
  120. package/dist/partials/FieldValidationError/index.mjs +1 -1
  121. package/dist/{radioControlVariants-Cm6WufWo.mjs → radioControlVariants-BYRfaD6y.mjs} +24 -25
  122. package/dist/radioControlVariants-BYRfaD6y.mjs.map +1 -0
  123. package/dist/{switchVariants-BaQw2DA7.mjs → switchVariants-D16b2VaT.mjs} +4 -4
  124. package/dist/{switchVariants-BaQw2DA7.mjs.map → switchVariants-D16b2VaT.mjs.map} +1 -1
  125. package/dist/{timeVariants-B9HDfNYt.mjs → timeVariants-CtXyNKmW.mjs} +3 -3
  126. package/dist/{timeVariants-B9HDfNYt.mjs.map → timeVariants-CtXyNKmW.mjs.map} +1 -1
  127. package/dist/{useController-BCFeZbBZ.mjs → useController-JtIeurpw.mjs} +3 -4
  128. package/dist/{useController-BCFeZbBZ.mjs.map → useController-JtIeurpw.mjs.map} +1 -1
  129. package/dist/{useFormContext-BPjJjNnM.mjs → useFormContext-piqnN2L-.mjs} +3 -4
  130. package/dist/useFormContext-piqnN2L-.mjs.map +1 -0
  131. package/dist/{useInputValueTransform-Mw8YEOXT.mjs → useInputValueTransform-CXWWFhy_.mjs} +2 -3
  132. package/dist/{useInputValueTransform-Mw8YEOXT.mjs.map → useInputValueTransform-CXWWFhy_.mjs.map} +1 -1
  133. package/package.json +8 -7
  134. package/dist/FieldDescription-C4l0HKGL.mjs.map +0 -1
  135. package/dist/FieldLabel-DKzqkuY1.mjs.map +0 -1
  136. package/dist/FormContext-CsFiNvuJ.d.mts +0 -19
  137. package/dist/FormContext-CsFiNvuJ.d.mts.map +0 -1
  138. package/dist/index-BS8IoBOn.d.mts.map +0 -1
  139. package/dist/radioControlVariants-Cm6WufWo.mjs.map +0 -1
  140. package/dist/useFormContext-BPjJjNnM.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useController-BCFeZbBZ.mjs","names":["useController","useRHFController"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n fieldState: ControllerFieldState;\n formState: UseFormStateReturn<TFieldValues>;\n}\n\n/**\n * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's useController\n * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n * 6. No-op when value unchanged: onChange is ignored if the new value equals the current value\n * (prevents unnecessary re-renders and spurious useWatchUserChange triggers)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Skip if value hasn't changed (e.g., user re-selects same option)\n // We compare formattedValue (the new value after nullish conversion) with\n // field.value (the current stored value, also in nullish format)\n if (formattedValue === field.value) {\n return;\n }\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n // NOTE: We notify with the original value (not formattedValue) so that\n // listeners receive the actual value (false, 0, null) instead of marker\n // strings like '__FALSE__', '__ZERO__', '__NULL__'\n userChange?.notify(field.name, value);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAaA,mBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,eAAeC,cAAiB,KAAK;CAC/D,MAAM,EAAE,eAAe,WAAW,cAAc;CAEhD,OAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,EAAE,EAAE,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAK,gBAAgB,KAAK;IAKhE,IAAI,mBAAmB,MAAM,OAC3B;IAIF,MAAM,SAAS,cAAc;IAQ7B,YAAY,OAAO,MAAM,MAAM,KAAK;GACtC;GAEA,OAAO,kBAAkB,MAAM,KAAK;EACtC;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useController-JtIeurpw.mjs","names":["useController","useRHFController"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n fieldState: ControllerFieldState;\n formState: UseFormStateReturn<TFieldValues>;\n}\n\n/**\n * A wrapper around react-hook-form's useController that transparently handles nullish string conversions.\n *\n * Key features:\n * 1. Empty strings ('') in the UI are stored as null in form state\n * 2. Null/undefined values in form state are displayed as empty strings in the UI\n * 3. Handles both direct value changes and React synthetic events\n * 4. Maintains the same API as react-hook-form's useController\n * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n * 6. No-op when value unchanged: onChange is ignored if the new value equals the current value\n * (prevents unnecessary re-renders and spurious useWatchUserChange triggers)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Skip if value hasn't changed (e.g., user re-selects same option)\n // We compare formattedValue (the new value after nullish conversion) with\n // field.value (the current stored value, also in nullish format)\n if (formattedValue === field.value) {\n return;\n }\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n // NOTE: We notify with the original value (not formattedValue) so that\n // listeners receive the actual value (false, 0, null) instead of marker\n // strings like '__FALSE__', '__ZERO__', '__NULL__'\n userChange?.notify(field.name, value);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAaA,mBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,eAAeC,cAAiB,KAAK;CAC/D,MAAM,EAAE,eAAe,WAAW,cAAc;CAEhD,OAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,EAAE,EAAE,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAK,gBAAgB,KAAK;IAKhE,IAAI,mBAAmB,MAAM,OAC3B;IAIF,MAAM,SAAS,cAAc;IAQ7B,YAAY,OAAO,MAAM,MAAM,KAAK;GACtC;GAEA,OAAO,kBAAkB,MAAM,KAAK;EACtC;EACA;EACA;CACF;AACF"}
@@ -1,8 +1,8 @@
1
- import { n as UniformContext } from "./FormContext-CHctWFAP.mjs";
1
+ import { n as UniformContext } from "./FormContext-PXkVlBdU.mjs";
2
2
  import { flatArrayKey, nameToTestId, toValidationFormat } from "./helpers/index.mjs";
3
3
  import { useContext } from "react";
4
4
  import { useFormContext } from "react-hook-form";
5
- //#region src/hooks/useFormContext/useFormContext.ts
5
+ // src/hooks/useFormContext/useFormContext.ts
6
6
  /** Schema check whether a field is required or optional */
7
7
  const checkFieldIsRequired = (validation, path) => {
8
8
  const checkPath = path[path.length - 1] === "__FLAT__" ? path.slice(0, -1) : path;
@@ -131,7 +131,6 @@ const useFormContext$1 = () => {
131
131
  watch
132
132
  };
133
133
  };
134
- //#endregion
135
134
  export { useFormContext$1 as n, checkFieldIsRequired as t };
136
135
 
137
- //# sourceMappingURL=useFormContext-BPjJjNnM.mjs.map
136
+ //# sourceMappingURL=useFormContext-piqnN2L-.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormContext-piqnN2L-.mjs","names":["useFormContext","useHookFormContext"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { ContextType } from 'react';\nimport type {\n FieldError,\n FieldValues,\n Path,\n UseFormReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors;\n keys.forEach((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n } else {\n current = undefined;\n }\n });\n return current as FieldError[] | undefined;\n};\n\n/** Field state returned by the enhanced `getFieldState` */\nexport interface UniformFieldState {\n /** Validation errors for the field from the Uniform validation schema */\n error: FieldError[] | undefined;\n /** Whether the field has validation errors */\n invalid: boolean;\n /** Whether the field value differs from its default value */\n isDirty: boolean;\n /** Whether the field has been touched */\n isTouched: boolean;\n /** Whether the field is currently being validated */\n isValidating: boolean;\n /** Whether the validation schema requires the field */\n required: boolean;\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Return type of `useFormContext`.\n *\n * Declared explicitly so the published declarations only reference types that\n * react-hook-form exports from its package root.\n */\nexport type UseFormContextReturn<\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n> = Omit<\n UseFormReturn<TFieldValues, TContext, TTransformedValues>,\n 'getFieldState'\n> &\n ContextType<typeof UniformContext> & {\n getFieldState: (\n name: Path<TFieldValues>,\n testId?: string,\n ) => UniformFieldState;\n };\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>(): UseFormContextReturn<TFieldValues, TContext, TTransformedValues> => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n reset: resetOrig,\n // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Wrap react-hook-form's `reset` so the uniform context is notified about\n * programmatic resets. Field components (e.g. FieldArray) use this signal to\n * normalize their state on reset instead of inferring it from field contents.\n */\n const notifyReset = uniformContext?.formReset?.notify;\n const reset = ((...args: Parameters<typeof resetOrig>) => {\n resetOrig(...args);\n notifyReset?.();\n }) as typeof resetOrig;\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (\n name: Path<TFieldValues>,\n testId?: string,\n ): UniformFieldState => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n );\n\n // Get everything but the error from the original field state\n const fieldState = getFieldStateOrig(name, formState);\n\n return {\n ...fieldState,\n error,\n invalid: !!error,\n required,\n testId: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n reset,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;AAkBA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAA,aAAsB,KAAK,MAAM,GAAG,EAAE,IAAI;CAE/D,MAAM,iBAAiB,WAAgB;EAErC,IAAI,OAAO,SAAS,SAAS;GAE3B,IAAI,OAAO,cAAc,OAAO,YAC9B,OAAO;GAGT,OAAO;EACT;EAIA,OAAO,CAAC,OAAO,cAAc,CAAC,OAAO;CACvC;CAEA,OAAO,WAAW,gBAAgB,eAAe,SAAS;AAC5D;;;;;;;;;;;;;AAcA,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM;EACzC,OAAO,MAAM;CACf,CAAC;CACD,IAAI,UAAmB;CACvB,KAAK,SAAS,QAAQ;EACpB,IAAI,WAAW,OAAO,YAAY,UAChC,UAAW,QAAoC;OAE/C,UAAU,KAAA;CAEd,CAAC;CACD,OAAO;AACT;;;;;;;;;;;AAmDA,MAAaA,yBAI4D;CACvE,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eACX,OAAO,WAEP,GAAG,iBACDC,eAA+D;CAEnE,MAAM,iBAAiB,WAAW,cAAc;;;;;;CAOhD,MAAM,cAAc,gBAAgB,WAAW;CAC/C,MAAM,UAAU,GAAG,SAAuC;EACxD,UAAU,GAAG,IAAI;EACjB,cAAc;CAChB;;;;;;;;;;CAWA,MAAM,iBACJ,MACA,WACsB;EACtB,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,SAAS,IAClD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,CAAC,GACtC,IACF;EAKA,OAAO;GACL,GAHiB,kBAAkB,MAAM,SAG7B;GACZ;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQ,aAAa,UAAU,IAAI;EACrC;CACF;;;;;;;;;;;;CAaA,MAAM,cAAc,GAAG,SAAgB;EACrC,MAAM,SAAU,cAAsB,GAAG,IAAI;EAC7C,OAAO,mBAAmB,MAAM;CAClC;CAEA,MAAM,UAAU,GAAG,SAAgB;EACjC,MAAM,SAAU,UAAkB,GAAG,IAAI;EACzC,OAAO,mBAAmB,MAAM;CAClC;CAEA,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;EAClB,IAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;GACjC,MAAM,iBAAiB;IACrB,GAAG;IACH,WAAW,uBAA4B;KAErC,MAAM,qBAAqB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQ,mBAAmB,mBAAmB,MAAM,EACtD;KACF;KAEA,OAAO,iBAAiB,kBAAkB;IAC5C;GACF;GACA,OAAO,cAAc,cAAc;EACrC;EAEA,OAAQ,cAAsB,GAAG,IAAI;CACvC;CAEA,OAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { useCallback } from "react";
2
- //#region src/hooks/useInputValueTransform/useInputValueTransform.ts
2
+ // src/hooks/useInputValueTransform/useInputValueTransform.ts
3
3
  /**
4
4
  * Custom hook providing utility functions for value transformations between display and form values.
5
5
  *
@@ -104,7 +104,6 @@ const useInputValueTransform = ({ type, transform }) => {
104
104
  }, [type, transform])
105
105
  };
106
106
  };
107
- //#endregion
108
107
  export { useInputValueTransform as t };
109
108
 
110
- //# sourceMappingURL=useInputValueTransform-Mw8YEOXT.mjs.map
109
+ //# sourceMappingURL=useInputValueTransform-CXWWFhy_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInputValueTransform-Mw8YEOXT.mjs","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform<TDisplay = unknown> {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\" or 'a' → ['a']) */\n toDisplayValue: (value: unknown) => TDisplay;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000 or ['a'] → 'a') */\n toFormValue: (value: TDisplay) => unknown;\n}\n\nexport interface UseInputValueTransformOptions<TDisplay = unknown> {\n /** Value transformation functions */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseInputValueTransformReturn<TDisplay = unknown> {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: unknown) => TDisplay;\n /** Converts any display value to form value */\n toFormValue: (displayValue: TDisplay) => unknown;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n * - Array/Object transformations (single value ↔ array, nested structures)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Generic support for any data type (strings, numbers, arrays, objects)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Array to single value (for single checkbox)\n * const singleValueTransform = {\n * toDisplayValue: (val: string[]) => val?.[0] || '',\n * toFormValue: (val: string) => val ? [val] : []\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: singleValueTransform\n * });\n *\n * const displayVal = toDisplayValue(['option1']); // \"option1\"\n * const formVal = toFormValue(\"option2\"); // [\"option2\"]\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = <TDisplay = unknown>({\n type,\n transform,\n}: UseInputValueTransformOptions<TDisplay>): UseInputValueTransformReturn<TDisplay> => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: unknown): TDisplay => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue);\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '' || formValue === null || formValue === undefined) {\n return '' as TDisplay;\n }\n const numValue = Number(formValue);\n return (Number.isNaN(numValue) ? formValue : numValue) as TDisplay;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return (formValue ?? '') as TDisplay;\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: TDisplay): unknown => {\n if (transform?.toFormValue) {\n return transform.toFormValue(displayValue);\n }\n\n // For number type, convert strings to numbers\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,MAAa,0BAA8C,EACzD,MACA,gBACqF;CAiDrF,OAAO;EACL,gBA9CqB,aACpB,cAAiC;GAChC,IAAI,WAAW,gBACb,OAAO,UAAU,eAAe,SAAS;GAI3C,IAAI,SAAS,UAAU;IACrB,IAAI,cAAc,MAAM,cAAc,QAAQ,cAAc,KAAA,GAC1D,OAAO;IAET,MAAM,WAAW,OAAO,SAAS;IACjC,OAAQ,OAAO,MAAM,QAAQ,IAAI,YAAY;GAC/C;GAGA,OAAQ,aAAa;EACvB,GACA,CAAC,MAAM,SAAS,CA4BH;EACb,aAvBkB,aACjB,iBAAoC;GACnC,IAAI,WAAW,aACb,OAAO,UAAU,YAAY,YAAY;GAI3C,IAAI,SAAS,UAAU;IACrB,IAAI,iBAAiB,IACnB,OAAO;IAET,MAAM,WAAW,OAAO,YAAY;IACpC,OAAO,OAAO,MAAM,QAAQ,IAAI,eAAe;GACjD;GAGA,OAAO;EACT,GACA,CAAC,MAAM,SAAS,CAKN;CACZ;AACF"}
1
+ {"version":3,"file":"useInputValueTransform-CXWWFhy_.mjs","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform<TDisplay = unknown> {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\" or 'a' → ['a']) */\n toDisplayValue: (value: unknown) => TDisplay;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000 or ['a'] → 'a') */\n toFormValue: (value: TDisplay) => unknown;\n}\n\nexport interface UseInputValueTransformOptions<TDisplay = unknown> {\n /** Value transformation functions */\n transform?: InputValueTransform<TDisplay>;\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n}\n\nexport interface UseInputValueTransformReturn<TDisplay = unknown> {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: unknown) => TDisplay;\n /** Converts any display value to form value */\n toFormValue: (displayValue: TDisplay) => unknown;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n * - Array/Object transformations (single value ↔ array, nested structures)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Generic support for any data type (strings, numbers, arrays, objects)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Array to single value (for single checkbox)\n * const singleValueTransform = {\n * toDisplayValue: (val: string[]) => val?.[0] || '',\n * toFormValue: (val: string) => val ? [val] : []\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: singleValueTransform\n * });\n *\n * const displayVal = toDisplayValue(['option1']); // \"option1\"\n * const formVal = toFormValue(\"option2\"); // [\"option2\"]\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = <TDisplay = unknown>({\n type,\n transform,\n}: UseInputValueTransformOptions<TDisplay>): UseInputValueTransformReturn<TDisplay> => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: unknown): TDisplay => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue);\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '' || formValue === null || formValue === undefined) {\n return '' as TDisplay;\n }\n const numValue = Number(formValue);\n return (Number.isNaN(numValue) ? formValue : numValue) as TDisplay;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return (formValue ?? '') as TDisplay;\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: TDisplay): unknown => {\n if (transform?.toFormValue) {\n return transform.toFormValue(displayValue);\n }\n\n // For number type, convert strings to numbers\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,MAAa,0BAA8C,EACzD,MACA,gBACqF;CAiDrF,OAAO;EACL,gBA9CqB,aACpB,cAAiC;GAChC,IAAI,WAAW,gBACb,OAAO,UAAU,eAAe,SAAS;GAI3C,IAAI,SAAS,UAAU;IACrB,IAAI,cAAc,MAAM,cAAc,QAAQ,cAAc,KAAA,GAC1D,OAAO;IAET,MAAM,WAAW,OAAO,SAAS;IACjC,OAAQ,OAAO,MAAM,QAAQ,IAAI,YAAY;GAC/C;GAGA,OAAQ,aAAa;EACvB,GACA,CAAC,MAAM,SAAS,CA4BH;EACb,aAvBkB,aACjB,iBAAoC;GACnC,IAAI,WAAW,aACb,OAAO,UAAU,YAAY,YAAY;GAI3C,IAAI,SAAS,UAAU;IACrB,IAAI,iBAAiB,IACnB,OAAO;IAET,MAAM,WAAW,OAAO,YAAY;IACpC,OAAO,OAAO,MAAM,QAAQ,IAAI,eAAe;GACjD;GAGA,OAAO;EACT,GACA,CAAC,MAAM,SAAS,CAKN;CACZ;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fuf-stack/uniform",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.3",
4
4
  "description": "fuf react form library",
5
5
  "author": "Fröhlich ∧ Frei",
6
6
  "homepage": "https://github.com/fuf-stack/pixels#readme",
@@ -12,6 +12,7 @@
12
12
  "./DatePicker": "./dist/DatePicker/index.mjs",
13
13
  "./FieldArray": "./dist/FieldArray/index.mjs",
14
14
  "./FieldCard": "./dist/FieldCard/index.mjs",
15
+ "./FieldReset": "./dist/FieldReset/index.mjs",
15
16
  "./Form": "./dist/Form/index.mjs",
16
17
  "./Grid": "./dist/Grid/index.mjs",
17
18
  "./helpers": "./dist/helpers/index.mjs",
@@ -68,13 +69,13 @@
68
69
  "@dnd-kit/utilities": "3.2.2",
69
70
  "@fuf-stack/pixel-motion": "2.0.0-next.1",
70
71
  "@fuf-stack/pixel-utils": "2.0.0-next.1",
71
- "@fuf-stack/pixels": "2.0.0-next.1",
72
- "@fuf-stack/veto": "2.0.0-next.1",
72
+ "@fuf-stack/pixels": "2.0.0-next.3",
73
+ "@fuf-stack/veto": "2.0.0-next.3",
73
74
  "@internationalized/date": "3.12.4",
74
75
  "debug": "4.4.3",
75
76
  "react-aria": "3.50.0",
76
77
  "react-aria-components": "1.19.0",
77
- "react-hook-form": "7.81.0",
78
+ "react-hook-form": "7.91.0",
78
79
  "react-icons": "5.7.0",
79
80
  "react-select": "5.10.2",
80
81
  "react-stately": "3.48.0",
@@ -84,8 +85,8 @@
84
85
  "@types/debug": "4.1.13",
85
86
  "@types/react": "19.3.0",
86
87
  "@types/react-dom": "19.3.0",
87
- "react": "19.3.0",
88
- "react-dom": "19.3.0"
88
+ "react": "19.3.1",
89
+ "react-dom": "19.3.1"
89
90
  },
90
- "gitHead": "ec69356cdafe4e2399405b7e5e1b970022bbbbc6"
91
+ "gitHead": "50d6df62dcc5bd2570bd129476cb4a5a36fc15ed"
91
92
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldDescription-C4l0HKGL.mjs","names":[],"sources":["../src/helpers/fieldProps/fieldProps.ts","../src/partials/FieldDescription/FieldDescription.tsx"],"sourcesContent":["import type { UniformField } from '../../hooks/useUniformField/types';\nimport type { FieldControlProps } from '../../partials/types';\n\ninterface FieldDataState {\n /** Disables interaction with the field */\n disabled?: boolean;\n /** Marks visible validation failure */\n invalid?: boolean;\n /** Marks a required field */\n required?: boolean;\n}\n\n/** Shared styling attributes for field state, inactive flags are omitted */\nexport const getFieldDataAttributes = ({\n disabled,\n invalid,\n required,\n}: FieldDataState) => {\n return {\n 'data-disabled': disabled ? true : undefined,\n 'data-invalid': invalid ? true : undefined,\n 'data-required': required ? true : undefined,\n };\n};\n\n/** Field metadata needed to associate an editable control with its content */\ntype FieldControlState = Pick<\n UniformField,\n | 'ariaLabel'\n | 'customAriaLabel'\n | 'description'\n | 'hasErrors'\n | 'hasLabel'\n | 'ids'\n | 'invalid'\n | 'required'\n>;\n\n/** ID and ARIA associations for the editable control or selection group */\nexport const getFieldControlProps = ({\n ariaLabel,\n customAriaLabel,\n description,\n hasErrors,\n hasLabel,\n ids,\n invalid,\n required,\n}: FieldControlState): FieldControlProps => {\n return {\n id: ids.control,\n 'aria-label': customAriaLabel ?? (!hasLabel ? ariaLabel : undefined),\n 'aria-labelledby': !customAriaLabel && hasLabel ? ids.label : undefined,\n 'aria-describedby':\n [\n description ? ids.description : undefined,\n invalid && hasErrors ? ids.error : undefined,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n 'aria-invalid': invalid || undefined,\n 'aria-required': required || undefined,\n };\n};\n","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"],"mappings":";;;AAaA,MAAa,0BAA0B,EACrC,UACA,SACA,eACoB;CACpB,OAAO;EACL,iBAAiB,WAAW,OAAO,KAAA;EACnC,gBAAgB,UAAU,OAAO,KAAA;EACjC,iBAAiB,WAAW,OAAO,KAAA;CACrC;AACF;;AAgBA,MAAa,wBAAwB,EACnC,WACA,iBACA,aACA,WACA,UACA,KACA,SACA,eAC0C;CAC1C,OAAO;EACL,IAAI,IAAI;EACR,cAAc,oBAAoB,CAAC,WAAW,YAAY,KAAA;EAC1D,mBAAmB,CAAC,mBAAmB,WAAW,IAAI,QAAQ,KAAA;EAC9D,oBACE,CACE,cAAc,IAAI,cAAc,KAAA,GAChC,WAAW,YAAY,IAAI,QAAQ,KAAA,CACrC,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,KAAK,KAAA;EAClB,gBAAgB,WAAW,KAAA;EAC3B,iBAAiB,YAAY,KAAA;CAC/B;AACF;;;;ACrDA,MAAM,oBAAoB,EAAE,UAAU,GAAG,YAAmC;CAC1E,IAAI,CAAC,UACH,OAAO;CAGT,OACE,oBAAC,OAAD;EAAK,aAAU;EAAc,GAAI;EAC9B;CACE,CAAA;AAET"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"FieldLabel-DKzqkuY1.mjs","names":["FieldCopyTestIdButton","FieldValidationError"],"sources":["../src/hooks/useUniformField/useUniformField.tsx","../src/partials/FieldLabel/FieldLabel.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\nimport type { UniformFieldState, UseUniformFieldParams } from './types';\n\nimport React from 'react';\n\nimport { useDebounce } from '@fuf-stack/pixels';\n\nimport { useSensitiveField } from '../../Form/subcomponents/SensitiveFields';\nimport { flattenFieldErrors, isValueEmpty } from '../../helpers';\nimport FieldCopyTestIdButton from '../../partials/FieldCopyTestIdButton';\nimport FieldValidationError from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInputValueTransform } from '../useInputValueTransform/useInputValueTransform';\n\n/**\n * Binds a form field's value, interactions, validation and label metadata\n *\n * Converts stored values for display and edited values back to form values\n * through `transform`, with automatic number conversion for numeric inputs\n *\n * Reveals validation errors after editing a nonempty value, blur or submission,\n * keeping pristine fields quiet. Debounces invalid-state changes to avoid\n * flickering during validation updates\n *\n * Returns a bound `field` with callbacks, a focus ref, rendered validation\n * messages and label content, including the test ID action in debug mode\n * Stable IDs and accessible-name metadata support associations in controls\n * Form operations remain separate from the field bundle\n */\nconst useUniformField = <\n TFieldValues extends FieldValues = FieldValues,\n TDisplay = unknown,\n>(\n params: UseUniformFieldParams<TFieldValues, TDisplay>,\n): UniformFieldState<TFieldValues, TDisplay> => {\n // field configuration\n const {\n name,\n ariaLabel: customAriaLabel,\n disabled = false,\n description,\n isArrayValue = false,\n testId: explicitTestId,\n label,\n placeholder,\n sensitive = false,\n type,\n transform,\n } = params;\n\n // revealing a password never changes its diagnostic redaction\n useSensitiveField(name, type === 'password' || sensitive);\n\n // stable associations between the control, label and messages\n const associationId = React.useId();\n const ids = {\n control: `uniform-${associationId}`,\n label: `uniform-${associationId}-label`,\n description: `uniform-${associationId}-description`,\n error: `uniform-${associationId}-error`,\n };\n\n // form operations and submission state\n const {\n control,\n debugMode,\n formState: { submitCount },\n formReset,\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n // validation and interaction state\n const {\n error: rawError,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n // register the field and connect its value and callbacks\n const { field: controllerField } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n\n const {\n onChange: fieldOnChange,\n value: fieldValue,\n disabled: isDisabled,\n onBlur,\n ref,\n } = controllerField;\n\n // convert between stored form values and displayed values\n const { toDisplayValue, toFormValue } = useInputValueTransform<TDisplay>({\n transform,\n type,\n });\n\n const transformedValue = toDisplayValue(fieldValue);\n const transformedOnChange = (eventOrValue: TDisplay | React.ChangeEvent) => {\n // accept native events as well as direct values\n const displayValue =\n (eventOrValue as React.ChangeEvent<HTMLInputElement>)?.target?.value ??\n eventOrValue;\n const formValue = toFormValue(displayValue as TDisplay);\n fieldOnChange(formValue);\n };\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n // show errors after editing a nonempty value, blur or submission\n const hasValue = !isValueEmpty(fieldValue);\n const showInvalid =\n rawInvalid && ((isDirty && hasValue) || isTouched || submitCount > 0);\n\n // allow validation messages to finish their exit animation\n const invalid = useDebounce(showInvalid, 200);\n\n // include the test ID action when debugging fields\n const showTestIdCopyButton = debugMode === 'debug-testids';\n const labelNode: ReactNode | null =\n !!label || showTestIdCopyButton ? (\n <>\n {label !== false ? label : null}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </>\n ) : null;\n\n // preserve nested errors for groups, flatten messages for rendering\n const error = isArrayValue ? flattenFieldErrors(rawError) : rawError;\n const normalizedError = flattenFieldErrors(rawError);\n const errorMessage = (\n <FieldValidationError error={normalizedError} testId={testId} />\n );\n\n // prefer a visible label, use placeholder text only when the field has no label\n const fallbackLabel = !label && placeholder?.trim() ? placeholder : name;\n const ariaLabel =\n customAriaLabel ??\n (label && typeof label === 'string' ? label : fallbackLabel);\n\n // collect the bound field without exposing controller internals\n const field = {\n ariaLabel,\n customAriaLabel,\n defaultValue,\n description,\n disabled: isDisabled,\n error,\n errorMessage,\n hasErrors: normalizedError.length > 0,\n hasLabel: !!label,\n ids,\n invalid,\n label: labelNode,\n name: controllerField.name,\n onBlur,\n onChange: transformedOnChange,\n ref,\n required,\n testId,\n value: transformedValue,\n };\n\n return {\n control,\n debugMode,\n field,\n formReset,\n getValues,\n resetField,\n };\n};\n\nexport default useUniformField;\n","import type { HTMLAttributes, ReactNode } from 'react';\nimport type { Label as AriaLabel } from 'react-aria-components';\n\ninterface 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,mBAIJ,WAC8C;CAE9C,MAAM,EACJ,MACA,WAAW,iBACX,WAAW,OACX,aACA,eAAe,OACf,QAAQ,gBACR,OACA,aACA,YAAY,OACZ,MACA,cACE;CAGJ,kBAAkB,MAAM,SAAS,cAAc,SAAS;CAGxD,MAAM,gBAAgB,MAAM,MAAM;CAClC,MAAM,MAAM;EACV,SAAS,WAAW;EACpB,OAAO,WAAW,cAAc;EAChC,aAAa,WAAW,cAAc;EACtC,OAAO,WAAW,cAAc;CAClC;CAGA,MAAM,EACJ,SACA,WACA,WAAW,EAAE,eACb,WACA,eACA,WACA,eACE,eAA6B;CAGjC,MAAM,EACJ,OAAO,UACP,SAAS,YACT,SACA,WACA,UACA,WACE,cAAc,MAAM,cAAc;CAGtC,MAAM,EAAE,OAAO,oBAAoB,cAA4B;EAC7D;EACA;EACA;CACF,CAAC;CAED,MAAM,EACJ,UAAU,eACV,OAAO,YACP,UAAU,YACV,QACA,QACE;CAGJ,MAAM,EAAE,gBAAgB,gBAAgB,uBAAiC;EACvE;EACA;CACF,CAAC;CAED,MAAM,mBAAmB,eAAe,UAAU;CAClD,MAAM,uBAAuB,iBAA+C;EAE1E,MAAM,eACH,cAAsD,QAAQ,SAC/D;EACF,MAAM,YAAY,YAAY,YAAwB;EACtD,cAAc,SAAS;CACzB;CAEA,MAAM,eAAgB,UAAU,CAAC,GAC/B;CAIF,MAAM,WAAW,CAAC,aAAa,UAAU;CAKzC,MAAM,UAAU,YAHd,eAAgB,WAAW,YAAa,aAAa,cAAc,IAG5B,GAAG;CAG5C,MAAM,uBAAuB,cAAc;CAC3C,MAAM,YACJ,CAAC,CAAC,SAAS,uBACT,qBAAA,UAAA,EAAA,UAAA,CACG,UAAU,QAAQ,QAAQ,MAC1B,uBACC,oBAACA,+BAAD,EAA+B,OAAS,CAAA,IACtC,IACJ,EAAA,CAAA,IACA;CAGN,MAAM,QAAQ,eAAe,mBAAmB,QAAQ,IAAI;CAC5D,MAAM,kBAAkB,mBAAmB,QAAQ;CACnD,MAAM,eACJ,oBAACC,8BAAD;EAAsB,OAAO;EAAyB;CAAS,CAAA;CAIjE,MAAM,gBAAgB,CAAC,SAAS,aAAa,KAAK,IAAI,cAAc;CA4BpE,OAAO;EACL;EACA;EACA,OAAA;GAxBA,WALA,oBACC,SAAS,OAAO,UAAU,WAAW,QAAQ;GAK9C;GACA;GACA;GACA,UAAU;GACV;GACA;GACA,WAAW,gBAAgB,SAAS;GACpC,UAAU,CAAC,CAAC;GACZ;GACA;GACA,OAAO;GACP,MAAM,gBAAgB;GACtB;GACA,UAAU;GACV;GACA;GACA;GACA,OAAO;EAMH;EACJ;EACA;EACA;CACF;AACF;;;;;;;;;;;;ACxJA,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,19 +0,0 @@
1
- import React, { ReactNode } from "react";
2
- import { FieldValues, Path, SubmitHandler } from "react-hook-form";
3
- import { VetoFormattedError, VetoInstance, VetoTypeAny } from "@fuf-stack/veto";
4
- //#region src/Form/subcomponents/FormContext.d.ts
5
- interface DebugModeSettings {
6
- /** disable form debug completely */
7
- disable?: boolean;
8
- /** custom localStorage key to save debug mode state */
9
- localStorageKey?: string;
10
- }
11
- /** Listener function that gets called when a form reset is triggered */
12
- type FormResetListener = () => void;
13
- /**
14
- * Listener function that gets called when a field changes due to user input
15
- */
16
- type UserChangeListener<TFieldValues extends object = object> = (fieldName: Path<TFieldValues>, value: unknown) => void;
17
- //#endregion
18
- export { FormResetListener as n, UserChangeListener as r, DebugModeSettings as t };
19
- //# sourceMappingURL=FormContext-CsFiNvuJ.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormContext-CsFiNvuJ.d.mts","names":[],"sources":["../src/Form/subcomponents/FormContext.tsx"],"mappings":";;;;UAgCiB;;EAEf;;EAEA;;;KAIU;;;;KAKA,mBAAmB,yCAC7B,WAAW,KAAK,eAChB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BS8IoBOn.d.mts","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"mappings":";UAEiB,oBAAoB;;EAEnC,iBAAiB,mBAAmB;;EAEpC,cAAc,OAAO;;UAGN,8BAA8B;;EAE7C,YAAY,oBAAoB;;EAEhC;;UAGe,6BAA6B;;EAE5C,iBAAiB,uBAAuB;;EAExC,cAAc,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqFjB,yBAA0B,sBAAoB,MAAA,aAGxD,8BAA8B,cAAY,6BAA6B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"radioControlVariants-Cm6WufWo.mjs","names":[],"sources":["../src/partials/RadioGroupField/RadioGroupDescriptionContext.ts","../src/partials/RadioGroupField/RadioGroupField.tsx","../src/partials/RadioGroupField/radioGroupFieldVariants.ts","../src/Radios/subcomponents/RadioControl.tsx","../src/Radios/subcomponents/radioControlVariants.ts"],"sourcesContent":["import { createContext } from 'react';\n\n/** Supporting message IDs inherited by each option */\nconst RadioGroupDescriptionContext = createContext<string | undefined>(\n undefined,\n);\n\nexport default RadioGroupDescriptionContext;\n","import type { ReactNode } from 'react';\nimport type { RadioGroupProps } from 'react-aria-components';\nimport type { FieldControlProps } from '../types';\n\nimport { useRef } from 'react';\nimport { RadioGroup } from 'react-aria-components';\n\nimport RadioGroupDescriptionContext from './RadioGroupDescriptionContext';\n\ninterface RadioGroupFieldProps {\n /** Group content, including its label and options */\n children: ReactNode;\n /** CSS class name */\n className?: string;\n /** Control ID, explicit accessible name and supporting message IDs */\n controlProps: Pick<\n FieldControlProps,\n 'id' | 'aria-label' | 'aria-describedby'\n >;\n /** Identifies the public component owning the radio group */\n dataComponent?: string;\n /** Disables every option */\n disabled?: boolean;\n /** Arranges options horizontally */\n inline: boolean;\n /** Connects form focus requests to the selected or first enabled option */\n inputRef: (control: Pick<HTMLElement, 'focus'> | null) => void;\n /** Marks visible validation failure */\n invalid: boolean;\n /** Field name */\n name: string;\n /** Callback when focus leaves the group */\n onBlur: () => void;\n /** Callback with the selected option's string value */\n onChange: (value: string) => void;\n /** Marks the group as required */\n required: boolean;\n /** HTML data-testid attribute */\n testId: string;\n /** Selected value, nullish values become an empty selection */\n value: unknown;\n}\n\n/**\n * React Aria radio-group engine with option focus routing and shared descriptions\n *\n * Receives bound values and callbacks, without registering a form field.\n * Its children own the field layout and option presentation.\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nconst RadioGroupField = ({\n children,\n className = undefined,\n controlProps,\n dataComponent = undefined,\n disabled = undefined,\n inputRef,\n invalid,\n inline,\n name,\n onBlur,\n onChange,\n required,\n testId,\n value,\n}: RadioGroupFieldProps) => {\n const groupRef = useRef<HTMLDivElement>(null);\n\n // focus the selected enabled option, otherwise the first enabled option\n const handleFocus = () => {\n const input =\n groupRef.current?.querySelector<HTMLInputElement>(\n 'input:checked:not(:disabled)',\n ) ??\n groupRef.current?.querySelector<HTMLInputElement>('input:not(:disabled)');\n input?.focus();\n };\n\n // expose option focus through the binding ref\n const setControlRef = (node: HTMLDivElement | null) => {\n groupRef.current = node;\n inputRef(node ? { focus: handleFocus } : null);\n };\n\n // preserve the group's existing state selectors on the actual root\n const renderGroup: NonNullable<RadioGroupProps['render']> = (props) => {\n return (\n <div {...props} data-invalid={invalid} data-required={required}>\n {props.children}\n </div>\n );\n };\n\n return (\n <RadioGroup\n ref={setControlRef}\n aria-describedby={controlProps['aria-describedby']}\n aria-label={controlProps['aria-label']}\n className={className}\n data-component={dataComponent}\n data-invalid={invalid}\n data-required={required}\n data-slot=\"base\"\n data-testid={testId}\n id={controlProps.id}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n orientation={inline ? 'horizontal' : 'vertical'}\n render={renderGroup}\n validationBehavior=\"aria\"\n value={value != null ? String(value) : ''}\n >\n <RadioGroupDescriptionContext.Provider\n value={controlProps['aria-describedby']}\n >\n {children}\n </RadioGroupDescriptionContext.Provider>\n </RadioGroup>\n );\n};\n\nexport default RadioGroupField;\n","import { tv } from '@fuf-stack/pixel-utils';\n\nconst radioGroupFieldVariants = tv({\n slots: {\n /** Container grouping the label, options and hints */\n base: 'relative',\n /** Supporting text below the options */\n description: 'text-foreground-400 text-tiny',\n /** Container for validation messages */\n errorMessage: '',\n /** Label above the options */\n label: 'relative',\n /** Container around the selectable options */\n wrapper: '',\n },\n});\n\nexport default radioGroupFieldVariants;\n","import type { ReactNode } from 'react';\nimport type { RadioButtonProps } from 'react-aria-components';\nimport type { RadioControlClassNames } from './radioControlVariants';\n\nimport { useContext, useId } from 'react';\nimport { RadioButton, RadioField } from 'react-aria-components';\n\nimport RadioGroupDescriptionContext from '../../partials/RadioGroupField/RadioGroupDescriptionContext';\n\ninterface RadioControlProps {\n /** Option label */\n children: ReactNode;\n /** CSS class name */\n className: RadioControlClassNames;\n /** Help text associated with the field */\n description?: ReactNode;\n /** Disables the field */\n disabled?: boolean;\n /** Decorative option icon */\n icon?: ReactNode;\n /** Marks visible validation failure */\n invalid: boolean;\n /** HTML data-testid attribute for e2e tests */\n testId?: string;\n /** String value managed by the containing group */\n value: string;\n}\n\n/**\n * React Aria radio option with an indicator, label and optional supporting text\n *\n * Inherits selection and disabled state from its RadioGroup, and supporting\n * message IDs from RadioGroupField when composed inside that engine.\n *\n * @see https://react-aria.adobe.com/RadioGroup\n */\nconst RadioControl = ({\n children,\n className: classNames,\n description = undefined,\n disabled = undefined,\n icon = undefined,\n invalid,\n testId = undefined,\n value,\n}: RadioControlProps) => {\n const id = useId();\n const groupDescription = useContext(RadioGroupDescriptionContext);\n\n const describedBy =\n [groupDescription, description ? `${id}-description` : undefined]\n .filter(Boolean)\n .join(' ') || undefined;\n\n const control = (\n <span aria-hidden className={classNames.wrapper} data-slot=\"wrapper\">\n <span className={classNames.control} data-slot=\"control\" />\n </span>\n );\n\n // preserve option state selectors on the visible label\n const renderOption: NonNullable<RadioButtonProps['render']> = (\n props,\n state,\n ) => {\n return (\n <label\n {...props}\n data-focus={state.isFocused || undefined}\n data-hover={state.isHovered || undefined}\n data-hover-unselected={\n (state.isHovered && !state.isSelected) || undefined\n }\n htmlFor={`${id}-control`}\n >\n {props.children}\n </label>\n );\n };\n\n return (\n <RadioField\n aria-describedby={describedBy}\n aria-labelledby={`${id}-label`}\n className={classNames.field}\n id={`${id}-control`}\n isDisabled={disabled}\n value={value}\n >\n <RadioButton\n className={classNames.base}\n data-invalid={invalid}\n data-slot=\"base\"\n data-testid={testId}\n render={renderOption}\n >\n {!icon ? control : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className={classNames.labelWrapper} data-slot=\"label-wrapper\">\n <span\n className={classNames.label}\n data-slot=\"label\"\n id={`${id}-label`}\n >\n {children}\n </span>\n {description ? (\n <div\n className={classNames.description}\n data-slot=\"description\"\n id={`${id}-description`}\n >\n {description}\n </div>\n ) : null}\n </div>\n {icon ? control : null}\n </RadioButton>\n </RadioField>\n );\n};\n\nexport default RadioControl;\n","import type { TVClassName } from '@fuf-stack/pixel-utils';\n\nimport { tv } from '@fuf-stack/pixel-utils';\n\nconst radioControlVariants = tv({\n slots: {\n /** Clickable option containing the indicator and label */\n base: [\n // option layout and pointer behavior\n 'group relative -m-2 inline-flex max-w-fit cursor-pointer select-none items-center justify-start p-2 tap-highlight-transparent',\n // disabled interaction and opacity\n 'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-disabled',\n ],\n /** Dot marking the selected option */\n control: [\n // selection dot appearance and animation\n 'z-10 h-2 w-2 origin-center scale-0 rounded-full bg-primary text-primary-foreground opacity-0 transition-transform-opacity',\n // selection and validation states\n 'group-data-[selected=true]:scale-100 group-data-[invalid=true]:bg-danger group-data-[invalid=true]:text-danger-foreground group-data-[selected=true]:opacity-100',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n /** Supporting text below the option label */\n description:\n 'relative text-foreground-400 transition-colors text-small motion-reduce:transition-none',\n /** Option state boundary without an additional layout box */\n field: 'contents',\n /** Container for a decorative option icon */\n icon: '',\n /** Primary option text */\n label:\n 'relative select-none text-foreground transition-colors text-medium motion-reduce:transition-none',\n /** Container grouping the option label and description */\n labelWrapper: 'ml-1 ms-2 flex flex-col',\n /** Circular outline around the selection indicator */\n wrapper: [\n // indicator dimensions and layout\n 'relative box-border inline-flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden',\n // circular border and transitions\n 'rounded-full border-2 border-solid border-default transition-transform-colors',\n // pressed, selected and invalid states\n 'group-data-[pressed=true]:scale-95 group-data-[invalid=true]:border-danger group-data-[invalid=true]:group-data-[selected=true]:border-danger group-data-[selected=true]:border-primary group-data-[hover-unselected=true]:bg-default-100',\n // keyboard focus ring\n 'group-data-[focus-visible=true]:ring-2 group-data-[focus-visible=true]:ring-focus group-data-[focus-visible=true]:ring-offset-2 group-data-[focus-visible=true]:ring-offset-background',\n // reduced motion\n 'motion-reduce:transition-none',\n ],\n },\n variants: {\n invalid: {\n true: {\n control: 'bg-danger text-danger-foreground',\n description: 'text-danger-300',\n label: 'text-danger',\n wrapper: 'border-danger group-data-[selected=true]:border-danger',\n },\n },\n },\n});\n\nexport type RadioControlClassNames = Partial<\n Record<keyof ReturnType<typeof radioControlVariants>, string>\n>;\n\nexport type ClassName = TVClassName<typeof radioControlVariants>;\n\nexport default radioControlVariants;\n"],"mappings":";;;;;;AAGA,MAAM,+BAA+B,cACnC,KAAA,CACF;;;;;;;;;;;AC8CA,MAAM,mBAAmB,EACvB,UACA,YAAY,KAAA,GACZ,cACA,gBAAgB,KAAA,GAChB,WAAW,KAAA,GACX,UACA,SACA,QACA,MACA,QACA,UACA,UACA,QACA,YAC0B;CAC1B,MAAM,WAAW,OAAuB,IAAI;CAG5C,MAAM,oBAAoB;EAMxB,CAJE,SAAS,SAAS,cAChB,8BACF,KACA,SAAS,SAAS,cAAgC,sBAAsB,EAAA,EACnE,MAAM;CACf;CAGA,MAAM,iBAAiB,SAAgC;EACrD,SAAS,UAAU;EACnB,SAAS,OAAO,EAAE,OAAO,YAAY,IAAI,IAAI;CAC/C;CAGA,MAAM,eAAuD,UAAU;EACrE,OACE,oBAAC,OAAD;GAAK,GAAI;GAAO,gBAAc;GAAS,iBAAe;GACnD,UAAA,MAAM;EACJ,CAAA;CAET;CAEA,OACE,oBAAC,YAAD;EACE,KAAK;EACL,oBAAkB,aAAa;EAC/B,cAAY,aAAa;EACd;EACX,kBAAgB;EAChB,gBAAc;EACd,iBAAe;EACf,aAAU;EACV,eAAa;EACb,IAAI,aAAa;EACjB,YAAY;EACZ,WAAW;EACX,YAAY;EACN;EACE;EACE;EACV,aAAa,SAAS,eAAe;EACrC,QAAQ;EACR,oBAAmB;EACnB,OAAO,SAAS,OAAO,OAAO,KAAK,IAAI;EAEvC,UAAA,oBAAC,6BAA6B,UAA9B;GACE,OAAO,aAAa;GAEnB;EACoC,CAAA;CAC7B,CAAA;AAEhB;;;AC1HA,MAAM,0BAA0B,GAAG,EACjC,OAAO;;CAEL,MAAM;;CAEN,aAAa;;CAEb,cAAc;;CAEd,OAAO;;CAEP,SAAS;AACX,EACF,CAAC;;;;;;;;;;;ACqBD,MAAM,gBAAgB,EACpB,UACA,WAAW,YACX,cAAc,KAAA,GACd,WAAW,KAAA,GACX,OAAO,KAAA,GACP,SACA,SAAS,KAAA,GACT,YACuB;CACvB,MAAM,KAAK,MAAM;CAGjB,MAAM,cACJ,CAHuB,WAAW,4BAGlB,GAAG,cAAc,GAAG,GAAG,gBAAgB,KAAA,CAAS,CAAC,CAC9D,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,KAAK,KAAA;CAElB,MAAM,UACJ,oBAAC,QAAD;EAAM,eAAA;EAAY,WAAW,WAAW;EAAS,aAAU;EACzD,UAAA,oBAAC,QAAD;GAAM,WAAW,WAAW;GAAS,aAAU;EAAW,CAAA;CACtD,CAAA;CAIR,MAAM,gBACJ,OACA,UACG;EACH,OACE,oBAAC,SAAD;GACE,GAAI;GACJ,cAAY,MAAM,aAAa,KAAA;GAC/B,cAAY,MAAM,aAAa,KAAA;GAC/B,yBACG,MAAM,aAAa,CAAC,MAAM,cAAe,KAAA;GAE5C,SAAS,GAAG,GAAG;GAEd,UAAA,MAAM;EACF,CAAA;CAEX;CAEA,OACE,oBAAC,YAAD;EACE,oBAAkB;EAClB,mBAAiB,GAAG,GAAG;EACvB,WAAW,WAAW;EACtB,IAAI,GAAG,GAAG;EACV,YAAY;EACL;EAEP,UAAA,qBAAC,aAAD;GACE,WAAW,WAAW;GACtB,gBAAc;GACd,aAAU;GACV,eAAa;GACb,QAAQ;GALV,UAAA;IAOG,CAAC,OAAO,UAAU;IAClB,OAAO,oBAAC,OAAD;KAAK,WAAW,WAAW;KAAO,UAAA;IAAU,CAAA,IAAI;IACxD,qBAAC,OAAD;KAAK,WAAW,WAAW;KAAc,aAAU;KAAnD,UAAA,CACE,oBAAC,QAAD;MACE,WAAW,WAAW;MACtB,aAAU;MACV,IAAI,GAAG,GAAG;MAET;KACG,CAAA,GACL,cACC,oBAAC,OAAD;MACE,WAAW,WAAW;MACtB,aAAU;MACV,IAAI,GAAG,GAAG;MAET,UAAA;KACE,CAAA,IACH,IACD;;IACJ,OAAO,UAAU;GACP;;CACH,CAAA;AAEhB;;;ACpHA,MAAM,uBAAuB,GAAG;CAC9B,OAAO;;EAEL,MAAM,CAEJ,iIAEA,gFACF;;EAEA,SAAS;GAEP;GAEA;GAEA;EACF;;EAEA,aACE;;EAEF,OAAO;;EAEP,MAAM;;EAEN,OACE;;EAEF,cAAc;;EAEd,SAAS;GAEP;GAEA;GAEA;GAEA;GAEA;EACF;CACF;CACA,UAAU,EACR,SAAS,EACP,MAAM;EACJ,SAAS;EACT,aAAa;EACb,OAAO;EACP,SAAS;CACX,EACF,EACF;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFormContext-BPjJjNnM.mjs","names":["useFormContext","useHookFormContext"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors;\n keys.forEach((key) => {\n if (current && typeof current === 'object') {\n current = (current as Record<string, unknown>)[key];\n } else {\n current = undefined;\n }\n });\n return current as FieldError[] | undefined;\n};\n\n/**\n * Custom hook that extends react-hook-form's useFormContext to add validation and state management.\n *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>() => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n reset: resetOrig,\n // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\n\n /**\n * Wrap react-hook-form's `reset` so the uniform context is notified about\n * programmatic resets. Field components (e.g. FieldArray) use this signal to\n * normalize their state on reset instead of inferring it from field contents.\n */\n const notifyReset = uniformContext?.formReset?.notify;\n const reset = ((...args: Parameters<typeof resetOrig>) => {\n resetOrig(...args);\n notifyReset?.();\n }) as typeof resetOrig;\n\n /**\n * Updated getFieldState method which returns:\n * - Whether the field is required by checking the validation schema\n * - Existing field state information (errors, etc.)\n * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n );\n\n // Get everything but the error from the original field state\n const fieldState = getFieldStateOrig(name, formState);\n\n return {\n ...fieldState,\n error,\n invalid: !!error,\n required,\n testId: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n reset,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;AAYA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAA,aAAsB,KAAK,MAAM,GAAG,EAAE,IAAI;CAE/D,MAAM,iBAAiB,WAAgB;EAErC,IAAI,OAAO,SAAS,SAAS;GAE3B,IAAI,OAAO,cAAc,OAAO,YAC9B,OAAO;GAGT,OAAO;EACT;EAIA,OAAO,CAAC,OAAO,cAAc,CAAC,OAAO;CACvC;CAEA,OAAO,WAAW,gBAAgB,eAAe,SAAS;AAC5D;;;;;;;;;;;;;AAcA,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,GAAG,CAAC,CAAC,QAAQ,MAAM;EACzC,OAAO,MAAM;CACf,CAAC;CACD,IAAI,UAAmB;CACvB,KAAK,SAAS,QAAQ;EACpB,IAAI,WAAW,OAAO,YAAY,UAChC,UAAW,QAAoC;OAE/C,UAAU,KAAA;CAEd,CAAC;CACD,OAAO;AACT;;;;;;;;;;;AAYA,MAAaA,yBAIN;CACL,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eACX,OAAO,WAEP,GAAG,iBACDC,eAA+D;CAEnE,MAAM,iBAAiB,WAAW,cAAc;;;;;;CAOhD,MAAM,cAAc,gBAAgB,WAAW;CAC/C,MAAM,UAAU,GAAG,SAAuC;EACxD,UAAU,GAAG,IAAI;EACjB,cAAc;CAChB;;;;;;;;;;CAWA,MAAM,iBAAiB,MAA0B,WAAoB;EACnE,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,EAAE,CAAC,CAAC,MAAM,GAAG,IAAI;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,SAAS,IAClD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,CAAC,GACtC,IACF;EAKA,OAAO;GACL,GAHiB,kBAAkB,MAAM,SAG7B;GACZ;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQ,aAAa,UAAU,IAAI;EACrC;CACF;;;;;;;;;;;;CAaA,MAAM,cAAc,GAAG,SAAgB;EACrC,MAAM,SAAU,cAAsB,GAAG,IAAI;EAC7C,OAAO,mBAAmB,MAAM;CAClC;CAEA,MAAM,UAAU,GAAG,SAAgB;EACjC,MAAM,SAAU,UAAkB,GAAG,IAAI;EACzC,OAAO,mBAAmB,MAAM;CAClC;CAEA,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;EAClB,IAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;GACjC,MAAM,iBAAiB;IACrB,GAAG;IACH,WAAW,uBAA4B;KAErC,MAAM,qBAAqB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQ,mBAAmB,mBAAmB,MAAM,EACtD;KACF;KAEA,OAAO,iBAAiB,kBAAkB;IAC5C;GACF;GACA,OAAO,cAAc,cAAc;EACrC;EAEA,OAAQ,cAAsB,GAAG,IAAI;CACvC;CAEA,OAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}