@fuf-stack/uniform 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/Checkboxes/index.cjs +6 -6
  2. package/dist/Checkboxes/index.js +5 -5
  3. package/dist/FieldArray/index.cjs +6 -6
  4. package/dist/FieldArray/index.js +5 -5
  5. package/dist/Form/index.cjs +6 -6
  6. package/dist/Form/index.js +5 -5
  7. package/dist/Input/index.cjs +6 -6
  8. package/dist/Input/index.js +5 -5
  9. package/dist/RadioBoxes/index.cjs +6 -6
  10. package/dist/RadioBoxes/index.js +5 -5
  11. package/dist/RadioTabs/index.cjs +6 -6
  12. package/dist/RadioTabs/index.js +5 -5
  13. package/dist/Radios/index.cjs +6 -6
  14. package/dist/Radios/index.js +5 -5
  15. package/dist/Select/index.cjs +6 -6
  16. package/dist/Select/index.d.cts +2 -2
  17. package/dist/Select/index.d.ts +2 -2
  18. package/dist/Select/index.js +5 -5
  19. package/dist/SubmitButton/index.cjs +6 -6
  20. package/dist/SubmitButton/index.js +5 -5
  21. package/dist/Switch/index.cjs +6 -6
  22. package/dist/Switch/index.d.cts +2 -2
  23. package/dist/Switch/index.d.ts +2 -2
  24. package/dist/Switch/index.js +5 -5
  25. package/dist/TextArea/index.cjs +6 -6
  26. package/dist/TextArea/index.js +5 -5
  27. package/dist/{chunk-NZBO4N3S.cjs → chunk-42NCLEX4.cjs} +5 -4
  28. package/dist/chunk-42NCLEX4.cjs.map +1 -0
  29. package/dist/{chunk-SJZ7UUEE.js → chunk-46FKQWMF.js} +3 -3
  30. package/dist/{chunk-E4DCVJS5.cjs → chunk-4ATOAQOF.cjs} +3 -3
  31. package/dist/{chunk-E4DCVJS5.cjs.map → chunk-4ATOAQOF.cjs.map} +1 -1
  32. package/dist/{chunk-BXGILW5C.js → chunk-4RIJJ5AV.js} +2 -2
  33. package/dist/{chunk-345LYO4H.cjs → chunk-4Z7LIJHZ.cjs} +3 -3
  34. package/dist/{chunk-345LYO4H.cjs.map → chunk-4Z7LIJHZ.cjs.map} +1 -1
  35. package/dist/{chunk-WFO4XPA3.cjs → chunk-5BH5XTVC.cjs} +4 -4
  36. package/dist/{chunk-WFO4XPA3.cjs.map → chunk-5BH5XTVC.cjs.map} +1 -1
  37. package/dist/{chunk-MXUKW3PZ.js → chunk-65UJEB4P.js} +2 -2
  38. package/dist/{chunk-F6JQYB53.cjs → chunk-7NZVPVK3.cjs} +3 -3
  39. package/dist/{chunk-F6JQYB53.cjs.map → chunk-7NZVPVK3.cjs.map} +1 -1
  40. package/dist/{chunk-IYULWK4H.cjs → chunk-A2LFA4A7.cjs} +6 -6
  41. package/dist/{chunk-IYULWK4H.cjs.map → chunk-A2LFA4A7.cjs.map} +1 -1
  42. package/dist/{chunk-QRCV7JVB.js → chunk-AAGOHXSZ.js} +2 -2
  43. package/dist/{chunk-TEIXBRF5.cjs → chunk-D3EZXJQH.cjs} +14 -5
  44. package/dist/chunk-D3EZXJQH.cjs.map +1 -0
  45. package/dist/{chunk-D3NAUOYG.js → chunk-D3JYMGTB.js} +2 -2
  46. package/dist/{chunk-Z7FVILDT.js → chunk-FZQDAI7E.js} +3 -3
  47. package/dist/{chunk-NZIAIYPS.cjs → chunk-HANR2BDX.cjs} +3 -3
  48. package/dist/{chunk-NZIAIYPS.cjs.map → chunk-HANR2BDX.cjs.map} +1 -1
  49. package/dist/{chunk-JKWNYLNS.js → chunk-HBVHOUAR.js} +2 -2
  50. package/dist/{chunk-RMCPVDAC.cjs → chunk-HEGORLRF.cjs} +3 -3
  51. package/dist/{chunk-RMCPVDAC.cjs.map → chunk-HEGORLRF.cjs.map} +1 -1
  52. package/dist/{chunk-XJBGXFVX.cjs → chunk-HX2JJ2ZK.cjs} +3 -3
  53. package/dist/{chunk-XJBGXFVX.cjs.map → chunk-HX2JJ2ZK.cjs.map} +1 -1
  54. package/dist/{chunk-HQGTCSHK.js → chunk-I5RBXUIV.js} +2 -2
  55. package/dist/{chunk-GUPJNFEX.js → chunk-IK5IWKUC.js} +2 -2
  56. package/dist/{chunk-AACO4OEK.cjs → chunk-MOVNWZX5.cjs} +5 -5
  57. package/dist/{chunk-AACO4OEK.cjs.map → chunk-MOVNWZX5.cjs.map} +1 -1
  58. package/dist/{chunk-TKFODQWI.js → chunk-NM66XFQH.js} +2 -2
  59. package/dist/{chunk-H24QXVUI.js → chunk-NUGEM725.js} +2 -2
  60. package/dist/{chunk-PO5UQAU6.js → chunk-NZ54JBSR.js} +5 -4
  61. package/dist/chunk-NZ54JBSR.js.map +1 -0
  62. package/dist/{chunk-OJHD2XHD.cjs → chunk-PC3VCEGM.cjs} +3 -3
  63. package/dist/{chunk-OJHD2XHD.cjs.map → chunk-PC3VCEGM.cjs.map} +1 -1
  64. package/dist/{chunk-A5Z75X7M.cjs → chunk-QAQ3UP7W.cjs} +3 -3
  65. package/dist/{chunk-A5Z75X7M.cjs.map → chunk-QAQ3UP7W.cjs.map} +1 -1
  66. package/dist/{chunk-CHNYQVWO.js → chunk-RI45RSNN.js} +13 -4
  67. package/dist/chunk-RI45RSNN.js.map +1 -0
  68. package/dist/{chunk-TGJJZEHB.cjs → chunk-SOQ6GCN3.cjs} +3 -3
  69. package/dist/{chunk-TGJJZEHB.cjs.map → chunk-SOQ6GCN3.cjs.map} +1 -1
  70. package/dist/{chunk-6C6YW5TM.js → chunk-T7S6RMCF.js} +2 -2
  71. package/dist/{chunk-Z7NI5347.js → chunk-TB5WXGWX.js} +2 -2
  72. package/dist/{chunk-VPUMTPD3.cjs → chunk-V3NNJJHY.cjs} +3 -3
  73. package/dist/{chunk-VPUMTPD3.cjs.map → chunk-V3NNJJHY.cjs.map} +1 -1
  74. package/dist/hooks/index.cjs +5 -5
  75. package/dist/hooks/index.js +4 -4
  76. package/dist/hooks/useClientValidation/index.cjs +3 -3
  77. package/dist/hooks/useClientValidation/index.d.cts +101 -32
  78. package/dist/hooks/useClientValidation/index.d.ts +101 -32
  79. package/dist/hooks/useClientValidation/index.js +2 -2
  80. package/dist/hooks/useFormContext/index.cjs +2 -2
  81. package/dist/hooks/useFormContext/index.d.cts +3 -2
  82. package/dist/hooks/useFormContext/index.d.ts +3 -2
  83. package/dist/hooks/useFormContext/index.js +1 -1
  84. package/dist/hooks/useUniformField/index.cjs +3 -3
  85. package/dist/hooks/useUniformField/index.js +2 -2
  86. package/dist/hooks/useUniformFieldArray/index.cjs +4 -4
  87. package/dist/hooks/useUniformFieldArray/index.js +3 -3
  88. package/dist/index.cjs +16 -16
  89. package/dist/index.d.cts +2 -2
  90. package/dist/index.d.ts +2 -2
  91. package/dist/index.js +15 -15
  92. package/package.json +3 -3
  93. package/dist/chunk-CHNYQVWO.js.map +0 -1
  94. package/dist/chunk-NZBO4N3S.cjs.map +0 -1
  95. package/dist/chunk-PO5UQAU6.js.map +0 -1
  96. package/dist/chunk-TEIXBRF5.cjs.map +0 -1
  97. package/dist/{Select-CDkZmZp2.d.cts → Select-BEHwvmOf.d.cts} +9 -9
  98. package/dist/{Select-CDkZmZp2.d.ts → Select-BEHwvmOf.d.ts} +9 -9
  99. package/dist/{Switch-Hr6PnK98.d.cts → Switch-BWu3JXl4.d.cts} +3 -3
  100. package/dist/{Switch-Hr6PnK98.d.ts → Switch-BWu3JXl4.d.ts} +3 -3
  101. /package/dist/{chunk-SJZ7UUEE.js.map → chunk-46FKQWMF.js.map} +0 -0
  102. /package/dist/{chunk-BXGILW5C.js.map → chunk-4RIJJ5AV.js.map} +0 -0
  103. /package/dist/{chunk-MXUKW3PZ.js.map → chunk-65UJEB4P.js.map} +0 -0
  104. /package/dist/{chunk-QRCV7JVB.js.map → chunk-AAGOHXSZ.js.map} +0 -0
  105. /package/dist/{chunk-D3NAUOYG.js.map → chunk-D3JYMGTB.js.map} +0 -0
  106. /package/dist/{chunk-Z7FVILDT.js.map → chunk-FZQDAI7E.js.map} +0 -0
  107. /package/dist/{chunk-JKWNYLNS.js.map → chunk-HBVHOUAR.js.map} +0 -0
  108. /package/dist/{chunk-HQGTCSHK.js.map → chunk-I5RBXUIV.js.map} +0 -0
  109. /package/dist/{chunk-GUPJNFEX.js.map → chunk-IK5IWKUC.js.map} +0 -0
  110. /package/dist/{chunk-TKFODQWI.js.map → chunk-NM66XFQH.js.map} +0 -0
  111. /package/dist/{chunk-H24QXVUI.js.map → chunk-NUGEM725.js.map} +0 -0
  112. /package/dist/{chunk-6C6YW5TM.js.map → chunk-T7S6RMCF.js.map} +0 -0
  113. /package/dist/{chunk-Z7NI5347.js.map → chunk-TB5WXGWX.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-VPUMTPD3.cjs","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"names":["jsx","_a","_b","RadioBoxes_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAA6C;AAE7C,oDAAkD;ADOlD;AACA;AEVA;AACA,6DAA+B;AAE/B;AAiCQ,+CAAA;AA1BD,IAAM,SAAA,EAAW,CAAC,EAAA,EAAA,GAA+C;AAA/C,EAAA,IAAA,GAAA,EAAA,EAAA,EAAE,EAAA,KAAA,EAAO,KAAA,EAblC,EAAA,EAayB,EAAA,EAAuB,MAAA,EAAA,yCAAA,EAAvB,EAAuB,CAArB,MAAA,CAAA,CAAA;AACzB,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA;AAAA,IACA,aAAA;AAAA,IACA,aAAA;AAAA,IACA,oBAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,EACF,EAAA,EAAI,6BAAA,KAAc,CAAA;AAElB,EAAA,uBACE,8BAAA;AAAA,IAAC,SAAA;AAAA,IAAA,6CAAA,8CAAA,CAAA,CAAA,EACK,YAAA,CAAa,CAAA,CAA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,CAAW,gBAAA;AAAA,IACzB,OAAA,EAAS,UAAA,CAAW;AAAA,EACtB,CAAA;AAEA,EAAA,uBACEA,6BAAAA;AAAA,IAAC,iBAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,UAAA;AAAA,MAGA,cAAA,EAAc,OAAA;AAAA,MACd,eAAA,EAAe,QAAA;AAAA,MACf,aAAA,EAAa,MAAA;AAAA,MACb,YAAA;AAAA,MACA,YAAA;AAAA,MACA,UAAA,EAAY,QAAA;AAAA,MACZ,SAAA,EAAW,OAAA;AAAA,MACX,UAAA,EAAY,QAAA;AAAA,MACZ,KAAA,EAAO,MAAA,kBAAQA,6BAAAA,QAAC,EAAA,EAAQ,QAAA,EAAA,MAAA,CAAM,EAAA,EAAY,IAAA;AAAA,MAC1C,IAAA;AAAA,MACA,MAAA;AAAA,MACA,WAAA,EAAa,OAAA,EAAS,aAAA,EAAe,UAAA;AAAA,MAEpC,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,GAAW;AAzH/B,QAAA,IAAAC,GAAAA,EAAAC,GAAAA;AA0HQ,QAAA,GAAA,CAAI,QAAA,GAAW,MAAA,EAAQ;AACrB,UAAA,MAAM,aAAA,EAAe,iCAAA;AAAA,YACnB,CAAA,EAAA;AACA,YAAA;AACF,UAAA;AACA,UAAA;AACG,YAAA;AAAA,YAAA;AAAA,cAAA;AAEa,cAAA;AACC,cAAA;AACO,cAAA;AACP,cAAA;AACoB,cAAA;AACjC,cAAA;AACc,cAAA;AAEU,YAAA;AATnB,YAAA;AAUP,UAAA;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADaM;AACA;AG5JNC;AH8JM;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-VPUMTPD3.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n//\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends HeroRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props);\n\n return (\n <Component\n {...getBaseProps()}\n className={cn(\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n <span {...getWrapperProps()}>\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {children ? <span {...getLabelProps()}>{children}</span> : null}\n {description ? (\n <span className=\"text-foreground opacity-70 text-small\">\n {description}\n </span>\n ) : null}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V3NNJJHY.cjs","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"names":["jsx","_a","_b","RadioBoxes_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACNA,sCAA6C;AAE7C,oDAAkD;ADOlD;AACA;AEVA;AACA,6DAA+B;AAE/B;AAiCQ,+CAAA;AA1BD,IAAM,SAAA,EAAW,CAAC,EAAA,EAAA,GAA+C;AAA/C,EAAA,IAAA,GAAA,EAAA,EAAA,EAAE,EAAA,KAAA,EAAO,KAAA,EAblC,EAAA,EAayB,EAAA,EAAuB,MAAA,EAAA,yCAAA,EAAvB,EAAuB,CAArB,MAAA,CAAA,CAAA;AACzB,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,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A;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADaM;AACA;AG5JNC;AH8JM;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-V3NNJJHY.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n//\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n itemBase: '',\n itemControl: 'bg-focus group-data-[invalid=true]:bg-danger',\n itemDescription: '',\n itemLabel: 'text-sm',\n itemLabelWrapper: '',\n itemWrapper:\n 'group-data-[invalid=true]:!border-danger [&:not(group-data-[invalid=\"true\"]):not(group-data-[selected=\"false\"])]:border-focus', // TODO: get rid of !.\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof radioBoxesVariants>;\ntype ClassName = TVClassName<typeof radioBoxesVariants>;\n\nexport interface RadioBoxesOption {\n /** Description of the value. Works with variant radioBox. */\n description?: ReactNode;\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: ReactNode;\n /** option icon */\n icon?: ReactNode;\n /** HTML data-testid attribute of the option */\n testId?: string;\n /** option value */\n value: string;\n}\n\nexport interface RadioBoxesProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** Determines if the Buttons are disabled or not. */\n disabled?: boolean;\n /** determines orientation of the Buttons. */\n inline?: boolean;\n /** Label displayed next to the RadioButton. */\n label?: ReactNode;\n /** Name the RadioButtons are registered at in HTML forms (react-hook-form). */\n name: string;\n /** Radio button configuration. */\n options: RadioBoxesOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * RadioBoxes component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst RadioBoxes = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadioBoxesProps) => {\n const {\n defaultValue,\n errorMessage,\n invalid,\n disabled,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radioBoxesVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n const itemClassNames = {\n base: classNames.itemBase,\n control: classNames.itemControl,\n description: classNames.itemDescription,\n label: classNames.itemLabel,\n labelWrapper: classNames.itemLabelWrapper,\n wrapper: classNames.itemWrapper,\n };\n\n return (\n <HeroRadioGroup\n ref={ref}\n classNames={classNames}\n // see HeroUI styles for group-data condition (data-invalid),\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/components/select/src/use-select.ts\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultValue={defaultValue as string}\n errorMessage={errorMessage}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label ? <legend>{label}</legend> : null}\n name={name}\n onBlur={onBlur}\n orientation={inline ? 'horizontal' : 'vertical'}\n >\n {options.map((option) => {\n if ('value' in option) {\n const optionTestId = slugify(\n `${testId}_option_${option.testId ?? option.value}`,\n { replaceDots: true },\n );\n return (\n <RadioBox\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </RadioBox>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default RadioBoxes;\n","import type { RadioProps as HeroRadioProps } from '@heroui/radio';\nimport type { ReactNode } from 'react';\n\nimport { useRadio } from '@heroui/radio';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn } from '@fuf-stack/pixel-utils';\n\ninterface RadioProps extends HeroRadioProps {\n /** icon for the option */\n icon?: ReactNode;\n}\n\nexport const RadioBox = ({ icon = undefined, ...props }: RadioProps) => {\n const {\n children,\n Component,\n description,\n getBaseProps,\n getControlProps,\n getInputProps,\n getLabelProps,\n getLabelWrapperProps,\n getWrapperProps,\n isDisabled,\n } = useRadio(props);\n\n return (\n <Component\n {...getBaseProps()}\n className={cn(\n 'group inline-flex flex-auto cursor-pointer items-center justify-between gap-4 rounded-lg border-2 border-default p-4 hover:bg-content2 data-[selected=true]:border-focus',\n {\n // disabled styles\n 'pointer-events-none opacity-disabled': isDisabled,\n },\n )}\n >\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n <span {...getWrapperProps()}>\n <span {...getControlProps()} />\n </span>\n {icon}\n <div\n {...getLabelWrapperProps()}\n className={cn(getLabelWrapperProps().className, 'grow')}\n >\n {children ? <span {...getLabelProps()}>{children}</span> : null}\n {description ? (\n <span className=\"text-foreground opacity-70 text-small\">\n {description}\n </span>\n ) : null}\n </div>\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"]}
@@ -7,10 +7,10 @@ var _chunkBZ5OMN4Ycjs = require('../chunk-BZ5OMN4Y.cjs');
7
7
  var _chunk4WYC2RBEcjs = require('../chunk-4WYC2RBE.cjs');
8
8
 
9
9
 
10
- var _chunkAACO4OEKcjs = require('../chunk-AACO4OEK.cjs');
10
+ var _chunkMOVNWZX5cjs = require('../chunk-MOVNWZX5.cjs');
11
11
 
12
12
 
13
- var _chunkTGJJZEHBcjs = require('../chunk-TGJJZEHB.cjs');
13
+ var _chunkSOQ6GCN3cjs = require('../chunk-SOQ6GCN3.cjs');
14
14
  require('../chunk-NHEZXA4H.cjs');
15
15
 
16
16
 
@@ -22,11 +22,11 @@ require('../chunk-OE5BOGGX.cjs');
22
22
 
23
23
 
24
24
 
25
- var _chunkTEIXBRF5cjs = require('../chunk-TEIXBRF5.cjs');
25
+ var _chunkD3EZXJQHcjs = require('../chunk-D3EZXJQH.cjs');
26
26
 
27
27
 
28
28
 
29
- var _chunkNZBO4N3Scjs = require('../chunk-NZBO4N3S.cjs');
29
+ var _chunk42NCLEX4cjs = require('../chunk-42NCLEX4.cjs');
30
30
  require('../chunk-Z353BLWI.cjs');
31
31
  require('../chunk-555JRYCS.cjs');
32
32
 
@@ -40,5 +40,5 @@ require('../chunk-555JRYCS.cjs');
40
40
 
41
41
 
42
42
 
43
- exports.checkFieldIsRequired = _chunkNZBO4N3Scjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkTEIXBRF5cjs.clientValidationSchemaByName; exports.useClientValidation = _chunkTEIXBRF5cjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunkNZBO4N3Scjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkTGJJZEHBcjs.useUniformField; exports.useUniformFieldArray = _chunkAACO4OEKcjs.useUniformFieldArray;
43
+ exports.checkFieldIsRequired = _chunk42NCLEX4cjs.checkFieldIsRequired; exports.clientValidationSchemaByName = _chunkD3EZXJQHcjs.clientValidationSchemaByName; exports.useClientValidation = _chunkD3EZXJQHcjs.useClientValidation; exports.useController = _chunkJMFDNTVCcjs.useController; exports.useFormContext = _chunk42NCLEX4cjs.useFormContext; exports.useInput = _chunkPCTYJUY7cjs.useInput; exports.useInputValueDebounce = _chunkBZ5OMN4Ycjs.useInputValueDebounce; exports.useInputValueTransform = _chunk4WYC2RBEcjs.useInputValueTransform; exports.useUniformField = _chunkSOQ6GCN3cjs.useUniformField; exports.useUniformFieldArray = _chunkMOVNWZX5cjs.useUniformFieldArray;
44
44
  //# sourceMappingURL=index.cjs.map
@@ -7,10 +7,10 @@ import {
7
7
  } from "../chunk-7KLFK2IT.js";
8
8
  import {
9
9
  useUniformFieldArray
10
- } from "../chunk-Z7FVILDT.js";
10
+ } from "../chunk-FZQDAI7E.js";
11
11
  import {
12
12
  useUniformField
13
- } from "../chunk-D3NAUOYG.js";
13
+ } from "../chunk-D3JYMGTB.js";
14
14
  import "../chunk-ELYGQTXB.js";
