@fuf-stack/uniform 1.5.5 → 1.5.7

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 (90) hide show
  1. package/dist/Checkboxes/index.cjs +3 -3
  2. package/dist/Checkboxes/index.js +2 -2
  3. package/dist/FieldArray/index.cjs +3 -3
  4. package/dist/FieldArray/index.js +2 -2
  5. package/dist/Form/index.cjs +3 -3
  6. package/dist/Form/index.js +2 -2
  7. package/dist/Input/index.cjs +3 -3
  8. package/dist/Input/index.js +2 -2
  9. package/dist/RadioBoxes/index.cjs +3 -3
  10. package/dist/RadioBoxes/index.js +2 -2
  11. package/dist/RadioTabs/index.cjs +3 -3
  12. package/dist/RadioTabs/index.js +2 -2
  13. package/dist/Radios/index.cjs +3 -3
  14. package/dist/Radios/index.js +2 -2
  15. package/dist/Select/index.cjs +3 -3
  16. package/dist/Select/index.js +2 -2
  17. package/dist/SubmitButton/index.cjs +3 -3
  18. package/dist/SubmitButton/index.js +2 -2
  19. package/dist/Switch/index.cjs +3 -3
  20. package/dist/Switch/index.js +2 -2
  21. package/dist/TextArea/index.cjs +3 -3
  22. package/dist/TextArea/index.js +2 -2
  23. package/dist/{chunk-HFYNTR6H.js → chunk-2ZM4P4G3.js} +2 -2
  24. package/dist/{chunk-Y5Q5CGS3.js → chunk-33X26MSK.js} +3 -4
  25. package/dist/chunk-33X26MSK.js.map +1 -0
  26. package/dist/{chunk-HI677N7G.cjs → chunk-3UIFEC4R.cjs} +17 -17
  27. package/dist/chunk-3UIFEC4R.cjs.map +1 -0
  28. package/dist/{chunk-WVTLXBTO.js → chunk-47MZU3WD.js} +17 -17
  29. package/dist/{chunk-WVTLXBTO.js.map → chunk-47MZU3WD.js.map} +1 -1
  30. package/dist/{chunk-F5UPZGEY.cjs → chunk-4XTUP7W7.cjs} +5 -5
  31. package/dist/{chunk-F5UPZGEY.cjs.map → chunk-4XTUP7W7.cjs.map} +1 -1
  32. package/dist/{chunk-SUT7AMXT.js → chunk-7FTSMHFL.js} +2 -2
  33. package/dist/{chunk-KBWRXYOJ.cjs → chunk-A5MP4JAG.cjs} +4 -5
  34. package/dist/chunk-A5MP4JAG.cjs.map +1 -0
  35. package/dist/{chunk-ZQQUG4OK.js → chunk-B5OTVY3W.js} +4 -7
  36. package/dist/chunk-B5OTVY3W.js.map +1 -0
  37. package/dist/{chunk-263G4JAA.cjs → chunk-CSTA3NED.cjs} +7 -10
  38. package/dist/chunk-CSTA3NED.cjs.map +1 -0
  39. package/dist/{chunk-3GAELJ2V.js → chunk-DFDZFIQN.js} +2 -2
  40. package/dist/{chunk-3QUPBPC4.cjs → chunk-EALQ3KNW.cjs} +4 -5
  41. package/dist/chunk-EALQ3KNW.cjs.map +1 -0
  42. package/dist/{chunk-DIVVP6PT.cjs → chunk-GE2QRIOE.cjs} +3 -3
  43. package/dist/{chunk-DIVVP6PT.cjs.map → chunk-GE2QRIOE.cjs.map} +1 -1
  44. package/dist/{chunk-PE5GBKV4.cjs → chunk-JABO2635.cjs} +4 -4
  45. package/dist/{chunk-PE5GBKV4.cjs.map → chunk-JABO2635.cjs.map} +1 -1
  46. package/dist/{chunk-IONFOB6T.cjs → chunk-KORRVEJL.cjs} +4 -5
  47. package/dist/chunk-KORRVEJL.cjs.map +1 -0
  48. package/dist/{chunk-DSUSI47C.js → chunk-LEEWUHKX.js} +2 -2
  49. package/dist/{chunk-6FZ7EYJV.js → chunk-LKBR2JGT.js} +3 -4
  50. package/dist/chunk-LKBR2JGT.js.map +1 -0
  51. package/dist/{chunk-DBVFPFUE.cjs → chunk-MLAU2DYU.cjs} +4 -5
  52. package/dist/chunk-MLAU2DYU.cjs.map +1 -0
  53. package/dist/{chunk-XZUDH3I3.cjs → chunk-P7Z25LOZ.cjs} +3 -3
  54. package/dist/{chunk-XZUDH3I3.cjs.map → chunk-P7Z25LOZ.cjs.map} +1 -1
  55. package/dist/{chunk-D2JPS3GR.js → chunk-QIIMEQS3.js} +3 -4
  56. package/dist/chunk-QIIMEQS3.js.map +1 -0
  57. package/dist/{chunk-ZAHSRYDI.js → chunk-RBQP2VHW.js} +2 -2
  58. package/dist/{chunk-ASCGKJH2.js → chunk-TCJK6IYV.js} +3 -4
  59. package/dist/chunk-TCJK6IYV.js.map +1 -0
  60. package/dist/{chunk-S7WOLTWD.js → chunk-UB44OT6Q.js} +3 -4
  61. package/dist/chunk-UB44OT6Q.js.map +1 -0
  62. package/dist/{chunk-7WT4JCGS.cjs → chunk-UO52HWMC.cjs} +3 -3
  63. package/dist/{chunk-7WT4JCGS.cjs.map → chunk-UO52HWMC.cjs.map} +1 -1
  64. package/dist/{chunk-SMIIVASZ.cjs → chunk-X5WF3MEZ.cjs} +4 -5
  65. package/dist/chunk-X5WF3MEZ.cjs.map +1 -0
  66. package/dist/hooks/index.cjs +2 -2
  67. package/dist/hooks/index.d.cts +9 -19
  68. package/dist/hooks/index.d.ts +9 -19
  69. package/dist/hooks/index.js +1 -1
  70. package/dist/index.cjs +13 -13
  71. package/dist/index.js +12 -12
  72. package/package.json +1 -1
  73. package/dist/chunk-263G4JAA.cjs.map +0 -1
  74. package/dist/chunk-3QUPBPC4.cjs.map +0 -1
  75. package/dist/chunk-6FZ7EYJV.js.map +0 -1
  76. package/dist/chunk-ASCGKJH2.js.map +0 -1
  77. package/dist/chunk-D2JPS3GR.js.map +0 -1
  78. package/dist/chunk-DBVFPFUE.cjs.map +0 -1
  79. package/dist/chunk-HI677N7G.cjs.map +0 -1
  80. package/dist/chunk-IONFOB6T.cjs.map +0 -1
  81. package/dist/chunk-KBWRXYOJ.cjs.map +0 -1
  82. package/dist/chunk-S7WOLTWD.js.map +0 -1
  83. package/dist/chunk-SMIIVASZ.cjs.map +0 -1
  84. package/dist/chunk-Y5Q5CGS3.js.map +0 -1
  85. package/dist/chunk-ZQQUG4OK.js.map +0 -1
  86. /package/dist/{chunk-HFYNTR6H.js.map → chunk-2ZM4P4G3.js.map} +0 -0
  87. /package/dist/{chunk-SUT7AMXT.js.map → chunk-7FTSMHFL.js.map} +0 -0
  88. /package/dist/{chunk-3GAELJ2V.js.map → chunk-DFDZFIQN.js.map} +0 -0
  89. /package/dist/{chunk-DSUSI47C.js.map → chunk-LEEWUHKX.js.map} +0 -0
  90. /package/dist/{chunk-ZAHSRYDI.js.map → chunk-RBQP2VHW.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3UIFEC4R.cjs","../src/hooks/useClientValidation/useClientValidation.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx","../src/Form/subcomponents/FormResolver.ts","../src/hooks/useController/useController.ts","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useInput/useInput.ts"],"names":["useState","_a","useMemo","useRef","useEffect","jsx","useReducedMotion"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACjBA,4EAAiC;ADmBjC;AACA;AEnBA;AACA,gDAAqD;AAErD,oDAAwB;AFoBxB;AACA;AGrBA;AACA;AAEA,2CAAgC;AHsBhC;AACA;AI3BA;AAEA,uCAA0B;AAYnB,IAAM,2BAAA,EAA6B,CAAA,EAAA,GAAM;AAE9C,EAAA,MAAM,CAAC,uBAAA,EAAyB,0BAA0B,EAAA,EAAI,6BAAA,CAE3D,CAAC,CAAA;AAGJ,EAAA,MAAM,0BAAA,EAA4B,4BAAA,CAAQ,EAAA,GAAM;AAC9C,IAAA,OAAO,CAAC,GAAA,EAAa,MAAA,EAAA,GAA+B;AAElD,MAAA,0BAAA,CAA2B,CAAC,IAAA,EAAA,GAAS;AAEnC,QAAA,GAAA,CAAI,CAAC,IAAA,CAAK,GAAG,EAAA,GAAK,CAAC,MAAA,EAAQ;AACz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ACE,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,eAAA,EAAiB;AAInB,QAAA,GAAA,CAAI,CAAC,gBAAA,EAAkB;AACrB,UAAA,mBAAA,CAAoB,IAAI,CAAA;AAAA,QAC1B;AAIA,QAAA,QAAA,CAAS,IAAA,EAA4B,CAAC,mBAAmB,CAAA,EAAU;AAAA,UACjE,WAAA,EAAa,KAAA;AAAA,UACb,WAAA,EAAa;AAAA,QACf,CAAC,CAAA;AAGD,QAAA,cAAA,CAAe,QAAA,EAAU,IAAA;AAKzB,QAAA,GAAA,CAAI,CAAC,oBAAA,EAAsB;AACzB,UAAA,UAAA,CAAW,CAAA,EAAA,GAAM;AACf,YAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA,UAC3B,CAAA,EAAG,CAAC,CAAA;AAAA,QACN;AAAA,MACF;AAAA,IACF,CAAA;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,8CAAA;AAAA;AAAA,IAEL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;AN+WA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8WAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-3UIFEC4R.cjs","sourcesContent":[null,"/* eslint-disable import-x/prefer-default-export */\n\nimport type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount.\n *\n * When the client validation schema changes, automatically re-validates all touched\n * fields to ensure they are validated against the new schema.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data.\n *\n * @example\n * ```tsx\n * const { data: teamData } = useTeamQuery(teamId);\n *\n * useClientValidation(teamData, (data) =>\n * vt.object({\n * username: vt.string().refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * })\n * );\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Auto-generate unique key\n const key = useId();\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(async () => {\n return trigger(touchedFieldNames);\n }, 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n","/* 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 { slugify } from '@fuf-stack/pixel-utils';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, 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 as unknown;\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 */\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 // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\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 */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n const validationInstance = 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 ) as unknown as FieldError[] | undefined;\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: slugify(testId ?? name, { replaceDots: true }),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\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 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 subscribe,\n watch,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toValidationFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n *\n * IMPORTANT: Context Singleton Pattern for HMR (Hot Module Replacement)\n * =====================================================================\n *\n * We use a global window variable to ensure only ONE context instance exists across\n * hot module reloads during development. This is critical because:\n *\n * **The Problem:**\n * When using Vite/Storybook with Fast Refresh (HMR), editing this file causes it to\n * be re-evaluated. Each re-evaluation runs `React.createContext()` again, creating a\n * NEW context instance. This leads to \"context instance mismatch\":\n *\n * 1. FormProvider (provider) loads and uses context instance A\n * 2. File is edited, HMR triggers\n * 3. SubmitButton (consumer) hot-reloads and imports context instance B\n * 4. Provider writes to instance A, Consumer reads from instance B\n * 5. Result: Consumer sees default values (triggerSubmit = () => undefined)\n * 6. Clicking submit does nothing because it calls the empty default function\n *\n * **The Solution:**\n * By storing the context in `window.__UNIFORM_CONTEXT__`, we ensure:\n * - First load: Create context and store in window\n * - Subsequent HMRs: Reuse the same context from window\n * - All components always reference the SAME context instance\n * - Provider and consumers can properly communicate\n *\n * **Why This Is Safe:**\n * - Only affects development (production has no HMR)\n * - Context type never changes (same interface)\n * - React handles cleanup on unmount normally\n * - No memory leaks (context is lightweight)\n *\n * Without this pattern, you'd need to restart the dev server after every edit\n * to FormContext.tsx to ensure all components use the same context instance.\n */\n\n// Define the context type\ninterface UniformContextType {\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** Form validation configuration */\n validation: {\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nif (!(window as any).__UNIFORM_CONTEXT__) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).__UNIFORM_CONTEXT__ = React.createContext<UniformContextType>(\n {\n debugMode: 'off',\n preventSubmit: () => {\n return undefined;\n },\n setDebugMode: () => {\n return undefined;\n },\n triggerSubmit: () => {\n return undefined;\n },\n validation: {\n setClientValidationSchema: () => {\n return undefined;\n },\n },\n },\n );\n}\n\n// Export the singleton context instance from window\n// This ensures all imports get the same context, even after HMR\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const UniformContext = (window as any)\n .__UNIFORM_CONTEXT__ as React.Context<UniformContextType>;\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues ? toFormFormat(initialValues) : initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n // Convert nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(data) ?? {};\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n };\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => {\n return {\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n validation: {\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useMemo, useRef, useState } from 'react';\n\nimport { and, veto } from '@fuf-stack/veto';\n\nimport { toValidationFormat } from '../../helpers';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(() => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n }, []);\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n validationErrors.current = result.errors ?? undefined;\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\n };\n};\n","import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useController as useRHFController } from 'react-hook-form';\n\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 formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\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 *\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\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 // Preserve empty strings for required field validation\n // Only convert non-empty values to nullish strings\n field.onChange(value === '' ? '' : toNullishString(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","import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\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 } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\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 * - Animation control (disabled during initialization)\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 useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\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 // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\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 // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\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 // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\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 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\n\n/**\n * Debounce invalid state changes for smooth UI transitions while respecting accessibility.\n *\n * Behavior:\n * - Specifically intended for validation invalid flags: debounces both\n * true → false and false → true transitions by `delayMs` to prevent\n * flicker and allow enter/exit animations to complete.\n * - If the user prefers reduced motion (via `useReducedMotion` from\n * `@fuf-stack/pixel-motion`), updates apply immediately with no delay.\n */\nconst useDebouncedInvalid = (value: boolean, delayMs: number) => {\n const [state, setState] = useState(value);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const prefersReducedMotion = useReducedMotion();\n\n useEffect(() => {\n if (prefersReducedMotion) {\n // Respect reduced motion: apply immediately\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setState(value);\n return undefined;\n }\n\n // Debounce any change (true or false) by delayMs\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setState(value);\n timeoutRef.current = null;\n }, delayMs);\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n };\n }, [value, delayMs, prefersReducedMotion]);\n\n return state;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with nullish conversions applied */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with nullish handling) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport function useUniformField<TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldParams<TFieldValues>,\n): UseUniformFieldReturn<TFieldValues> {\n const { name, disabled = false, testId: explicitTestId, label } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const { onChange, disabled: isDisabled, onBlur, ref } = field;\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\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 // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return {\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange,\n ref,\n required,\n resetField,\n testId,\n };\n}\n\nexport default useUniformField;\n","/* eslint-disable import-x/prefer-default-export */\nexport { useInput } from '@heroui/input';\n"]}
