@fuf-stack/uniform 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) 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-BZBA2YGQ.js → chunk-2TVCFRLE.js} +2 -2
  24. package/dist/{chunk-TTKSVOSS.js → chunk-33JULJXP.js} +2 -2
  25. package/dist/{chunk-RNBJT4Y7.cjs → chunk-3Z3F4LTX.cjs} +3 -3
  26. package/dist/{chunk-RNBJT4Y7.cjs.map → chunk-3Z3F4LTX.cjs.map} +1 -1
  27. package/dist/{chunk-L53NZ7S5.js → chunk-4TOWIBVX.js} +2 -2
  28. package/dist/{chunk-VRFZFKDM.js → chunk-57GTLKQC.js} +2 -2
  29. package/dist/{chunk-O3DDOJTB.cjs → chunk-BGVM2RIC.cjs} +81 -6
  30. package/dist/chunk-BGVM2RIC.cjs.map +1 -0
  31. package/dist/{chunk-XZLIDJKA.cjs → chunk-BQLB74OT.cjs} +3 -3
  32. package/dist/{chunk-XZLIDJKA.cjs.map → chunk-BQLB74OT.cjs.map} +1 -1
  33. package/dist/{chunk-4DGOOLSO.js → chunk-CG7LKC5L.js} +2 -2
  34. package/dist/{chunk-3MXAIQKI.js → chunk-CICN5KXP.js} +2 -2
  35. package/dist/{chunk-SU5WXAC7.cjs → chunk-F6H3CFFX.cjs} +4 -4
  36. package/dist/{chunk-SU5WXAC7.cjs.map → chunk-F6H3CFFX.cjs.map} +1 -1
  37. package/dist/{chunk-2A74CSGX.js → chunk-FUJZS2ZW.js} +2 -2
  38. package/dist/{chunk-3FSNNDYZ.cjs → chunk-IOFHIMRR.cjs} +3 -3
  39. package/dist/{chunk-3FSNNDYZ.cjs.map → chunk-IOFHIMRR.cjs.map} +1 -1
  40. package/dist/{chunk-JJDPGGYL.cjs → chunk-J2EEMMKC.cjs} +3 -3
  41. package/dist/{chunk-JJDPGGYL.cjs.map → chunk-J2EEMMKC.cjs.map} +1 -1
  42. package/dist/{chunk-TED4I5EF.cjs → chunk-NCYGAFR2.cjs} +3 -3
  43. package/dist/{chunk-TED4I5EF.cjs.map → chunk-NCYGAFR2.cjs.map} +1 -1
  44. package/dist/{chunk-LZPH7LW5.cjs → chunk-NURK44RO.cjs} +5 -5
  45. package/dist/{chunk-LZPH7LW5.cjs.map → chunk-NURK44RO.cjs.map} +1 -1
  46. package/dist/{chunk-KE3ZO2IJ.cjs → chunk-PVB5EFWW.cjs} +3 -3
  47. package/dist/{chunk-KE3ZO2IJ.cjs.map → chunk-PVB5EFWW.cjs.map} +1 -1
  48. package/dist/{chunk-SUO4QK32.js → chunk-QJETOENA.js} +2 -2
  49. package/dist/{chunk-CHG25NCC.js → chunk-RROVF7SO.js} +2 -2
  50. package/dist/{chunk-4EZWAVRZ.js → chunk-U57PIYJR.js} +2 -2
  51. package/dist/{chunk-CROGVLLB.js → chunk-UVCXMSCC.js} +53 -58
  52. package/dist/chunk-UVCXMSCC.js.map +1 -0
  53. package/dist/{chunk-CUXVVIWS.cjs → chunk-WPBRWZ6G.cjs} +3 -3
  54. package/dist/{chunk-CUXVVIWS.cjs.map → chunk-WPBRWZ6G.cjs.map} +1 -1
  55. package/dist/{chunk-Y6NHIZ2M.js → chunk-XRV3STYH.js} +83 -8
  56. package/dist/chunk-XRV3STYH.js.map +1 -0
  57. package/dist/{chunk-I6CQH42B.cjs → chunk-Y4TP2U6D.cjs} +3 -3
  58. package/dist/{chunk-I6CQH42B.cjs.map → chunk-Y4TP2U6D.cjs.map} +1 -1
  59. package/dist/{chunk-BOESKBZN.cjs → chunk-ZFOAPZDA.cjs} +49 -54
  60. package/dist/chunk-ZFOAPZDA.cjs.map +1 -0
  61. package/dist/hooks/index.cjs +2 -2
  62. package/dist/hooks/index.cjs.map +1 -1
  63. package/dist/hooks/index.d.cts +69 -5
  64. package/dist/hooks/index.d.ts +69 -5
  65. package/dist/hooks/index.js +5 -5
  66. package/dist/index.cjs +13 -13
  67. package/dist/index.cjs.map +1 -1
  68. package/dist/index.d.cts +2 -2
  69. package/dist/index.d.ts +2 -2
  70. package/dist/index.js +16 -16
  71. package/package.json +4 -4
  72. package/dist/chunk-BOESKBZN.cjs.map +0 -1
  73. package/dist/chunk-CROGVLLB.js.map +0 -1
  74. package/dist/chunk-O3DDOJTB.cjs.map +0 -1
  75. package/dist/chunk-Y6NHIZ2M.js.map +0 -1
  76. /package/dist/{chunk-BZBA2YGQ.js.map → chunk-2TVCFRLE.js.map} +0 -0
  77. /package/dist/{chunk-TTKSVOSS.js.map → chunk-33JULJXP.js.map} +0 -0
  78. /package/dist/{chunk-L53NZ7S5.js.map → chunk-4TOWIBVX.js.map} +0 -0
  79. /package/dist/{chunk-VRFZFKDM.js.map → chunk-57GTLKQC.js.map} +0 -0
  80. /package/dist/{chunk-4DGOOLSO.js.map → chunk-CG7LKC5L.js.map} +0 -0
  81. /package/dist/{chunk-3MXAIQKI.js.map → chunk-CICN5KXP.js.map} +0 -0
  82. /package/dist/{chunk-2A74CSGX.js.map → chunk-FUJZS2ZW.js.map} +0 -0
  83. /package/dist/{chunk-SUO4QK32.js.map → chunk-QJETOENA.js.map} +0 -0
  84. /package/dist/{chunk-CHG25NCC.js.map → chunk-RROVF7SO.js.map} +0 -0
  85. /package/dist/{chunk-4EZWAVRZ.js.map → chunk-U57PIYJR.js.map} +0 -0