15
15
  import {
16
16
  useController
@@ -22,11 +22,11 @@ import "../chunk-NTDKZW4E.js";
22
22
  import {
23
23
  clientValidationSchemaByName,
24
24
  useClientValidation
25
- } from "../chunk-CHNYQVWO.js";
25
+ } from "../chunk-RI45RSNN.js";
26
26
  import {
27
27
  checkFieldIsRequired,
28
28
  useFormContext
29
- } from "../chunk-PO5UQAU6.js";
29
+ } from "../chunk-NZ54JBSR.js";
30
30
  import "../chunk-76KOVUDN.js";
31
31
  import "../chunk-K2V4ULA2.js";
32
32
  export {
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkTEIXBRF5cjs = require('../../chunk-TEIXBRF5.cjs');
5
- require('../../chunk-NZBO4N3S.cjs');
4
+ var _chunkD3EZXJQHcjs = require('../../chunk-D3EZXJQH.cjs');
5
+ require('../../chunk-42NCLEX4.cjs');
6
6
  require('../../chunk-Z353BLWI.cjs');
7
7
  require('../../chunk-555JRYCS.cjs');
8
8
 
9
9
 
10
10
 
11
- exports.clientValidationSchemaByName = _chunkTEIXBRF5cjs.clientValidationSchemaByName; exports.useClientValidation = _chunkTEIXBRF5cjs.useClientValidation;
11
+ exports.clientValidationSchemaByName = _chunkD3EZXJQHcjs.clientValidationSchemaByName; exports.useClientValidation = _chunkD3EZXJQHcjs.useClientValidation;
12
12
  //# sourceMappingURL=index.cjs.map
@@ -4,73 +4,142 @@ import { VetoTypeAny } from '@fuf-stack/veto';
4
4
  /**
5
5
  * Hook for adding dynamic client-side validation to forms.
6
6
  *
7
- * Automatically manages validation schema lifecycle: sets schema when data is provided,
8
- * clears schema when data is null/undefined, and cleans up on unmount.
7
+ * Client validation is used for context-dependent validation rules that require external data
8
+ * (e.g., checking if a username already exists). It complements base validation (passed to Form),
9
+ * which handles static rules like "required", min/max length, format, etc.
10
+ *
11
+ * **Typical pattern:**
12
+ * - Base validation: Static, always-on rules (required, format, length constraints)
13
+ * - Client validation: Dynamic rules based on external data (uniqueness, business logic)
14
+ * - Client schemas should use `.nullish()` to allow empty values (base validation handles "required")
9
15
  *
10
- * When the client validation schema changes, automatically re-validates all touched
11
- * fields to ensure they are validated against the new schema.
16
+ * Automatically manages validation schema lifecycle: sets schema when data is provided,
17
+ * clears schema when data is null/undefined, and cleans up on unmount. When the client
18
+ * validation schema changes, automatically re-validates all touched fields.
12
19
  *
13
20
  * @param data - Data to create validation schema from (or null/undefined to clear validation)
14
- * @param schemaFactory - Function that creates a validation schema from the data.
21
+ * @param schemaFactory - Function that creates a validation schema from the data. Schemas should typically use `.nullish()`.
22
+ * @param options - Optional configuration object
23
+ * @param options.key - Optional custom key for registration. Useful when multiple instances should share validation (e.g., in field arrays)
15
24
  *
16
25
  * @example
17
26
  * ```tsx
18
- * const { data: teamData } = useTeamQuery(teamId);
27
+ * // Base validation handles "required" and format
28
+ * const baseSchema = veto({ username: vt.string({ min: 3 }) });
19
29
  *
30
+ * // Client validation adds dynamic uniqueness check
31
+ * const { data: teamData } = useTeamQuery(teamId);
20
32
  * useClientValidation(teamData, (data) =>
21
- * vt.object({
22
- * username: vt.string().refine(
23
- * (value) => !data.existingUsers.includes(value),
24
- * { message: 'Username already exists' }
25
- * )
33
+ * vt.objectLoose({
34
+ * username: vt.string()
35
+ * .refine(
36
+ * (value) => !data.existingUsers.includes(value),
37
+ * { message: 'Username already exists' }
38
+ * )
39
+ * .nullish() // Allow empty - base validation handles "required"
26
40
  * })
27
41
  * );
28
42
  * ```
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // Using custom key in a field array to avoid multiple registrations
47
+ * fields.map((field, index) => (
48
+ * useClientValidation(
49
+ * userData,
50
+ * (data) => clientValidationSchemaByName(
51
+ * `items.${index}.name`,
52
+ * vt.string()
53
+ * .refine((val) => !data.forbidden.includes(val), { message: 'Name not allowed' })
54
+ * .nullish()
55
+ * ),
56
+ * { key: 'items-validation' } // All instances share the same key
57
+ * )
58
+ * ));
59
+ * ```
29
60
  */
30
- declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
61
+ declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny, options?: {
62
+ key?: string;
63
+ }) => void;
31
64
  /**
32
65
  * Helper function to create a veto looseObject schema for a single field with nested path support.
33
66
  *
34
67
  * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
35
68
  * All intermediate objects and arrays are marked as optional to allow partial data structures.
36
69
  * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
70
+ * Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
71
+ *
72
+ * **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
73
+ * - Base validation (passed to Form) handles "required" constraints
74
+ * - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
75
+ * - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
76
+ * - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
37
77
  *
38
- * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name')
39
- * @param fieldSchema - The veto validation schema for the field
78
+ * This pattern ensures client validation only validates non-empty values, while base validation
79
+ * enforces required fields and basic constraints (min length, format, etc.).
80
+ *
81
+ * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
82
+ * @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
40
83
  * @returns A nested loose object schema matching the field path structure with proper type inference
41
84
  *
42
85
  * @example
43
86
  * ```tsx
44
- * // Simple field
45
- * clientValidationSchemaByName('username', vt.string())
46
- * // => objectLoose({ username: vt.string() })
87
+ * // Typical usage: base validation handles "required", client validation adds dynamic rules
88
+ * // Base validation (in Form component)
89
+ * const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
90
+ *
91
+ * // Client validation (dynamic check for existing usernames)
92
+ * const { data: userData } = useUserQuery(userId);
93
+ * useClientValidation(userData, (data) =>
94
+ * clientValidationSchemaByName(
95
+ * 'username',
96
+ * vt.string()
97
+ * .refine(
98
+ * (value) => !data.existingUsernames.includes(value),
99
+ * { message: 'Username already taken' }
100
+ * )
101
+ * .nullish() // Allow empty - base validation handles "required"
102
+ * )
103
+ * );
47
104
  * ```
48
105
  *
49
106
  * @example
50
107
  * ```tsx
51
- * // Nested field (with optional intermediate objects)
52
- * clientValidationSchemaByName('user.profile.email', vt.string().email())
53
- * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: vt.string().email() }).optional() }).optional() })
108
+ * // Nested field path with dynamic validation
109
+ * clientValidationSchemaByName(
110
+ * 'user.profile.email',
111
+ * vt.string()
112
+ * .refine(
113
+ * (value) => !reservedEmails.includes(value),
114
+ * { message: 'This email is reserved' }
115
+ * )
116
+ * .nullish()
117
+ * )
118
+ * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
54
119
  * ```
55
120
  *
56
121
  * @example
57
122
  * ```tsx
58
- * // Array field (with optional array)
59
- * clientValidationSchemaByName('items.0.name', vt.string())
60
- * // => objectLoose({ items: array(objectLoose({ name: vt.string() })).optional() })
123
+ * // Array of objects with dynamic validation
124
+ * clientValidationSchemaByName(
125
+ * 'items.0.tag',
126
+ * vt.string()
127
+ * .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
128
+ * .nullish()
129
+ * )
130
+ * // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
61
131
  * ```
62
132
  *
63
133
  * @example
64
134
  * ```tsx
65
- * // Usage with useClientValidation
66
- * const { data: userData } = useUserQuery(userId);
67
- *
68
- * useClientValidation(userData, (data) =>
69
- * clientValidationSchemaByName('username', vt.string().refine(
70
- * (value) => !data.existingUsernames.includes(value),
71
- * { message: 'Username already taken' }
72
- * ))
73
- * );
135
+ * // Flat array (array of primitives) with dynamic validation
136
+ * clientValidationSchemaByName(
137
+ * 'tags.0.__FLAT__',
138
+ * vt.string()
139
+ * .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
140
+ * .nullish()
141
+ * )
142
+ * // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
74
143
  * ```
75
144
  */
