@fuf-stack/uniform 1.8.10 → 1.9.0

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 (126) hide show
  1. package/dist/Checkboxes/index.cjs +8 -8
  2. package/dist/Checkboxes/index.js +7 -7
  3. package/dist/FieldArray/index.cjs +8 -8
  4. package/dist/FieldArray/index.js +7 -7
  5. package/dist/Form/index.cjs +6 -6
  6. package/dist/Form/index.js +6 -6
  7. package/dist/Input/index.cjs +8 -8
  8. package/dist/Input/index.js +7 -7
  9. package/dist/{RadioBoxes-DpkI28l0.d.cts → RadioBox-B0s3q9g6.d.cts} +87 -37
  10. package/dist/{RadioBoxes-DpkI28l0.d.ts → RadioBox-B0s3q9g6.d.ts} +87 -37
  11. package/dist/RadioBoxes/index.cjs +10 -8
  12. package/dist/RadioBoxes/index.cjs.map +1 -1
  13. package/dist/RadioBoxes/index.d.cts +2 -2
  14. package/dist/RadioBoxes/index.d.ts +2 -2
  15. package/dist/RadioBoxes/index.js +11 -9
  16. package/dist/RadioTabs/index.cjs +8 -8
  17. package/dist/RadioTabs/index.d.cts +2 -2
  18. package/dist/RadioTabs/index.d.ts +2 -2
  19. package/dist/RadioTabs/index.js +7 -7
  20. package/dist/{RadioTabs-DTDcAZoH.d.cts → RadioTabs-D9Px3XEs.d.cts} +15 -0
  21. package/dist/{RadioTabs-DTDcAZoH.d.ts → RadioTabs-D9Px3XEs.d.ts} +15 -0
  22. package/dist/Radios/index.cjs +8 -8
  23. package/dist/Radios/index.js +7 -7
  24. package/dist/Select/index.cjs +8 -8
  25. package/dist/Select/index.js +7 -7
  26. package/dist/Slider/index.cjs +19 -0
  27. package/dist/Slider/index.cjs.map +1 -0
  28. package/dist/Slider/index.d.cts +10 -0
  29. package/dist/Slider/index.d.ts +10 -0
  30. package/dist/Slider/index.js +19 -0
  31. package/dist/Slider/index.js.map +1 -0
  32. package/dist/Slider-CIVhjJy1.d.cts +153 -0
  33. package/dist/Slider-CIVhjJy1.d.ts +153 -0
  34. package/dist/SubmitButton/index.cjs +6 -6
  35. package/dist/SubmitButton/index.js +6 -6
  36. package/dist/Switch/index.cjs +8 -8
  37. package/dist/Switch/index.d.cts +2 -2
  38. package/dist/Switch/index.d.ts +2 -2
  39. package/dist/Switch/index.js +7 -7
  40. package/dist/{Switch-Hr6PnK98.d.cts → Switch-CqBVdRJe.d.cts} +4 -4
  41. package/dist/{Switch-Hr6PnK98.d.ts → Switch-CqBVdRJe.d.ts} +4 -4
  42. package/dist/SwitchBox/index.cjs +26 -0
  43. package/dist/SwitchBox/index.cjs.map +1 -0
  44. package/dist/SwitchBox/index.d.cts +11 -0
  45. package/dist/SwitchBox/index.d.ts +11 -0
  46. package/dist/SwitchBox/index.js +26 -0
  47. package/dist/SwitchBox/index.js.map +1 -0
  48. package/dist/SwitchBox-q1I7a0NX.d.cts +146 -0
  49. package/dist/SwitchBox-q1I7a0NX.d.ts +146 -0
  50. package/dist/TextArea/index.cjs +8 -8
  51. package/dist/TextArea/index.js +7 -7
  52. package/dist/{chunk-EFZXZNJO.js → chunk-246OISWB.js} +2 -2
  53. package/dist/chunk-2OXNDD5W.cjs +162 -0
  54. package/dist/chunk-2OXNDD5W.cjs.map +1 -0
  55. package/dist/{chunk-BIC7IWER.js → chunk-7FOSZV75.js} +4 -4
  56. package/dist/{chunk-6AQ5R4U4.cjs → chunk-7O6LAGV2.cjs} +6 -6
  57. package/dist/{chunk-6AQ5R4U4.cjs.map → chunk-7O6LAGV2.cjs.map} +1 -1
  58. package/dist/{chunk-DUYZ7WW3.cjs → chunk-7WKVH43M.cjs} +78 -46
  59. package/dist/chunk-7WKVH43M.cjs.map +1 -0
  60. package/dist/{chunk-7WHL6K5T.js → chunk-CEVS6WSG.js} +2 -2
  61. package/dist/{chunk-R5AOS4DQ.js → chunk-CG7GDQAP.js} +2 -2
  62. package/dist/{chunk-QE4J4AMH.js → chunk-DQAZSXD6.js} +2 -2
  63. package/dist/chunk-FUMQULCR.cjs +215 -0
  64. package/dist/chunk-FUMQULCR.cjs.map +1 -0
  65. package/dist/{chunk-NG2KM4CA.cjs → chunk-IU4RL2D7.cjs} +3 -3
  66. package/dist/{chunk-NG2KM4CA.cjs.map → chunk-IU4RL2D7.cjs.map} +1 -1
  67. package/dist/{chunk-OTFX4BWZ.js → chunk-IZZTVGEW.js} +78 -46
  68. package/dist/chunk-IZZTVGEW.js.map +1 -0
  69. package/dist/{chunk-GRQVGEYI.js → chunk-JICFOKDO.js} +2 -2
  70. package/dist/{chunk-MEIT57H2.cjs → chunk-LTE7PW7F.cjs} +3 -3
  71. package/dist/{chunk-MEIT57H2.cjs.map → chunk-LTE7PW7F.cjs.map} +1 -1
  72. package/dist/chunk-LUO4I3TW.js +162 -0
  73. package/dist/chunk-LUO4I3TW.js.map +1 -0
  74. package/dist/{chunk-OYDNTOOU.cjs → chunk-MEYGGRBQ.cjs} +3 -3
  75. package/dist/{chunk-OYDNTOOU.cjs.map → chunk-MEYGGRBQ.cjs.map} +1 -1
  76. package/dist/{chunk-2UHJBGKV.js → chunk-MHQ2V7UW.js} +2 -2
  77. package/dist/{chunk-WWSJQUTT.cjs → chunk-SR76XJW4.cjs} +3 -3
  78. package/dist/{chunk-WWSJQUTT.cjs.map → chunk-SR76XJW4.cjs.map} +1 -1
  79. package/dist/chunk-THCIT66I.cjs +217 -0
  80. package/dist/chunk-THCIT66I.cjs.map +1 -0
  81. package/dist/chunk-UUGSI3FD.js +215 -0
  82. package/dist/chunk-UUGSI3FD.js.map +1 -0
  83. package/dist/{chunk-PFFTE4NW.cjs → chunk-V65AMUKK.cjs} +3 -3
  84. package/dist/{chunk-PFFTE4NW.cjs.map → chunk-V65AMUKK.cjs.map} +1 -1
  85. package/dist/chunk-VIV3MSIX.cjs +129 -0
  86. package/dist/chunk-VIV3MSIX.cjs.map +1 -0
  87. package/dist/chunk-XBVXMQBW.js +217 -0
  88. package/dist/chunk-XBVXMQBW.js.map +1 -0
  89. package/dist/{chunk-37RM7TVP.cjs → chunk-XC3C2W4M.cjs} +3 -3
  90. package/dist/{chunk-37RM7TVP.cjs.map → chunk-XC3C2W4M.cjs.map} +1 -1
  91. package/dist/chunk-XMCL3F4W.js +129 -0
  92. package/dist/chunk-XMCL3F4W.js.map +1 -0
  93. package/dist/{chunk-TN7OSO3T.js → chunk-XXLYUZY4.js} +3 -3
  94. package/dist/{chunk-ZNX2PT6C.cjs → chunk-YCCBMAN2.cjs} +4 -4
  95. package/dist/{chunk-ZNX2PT6C.cjs.map → chunk-YCCBMAN2.cjs.map} +1 -1
  96. package/dist/hooks/index.cjs +13 -13
  97. package/dist/hooks/index.cjs.map +1 -1
  98. package/dist/hooks/index.js +16 -16
  99. package/dist/hooks/useUniformField/index.cjs +4 -4
  100. package/dist/hooks/useUniformField/index.js +3 -3
  101. package/dist/hooks/useUniformFieldArray/index.cjs +5 -5
  102. package/dist/hooks/useUniformFieldArray/index.js +4 -4
  103. package/dist/index.cjs +34 -22
  104. package/dist/index.cjs.map +1 -1
  105. package/dist/index.d.cts +5 -3
  106. package/dist/index.d.ts +5 -3
  107. package/dist/index.js +38 -26
  108. package/package.json +13 -2
  109. package/dist/chunk-44STFB2F.cjs +0 -170
  110. package/dist/chunk-44STFB2F.cjs.map +0 -1
  111. package/dist/chunk-5ZMXUK6O.js +0 -170
  112. package/dist/chunk-5ZMXUK6O.js.map +0 -1
  113. package/dist/chunk-DUYZ7WW3.cjs.map +0 -1
  114. package/dist/chunk-HBPVEZJN.js +0 -105
  115. package/dist/chunk-HBPVEZJN.js.map +0 -1
  116. package/dist/chunk-OTFX4BWZ.js.map +0 -1
  117. package/dist/chunk-PEADXODY.cjs +0 -105
  118. package/dist/chunk-PEADXODY.cjs.map +0 -1
  119. /package/dist/{chunk-EFZXZNJO.js.map → chunk-246OISWB.js.map} +0 -0
  120. /package/dist/{chunk-BIC7IWER.js.map → chunk-7FOSZV75.js.map} +0 -0
  121. /package/dist/{chunk-7WHL6K5T.js.map → chunk-CEVS6WSG.js.map} +0 -0
  122. /package/dist/{chunk-R5AOS4DQ.js.map → chunk-CG7GDQAP.js.map} +0 -0
  123. /package/dist/{chunk-QE4J4AMH.js.map → chunk-DQAZSXD6.js.map} +0 -0
  124. /package/dist/{chunk-GRQVGEYI.js.map → chunk-JICFOKDO.js.map} +0 -0
  125. /package/dist/{chunk-2UHJBGKV.js.map → chunk-MHQ2V7UW.js.map} +0 -0
  126. /package/dist/{chunk-TN7OSO3T.js.map → chunk-XXLYUZY4.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MEIT57H2.cjs","../src/Radios/Radios.tsx","../src/Radios/index.ts"],"names":["_a","_b","Radios_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA;AACE;AACA;AAAc,sCACT;AAEP,oDAAkD;AA0G7B,+CAAA;AAtGd,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,aAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA,IACV,WAAA,EAAa,8CAAA;AAAA,IACb,eAAA,EAAiB,EAAA;AAAA,IACjB,SAAA,EAAW,SAAA;AAAA,IACX,gBAAA,EAAkB,EAAA;AAAA,IAClB,WAAA,EACE,+HAAA;AAAA;AAAA,IAEF,KAAA,EACE,qGAAA;AAAA,IACF,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AAsCD,IAAM,OAAA,EAAS,CAAC,EAAA,EAAA,GAMiB;AANjB,EAAA,IAAA,GAAA,EAAA,EAAA,EACd;AAAA,IAAA,UAAA,EAAY,KAAA,CAAA;AAAA,IACZ,OAAA,EAAS,KAAA;AAAA,IACT,IAAA;AAAA,IACA;AAAA,EAtEF,EAAA,EAkEgB,EAAA,EAKX,kBAAA,EAAA,yCAAA,EALW,EAKX;AAAA,IAJH,WAAA;AAAA,IACA,QAAA;AA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A,EAAS,aAAA,EAAe,UAAA;AAAA,MAEpC,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,GAAW;AAvH/B,QAAA,IAAAA,GAAAA,EAAAC,GAAAA;AAwHQ,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;AACoB,cAAA;AACjC,cAAA;AACc,cAAA;AAEU,YAAA;AAPnB,YAAA;AAQP,UAAA;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADrCM;AACA;AEtGNC;AFwGM;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MEIT57H2.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\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',\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 radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\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 | undefined}\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 <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-LTE7PW7F.cjs","../src/Radios/Radios.tsx","../src/Radios/index.ts"],"names":["_a","_b","Radios_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACLA;AACE;AACA;AAAc,sCACT;AAEP,oDAAkD;AA0G7B,+CAAA;AAtGd,IAAM,eAAA,EAAiB,4BAAA;AAAG,EAC/B,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,aAAA;AAAA,IACN,QAAA,EAAU,EAAA;AAAA,IACV,WAAA,EAAa,8CAAA;AAAA,IACb,eAAA,EAAiB,EAAA;AAAA,IACjB,SAAA,EAAW,SAAA;AAAA,IACX,gBAAA,EAAkB,EAAA;AAAA,IAClB,WAAA,EACE,+HAAA;AAAA;AAAA,IAEF,KAAA,EACE,qGAAA;AAAA,IACF,OAAA,EAAS;AAAA,EACX;AACF,CAAC,CAAA;AAsCD,IAAM,OAAA,EAAS,CAAC,EAAA,EAAA,GAMiB;AANjB,EAAA,IAAA,GAAA,EAAA,EAAA,EACd;AAAA,IAAA,UAAA,EAAY,KAAA,CAAA;AAAA,IACZ,OAAA,EAAS,KAAA;AAAA,IACT,IAAA;AAAA,IACA;AAAA,EAtEF,EAAA,EAkEgB,EAAA,EAKX,kBAAA,EAAA,yCAAA,EALW,EAKX;AAAA,IAJH,WAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;A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AAe,UAAA;AAAA,MAEpC,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,GAAW;AAvH/B,QAAA,IAAAA,GAAAA,EAAAC,GAAAA;AAwHQ,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;AACoB,cAAA;AACjC,cAAA;AACc,cAAA;AAEU,YAAA;AAPnB,YAAA;AAQP,UAAA;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;ADrCM;AACA;AEtGNC;AFwGM;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-LTE7PW7F.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport {\n Radio as HeroRadio,\n RadioGroup as HeroRadioGroup,\n} from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\n\nexport const radiosVariants = tv({\n slots: {\n // Needs group for group-data condition\n base: 'group gap-0',\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',\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 radiosVariants>;\ntype ClassName = TVClassName<typeof radiosVariants>;\n\nexport interface RadioOption {\n /** disables the option */\n disabled?: boolean;\n /** option label */\n label?: React.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 RadiosProps 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: RadioOption[];\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * Radios component based on [HeroUI RadioGroup](https://www.heroui.com//docs/components/radio-group)\n */\nconst Radios = ({\n className = undefined,\n inline = false,\n name,\n options,\n ...uniformFieldProps\n}: RadiosProps): ReactElement => {\n const {\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref },\n invalid,\n label,\n required,\n defaultValue,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // classNames from slots\n const variants = radiosVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\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 | undefined}\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 <HeroRadio\n key={option.value}\n classNames={itemClassNames}\n data-testid={optionTestId}\n isDisabled={!!disabled || option.disabled}\n onChange={onChange}\n value={option.value}\n >\n {option.label ?? option.value}\n </HeroRadio>\n );\n }\n return null;\n })}\n </HeroRadioGroup>\n );\n};\n\nexport default Radios;\n","import Radios from './Radios';\n\nexport type { RadiosProps } from './Radios';\n\nexport { Radios };\n\nexport default Radios;\n"]}
@@ -0,0 +1,162 @@
1
+ import {
2
+ useUniformField
3
+ } from "./chunk-7FOSZV75.js";
4
+ import {
5
+ __objRest,
6
+ __spreadProps,
7
+ __spreadValues
8
+ } from "./chunk-K2V4ULA2.js";
9
+
10
+ // src/Slider/Slider.tsx
11
+ import { useRef } from "react";
12
+ import { Slider as HeroUISlider } from "@heroui/slider";
13
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
14
+ import { tv, variantsToClassNames } from "@fuf-stack/pixel-utils";
15
+ import { jsx, jsxs } from "react/jsx-runtime";
16
+ var sliderVariants = tv({
17
+ slots: {
18
+ base: "group",
19
+ endContent: "",
20
+ errorMessage: "ml-1 mt-1",
21
+ filler: "",
22
+ // see HeroUI styles for group-data condition,
23
+ // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
24
+ label: 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-["*"]',
25
+ labelWrapper: "",
26
+ mark: "",
27
+ startContent: "",
28
+ step: "",
29
+ thumb: "",
30
+ track: "",
31
+ trackWrapper: "",
32
+ value: ""
33
+ }
34
+ });
35
+ var Slider = (_a) => {
36
+ var _b = _a, {
37
+ className = void 0,
38
+ endContent = void 0,
39
+ fillOffset = void 0,
40
+ name,
41
+ showSteps = false,
42
+ size = "md",
43
+ startContent = void 0,
44
+ step = 1,
45
+ minValue = 0,
46
+ maxValue = 100
47
+ } = _b, uniformFieldProps = __objRest(_b, [
48
+ "className",
49
+ "endContent",
50
+ "fillOffset",
51
+ "name",
52
+ "showSteps",
53
+ "size",
54
+ "startContent",
55
+ "step",
56
+ "minValue",
57
+ "maxValue"
58
+ ]);
59
+ const {
60
+ disabled,
61
+ field,
62
+ getErrorMessageProps,
63
+ getHelperWrapperProps,
64
+ invalid,
65
+ label,
66
+ onBlur,
67
+ onChange,
68
+ ref,
69
+ required,
70
+ errorMessage,
71
+ testId
72
+ } = useUniformField(__spreadValues({
73
+ name
74
+ }, uniformFieldProps));
75
+ const visualSliderRef = useRef(null);
76
+ const variants = sliderVariants();
77
+ const classNames = variantsToClassNames(variants, className, "base");
78
+ const currentValue = field.value != null ? Number(field.value) : minValue;
79
+ return /* @__PURE__ */ jsxs(
80
+ "div",
81
+ {
82
+ className: classNames.base,
83
+ "data-invalid": invalid,
84
+ "data-required": required,
85
+ "data-testid": testId,
86
+ children: [
87
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(
88
+ "input",
89
+ {
90
+ ref,
91
+ "aria-label": typeof label === "string" ? label : name,
92
+ disabled,
93
+ max: maxValue,
94
+ min: minValue,
95
+ name,
96
+ onBlur,
97
+ step,
98
+ tabIndex: -1,
99
+ type: "range",
100
+ value: currentValue,
101
+ onChange: (e) => {
102
+ onChange(Number(e.target.value));
103
+ },
104
+ onFocus: () => {
105
+ var _a2;
106
+ (_a2 = visualSliderRef.current) == null ? void 0 : _a2.focus();
107
+ }
108
+ }
109
+ ) }),
110
+ /* @__PURE__ */ jsx(
111
+ HeroUISlider,
112
+ {
113
+ ref: visualSliderRef,
114
+ color: invalid ? "danger" : "primary",
115
+ endContent,
116
+ fillOffset,
117
+ isDisabled: disabled,
118
+ label,
119
+ maxValue,
120
+ minValue,
121
+ name: `${name}_slider`,
122
+ showSteps,
123
+ size,
124
+ startContent,
125
+ step,
126
+ value: currentValue,
127
+ classNames: {
128
+ endContent: classNames.endContent,
129
+ filler: classNames.filler,
130
+ label: classNames.label,
131
+ labelWrapper: classNames.labelWrapper,
132
+ mark: classNames.mark,
133
+ startContent: classNames.startContent,
134
+ step: classNames.step,
135
+ thumb: classNames.thumb,
136
+ track: classNames.track,
137
+ trackWrapper: classNames.trackWrapper,
138
+ value: classNames.value
139
+ },
140
+ onChange: (value) => {
141
+ onChange(value);
142
+ },
143
+ onChangeEnd: (_value) => {
144
+ onBlur();
145
+ }
146
+ }
147
+ ),
148
+ /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getHelperWrapperProps()), { children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({}, getErrorMessageProps()), { children: errorMessage })) }))
149
+ ]
150
+ }
151
+ );
152
+ };
153
+ var Slider_default = Slider;
154
+
155
+ // src/Slider/index.ts
156
+ var Slider_default2 = Slider_default;
157
+
158
+ export {
159
+ Slider_default,
160
+ Slider_default2
161
+ };
162
+ //# sourceMappingURL=chunk-LUO4I3TW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/Slider/Slider.tsx","../src/Slider/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Slider as HeroUISlider } from '@heroui/slider';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField/useUniformField';\n\nexport const sliderVariants = tv({\n slots: {\n base: 'group',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n filler: '',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n labelWrapper: '',\n mark: '',\n startContent: '',\n step: '',\n thumb: '',\n track: '',\n trackWrapper: '',\n value: '',\n },\n});\n\ntype VariantProps = TVProps<typeof sliderVariants>;\ntype ClassName = TVClassName<typeof sliderVariants>;\n\nexport interface SliderProps extends VariantProps {\n /** CSS class name */\n className?: ClassName;\n /** input field is disabled */\n disabled?: boolean;\n /** Content to display at the end of the slider */\n endContent?: ReactNode;\n /** The offset from where the fill should start */\n fillOffset?: number;\n /** form field label (set to false to disable label) */\n label?: string | false;\n /** form field name */\n name: string;\n /**\n * Whether to show step dots on the slider\n * @default false\n */\n showSteps?: boolean;\n /**\n * The size of the slider\n * @default \"md\"\n */\n size?: 'sm' | 'md' | 'lg';\n /** Content to display at the start of the slider */\n startContent?: ReactNode;\n /**\n * The step value of the slider\n * @default 1\n */\n step?: number;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /**\n * The minimum value of the slider\n * @default 0\n */\n minValue?: number;\n /**\n * The maximum value of the slider\n * @default 100\n */\n maxValue?: number;\n}\n\n/**\n * Slider component based on [HeroUI Slider](https://www.heroui.com//docs/components/slider)\n */\nconst Slider = ({\n className = undefined,\n endContent = undefined,\n fillOffset = undefined,\n name,\n showSteps = false,\n size = 'md',\n startContent = undefined,\n step = 1,\n minValue = 0,\n maxValue = 100,\n ...uniformFieldProps\n}: SliderProps) => {\n const {\n disabled,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n errorMessage,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual slider to forward focus\n const visualSliderRef = useRef<HTMLDivElement>(null);\n\n // classNames from slots\n const variants = sliderVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // Get the current value, defaulting to minValue if null/undefined\n const currentValue = field.value != null ? Number(field.value) : minValue;\n\n return (\n <div\n className={classNames.base}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n disabled={disabled}\n max={maxValue}\n min={minValue}\n name={name}\n onBlur={onBlur}\n step={step}\n tabIndex={-1}\n type=\"range\"\n value={currentValue}\n onChange={(e) => {\n onChange(Number(e.target.value));\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual slider to show focus ring\n visualSliderRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroUISlider component */}\n <HeroUISlider\n ref={visualSliderRef}\n color={invalid ? 'danger' : 'primary'}\n endContent={endContent}\n fillOffset={fillOffset}\n isDisabled={disabled}\n label={label}\n maxValue={maxValue}\n minValue={minValue}\n name={`${name}_slider`}\n showSteps={showSteps}\n size={size}\n startContent={startContent}\n step={step}\n value={currentValue}\n classNames={{\n endContent: classNames.endContent,\n filler: classNames.filler,\n label: classNames.label,\n labelWrapper: classNames.labelWrapper,\n mark: classNames.mark,\n startContent: classNames.startContent,\n step: classNames.step,\n thumb: classNames.thumb,\n track: classNames.track,\n trackWrapper: classNames.trackWrapper,\n value: classNames.value,\n }}\n onChange={(value) => {\n onChange(value);\n }}\n onChangeEnd={(_value) => {\n onBlur();\n }}\n />\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n </div>\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { Slider };\n\nexport default Slider;\n"],"mappings":";;;;;;;;;;AAGA,SAAS,cAAc;AAEvB,SAAS,UAAU,oBAAoB;AACvC,SAAS,sBAAsB;AAE/B,SAAS,IAAI,4BAA4B;AAqHrC,SAQI,KARJ;AAjHG,IAAM,iBAAiB,GAAG;AAAA,EAC/B,OAAO;AAAA,IACL,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,QAAQ;AAAA;AAAA;AAAA,IAGR,OACE;AAAA,IACF,cAAc;AAAA,IACd,MAAM;AAAA,IACN,cAAc;AAAA,IACd,MAAM;AA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AAAA,YACA,SAAS,MAAM;AApJzB,kBAAAA;AAuJY,eAAAA,MAAA,gBAAgB,YAAhB,gBAAAA,IAAyB;AAAA,YAC3B;AAAA;AAAA,QACF,GACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,KAAK;AAAA,YACL,OAAO,UAAU,WAAW;AAAA,YAC5B;AAAA,YACA;AAAA,YACA,YAAY;AAAA,YACZ;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAM,GAAG,IAAI;AAAA,YACb;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,OAAO;AAAA,YACP,YAAY;AAAA,cACV,YAAY,WAAW;AAAA,cACvB,QAAQ,WAAW;AAAA,cACnB,OAAO,WAAW;AAAA,cAClB,cAAc,WAAW;AAAA,cACzB,MAAM,WAAW;AAAA,cACjB,cAAc,WAAW;AAAA,cACzB,MAAM,WAAW;AAAA,cACjB,OAAO,WAAW;AAAA,cAClB,OAAO,WAAW;AAAA,cAClB,cAAc,WAAW;AAAA,cACzB,OAAO,WAAW;AAAA,YACpB;AAAA,YACA,UAAU,CAAC,UAAU;AACnB,uBAAS,KAAK;AAAA,YAChB;AAAA,YACA,aAAa,CAAC,WAAW;AACvB,qBAAO;AAAA,YACT;AAAA;AAAA,QACF;AAAA,QACA,oBAAC,wCAAQ,sBAAsB,IAA9B,EACC,8BAAC,wCAAQ,qBAAqB,IAA7B,EAAiC,yBAAa,IACjD;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,iBAAQ;;;AChMf,IAAOC,kBAAQ;","names":["_a","Slider_default"]}
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkZNX2PT6Ccjs = require('./chunk-ZNX2PT6C.cjs');
3
+ var _chunkYCCBMAN2cjs = require('./chunk-YCCBMAN2.cjs');
4
4
 