@@ -218,6 +218,7 @@ var FormContext_default = FormProvider;
218
218
 
219
219
  // src/hooks/useFormContext/useFormContext.ts
220
220
  var checkFieldIsRequired = (validation, path) => {
221
+ const checkPath = path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;
221
222
  const checkRequired = (schema) => {
222
223
  if (schema.type === "array") {
223
224
  if (schema.isOptional || schema.isNullable) {
@@ -227,7 +228,7 @@ var checkFieldIsRequired = (validation, path) => {
227
228
  }
228
229
  return !schema.isOptional && !schema.isNullable;
229
230
  };
230
- return validation.checkSchemaPath(checkRequired, path);
231
+ return validation.checkSchemaPath(checkRequired, checkPath);
231
232
  };
232
233
  var getValidationErrorsByName = (errors, name) => {
233
234
  const keys = name.split(".").filter((k) => {
@@ -358,15 +359,19 @@ var useController = (props) => {
358
359
  };
359
360
  };
360
361
 
361
- // src/hooks/useFieldArray/useFieldArray.ts
362
- import { useFieldArray } from "react-hook-form";
362
+ // src/hooks/useUniformFieldArray/useUniformFieldArray.ts
363
+ import { useEffect as useEffect3, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
364
+ import { useFieldArray as useRHFFieldArray } from "react-hook-form";
365
+ import { useReducedMotion as useReducedMotion2 } from "@fuf-stack/pixel-motion";
366
+
367
+ // src/hooks/useUniformField/useUniformField.tsx
368
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
369
+ import { useReducedMotion } from "@fuf-stack/pixel-motion";
363
370
 
364
371
  // src/hooks/useInput/useInput.ts
365
372
  import { useInput } from "@heroui/input";
366
373
 
367
374
  // src/hooks/useUniformField/useUniformField.tsx
368
- import { useEffect as useEffect2, useRef as useRef2, useState as useState3 } from "react";
369
- import { useReducedMotion } from "@fuf-stack/pixel-motion";
370
375
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
371
376
  var useDebouncedInvalid = (value, delayMs) => {
372
377
  const [state, setState] = useState3(value);
@@ -467,14 +472,84 @@ function useUniformField(params) {
467
472
  };
468
473
  }
469
474
 
475
+ // src/hooks/useUniformFieldArray/useUniformFieldArray.ts
476
+ var useUniformFieldArray = ({
477
+ name,
478
+ flat = false,
479
+ elementInitialValue: _elementInitialValue = null,
480
+ lastElementNotRemovable = false,
481
+ disabled,
482
+ testId: explicitTestId,
483
+ label,
484
+ showInvalidWhen = "immediate"
485
+ }) => {
486
+ const uniformField = useUniformField({
487
+ name,
488
+ disabled,
489
+ testId: explicitTestId,
490
+ label,
491
+ showInvalidWhen
492
+ });
493
+ const { control } = uniformField;
494
+ const { fields, append, remove, insert, move } = useRHFFieldArray({
495
+ control,
496
+ name
497
+ });
498
+ const { trigger, setValue } = useFormContext();
499
+ const [disableAnimation, setDisableAnimation] = useState4(true);
500
+ const hasInitialized = useRef3(false);
501
+ useEffect3(() => {
502
+ if (hasInitialized.current) {
503
+ setTimeout(() => {
504
+ trigger(name);
505
+ }, 200);
506
+ }
507
+ }, [fields.length]);
508
+ const prefersReducedMotion = useReducedMotion2();
509
+ useEffect3(() => {
510
+ if (hasInitialized.current) {
511
+ setDisableAnimation(!!prefersReducedMotion);
512
+ }
513
+ }, [prefersReducedMotion]);
514
+ const elementInitialValue = useMemo3(() => {
515
+ return flat ? { [flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
516
+ }, [flat, _elementInitialValue]);
517
+ useEffect3(
518
+ () => {
519
+ if (lastElementNotRemovable && fields.length === 0) {
520
+ setValue(name, [elementInitialValue]);
521
+ }
522
+ hasInitialized.current = true;
523
+ if (!prefersReducedMotion) {
524
+ setTimeout(() => {
525
+ setDisableAnimation(false);
526
+ }, 1);
527
+ }
528
+ },
529
+ // only run once when the component mounts
530
+ // eslint-disable-next-line react-hooks/exhaustive-deps
531
+ []
532
+ );
533
+ return __spreadValues({
534
+ // Field array methods and state
535
+ fields,
536
+ append,
537
+ remove,
538
+ insert,
539
+ move,
540
+ disableAnimation,
541
+ elementInitialValue
542
+ }, uniformField);
543
+ };
544
+
470
545
  export {
471
546
  FormContext_default,
472
547
  checkFieldIsRequired,
473
548
  useFormContext,
474
549
  useClientValidation,
475
550
  useController,
476
- useFieldArray,
477
551
  useInput,
478
- useUniformField
552
+ useUniformField,
553
+ useUniformFieldArray
479
554
  };
480
- //# sourceMappingURL=chunk-Y6NHIZ2M.js.map
555
+ //# sourceMappingURL=chunk-XRV3STYH.js.map
@@ -0,0 +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 // 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 // Track whether initialization has completed. Used to:\n // 1. Skip validation during initial setup\n // 2. Only enable animations after initialization\n // 3. Only respond to motion preference changes after initialization\n const hasInitialized = useRef(false);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization to avoid showing errors before initialization is complete.\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 // 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: Add initial element if lastElementNotRemovable is set.\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 (lastElementNotRemovable && fields.length === 0) {\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\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 initial 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 // only run once when the component mounts\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [],\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,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;AACX,gBAAqC,WAA5B,EAtCnB,CAsCmB,MAAM,SAtCzB,IAsC+C,IAAT,iBAAS,IAAT,CAAnB;AACT,iBAAO;AAAA,QACT;AAEA,eAAO,iCAAK,OAAL,EAAW,CAAC,GAAG,GAAG,OAAO;AAAA,MAClC,CAAC;AAAA,IACH;AAAA,EACF,GAAG,CAAC,CAA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MAAM,CAAC;AAIlB,QAAM,uBAAuBC,kBAAiB;AAC9C,EAAAD,WAAU,MAAM;AACd,QAAI,eAAe,SAAS;AAC1B,0BAAoB,CAAC,CAAC,oBAAoB;AAAA,IAC5C;AAAA,EACF,GAAG,CAAC,oBAAoB,CAAC;AAKzB,QAAM,sBAAsBE,SAAQ,MAAM;AACxC,WAAO,OACH,EAAE,CAAC,YAAY,GAAG,sDAAwB,KAAK,IAC9C,sDAAwB,CAAC;AAAA,EAChC,GAAG,CAAC,MAAM,oBAAoB,CAAC;AAS/B,EAAAF;AAAA,IACE,MAAM;AACJ,UAAI,2BAA2B,OAAO,WAAW,GAAG;AAGlD,iBAAS,MAA4B,CAAC,mBAAmB,CAAQ;AAAA,MACnE;AAGA,qBAAe,UAAU;AAKzB,UAAI,CAAC,sBAAsB;AACzB,mBAAW,MAAM;AACf,8BAAoB,KAAK;AAAA,QAC3B,GAAG,CAAC;AAAA,MACN;AAAA,IACF;AAAA;AAAA;AAAA,IAGA,CAAC;AAAA,EACH;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","useState","useRef","useEffect","useReducedMotion","useMemo"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkO3DDOJTBcjs = require('./chunk-O3DDOJTB.cjs');
3
+ var _chunkBGVM2RICcjs = require('./chunk-BGVM2RIC.cjs');
4
4
 
5
5
 
6
6
  var _chunkBZ5OMN4Ycjs = require('./chunk-BZ5OMN4Y.cjs');
@@ -65,7 +65,7 @@ var Input = (_a) => {
65
65
  required,
66
66
  testId,
67
67
  resetField
68
- } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, { name }, uniformFieldProps));
68
+ } = _chunkBGVM2RICcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, { name }, uniformFieldProps));
69
69
  const { onChange, onBlur, value } = _chunkBZ5OMN4Ycjs.useInputValueDebounce.call(void 0, {
70
70
  debounceDelay,
71
71
  onBlur: fieldOnBlur,
@@ -128,4 +128,4 @@ var Input_default2 = Input_default;
128
128
 
129
129
 
130
130
  exports.Input_default = Input_default; exports.Input_default2 = Input_default2;
131
- //# sourceMappingURL=chunk-I6CQH42B.cjs.map
131
+ //# sourceMappingURL=chunk-Y4TP2U6D.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-I6CQH42B.cjs","../src/Input/Input.tsx","../src/Input/index.ts"],"names":["Input_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAAmC;AAEnC,oDAAyC;AAqHrC,+CAAA;AAhHG,IAAM,cAAA,EAAgB,4BAAA;AAAG,EAC9B,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,EAAA;AAAA;AAAA,IAEN,WAAA,EAAa,EAAA;AAAA;AAAA,IAEb,KAAA,EAAO,EAAA;AAAA;AAAA,IAEP,YAAA,EAAc;AAAA,EAChB;AACF,CAAC,CAAA;AAuCD,IAAM,MAAA,EAAQ,CAAC,EAAA,EAAA,GAaG;AAbH,EAAA,IAAA,GAAA,EAAA,EAAA,EACb;AAAA,IAAA,SAAA,EAAW,WAAA,EAAa,KAAA,CAAA;AAAA,IACxB,UAAA,EAAY,KAAA;AAAA,IACZ,cAAA,EAAgB,GAAA;AAAA,IAChB,WAAA,EAAa,KAAA,CAAA;AAAA,IACb,IAAA;AAAA,IACA,QAAA,EAAU,KAAA,CAAA;AAAA,IACV,YAAA,EAAc,GAAA;AAAA,IACd,KAAA,EA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ACV;AAAA,IACF;AAAA,EACF,EAAA,EACA,CAAC,CAAA;AAGP,EAAA,MAAM,SAAA,EAAW,aAAA,CAAc,CAAA;AAC/B,EAAA,MAAM,WAAA,EAAa,8CAAA,QAAqB,EAAU,UAAA,EAAY,MAAM,CAAA;AAEpE,EAAA,uBACE,6BAAA;AAAA,IAAC,YAAA;AAAA,IAAA,8CAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAa,MAAA;AAAA,MACb,UAAA;AAAA,MACA,YAAA;AAAA,MACA,EAAA,EAAI,MAAA;AAAA,MACJ,UAAA,EAAY,QAAA;AAAA,MACZ,SAAA,EAAW,OAAA;AAAA,MACX,UAAA,EAAY,QAAA;AAAA,MACZ,KAAA;AAAA,MACA,cAAA,EAAe,SAAA;AAAA,MACf,IAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,MAAA,EAAO,IAAA;AAAA,MACP,IAAA;AAAA,MACA,YAAA;AAAA,MACA,IAAA;AAAA,MAEA,KAAA;AAAA,MACA,OAAA,EAAQ,UAAA;AAAA,MACR,UAAA,EAAY;AAAA,QACV,IAAA,EAAM,UAAA,CAAW,IAAA;AAAA,QACjB,WAAA,EAAa,UAAA,CAAW,WAAA;AAAA;AAAA,QAExB,aAAA,EAAe,KAAA;AAAA,QACf,KAAA,EAAO,UAAA,CAAW,KAAA;AAAA,QAClB,YAAA,EAAc,UAAA,CAAW;AAAA,MAC3B;AAAA,IAAA,CAAA,EACI,cAAA;AAAA,EACN,CAAA;AAEJ,CAAA;AAEA,IAAO,cAAA,EAAQ,KAAA;ADrCf;AACA;AErHA,IAAOA,eAAAA,EAAQ,aAAA;AFuHf;AACA;AACE;AACA;AACF,+EAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-I6CQH42B.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks';\n\nimport { Input as HeroInput } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce, useUniformField } from '../hooks';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n transform = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n transform,\n type,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroInput\n ref={ref}\n data-testid={testId}\n endContent={endContent}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n radius=\"sm\"\n size={size}\n startContent={startContent}\n type={type}\n // @ts-expect-error can be number for input type number\n value={value}\n variant=\"bordered\"\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n {...clearableProps}\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-Y4TP2U6D.cjs","../src/Input/Input.tsx","../src/Input/index.ts"],"names":["Input_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAAmC;AAEnC,oDAAyC;AAqHrC,+CAAA;AAhHG,IAAM,cAAA,EAAgB,4BAAA;AAAG,EAC9B,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,EAAA;AAAA;AAAA,IAE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;AAAA;AAAA,QAExB,aAAA,EAAe,KAAA;AAAA,QACf,KAAA,EAAO,UAAA,CAAW,KAAA;AAAA,QAClB,YAAA,EAAc,UAAA,CAAW;AAAA,MAC3B;AAAA,IAAA,CAAA,EACI,cAAA;AAAA,EACN,CAAA;AAEJ,CAAA;AAEA,IAAO,cAAA,EAAQ,KAAA;ADrCf;AACA;AErHA,IAAOA,eAAAA,EAAQ,aAAA;AFuHf;AACA;AACE;AACA;AACF,+EAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-Y4TP2U6D.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { InputProps as HeroInputProps } from '@heroui/input';\nimport type { ReactNode } from 'react';\nimport type { InputValueTransform } from '../hooks';\n\nimport { Input as HeroInput } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce, useUniformField } from '../hooks';\n\n// input variants\nexport const inputVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof inputVariants>;\ntype ClassName = TVClassName<typeof inputVariants>;\n\nexport interface InputProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** shows clear button when input has value */\n clearable?: boolean;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** input field is disabled */\n disabled?: boolean;\n /** added content to the end of the input Field. */\n endContent?: ReactNode;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /** callback that is fired when the value is cleared */\n onClear?: () => void;\n /** form field placeholder */\n placeholder?: string;\n /** size of the input */\n size?: 'sm' | 'md' | 'lg';\n /** content added to the start of the input field */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** allows disentangled display and form values for a field */\n transform?: InputValueTransform;\n /** input type */\n type?: 'number' | 'password';\n}\n\n/**\n * Input component based on [HeroUI Input](https://www.heroui.com//docs/components/input)\n */\nconst Input = ({\n className: _className = undefined,\n clearable = false,\n debounceDelay = 300,\n endContent = undefined,\n name,\n onClear = undefined,\n placeholder = ' ',\n size = undefined,\n startContent = undefined,\n transform = undefined,\n type = undefined,\n ...uniformFieldProps\n}: InputProps) => {\n const {\n disabled,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n errorMessage,\n invalid,\n label,\n required,\n testId,\n resetField,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use hook that provides debounced onChange and enhanced blur handling\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n transform,\n type,\n value: fieldValue,\n });\n\n // If input is clearable add props for clearing input value\n const clearableProps: Pick<HeroInputProps, 'isClearable' | 'onClear'> =\n clearable\n ? {\n isClearable: true,\n onClear: () => {\n // if field had initial value we do not reset it\n // to that value, but clear it instead\n resetField(name, { defaultValue: null });\n // if onClear cb provided we call it\n if (onClear) {\n onClear();\n }\n },\n }\n : {};\n\n // classNames from slots\n const variants = inputVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroInput\n ref={ref}\n data-testid={testId}\n endContent={endContent}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n radius=\"sm\"\n size={size}\n startContent={startContent}\n type={type}\n // @ts-expect-error can be number for input type number\n value={value}\n variant=\"bordered\"\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n {...clearableProps}\n />\n );\n};\n\nexport default Input;\n","import Input from './Input';\n\nexport type { InputProps } from './Input';\n\nexport { Input };\n\nexport default Input;\n"]}
@@ -4,8 +4,7 @@ var _chunkTTD3KL6Ecjs = require('./chunk-TTD3KL6E.cjs');
4
4
 
5
5
 
6
6
 
7
-
8
- var _chunkO3DDOJTBcjs = require('./chunk-O3DDOJTB.cjs');
7
+ var _chunkBGVM2RICcjs = require('./chunk-BGVM2RIC.cjs');
9
8
 
10
9
 
11
10
  var _chunkNHEZXA4Hcjs = require('./chunk-NHEZXA4H.cjs');
@@ -19,8 +18,6 @@ var _chunkZ353BLWIcjs = require('./chunk-Z353BLWI.cjs');
19
18
  var _chunk555JRYCScjs = require('./chunk-555JRYCS.cjs');
20
19
 
21
20
  // src/FieldArray/FieldArray.tsx
22
- var _react = require('react');
23
- var _pixelmotion = require('@fuf-stack/pixel-motion');
24
21
  var _pixelutils = require('@fuf-stack/pixel-utils');
25
22
 
26
23
  // src/FieldArray/subcomponents/ElementAppendButton.tsx
@@ -53,10 +50,10 @@ var ElementAppendButton = ({
53
50
  var ElementAppendButton_default = ElementAppendButton;
54
51
 
55
52
  // src/FieldArray/subcomponents/FieldArrayElement.tsx
56
-
53
+ var _react = require('react');
57
54
  var _sortable = require('@dnd-kit/sortable');
58
55
  var _utilities = require('@dnd-kit/utilities');
59
-
56
+ var _pixelmotion = require('@fuf-stack/pixel-motion');
60
57
 
61
58
 
62
59
  // src/FieldArray/subcomponents/ElementActionsMenu.tsx
@@ -135,12 +132,14 @@ var ElementActionsMenu_default = ElementActionsMenu;
135
132
 
136
133
 
137
134
 
135
+
138
136
  var ElementRemoveButton = ({
139
137
  className = void 0,
138
+ disableAnimation = false,
140
139
  onClick,
141
140
  testId = void 0
142
141
  }) => {
143
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
142
+ const button = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
144
143
  _pixels.Button,
145
144
  {
146
145
  ariaLabel: "remove element",
@@ -153,6 +152,20 @@ var ElementRemoveButton = ({
153
152
  variant: "light"
154
153
  }
155
154
  );
155
+ if (disableAnimation) {
156
+ return button;
157
+ }
158
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
159
+ _pixelmotion.motion.div,
160
+ {
161
+ animate: { opacity: 1, width: "auto" },
162
+ className: "flex",
163
+ exit: { opacity: 0, width: 0 },
164
+ initial: { opacity: 0, width: 0 },
165
+ transition: { duration: 0.2 },
166
+ children: button
167
+ }
168
+ );
156
169
  };
157
170
  var ElementRemoveButton_default = ElementRemoveButton;
158
171
 
@@ -277,10 +290,11 @@ var FieldArrayElement = ({
277
290
  }
278
291
  })
279
292
  }
280
- ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: lastNotDeletable && fields.length === 1 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
293
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _pixelmotion.AnimatePresence, { initial: false, children: lastNotDeletable && fields.length === 1 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
281
294
  ElementRemoveButton_default,
282
295
  {
283
296
  className: className.removeButton,
297
+ disableAnimation,
284
298
  testId: `${testId}_remove_button`,
285
299
  onClick: () => {
286
300
  if (disableAnimation) {
@@ -289,8 +303,9 @@ var FieldArrayElement = ({
289
303
  setIsVisible(false);
290
304
  }
291
305
  }
292
- }
293
- ) })
306
+ },
307
+ "remove-button"
308
+ ) }) })
294
309
  ] })
