@fuf-stack/uniform 1.19.0 → 1.19.2
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.
- package/dist/Checkboxes/index.cjs +1 -1
- package/dist/{Checkboxes-Ca9fTce_.cjs → Checkboxes-DegQ22uN.cjs} +3 -3
- package/dist/{Checkboxes-Ca9fTce_.cjs.map → Checkboxes-DegQ22uN.cjs.map} +1 -1
- package/dist/FieldArray/index.cjs +1 -1
- package/dist/FieldArray/index.js +1 -1
- package/dist/{FieldArray-n39Aj9AV.js → FieldArray-BVL5Tz0Q.js} +33 -34
- package/dist/{FieldArray-n39Aj9AV.js.map → FieldArray-BVL5Tz0Q.js.map} +1 -1
- package/dist/{FieldArray-CnxCQt0o.cjs → FieldArray-CeiNCobX.cjs} +36 -37
- package/dist/{FieldArray-CnxCQt0o.cjs.map → FieldArray-CeiNCobX.cjs.map} +1 -1
- package/dist/FieldCard/index.cjs +1 -1
- package/dist/{FieldCard-DbuGSb_j.cjs → FieldCard-C0kNSLj7.cjs} +4 -4
- package/dist/{FieldCard-DbuGSb_j.cjs.map → FieldCard-C0kNSLj7.cjs.map} +1 -1
- package/dist/{FieldCopyTestIdButton-BvVBidko.cjs → FieldCopyTestIdButton-DrUzXwTo.cjs} +2 -2
- package/dist/{FieldCopyTestIdButton-BvVBidko.cjs.map → FieldCopyTestIdButton-DrUzXwTo.cjs.map} +1 -1
- package/dist/{FieldValidationError-EecXNx5F.cjs → FieldValidationError-8H8LxDjk.cjs} +2 -2
- package/dist/{FieldValidationError-EecXNx5F.cjs.map → FieldValidationError-8H8LxDjk.cjs.map} +1 -1
- package/dist/Form/index.cjs +1 -1
- package/dist/{Form-Diivw8pg.cjs → Form-Dqa1b7Y7.cjs} +3 -3
- package/dist/{Form-Diivw8pg.cjs.map → Form-Dqa1b7Y7.cjs.map} +1 -1
- package/dist/{FormContext-3GzWxXSS.cjs → FormContext-BrY1FQYR.cjs} +2 -2
- package/dist/{FormContext-3GzWxXSS.cjs.map → FormContext-BrY1FQYR.cjs.map} +1 -1
- package/dist/Grid/index.cjs +1 -1
- package/dist/{Grid-V1pCY2LC.cjs → Grid-DdYQQ_UM.cjs} +2 -2
- package/dist/{Grid-V1pCY2LC.cjs.map → Grid-DdYQQ_UM.cjs.map} +1 -1
- package/dist/Input/index.cjs +1 -1
- package/dist/Input/index.d.cts +1 -1
- package/dist/Input/index.d.ts +1 -1
- package/dist/{Input-C6kRsqx1.cjs → Input-BXJ4DSha.cjs} +2 -2
- package/dist/{Input-C6kRsqx1.cjs.map → Input-BXJ4DSha.cjs.map} +1 -1
- package/dist/RadioBoxes/index.cjs +1 -1
- package/dist/RadioBoxes/index.d.cts +1 -1
- package/dist/RadioBoxes/index.d.ts +1 -1
- package/dist/RadioBoxes/index.js +1 -1
- package/dist/{RadioBoxes-DNQCynvF.js → RadioBoxes-BR3X986V.js} +11 -14
- package/dist/{RadioBoxes-DNQCynvF.js.map → RadioBoxes-BR3X986V.js.map} +1 -1
- package/dist/{RadioBoxes-DVxDhpbp.cjs → RadioBoxes-Cim3InDW.cjs} +12 -15
- package/dist/{RadioBoxes-DVxDhpbp.cjs.map → RadioBoxes-Cim3InDW.cjs.map} +1 -1
- package/dist/RadioTabs/index.cjs +1 -1
- package/dist/{RadioTabs-CFraIx6w.cjs → RadioTabs-t-x2XnuI.cjs} +2 -2
- package/dist/{RadioTabs-CFraIx6w.cjs.map → RadioTabs-t-x2XnuI.cjs.map} +1 -1
- package/dist/Radios/index.cjs +1 -1
- package/dist/Radios/index.d.cts +1 -1
- package/dist/Radios/index.d.ts +1 -1
- package/dist/Radios/index.js +1 -1
- package/dist/{Radios-C-Zf3Yij.js → Radios-CYwW3bZa.js} +8 -11
- package/dist/{Radios-C-Zf3Yij.js.map → Radios-CYwW3bZa.js.map} +1 -1
- package/dist/{Radios-OhSB1oFo.cjs → Radios-CjEFdyD6.cjs} +9 -12
- package/dist/{Radios-OhSB1oFo.cjs.map → Radios-CjEFdyD6.cjs.map} +1 -1
- package/dist/Select/index.cjs +1 -1
- package/dist/Select/index.d.cts +1 -1
- package/dist/Select/index.d.ts +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/{Select-fEJPVWJa.cjs → Select-BEed8xan.cjs} +5 -7
- package/dist/{Select-fEJPVWJa.cjs.map → Select-BEed8xan.cjs.map} +1 -1
- package/dist/{Select-DMpCAYLB.js → Select-BILyyM7Z.js} +3 -5
- package/dist/{Select-DMpCAYLB.js.map → Select-BILyyM7Z.js.map} +1 -1
- package/dist/Slider/index.cjs +1 -1
- package/dist/Slider/index.d.cts +1 -1
- package/dist/Slider/index.d.ts +1 -1
- package/dist/{Slider-ChBNfwS2.cjs → Slider-CFYP86ku.cjs} +2 -2
- package/dist/{Slider-ChBNfwS2.cjs.map → Slider-CFYP86ku.cjs.map} +1 -1
- package/dist/SubmitButton/index.cjs +1 -1
- package/dist/{SubmitButton-CfuPpJKk.cjs → SubmitButton-D7xacDyS.cjs} +3 -3
- package/dist/{SubmitButton-CfuPpJKk.cjs.map → SubmitButton-D7xacDyS.cjs.map} +1 -1
- package/dist/Switch/index.cjs +1 -1
- package/dist/Switch/index.d.cts +1 -1
- package/dist/Switch/index.d.ts +1 -1
- package/dist/{Switch-MDrnacFJ.cjs → Switch-Dt9TGQ8d.cjs} +2 -2
- package/dist/{Switch-MDrnacFJ.cjs.map → Switch-Dt9TGQ8d.cjs.map} +1 -1
- package/dist/SwitchBox/index.cjs +1 -1
- package/dist/{SwitchBox-kp93uE8e.cjs → SwitchBox-DMPp_Ed-.cjs} +2 -2
- package/dist/{SwitchBox-kp93uE8e.cjs.map → SwitchBox-DMPp_Ed-.cjs.map} +1 -1
- package/dist/TextArea/index.cjs +1 -1
- package/dist/TextArea/index.d.cts +1 -1
- package/dist/TextArea/index.d.ts +1 -1
- package/dist/{TextArea-B8XYKqFg.cjs → TextArea-DDwzXW-y.cjs} +2 -2
- package/dist/{TextArea-B8XYKqFg.cjs.map → TextArea-DDwzXW-y.cjs.map} +1 -1
- package/dist/helpers/index.cjs +1 -1
- package/dist/hooks/useClientValidation/index.cjs +1 -1
- package/dist/hooks/useClientValidation/index.d.cts +1 -1
- package/dist/hooks/useClientValidation/index.d.ts +1 -1
- package/dist/hooks/useController/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.cjs +1 -1
- package/dist/hooks/useFormContext/index.d.cts +1 -1
- package/dist/hooks/useFormContext/index.d.ts +1 -1
- package/dist/hooks/useInput/index.cjs +1 -1
- package/dist/hooks/useInputValueDebounce/index.cjs +2 -2
- package/dist/hooks/useInputValueTransform/index.cjs +1 -1
- package/dist/hooks/useUniformField/index.cjs +6 -6
- package/dist/hooks/useUniformField/index.d.cts +1 -1
- package/dist/hooks/useUniformField/index.d.ts +1 -1
- package/dist/hooks/useUniformFieldArray/index.cjs +2 -2
- package/dist/hooks/useUniformFieldArray/index.d.cts +1 -1
- package/dist/hooks/useUniformFieldArray/index.d.ts +1 -1
- package/dist/hooks/useWatchUserChange/index.cjs +1 -1
- package/dist/{index-B2tIMFYh.d.cts → index-25CYKzg4.d.cts} +4 -4
- package/dist/{index-B2tIMFYh.d.cts.map → index-25CYKzg4.d.cts.map} +1 -1
- package/dist/{index-DpNf55K6.d.ts → index-6hu79Fof.d.ts} +4 -4
- package/dist/{index-DpNf55K6.d.ts.map → index-6hu79Fof.d.ts.map} +1 -1
- package/dist/{index-B0Fw1BAy.d.cts → index-AmOFlE3L.d.cts} +7 -7
- package/dist/{index-B0Fw1BAy.d.cts.map → index-AmOFlE3L.d.cts.map} +1 -1
- package/dist/{index-CZJ_lWQ0.d.ts → index-B-6CMF1H.d.ts} +4 -4
- package/dist/{index-CZJ_lWQ0.d.ts.map → index-B-6CMF1H.d.ts.map} +1 -1
- package/dist/{index-BqWtWLeP.d.cts → index-B6WiZaSk.d.cts} +19 -19
- package/dist/{index-BqWtWLeP.d.cts.map → index-B6WiZaSk.d.cts.map} +1 -1
- package/dist/{index-CKJumX37.d.cts → index-C9up4f3f.d.cts} +4 -4
- package/dist/{index-CKJumX37.d.cts.map → index-C9up4f3f.d.cts.map} +1 -1
- package/dist/{index-BLctuwc0.d.ts → index-CVINifvT.d.ts} +19 -19
- package/dist/{index-BLctuwc0.d.ts.map → index-CVINifvT.d.ts.map} +1 -1
- package/dist/{index-Yj6VEhqF.d.ts → index-CdjZBYTX.d.ts} +13 -13
- package/dist/{index-Yj6VEhqF.d.ts.map → index-CdjZBYTX.d.ts.map} +1 -1
- package/dist/{index-C6dMrOEm.d.cts → index-ChTPOej7.d.cts} +13 -13
- package/dist/{index-C6dMrOEm.d.cts.map → index-ChTPOej7.d.cts.map} +1 -1
- package/dist/{index-DGHBlmnV.d.ts → index-CuRn5Thx.d.ts} +7 -7
- package/dist/{index-DGHBlmnV.d.ts.map → index-CuRn5Thx.d.ts.map} +1 -1
- package/dist/{index-1Gzrph8R.d.cts → index-DMwNV_Br.d.cts} +4 -4
- package/dist/{index-1Gzrph8R.d.cts.map → index-DMwNV_Br.d.cts.map} +1 -1
- package/dist/{index-DZzfeV4O.d.cts → index-DiD7s23-.d.cts} +4 -4
- package/dist/{index-DZzfeV4O.d.cts.map → index-DiD7s23-.d.cts.map} +1 -1
- package/dist/{index-DJe_1ZdK.d.ts → index-Gs3zrYoY.d.ts} +4 -4
- package/dist/{index-DJe_1ZdK.d.ts.map → index-Gs3zrYoY.d.ts.map} +1 -1
- package/dist/{index-BExpqT81.d.ts → index-N5wvPOq3.d.ts} +4 -4
- package/dist/{index-BExpqT81.d.ts.map → index-N5wvPOq3.d.ts.map} +1 -1
- package/dist/index.cjs +23 -23
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +4 -4
- package/dist/partials/FieldCopyTestIdButton/index.cjs +1 -1
- package/dist/partials/FieldValidationError/index.cjs +1 -1
- package/dist/{useClientValidation-_8PTmv8i.d.ts → useClientValidation-BWElhQ91.d.ts} +2 -3
- package/dist/useClientValidation-BWElhQ91.d.ts.map +1 -0
- package/dist/{useClientValidation-Bu3mNZpf.d.cts → useClientValidation-DtnfCE5T.d.cts} +2 -3
- package/dist/{useClientValidation-_8PTmv8i.d.ts.map → useClientValidation-DtnfCE5T.d.cts.map} +1 -1
- package/dist/{useClientValidation-HqsAYK9K.cjs → useClientValidation-NKOuXuHV.cjs} +3 -3
- package/dist/{useClientValidation-HqsAYK9K.cjs.map → useClientValidation-NKOuXuHV.cjs.map} +1 -1
- package/dist/{useController-D3a0qufz.cjs → useController-DVRh86Zy.cjs} +2 -2
- package/dist/{useController-D3a0qufz.cjs.map → useController-DVRh86Zy.cjs.map} +1 -1
- package/dist/{useFormContext-BQeGmV8j.cjs → useFormContext-Bum4VP1o.cjs} +2 -2
- package/dist/{useFormContext-BQeGmV8j.cjs.map → useFormContext-Bum4VP1o.cjs.map} +1 -1
- package/dist/{useFormContext-CHA8GnKp.d.ts → useFormContext-DEMm-bsc.d.ts} +3 -3
- package/dist/{useFormContext-CHA8GnKp.d.ts.map → useFormContext-DEMm-bsc.d.ts.map} +1 -1
- package/dist/{useFormContext-C06aufHt.d.cts → useFormContext-Dey5DbWr.d.cts} +3 -3
- package/dist/{useFormContext-C06aufHt.d.cts.map → useFormContext-Dey5DbWr.d.cts.map} +1 -1
- package/dist/{useInputValueTransform-Cl6Xeso7.cjs → useInputValueTransform-DKH-7F9D.cjs} +2 -2
- package/dist/{useInputValueTransform-Cl6Xeso7.cjs.map → useInputValueTransform-DKH-7F9D.cjs.map} +1 -1
- package/dist/{useUniformField-j22kM31n.d.cts → useUniformField-DB8jF52F.d.cts} +2 -2
- package/dist/{useUniformField-j22kM31n.d.cts.map → useUniformField-DB8jF52F.d.cts.map} +1 -1
- package/dist/{useUniformField-BTBS1Kv-.d.ts → useUniformField-iHk8xYXN.d.ts} +2 -2
- package/dist/{useUniformField-BTBS1Kv-.d.ts.map → useUniformField-iHk8xYXN.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-CMHoo4o3.d.ts → useUniformFieldArray-B0SPtHeT.d.ts} +2 -2
- package/dist/{useUniformFieldArray-CMHoo4o3.d.ts.map → useUniformFieldArray-B0SPtHeT.d.ts.map} +1 -1
- package/dist/{useUniformFieldArray-CDEagafl.d.cts → useUniformFieldArray-okvikMJp.d.cts} +2 -2
- package/dist/{useUniformFieldArray-CDEagafl.d.cts.map → useUniformFieldArray-okvikMJp.d.cts.map} +1 -1
- package/dist/{useWatchUserChange-DkZ0Vqv3.cjs → useWatchUserChange-CBuIa5kU.cjs} +3 -3
- package/dist/{useWatchUserChange-DkZ0Vqv3.cjs.map → useWatchUserChange-CBuIa5kU.cjs.map} +1 -1
- package/package.json +6 -6
- package/dist/useClientValidation-Bu3mNZpf.d.cts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useController-
|
|
1
|
+
{"version":3,"file":"useController-DVRh86Zy.cjs","names":["UniformContext","toNullishString","fromNullishString"],"sources":["../src/hooks/useController/useController.ts"],"sourcesContent":["import type {\n ControllerFieldState,\n ControllerRenderProps,\n UseControllerProps as RHFUseControllerProps,\n UseFormStateReturn,\n} from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useController as useRHFController } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { fromNullishString, toNullishString } from '../../helpers';\n\nexport type UseControllerProps<TFieldValues extends object = object> =\n RHFUseControllerProps<TFieldValues>;\n\nexport interface UseControllerReturn<TFieldValues extends object = object> {\n field: Omit<ControllerRenderProps<TFieldValues>, 'onChange' | 'value'> & {\n // Using any[] to support both direct value changes and React synthetic events\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => void;\n value: string;\n };\n 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 * 5. Notifies UniformContext's userChange listeners on field changes (enables useWatchUserChange hook)\n * 6. No-op when value unchanged: onChange is ignored if the new value equals the current value\n * (prevents unnecessary re-renders and spurious useWatchUserChange triggers)\n *\n * This enables consistent handling of empty/null values while keeping a clean API\n * for form inputs that expect string values.\n *\n * @see https://react-hook-form.com/docs/usecontroller\n */\nexport const useController = <TFieldValues extends object = object>(\n props: UseControllerProps<TFieldValues>,\n): UseControllerReturn<TFieldValues> => {\n const { field, formState, fieldState } = useRHFController(props);\n const { userChange } = useContext(UniformContext);\n\n return {\n field: {\n ...field,\n // Handles both direct values (onChange(\"value\")) and events (onChange(event))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onChange: (...event: any[]) => {\n const value = event[0]?.target?.value ?? event[0];\n const formattedValue = value === '' ? '' : toNullishString(value);\n\n // Skip if value hasn't changed (e.g., user re-selects same option)\n // We compare formattedValue (the new value after nullish conversion) with\n // field.value (the current stored value, also in nullish format)\n if (formattedValue === field.value) {\n return;\n }\n\n // Update form state first\n field.onChange(formattedValue);\n\n // Then notify userChange listeners (for useWatchUserChange hook)\n // This ensures getValues() in listeners returns the updated value\n // Guard against undefined userChange (when used outside FormProvider)\n // NOTE: We notify with the original value (not formattedValue) so that\n // listeners receive the actual value (false, 0, null) instead of marker\n // strings like '__FALSE__', '__ZERO__', '__NULL__'\n userChange?.notify(field.name, value);\n },\n // Convert null/undefined to empty string for UI display\n value: fromNullishString(field.value) as string,\n },\n formState,\n fieldState,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,iBACX,UACsC;CACtC,MAAM,EAAE,OAAO,WAAW,gBAAA,GAAA,gBAAA,eAAgC,MAAM;CAChE,MAAM,EAAE,gBAAA,GAAA,MAAA,YAA0BA,oBAAAA,eAAe;AAEjD,QAAO;EACL,OAAO;GACL,GAAG;GAGH,WAAW,GAAG,UAAiB;IAC7B,MAAM,QAAQ,MAAM,IAAI,QAAQ,SAAS,MAAM;IAC/C,MAAM,iBAAiB,UAAU,KAAK,KAAKC,sBAAAA,gBAAgB,MAAM;AAKjE,QAAI,mBAAmB,MAAM,MAC3B;AAIF,UAAM,SAAS,eAAe;AAQ9B,gBAAY,OAAO,MAAM,MAAM,MAAM;;GAGvC,OAAOC,sBAAAA,kBAAkB,MAAM,MAAM;GACtC;EACD;EACA;EACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_FormContext = require("./FormContext-
|
|
1
|
+
const require_FormContext = require("./FormContext-BrY1FQYR.cjs");
|
|
2
2
|
const require_helpers_index = require("./helpers/index.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
let react_hook_form = require("react-hook-form");
|
|
@@ -130,4 +130,4 @@ Object.defineProperty(exports, "useFormContext", {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
-
//# sourceMappingURL=useFormContext-
|
|
133
|
+
//# sourceMappingURL=useFormContext-Bum4VP1o.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-Bum4VP1o.cjs","names":["flatArrayKey","UniformContext","nameToTestId","toValidationFormat"],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { VetoFormattedError, VetoInstance } from '@fuf-stack/veto';\nimport type { FieldError, FieldValues, Path } from 'react-hook-form';\n\nimport { useContext } from 'react';\nimport { useFormContext as useHookFormContext } from 'react-hook-form';\n\nimport { UniformContext } from '../../Form/subcomponents/FormContext';\nimport { flatArrayKey, nameToTestId, toValidationFormat } from '../../helpers';\n\n/** Schema check whether a field is required or optional */\nexport const checkFieldIsRequired = (\n validation: VetoInstance,\n path: string[],\n): boolean => {\n // Handle flat array paths: strip the flatArrayKey to check the array element schema\n // e.g., ['arrayField', '0', '__FLAT__'] -> check schema at ['arrayField', '0']\n const checkPath =\n path[path.length - 1] === flatArrayKey ? path.slice(0, -1) : path;\n\n const checkRequired = (schema: any) => {\n // arrays ...\n if (schema.type === 'array') {\n // ... if array is optional or nullable it is not required\n if (schema.isOptional || schema.isNullable) {\n return false;\n }\n // ... otherwise arrays are required (display logic wise -> no asterisk in the label)\n return true;\n }\n\n // all other fields are required if they are\n // not optional and not nullable\n return !schema.isOptional && !schema.isNullable;\n };\n\n return validation.checkSchemaPath(checkRequired, checkPath);\n};\n\n/**\n * Resolve validation errors for a given field path.\n *\n * Traverses a nested `VetoFormattedError` structure using a dotted path\n * (for example: \"user.address.0.street\") and returns the matching\n * `FieldError[]` if present. If no error exists at the path, returns\n * `undefined`.\n *\n * @param errors - The formatted validation errors from Uniform's context\n * @param name - The dotted field path to resolve\n * @returns An array of `FieldError` entries for the field, or `undefined`\n */\nconst getValidationErrorsByName = (\n errors: VetoFormattedError,\n name: string,\n) => {\n // Traverse nested error structure; ignore flat array wrapper key\n const keys = name.split('.').filter((k) => {\n return k !== flatArrayKey;\n });\n let current: unknown = errors 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 *\n * Key features:\n * - Enhanced `getFieldState` that includes validation schema-based \"required\" status and testId generation\n * - Automatic conversion of form values via `getValues`, `watch`, and `subscribe`:\n * - Unwraps flat array wrappers (`{ __FLAT__: value }` → `value`)\n * - Converts nullish string markers (`__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`)\n * - Filters out empty/null values\n */\nexport const useFormContext = <\n TFieldValues extends FieldValues = FieldValues,\n TContext = any,\n TTransformedValues = TFieldValues,\n>() => {\n const {\n formState,\n // some methods that will be enhanced below\n getFieldState: getFieldStateOrig,\n getValues: getValuesOrig,\n watch: watchOrig,\n subscribe: subscribeOrig,\n // 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 * - A testId generated from the field name (with flat array keys removed and slugified)\n *\n * @param name - The field path (string or array)\n * @param testId - Optional explicit testId. If provided, will be slugified. If not provided, generated from name.\n */\n const getFieldState = (name: Path<TFieldValues>, testId?: string) => {\n const fieldPath =\n typeof name === 'string' ? name.replace(/\\[\\d+\\]/g, '').split('.') : name;\n\n // Use base validation instance for checking \"required\" status\n // Client validation often uses .nullish() which would incorrectly mark fields as optional\n const validationInstance =\n uniformContext?.validation.baseInstance ??\n uniformContext?.validation.instance;\n\n // Check if the field is required using the validation schema\n const required = validationInstance\n ? checkFieldIsRequired(validationInstance, fieldPath)\n : false;\n\n const error = getValidationErrorsByName(\n uniformContext?.validation.errors ?? {},\n name,\n ) 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: nameToTestId(testId ?? name),\n };\n };\n\n /**\n * Wrap form value accessor methods to automatically convert from internal storage format\n * to component-friendly format:\n *\n * - Unwrap flat array wrappers: `{ __FLAT__: value }` → `value`\n * - Convert nullish string markers: `__NULL__` → `null`, `__FALSE__` → `false`, `__ZERO__` → `0`\n * - Filter out empty/null values: fields with converted null/empty values are removed entirely\n *\n * This ensures components receive clean, predictable data without needing to handle\n * the internal nullish string conversion system or flat array wrapping manually.\n */\n const getValues = ((...args: any[]) => {\n const result = (getValuesOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof getValuesOrig;\n\n const watch = ((...args: any[]) => {\n const result = (watchOrig as any)(...args);\n return toValidationFormat(result);\n }) as typeof watchOrig;\n\n const subscribe = ((...args: any[]) => {\n // For subscribe, we need to wrap the callback to convert the values property\n const [options] = args;\n if (options?.callback) {\n const originalCallback = options.callback;\n const wrappedOptions = {\n ...options,\n callback: (subscribeFormState: any) => {\n // Convert the values property if it exists\n const convertedFormState = {\n ...subscribeFormState,\n ...(subscribeFormState.values && {\n values: toValidationFormat(subscribeFormState.values),\n }),\n };\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return originalCallback(convertedFormState);\n },\n };\n return subscribeOrig(wrappedOptions);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (subscribeOrig as any)(...args);\n }) as typeof subscribeOrig;\n\n return {\n ...otherMethods,\n ...uniformContext,\n formState,\n getFieldState,\n getValues,\n subscribe,\n watch,\n };\n};\n"],"mappings":";;;;;;AAYA,MAAa,wBACX,YACA,SACY;CAGZ,MAAM,YACJ,KAAK,KAAK,SAAS,OAAA,aAAsB,KAAK,MAAM,GAAG,GAAG,GAAG;CAE/D,MAAM,iBAAiB,WAAgB;AAErC,MAAI,OAAO,SAAS,SAAS;AAE3B,OAAI,OAAO,cAAc,OAAO,WAC9B,QAAO;AAGT,UAAO;;AAKT,SAAO,CAAC,OAAO,cAAc,CAAC,OAAO;;AAGvC,QAAO,WAAW,gBAAgB,eAAe,UAAU;;;;;;;;;;;;;;AAe7D,MAAM,6BACJ,QACA,SACG;CAEH,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC,QAAQ,MAAM;AACzC,SAAO,MAAMA,sBAAAA;GACb;CACF,IAAI,UAAmB;AACvB,MAAK,SAAS,QAAQ;AACpB,MAAI,WAAW,OAAO,YAAY,SAChC,WAAW,QAAoC;MAE/C,WAAU,KAAA;GAEZ;AACF,QAAO;;;;;;;;;;;;AAaT,MAAa,uBAIN;CACL,MAAM,EACJ,WAEA,eAAe,mBACf,WAAW,eACX,OAAO,WACP,WAAW,eAEX,GAAG,kBAAA,GAAA,gBAAA,iBAC+D;CAEpE,MAAM,kBAAA,GAAA,MAAA,YAA4BC,oBAAAA,eAAe;;;;;;;;;;CAWjD,MAAM,iBAAiB,MAA0B,WAAoB;EACnE,MAAM,YACJ,OAAO,SAAS,WAAW,KAAK,QAAQ,YAAY,GAAG,CAAC,MAAM,IAAI,GAAG;EAIvE,MAAM,qBACJ,gBAAgB,WAAW,gBAC3B,gBAAgB,WAAW;EAG7B,MAAM,WAAW,qBACb,qBAAqB,oBAAoB,UAAU,GACnD;EAEJ,MAAM,QAAQ,0BACZ,gBAAgB,WAAW,UAAU,EAAE,EACvC,KACD;AAKD,SAAO;GACL,GAHiB,kBAAkB,MAAM,UAAU;GAInD;GACA,SAAS,CAAC,CAAC;GACX;GACA,QAAQC,sBAAAA,aAAa,UAAU,KAAK;GACrC;;;;;;;;;;;;;CAcH,MAAM,cAAc,GAAG,SAAgB;AAErC,SAAOC,sBAAAA,mBADS,cAAsB,GAAG,KAAK,CACb;;CAGnC,MAAM,UAAU,GAAG,SAAgB;AAEjC,SAAOA,sBAAAA,mBADS,UAAkB,GAAG,KAAK,CACT;;CAGnC,MAAM,cAAc,GAAG,SAAgB;EAErC,MAAM,CAAC,WAAW;AAClB,MAAI,SAAS,UAAU;GACrB,MAAM,mBAAmB,QAAQ;AAejC,UAAO,cAdgB;IACrB,GAAG;IACH,WAAW,uBAA4B;AASrC,YAAO,iBAPoB;MACzB,GAAG;MACH,GAAI,mBAAmB,UAAU,EAC/B,QAAQA,sBAAAA,mBAAmB,mBAAmB,OAAO,EACtD;MACF,CAE0C;;IAE9C,CACmC;;AAGtC,SAAQ,cAAsB,GAAG,KAAK;;AAGxC,QAAO;EACL,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -32,10 +32,10 @@ declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues,
|
|
|
32
32
|
getValues: _$react_hook_form0.UseFormGetValues<TFieldValues>;
|
|
33
33
|
subscribe: _$react_hook_form0.UseFormSubscribe<TFieldValues>;
|
|
34
34
|
watch: _$react_hook_form0.UseFormWatch<TFieldValues>;
|
|
35
|
-
debugMode: "
|
|
35
|
+
debugMode: "disabled" | "debug" | "debug-testids" | "off";
|
|
36
36
|
debugModeSettings?: DebugModeSettings;
|
|
37
37
|
preventSubmit: (prevent: boolean) => void;
|
|
38
|
-
setDebugMode: (debugMode: "
|
|
38
|
+
setDebugMode: (debugMode: "disabled" | "debug" | "debug-testids" | "off") => void;
|
|
39
39
|
triggerSubmit: (e?: _$react.BaseSyntheticEvent) => Promise<void> | void;
|
|
40
40
|
userChange: {
|
|
41
41
|
subscribe: (listener: UserChangeListener) => () => void;
|
|
@@ -61,4 +61,4 @@ declare const useFormContext$1: <TFieldValues extends FieldValues = FieldValues,
|
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { useFormContext$1 as n, checkFieldIsRequired as t };
|
|
64
|
-
//# sourceMappingURL=useFormContext-
|
|
64
|
+
//# sourceMappingURL=useFormContext-DEMm-bsc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-DEMm-bsc.d.ts","names":[],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"mappings":";;;;;;;;;cAYa,oBAAA,GACX,UAAA,EAAY,YAAA,EACZ,IAAA;;;;;AAFF;;;;;;cAqEa,gBAAA,wBACU,WAAA,GAAc,WAAA,uCAEd,YAAA;;wBAwBQ,IAAA,CAAK,YAAA,GAAa,MAAA;;;;;;;;;;;;;;;;8BAWf,kBAAA,KAAA,OAAA;;0BAAA,kBAAA;;;;mBAwB/B,YAAA;eAEoB,YAAA;aAAwE,kBAAA;qDAAA,kBAAA,CAAA,WAAA;EAAA"}
|
|
@@ -32,10 +32,10 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
32
32
|
getValues: _$react_hook_form0.UseFormGetValues<TFieldValues>;
|
|
33
33
|
subscribe: _$react_hook_form0.UseFormSubscribe<TFieldValues>;
|
|
34
34
|
watch: _$react_hook_form0.UseFormWatch<TFieldValues>;
|
|
35
|
-
debugMode: "
|
|
35
|
+
debugMode: "disabled" | "debug" | "debug-testids" | "off";
|
|
36
36
|
debugModeSettings?: DebugModeSettings;
|
|
37
37
|
preventSubmit: (prevent: boolean) => void;
|
|
38
|
-
setDebugMode: (debugMode: "
|
|
38
|
+
setDebugMode: (debugMode: "disabled" | "debug" | "debug-testids" | "off") => void;
|
|
39
39
|
triggerSubmit: (e?: _$react.BaseSyntheticEvent) => Promise<void> | void;
|
|
40
40
|
userChange: {
|
|
41
41
|
subscribe: (listener: UserChangeListener) => () => void;
|
|
@@ -61,4 +61,4 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
|
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { useFormContext as n, checkFieldIsRequired as t };
|
|
64
|
-
//# sourceMappingURL=useFormContext-
|
|
64
|
+
//# sourceMappingURL=useFormContext-Dey5DbWr.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFormContext-
|
|
1
|
+
{"version":3,"file":"useFormContext-Dey5DbWr.d.cts","names":[],"sources":["../src/hooks/useFormContext/useFormContext.ts"],"mappings":";;;;;;;;;cAYa,oBAAA,GACX,UAAA,EAAY,YAAA,EACZ,IAAA;;;;;AAFF;;;;;;cAqEa,cAAA,wBACU,WAAA,GAAc,WAAA,uCAEd,YAAA;;wBAwBQ,IAAA,CAAK,YAAA,GAAa,MAAA;;;;;;;;;;;;;;;;8BAWf,kBAAA,KAAA,OAAA;;0BAAA,kBAAA;;;;mBAwB/B,YAAA;eAEoB,YAAA;aAAwE,kBAAA;qDAAA,kBAAA,CAAA,WAAA;EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./FormContext-
|
|
1
|
+
require("./FormContext-BrY1FQYR.cjs");
|
|
2
2
|
let react = require("react");
|
|
3
3
|
//#region src/hooks/useInputValueTransform/useInputValueTransform.ts
|
|
4
4
|
/**
|
|
@@ -113,4 +113,4 @@ Object.defineProperty(exports, "useInputValueTransform", {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
//# sourceMappingURL=useInputValueTransform-
|
|
116
|
+
//# sourceMappingURL=useInputValueTransform-DKH-7F9D.cjs.map
|
package/dist/{useInputValueTransform-Cl6Xeso7.cjs.map → useInputValueTransform-DKH-7F9D.cjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInputValueTransform-
|
|
1
|
+
{"version":3,"file":"useInputValueTransform-DKH-7F9D.cjs","names":[],"sources":["../src/hooks/useInputValueTransform/useInputValueTransform.ts"],"sourcesContent":["import { useCallback } from 'react';\n\nexport interface InputValueTransform<TDisplay = unknown> {\n /** Transforms the form value to display value (e.g., 1000 → \"$1,000\" or 'a' → ['a']) */\n toDisplayValue: (value: unknown) => TDisplay;\n /** Transforms the display value to form value (e.g., \"$1,000\" → 1000 or ['a'] → 'a') */\n toFormValue: (value: TDisplay) => unknown;\n}\n\nexport interface UseInputValueTransformOptions<TDisplay = unknown> {\n /** Input type for special number handling */\n type?: 'text' | 'number' | 'password';\n /** Value transformation functions */\n transform?: InputValueTransform<TDisplay>;\n}\n\nexport interface UseInputValueTransformReturn<TDisplay = unknown> {\n /** Converts any form value to display value */\n toDisplayValue: (formValue: unknown) => TDisplay;\n /** Converts any display value to form value */\n toFormValue: (displayValue: TDisplay) => unknown;\n}\n\n/**\n * Custom hook providing utility functions for value transformations between display and form values.\n *\n * This hook provides pure conversion functions without any state management. It's useful for:\n * - Currency formatting ($1,000 display vs 1000 stored)\n * - Number inputs with special handling\n * - Date formatting (MM/DD/YYYY display vs ISO date stored)\n * - Phone number formatting ((555) 123-4567 display vs 5551234567 stored)\n * - Array/Object transformations (single value ↔ array, nested structures)\n *\n * **Key Features:**\n * - Pure conversion functions (no state)\n * - Generic support for any data type (strings, numbers, arrays, objects)\n * - Special number input handling (empty string preservation)\n * - Bidirectional value transformations\n * - Memoized functions for performance\n *\n * @param options Configuration for value transformation\n * @returns Pure conversion utility functions\n *\n * @example\n * ```tsx\n * // Currency formatting\n * const currencyTransform = {\n * toDisplayValue: (val) => val ? `$${Number(val).toLocaleString()}` : '',\n * toFormValue: (val) => parseFloat(val.replace(/[$,]/g, '')) || 0\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: currencyTransform\n * });\n *\n * const displayVal = toDisplayValue(1000); // \"$1,000\"\n * const formVal = toFormValue(\"$1,500\"); // 1500\n * ```\n *\n * @example\n * ```tsx\n * // Number input (no transforms needed)\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * type: 'number'\n * });\n *\n * // Handles empty string → empty string (not NaN)\n * // Handles \"123\" → 123 (string to number conversion)\n * ```\n *\n * @example\n * ```tsx\n * // Array to single value (for single checkbox)\n * const singleValueTransform = {\n * toDisplayValue: (val: string[]) => val?.[0] || '',\n * toFormValue: (val: string) => val ? [val] : []\n * };\n *\n * const { toDisplayValue, toFormValue } = useInputValueTransform({\n * transform: singleValueTransform\n * });\n *\n * const displayVal = toDisplayValue(['option1']); // \"option1\"\n * const formVal = toFormValue(\"option2\"); // [\"option2\"]\n * ```\n *\n * @example\n * ```tsx\n * // Integration with debouncing\n * const MyInput = ({ field, transform }) => {\n * const transform = useInputValueTransform({ transform });\n *\n * const { onChange, onBlur, value } = useInputValueDebounce({\n * ...transform,\n * debounceDelay: 300,\n * name: 'fieldName',\n * onBlur: field.onBlur,\n * onChange: field.onChange,\n * value: field.value,\n * });\n *\n * return <input value={value} onChange={onChange} onBlur={onBlur} />;\n * };\n * ```\n */\nexport const useInputValueTransform = <TDisplay = unknown>({\n type,\n transform,\n}: UseInputValueTransformOptions<TDisplay>): UseInputValueTransformReturn<TDisplay> => {\n /**\n * Converts any form value to display value\n */\n const toDisplayValue = useCallback(\n (formValue: unknown): TDisplay => {\n if (transform?.toDisplayValue) {\n return transform.toDisplayValue(formValue);\n }\n\n // For number type, convert valid strings to numbers for display\n if (type === 'number') {\n if (formValue === '') {\n return '' as TDisplay;\n }\n const numValue = Number(formValue);\n return (Number.isNaN(numValue) ? formValue : numValue) as TDisplay;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return (formValue ?? '') as TDisplay;\n },\n [type, transform],\n );\n\n /**\n * Converts any display value to form value\n */\n const toFormValue = useCallback(\n (displayValue: TDisplay): unknown => {\n if (transform?.toFormValue) {\n return transform.toFormValue(displayValue);\n }\n\n // For number type, convert strings to numbers\n if (type === 'number') {\n if (displayValue === '') {\n return '';\n }\n const numValue = Number(displayValue);\n return Number.isNaN(numValue) ? displayValue : numValue;\n }\n\n // Default: pass through (handles primitives, arrays, objects, etc.)\n return displayValue;\n },\n [type, transform],\n );\n\n return {\n toDisplayValue,\n toFormValue,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,MAAa,0BAA8C,EACzD,MACA,gBACqF;AAiDrF,QAAO;EACL,iBAAA,GAAA,MAAA,cA7CC,cAAiC;AAChC,OAAI,WAAW,eACb,QAAO,UAAU,eAAe,UAAU;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,cAAc,GAChB,QAAO;IAET,MAAM,WAAW,OAAO,UAAU;AAClC,WAAQ,OAAO,MAAM,SAAS,GAAG,YAAY;;AAI/C,UAAQ,aAAa;KAEvB,CAAC,MAAM,UAAU,CAClB;EA4BC,cAAA,GAAA,MAAA,cAtBC,iBAAoC;AACnC,OAAI,WAAW,YACb,QAAO,UAAU,YAAY,aAAa;AAI5C,OAAI,SAAS,UAAU;AACrB,QAAI,iBAAiB,GACnB,QAAO;IAET,MAAM,WAAW,OAAO,aAAa;AACrC,WAAO,OAAO,MAAM,SAAS,GAAG,eAAe;;AAIjD,UAAO;KAET,CAAC,MAAM,UAAU,CAClB;EAKA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as InputValueTransform } from "./useInputValueTransform-BwAfw8Xb.cjs";
|
|
2
2
|
import { r as useController } from "./useController-CNiqy_2D.cjs";
|
|
3
|
-
import { n as useFormContext } from "./useFormContext-
|
|
3
|
+
import { n as useFormContext } from "./useFormContext-Dey5DbWr.cjs";
|
|
4
4
|
import { t as useInput } from "./useInput-93TCCrkB.cjs";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
@@ -95,4 +95,4 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
95
95
|
declare const useUniformField: <TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>) => UseUniformFieldReturn<TFieldValues>;
|
|
96
96
|
//#endregion
|
|
97
97
|
export { UseUniformFieldReturn as n, useUniformField as r, UseUniformFieldParams as t };
|
|
98
|
-
//# sourceMappingURL=useUniformField-
|
|
98
|
+
//# sourceMappingURL=useUniformField-DB8jF52F.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-
|
|
1
|
+
{"version":3,"file":"useUniformField-DB8jF52F.d.cts","names":[],"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"mappings":";;;;;;;;UAgBiB,qBAAA,sBACM,WAAA,GAAc,WAAA;;EAInC,IAAA,EAAM,IAAA,CAAK,YAAA;EALyB;EAOpC,SAAA;EANqB;EAQrB,QAAA;EAJW;EAMX,KAAA,GAAQ,SAAA;EAAA;EAER,MAAA;EAEY;EAAZ,SAAA,GAAY,mBAAA,CAAoB,QAAA;EAAD;EAE/B,IAAA;AAAA;AAAA,UAGe,qBAAA,sBACM,WAAA,GAAc,WAAA;EAnBnC;EAsBA,SAAA;EAnBM;EAqBN,OAAA,EAAS,UAAA,QAAkB,cAAA,CAAe,YAAA;EAnB1C;EAqBA,SAAA,EAAW,UAAA,QAAkB,cAAA,CAAe,YAAA;EAjB5C;EAmBA,YAAA;EAjBA;EAmBA,QAAA;EAjBY;EAmBZ,KAAA,EAAO,UAAA;EAjBP;EAmBA,YAAA,EAAc,SAAA;EAnBV;EAqBJ,KAAA,EAAO,UAAA,QAAkB,aAAA,CAAc,YAAA;EAlBH;EAoBpC,oBAAA,EAAsB,UAAA,QAAkB,QAAA;EAnBnB;EAqBrB,qBAAA,EAAuB,UAAA,QAAkB,QAAA;EAhBC;EAkB1C,aAAA,EAAe,UAAA,QAAkB,QAAA;EAlBxB;EAoBT,SAAA,EAAW,UAAA,QAAkB,cAAA,CAAe,YAAA;EAlBf;EAoB7B,OAAA;EAdO;EAgBP,KAAA,EAAO,SAAA;EAZgC;EAcvC,MAAA,EAAQ,UAAA,QAAkB,aAAA,CAAc,YAAA;EAdjC;EAgBP,QAAA,EAAU,UAAA,QAAkB,aAAA,CAAc,YAAA;EAdpB;EAgBtB,GAAA,EAAK,UAAA,QAAkB,aAAA,CAAc,YAAA;EAdd;EAgBvB,QAAA;EAde;EAgBf,UAAA,EAAY,UAAA,QAAkB,cAAA,CAAe,YAAA;EAdhB;EAgB7B,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BW,eAAA,wBACU,WAAA,GAAc,WAAA,sBAGnC,MAAA,EAAQ,qBAAA,CAAsB,YAAA,EAAc,QAAA,MAC3C,qBAAA,CAAsB,YAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as InputValueTransform } from "./useInputValueTransform-CdoaxNyD.js";
|
|
2
2
|
import { r as useController$1 } from "./useController-Cc0UNQMm.js";
|
|
3
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
3
|
+
import { n as useFormContext$1 } from "./useFormContext-DEMm-bsc.js";
|
|
4
4
|
import { t as useInput } from "./useInput-C_fY--wx.js";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FieldError, FieldValues, Path } from "react-hook-form";
|
|
@@ -95,4 +95,4 @@ interface UseUniformFieldReturn<TFieldValues extends FieldValues = FieldValues>
|
|
|
95
95
|
declare const useUniformField: <TFieldValues extends FieldValues = FieldValues, TDisplay = unknown>(params: UseUniformFieldParams<TFieldValues, TDisplay>) => UseUniformFieldReturn<TFieldValues>;
|
|
96
96
|
//#endregion
|
|
97
97
|
export { UseUniformFieldReturn as n, useUniformField as r, UseUniformFieldParams as t };
|
|
98
|
-
//# sourceMappingURL=useUniformField-
|
|
98
|
+
//# sourceMappingURL=useUniformField-iHk8xYXN.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformField-
|
|
1
|
+
{"version":3,"file":"useUniformField-iHk8xYXN.d.ts","names":[],"sources":["../src/hooks/useUniformField/useUniformField.tsx"],"mappings":";;;;;;;;UAgBiB,qBAAA,sBACM,WAAA,GAAc,WAAA;;EAInC,IAAA,EAAM,IAAA,CAAK,YAAA;EALyB;EAOpC,SAAA;EANqB;EAQrB,QAAA;EAJW;EAMX,KAAA,GAAQ,SAAA;EAAA;EAER,MAAA;EAEY;EAAZ,SAAA,GAAY,mBAAA,CAAoB,QAAA;EAAD;EAE/B,IAAA;AAAA;AAAA,UAGe,qBAAA,sBACM,WAAA,GAAc,WAAA;EAnBnC;EAsBA,SAAA;EAnBM;EAqBN,OAAA,EAAS,UAAA,QAAkB,gBAAA,CAAe,YAAA;EAnB1C;EAqBA,SAAA,EAAW,UAAA,QAAkB,gBAAA,CAAe,YAAA;EAjB5C;EAmBA,YAAA;EAjBA;EAmBA,QAAA;EAjBY;EAmBZ,KAAA,EAAO,UAAA;EAjBP;EAmBA,YAAA,EAAc,SAAA;EAnBV;EAqBJ,KAAA,EAAO,UAAA,QAAkB,eAAA,CAAc,YAAA;EAlBH;EAoBpC,oBAAA,EAAsB,UAAA,QAAkB,QAAA;EAnBnB;EAqBrB,qBAAA,EAAuB,UAAA,QAAkB,QAAA;EAhBC;EAkB1C,aAAA,EAAe,UAAA,QAAkB,QAAA;EAlBxB;EAoBT,SAAA,EAAW,UAAA,QAAkB,gBAAA,CAAe,YAAA;EAlBf;EAoB7B,OAAA;EAdO;EAgBP,KAAA,EAAO,SAAA;EAZgC;EAcvC,MAAA,EAAQ,UAAA,QAAkB,eAAA,CAAc,YAAA;EAdjC;EAgBP,QAAA,EAAU,UAAA,QAAkB,eAAA,CAAc,YAAA;EAdpB;EAgBtB,GAAA,EAAK,UAAA,QAAkB,eAAA,CAAc,YAAA;EAdd;EAgBvB,QAAA;EAde;EAgBf,UAAA,EAAY,UAAA,QAAkB,gBAAA,CAAe,YAAA;EAdhB;EAgB7B,MAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BW,eAAA,wBACU,WAAA,GAAc,WAAA,sBAGnC,MAAA,EAAQ,qBAAA,CAAsB,YAAA,EAAc,QAAA,MAC3C,qBAAA,CAAsB,YAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useController$1 } from "./useController-Cc0UNQMm.js";
|
|
2
|
-
import { n as useFormContext$1 } from "./useFormContext-
|
|
2
|
+
import { n as useFormContext$1 } from "./useFormContext-DEMm-bsc.js";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as _$react_hook_form0 from "react-hook-form";
|
|
5
5
|
import { ArrayPath, FieldValues } from "react-hook-form";
|
|
@@ -76,4 +76,4 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
78
|
export { useUniformFieldArray as n, UseUniformFieldArrayProps as t };
|
|
79
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
79
|
+
//# sourceMappingURL=useUniformFieldArray-B0SPtHeT.d.ts.map
|
package/dist/{useUniformFieldArray-CMHoo4o3.d.ts.map → useUniformFieldArray-B0SPtHeT.d.ts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-B0SPtHeT.d.ts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"mappings":";;;;;;;;UAYiB,yBAAA,sBACM,WAAA,GAAc,WAAA;;EAGnC,IAAA,EAAM,SAAA,CAAU,YAAA;;EAEhB,IAAA;;EAEA,mBAAA;EARe;EAUf,uBAAA;EAVwC;EAYxC,QAAA;EAXmC;EAanC,MAAA;EAVM;EAYN,KAAA,GAAQ,SAAA;AAAA;;;;;;;;;;;;;cAeG,oBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,IAAA;EAAA,IAAA;EAAA,mBAAA,EAAA,oBAAA;EAAA,uBAAA;EAAA,QAAA;EAAA,MAAA,EAAA,cAAA;EAAA;AAAA,GAQC,yBAAA,CAA0B,YAAA;;;;;;;;;kBAhC+B,KAAA;;;;;;;;;UAqExB,UAAA;YAEX,UAAA,QAFW,eAAA;OAKzB,UAAA,QAHc,eAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as useController } from "./useController-CNiqy_2D.cjs";
|
|
2
|
-
import { n as useFormContext } from "./useFormContext-
|
|
2
|
+
import { n as useFormContext } from "./useFormContext-Dey5DbWr.cjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
import * as _$react_hook_form0 from "react-hook-form";
|
|
5
5
|
import { ArrayPath, FieldValues } from "react-hook-form";
|
|
@@ -76,4 +76,4 @@ declare const useUniformFieldArray: <TFieldValues extends FieldValues = FieldVal
|
|
|
76
76
|
};
|
|
77
77
|
//#endregion
|
|
78
78
|
export { useUniformFieldArray as n, UseUniformFieldArrayProps as t };
|
|
79
|
-
//# sourceMappingURL=useUniformFieldArray-
|
|
79
|
+
//# sourceMappingURL=useUniformFieldArray-okvikMJp.d.cts.map
|
package/dist/{useUniformFieldArray-CDEagafl.d.cts.map → useUniformFieldArray-okvikMJp.d.cts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUniformFieldArray-
|
|
1
|
+
{"version":3,"file":"useUniformFieldArray-okvikMJp.d.cts","names":[],"sources":["../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"mappings":";;;;;;;;UAYiB,yBAAA,sBACM,WAAA,GAAc,WAAA;;EAGnC,IAAA,EAAM,SAAA,CAAU,YAAA;;EAEhB,IAAA;;EAEA,mBAAA;EARe;EAUf,uBAAA;EAVwC;EAYxC,QAAA;EAXmC;EAanC,MAAA;EAVM;EAYN,KAAA,GAAQ,SAAA;AAAA;;;;;;;;;;;;;cAeG,oBAAA,wBACU,WAAA,GAAc,WAAA;EACnC,IAAA;EAAA,IAAA;EAAA,mBAAA,EAAA,oBAAA;EAAA,uBAAA;EAAA,QAAA;EAAA,MAAA,EAAA,cAAA;EAAA;AAAA,GAQC,yBAAA,CAA0B,YAAA;;;;;;;;;kBAhC+B,KAAA;;;;;;;;;UAqExB,UAAA;YAEX,UAAA,QAFW,aAAA;OAKzB,UAAA,QAHc,aAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require("./FormContext-
|
|
2
|
-
const require_useFormContext = require("./useFormContext-
|
|
1
|
+
require("./FormContext-BrY1FQYR.cjs");
|
|
2
|
+
const require_useFormContext = require("./useFormContext-Bum4VP1o.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/hooks/useWatchUserChange/useWatchUserChange.ts
|
|
5
5
|
/**
|
|
@@ -87,4 +87,4 @@ Object.defineProperty(exports, "useWatchUserChange", {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
//# sourceMappingURL=useWatchUserChange-
|
|
90
|
+
//# sourceMappingURL=useWatchUserChange-CBuIa5kU.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWatchUserChange-
|
|
1
|
+
{"version":3,"file":"useWatchUserChange-CBuIa5kU.cjs","names":["useFormContext"],"sources":["../src/hooks/useWatchUserChange/useWatchUserChange.ts"],"sourcesContent":["import type {\n FieldValues,\n Path,\n UseFormReset,\n UseFormResetField,\n UseFormSetValue,\n} from 'react-hook-form';\n\nimport { useEffect } from 'react';\n\nimport { useFormContext } from '../useFormContext/useFormContext';\n\nexport interface UseWatchUserChangeOptions<TFieldValues extends FieldValues> {\n /** Field name to watch for user changes */\n watch: Path<TFieldValues>;\n /**\n * Callback when watched field is changed by user input.\n * Receives the new value and form helpers (setValue, resetField, reset).\n */\n onChange: (\n value: unknown,\n helpers: {\n setValue: UseFormSetValue<TFieldValues>;\n resetField: UseFormResetField<TFieldValues>;\n reset: UseFormReset<TFieldValues>;\n },\n ) => void;\n}\n\n/**\n * Hook that watches for user changes on a specific form field.\n *\n * Only triggers on manual user input (typing, clicking, selecting),\n * NOT on programmatic changes like form.reset() or form.setValue().\n * Also does NOT trigger when selecting the same value (e.g., clicking\n * an already-selected option in a Select).\n *\n * This hook subscribes to field changes at the source (useController),\n * ensuring immediate and accurate detection of user interactions.\n *\n * Use cases:\n * - Reset dependent fields when parent field changes\n * - Set mode-specific default values when a toggle changes\n * - Clear form sections based on user selections\n * - Trigger side effects only on user interaction\n *\n * Note: To watch multiple fields, call this hook multiple times.\n *\n * @example\n * ```tsx\n * // Reset city and address when user changes country\n * useWatchUserChange({\n * watch: 'country',\n * onChange: (value, { resetField }) => {\n * resetField('city');\n * resetField('address');\n * },\n * });\n *\n * // Set defaults when user changes payment method\n * useWatchUserChange({\n * watch: 'paymentMethod',\n * onChange: (value, { setValue }) => {\n * if (value === 'credit') {\n * setValue('installments', 3);\n * } else {\n * setValue('installments', 1);\n * }\n * },\n * });\n *\n * // Watch multiple fields by calling the hook multiple times\n * useWatchUserChange({\n * watch: 'category',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * useWatchUserChange({\n * watch: 'brand',\n * onChange: (value, { resetField }) => {\n * resetField('productId');\n * },\n * });\n * ```\n */\nexport const useWatchUserChange = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n watch: watchField,\n onChange,\n}: UseWatchUserChangeOptions<TFieldValues>) => {\n const { setValue, resetField, reset, userChange } =\n useFormContext<TFieldValues>();\n\n useEffect(() => {\n // Create listener that checks if changed field is the one we're watching\n const listener = (fieldName: Path<TFieldValues>, value: unknown) => {\n // Check if this is the field we're watching\n if (fieldName === watchField) {\n // Call the onChange callback with helpers\n onChange(value, { setValue, resetField, reset });\n }\n };\n\n // Subscribe to user changes\n const unsubscribe = userChange.subscribe(listener);\n\n // Cleanup on unmount\n return unsubscribe;\n }, [watchField, onChange, setValue, resetField, reset, userChange]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,MAAa,sBAEX,EACA,OAAO,YACP,eAC6C;CAC7C,MAAM,EAAE,UAAU,YAAY,OAAO,eACnCA,uBAAAA,gBAA8B;AAEhC,EAAA,GAAA,MAAA,iBAAgB;EAEd,MAAM,YAAY,WAA+B,UAAmB;AAElE,OAAI,cAAc,WAEhB,UAAS,OAAO;IAAE;IAAU;IAAY;IAAO,CAAC;;AAQpD,SAHoB,WAAW,UAAU,SAAS;IAIjD;EAAC;EAAY;EAAU;EAAU;EAAY;EAAO;EAAW,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuf-stack/uniform",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.2",
|
|
4
4
|
"description": "fuf react form library",
|
|
5
5
|
"author": "Fröhlich ∧ Frei",
|
|
6
6
|
"homepage": "https://github.com/fuf-stack/pixels#readme",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"@fuf-stack/pixel-motion": "1.2.0",
|
|
157
157
|
"@fuf-stack/pixel-utils": "1.2.0",
|
|
158
158
|
"@fuf-stack/pixels": "1.9.0",
|
|
159
|
-
"@fuf-stack/veto": "0.
|
|
159
|
+
"@fuf-stack/veto": "1.0.1",
|
|
160
160
|
"@heroui/button": "2.2.24",
|
|
161
161
|
"@heroui/checkbox": "2.3.24",
|
|
162
162
|
"@heroui/input": "2.4.25",
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
"@heroui/switch": "2.2.22",
|
|
168
168
|
"@heroui/system": "2.4.20",
|
|
169
169
|
"@heroui/theme": "2.4.20",
|
|
170
|
-
"@react-aria/visually-hidden": "3.
|
|
170
|
+
"@react-aria/visually-hidden": "3.9.0",
|
|
171
171
|
"debug": "4.4.3",
|
|
172
172
|
"framer-motion": "12.38.0",
|
|
173
173
|
"react-hook-form": "7.72.1",
|
|
@@ -178,12 +178,12 @@
|
|
|
178
178
|
"@types/debug": "4.1.13",
|
|
179
179
|
"@types/react": "19.2.14",
|
|
180
180
|
"@types/react-dom": "19.2.3",
|
|
181
|
-
"react": "19.2.
|
|
182
|
-
"react-dom": "19.2.
|
|
181
|
+
"react": "19.2.5",
|
|
182
|
+
"react-dom": "19.2.5"
|
|
183
183
|
},
|
|
184
184
|
"inlinedDependencies": {
|
|
185
185
|
"tailwind-merge": "3.3.1",
|
|
186
186
|
"tailwind-variants": "2.0.1"
|
|
187
187
|
},
|
|
188
|
-
"gitHead": "
|
|
188
|
+
"gitHead": "7e8219605dcfdc360fc2ee37b0f12ce0a47e41a3"
|
|
189
189
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useClientValidation-Bu3mNZpf.d.cts","names":[],"sources":["../src/hooks/useClientValidation/useClientValidation.ts"],"mappings":";;;;;;;AAkEA;;;;;;;;;;;;;;;;;;;AAkIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAlIa,mBAAA,oBACX,IAAA,EAAM,KAAA,qBACN,aAAA,GAAgB,IAAA,EAAM,KAAA,KAAU,WAAA,EAChC,OAAA;EAAY,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+HD,4BAAA,aAA0C,WAAA,EACrD,IAAA,UACA,WAAA,EAAa,CAAA,KAAC,wCAAA,CAAA,CAAA"}
|