76
145
  declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_CNPgNK_V.Z;
@@ -4,73 +4,142 @@ import { VetoTypeAny } from '@fuf-stack/veto';
4
4
  /**
5
5
  * Hook for adding dynamic client-side validation to forms.
6
6
  *
7
- * Automatically manages validation schema lifecycle: sets schema when data is provided,
8
- * clears schema when data is null/undefined, and cleans up on unmount.
7
+ * Client validation is used for context-dependent validation rules that require external data
8
+ * (e.g., checking if a username already exists). It complements base validation (passed to Form),
9
+ * which handles static rules like "required", min/max length, format, etc.
10
+ *
11
+ * **Typical pattern:**
12
+ * - Base validation: Static, always-on rules (required, format, length constraints)
13
+ * - Client validation: Dynamic rules based on external data (uniqueness, business logic)
14
+ * - Client schemas should use `.nullish()` to allow empty values (base validation handles "required")
9
15
  *
10
- * When the client validation schema changes, automatically re-validates all touched
11
- * fields to ensure they are validated against the new schema.
16
+ * Automatically manages validation schema lifecycle: sets schema when data is provided,
17
+ * clears schema when data is null/undefined, and cleans up on unmount. When the client
18
+ * validation schema changes, automatically re-validates all touched fields.
12
19
  *
13
20
  * @param data - Data to create validation schema from (or null/undefined to clear validation)
14
- * @param schemaFactory - Function that creates a validation schema from the data.
21
+ * @param schemaFactory - Function that creates a validation schema from the data. Schemas should typically use `.nullish()`.
22
+ * @param options - Optional configuration object
23
+ * @param options.key - Optional custom key for registration. Useful when multiple instances should share validation (e.g., in field arrays)
15
24
  *
16
25
  * @example
17
26
  * ```tsx
18
- * const { data: teamData } = useTeamQuery(teamId);
27
+ * // Base validation handles "required" and format
28
+ * const baseSchema = veto({ username: vt.string({ min: 3 }) });
19
29
  *
30
+ * // Client validation adds dynamic uniqueness check
31
+ * const { data: teamData } = useTeamQuery(teamId);
20
32
  * useClientValidation(teamData, (data) =>
21
- * vt.object({
22
- * username: vt.string().refine(
23
- * (value) => !data.existingUsers.includes(value),
24
- * { message: 'Username already exists' }
25
- * )
33
+ * vt.objectLoose({
34
+ * username: vt.string()
35
+ * .refine(
36
+ * (value) => !data.existingUsers.includes(value),
37
+ * { message: 'Username already exists' }
38
+ * )
39
+ * .nullish() // Allow empty - base validation handles "required"
26
40
  * })
27
41
  * );
28
42
  * ```
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // Using custom key in a field array to avoid multiple registrations
47
+ * fields.map((field, index) => (
48
+ * useClientValidation(
49
+ * userData,
50
+ * (data) => clientValidationSchemaByName(
51
+ * `items.${index}.name`,
52
+ * vt.string()
53
+ * .refine((val) => !data.forbidden.includes(val), { message: 'Name not allowed' })
54
+ * .nullish()
55
+ * ),
56
+ * { key: 'items-validation' } // All instances share the same key
57
+ * )
58
+ * ));
59
+ * ```
29
60
  */