@@ -404,13 +404,7 @@ var useDebouncedInvalid = (value, delayMs) => {
404
404
  };
405
405
  function useUniformField(params) {
406
406
  var _a;
407
- const {
408
- name,
409
- disabled = false,
410
- testId: explicitTestId,
411
- label,
412
- showInvalidWhen = "touched"
413
- } = params;
407
+ const { name, disabled = false, testId: explicitTestId, label } = params;
414
408
  const {
415
409
  control,
416
410
  debugMode,
@@ -422,15 +416,20 @@ function useUniformField(params) {
422
416
  const {
423
417
  error,
424
418
  invalid: rawInvalid,
419
+ isDirty,
425
420
  isTouched,
426
421
  required,
427
422
  testId
428
423
  } = getFieldState(name, explicitTestId);
429
- const { field } = useController({ control, disabled, name });
424
+ const { field } = useController({
425
+ control,
426
+ disabled,
427
+ name
428
+ });
430
429
  const { onChange, disabled: isDisabled, onBlur, ref } = field;
431
430
  const defaultValue = (_a = getValues()) == null ? void 0 : _a[name];
432
- const invalid = useDebouncedInvalid(rawInvalid, 200);
433
- const showInvalid = showInvalidWhen === "immediate" ? invalid || submitCount > 0 : invalid && (isTouched || submitCount > 0);
431
+ const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);
432
+ const invalid = useDebouncedInvalid(showInvalid, 200);
434
433
  const showTestIdCopyButton = debugMode === "debug-testids";
435
434
  const labelNode = !!label || showTestIdCopyButton ? /* @__PURE__ */ jsxs(Fragment, { children: [
436
435
  label !== false ? label : null,
@@ -461,7 +460,7 @@ function useUniformField(params) {
461
460
  getHelperWrapperProps,
462
461
  getLabelProps,
463
462
  getValues,
464
- invalid: showInvalid,
463
+ invalid,
465
464
  label: labelNode,
466
465
  onBlur,
467
466
  onChange,
@@ -480,15 +479,13 @@ var useUniformFieldArray = ({
480
479
  lastElementNotRemovable = false,
481
480
  disabled,
482
481
  testId: explicitTestId,
483
- label,
484
- showInvalidWhen = "immediate"
482
+ label
485
483
  }) => {
486
484
  const uniformField = useUniformField({
487
485
  name,
488
486
  disabled,
489
487
  testId: explicitTestId,
490
- label,
491
- showInvalidWhen
488
+ label
492
489
  });
493
490
  const { control } = uniformField;
494
491
  const { fields, append, remove, insert, move } = useRHFFieldArray({
@@ -526,7 +523,10 @@ var useUniformFieldArray = ({
526
523
  if (!disableAnimation) {
527
524
  setDisableAnimation(true);
528
525
  }
529
- setValue(name, [elementInitialValue]);
526
+ setValue(name, [elementInitialValue], {
527
+ shouldDirty: false,
528
+ shouldTouch: false
529
+ });
530
530
  hasInitialized.current = true;
531
531
  if (!prefersReducedMotion) {
532
532
  setTimeout(() => {
@@ -561,4 +561,4 @@ export {
561
561
  useUniformField,
562
562
  useUniformFieldArray
563
563
  };
564
- //# sourceMappingURL=chunk-WVTLXBTO.js.map
564
+ //# sourceMappingURL=chunk-47MZU3WD.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/hooks/useClientValidation/useClientValidation.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx","../src/Form/subcomponents/FormResolver.ts","../src/hooks/useController/useController.ts","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useInput/useInput.ts"],"sourcesContent":["/* eslint-disable import-x/prefer-default-export */\n\nimport type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount.\n *\n * When the client validation schema changes, automatically re-validates all touched\n * fields to ensure they are validated against the new schema.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data.\n *\n * @example\n * ```tsx\n * const { data: teamData } = useTeamQuery(teamId);\n *\n * useClientValidation(teamData, (data) =>\n * vt.object({\n * username: vt.string().refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * })\n * );\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Auto-generate unique key\n const key = useId();\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(async () => {\n return trigger(touchedFieldNames);\n }, 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n","/* 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 { slugify } from '@fuf-stack/pixel-utils';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, 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 as unknown;\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 */\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 // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\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 */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n const validationInstance = 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 ) as unknown as FieldError[] | undefined;\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: slugify(testId ?? name, { replaceDots: true }),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\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 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 subscribe,\n watch,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toValidationFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n *\n * IMPORTANT: Context Singleton Pattern for HMR (Hot Module Replacement)\n * =====================================================================\n *\n * We use a global window variable to ensure only ONE context instance exists across\n * hot module reloads during development. This is critical because:\n *\n * **The Problem:**\n * When using Vite/Storybook with Fast Refresh (HMR), editing this file causes it to\n * be re-evaluated. Each re-evaluation runs `React.createContext()` again, creating a\n * NEW context instance. This leads to \"context instance mismatch\":\n *\n * 1. FormProvider (provider) loads and uses context instance A\n * 2. File is edited, HMR triggers\n * 3. SubmitButton (consumer) hot-reloads and imports context instance B\n * 4. Provider writes to instance A, Consumer reads from instance B\n * 5. Result: Consumer sees default values (triggerSubmit = () => undefined)\n * 6. Clicking submit does nothing because it calls the empty default function\n *\n * **The Solution:**\n * By storing the context in `window.__UNIFORM_CONTEXT__`, we ensure:\n * - First load: Create context and store in window\n * - Subsequent HMRs: Reuse the same context from window\n * - All components always reference the SAME context instance\n * - Provider and consumers can properly communicate\n *\n * **Why This Is Safe:**\n * - Only affects development (production has no HMR)\n * - Context type never changes (same interface)\n * - React handles cleanup on unmount normally\n * - No memory leaks (context is lightweight)\n *\n * Without this pattern, you'd need to restart the dev server after every edit\n * to FormContext.tsx to ensure all components use the same context instance.\n */\n\n// Define the context type\ninterface UniformContextType {\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** Form validation configuration */\n validation: {\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nif (!(window as any).__UNIFORM_CONTEXT__) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).__UNIFORM_CONTEXT__ = React.createContext<UniformContextType>(\n {\n debugMode: 'off',\n preventSubmit: () => {\n return undefined;\n },\n setDebugMode: () => {\n return undefined;\n },\n triggerSubmit: () => {\n return undefined;\n },\n validation: {\n setClientValidationSchema: () => {\n return undefined;\n },\n },\n },\n );\n}\n\n// Export the singleton context instance from window\n// This ensures all imports get the same context, even after HMR\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const UniformContext = (window as any)\n .__UNIFORM_CONTEXT__ as React.Context<UniformContextType>;\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues ? toFormFormat(initialValues) : initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n // Convert nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(data) ?? {};\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n };\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => {\n return {\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n validation: {\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useMemo, useRef, useState } from 'react';\n\nimport { and, veto } from '@fuf-stack/veto';\n\nimport { toValidationFormat } from '../../helpers';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(() => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n }, []);\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n validationErrors.current = result.errors ?? undefined;\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\n };\n};\n","import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useController as useRHFController } from 'react-hook-form';\n\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 formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\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 *\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\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 // Preserve empty strings for required field validation\n // Only convert non-empty values to nullish strings\n field.onChange(value === '' ? '' : toNullishString(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","import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\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 } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n /**\n * When to show the invalid state to users.\n * - 'touched': Only show errors after field is touched or form is submitted (default, good for text inputs)\n * - 'immediate': Show errors as soon as they occur (good for checkboxes, radios, arrays)\n */\n showInvalidWhen?: 'touched' | 'immediate';\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 * - Animation control (disabled during initialization)\n * - Automatic validation triggering\n * - Support for flat arrays (arrays of primitives)\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n showInvalidWhen = 'immediate',\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n showInvalidWhen,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\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 // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\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 // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\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 // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\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\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\n\n/**\n * Debounce invalid state changes for smooth UI transitions while respecting accessibility.\n *\n * Behavior:\n * - Specifically intended for validation invalid flags: debounces both\n * true → false and false → true transitions by `delayMs` to prevent\n * flicker and allow enter/exit animations to complete.\n * - If the user prefers reduced motion (via `useReducedMotion` from\n * `@fuf-stack/pixel-motion`), updates apply immediately with no delay.\n */\nconst useDebouncedInvalid = (value: boolean, delayMs: number) => {\n const [state, setState] = useState(value);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const prefersReducedMotion = useReducedMotion();\n\n useEffect(() => {\n if (prefersReducedMotion) {\n // Respect reduced motion: apply immediately\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setState(value);\n return undefined;\n }\n\n // Debounce any change (true or false) by delayMs\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setState(value);\n timeoutRef.current = null;\n }, delayMs);\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n };\n }, [value, delayMs, prefersReducedMotion]);\n\n return state;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n /**\n * When to show the invalid state to users.\n * - 'touched': Only show errors after field is touched or form is submitted (default, good for text inputs)\n * - 'immediate': Show errors as soon as they occur (good for checkboxes, radios, arrays)\n */\n showInvalidWhen?: 'touched' | 'immediate';\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with nullish conversions applied */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field is invalid (debounced for smoother exit animations) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with nullish handling) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`), configurable via `showInvalidWhen`:\n * • 'touched' (default): Shows errors only after field touched OR form submitted\n * • 'immediate': Shows errors as soon as validation fails (for checkboxes/radios/arrays)\n * • Prevents showing errors on pristine fields for better UX\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport function useUniformField<TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldParams<TFieldValues>,\n): UseUniformFieldReturn<TFieldValues> {\n const {\n name,\n disabled = false,\n testId: explicitTestId,\n label,\n showInvalidWhen = 'touched',\n } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({ control, disabled, name });\n const { onChange, disabled: isDisabled, onBlur, ref } = field;\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n // Debounce invalid changes so validation does not flicker and\n // components can play exit animations\n const invalid = useDebouncedInvalid(rawInvalid, 200);\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Behavior depends on `showInvalidWhen` parameter:\n *\n * 'touched' mode (default for text inputs):\n * - Only show invalid when: field has errors AND (touched OR form submitted)\n * - Prevents showing errors on pristine fields for better UX\n * - Example: User loads form with empty required field → no error shown yet\n *\n * 'immediate' mode (for checkboxes, radios, arrays):\n * - Show invalid as soon as validation fails OR after form submission\n * - Good for components where user sees immediate feedback per interaction\n * - Example: Checkbox group with \"select at least 2\" → error shows immediately\n */\n const showInvalid =\n showInvalidWhen === 'immediate'\n ? invalid || submitCount > 0\n : invalid && (isTouched || submitCount > 0);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\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 // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return {\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid: showInvalid,\n label: labelNode,\n onBlur,\n onChange,\n ref,\n required,\n resetField,\n testId,\n };\n}\n\nexport default useUniformField;\n","/* eslint-disable import-x/prefer-default-export */\nexport { useInput } from '@heroui/input';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,WAAW,aAAa;;;ACCjC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;AAErD,SAAS,eAAe;;;ACAxB,OAAO,SAAS,WAAAA,UAAS,YAAAC,iBAAgB;AACzC,SAAS,gBAAgB,kBAAkB,eAAe;AAE1D,SAAS,uBAAuB;;;ACJhC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,SAAS,KAAK,YAAY;AAYnB,IAAM,6BAA6B,MAAM;AAE9C,QAAM,CAAC,yBAAyB,0BAA0B,IAAI,SAE5D,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AA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEG;AAEP;","names":["useMemo","useState","useState","_a","useMemo","_a","useEffect","useMemo","useRef","useState","useReducedMotion","useEffect","useRef","useState","jsx","useState","useRef","useEffect","useRef","useEffect","useState","useReducedMotion","useMemo"]}
1
+ {"version":3,"sources":["../src/hooks/useClientValidation/useClientValidation.ts","../src/hooks/useFormContext/useFormContext.ts","../src/Form/subcomponents/FormContext.tsx","../src/Form/subcomponents/FormResolver.ts","../src/hooks/useController/useController.ts","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts","../src/hooks/useUniformField/useUniformField.tsx","../src/hooks/useInput/useInput.ts"],"sourcesContent":["/* eslint-disable import-x/prefer-default-export */\n\nimport type { VetoTypeAny } from '@fuf-stack/veto';\n\nimport { useEffect, useId } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\n/**\n * Hook for adding dynamic client-side validation to forms.\n *\n * Automatically manages validation schema lifecycle: sets schema when data is provided,\n * clears schema when data is null/undefined, and cleans up on unmount.\n *\n * When the client validation schema changes, automatically re-validates all touched\n * fields to ensure they are validated against the new schema.\n *\n * @param data - Data to create validation schema from (or null/undefined to clear validation)\n * @param schemaFactory - Function that creates a validation schema from the data.\n *\n * @example\n * ```tsx\n * const { data: teamData } = useTeamQuery(teamId);\n *\n * useClientValidation(teamData, (data) =>\n * vt.object({\n * username: vt.string().refine(\n * (value) => !data.existingUsers.includes(value),\n * { message: 'Username already exists' }\n * )\n * })\n * );\n * ```\n */\nexport const useClientValidation = <TData = unknown>(\n data: TData | null | undefined,\n schemaFactory: (data: TData) => VetoTypeAny,\n): void => {\n const {\n formState: { touchedFields },\n validation: { setClientValidationSchema },\n trigger,\n } = useFormContext();\n\n // Auto-generate unique key\n const key = useId();\n\n // Use data hash instead of object reference to avoid unnecessary re-runs\n // when data object reference changes but data remains the same\n const dataHash = JSON.stringify(data);\n\n // Single effect to manage validation schema lifecycle\n useEffect(() => {\n // Set validation schema when data is available\n if (data != null) {\n const validationSchema = schemaFactory(data);\n setClientValidationSchema(key, validationSchema);\n } else {\n // Clear validation schema when no data\n setClientValidationSchema(key, null);\n }\n\n // Re-validate all touched fields when client validation schema changes\n const touchedFieldNames = Object.keys(touchedFields);\n if (touchedFieldNames.length > 0) {\n // Use setTimeout to ensure the client validation schema update has propagated\n // before triggering re-validation (fixes race condition)\n setTimeout(async () => {\n return trigger(touchedFieldNames);\n }, 1);\n }\n\n // Cleanup on unmount or when dependencies change\n return () => {\n setClientValidationSchema(key, null);\n };\n // Only re-run when data (dataHash) or key changes\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [dataHash, key]);\n};\n","/* 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 { slugify } from '@fuf-stack/pixel-utils';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, 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 as unknown;\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 */\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 // the rest of the methods pass through unchanged\n ...otherMethods\n } = useHookFormContext<TFieldValues, TContext, TTransformedValues>();\n\n const uniformContext = useContext(UniformContext);\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 */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n const validationInstance = 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 ) as unknown as FieldError[] | undefined;\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: slugify(testId ?? name, { replaceDots: true }),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\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 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 subscribe,\n watch,\n };\n};\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { BaseSyntheticEvent, ReactNode } from 'react';\nimport type { FieldValues, SubmitHandler } from 'react-hook-form';\n\nimport React, { useMemo, useState } from 'react';\nimport { FormProvider as HookFormProvider, useForm } from 'react-hook-form';\n\nimport { useLocalStorage } from '@fuf-stack/pixels';\n\nimport { toFormFormat, toValidationFormat } from '../../helpers';\nimport { useExtendedValidation, useFormResolver } from './FormResolver';\n\ntype DebugMode = 'debug' | 'debug-testids' | 'off' | 'disabled';\n\nexport interface DebugModeSettings {\n /** disable form debug completely */\n disable?: boolean;\n /** custom localStorage key to save debug mode state */\n localStorageKey?: string;\n}\n\nconst DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT = 'uniform:debug-mode';\n\n/**\n * The `UniformContext` provides control over the form's submission behavior and may optionally include\n * a Veto validation schema for form validation.\n *\n * Specifically, this context offers:\n * 1. **Form Submission Control**: The `preventSubmit` function allows components to enable or disable\n * form submissions.\n * 2. **Optional Validation Schema**: The `validation` property may hold a Veto validation schema instance\n * that can be used to validate form fields and handle validation logic.\n * 3. **Client Validation**: The `setClientValidationSchema` function allows setting dynamic client-side\n * validation schemas that complement the base Veto validation.\n *\n * This context is useful for components that need to interact with or control the form submission state,\n * or access the validation schema for managing form validation logic.\n *\n * IMPORTANT: Context Singleton Pattern for HMR (Hot Module Replacement)\n * =====================================================================\n *\n * We use a global window variable to ensure only ONE context instance exists across\n * hot module reloads during development. This is critical because:\n *\n * **The Problem:**\n * When using Vite/Storybook with Fast Refresh (HMR), editing this file causes it to\n * be re-evaluated. Each re-evaluation runs `React.createContext()` again, creating a\n * NEW context instance. This leads to \"context instance mismatch\":\n *\n * 1. FormProvider (provider) loads and uses context instance A\n * 2. File is edited, HMR triggers\n * 3. SubmitButton (consumer) hot-reloads and imports context instance B\n * 4. Provider writes to instance A, Consumer reads from instance B\n * 5. Result: Consumer sees default values (triggerSubmit = () => undefined)\n * 6. Clicking submit does nothing because it calls the empty default function\n *\n * **The Solution:**\n * By storing the context in `window.__UNIFORM_CONTEXT__`, we ensure:\n * - First load: Create context and store in window\n * - Subsequent HMRs: Reuse the same context from window\n * - All components always reference the SAME context instance\n * - Provider and consumers can properly communicate\n *\n * **Why This Is Safe:**\n * - Only affects development (production has no HMR)\n * - Context type never changes (same interface)\n * - React handles cleanup on unmount normally\n * - No memory leaks (context is lightweight)\n *\n * Without this pattern, you'd need to restart the dev server after every edit\n * to FormContext.tsx to ensure all components use the same context instance.\n */\n\n// Define the context type\ninterface UniformContextType {\n /** Form debug mode enabled or not */\n debugMode: DebugMode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** Function to update if the form can currently be submitted */\n preventSubmit: (prevent: boolean) => void;\n /** Setter to enable or disable form debug mode */\n setDebugMode: (debugMode: DebugMode) => void;\n /** Function to trigger form submit programmatically */\n triggerSubmit: (e?: BaseSyntheticEvent) => Promise<void> | void;\n /** Form validation configuration */\n validation: {\n /** Veto validation schema instance for form validation */\n instance?: VetoInstance;\n /** Current validation errors in form */\n errors?: VetoFormattedError;\n /** Function to set client validation schema for a specific key */\n setClientValidationSchema: (\n key: string,\n schema: VetoTypeAny | null,\n ) => void;\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nif (!(window as any).__UNIFORM_CONTEXT__) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (window as any).__UNIFORM_CONTEXT__ = React.createContext<UniformContextType>(\n {\n debugMode: 'off',\n preventSubmit: () => {\n return undefined;\n },\n setDebugMode: () => {\n return undefined;\n },\n triggerSubmit: () => {\n return undefined;\n },\n validation: {\n setClientValidationSchema: () => {\n return undefined;\n },\n },\n },\n );\n}\n\n// Export the singleton context instance from window\n// This ensures all imports get the same context, even after HMR\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const UniformContext = (window as any)\n .__UNIFORM_CONTEXT__ as React.Context<UniformContextType>;\n\n// Define props for the FormProvider component, extending HookForm's props\ninterface FormProviderProps {\n /** children form render function */\n children: (childProps: {\n handleSubmit: (e?: BaseSyntheticEvent) => Promise<void>;\n isValid: boolean;\n }) => ReactNode;\n /** settings for from debug mode */\n debugModeSettings?: DebugModeSettings;\n /** initial form values */\n initialValues?: FieldValues;\n /** form submit handler */\n onSubmit: SubmitHandler<FieldValues>;\n /** Veto validation schema instance */\n validation?: VetoInstance;\n /** when the validation should be triggered */\n validationTrigger: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';\n}\n\n/**\n * FormProvider component provides:\n * - Veto validation schema context\n * - Client validation schema management\n * - Submit handler with automatic data conversion and submission control with preventSubmit\n * - Form Debug Mode state\n * - React Hook Form context\n */\nconst FormProvider: React.FC<FormProviderProps> = ({\n children,\n debugModeSettings = undefined,\n initialValues = undefined,\n onSubmit,\n validation: baseValidation = undefined,\n validationTrigger,\n}) => {\n // Form Debug mode state is handled in the form context\n const [debugMode, setDebugMode] = useLocalStorage<DebugMode>(\n debugModeSettings?.localStorageKey ?? DEBUG_MODE_LOCAL_STORAGE_KEY_DEFAULT,\n 'off',\n );\n\n // Create extended validation combining base + client validations\n const { extendedValidation, setClientValidationSchema } =\n useExtendedValidation(baseValidation);\n\n // Create resolver from extended validation + get current validation errors\n const { resolver, validationErrors, validationErrorsHash } =\n useFormResolver(extendedValidation);\n\n // Initialize react hook form with the resolver\n const methods = useForm({\n defaultValues: initialValues ? toFormFormat(initialValues) : initialValues,\n // set rhf mode\n // see: https://react-hook-form.com/docs/useform#mode\n mode: validationTrigger,\n resolver,\n });\n\n // Get isValid from React Hook Form's formState\n const isValid = methods.formState?.isValid;\n\n // Control if the form can currently be submitted\n const [preventSubmit, setPreventSubmit] = useState(false);\n\n // Create submit handler with automatic data conversion\n // eslint-disable-next-line consistent-return\n const handleSubmit = async (e?: React.BaseSyntheticEvent) => {\n // only prevent submit when form state is valid, because otherwise\n // submit will only trigger validation and add errors / focus invalid fields\n if (methods.formState.isValid && preventSubmit) {\n console.warn(\n '[FormProvider] form submit was prevented because preventSubmit is true...',\n );\n e?.preventDefault();\n return Promise.resolve();\n }\n\n // Convert nullish strings and filter out empty values before submission\n const wrappedOnSubmit = (data: FieldValues, event?: BaseSyntheticEvent) => {\n const submitData = toValidationFormat(data) ?? {};\n return onSubmit(submitData, event);\n };\n\n await methods.handleSubmit(wrappedOnSubmit)(e);\n };\n\n // Memoize the context value to prevent re-renders\n const contextValue = useMemo(\n () => {\n return {\n // set debugMode to disabled when debugModeSettings.disable is true\n // otherwise use current debug mode from localStorage\n debugMode: debugModeSettings?.disable ? 'disabled' : debugMode,\n preventSubmit: (prevent: boolean) => {\n setPreventSubmit(prevent);\n },\n setClientValidationSchema,\n setDebugMode,\n triggerSubmit: handleSubmit,\n validation: {\n instance: extendedValidation,\n errors: validationErrors,\n setClientValidationSchema,\n },\n };\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [debugMode, debugModeSettings?.disable, validationErrorsHash],\n );\n\n return (\n <UniformContext.Provider value={contextValue}>\n {/* Spread all hook form props into HookFormProvider */}\n <HookFormProvider {...methods}>\n {children({ handleSubmit, isValid })}\n </HookFormProvider>\n </UniformContext.Provider>\n );\n};\n\nexport default FormProvider;\n","import type {\n VetoFormattedError,\n VetoInstance,\n VetoTypeAny,\n} from '@fuf-stack/veto';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { useMemo, useRef, useState } from 'react';\n\nimport { and, veto } from '@fuf-stack/veto';\n\nimport { toValidationFormat } from '../../helpers';\n\n/**\n * Hook that manages client validation schemas state.\n *\n * Provides a centralized way to add/remove dynamic validation schemas\n * that can be combined with base form validation.\n *\n * @returns Object with client validation state and memoized setter function\n */\nexport const useClientValidationManager = () => {\n // Client validation schemas state\n const [clientValidationSchemas, setClientValidationSchemas] = useState<\n Record<string, VetoTypeAny>\n >({});\n\n // Memoized function to set/clear client validation schema\n const setClientValidationSchema = useMemo(() => {\n return (key: string, schema: VetoTypeAny | null) => {\n // update client validation schemas\n setClientValidationSchemas((prev) => {\n // if no schema and no existing client validation schema for this key, do nothing\n if (!prev[key] && !schema) {\n return prev;\n }\n // if no schema, remove the client validation schema for this key\n if (!schema) {\n const { [key]: _removed, ...rest } = prev;\n return rest;\n }\n // if schema, add or update the client validation schema for this key\n return { ...prev, [key]: schema };\n });\n };\n }, []);\n\n return {\n clientValidationSchemas,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates an extended validation instance combining base Veto validation with dynamic client validation.\n *\n * @param baseValidation - Optional base Veto validation schema\n * @returns Combined validation instance and client schema setter\n */\nexport const useExtendedValidation = (baseValidation?: VetoInstance) => {\n // Setup client validation schemas\n const { clientValidationSchemas, setClientValidationSchema } =\n useClientValidationManager();\n\n // Create a stable dependency array from the client validation schemas\n const clientSchemaValues = useMemo(\n () => {\n const keys = Object.keys(clientValidationSchemas).sort();\n return keys\n .map((key) => {\n return clientValidationSchemas[key];\n })\n .filter(Boolean);\n },\n // Include the object identity to react to schema instance updates with same shape\n [clientValidationSchemas],\n );\n\n // Memoized extended validation instance\n const extendedValidation = useMemo(\n () => {\n const hasBaseValidation = !!baseValidation;\n const hasClientSchemas = clientSchemaValues.length > 0;\n\n // If no base validation and no client schemas, return undefined\n if (!hasBaseValidation && !hasClientSchemas) {\n return undefined;\n }\n\n // If no client schemas, return base validation\n if (!hasClientSchemas) {\n return baseValidation;\n }\n\n // Combine client validation schemas\n const clientSchemasCombined = clientSchemaValues.reduce(\n // @ts-expect-error is ok, because initially it is null\n (combined, clientSchema) => {\n return combined ? and(combined, clientSchema) : clientSchema;\n },\n null,\n );\n\n // return combined validation\n if (hasBaseValidation && clientSchemasCombined) {\n return veto(and(baseValidation.schema, clientSchemasCombined));\n }\n\n // If we only have client schemas, return them as a veto instance\n if (clientSchemasCombined) {\n return veto(clientSchemasCombined);\n }\n\n // This should not happen due to the conditions above, but just in case\n return baseValidation;\n },\n // Recompute when validation schema instances change\n [baseValidation, clientSchemaValues],\n );\n\n return {\n extendedValidation,\n setClientValidationSchema,\n };\n};\n\n/**\n * Hook that creates a React Hook Form resolver from an extended validation instance.\n *\n * @param extendedValidation - Extended validation instance from useExtendedValidation\n * @returns Object containing resolver function, current validation errors, and optimization hash\n */\nexport const useFormResolver = (extendedValidation?: VetoInstance) => {\n // Use ref to store validation errors without triggering re-renders\n const validationErrors = useRef<VetoFormattedError>(undefined);\n\n // Memoized resolver function for React Hook Form\n const resolver = useMemo(() => {\n if (!extendedValidation) {\n return undefined;\n }\n\n return async (values: FieldValues) => {\n const validationValues = toValidationFormat(values) ?? {};\n const result = await extendedValidation.validateAsync(validationValues);\n validationErrors.current = result.errors ?? undefined;\n\n // Transform veto result to React Hook Form format\n return {\n values: result.data ?? {},\n errors: result.errors ?? {},\n };\n };\n }, [extendedValidation]);\n\n // Hash for memo dependency optimization in consuming components\n const validationErrorsHash = JSON.stringify(validationErrors.current);\n\n return {\n resolver,\n validationErrors: validationErrors.current,\n validationErrorsHash,\n };\n};\n","import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useController as useRHFController } from 'react-hook-form';\n\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 formState: UseFormStateReturn<TFieldValues>;\n fieldState: ControllerFieldState;\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 *\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\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 // Preserve empty strings for required field validation\n // Only convert non-empty values to nullish strings\n field.onChange(value === '' ? '' : toNullishString(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","import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\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 } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\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 * - Animation control (disabled during initialization)\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 useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n const needsInitialize = lastElementNotRemovable && fields.length === 0;\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 // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\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 // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\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 // Disable animations if they're currently enabled (important for reset scenario).\n // During initial mount, animations are already disabled, but after a form reset\n // animations might be enabled, so we need to disable them before adding the element.\n if (!disableAnimation) {\n setDisableAnimation(true);\n }\n\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 1ms delay (unless user prefers reduced motion).\n // The delay ensures the setValue completes before animations turn on,\n // preventing the initial element from animating in.\n if (!prefersReducedMotion) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n","import type { ReactNode } from 'react';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { FieldCopyTestIdButton } from '../../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../../partials/FieldValidationError';\nimport { useController } from '../useController/useController';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useInput } from '../useInput/useInput';\n\n/**\n * Debounce invalid state changes for smooth UI transitions while respecting accessibility.\n *\n * Behavior:\n * - Specifically intended for validation invalid flags: debounces both\n * true → false and false → true transitions by `delayMs` to prevent\n * flicker and allow enter/exit animations to complete.\n * - If the user prefers reduced motion (via `useReducedMotion` from\n * `@fuf-stack/pixel-motion`), updates apply immediately with no delay.\n */\nconst useDebouncedInvalid = (value: boolean, delayMs: number) => {\n const [state, setState] = useState(value);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const prefersReducedMotion = useReducedMotion();\n\n useEffect(() => {\n if (prefersReducedMotion) {\n // Respect reduced motion: apply immediately\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setState(value);\n return undefined;\n }\n\n // Debounce any change (true or false) by delayMs\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setState(value);\n timeoutRef.current = null;\n }, delayMs);\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n };\n }, [value, delayMs, prefersReducedMotion]);\n\n return state;\n};\n\nexport interface UseUniformFieldParams<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Form field name */\n name: Path<TFieldValues> & string;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\nexport interface UseUniformFieldReturn<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** react-hook-form control instance for advanced integrations */\n control: ReturnType<typeof useFormContext<TFieldValues>>['control'];\n /** Debug mode from Uniform provider */\n debugMode: ReturnType<typeof useFormContext<TFieldValues>>['debugMode'];\n /** Current value used to initialize uncontrolled components */\n defaultValue: unknown;\n /** Whether the field is currently disabled (from RHF) */\n disabled: boolean | undefined;\n /** Validation error(s) for the field */\n error: FieldError[] | undefined;\n /** Pre-built errorMessage node to plug into components */\n errorMessage: ReactNode | null;\n /** RHF controller field with nullish conversions applied */\n field: ReturnType<typeof useController<TFieldValues>>['field'];\n /** Helper to spread standardized error message props to underlying components */\n getErrorMessageProps: ReturnType<typeof useInput>['getErrorMessageProps'];\n /** Helper to spread standardized helper wrapper props (for spacing/animation) */\n getHelperWrapperProps: ReturnType<typeof useInput>['getHelperWrapperProps'];\n /** Helper to spread standardized label props to underlying components */\n getLabelProps: ReturnType<typeof useInput>['getLabelProps'];\n /** Access current form values (converted to validation-friendly format) */\n getValues: ReturnType<typeof useFormContext<TFieldValues>>['getValues'];\n /** Whether the field should show invalid state (debounced for smooth animations). True when field is invalid AND (dirty OR touched OR submitted) */\n invalid: boolean;\n /** Computed label node including optional test id copy button */\n label: ReactNode | null;\n /** onBlur handler from controller */\n onBlur: ReturnType<typeof useController<TFieldValues>>['field']['onBlur'];\n /** onChange handler from controller (with nullish handling) */\n onChange: ReturnType<typeof useController<TFieldValues>>['field']['onChange'];\n /** Ref to forward to underlying control */\n ref: ReturnType<typeof useController<TFieldValues>>['field']['ref'];\n /** Whether the field is required according to validation schema */\n required: boolean;\n /** Reset a specific field in the form */\n resetField: ReturnType<typeof useFormContext<TFieldValues>>['resetField'];\n /** Generated HTML data-testid for the field */\n testId: string;\n}\n\n/**\n * Combines frequently used form field logic into a single hook.\n *\n * Provides:\n * - Enhanced form context (validation-aware state, `testId`, value transforms)\n * - Controller field with nullish conversion handling\n * - Debounced `invalid` state with smart timing:\n * • `true` (field becomes invalid): applies immediately so errors show right away\n * • `false` (field becomes valid): delayed 200ms to allow smooth exit animations\n * • Respects `prefers-reduced-motion` by skipping delays when user prefers reduced motion\n * - Smart `invalid` visibility (via `showInvalid`):\n * • Shows errors when field is dirty OR touched OR form has been submitted\n * • Prevents showing errors on pristine/untouched fields for better UX\n * • Works well for all field types (text inputs, checkboxes, radios, arrays)\n * - Prebuilt `errorMessage` React node using `FieldValidationError`\n * - Computed `label` node which appends a `FieldCopyTestIdButton` in\n * `debug-testids` mode\n * - `defaultValue` for uncontrolled defaults and all usual field handlers\n * - Access to form utilities: `control`, `getValues`, `resetField`\n * - Presentation helpers: `getLabelProps`, `getErrorMessageProps`,\n * `getHelperWrapperProps` for consistent wiring to underlying UI components\n */\nexport function useUniformField<TFieldValues extends FieldValues = FieldValues>(\n params: UseUniformFieldParams<TFieldValues>,\n): UseUniformFieldReturn<TFieldValues> {\n const { name, disabled = false, testId: explicitTestId, label } = params;\n\n const {\n control,\n debugMode,\n formState: { submitCount },\n getFieldState,\n getValues,\n resetField,\n } = useFormContext<TFieldValues>();\n\n const {\n error,\n invalid: rawInvalid,\n isDirty,\n isTouched,\n required,\n testId,\n } = getFieldState(name, explicitTestId);\n\n const { field } = useController<TFieldValues>({\n control,\n disabled,\n name,\n });\n const { onChange, disabled: isDisabled, onBlur, ref } = field;\n\n const defaultValue = (getValues() as Record<string, unknown>)?.[\n name as string\n ];\n\n /**\n * Determine when to show the invalid state to the user.\n *\n * Show errors when the field is invalid AND any of these conditions are met:\n * - Field is dirty (value changed from initial) - good for checkboxes/radios/arrays\n * - Field is touched (focused and blurred) - good for text inputs\n * - Form has been submitted - shows all errors after submit attempt\n *\n * This prevents showing errors on pristine/untouched fields for better UX.\n * Examples:\n * - Text input: User loads form with empty required field → no error shown yet\n * - Text input: User focuses and blurs → error shows (via isTouched)\n * - Checkbox group: User clicks first checkbox → error shows immediately (via isDirty)\n * - Any field: User submits form → all errors show (via submitCount)\n *\n * The entire condition is debounced to prevent flickering and allow smooth animations\n * when any of the states (invalid, isDirty, isTouched, submitCount) change.\n */\n const showInvalid = rawInvalid && (isDirty || isTouched || submitCount > 0);\n const invalid = useDebouncedInvalid(showInvalid, 200);\n\n // Build a label node that:\n // - shows the provided label (unless explicitly set to false)\n // - appends a copy-to-clipboard button for the test id in `debug-testids` mode\n // Consumers can pass this directly to component `label` props\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 // Ready-to-render error message; consumers can drop this into their\n // component `errorMessage` prop without repeating mapping/markup\n const errorMessage = <FieldValidationError error={error} testId={testId} />;\n\n // Generate standardized props for label, helper wrapper and error message\n // so consumers can spread them directly into UI components (e.g. HeroUI),\n // keeping animations/spacing consistent across fields\n const { getErrorMessageProps, getLabelProps, getHelperWrapperProps } =\n useInput({\n ref,\n classNames: {\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n },\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n return {\n control,\n debugMode,\n defaultValue,\n disabled: isDisabled,\n error,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n getValues,\n invalid,\n label: labelNode,\n onBlur,\n onChange,\n ref,\n required,\n resetField,\n testId,\n };\n}\n\nexport default useUniformField;\n","/* eslint-disable import-x/prefer-default-export */\nexport { useInput } from '@heroui/input';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,WAAW,aAAa;;;ACCjC,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB,0BAA0B;AAErD,SAAS,eAAe;;;ACAxB,OAAO,SAAS,WAAAA,UAAS,YAAAC,iBAAgB;AACzC,SAAS,gBAAgB,kBAAkB,eAAe;AAE1D,SAAS,uBAAuB;;;ACJhC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,SAAS,KAAK,YAAY;AAYnB,IAAM,6BAA6B,MAAM;AAE9C,QAAM,CAAC,yBAAyB,0BAA0B,IAAI,SAE5D,CAAC,CAAC;AAGJ,QAAM,4BAA4B,QAAQ,MAAM;AAC9C,WAAO,CAAC,KAAa,WAA+B;AAElD,iCAA2B,CAAC,SAAS;AAEnC,YAAI,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ;AACzB,iBAAO;AAAA,QACT;AAEA,YAAI,CAAC,QAAQ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U,MAAM;AACd,QAAI,iBAAiB;AACnB,qBAAe,UAAU;AAAA,IAC3B;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAIpB,EAAAA,WAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,iBAAW,MAAM;AAEf,gBAAQ,IAA0B;AAAA,MACpC,GAAG,GAAG;AAAA,IACR;AAAA,EAEF,GAAG,CAAC,OAAO,MAAM,CAAC;AAIlB,QAAM,CAAC,kBAAkB,mBAAmB,IAAIC,UAAS,IAAI;AAI7D,QAAM,uBAAuBC,kBAAiB;AAC9C,EAAAF,WAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,0BAAoB,CAAC,CAAC,oBAAoB;AAAA,IAC5C;AAAA,EACF,GAAG,CAAC,oBAAoB,CAAC;AAKzB,QAAM,sBAAsBG,SAAQ,MAAM;AACxC,WAAO,OACH,EAAE,CAAC,YAAY,GAAG,sDAAwB,KAAK,IAC9C,sDAAwB,CAAC;AAAA,EAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;AAU/B,EAAAH;AAAA,IACE,MAAM;AACJ,UAAI,iBAAiB;AAInB,YAAI,CAAC,kBAAkB;AACrB,8BAAoB,IAAI;AAAA,QAC1B;AAIA,iBAAS,MAA4B,CAAC,mBAAmB,GAAU;AAAA,UACjE,aAAa;AAAA,UACb,aAAa;AAAA,QACf,CAAC;AAGD,uBAAe,UAAU;AAKzB,YAAI,CAAC,sBAAsB;AACzB,qBAAW,MAAM;AACf,gCAAoB,KAAK;AAAA,UAC3B,GAAG,CAAC;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAAA;AAAA;AAAA,IAGA,CAAC,eAAe;AAAA,EAClB;AAEA,SAAO;AAAA;AAAA,IAEL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,KAEG;AAEP;","names":["useMemo","useState","useState","_a","useMemo","_a","useEffect","useMemo","useRef","useState","useReducedMotion","useEffect","useRef","useState","jsx","useState","useRef","useEffect","useRef","useEffect","useState","useReducedMotion","useMemo"]}
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkHI677N7Gcjs = require('./chunk-HI677N7G.cjs');
5
+ var _chunk3UIFEC4Rcjs = require('./chunk-3UIFEC4R.cjs');
6
6
 
7
7
 
8
8
  var _chunkOE5BOGGXcjs = require('./chunk-OE5BOGGX.cjs');
@@ -44,11 +44,11 @@ var Switch = ({
44
44
  testId: _testId = void 0,
45
45
  thumbIcon = void 0
46
46
  }) => {
47
- const { control, debugMode, getFieldState } = _chunkHI677N7Gcjs.useFormContext.call(void 0, );
47
+ const { control, debugMode, getFieldState } = _chunk3UIFEC4Rcjs.useFormContext.call(void 0, );
48
48
  const { error, required, testId, invalid } = getFieldState(name, _testId);
49
- const { field } = _chunkHI677N7Gcjs.useController.call(void 0, { name, control, disabled });
49
+ const { field } = _chunk3UIFEC4Rcjs.useController.call(void 0, { name, control, disabled });
50
50
  const { disabled: isDisabled, value, ref, onBlur, onChange } = field;
51
- const { label, getInputProps, getErrorMessageProps } = _chunkHI677N7Gcjs.useInput.call(void 0, {
51
+ const { label, getInputProps, getErrorMessageProps } = _chunk3UIFEC4Rcjs.useInput.call(void 0, {
52
52
  errorMessage: JSON.stringify(error),
53
53
  isInvalid: invalid,
54
54
  isRequired: required,
@@ -98,4 +98,4 @@ var Switch_default2 = Switch_default;
98
98
 
99
99
 
100
100
  exports.Switch_default = Switch_default; exports.Switch_default2 = Switch_default2;
101
- //# sourceMappingURL=chunk-F5UPZGEY.cjs.map
101
+ //# sourceMappingURL=chunk-4XTUP7W7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-F5UPZGEY.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":["Switch_default"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC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AA,CAAW,YAAA,EACzB,QAAA,kBAAA,6BAAA,KAAC,EAAA,6CAAA,8CAAA,CAAA,CAAA,EAAQ,oBAAA,CAAqB,CAAA,CAAA,EAA7B,EACC,QAAA,kBAAA,6BAAA,8CAAC,EAAA,EAAqB,KAAA,EAAc,OAAA,CAAgB,EAAA,CAAA,CACtD,EAAA,CACF,EAAA,EACE;AAAA,EAAA,EAAA,CACN,CAAA;AAEJ,CAAA;AAEA,IAAO,eAAA,EAAQ,MAAA;ADpCf;AACA;AEvFA,IAAOA,gBAAAA,EAAQ,cAAA;AFyFf;AACA;AACE;AACA;AACF,mFAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-F5UPZGEY.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInput } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label: _label = undefined,\n name,\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n thumbIcon = undefined,\n}: SwitchProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { field } = useController<FieldValues>({ name, control, disabled });\n const { disabled: isDisabled, value, ref, onBlur, onChange } = field;\n\n const { label, getInputProps, getErrorMessageProps } = useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n <HeroSwitch\n ref={ref}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n endContent={endContent}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n required={required}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n value={value}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </HeroSwitch>\n {error ? (\n <div className={classNames.errorMessage}>\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-4XTUP7W7.cjs","../src/Switch/Switch.tsx","../src/Switch/index.ts"],"names":["Switch_default"],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACXA,wCAAqC;AAErC,oDAAyC;AAoFnC,+CAAA;AA9EC,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,EAAA;AAAA,IACN,UAAA,EAAY,EAAA;AAAA,IACZ,YAAA,EAAc,WAAA;AAAA;AAAA;AAAA,IAGd,KAAA,EACE,yNAAA;AAAA,IACF,YAAA,EAAc,sBAAA;AAAA,IACd,YAAA,EAAc,EAAA;AAAA,IACd,KAAA,EAAO,EAAA;AAAA,IACP,SAAA,EAAW,EAAA;AAAA,IACX,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AA6BD,IAAM,OAAA,EAAS,CAAC;AAAA,EACd,UAAA,EAAY,KAAA,CAAA;AAAA,EACZ,SAAA,EAAW,KAAA;AAAA,EACX,WAAA,EAAa,KAAA,CAAA;AAAA,EACb,KAAA,EAAO,OAAA,EAAS,KAAA,CAAA;AAAA,EAChB,IAAA;AAAA,EACA,KAAA,EAAO,KAAA,CAAA;AAAA,EACP,aAAA,EAAe,KAAA,CAAA;AAAA,EACf,MAAA,EAAQ,QAAA,EAAU,KAAA,CAAA;AAAA,EAClB,UAAA,EAAY,KAAA;AACd,CAAA,EAAA,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AAA;AAAA,QACA,UAAA;AAAA,QACA,UAAA,EAAY,CAAC,CAAC,KAAA;AAAA,QACd,IAAA;AAAA,QACA,MAAA;AAAA,QACA,aAAA,EAAe,QAAA;AAAA,QACf,QAAA;AAAA,QACA,IAAA;AAAA,QACA,YAAA;AAAA,QACA,SAAA;AAAA,QACA,KAAA;AAAA,QAEC,QAAA,EAAA;AAAA,UAAA,KAAA;AAAA,UACA,qBAAA,kBACC,6BAAA,+CAAC,EAAA,EAAsB,OAAA,CAAgB,EAAA,EACrC;AAAA,QAAA;AAAA,MAAA;AAAA,IACN,CAAA;AAAA,IACC,MAAA,kBACC,6BAAA,KAAC,EAAA,EAAI,SAAA,EAAW,UAAA,CAAW,YAAA,EACzB,QAAA,kBAAA,6BAAA,KAAC,EAAA,6CAAA,8CAAA,CAAA,CAAA,EAAQ,oBAAA,CAAqB,CAAA,CAAA,EAA7B,EACC,QAAA,kBAAA,6BAAA,8CAAC,EAAA,EAAqB,KAAA,EAAc,OAAA,CAAgB,EAAA,CAAA,CACtD,EAAA,CACF,EAAA,EACE;AAAA,EAAA,EAAA,CACN,CAAA;AAEJ,CAAA;AAEA,IAAO,eAAA,EAAQ,MAAA;ADpCf;AACA;AEvFA,IAAOA,gBAAAA,EAAQ,cAAA;AFyFf;AACA;AACE;AACA;AACF,mFAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-4XTUP7W7.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\nimport type { FieldValues } from 'react-hook-form';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useController, useFormContext, useInput } from '../hooks';\nimport { FieldCopyTestIdButton } from '../partials/FieldCopyTestIdButton';\nimport { FieldValidationError } from '../partials/FieldValidationError';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n disabled = false,\n endContent = undefined,\n label: _label = undefined,\n name,\n size = undefined,\n startContent = undefined,\n testId: _testId = undefined,\n thumbIcon = undefined,\n}: SwitchProps) => {\n const { control, debugMode, getFieldState } = useFormContext();\n const { error, required, testId, invalid } = getFieldState(name, _testId);\n\n const { field } = useController<FieldValues>({ name, control, disabled });\n const { disabled: isDisabled, value, ref, onBlur, onChange } = field;\n\n const { label, getInputProps, getErrorMessageProps } = useInput({\n errorMessage: JSON.stringify(error),\n isInvalid: invalid,\n isRequired: required,\n label: _label,\n labelPlacement: 'outside',\n placeholder: ' ',\n });\n\n const showTestIdCopyButton = debugMode === 'debug-testids';\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n <HeroSwitch\n ref={ref}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n aria-describedby={getInputProps()['aria-describedby']}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n endContent={endContent}\n isDisabled={isDisabled}\n isSelected={!!value}\n name={name}\n onBlur={onBlur}\n onValueChange={onChange}\n required={required}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n value={value}\n >\n {label}\n {showTestIdCopyButton ? (\n <FieldCopyTestIdButton testId={testId} />\n ) : null}\n </HeroSwitch>\n {error ? (\n <div className={classNames.errorMessage}>\n <div {...getErrorMessageProps()}>\n <FieldValidationError error={error} testId={testId} />\n </div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useFormContext
3
- } from "./chunk-WVTLXBTO.js";
3
+ } from "./chunk-47MZU3WD.js";
4
4
 
5
5
  // src/SubmitButton/SubmitButton.tsx
6
6
  import { cn, slugify } from "@fuf-stack/pixel-utils";
@@ -46,4 +46,4 @@ export {
46
46
  SubmitButton_default,
47
47
  SubmitButton_default2
48
48
  };
49
- //# sourceMappingURL=chunk-SUT7AMXT.js.map
49
+ //# sourceMappingURL=chunk-7FTSMHFL.js.map