5
5
 
6
6
  var _chunkUUGUQGMXcjs = require('./chunk-UUGUQGMX.cjs');
@@ -24,7 +24,7 @@ var useUniformFieldArray = ({
24
24
  testId: explicitTestId,
25
25
  label
26
26
  }) => {
27
- const uniformField = _chunkZNX2PT6Ccjs.useUniformField.call(void 0, {
27
+ const uniformField = _chunkYCCBMAN2cjs.useUniformField.call(void 0, {
28
28
  name,
29
29
  disabled,
30
30
  testId: explicitTestId,
@@ -100,4 +100,4 @@ var useUniformFieldArray = ({
100
100
 
101
101
 
102
102
  exports.useUniformFieldArray = useUniformFieldArray;
103
- //# sourceMappingURL=chunk-OYDNTOOU.cjs.map
103
+ //# sourceMappingURL=chunk-MEYGGRBQ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OYDNTOOU.cjs","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAqD;AACrD,gDAAkD;AAElD,sDAAiC;AAqC1B,IAAM,qBAAA,EAAuB,CAElC;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,KAAA;AAAA,EACP,mBAAA,EAAqB,qBAAA,EAAuB,IAAA;AAAA,EAC5C,wBAAA,EAA0B,KAAA;AAAA,EAC1B,QAAA;AAAA,EACA,MAAA,EAAQ,cAAA;AAAA,EACR;AACF,CAAA,EAAA,GAA+C;AAE7C,EAAA,MAAM,aAAA,EAAe,+CAAA;AAA8B,IACjD,IAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA,EAAQ,cAAA;AAAA,IACR;AAAA,EACF,CAAC,CAAA;AAED,EAAA,MAAM,EAAE,QAAQ,EAAA,EAAI,YAAA;AAEpB,EAAA,MAAM,EAAE,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,MAAA,EAAQ,KAAK,EAAA,EAAI,0CAAA;AAAiB,IAChE,OAAA;AAAA,IACA;AAAA,EACF,CAA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G,qBAAA,GAAA,KAAA,EAAA,qBAAA,EAAwB,KAAK,EAAA,EAC9C,qBAAA,GAAA,KAAA,EAAA,qBAAA,EAAwB,CAAC,CAAA;AAAA,EAChC,CAAA,EAAG,CAAC,IAAA,EAAM,oBAAoB,CAAC,CAAA;AAU/B,EAAA,8BAAA;AAAA,IACE,CAAA,EAAA,GAAM;AACJ,MAAA,GAAA,CAAI,eAAA,EAAiB;AAGnB,QAAA,QAAA,CAAS,IAAA,EAA4B,CAAC,mBAAmB,CAAA,EAAU;AAAA,UACjE,WAAA,EAAa,KAAA;AAAA,UACb,WAAA,EAAa;AAAA,QACf,CAAC,CAAA;AAGD,QAAA,cAAA,CAAe,QAAA,EAAU,IAAA;AAKzB,QAAA,GAAA,CAAI,CAAC,qBAAA,GAAwB,gBAAA,EAAkB;AAC7C,UAAA,UAAA,CAAW,CAAA,EAAA,GAAM;AACf,YAAA,mBAAA,CAAoB,KAAK,CAAA;AAAA,UAC3B,CAAA,EAAG,CAAC,CAAA;AAAA,QACN;AAAA,MACF;AAAA,IACF,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOA,CAAC,eAAe;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,8CAAA;AAAA;AAAA,IAEL,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;ADvFA;AACA;AACE;AACF,oDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-OYDNTOOU.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MEYGGRBQ.cjs","../src/hooks/useUniformFieldArray/useUniformFieldArray.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACVA,8BAAqD;AACrD,gDAAkD;AAElD,sDAAiC;AAqC1B,IAAM,qBAAA,EAAuB,CAElC;AAAA,EACA,IAAA;AAAA,EACA,KAAA,EAAO,KAAA;AAAA,EACP,mBAAA,EAAqB,qBAAA,EAAuB,IAAA;AAAA,EAC5C,wBAAA,EAA0B,KAAA;AAA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MAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,EAAA,CAAA,EAEG,YAAA,CAAA;AAEP,CAAA;ADvFA;AACA;AACE;AACF,oDAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-MEYGGRBQ.cjs","sourcesContent":[null,"import type { ReactNode } from 'react';\nimport type { ArrayPath, FieldValues, Path } from 'react-hook-form';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { useFieldArray as useRHFFieldArray } from 'react-hook-form';\n\nimport { useReducedMotion } from '@fuf-stack/pixel-motion';\n\nimport { flatArrayKey } from '../../helpers';\nimport { useFormContext } from '../useFormContext/useFormContext';\nimport { useUniformField } from '../useUniformField/useUniformField';\n\nexport interface UseUniformFieldArrayProps<\n TFieldValues extends FieldValues = FieldValues,\n> {\n /** Field name for the array */\n name: ArrayPath<TFieldValues>;\n /** Whether this is a flat array (array of primitives) */\n flat?: boolean;\n /** Initial value for new array elements */\n elementInitialValue?: unknown;\n /** Whether the last element cannot be removed (always maintain at least one element) */\n lastElementNotRemovable?: boolean;\n /** Disable the field */\n disabled?: boolean;\n /** Optional explicit test id used to build stable test ids */\n testId?: string;\n /** Optional label content; pass false to suppress label entirely */\n label?: ReactNode | false;\n}\n\n/**\n * Enhanced useFieldArray hook with initialization and animation logic.\n * Based on React Hook Form's useFieldArray with additional features:\n * - Automatic initialization when lastElementNotRemovable is set\n * - Animation control (disabled during initialization)\n * - Support for flat arrays (arrays of primitives)\n *\n * Note: Automatic validation triggering on length change is disabled to prevent\n * triggering form-wide validation. Array validation still runs on form submission.\n *\n * @see https://react-hook-form.com/docs/usefieldarray\n */\nexport const useUniformFieldArray = <\n TFieldValues extends FieldValues = FieldValues,\n>({\n name,\n flat = false,\n elementInitialValue: _elementInitialValue = null,\n lastElementNotRemovable = false,\n disabled,\n testId: explicitTestId,\n label,\n}: UseUniformFieldArrayProps<TFieldValues>) => {\n // Get uniform field state and utilities\n const uniformField = useUniformField<TFieldValues>({\n name: name as Path<TFieldValues> & string,\n disabled,\n testId: explicitTestId,\n label,\n });\n\n const { control } = uniformField;\n\n const { fields, append, remove, insert, move } = useRHFFieldArray({\n control,\n name,\n });\n\n const { trigger, setValue } = useFormContext<TFieldValues>();\n\n // Determine if initialization is needed (initially or after reset).\n // This flag automatically handles both scenarios:\n // - Initial mount: fields.length starts at 0\n // - Form reset: fields.length becomes 0 again\n // Additional initialization conditions can be added here later (e.g., minElements > 0)\n // Using useMemo ensures this value is properly tracked by React and effects can depend on it\n const needsInitialize = useMemo(() => {\n return lastElementNotRemovable && fields.length === 0;\n }, [lastElementNotRemovable, fields.length]);\n\n // Track whether initialization has completed. Initialized contextually:\n // - If initialization IS needed (needsInitialize = true): starts as false, set to true after init\n // - If initialization is NOT needed (needsInitialize = false): starts as true (already initialized)\n // This ref is used to:\n // 1. Skip validation during initialization/re-initialization\n // 2. Gate animation enabling until after initialization\n // 3. Gate motion preference effect until after initialization\n const hasInitialized = useRef(!needsInitialize);\n\n // Reset initialization flag when needsInitialize changes to true.\n // This handles form reset: when fields become empty (needsInitialize becomes true),\n // hasInitialized is reset to false, triggering re-initialization in the effect below.\n useEffect(() => {\n if (needsInitialize) {\n hasInitialized.current = false;\n }\n }, [needsInitialize]);\n\n // Validate array-level constraints (min/max items) when length changes.\n // Skip validation during initialization/re-initialization to avoid showing errors prematurely.\n useEffect(() => {\n if (hasInitialized.current) {\n setTimeout(() => {\n // Trigger validation so min/max errors appear instantly when user adds/removes items\n trigger(name as Path<TFieldValues>);\n }, 200);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [fields.length]);\n\n // Animation control: Start with animations disabled to prevent animating in initial elements.\n // Will be enabled after initialization completes (unless user prefers reduced motion).\n const [disableAnimation, setDisableAnimation] = useState(true);\n\n // Respond to user's motion preference changes (after initialization).\n // During initialization, animations stay disabled regardless of preference.\n const prefersReducedMotion = useReducedMotion();\n useEffect(() => {\n if (hasInitialized.current) {\n setDisableAnimation(!!prefersReducedMotion);\n }\n }, [prefersReducedMotion]);\n\n // Prepare initial element value based on mode\n // - flat=true: arrays of primitives → object with flatArrayKey and null value by default\n // - flat=false: arrays of objects → empty object by default\n const elementInitialValue = useMemo(() => {\n return flat\n ? { [flatArrayKey]: _elementInitialValue ?? null }\n : (_elementInitialValue ?? {});\n }, [flat, _elementInitialValue]);\n\n // Initialization/Re-initialization: Add initial element when needed.\n // This handles both initial mount and form reset scenarios by reacting to needsInitialize.\n // CRITICAL: This effect MUST be the LAST hook in this component.\n // It sets hasInitialized.current = true, which acts as a gate for other effects.\n // If this runs before other effects, hasInitialized will be true during their first run,\n // causing them to execute logic meant only for post-initialization (e.g., validation,\n // animation enabling). By placing this last, all other effects run first with\n // hasInitialized = false, allowing them to skip initialization-phase logic.\n useEffect(\n () => {\n if (needsInitialize) {\n // use setValue instead of append to avoid focusing the added element\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n setValue(name as Path<TFieldValues>, [elementInitialValue] as any, {\n shouldDirty: false,\n shouldTouch: false,\n });\n\n // Mark initialization as complete\n hasInitialized.current = true;\n\n // Enable animations after a brief delay (unless user prefers reduced motion or animations are already enabled).\n // This only runs on initial mount when animations start disabled.\n // On reset, disableAnimation is typically false, so this setTimeout won't run and animations stay enabled.\n if (!prefersReducedMotion && disableAnimation) {\n setTimeout(() => {\n setDisableAnimation(false);\n }, 1);\n }\n }\n },\n // Run when needsInitialize changes (initial mount or reset)\n // needsInitialize is memoized based on fields.length and lastElementNotRemovable\n // Other dependencies are intentionally omitted:\n // - append, setValue, trigger, setDisableAnimation are stable refs/functions\n // - elementInitialValue, name, flat, prefersReducedMotion, disableAnimation are props/stable values\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [needsInitialize],\n );\n\n return {\n // Field array methods and state\n fields,\n append,\n remove,\n insert,\n move,\n disableAnimation,\n elementInitialValue,\n // Uniform field state and utilities (spread all)\n ...uniformField,\n };\n};\n"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useUniformField
3
- } from "./chunk-BIC7IWER.js";
3
+ } from "./chunk-7FOSZV75.js";
4
4
  import {
5
5
  FieldValidationError_default
6
6
  } from "./chunk-ELYGQTXB.js";
@@ -160,4 +160,4 @@ export {
160
160
  Checkboxes_default,
161
161
  Checkboxes_default2
162
162
  };
163
- //# sourceMappingURL=chunk-2UHJBGKV.js.map
163
+ //# sourceMappingURL=chunk-MHQ2V7UW.js.map
@@ -3,7 +3,7 @@
3
3
  var _chunkNTOYCWCJcjs = require('./chunk-NTOYCWCJ.cjs');
4
4
 
5
5
 
6
- var _chunkZNX2PT6Ccjs = require('./chunk-ZNX2PT6C.cjs');
6
+ var _chunkYCCBMAN2cjs = require('./chunk-YCCBMAN2.cjs');
7
7
 
8
8
 
9
9
 
@@ -52,7 +52,7 @@ var TextArea = (_a) => {
52
52
  label,
53
53
  required,
54
54
  testId
55
- } = _chunkZNX2PT6Ccjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, { name }, uniformFieldProps));
55
+ } = _chunkYCCBMAN2cjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, { name }, uniformFieldProps));
56
56
  const { onChange, onBlur, value } = _chunkNTOYCWCJcjs.useInputValueDebounce.call(void 0, {
57
57
  debounceDelay,
58
58
  onBlur: fieldOnBlur,
@@ -100,4 +100,4 @@ var TextArea_default2 = TextArea_default;
100
100
 
101
101
 
102
102
  exports.TextArea_default = TextArea_default; exports.TextArea_default2 = TextArea_default2;
103
- //# sourceMappingURL=chunk-WWSJQUTT.cjs.map
103
+ //# sourceMappingURL=chunk-SR76XJW4.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-WWSJQUTT.cjs","../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"names":["TextArea_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wD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,CAAA;AAGD,EAAA,MAAM,SAAA,EAAW,gBAAA,CAAiB,CAAA;AAClC,EAAA,MAAM,WAAA,EAAa,8CAAA,QAAqB,EAAU,UAAA,EAAY,MAAM,CAAA;AAEpE,EAAA,uBACE,6BAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,aAAA,EAAa,MAAA;AAAA,MACb,YAAA;AAAA,MACA,EAAA,EAAI,MAAA;AAAA,MACJ,UAAA,EAAY,QAAA;AAAA,MACZ,SAAA,EAAW,OAAA;AAAA,MACX,UAAA,EAAY,QAAA;AAAA,MACZ,KAAA;AAAA,MACA,cAAA,EAAe,SAAA;AAAA,MACf,IAAA;AAAA,MACA,MAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,KAAA;AAAA,MACA,OAAA,EAAQ,UAAA;AAAA,MACR,UAAA,EAAY;AAAA,QACV,IAAA,EAAM,UAAA,CAAW,IAAA;AAAA,QACjB,WAAA,EAAa,UAAA,CAAW,WAAA;AAAA;AAAA,QAExB,aAAA,EAAe,KAAA;AAAA,QACf,KAAA,EAAO,UAAA,CAAW,KAAA;AAAA,QAClB,YAAA,EAAc,UAAA,CAAW;AAAA,MAC3B,CAAA;AAAA,MAEC;AAAA,IAAA;AAAA,EACH,CAAA;AAEJ,CAAA;AAEA,IAAO,iBAAA,EAAQ,QAAA;ADpBf;AACA;AEzFA,IAAOA,kBAAAA,EAAQ,gBAAA;AF2Ff;AACA;AACE;AACA;AACF,2FAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-WWSJQUTT.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce, useUniformField } from '../hooks';\n\n// input variants\nexport const textAreaVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof textAreaVariants>;\ntype ClassName = TVClassName<typeof textAreaVariants>;\n\nexport interface TextAreaProps extends VariantProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className: _className = undefined,\n debounceDelay = 300,\n name,\n placeholder = ' ',\n ...uniformFieldProps\n}: TextAreaProps) => {\n const {\n disabled,\n errorMessage,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use debounced handlers for form updates\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // classNames from slots\n const variants = textAreaVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroTextArea\n ref={ref}\n data-testid={testId}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n value={value as string}\n variant=\"bordered\"\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-SR76XJW4.cjs","../src/TextArea/TextArea.tsx","../src/TextArea/index.ts"],"names":["TextArea_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACRA,sCAAyC;AAEzC,oDAAyC;AA+ErC,+CAAA;AA1EG,IAAM,iBAAA,EAAmB,4BAAA;AAAG,EACjC,KAAA,EAAO;AAAA;AAAA,IAEL,IAAA,EAAM,EAAA;AAAA;AAAA,IAEN,WAAA,EAAa,EAAA;AAAA;AAAA,IAEb,KAAA,EAAO,EAAA;AAAA;AAAA,IAEP,YAAA,EAAc;AAAA,EAChB;AACF,CAAC,CAAA;AA2BD,IAAM,SAAA,EAAW,CAAC,EAAA,EAAA,GAOG;AAPH,EAAA,IAAA,GAAA,EAAA,EAAA,EAChB;AAAA,IAAA,SAAA,EAAW,IAAA;AAAA,IACX,SAAA,EAAW,WAAA,EAAa,KAAA,CAAA;AAAA,IACxB,cAAA,EAAgB,GAAA;AAAA,IAChB,IAAA;AAAA,IACA,YAAA,EAAc;AAAA,EArDhB,EAAA,EAgDkB,EAAA,EAMb,kBAAA,EAAA,yCAAA,EANa,EAMb;AAAA,IALH,UAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,MAAA;AAAA,IACA;AAAA,EAAA,CAAA,CAAA;AAGA,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA,YAAA;AAAA,IACA,KAAA,EAAO;AAAA,MACL,QAAA,EAAU,aAAA;AAAA,MACV,MAAA,EAAQ,WAAA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AAA,EAAQ,QAAA;ADpBf;AACA;AEzFA,IAAOA,kBAAAA,EAAQ,gBAAA;AF2Ff;AACA;AACE;AACA;AACF,2FAAC","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-SR76XJW4.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n\nimport { Textarea as HeroTextArea } from '@heroui/input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useInputValueDebounce, useUniformField } from '../hooks';\n\n// input variants\nexport const textAreaVariants = tv({\n slots: {\n /** wrapper around the whole input */\n base: '',\n /** clear button */\n clearButton: '',\n /** actual input element */\n input: '',\n /** inner wrapper (HeroUI inputWrapper slot) */\n inputWrapper: 'bg-content1 group-data-[focus=true]:border-focus',\n },\n});\n\ntype VariantProps = TVProps<typeof textAreaVariants>;\ntype ClassName = TVClassName<typeof textAreaVariants>;\n\nexport interface TextAreaProps extends VariantProps {\n /** Child components. The content of the textarea. */\n children?: ReactNode;\n /** CSS class name */\n className?: ClassName;\n /** debounce delay in milliseconds for form state updates (default: 300ms) */\n debounceDelay?: number;\n /** Determines if the TextArea is disabled or not. */\n disabled?: boolean;\n /** Label displayed above the TextArea. */\n label?: ReactNode;\n /** Name the TextArea is registered at in HTML forms (react-hook-form). */\n name: string;\n /** placeholder for the textArea content. */\n placeholder?: string;\n /** Id to grab element in internal tests. */\n testId?: string;\n}\n\n/**\n * TextArea component based on [HeroUI TextArea](https://www.heroui.com//docs/components/textarea)\n */\nconst TextArea = ({\n children = null,\n className: _className = undefined,\n debounceDelay = 300,\n name,\n placeholder = ' ',\n ...uniformFieldProps\n}: TextAreaProps) => {\n const {\n disabled,\n errorMessage,\n field: {\n onChange: fieldOnChange,\n onBlur: fieldOnBlur,\n value: fieldValue,\n ref,\n },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // Use debounced handlers for form updates\n const { onChange, onBlur, value } = useInputValueDebounce({\n debounceDelay,\n onBlur: fieldOnBlur,\n onChange: fieldOnChange,\n value: fieldValue,\n });\n\n // classNames from slots\n const variants = textAreaVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n\n return (\n <HeroTextArea\n ref={ref}\n data-testid={testId}\n errorMessage={errorMessage}\n id={testId}\n isDisabled={disabled}\n isInvalid={invalid}\n isRequired={required}\n label={label}\n labelPlacement=\"outside\"\n name={name}\n onBlur={onBlur}\n onChange={onChange}\n placeholder={placeholder}\n value={value as string}\n variant=\"bordered\"\n classNames={{\n base: classNames.base,\n clearButton: classNames.clearButton,\n // set padding to 0 for error message exit animation\n helperWrapper: 'p-0',\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n }}\n >\n {children}\n </HeroTextArea>\n );\n};\n\nexport default TextArea;\n","import TextArea from './TextArea';\n\nexport type { TextAreaProps } from './TextArea';\n\nexport { TextArea };\n\nexport default TextArea;\n"]}
@@ -0,0 +1,217 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkYCCBMAN2cjs = require('./chunk-YCCBMAN2.cjs');
4
+
5
+
6
+
7
+
8
+ var _chunk555JRYCScjs = require('./chunk-555JRYCS.cjs');
9
+
10
+ // src/RadioBoxes/RadioBoxes.tsx
11
+ var _radio = require('@heroui/radio');
12
+ var _pixelutils = require('@fuf-stack/pixel-utils');
13
+
14
+ // src/RadioBoxes/RadioBox.tsx
15
+
16
+ var _visuallyhidden = require('@react-aria/visually-hidden');
17
+
18
+ var _jsxruntime = require('react/jsx-runtime');
19
+ var radioBoxVariants = _pixelutils.tv.call(void 0, {
20
+ slots: {
21
+ base: "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",
22
+ control: "",
23
+ description: "text-foreground opacity-70 text-small",
24
+ icon: "",
25
+ label: "",
26
+ labelWrapper: "grow"
27
+ },
28
+ variants: {
29
+ isDisabled: {
30
+ true: {
31
+ base: "pointer-events-none opacity-disabled"
32
+ }
33
+ },
34
+ isInvalid: {
35
+ true: {
36
+ base: "!border-danger"
37
+ }
38
+ }
39
+ }
40
+ });
41
+ var RadioBox = (_a) => {
42
+ var _b = _a, {
43
+ classNames: _classNames = void 0,
44
+ icon = void 0,
45
+ isInvalid = false
46
+ } = _b, props = _chunk555JRYCScjs.__objRest.call(void 0, _b, [
47
+ "classNames",
48
+ "icon",
49
+ "isInvalid"
50
+ ]);
51
+ const {
52
+ children,
53
+ Component,
54
+ description,
55
+ getBaseProps,
56
+ getControlProps,
57
+ getInputProps,
58
+ getLabelProps,
59
+ getLabelWrapperProps,
60
+ getWrapperProps,
61
+ isDisabled
62
+ } = _radio.useRadio.call(void 0, props);
63
+ const variants = radioBoxVariants({
64
+ isDisabled,
65
+ isInvalid
66
+ });
67
+ const classNames = _pixelutils.variantsToClassNames.call(void 0,
68
+ variants,
69
+ // @ts-expect-error not sure here, but it works
70
+ _classNames,
71
+ "base"
72
+ );
73
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Component, _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getBaseProps()), { className: classNames.base, children: [
74
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _visuallyhidden.VisuallyHidden, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getInputProps())) }),
75
+ !icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getWrapperProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
76
+ "span",
77
+ _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getControlProps()), {
78
+ className: _pixelutils.cn.call(void 0, getControlProps().className, classNames.control)
79
+ })
80
+ ) })) : null,
81
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: classNames.icon, children: icon }) : null,
82
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
83
+ "div",
84
+ _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getLabelWrapperProps()), {
85
+ className: _pixelutils.cn.call(void 0,
86
+ getLabelWrapperProps().className,
87
+ classNames.labelWrapper
88
+ ),
89
+ children: [
90
+ children ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
91
+ "span",
92
+ _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getLabelProps()), {
93
+ className: _pixelutils.cn.call(void 0, getLabelProps().className, classNames.label),
94
+ children
95
+ })
96
+ ) : null,
97
+ description ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: classNames.description, children: description }) : null
98
+ ]
99
+ })
100
+ ),
101
+ icon ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getWrapperProps()), { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
102
+ "span",
103
+ _chunk555JRYCScjs.__spreadProps.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {}, getControlProps()), {
104
+ className: _pixelutils.cn.call(void 0, getControlProps().className, classNames.control)
105
+ })
106
+ ) })) : null
107
+ ] }));
108
+ };
109
+
110
+ // src/RadioBoxes/RadioBoxes.tsx
111
+
112
+ var radioBoxesVariants = _pixelutils.tv.call(void 0, {
113
+ slots: {
114
+ base: "group gap-0",
115
+ // Needs group for group-data condition
116
+ boxBase: "",
117
+ boxControl: "",
118
+ boxDescription: "",
119
+ boxLabel: "",
120
+ boxLabelWrapper: "",
121
+ // see HeroUI styles for group-data condition,
122
+ // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts
123
+ label: "mb-2 inline-flex text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:text-danger",
124
+ wrapper: ""
125
+ }
126
+ });
127
+ var RadioBoxes = (_a) => {
128
+ var _b = _a, {
129
+ className = void 0,
130
+ inline = false,
131
+ name,
132
+ options
133
+ } = _b, uniformFieldProps = _chunk555JRYCScjs.__objRest.call(void 0, _b, [
134
+ "className",
135
+ "inline",
136
+ "name",
137
+ "options"
138
+ ]);
139
+ const {
140
+ defaultValue,
141
+ errorMessage,
142
+ invalid,
143
+ disabled,
144
+ label,
145
+ onBlur,
146
+ onChange,
147
+ ref,
148
+ required,
149
+ testId
150
+ } = _chunkYCCBMAN2cjs.useUniformField.call(void 0, _chunk555JRYCScjs.__spreadValues.call(void 0, {
151
+ name
152
+ }, uniformFieldProps));
153
+ const variants = radioBoxesVariants();
154
+ const classNames = _pixelutils.variantsToClassNames.call(void 0, variants, className, "base");
155
+ const boxClassNames = {
156
+ base: classNames.boxBase,
157
+ control: classNames.boxControl,
158
+ description: classNames.boxDescription,
159
+ label: classNames.boxLabel,
160
+ labelWrapper: classNames.boxLabelWrapper
161
+ };
162
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
163
+ _radio.RadioGroup,
164
+ {
165
+ ref,
166
+ classNames,
167
+ "data-invalid": invalid,
168
+ "data-required": required,
169
+ "data-testid": testId,
170
+ defaultValue,
171
+ errorMessage,
172
+ isDisabled: disabled,
173
+ isInvalid: invalid,
174
+ isRequired: required,
175
+ label: label ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "legend", { children: label }) : null,
176
+ name,
177
+ onBlur,
178
+ onValueChange: onChange,
179
+ orientation: inline ? "horizontal" : "vertical",
180
+ children: options.map((option) => {
181
+ var _a2, _b2;
182
+ if ("value" in option) {
183
+ const optionTestId = _pixelutils.slugify.call(void 0,
184
+ `${testId}_option_${(_a2 = option.testId) != null ? _a2 : option.value}`,
185
+ { replaceDots: true }
186
+ );
187
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
188
+ RadioBox,
189
+ {
190
+ classNames: boxClassNames,
191
+ "data-testid": optionTestId,
192
+ description: option.description,
193
+ icon: option.icon,
194
+ isDisabled: !!disabled || option.disabled,
195
+ isInvalid: invalid,
196
+ value: option.value,
197
+ children: (_b2 = option.label) != null ? _b2 : option.value
198
+ },
199
+ option.value
200
+ );
201
+ }
202
+ return null;
203
+ })
204
+ }
205
+ );
206
+ };
207
+ var RadioBoxes_default = RadioBoxes;
208
+
209
+ // src/RadioBoxes/index.ts
210
+ var RadioBoxes_default2 = RadioBoxes_default;
211
+
212
+
213
+
214
+
215
+
216
+ exports.radioBoxVariants = radioBoxVariants; exports.RadioBoxes_default = RadioBoxes_default; exports.RadioBoxes_default2 = RadioBoxes_default2;
217
+ //# sourceMappingURL=chunk-THCIT66I.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-THCIT66I.cjs","../src/RadioBoxes/RadioBoxes.tsx","../src/RadioBoxes/RadioBox.tsx","../src/RadioBoxes/index.ts"],"names":["tv","variantsToClassNames","jsx","_a","_b","RadioBoxes_default"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACJA,sCAA6C;AAE7C,oDAAkD;ADKlD;AACA;AETA;AACA,6DAA+B;AAE/B;AAsEQ,+CAAA;AApED,IAAM,iBAAA,EAAmB,4BAAA;AAAG,EACjC,KAAA,EAAO;AAAA,IACL,IAAA,EAAM,0KAAA;AAAA,IACN,OAAA,EAAS,EAAA;AAAA,IACT,WAAA,EAAa,uCAAA;AAAA,IACb,IAAA,EAAM,EAAA;AAAA,IACN,KAAA,EAAO,EAAA;AAAA,IACP,YAAA,EAAc;AAAA,EAChB,CAAA;AAAA,EACA,QAAA,EAAU;AAAA,IACR,UAAA,EAAY;AAAA,MACV,IAAA,EAAM;AAAA,QACJ,IAAA,EAAM;AAAA,MACR;AAA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CAAA,EAAA;AACA,YAAA;AACF,UAAA;AACA,UAAA;AACG,YAAA;AAAA,YAAA;AAAA,cAAA;AAEa,cAAA;AACC,cAAA;AACO,cAAA;AACP,cAAA;AACoB,cAAA;AACtB,cAAA;AACG,cAAA;AAEU,YAAA;AATnB,YAAA;AAUP,UAAA;AAEJ,QAAA;AACA,QAAA;AACD,MAAA;AAAA,IAAA;AACH,EAAA;AAEJ;AAEO;AD4DM;AACA;AGzMNC;AH2MM;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/pixels/pixels/packages/uniform/dist/chunk-THCIT66I.cjs","sourcesContent":[null,"import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\n//\nimport type { RadioBoxProps } from './RadioBox';\n\nimport { RadioGroup as HeroRadioGroup } from '@heroui/radio';\n\nimport { slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks';\nimport { RadioBox } from './RadioBox';\n\nexport const radioBoxesVariants = tv({\n slots: {\n base: 'group gap-0', // Needs group for group-data condition\n boxBase: '',\n boxControl: '',\n boxDescription: '',\n boxLabel: '',\n boxLabelWrapper: '',\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 boxClassNames: RadioBoxProps['classNames'] = {\n base: classNames.boxBase,\n control: classNames.boxControl,\n description: classNames.boxDescription,\n label: classNames.boxLabel,\n labelWrapper: classNames.boxLabelWrapper,\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 onValueChange={onChange}\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={boxClassNames}\n data-testid={optionTestId}\n description={option.description}\n icon={option.icon}\n isDisabled={!!disabled || option.disabled}\n isInvalid={invalid}\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 { TVClassName } from '@fuf-stack/pixel-utils';\nimport 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, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nexport const radioBoxVariants = tv({\n slots: {\n base: '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 control: '',\n description: 'text-foreground opacity-70 text-small',\n icon: '',\n label: '',\n labelWrapper: 'grow',\n },\n variants: {\n isDisabled: {\n true: {\n base: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n base: '!border-danger',\n },\n },\n },\n});\n\ntype ClassName = TVClassName<typeof radioBoxVariants>;\n\nexport interface RadioBoxProps extends Omit<HeroRadioProps, 'className'> {\n /** CSS class name */\n className?: ClassName;\n /** icon for the option */\n icon?: ReactNode;\n /** whether the radio is invalid */\n isInvalid?: boolean;\n}\n\nexport const RadioBox = ({\n classNames: _classNames = undefined,\n icon = undefined,\n isInvalid = false,\n ...props\n}: RadioBoxProps) => {\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 as HeroRadioProps);\n\n // classNames from slots\n const variants = radioBoxVariants({\n isDisabled,\n isInvalid,\n });\n const classNames = variantsToClassNames(\n variants,\n // @ts-expect-error not sure here, but it works\n _classNames,\n 'base',\n );\n\n return (\n <Component {...getBaseProps()} className={classNames.base}>\n <VisuallyHidden>\n <input {...getInputProps()} />\n </VisuallyHidden>\n {!icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div\n {...getLabelWrapperProps()}\n className={cn(\n getLabelWrapperProps().className,\n classNames.labelWrapper,\n )}\n >\n {children ? (\n <span\n {...getLabelProps()}\n className={cn(getLabelProps().className, classNames.label)}\n >\n {children}\n </span>\n ) : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span {...getWrapperProps()}>\n <span\n {...getControlProps()}\n className={cn(getControlProps().className, classNames.control)}\n />\n </span>\n ) : null}\n </Component>\n );\n};\n\nexport default RadioBox;\n","import RadioBoxes from './RadioBoxes';\n\nexport type { RadioBoxesProps } from './RadioBoxes';\nexport { radioBoxVariants } from './RadioBox';\n\nexport { RadioBoxes };\n\nexport default RadioBoxes;\n"]}