30
- declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny) => void;
61
+ declare const useClientValidation: <TData = unknown>(data: TData | null | undefined, schemaFactory: (data: TData) => VetoTypeAny, options?: {
62
+ key?: string;
63
+ }) => void;
31
64
  /**
32
65
  * Helper function to create a veto looseObject schema for a single field with nested path support.
33
66
  *
34
67
  * Parses field paths (dot-notation) and creates properly nested loose object schemas with array support.
35
68
  * All intermediate objects and arrays are marked as optional to allow partial data structures.
36
69
  * Numeric segments in the path are treated as array indices, and the parent field is wrapped in an array schema.
70
+ * Supports flat arrays (arrays of primitives) via the special `__FLAT__` key.
71
+ *
72
+ * **Important:** The fieldSchema should typically use `.nullish()` to allow empty values. This is because:
73
+ * - Base validation (passed to Form) handles "required" constraints
74
+ * - Client validation adds dynamic, context-dependent rules (e.g., "username already exists")
75
+ * - Form data processing converts empty strings in flat arrays to `null` (not `undefined`)
76
+ * - `.nullish()` accepts both `null` and `undefined`, while `.optional()` only accepts `undefined`
37
77
  *
38
- * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name')
39
- * @param fieldSchema - The veto validation schema for the field
78
+ * This pattern ensures client validation only validates non-empty values, while base validation
79
+ * enforces required fields and basic constraints (min length, format, etc.).
80
+ *
81
+ * @param name - The dot-separated path to the field (e.g., 'username', 'user.profile.email', 'items.0.name', 'tags.0.__FLAT__')
82
+ * @param fieldSchema - The veto validation schema for the field. Should typically use `.nullish()` to allow empty values.
40
83
  * @returns A nested loose object schema matching the field path structure with proper type inference
41
84
  *
42
85
  * @example
43
86
  * ```tsx
44
- * // Simple field
45
- * clientValidationSchemaByName('username', vt.string())
46
- * // => objectLoose({ username: vt.string() })
87
+ * // Typical usage: base validation handles "required", client validation adds dynamic rules
88
+ * // Base validation (in Form component)
89
+ * const baseSchema = veto({ username: vt.string({ min: 3 }) }); // Required + min length
90
+ *
91
+ * // Client validation (dynamic check for existing usernames)
92
+ * const { data: userData } = useUserQuery(userId);
93
+ * useClientValidation(userData, (data) =>
94
+ * clientValidationSchemaByName(
95
+ * 'username',
96
+ * vt.string()
97
+ * .refine(
98
+ * (value) => !data.existingUsernames.includes(value),
99
+ * { message: 'Username already taken' }
100
+ * )
101
+ * .nullish() // Allow empty - base validation handles "required"
102
+ * )
103
+ * );
47
104
  * ```
48
105
  *
49
106
  * @example
50
107
  * ```tsx
51
- * // Nested field (with optional intermediate objects)
52
- * clientValidationSchemaByName('user.profile.email', vt.string().email())
53
- * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: vt.string().email() }).optional() }).optional() })
108
+ * // Nested field path with dynamic validation
109
+ * clientValidationSchemaByName(
110
+ * 'user.profile.email',
111
+ * vt.string()
112
+ * .refine(
113
+ * (value) => !reservedEmails.includes(value),
114
+ * { message: 'This email is reserved' }
115
+ * )
116
+ * .nullish()
117
+ * )
118
+ * // => objectLoose({ user: objectLoose({ profile: objectLoose({ email: ... }).optional() }).optional() })
54
119
  * ```
55
120
  *
56
121
  * @example
57
122
  * ```tsx
58
- * // Array field (with optional array)
59
- * clientValidationSchemaByName('items.0.name', vt.string())
60
- * // => objectLoose({ items: array(objectLoose({ name: vt.string() })).optional() })
123
+ * // Array of objects with dynamic validation
124
+ * clientValidationSchemaByName(
125
+ * 'items.0.tag',
126
+ * vt.string()
127
+ * .refine((value) => !forbiddenTags.includes(value), { message: 'Tag not allowed' })
128
+ * .nullish()
129
+ * )
130
+ * // => objectLoose({ items: array(objectLoose({ tag: ... })).optional() })
61
131
  * ```
62
132
  *
63
133
  * @example
64
134
  * ```tsx
65
- * // Usage with useClientValidation
66
- * const { data: userData } = useUserQuery(userId);
67
- *
68
- * useClientValidation(userData, (data) =>
69
- * clientValidationSchemaByName('username', vt.string().refine(
70
- * (value) => !data.existingUsernames.includes(value),
71
- * { message: 'Username already taken' }
72
- * ))
73
- * );
135
+ * // Flat array (array of primitives) with dynamic validation
136
+ * clientValidationSchemaByName(
137
+ * 'tags.0.__FLAT__',
138
+ * vt.string()
139
+ * .refine((value) => !forbiddenWords.includes(value), { message: 'Word not allowed' })
140
+ * .nullish()
141
+ * )
142
+ * // => objectLoose({ tags: array(vt.string().refine(...).nullish()).optional() })
74
143
  * ```
75
144
  */