295
310
  },
296
311
  id
@@ -309,7 +324,7 @@ var FieldArrayLabel = ({
309
324
  name
310
325
  }) => {
311
326
  var _a;
312
- const { error, getLabelProps, invalid, label } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, {
327
+ const { error, getLabelProps, invalid, label } = _chunkBGVM2RICcjs.useUniformField.call(void 0, {
313
328
  name,
314
329
  showInvalidWhen: "immediate",
315
330
  label: _label
@@ -351,7 +366,7 @@ var FieldArrayValidationError = ({
351
366
  getHelperWrapperProps,
352
367
  invalid,
353
368
  testId
354
- } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, {
369
+ } = _chunkBGVM2RICcjs.useUniformField.call(void 0, {
355
370
  name,
356
371
  showInvalidWhen: "immediate"
357
372
  });
@@ -370,8 +385,8 @@ var FieldArrayValidationError = ({
370
385
  _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getHelperWrapperProps()), {
371
386
  className: _pixelutils.cn.call(void 0,
372
387
  (_a = getHelperWrapperProps()) == null ? void 0 : _a.className,
373
- // force helper to be visible (for some reason it's hidden by default) and add padding/rounded corners
374
- "block rounded-b-small px-3 py-2"
388
+ // force helper to be visible (for some reason it's hidden by default) and add padding
389
+ "block px-3 py-2"
375
390
  ),
376
391
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getErrorMessageProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
377
392
  _chunkNHEZXA4Hcjs.FieldValidationError_default,
@@ -480,7 +495,7 @@ var fieldArrayVariants = _pixelutils.tv.call(void 0, {
480
495
  /** class for the append button */
481
496
  appendButton: [
482
497
  // base styles
483
- "w-full rounded-b-small rounded-t-none",
498
+ "w-full justify-start rounded-b-small rounded-t-none font-semibold",
484
499
  // match label height (p-3 = 12px vertical padding + text-base line height)
485
500
  "!h-[48px] !min-h-0",
486
501
  // focus styles - inset ring with rounded bottom corners to match container
@@ -573,38 +588,23 @@ var FieldArray = (_a) => {
573
588
  "name",
574
589
  "sortable"
575
590
  ]);
576
- const { control, error, getValues, invalid, testId } = _chunkO3DDOJTBcjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
591
+ const {
592
+ fields,
593
+ append,
594
+ remove,
595
+ insert,
596
+ move,
597
+ disableAnimation,
598
+ elementInitialValue,
599
+ getValues,
600
+ testId
601
+ } = _chunkBGVM2RICcjs.useUniformFieldArray.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
577
602
  name,
603
+ flat,
604
+ elementInitialValue: _elementInitialValue,
605
+ lastElementNotRemovable,
578
606
  showInvalidWhen: "immediate"
579
607
  }, uniformFieldProps));
580
- const { fields, append, remove, insert, move } = _chunkO3DDOJTBcjs.useFieldArray.call(void 0, {
581
- control,
582
- name
583
- });
584
- const { trigger, setValue } = _chunkO3DDOJTBcjs.useFormContext.call(void 0, );
585
- _react.useEffect.call(void 0, () => {
586
- setTimeout(() => {
587
- trigger(name);
588
- }, 200);
589
- }, [fields.length]);
590
- const elementInitialValue = flat ? { [_chunkZ353BLWIcjs.flatArrayKey]: _elementInitialValue != null ? _elementInitialValue : null } : _elementInitialValue != null ? _elementInitialValue : {};
591
- _react.useEffect.call(void 0,
592
- () => {
593
- if (lastElementNotRemovable && fields.length === 0) {
594
- setValue(name, [elementInitialValue]);
595
- }
596
- },
597
- // only run once when the component mounts
598
- // eslint-disable-next-line react-hooks/exhaustive-deps
599
- []
600
- );
601
- const prefersReducedMotion = _pixelmotion.useReducedMotion.call(void 0, );
602
- const disableAnimationRef = _react.useRef.call(void 0, true);
603
- _react.useEffect.call(void 0, () => {
604
- if (!prefersReducedMotion) {
605
- disableAnimationRef.current = false;
606
- }
607
- }, [prefersReducedMotion]);
608
608
  const variants = fieldArrayVariants({ hasLabel: !!uniformFieldProps.label });
609
609
  const className = _pixelutils.variantsToClassNames.call(void 0, variants, _className, "base");
610
610
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: className.base, children: [
@@ -649,7 +649,7 @@ var FieldArray = (_a) => {
649
649
  FieldArrayElement_default,
650
650
  {
651
651
  className,
652
- disableAnimation: disableAnimationRef.current,
652
+ disableAnimation,
653
653
  duplicate,
654
654
  elementMarginBottom,
655
655
  fields,
@@ -674,23 +674,18 @@ var FieldArray = (_a) => {
674
674
  }
675
675
  ) })
676
676
  ) : null,
677
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FieldArrayValidationError_default, { name }),
677
678
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
678
679
  ElementAppendButton_default,
679
680
  {
680
681
  appendButtonText,
682
+ className: className.appendButton,
681
683
  testId: `${testId}_append_button`,
682
- className: _pixelutils.cn.call(void 0,
683
- className.appendButton,
684
- // only round bottom corners if there are no errors below
685
- // @ts-expect-error - error._errors exists but not typed
686
- { "rounded-none": invalid && (error == null ? void 0 : error._errors) }
687
- ),
688
684
  onClick: () => {
689
685
  append(elementInitialValue);
690
686
  }
691
687
  }
692
- ),
693
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FieldArrayValidationError_default, { name })
688
+ )
694
689
  ] });
695
690
  };
696
691
  var FieldArray_default = FieldArray;
@@ -702,4 +697,4 @@ var FieldArray_default2 = FieldArray_default;
702
697
 
703
698
 
704
699
  exports.FieldArray_default = FieldArray_default; exports.FieldArray_default2 = FieldArray_default2;
705
- //# sourceMappingURL=chunk-BOESKBZN.cjs.map
700
+ //# sourceMappingURL=chunk-ZFOAPZDA.cjs.map