76
145
  declare const clientValidationSchemaByName: <T extends VetoTypeAny>(name: string, fieldSchema: T) => _fuf_stack_veto_dist_types_d_CNPgNK_V.Z;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  clientValidationSchemaByName,
3
3
  useClientValidation
4
- } from "../../chunk-CHNYQVWO.js";
5
- import "../../chunk-PO5UQAU6.js";
4
+ } from "../../chunk-RI45RSNN.js";
5
+ import "../../chunk-NZ54JBSR.js";
6
6
  import "../../chunk-76KOVUDN.js";
7
7
  import "../../chunk-K2V4ULA2.js";
8
8
  export {
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkNZBO4N3Scjs = require('../../chunk-NZBO4N3S.cjs');
4
+ var _chunk42NCLEX4cjs = require('../../chunk-42NCLEX4.cjs');
5
5
  require('../../chunk-Z353BLWI.cjs');
6
6
  require('../../chunk-555JRYCS.cjs');
7
7
 
8
8
 
9
9
 
10
- exports.checkFieldIsRequired = _chunkNZBO4N3Scjs.checkFieldIsRequired; exports.useFormContext = _chunkNZBO4N3Scjs.useFormContext;
10
+ exports.checkFieldIsRequired = _chunk42NCLEX4cjs.checkFieldIsRequired; exports.useFormContext = _chunk42NCLEX4cjs.useFormContext;
11
11
  //# sourceMappingURL=index.cjs.map
@@ -24,12 +24,13 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
24
24
  getValues: react_hook_form.UseFormGetValues<TFieldValues>;
25
25
  subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
26
26
  watch: react_hook_form.UseFormWatch<TFieldValues>;
27
- debugMode: "debug" | "debug-testids" | "off" | "disabled";
27
+ debugMode: "disabled" | "debug" | "debug-testids" | "off";
28
28
  debugModeSettings?: DebugModeSettings;
29
29
  preventSubmit: (prevent: boolean) => void;
30
- setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
30
+ setDebugMode: (debugMode: "disabled" | "debug" | "debug-testids" | "off") => void;
31
31
  triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
32
32
  validation: {
33
+ baseInstance?: VetoInstance;
33
34
  instance?: VetoInstance;
34
35
  errors?: VetoFormattedError;
35
36
  setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
@@ -24,12 +24,13 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
24
24
  getValues: react_hook_form.UseFormGetValues<TFieldValues>;
25
25
  subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
26
26
  watch: react_hook_form.UseFormWatch<TFieldValues>;
27
- debugMode: "debug" | "debug-testids" | "off" | "disabled";
27
+ debugMode: "disabled" | "debug" | "debug-testids" | "off";
28
28
  debugModeSettings?: DebugModeSettings;
29
29
  preventSubmit: (prevent: boolean) => void;
30
- setDebugMode: (debugMode: "debug" | "debug-testids" | "off" | "disabled") => void;
30
+ setDebugMode: (debugMode: "disabled" | "debug" | "debug-testids" | "off") => void;
31
31
  triggerSubmit: (e?: React.BaseSyntheticEvent) => Promise<void> | void;
32
32
  validation: {
33
+ baseInstance?: VetoInstance;
33
34
  instance?: VetoInstance;
34
35
  errors?: VetoFormattedError;
35
36
  setClientValidationSchema: (key: string, schema: _fuf_stack_veto.VetoTypeAny | null) => void;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  checkFieldIsRequired,
3
3
  useFormContext
4
- } from "../../chunk-PO5UQAU6.js";
4
+ } from "../../chunk-NZ54JBSR.js";
5
5
  import "../../chunk-76KOVUDN.js";
6
6
  import "../../chunk-K2V4ULA2.js";
7
7
  export {
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTGJJZEHBcjs = require('../../chunk-TGJJZEHB.cjs');
3
+ var _chunkSOQ6GCN3cjs = require('../../chunk-SOQ6GCN3.cjs');
4
4
  require('../../chunk-NHEZXA4H.cjs');
5
5
  require('../../chunk-JMFDNTVC.cjs');
6
6
  require('../../chunk-PCTYJUY7.cjs');
7
7
  require('../../chunk-OE5BOGGX.cjs');
8
- require('../../chunk-NZBO4N3S.cjs');
8
+ require('../../chunk-42NCLEX4.cjs');
9
9
  require('../../chunk-Z353BLWI.cjs');
10
10
  require('../../chunk-555JRYCS.cjs');
11
11
 
12
12
 
13
- exports.useUniformField = _chunkTGJJZEHBcjs.useUniformField;
13
+ exports.useUniformField = _chunkSOQ6GCN3cjs.useUniformField;
14
14
  //# sourceMappingURL=index.cjs.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useUniformField
3
- } from "../../chunk-D3NAUOYG.js";
3
+ } from "../../chunk-D3JYMGTB.js";
4
4
  import "../../chunk-ELYGQTXB.js";
5
5
  import "../../chunk-CK362NWK.js";
6
6
  import "../../chunk-AHJJIANM.js";
7
7
  import "../../chunk-NTDKZW4E.js";
8
- import "../../chunk-PO5UQAU6.js";
8
+ import "../../chunk-NZ54JBSR.js";
9
9
  import "../../chunk-76KOVUDN.js";
10
10
  import "../../chunk-K2V4ULA2.js";
11
11
  export {
@@ -1,15 +1,15 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkAACO4OEKcjs = require('../../chunk-AACO4OEK.cjs');
4
- require('../../chunk-TGJJZEHB.cjs');
3
+ var _chunkMOVNWZX5cjs = require('../../chunk-MOVNWZX5.cjs');
4
+ require('../../chunk-SOQ6GCN3.cjs');
5
5
  require('../../chunk-NHEZXA4H.cjs');
6
6
  require('../../chunk-JMFDNTVC.cjs');
7
7
  require('../../chunk-PCTYJUY7.cjs');
8
8
  require('../../chunk-OE5BOGGX.cjs');
9
- require('../../chunk-NZBO4N3S.cjs');
9
+ require('../../chunk-42NCLEX4.cjs');
10
10
  require('../../chunk-Z353BLWI.cjs');
11
11
  require('../../chunk-555JRYCS.cjs');
12
12
 
13
13
 
14
- exports.useUniformFieldArray = _chunkAACO4OEKcjs.useUniformFieldArray;
14
+ exports.useUniformFieldArray = _chunkMOVNWZX5cjs.useUniformFieldArray;
15
15
  //# sourceMappingURL=index.cjs.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  useUniformFieldArray
3
- } from "../../chunk-Z7FVILDT.js";
4
- import "../../chunk-D3NAUOYG.js";
3
+ } from "../../chunk-FZQDAI7E.js";
4
+ import "../../chunk-D3JYMGTB.js";
5
5
  import "../../chunk-ELYGQTXB.js";
6
6
  import "../../chunk-CK362NWK.js";
7
7
  import "../../chunk-AHJJIANM.js";
8
8
  import "../../chunk-NTDKZW4E.js";
9
- import "../../chunk-PO5UQAU6.js";
9
+ import "../../chunk-NZ54JBSR.js";
10
10
  import "../../chunk-76KOVUDN.js";
11
11
  import "../../chunk-K2V4ULA2.js";
12
12
  export {