@fuf-stack/uniform 1.22.3 → 1.22.5

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 (227) hide show
  1. package/dist/Checkboxes/index.cjs +2 -1
  2. package/dist/Checkboxes/index.d.cts +2 -2
  3. package/dist/Checkboxes/index.d.ts +2 -2
  4. package/dist/Checkboxes/index.js +2 -2
  5. package/dist/{Checkboxes-DHk09GmH.cjs → Checkboxes-DrJqx6O2.cjs} +7 -1
  6. package/dist/{Checkboxes-DHk09GmH.cjs.map → Checkboxes-DrJqx6O2.cjs.map} +1 -1
  7. package/dist/{Checkboxes-D1hppxDE.js → Checkboxes-X6FRwI50.js} +2 -2
  8. package/dist/{Checkboxes-D1hppxDE.js.map → Checkboxes-X6FRwI50.js.map} +1 -1
  9. package/dist/DatePicker/index.cjs +2 -1
  10. package/dist/DatePicker/index.d.cts +2 -2
  11. package/dist/DatePicker/index.d.ts +2 -2
  12. package/dist/DatePicker/index.js +2 -2
  13. package/dist/{DatePicker-BUSi8SWQ.js → DatePicker-CGIWizz9.js} +2 -2
  14. package/dist/{DatePicker-BUSi8SWQ.js.map → DatePicker-CGIWizz9.js.map} +1 -1
  15. package/dist/{DatePicker-DuBjvS5g.cjs → DatePicker-CYUuwwsm.cjs} +7 -1
  16. package/dist/{DatePicker-DuBjvS5g.cjs.map → DatePicker-CYUuwwsm.cjs.map} +1 -1
  17. package/dist/FieldArray/index.cjs +2 -1
  18. package/dist/FieldArray/index.d.cts +2 -2
  19. package/dist/FieldArray/index.d.ts +2 -2
  20. package/dist/FieldArray/index.js +2 -2
  21. package/dist/{FieldArray-BxmK1NRd.js → FieldArray-Dkw6JBnT.js} +2 -2
  22. package/dist/{FieldArray-BxmK1NRd.js.map → FieldArray-Dkw6JBnT.js.map} +1 -1
  23. package/dist/{FieldArray-DgiQpIdr.cjs → FieldArray-V66fsvtd.cjs} +7 -1
  24. package/dist/{FieldArray-DgiQpIdr.cjs.map → FieldArray-V66fsvtd.cjs.map} +1 -1
  25. package/dist/FieldCard/index.cjs +6 -2
  26. package/dist/FieldCard/index.d.cts +2 -2
  27. package/dist/FieldCard/index.d.ts +2 -2
  28. package/dist/FieldCard/index.js +2 -2
  29. package/dist/{FieldCard-C-DZ5ARr.cjs → FieldCard-CAHnM8C0.cjs} +10 -1
  30. package/dist/FieldCard-CAHnM8C0.cjs.map +1 -0
  31. package/dist/{FieldCard-BK6SNqFY.js → FieldCard-Cg31ce9J.js} +5 -2
  32. package/dist/FieldCard-Cg31ce9J.js.map +1 -0
  33. package/dist/Input/index.d.cts +1 -1
  34. package/dist/Input/index.d.ts +1 -1
  35. package/dist/RadioBoxes/index.cjs +1 -1
  36. package/dist/RadioBoxes/index.d.cts +2 -2
  37. package/dist/RadioBoxes/index.d.ts +2 -2
  38. package/dist/RadioBoxes/index.js +1 -1
  39. package/dist/{RadioBoxes-CR--FBhQ.cjs → RadioBoxes-BmLrbYXt.cjs} +3 -3
  40. package/dist/RadioBoxes-BmLrbYXt.cjs.map +1 -0
  41. package/dist/{RadioBoxes-BJz-aJp3.js → RadioBoxes-DWxJBTKR.js} +3 -3
  42. package/dist/RadioBoxes-DWxJBTKR.js.map +1 -0
  43. package/dist/RadioTabs/index.cjs +2 -1
  44. package/dist/RadioTabs/index.d.cts +2 -2
  45. package/dist/RadioTabs/index.d.ts +2 -2
  46. package/dist/RadioTabs/index.js +2 -2
  47. package/dist/{RadioTabs-Btt582Nl.cjs → RadioTabs-14XTbTJU.cjs} +20 -14
  48. package/dist/RadioTabs-14XTbTJU.cjs.map +1 -0
  49. package/dist/{RadioTabs-CYmzrPBG.js → RadioTabs-DAY6MYJI.js} +15 -15
  50. package/dist/RadioTabs-DAY6MYJI.js.map +1 -0
  51. package/dist/Radios/index.cjs +2 -1
  52. package/dist/Radios/index.d.cts +2 -2
  53. package/dist/Radios/index.d.ts +2 -2
  54. package/dist/Radios/index.js +2 -2
  55. package/dist/{Radios-DZxhrX96.js → Radios-C938-msm.js} +2 -2
  56. package/dist/{Radios-DZxhrX96.js.map → Radios-C938-msm.js.map} +1 -1
  57. package/dist/{Radios-Jg9mwE0B.cjs → Radios-D_B9Y8s2.cjs} +7 -1
  58. package/dist/{Radios-Jg9mwE0B.cjs.map → Radios-D_B9Y8s2.cjs.map} +1 -1
  59. package/dist/Select/index.cjs +2 -1
  60. package/dist/Select/index.d.cts +2 -2
  61. package/dist/Select/index.d.ts +2 -2
  62. package/dist/Select/index.js +2 -2
  63. package/dist/{Select-CgeqhZIC.js → Select-BL6k_e-D.js} +2 -2
  64. package/dist/Select-BL6k_e-D.js.map +1 -0
  65. package/dist/{Select-CZwuEAB5.cjs → Select-D66A-hYm.cjs} +7 -1
  66. package/dist/Select-D66A-hYm.cjs.map +1 -0
  67. package/dist/Slider/index.cjs +2 -1
  68. package/dist/Slider/index.d.cts +2 -2
  69. package/dist/Slider/index.d.ts +2 -2
  70. package/dist/Slider/index.js +2 -2
  71. package/dist/{Slider-Bpxt-Qgj.cjs → Slider-ChC2PZNb.cjs} +7 -1
  72. package/dist/{Slider-Bpxt-Qgj.cjs.map → Slider-ChC2PZNb.cjs.map} +1 -1
  73. package/dist/{Slider-DRfSw0uE.js → Slider-DmEwhC1T.js} +2 -2
  74. package/dist/{Slider-DRfSw0uE.js.map → Slider-DmEwhC1T.js.map} +1 -1
  75. package/dist/Switch/index.cjs +2 -1
  76. package/dist/Switch/index.d.cts +2 -2
  77. package/dist/Switch/index.d.ts +2 -2
  78. package/dist/Switch/index.js +2 -2
  79. package/dist/{Switch-hjjy34QB.cjs → Switch-Ch6_VInV.cjs} +7 -1
  80. package/dist/{Switch-hjjy34QB.cjs.map → Switch-Ch6_VInV.cjs.map} +1 -1
  81. package/dist/{Switch-D9DNrqmj.js → Switch-DvKRPFcC.js} +2 -2
  82. package/dist/{Switch-D9DNrqmj.js.map → Switch-DvKRPFcC.js.map} +1 -1
  83. package/dist/SwitchBox/index.d.cts +1 -1
  84. package/dist/SwitchBox/index.d.ts +1 -1
  85. package/dist/SwitchBox-BU1XieaZ.js.map +1 -1
  86. package/dist/SwitchBox-Dl-F5y2m.cjs.map +1 -1
  87. package/dist/TextArea/index.d.cts +1 -1
  88. package/dist/TextArea/index.d.ts +1 -1
  89. package/dist/Time/index.cjs +7 -2
  90. package/dist/Time/index.d.cts +2 -2
  91. package/dist/Time/index.d.ts +2 -2
  92. package/dist/Time/index.js +2 -2
  93. package/dist/{Time-CDptQ3CK.js → Time-B_SXrKWK.js} +5 -2
  94. package/dist/Time-B_SXrKWK.js.map +1 -0
  95. package/dist/{Time-WKgbji5k.cjs → Time-CYoWaQsz.cjs} +16 -1
  96. package/dist/Time-CYoWaQsz.cjs.map +1 -0
  97. package/dist/hooks/useUniformFieldArray/index.cjs +4 -4
  98. package/dist/hooks/useUniformFieldArray/index.cjs.map +1 -1
  99. package/dist/hooks/useUniformFieldArray/index.js +4 -4
  100. package/dist/hooks/useUniformFieldArray/index.js.map +1 -1
  101. package/dist/index-19JGtN7H.d.cts +1257 -0
  102. package/dist/index-19JGtN7H.d.cts.map +1 -0
  103. package/dist/index-B4XExHDi.d.cts +539 -0
  104. package/dist/index-B4XExHDi.d.cts.map +1 -0
  105. package/dist/index-BUZEnZDm.d.ts +1760 -0
  106. package/dist/index-BUZEnZDm.d.ts.map +1 -0
  107. package/dist/index-Bbaubtxp.d.cts +677 -0
  108. package/dist/index-Bbaubtxp.d.cts.map +1 -0
  109. package/dist/index-BdgFJ-dj.d.ts +1028 -0
  110. package/dist/index-BdgFJ-dj.d.ts.map +1 -0
  111. package/dist/index-BiZNkLK3.d.cts +1477 -0
  112. package/dist/index-BiZNkLK3.d.cts.map +1 -0
  113. package/dist/index-Bie3CWyW.d.cts +1760 -0
  114. package/dist/index-Bie3CWyW.d.cts.map +1 -0
  115. package/dist/index-BsTqcI1C.d.cts +659 -0
  116. package/dist/index-BsTqcI1C.d.cts.map +1 -0
  117. package/dist/index-C6Y8KybK.d.ts +677 -0
  118. package/dist/index-C6Y8KybK.d.ts.map +1 -0
  119. package/dist/index-CD0Wpla3.d.cts +1413 -0
  120. package/dist/index-CD0Wpla3.d.cts.map +1 -0
  121. package/dist/index-CUByIf_d.d.ts +314 -0
  122. package/dist/index-CUByIf_d.d.ts.map +1 -0
  123. package/dist/index-Cf2B9woY.d.cts +473 -0
  124. package/dist/index-Cf2B9woY.d.cts.map +1 -0
  125. package/dist/index-CqXEYILn.d.cts +1263 -0
  126. package/dist/index-CqXEYILn.d.cts.map +1 -0
  127. package/dist/index-D1cB3mbB.d.ts +3917 -0
  128. package/dist/index-D1cB3mbB.d.ts.map +1 -0
  129. package/dist/index-D7AUghFx.d.ts +1413 -0
  130. package/dist/index-D7AUghFx.d.ts.map +1 -0
  131. package/dist/index-DCwffq1f.d.ts +1263 -0
  132. package/dist/index-DCwffq1f.d.ts.map +1 -0
  133. package/dist/index-DFbuWomg.d.ts +534 -0
  134. package/dist/index-DFbuWomg.d.ts.map +1 -0
  135. package/dist/index-DXOBPBft.d.ts +659 -0
  136. package/dist/index-DXOBPBft.d.ts.map +1 -0
  137. package/dist/index-DY-d4cFe.d.cts +1028 -0
  138. package/dist/index-DY-d4cFe.d.cts.map +1 -0
  139. package/dist/index-DqMpHpu7.d.ts +1257 -0
  140. package/dist/index-DqMpHpu7.d.ts.map +1 -0
  141. package/dist/index-DwnqyNnX.d.cts +534 -0
  142. package/dist/index-DwnqyNnX.d.cts.map +1 -0
  143. package/dist/index-OdNTqjhQ.d.ts +585 -0
  144. package/dist/index-OdNTqjhQ.d.ts.map +1 -0
  145. package/dist/index-QPDvw5Z5.d.cts +585 -0
  146. package/dist/index-QPDvw5Z5.d.cts.map +1 -0
  147. package/dist/index-amMd-sQN.d.ts +473 -0
  148. package/dist/index-amMd-sQN.d.ts.map +1 -0
  149. package/dist/index-clztdahp.d.ts +1477 -0
  150. package/dist/index-clztdahp.d.ts.map +1 -0
  151. package/dist/index-jK092-MJ.d.cts +314 -0
  152. package/dist/index-jK092-MJ.d.cts.map +1 -0
  153. package/dist/index-veBM95Gw.d.cts +3917 -0
  154. package/dist/index-veBM95Gw.d.cts.map +1 -0
  155. package/dist/index-yYjVSHlN.d.ts +539 -0
  156. package/dist/index-yYjVSHlN.d.ts.map +1 -0
  157. package/dist/index.cjs +20 -11
  158. package/dist/index.d.cts +15 -15
  159. package/dist/index.d.ts +15 -15
  160. package/dist/index.js +12 -12
  161. package/package.json +6 -6
  162. package/dist/FieldCard-BK6SNqFY.js.map +0 -1
  163. package/dist/FieldCard-C-DZ5ARr.cjs.map +0 -1
  164. package/dist/RadioBoxes-BJz-aJp3.js.map +0 -1
  165. package/dist/RadioBoxes-CR--FBhQ.cjs.map +0 -1
  166. package/dist/RadioTabs-Btt582Nl.cjs.map +0 -1
  167. package/dist/RadioTabs-CYmzrPBG.js.map +0 -1
  168. package/dist/Select-CZwuEAB5.cjs.map +0 -1
  169. package/dist/Select-CgeqhZIC.js.map +0 -1
  170. package/dist/Time-CDptQ3CK.js.map +0 -1
  171. package/dist/Time-WKgbji5k.cjs.map +0 -1
  172. package/dist/index-B4jKGy-P.d.ts +0 -167
  173. package/dist/index-B4jKGy-P.d.ts.map +0 -1
  174. package/dist/index-B5SfdA5O.d.cts +0 -99
  175. package/dist/index-B5SfdA5O.d.cts.map +0 -1
  176. package/dist/index-B61zRzeS.d.cts +0 -101
  177. package/dist/index-B61zRzeS.d.cts.map +0 -1
  178. package/dist/index-BDFJDKmz.d.ts +0 -166
  179. package/dist/index-BDFJDKmz.d.ts.map +0 -1
  180. package/dist/index-BE4OAqJ2.d.cts +0 -113
  181. package/dist/index-BE4OAqJ2.d.cts.map +0 -1
  182. package/dist/index-BMEKfOWp.d.ts +0 -174
  183. package/dist/index-BMEKfOWp.d.ts.map +0 -1
  184. package/dist/index-BPaSE_7b.d.ts +0 -179
  185. package/dist/index-BPaSE_7b.d.ts.map +0 -1
  186. package/dist/index-BSjcTo7A.d.ts +0 -147
  187. package/dist/index-BSjcTo7A.d.ts.map +0 -1
  188. package/dist/index-Bgo2Dr6X.d.cts +0 -174
  189. package/dist/index-Bgo2Dr6X.d.cts.map +0 -1
  190. package/dist/index-BmMspnsJ.d.cts +0 -137
  191. package/dist/index-BmMspnsJ.d.cts.map +0 -1
  192. package/dist/index-BvbHkoH5.d.cts +0 -290
  193. package/dist/index-BvbHkoH5.d.cts.map +0 -1
  194. package/dist/index-C6DBVs7t.d.ts +0 -116
  195. package/dist/index-C6DBVs7t.d.ts.map +0 -1
  196. package/dist/index-CIiOXrrY.d.ts +0 -99
  197. package/dist/index-CIiOXrrY.d.ts.map +0 -1
  198. package/dist/index-CSRKNes5.d.cts +0 -167
  199. package/dist/index-CSRKNes5.d.cts.map +0 -1
  200. package/dist/index-CbPJiRK2.d.ts +0 -83
  201. package/dist/index-CbPJiRK2.d.ts.map +0 -1
  202. package/dist/index-CbQ8Ft4o.d.ts +0 -113
  203. package/dist/index-CbQ8Ft4o.d.ts.map +0 -1
  204. package/dist/index-CvP3tbVV.d.ts +0 -137
  205. package/dist/index-CvP3tbVV.d.ts.map +0 -1
  206. package/dist/index-Cwb7sTO0.d.ts +0 -154
  207. package/dist/index-Cwb7sTO0.d.ts.map +0 -1
  208. package/dist/index-CxY9VWv5.d.cts +0 -154
  209. package/dist/index-CxY9VWv5.d.cts.map +0 -1
  210. package/dist/index-Cz4JaCWd.d.ts +0 -122
  211. package/dist/index-Cz4JaCWd.d.ts.map +0 -1
  212. package/dist/index-DBsF7xsq.d.cts +0 -147
  213. package/dist/index-DBsF7xsq.d.cts.map +0 -1
  214. package/dist/index-DMOhTl4I.d.cts +0 -116
  215. package/dist/index-DMOhTl4I.d.cts.map +0 -1
  216. package/dist/index-DRg0anjB.d.cts +0 -179
  217. package/dist/index-DRg0anjB.d.cts.map +0 -1
  218. package/dist/index-DUmNI6cE.d.cts +0 -83
  219. package/dist/index-DUmNI6cE.d.cts.map +0 -1
  220. package/dist/index-Db0WD4d1.d.cts +0 -166
  221. package/dist/index-Db0WD4d1.d.cts.map +0 -1
  222. package/dist/index-GqydEAFk.d.ts +0 -290
  223. package/dist/index-GqydEAFk.d.ts.map +0 -1
  224. package/dist/index-PMCqBX0t.d.ts +0 -101
  225. package/dist/index-PMCqBX0t.d.ts.map +0 -1
  226. package/dist/index-Q3BWGyUO.d.cts +0 -122
  227. package/dist/index-Q3BWGyUO.d.cts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select-D66A-hYm.cjs","names":["components","useUniformField","useFormContext","createOptionValueConverter","isValueEmpty","ReactSelect"],"sources":["../src/Select/Select.tsx","../src/Select/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { MultiValue, Props, SingleValue } from 'react-select';\n\nimport { useState } from 'react';\nimport ReactSelect, { components } from 'react-select';\n\nimport { useSelect } from '@heroui/select';\n\nimport { cn, slugify, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { createOptionValueConverter, isValueEmpty } from '../helpers';\nimport { useFormContext } from '../hooks/useFormContext';\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const selectVariants = tv({\n slots: {\n base: 'group leading-normal',\n clearIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-foreground-800',\n control:\n 'duration-150! rounded-lg border-2 border-default-200 bg-content1 transition-background hover:border-default-400 group-data-[invalid=true]:border-danger group-data-[invalid=true]:hover:border-danger motion-reduce:transition-none',\n control_focused: 'border-focus',\n crossIcon: '',\n downChevron: '',\n dropdownIndicator:\n 'rounded-md p-1 text-foreground-500 hover:cursor-pointer hover:bg-default-200 hover:text-black',\n group: '',\n groupHeading: 'mb-1 ml-3 mt-2 text-sm text-foreground-500',\n indicatorsContainer: 'gap-1 p-1',\n indicatorSeparator: 'bg-default-300',\n input: 'py-0.5 pl-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'pointer-events-auto relative bottom-1.5 ml-1 text-foreground subpixel-antialiased text-small group-data-[invalid=true]:!text-danger',\n loadingIndicator: '',\n loadingMessage: 'rounded-sm p-2 text-foreground-500',\n menu: 'mt-2 rounded-xl border border-default-200 bg-content1 p-1 shadow-lg',\n menuList: '',\n // ensure menu has same z-index as modal so it is visible when rendered in modal\n // see: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/modal.ts (see z-50)\n menuPortal: 'z-50!',\n multiValue: 'items-center gap-1.5 rounded bg-default-100 py-0.5 pl-2 pr-1',\n multiValueContainer: '',\n multiValueLabel: 'py-0.5 leading-6',\n multiValueRemove:\n 'rounded text-default-500 hover:cursor-pointer hover:border-default-300 hover:text-default-800',\n noOptionsMessage: 'rounded-sm p-2 text-foreground-500',\n option: 'rounded px-3 py-2 hover:cursor-pointer',\n option_disabled:\n 'cursor-not-allowed! hover:cursor-not-allowed! opacity-disabled',\n option_focused: 'bg-default-100 active:bg-default-200',\n option_selected: 'bg-default-300',\n placeholder: 'ml-1 py-0.5 pl-1 text-sm text-foreground-500',\n selectContainer: '',\n singleValue: 'ml-1! leading-7!',\n valueContainer: 'gap-1 p-1',\n },\n});\n\nexport interface SelectOption {\n /** set option to disabled state */\n disabled?: boolean;\n /**\n * True when option was auto-generated because the value wasn't found in options.\n * Use in renderOptionLabel to render a component that fetches the real label.\n */\n isFallback?: boolean;\n /** option label */\n label?: ReactNode;\n /** option value */\n value: string | number;\n}\n\ntype VariantProps = TVProps<typeof selectVariants>;\ntype ClassName = TVClassName<typeof selectVariants>;\n\nexport interface SelectProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName; // string;\n /** Determine if the */\n clearable?: boolean;\n /** Set the select to disabled state. */\n disabled?: boolean;\n /** Force menu open for debugging or visual testing. */\n debugMenuOpen?: boolean;\n /** Filter Select Options */\n filterOption?:\n | undefined\n | ((option?: SelectOption, inputValue?: string) => boolean);\n /** The value of the search input */\n inputValue?: string;\n /** Label that should be associated with the select. */\n label?: ReactNode;\n /** Set the select to a loading state. */\n loading?: boolean;\n /** switch between single and multi select mode. */\n multiSelect?: boolean;\n /** The name for the Select component, used by react-hook-form */\n name: string;\n /** Placeholder that is displayed when nothing is selected */\n placeholder?: string;\n /** Handle change events on the input */\n onInputChange?: Props['onInputChange'];\n /** The options for the Select component */\n options: SelectOption[];\n /** Render custom content when no options match the current search input. */\n renderEmptyOptions?: Props['noOptionsMessage'];\n /** Format the label of the option */\n renderOptionLabel?: undefined | Props['formatOptionLabel'];\n /**\n * Fallback option(s) for async selects when value isn't in current options.\n * Use when the selected value may not be in the options list (e.g., after\n * search results change). Used only if value not found in options.\n * For single select: pass the option object or undefined\n * For multi-select: pass an array of option objects\n */\n selectedOptionFallback?: SelectOption | SelectOption[];\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n}\n\nconst InputComponent: typeof components.Input = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}`;\n return <components.Input data-testid={testId} {...props} />;\n};\n\nconst ControlComponent: typeof components.Control = (props) => {\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select`;\n return (\n <div data-testid={testId}>\n <components.Control {...props} />\n </div>\n );\n};\n\nconst OptionComponent: typeof components.Option = (props) => {\n const { isDisabled } = props;\n // @ts-expect-error data-testid is not a default prop\n // eslint-disable-next-line react/destructuring-assignment\n const testId = `${props.selectProps['data-testid']}_select_option_${slugify(String(props?.data?.testId ?? props?.data?.value), { replaceDots: true })}`;\n return (\n <div aria-disabled={isDisabled ? true : undefined} data-testid={testId}>\n <components.Option {...props} />\n </div>\n );\n};\n\nconst DropdownIndicatorComponent: typeof components.DropdownIndicator = (\n props,\n) => {\n // @ts-expect-error data-testid is not a default prop\n const testId = props?.selectProps['data-testid'] as string;\n return (\n <div data-testid={`${testId}_select_dropdown`}>\n <components.DropdownIndicator {...props} />\n </div>\n );\n};\n\n/** Select component based on [HeroUI Select](https://www.heroui.com//docs/components/select) and [React-Select](https://react-select.com/home) */\nconst Select = ({\n className = undefined,\n clearable = true,\n debugMenuOpen = false,\n filterOption = undefined,\n inputValue = undefined,\n loading = false,\n multiSelect = false,\n name,\n onInputChange = undefined,\n options,\n placeholder = undefined,\n renderEmptyOptions = undefined,\n renderOptionLabel = undefined,\n selectedOptionFallback = undefined,\n ...uniformFieldProps\n}: SelectProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, ref, value },\n getErrorMessageProps,\n getHelperWrapperProps,\n getLabelProps,\n invalid,\n label,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Get getFieldState to check isTouched in onChange callback\n const { getFieldState } = useFormContext();\n\n // Track if the select is focused\n const [isFocused, setIsFocused] = useState(false);\n\n // Create converter to preserve number types for option values\n const { convertToOriginalType } = createOptionValueConverter(options);\n\n // classNames from slots\n const variants = selectVariants();\n const classNames = variantsToClassNames(variants, className, 'base');\n\n // React-select classNames configuration\n const reactSelectClassNames = {\n clearIndicator: () => {\n return classNames.clearIndicator;\n },\n control: () => {\n return cn(classNames.control, {\n [classNames.control_focused]: isFocused && !invalid,\n });\n },\n dropdownIndicator: () => {\n return classNames.dropdownIndicator;\n },\n groupHeading: () => {\n return classNames.groupHeading;\n },\n indicatorSeparator: () => {\n return classNames.indicatorSeparator;\n },\n indicatorsContainer: () => {\n return classNames.indicatorsContainer;\n },\n input: () => {\n return classNames.input;\n },\n loadingIndicator: () => {\n return classNames.loadingIndicator;\n },\n loadingMessage: () => {\n return classNames.loadingMessage;\n },\n menu: () => {\n return classNames.menu;\n },\n menuList: () => {\n return classNames.menuList;\n },\n menuPortal: () => {\n return classNames.menuPortal;\n },\n multiValue: () => {\n return classNames.multiValue;\n },\n multiValueLabel: () => {\n return cn(classNames.multiValueLabel, `${getValueProps().className}`);\n },\n multiValueRemove: () => {\n return classNames.multiValueRemove;\n },\n noOptionsMessage: () => {\n return classNames.noOptionsMessage;\n },\n option: ({\n isDisabled: optionIsDisabled,\n isFocused: optionIsFocused,\n isSelected: optionIsSelected,\n }: {\n isDisabled: boolean;\n isFocused: boolean;\n isSelected: boolean;\n }) => {\n return cn(classNames.option, {\n [classNames.option_disabled]: optionIsDisabled,\n [classNames.option_focused]: optionIsFocused,\n [classNames.option_selected]: optionIsSelected,\n });\n },\n placeholder: () => {\n return classNames.placeholder;\n },\n singleValue: () => {\n return cn(classNames.singleValue, `${getValueProps().className}`);\n },\n valueContainer: () => {\n return classNames.valueContainer;\n },\n };\n\n const { getBaseProps, getTriggerProps, getValueProps } = useSelect({\n children: [],\n classNames,\n errorMessage,\n isDisabled: disabled,\n isInvalid: invalid,\n isLoading: loading,\n isRequired: required,\n label,\n labelPlacement: 'outside',\n });\n\n // react-select expects `isDisabled`, while our option contract uses `disabled`.\n const reactSelectOptions = options.map((option) => {\n return {\n ...option,\n isDisabled: option.disabled,\n };\n });\n\n // Compute selected option(s) for react-select\n //\n // Priority for finding options:\n // 1. Look in current options list\n // 2. Use selectedOptionFallback prop (for async selects with pre-fetched data)\n // 3. Create fallback with value as label\n //\n // Handles edge cases:\n // - Compares as strings to support both string and number values\n // - Returns null for empty single-select (required by react-select to clear)\n // - Creates fallback options when value exists but isn't in options list\n // (common with async selects where options change after selection)\n const reactSelectValue = (() => {\n // Helper to find option by value\n const findOption = (v: string | number): SelectOption => {\n // First, look in options list\n const inOptions = options.find((option) => {\n return String(option.value) === String(v);\n });\n if (inOptions) {\n return inOptions;\n }\n\n // Second, look in selectedOptionFallback prop (for async selects)\n if (selectedOptionFallback) {\n if (Array.isArray(selectedOptionFallback)) {\n const inSelected = selectedOptionFallback.find((option) => {\n return String(option.value) === String(v);\n });\n if (inSelected) {\n return inSelected;\n }\n } else if (String(selectedOptionFallback.value) === String(v)) {\n return selectedOptionFallback;\n }\n }\n\n // Fallback: create option with value as label, marked as fallback\n return { isFallback: true, label: String(v), value: v };\n };\n\n if (multiSelect) {\n if (!Array.isArray(value) || isValueEmpty(value)) {\n return [];\n }\n return value.map((v) => {\n return findOption(v);\n });\n }\n\n // Single select - use isValueEmpty to handle marker strings (__NULL__, etc.)\n if (isValueEmpty(value)) {\n return null;\n }\n return findOption(value);\n })();\n\n // Handle selection change\n const handleChange = (\n option: MultiValue<SelectOption> | SingleValue<SelectOption>,\n ) => {\n if (multiSelect) {\n onChange(\n (option as SelectOption[])?.map((_option) => {\n return convertToOriginalType(_option.value);\n }),\n );\n } else {\n const newValue = (option as SelectOption)?.value;\n // Pass null explicitly when clearing (not undefined)\n onChange(newValue != null ? convertToOriginalType(newValue) : null);\n }\n\n // Mark field as touched immediately when a selection is made if not already touched\n // This ensures validation errors show right away (isTouched becomes true)\n // For Select components, selecting an option is a complete user action\n // (unlike text inputs where typing is ongoing), so we mark as touched immediately\n const { isTouched: currentIsTouched } = getFieldState(name, testId);\n if (!currentIsTouched) {\n // Defer blur/touched notification until after the onChange value commit.\n // This prevents \"one render cycle behind\" validation states where blur\n // validation runs against the previous value.\n queueMicrotask(() => {\n onBlur();\n });\n }\n };\n\n // Handle blur event\n const handleBlur = () => {\n setIsFocused(false);\n onBlur();\n };\n\n // Handle focus event\n const handleFocus = () => {\n setIsFocused(true);\n };\n\n return (\n <div\n {...getBaseProps()}\n className={cn(classNames.base)}\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-required={required}\n data-testid={`${testId}_wrapper`}\n >\n {label ? (\n <label\n className={classNames.label}\n data-slot=\"label\"\n htmlFor={`react-select-${name}-input`}\n id={getLabelProps().id}\n >\n {label}\n {required ? (\n <span aria-hidden className=\"ml-0.5 text-danger\">\n *\n </span>\n ) : null}\n </label>\n ) : null}\n <ReactSelect\n ref={ref}\n aria-errormessage=\"\"\n aria-invalid={invalid}\n aria-label={ariaLabel}\n // set aria-labelledby to the label id so that the select is accessible\n aria-labelledby={\n label\n ? getTriggerProps()['aria-labelledby']?.split(' ')[1]\n : undefined\n }\n classNames={reactSelectClassNames}\n components={{\n Control: ControlComponent,\n DropdownIndicator: DropdownIndicatorComponent,\n Input: InputComponent,\n Option: OptionComponent,\n }}\n // Does not affect the testId of the select, but is needed to pass it to sub-components\n data-testid={testId}\n filterOption={filterOption}\n formatOptionLabel={renderOptionLabel}\n inputValue={inputValue}\n instanceId={name}\n isClearable={clearable}\n isDisabled={disabled}\n isLoading={loading}\n isMulti={multiSelect}\n menuIsOpen={debugMenuOpen ? true : undefined}\n // set menuPosition to fixed so that menu can be rendered\n // inside Card / Modal components, menuShouldBlockScroll\n // prevents container scroll when menu is open\n menuPosition=\"fixed\"\n menuShouldBlockScroll\n name={name}\n noOptionsMessage={renderEmptyOptions}\n onBlur={handleBlur}\n onChange={handleChange}\n onFocus={handleFocus}\n onInputChange={onInputChange}\n options={reactSelectOptions}\n placeholder={placeholder}\n unstyled\n value={reactSelectValue}\n />\n {invalid ? (\n <div {...getHelperWrapperProps()}>\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Select;\n","import Select from './Select';\n\nexport type { SelectProps, SelectOption } from './Select';\n\nexport { selectVariants } from './Select';\n\nexport { Select };\n\nexport default Select;\n"],"mappings":";;;;;;;;;;;AAeA,MAAa,kBAAA,GAAA,uBAAA,IAAoB,EAC/B,OAAO;CACL,MAAM;CACN,gBACE;CACF,SACE;CACF,iBAAiB;CACjB,WAAW;CACX,aAAa;CACb,mBACE;CACF,OAAO;CACP,cAAc;CACd,qBAAqB;CACrB,oBAAoB;CACpB,OAAO;CAGP,OACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,MAAM;CACN,UAAU;CAGV,YAAY;CACZ,YAAY;CACZ,qBAAqB;CACrB,iBAAiB;CACjB,kBACE;CACF,kBAAkB;CAClB,QAAQ;CACR,iBACE;CACF,gBAAgB;CAChB,iBAAiB;CACjB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AClB,QAAQ;IACR,UAAU;IACV,SAAS;IACM;IACf,SAAS;IACI;IACb,UAAA;IACA,OAAO;GACR,CAAA;GACA,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IAAK,GAAI,sBAAsB;cAC7B,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;ACheA,IAAA,iBAAe"}
@@ -2,6 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Slider = require("../Slider-Bpxt-Qgj.cjs");
5
+ const require_Slider = require("../Slider-ChC2PZNb.cjs");
6
6
  exports.Slider = require_Slider.Slider;
7
7
  exports.default = require_Slider.Slider_default;
8
+ exports.sliderVariants = require_Slider.sliderVariants;
@@ -1,2 +1,2 @@
1
- import { n as SliderProps, t as Slider } from "../index-CSRKNes5.cjs";
2
- export { Slider, Slider as default, type SliderProps };
1
+ import { n as SliderProps, r as sliderVariants, t as Slider } from "../index-Bie3CWyW.cjs";
2
+ export { Slider, Slider as default, type SliderProps, sliderVariants };
@@ -1,2 +1,2 @@
1
- import { n as SliderProps, t as Slider } from "../index-B4jKGy-P.js";
2
- export { Slider, Slider as default, type SliderProps };
1
+ import { n as SliderProps, r as sliderVariants, t as Slider } from "../index-BUZEnZDm.js";
2
+ export { Slider, Slider as default, type SliderProps, sliderVariants };
@@ -1,2 +1,2 @@
1
- import { n as Slider, t as Slider_default } from "../Slider-DRfSw0uE.js";
2
- export { Slider, Slider_default as default };
1
+ import { n as Slider, r as sliderVariants, t as Slider_default } from "../Slider-DmEwhC1T.js";
2
+ export { Slider, Slider_default as default, sliderVariants };
@@ -116,5 +116,11 @@ Object.defineProperty(exports, "Slider_default", {
116
116
  return Slider_default;
117
117
  }
118
118
  });
119
+ Object.defineProperty(exports, "sliderVariants", {
120
+ enumerable: true,
121
+ get: function() {
122
+ return sliderVariants;
123
+ }
124
+ });
119
125
 
120
- //# sourceMappingURL=Slider-Bpxt-Qgj.cjs.map
126
+ //# sourceMappingURL=Slider-ChC2PZNb.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slider-Bpxt-Qgj.cjs","names":["useUniformField","VisuallyHidden","HeroUISlider"],"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 { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/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 /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\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 */\n label?: string;\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 ariaLabel,\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={ariaLabel}\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 aria-label={ariaLabel}\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 onBlur={onBlur}\n onChange={onChange}\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 />\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\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":";;;;;;;;AAYA,MAAa,kBAAA,GAAA,uBAAA,IAAoB,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CACd,QAAQ;CAGR,OACE;CACF,cAAc;CACd,MAAM;CACN,cAAc;CACd,MAAM;CACN,OAAO;CACP,OAAO;CACP,cAAc;CACd,OAAO;AACT,EACF,CAAC;;;;AAsDD,MAAM,UAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,aAAa,KAAA,GACb,MACA,YAAY,OACZ,OAAO,MACP,eAAe,KAAA,GACf,OAAO,GACP,WAAW,GACX,WAAW,KACX,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,UACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,cACA,WACEA,oCAAAA,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,mBAAA,GAAA,MAAA,QAAyC,IAAI;CAInD,MAAM,cAAA,GAAA,uBAAA,sBADW,eAC8B,GAAG,WAAW,MAAM;CAGnE,MAAM,eAAe,MAAM,SAAS,OAAO,OAAO,MAAM,KAAK,IAAI;CAEjE,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EACE,WAAW,WAAW;EACtB,gBAAc;EACd,iBAAe;EACf,eAAa;YAJf;GAOE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;IACO;IACL,cAAY;IACF;IACV,KAAK;IACL,KAAK;IACC;IACE;IACF;IACN,UAAU;IACV,MAAK;IACL,OAAO;IACP,WAAW,MAAM;KACf,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;IACjC;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,iBAAA,GAAA,kBAAA,KAACC,eAAAA,QAAD;IACE,KAAK;IACL,cAAY;IACZ,OAAO,UAAU,WAAW;IAChB;IACA;IACZ,YAAY;IACL;IACG;IACA;IACV,MAAM,GAAG,KAAK;IACN;IACE;IACC;IACL;IACQ;IACR;IACN,OAAO;IACP,YAAY;KACV,YAAY,WAAW;KACvB,QAAQ,WAAW;KACnB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,OAAO,WAAW;KAClB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,OAAO,WAAW;IACpB;GACD,CAAA;GACA,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,YAAA,GAAA,uBAAA,IACE,sBAAsB,GAAG,WAEzB,YACF;cAEA,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;ACvMA,IAAA,iBAAe"}
1
+ {"version":3,"file":"Slider-ChC2PZNb.cjs","names":["useUniformField","VisuallyHidden","HeroUISlider"],"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 { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/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 /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\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 */\n label?: string;\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 ariaLabel,\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={ariaLabel}\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 aria-label={ariaLabel}\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 onBlur={onBlur}\n onChange={onChange}\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 />\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { sliderVariants } from './Slider';\n\nexport { Slider };\n\nexport default Slider;\n"],"mappings":";;;;;;;;AAYA,MAAa,kBAAA,GAAA,uBAAA,IAAoB,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CACd,QAAQ;CAGR,OACE;CACF,cAAc;CACd,MAAM;CACN,cAAc;CACd,MAAM;CACN,OAAO;CACP,OAAO;CACP,cAAc;CACd,OAAO;AACT,EACF,CAAC;;;;AAsDD,MAAM,UAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,aAAa,KAAA,GACb,MACA,YAAY,OACZ,OAAO,MACP,eAAe,KAAA,GACf,OAAO,GACP,WAAW,GACX,WAAW,KACX,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,UACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,cACA,WACEA,oCAAAA,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,mBAAA,GAAA,MAAA,QAAyC,IAAI;CAInD,MAAM,cAAA,GAAA,uBAAA,sBADW,eAC8B,GAAG,WAAW,MAAM;CAGnE,MAAM,eAAe,MAAM,SAAS,OAAO,OAAO,MAAM,KAAK,IAAI;CAEjE,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EACE,WAAW,WAAW;EACtB,gBAAc;EACd,iBAAe;EACf,eAAa;YAJf;GAOE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;IACO;IACL,cAAY;IACF;IACV,KAAK;IACL,KAAK;IACC;IACE;IACF;IACN,UAAU;IACV,MAAK;IACL,OAAO;IACP,WAAW,MAAM;KACf,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;IACjC;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,iBAAA,GAAA,kBAAA,KAACC,eAAAA,QAAD;IACE,KAAK;IACL,cAAY;IACZ,OAAO,UAAU,WAAW;IAChB;IACA;IACZ,YAAY;IACL;IACG;IACA;IACV,MAAM,GAAG,KAAK;IACN;IACE;IACC;IACL;IACQ;IACR;IACN,OAAO;IACP,YAAY;KACV,YAAY,WAAW;KACvB,QAAQ,WAAW;KACnB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,OAAO,WAAW;KAClB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,OAAO,WAAW;IACpB;GACD,CAAA;GACA,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,YAAA,GAAA,uBAAA,IACE,sBAAsB,GAAG,WAEzB,YACF;cAEA,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;ACrMA,IAAA,iBAAe"}
@@ -103,6 +103,6 @@ const Slider$1 = ({ className = void 0, endContent = void 0, fillOffset = void 0
103
103
  //#region src/Slider/index.ts
104
104
  var Slider_default = Slider$1;
105
105
  //#endregion
106
- export { Slider$1 as n, Slider_default as t };
106
+ export { Slider$1 as n, sliderVariants as r, Slider_default as t };
107
107
 
108
- //# sourceMappingURL=Slider-DRfSw0uE.js.map
108
+ //# sourceMappingURL=Slider-DmEwhC1T.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Slider-DRfSw0uE.js","names":["Slider","HeroUISlider","Slider"],"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 { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/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 /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\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 */\n label?: string;\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 ariaLabel,\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={ariaLabel}\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 aria-label={ariaLabel}\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 onBlur={onBlur}\n onChange={onChange}\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 />\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\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":";;;;;;;AAYA,MAAa,iBAAiB,GAAG,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CACd,QAAQ;CAGR,OACE;CACF,cAAc;CACd,MAAM;CACN,cAAc;CACd,MAAM;CACN,OAAO;CACP,OAAO;CACP,cAAc;CACd,OAAO;AACT,EACF,CAAC;;;;AAsDD,MAAMA,YAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,aAAa,KAAA,GACb,MACA,YAAY,OACZ,OAAO,MACP,eAAe,KAAA,GACf,OAAO,GACP,WAAW,GACX,WAAW,KACX,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,UACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,cACA,WACE,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,kBAAkB,OAAuB,IAAI;CAInD,MAAM,aAAa,qBADF,eAC8B,GAAG,WAAW,MAAM;CAGnE,MAAM,eAAe,MAAM,SAAS,OAAO,OAAO,MAAM,KAAK,IAAI;CAEjE,OACE,qBAAC,OAAD;EACE,WAAW,WAAW;EACtB,gBAAc;EACd,iBAAe;EACf,eAAa;YAJf;GAOE,oBAAC,gBAAD,EAAA,UACE,oBAAC,SAAD;IACO;IACL,cAAY;IACF;IACV,KAAK;IACL,KAAK;IACC;IACE;IACF;IACN,UAAU;IACV,MAAK;IACL,OAAO;IACP,WAAW,MAAM;KACf,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;IACjC;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,oBAACC,QAAD;IACE,KAAK;IACL,cAAY;IACZ,OAAO,UAAU,WAAW;IAChB;IACA;IACZ,YAAY;IACL;IACG;IACA;IACV,MAAM,GAAG,KAAK;IACN;IACE;IACC;IACL;IACQ;IACR;IACN,OAAO;IACP,YAAY;KACV,YAAY,WAAW;KACvB,QAAQ,WAAW;KACnB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,OAAO,WAAW;KAClB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,OAAO,WAAW;IACpB;GACD,CAAA;GACA,UACC,oBAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,GAAG,WAEzB,YACF;cAEA,oBAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;ACvMA,IAAA,iBAAeC"}
1
+ {"version":3,"file":"Slider-DmEwhC1T.js","names":["Slider","HeroUISlider","Slider"],"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 { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/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 /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\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 */\n label?: string;\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 ariaLabel,\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={ariaLabel}\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 aria-label={ariaLabel}\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 onBlur={onBlur}\n onChange={onChange}\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 />\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Slider;\n","import Slider from './Slider';\n\nexport type { SliderProps } from './Slider';\n\nexport { sliderVariants } from './Slider';\n\nexport { Slider };\n\nexport default Slider;\n"],"mappings":";;;;;;;AAYA,MAAa,iBAAiB,GAAG,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CACd,QAAQ;CAGR,OACE;CACF,cAAc;CACd,MAAM;CACN,cAAc;CACd,MAAM;CACN,OAAO;CACP,OAAO;CACP,cAAc;CACd,OAAO;AACT,EACF,CAAC;;;;AAsDD,MAAMA,YAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,aAAa,KAAA,GACb,MACA,YAAY,OACZ,OAAO,MACP,eAAe,KAAA,GACf,OAAO,GACP,WAAW,GACX,WAAW,KACX,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,UACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,cACA,WACE,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,kBAAkB,OAAuB,IAAI;CAInD,MAAM,aAAa,qBADF,eAC8B,GAAG,WAAW,MAAM;CAGnE,MAAM,eAAe,MAAM,SAAS,OAAO,OAAO,MAAM,KAAK,IAAI;CAEjE,OACE,qBAAC,OAAD;EACE,WAAW,WAAW;EACtB,gBAAc;EACd,iBAAe;EACf,eAAa;YAJf;GAOE,oBAAC,gBAAD,EAAA,UACE,oBAAC,SAAD;IACO;IACL,cAAY;IACF;IACV,KAAK;IACL,KAAK;IACC;IACE;IACF;IACN,UAAU;IACV,MAAK;IACL,OAAO;IACP,WAAW,MAAM;KACf,SAAS,OAAO,EAAE,OAAO,KAAK,CAAC;IACjC;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,oBAACC,QAAD;IACE,KAAK;IACL,cAAY;IACZ,OAAO,UAAU,WAAW;IAChB;IACA;IACZ,YAAY;IACL;IACG;IACA;IACV,MAAM,GAAG,KAAK;IACN;IACE;IACC;IACL;IACQ;IACR;IACN,OAAO;IACP,YAAY;KACV,YAAY,WAAW;KACvB,QAAQ,WAAW;KACnB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,cAAc,WAAW;KACzB,MAAM,WAAW;KACjB,OAAO,WAAW;KAClB,OAAO,WAAW;KAClB,cAAc,WAAW;KACzB,OAAO,WAAW;IACpB;GACD,CAAA;GACA,UACC,oBAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,GAAG,WAEzB,YACF;cAEA,oBAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;ACrMA,IAAA,iBAAeC"}
@@ -2,6 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_Switch = require("../Switch-hjjy34QB.cjs");
5
+ const require_Switch = require("../Switch-Ch6_VInV.cjs");
6
6
  exports.Switch = require_Switch.Switch;
7
7
  exports.default = require_Switch.Switch_default;
8
+ exports.switchVariants = require_Switch.switchVariants;
@@ -1,2 +1,2 @@
1
- import { n as SwitchProps, t as Switch } from "../index-DMOhTl4I.cjs";
2
- export { Switch, Switch as default, type SwitchProps };
1
+ import { n as SwitchProps, r as switchVariants, t as Switch } from "../index-19JGtN7H.cjs";
2
+ export { Switch, Switch as default, type SwitchProps, switchVariants };
@@ -1,2 +1,2 @@
1
- import { n as SwitchProps, t as Switch } from "../index-C6DBVs7t.js";
2
- export { Switch, Switch as default, type SwitchProps };
1
+ import { n as SwitchProps, r as switchVariants, t as Switch } from "../index-DqMpHpu7.js";
2
+ export { Switch, Switch as default, type SwitchProps, switchVariants };
@@ -1,2 +1,2 @@
1
- import { n as Switch, t as Switch_default } from "../Switch-D9DNrqmj.js";
2
- export { Switch, Switch_default as default };
1
+ import { n as Switch, r as switchVariants, t as Switch_default } from "../Switch-DvKRPFcC.js";
2
+ export { Switch, Switch_default as default, switchVariants };
@@ -89,5 +89,11 @@ Object.defineProperty(exports, "Switch_default", {
89
89
  return Switch_default;
90
90
  }
91
91
  });
92
+ Object.defineProperty(exports, "switchVariants", {
93
+ enumerable: true,
94
+ get: function() {
95
+ return switchVariants;
96
+ }
97
+ });
92
98
 
93
- //# sourceMappingURL=Switch-hjjy34QB.cjs.map
99
+ //# sourceMappingURL=Switch-Ch6_VInV.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch-hjjy34QB.cjs","names":["useUniformField","VisuallyHidden","HeroSwitch"],"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = undefined,\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchProps) => {\n const {\n ariaLabel,\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n checked={!!field.value}\n name={name}\n onBlur={onBlur}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroSwitch component */}\n <HeroSwitch\n ref={visualSwitchRef}\n aria-label={ariaLabel}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultSelected={!!defaultValue}\n endContent={endContent}\n isDisabled={disabled}\n isSelected={!!field.value}\n name={`${name}_switch`}\n onValueChange={onChange}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n >\n {label}\n </HeroSwitch>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;;AAaA,MAAa,kBAAA,GAAA,uBAAA,IAAoB,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CAGd,OACE;CACF,cAAc;CACd,cAAc;CACd,OAAO;CACP,WAAW;CACX,SAAS;AACX,EACF,CAAC;;;;AA+BD,MAAM,UAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,MACA,OAAO,KAAA,GACP,eAAe,KAAA,GACf,YAAY,KAAA,GACZ,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACEA,oCAAAA,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,mBAAA,GAAA,MAAA,QAA2C,IAAI;CAIrD,MAAM,cAAA,GAAA,uBAAA,sBADW,eAC8B,GAAG,WAAW,cAAc;CAE3E,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EAAK,WAAW,WAAW;YAA3B;GAEE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;IACO;IACL,cAAY;IACZ,SAAS,CAAC,CAAC,MAAM;IACX;IACE;IACR,MAAK;IACL,WAAW,MAAM;KACf,SAAS,EAAE,OAAO,OAAO;IAC3B;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,iBAAA,GAAA,kBAAA,KAACC,eAAAA,QAAD;IACE,KAAK;IACL,cAAY;IACA;IACZ,gBAAc;IACd,iBAAe;IACf,eAAa;IACb,iBAAiB,CAAC,CAAC;IACP;IACZ,YAAY;IACZ,YAAY,CAAC,CAAC,MAAM;IACpB,MAAM,GAAG,KAAK;IACd,eAAe;IACT;IACQ;IACH;cAEV;GACS,CAAA;GACX,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,YAAA,GAAA,uBAAA,IACE,sBAAsB,GAAG,WAEzB,YACF;cAEA,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;AChJA,IAAA,iBAAe"}
1
+ {"version":3,"file":"Switch-Ch6_VInV.cjs","names":["useUniformField","VisuallyHidden","HeroSwitch"],"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = undefined,\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchProps) => {\n const {\n ariaLabel,\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n checked={!!field.value}\n name={name}\n onBlur={onBlur}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroSwitch component */}\n <HeroSwitch\n ref={visualSwitchRef}\n aria-label={ariaLabel}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultSelected={!!defaultValue}\n endContent={endContent}\n isDisabled={disabled}\n isSelected={!!field.value}\n name={`${name}_switch`}\n onValueChange={onChange}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n >\n {label}\n </HeroSwitch>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { switchVariants } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;;AAaA,MAAa,kBAAA,GAAA,uBAAA,IAAoB,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CAGd,OACE;CACF,cAAc;CACd,cAAc;CACd,OAAO;CACP,WAAW;CACX,SAAS;AACX,EACF,CAAC;;;;AA+BD,MAAM,UAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,MACA,OAAO,KAAA,GACP,eAAe,KAAA,GACf,YAAY,KAAA,GACZ,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACEA,oCAAAA,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,mBAAA,GAAA,MAAA,QAA2C,IAAI;CAIrD,MAAM,cAAA,GAAA,uBAAA,sBADW,eAC8B,GAAG,WAAW,cAAc;CAE3E,OACE,iBAAA,GAAA,kBAAA,MAAC,OAAD;EAAK,WAAW,WAAW;YAA3B;GAEE,iBAAA,GAAA,kBAAA,KAACC,4BAAAA,gBAAD,EAAA,UACE,iBAAA,GAAA,kBAAA,KAAC,SAAD;IACO;IACL,cAAY;IACZ,SAAS,CAAC,CAAC,MAAM;IACX;IACE;IACR,MAAK;IACL,WAAW,MAAM;KACf,SAAS,EAAE,OAAO,OAAO;IAC3B;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,iBAAA,GAAA,kBAAA,KAACC,eAAAA,QAAD;IACE,KAAK;IACL,cAAY;IACA;IACZ,gBAAc;IACd,iBAAe;IACf,eAAa;IACb,iBAAiB,CAAC,CAAC;IACP;IACZ,YAAY;IACZ,YAAY,CAAC,CAAC,MAAM;IACpB,MAAM,GAAG,KAAK;IACd,eAAe;IACT;IACQ;IACH;cAEV;GACS,CAAA;GACX,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,YAAA,GAAA,uBAAA,IACE,sBAAsB,GAAG,WAEzB,YACF;cAEA,iBAAA,GAAA,kBAAA,KAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;AC9IA,IAAA,iBAAe"}
@@ -76,6 +76,6 @@ const Switch$1 = ({ className = void 0, endContent = void 0, name, size = void 0
76
76
  //#region src/Switch/index.ts
77
77
  var Switch_default = Switch$1;
78
78
  //#endregion
79
- export { Switch$1 as n, Switch_default as t };
79
+ export { Switch$1 as n, switchVariants as r, Switch_default as t };
80
80
 
81
- //# sourceMappingURL=Switch-D9DNrqmj.js.map
81
+ //# sourceMappingURL=Switch-DvKRPFcC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Switch-D9DNrqmj.js","names":["Switch","HeroSwitch","Switch"],"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = undefined,\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchProps) => {\n const {\n ariaLabel,\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n checked={!!field.value}\n name={name}\n onBlur={onBlur}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroSwitch component */}\n <HeroSwitch\n ref={visualSwitchRef}\n aria-label={ariaLabel}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultSelected={!!defaultValue}\n endContent={endContent}\n isDisabled={disabled}\n isSelected={!!field.value}\n name={`${name}_switch`}\n onValueChange={onChange}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n >\n {label}\n </HeroSwitch>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;AAaA,MAAa,iBAAiB,GAAG,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CAGd,OACE;CACF,cAAc;CACd,cAAc;CACd,OAAO;CACP,WAAW;CACX,SAAS;AACX,EACF,CAAC;;;;AA+BD,MAAMA,YAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,MACA,OAAO,KAAA,GACP,eAAe,KAAA,GACf,YAAY,KAAA,GACZ,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,kBAAkB,OAAyB,IAAI;CAIrD,MAAM,aAAa,qBADF,eAC8B,GAAG,WAAW,cAAc;CAE3E,OACE,qBAAC,OAAD;EAAK,WAAW,WAAW;YAA3B;GAEE,oBAAC,gBAAD,EAAA,UACE,oBAAC,SAAD;IACO;IACL,cAAY;IACZ,SAAS,CAAC,CAAC,MAAM;IACX;IACE;IACR,MAAK;IACL,WAAW,MAAM;KACf,SAAS,EAAE,OAAO,OAAO;IAC3B;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,oBAACC,QAAD;IACE,KAAK;IACL,cAAY;IACA;IACZ,gBAAc;IACd,iBAAe;IACf,eAAa;IACb,iBAAiB,CAAC,CAAC;IACP;IACZ,YAAY;IACZ,YAAY,CAAC,CAAC,MAAM;IACpB,MAAM,GAAG,KAAK;IACd,eAAe;IACT;IACQ;IACH;cAEV;GACS,CAAA;GACX,UACC,oBAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,GAAG,WAEzB,YACF;cAEA,oBAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;AChJA,IAAA,iBAAeC"}
1
+ {"version":3,"file":"Switch-DvKRPFcC.js","names":["Switch","HeroSwitch","Switch"],"sources":["../src/Switch/Switch.tsx","../src/Switch/index.ts"],"sourcesContent":["import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { Switch as HeroSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchVariants = tv({\n slots: {\n base: '',\n endContent: '',\n errorMessage: 'ml-1 mt-1',\n // see HeroUI styles for group-data condition,\n // e.g.: https://github.com/heroui-inc/heroui/blob/main/packages/core/theme/src/components/select.ts\n label:\n 'text-sm text-foreground subpixel-antialiased group-data-[invalid=true]:!text-danger group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n outerWrapper: 'place-content-center',\n startContent: '',\n thumb: '',\n thumbIcon: '',\n wrapper: '',\n },\n});\n\ntype VariantProps = TVProps<typeof switchVariants>;\ntype ClassName = TVClassName<typeof switchVariants>;\n\nexport interface SwitchProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** whether the select should be disabled */\n disabled?: boolean;\n /** Icon to be displayed at the end of the switch (when enabled) */\n endContent?: ReactNode;\n /** component displayed next to the switch */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** Icon to be displayed at the start of the switch (when disabled) */\n startContent?: ReactNode;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * Switch component based on [HeroUI Switch](https://www.heroui.com//docs/components/switch)\n */\nconst Switch = ({\n className = undefined,\n endContent = undefined,\n name,\n size = undefined,\n startContent = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchProps) => {\n const {\n ariaLabel,\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // classNames from slots\n const variants = switchVariants();\n const classNames = variantsToClassNames(variants, className, 'outerWrapper');\n\n return (\n <div className={classNames.outerWrapper}>\n {/* Visually hidden input for form accessibility and focus management */}\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={ariaLabel}\n checked={!!field.value}\n name={name}\n onBlur={onBlur}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n </VisuallyHidden>\n {/* Visual HeroSwitch component */}\n <HeroSwitch\n ref={visualSwitchRef}\n aria-label={ariaLabel}\n classNames={classNames}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n defaultSelected={!!defaultValue}\n endContent={endContent}\n isDisabled={disabled}\n isSelected={!!field.value}\n name={`${name}_switch`}\n onValueChange={onChange}\n size={size}\n startContent={startContent}\n thumbIcon={thumbIcon}\n >\n {label}\n </HeroSwitch>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default Switch;\n","import Switch from './Switch';\n\nexport type { SwitchProps } from './Switch';\n\nexport { switchVariants } from './Switch';\n\nexport { Switch };\n\nexport default Switch;\n"],"mappings":";;;;;;;AAaA,MAAa,iBAAiB,GAAG,EAC/B,OAAO;CACL,MAAM;CACN,YAAY;CACZ,cAAc;CAGd,OACE;CACF,cAAc;CACd,cAAc;CACd,OAAO;CACP,WAAW;CACX,SAAS;AACX,EACF,CAAC;;;;AA+BD,MAAMA,YAAU,EACd,YAAY,KAAA,GACZ,aAAa,KAAA,GACb,MACA,OAAO,KAAA,GACP,eAAe,KAAA,GACf,YAAY,KAAA,GACZ,GAAG,wBACc;CACjB,MAAM,EACJ,WACA,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACE,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,kBAAkB,OAAyB,IAAI;CAIrD,MAAM,aAAa,qBADF,eAC8B,GAAG,WAAW,cAAc;CAE3E,OACE,qBAAC,OAAD;EAAK,WAAW,WAAW;YAA3B;GAEE,oBAAC,gBAAD,EAAA,UACE,oBAAC,SAAD;IACO;IACL,cAAY;IACZ,SAAS,CAAC,CAAC,MAAM;IACX;IACE;IACR,MAAK;IACL,WAAW,MAAM;KACf,SAAS,EAAE,OAAO,OAAO;IAC3B;IACA,eAAe;KAGb,gBAAgB,SAAS,MAAM;IACjC;GACD,CAAA,EACa,CAAA;GAEhB,oBAACC,QAAD;IACE,KAAK;IACL,cAAY;IACA;IACZ,gBAAc;IACd,iBAAe;IACf,eAAa;IACb,iBAAiB,CAAC,CAAC;IACP;IACZ,YAAY;IACZ,YAAY,CAAC,CAAC,MAAM;IACpB,MAAM,GAAG,KAAK;IACd,eAAe;IACT;IACQ;IACH;cAEV;GACS,CAAA;GACX,UACC,oBAAC,OAAD;IACE,GAAI,sBAAsB;IAC1B,WAAW,GACT,sBAAsB,GAAG,WAEzB,YACF;cAEA,oBAAC,OAAD;KAAK,GAAI,qBAAqB;eAAI;IAAkB,CAAA;GACjD,CAAA,IACH;EACD;;AAET;;;AC9IA,IAAA,iBAAeC"}
@@ -1,2 +1,2 @@
1
- import { n as SwitchBoxProps, r as switchBoxVariants, t as SwitchBox } from "../index-CxY9VWv5.cjs";
1
+ import { n as SwitchBoxProps, r as switchBoxVariants, t as SwitchBox } from "../index-Cf2B9woY.cjs";
2
2
  export { SwitchBox, SwitchBox as default, type SwitchBoxProps, switchBoxVariants };
@@ -1,2 +1,2 @@
1
- import { n as SwitchBoxProps, r as switchBoxVariants, t as SwitchBox } from "../index-Cwb7sTO0.js";
1
+ import { n as SwitchBoxProps, r as switchBoxVariants, t as SwitchBox } from "../index-amMd-sQN.js";
2
2
  export { SwitchBox, SwitchBox as default, type SwitchBoxProps, switchBoxVariants };
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchBox-BU1XieaZ.js","names":[],"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\nexport { SwitchBox };\n\nexport default SwitchBox;\n"],"mappings":";;;;;;;AAaA,MAAa,oBAAoB,GAAG;CAClC,OAAO;EACL,KAAK;EACL,aAAa;EACb,MAAM;EACN,OACE;EACF,SAAS;EACT,OAAO;EACP,WAAW;CACb;CACA,UAAU;EACR,YAAY,EACV,MAAM,EACJ,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G,WAEzB,YACF;YAEA,oBAAC,OAAD;GAAK,GAAI,qBAAqB;aAAI;EAAkB,CAAA;CACjD,CAAA,IACH,IACJ,EAAA,CAAA;AAEN;;;ACzOA,IAAA,oBAAe"}
1
+ {"version":3,"file":"SwitchBox-BU1XieaZ.js","names":[],"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\n\nexport { SwitchBox };\n\nexport default SwitchBox;\n"],"mappings":";;;;;;;AAaA,MAAa,oBAAoB,GAAG;CAClC,OAAO;EACL,KAAK;EACL,aAAa;EACb,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F,CAAA,IACJ;EACK;KACV,UACC,oBAAC,OAAD;EACE,GAAI,sBAAsB;EAC1B,WAAW,GACT,sBAAsB,GAAG,WAEzB,YACF;YAEA,oBAAC,OAAD;GAAK,GAAI,qBAAqB;aAAI;EAAkB,CAAA;CACjD,CAAA,IACH,IACJ,EAAA,CAAA;AAEN;;;ACxOA,IAAA,oBAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"SwitchBox-Dl-F5y2m.cjs","names":["useUniformField","VisuallyHidden"],"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\nexport { SwitchBox };\n\nexport default SwitchBox;\n"],"mappings":";;;;;;;;AAaA,MAAa,qBAAA,GAAA,uBAAA,IAAuB;CAClC,OAAO;EACL,KAAK;EACL,aAAa;EACb,MAAM;EACN,OACE;EACF,SAAS;EACT,OAAO;EACP,WAAW;CACb;CACA,UAAU;EACR,YAAY,EACV,MAAM,EACJ,KAAK,uCACP,EACF;EACA,WAAW,EACT,MAAM;GACJ,KAAK;GACL,OAAO;EACT,EACF;EACA,MAAM;GACJ,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;GACA,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;GACA,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;EACF;CACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC;;;;AA8BD,MAAM,aAAa,EACjB,YAAY,KAAA,GACZ,cAAc,KAAA,GACd,OAAO,KAAA,GACP,MACA,OAAO,KAAA,GACP,YAAY,KAAA,GACZ,GAAG,wBACiB;CACpB,MAAM,EACJ,cACA,UACA,cACA,OACA,sBACA,uBACA,SACA,OACA,QACA,UACA,KACA,UACA,WACEA,oCAAAA,gBAAgB;EAClB;EACA,GAAG;CACL,CAAC;CAGD,MAAM,mBAAA,GAAA,MAAA,QAA2C,IAAI;CAGrD,MAAM,EACJ,WACA,OACA,YACA,cACA,eACA,qBAAA,GAAA,eAAA,WACY;EACZ,iBAAiB,CAAC,CAAC;EACnB,YAAY;EACZ,YAAY,CAAC,CAAC,MAAM;EACpB,MAAM,GAAG,KAAK;EACd,eAAe;EACf;EACA;CACF,CAAC;CAQD,MAAM,cAAA,GAAA,uBAAA,sBALW,kBAAkB;EACjC,YAAY;EACZ,WAAW;EACX;CACF,CAC+C,GAAG,WAAW,KAAK;CAElE,OACE,iBAAA,GAAA,kBAAA,MAAA,kBAAA,UAAA,EAAA,UAAA,CACE,iBAAA,GAAA,kBAAA,MAAC,WAAD;EACE,GAAI,aAAa;EACjB,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A,KAAC,OAAD;KAAK,WAAW,WAAW;eAAc;IAAiB,CAAA,IACxD,IACD;;GACJ,OACC,iBAAA,GAAA,kBAAA,KAAC,QAAD;IACE,GAAI,gBAAgB;IACpB,YAAA,GAAA,uBAAA,IAAc,gBAAgB,EAAE,WAAW,WAAW,OAAO;cAE7D,iBAAA,GAAA,kBAAA,KAAC,QAAD;KAAM,YAAA,GAAA,uBAAA,IAAc,MAAM,MAAM,EAAE,OAAO,WAAW,MAAM,CAAC,CAAC;eACzD,aAAa,OAAO,cAAc,aAC/B,UAAU;MACR,YAAY,CAAC,CAAC;MACd,WAAW,MAAM,UAAU,EAAE,OAAO,WAAW,UAAU,CAAC;MAC1D,OAAO;MACP,QAAQ;MACR,gBAAgB,aAAa,SAAS;KACxC,CAAC,IACD;IACA,CAAA;GACF,CAAA,IACJ;EACK;KACV,UACC,iBAAA,GAAA,kBAAA,KAAC,OAAD;EACE,GAAI,sBAAsB;EAC1B,YAAA,GAAA,uBAAA,IACE,sBAAsB,GAAG,WAEzB,YACF;YAEA,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,qBAAqB;aAAI;EAAkB,CAAA;CACjD,CAAA,IACH,IACJ,EAAA,CAAA;AAEN;;;ACzOA,IAAA,oBAAe"}
1
+ {"version":3,"file":"SwitchBox-Dl-F5y2m.cjs","names":["useUniformField","VisuallyHidden"],"sources":["../src/SwitchBox/SwitchBox.tsx","../src/SwitchBox/index.ts"],"sourcesContent":["import type { TVClassName } from '@fuf-stack/pixel-utils';\nimport type { SwitchProps as HeroSwitchProps } from '@heroui/switch';\nimport type { ReactNode } from 'react';\n\nimport { useRef } from 'react';\n\nimport { useSwitch } from '@heroui/switch';\nimport { VisuallyHidden } from '@react-aria/visually-hidden';\n\nimport { cn, tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\n\nexport const switchBoxVariants = tv({\n slots: {\n box: 'group inline-flex w-full cursor-pointer items-center justify-between rounded-lg border-2 border-default hover:bg-content2 data-[selected=true]:border-focus',\n description: 'text-foreground opacity-70',\n icon: '',\n label:\n 'font-medium text-foreground group-data-[required=true]:after:ml-0.5 group-data-[required=true]:after:text-danger group-data-[required=true]:after:content-[\"*\"]',\n wrapper: '',\n thumb: '',\n thumbIcon: '',\n },\n variants: {\n isDisabled: {\n true: {\n box: 'pointer-events-none opacity-disabled',\n },\n },\n isInvalid: {\n true: {\n box: '!border-danger',\n label: '!text-danger',\n },\n },\n size: {\n sm: {\n box: 'gap-2 p-3',\n description: 'text-xs',\n label: 'text-xs',\n },\n md: {\n box: 'gap-4 p-4',\n description: 'text-small',\n label: 'text-sm',\n },\n lg: {\n box: 'gap-4 p-5',\n description: 'text-small',\n label: 'text-base',\n },\n },\n },\n defaultVariants: {\n size: 'md',\n },\n});\n\ntype ClassName = TVClassName<typeof switchBoxVariants>;\n\nexport interface SwitchBoxProps {\n /** CSS class name */\n className?: ClassName;\n /** Description text displayed below the label */\n description?: ReactNode;\n /** whether the switch should be disabled */\n disabled?: boolean;\n /** Icon to be displayed in the box */\n icon?: ReactNode;\n /** component displayed as the label */\n label?: ReactNode;\n /** name the field is registered under */\n name: string;\n /** whether the field is required */\n required?: boolean;\n /* Size of the switch */\n size?: 'sm' | 'md' | 'lg';\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /** Icon to be displayed inside the thumb */\n thumbIcon?: HeroSwitchProps['thumbIcon'];\n}\n\n/**\n * SwitchBox component - A card-like box with a switch control\n */\nconst SwitchBox = ({\n className = undefined,\n description = undefined,\n icon = undefined,\n name,\n size = undefined,\n thumbIcon = undefined,\n ...uniformFieldProps\n}: SwitchBoxProps) => {\n const {\n defaultValue,\n disabled,\n errorMessage,\n field,\n getErrorMessageProps,\n getHelperWrapperProps,\n invalid,\n label,\n onBlur,\n onChange,\n ref,\n required,\n testId,\n } = useUniformField({\n name,\n ...uniformFieldProps,\n });\n\n // Ref for the visual switch to forward focus\n const visualSwitchRef = useRef<HTMLInputElement>(null);\n\n // Use the useSwitch hook to get access to all the necessary props\n const {\n Component,\n slots,\n isSelected,\n getBaseProps,\n getInputProps,\n getWrapperProps,\n } = useSwitch({\n defaultSelected: !!defaultValue,\n isDisabled: disabled,\n isSelected: !!field.value,\n name: `${name}_switch`,\n onValueChange: onChange,\n size,\n thumbIcon,\n });\n\n // classNames from slots\n const variants = switchBoxVariants({\n isDisabled: disabled,\n isInvalid: invalid,\n size,\n });\n const classNames = variantsToClassNames(variants, className, 'box');\n\n return (\n <>\n <Component\n {...getBaseProps()}\n className={classNames.box}\n data-invalid={invalid}\n data-required={required}\n data-testid={testId}\n >\n <VisuallyHidden>\n <input\n ref={ref}\n aria-label={typeof label === 'string' ? label : name}\n checked={!!field.value}\n name={name}\n tabIndex={-1}\n type=\"checkbox\"\n onChange={(e) => {\n onChange(e.target.checked);\n }}\n onFocus={() => {\n // When RHF focuses this hidden input (e.g., on validation error),\n // forward focus to the visual switch to show focus ring\n visualSwitchRef.current?.focus();\n }}\n />\n {/* Visual switch input for focus ring */}\n <input\n ref={visualSwitchRef}\n {...getInputProps()}\n onBlur={(e) => {\n // Call HeroUI's internal onBlur to clear focus state and remove focus ring\n getInputProps().onBlur?.(e);\n // Then call RHF's onBlur to mark field as touched\n onBlur();\n }}\n />\n </VisuallyHidden>\n {!icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n {icon ? <div className={classNames.icon}>{icon}</div> : null}\n <div className=\"grow\">\n {label ? <div className={classNames.label}>{label}</div> : null}\n {description ? (\n <div className={classNames.description}>{description}</div>\n ) : null}\n </div>\n {icon ? (\n <span\n {...getWrapperProps()}\n className={cn(getWrapperProps().className, classNames.wrapper)}\n >\n <span className={cn(slots.thumb({ class: classNames.thumb }))}>\n {thumbIcon && typeof thumbIcon === 'function'\n ? thumbIcon({\n isSelected: !!isSelected,\n className: slots.thumbIcon({ class: classNames.thumbIcon }),\n width: '1em',\n height: '1em',\n 'data-checked': isSelected ? 'true' : 'false',\n })\n : thumbIcon}\n </span>\n </span>\n ) : null}\n </Component>\n {invalid ? (\n <div\n {...getHelperWrapperProps()}\n className={cn(\n getHelperWrapperProps()?.className,\n // force helper to be visible (for some reason it's hidden by default) and remove margin\n 'ml-0 block',\n )}\n >\n <div {...getErrorMessageProps()}>{errorMessage}</div>\n </div>\n ) : null}\n </>\n );\n};\n\nexport default SwitchBox;\n","import SwitchBox from './SwitchBox';\n\nexport type { SwitchBoxProps } from './SwitchBox';\n\nexport { switchBoxVariants } from './SwitchBox';\n\nexport { SwitchBox };\n\nexport default SwitchBox;\n"],"mappings":";;;;;;;;AAaA,MAAa,qBAAA,GAAA,uBAAA,IAAuB;CAClC,OAAO;EACL,KAAK;EACL,aAAa;EACb,MAAM;EACN,OACE;EACF,SAAS;EACT,OAAO;EACP,WAAW;CACb;CACA,UAAU;EACR,YAAY,EACV,MAAM,EACJ,KAAK,uCACP,EACF;EACA,WAAW,EACT,MAAM;GACJ,KAAK;GACL,OAAO;EACT,EACF;EACA,MAAM;GACJ,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;GACA,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;GACA,IAAI;IACF,KAAK;IACL,aAAa;IACb,OAAO;GACT;EACF;CACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC;;;;AA8BD,MAAM,aAAa,EACjB,YAAY,KAAA,GACZ,cAAc,KAAA,GACd,OAAO,KAAA,GACP,MACA,OAAO,KAAA,GACP,YAAY,KAAA,GACZ,GAAG,wBACiB;CACpB,MAAM,EACJ,cACA,UACA,cACA,OACA,sBACA,uBACA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AI,qBAAqB;aAAI;EAAkB,CAAA;CACjD,CAAA,IACH,IACJ,EAAA,CAAA;AAEN;;;ACxOA,IAAA,oBAAe"}
@@ -1,2 +1,2 @@
1
- import { n as TextAreaProps, t as TextArea } from "../index-DUmNI6cE.cjs";
1
+ import { n as TextAreaProps, t as TextArea } from "../index-BsTqcI1C.cjs";
2
2
  export { TextArea, TextArea as default, type TextAreaProps };
@@ -1,2 +1,2 @@
1
- import { n as TextAreaProps, t as TextArea } from "../index-CbPJiRK2.js";
1
+ import { n as TextAreaProps, t as TextArea } from "../index-DXOBPBft.js";
2
2
  export { TextArea, TextArea as default, type TextAreaProps };
@@ -1,3 +1,8 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Time = require("../Time-WKgbji5k.cjs");
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_Time = require("../Time-CYoWaQsz.cjs");
3
6
  exports.Time = require_Time.Time;
7
+ exports.default = require_Time.Time_default;
8
+ exports.timeVariants = require_Time.timeVariants;
@@ -1,2 +1,2 @@
1
- import { n as TimeProps, t as Time } from "../index-BE4OAqJ2.cjs";
2
- export { Time, type TimeProps };
1
+ import { n as TimeProps, r as timeVariants, t as Time } from "../index-DY-d4cFe.cjs";
2
+ export { Time, Time as default, type TimeProps, timeVariants };
@@ -1,2 +1,2 @@
1
- import { n as TimeProps, t as Time } from "../index-CbQ8Ft4o.js";
2
- export { Time, type TimeProps };
1
+ import { n as TimeProps, r as timeVariants, t as Time } from "../index-BdgFJ-dj.js";
2
+ export { Time, Time as default, type TimeProps, timeVariants };
@@ -1,2 +1,2 @@
1
- import { t as Time } from "../Time-CDptQ3CK.js";
2
- export { Time };
1
+ import { n as Time, r as timeVariants, t as Time_default } from "../Time-B_SXrKWK.js";
2
+ export { Time, Time_default as default, timeVariants };
@@ -208,6 +208,9 @@ const Time = ({ className: _className = void 0, granularity = "minute", hideTime
208
208
  });
209
209
  };
210
210
  //#endregion
211
- export { Time as t };
211
+ //#region src/Time/index.ts
212
+ var Time_default = Time;
213
+ //#endregion
214
+ export { Time as n, timeVariants as r, Time_default as t };
212
215
 
213
- //# sourceMappingURL=Time-CDptQ3CK.js.map
216
+ //# sourceMappingURL=Time-B_SXrKWK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Time-B_SXrKWK.js","names":["HeroTimeInput"],"sources":["../src/Time/timeHelpers.ts","../src/Time/Time.tsx","../src/Time/index.ts"],"sourcesContent":["import type { TimeInput as HeroTimeInput } from '@heroui/date-input';\nimport type { ComponentProps } from 'react';\n\nimport {\n getLocalTimeZone,\n parseAbsolute,\n parseAbsoluteToLocal,\n parseDateTime,\n parseZonedDateTime,\n} from '@internationalized/date';\n\n/** Value type accepted by HeroUI TimeInput */\nexport type TimeValue = ComponentProps<typeof HeroTimeInput>['value'];\n\n/** Cast unknown input to the TimeInput value union type. */\nconst asTimeValue = (value: unknown): TimeValue => {\n return value as TimeValue;\n};\n\n/** Check whether a value already looks like an @internationalized/date value. */\nconst isTimeValueLike = (value: unknown): value is object => {\n if (!value || typeof value !== 'object') {\n return false;\n }\n\n return 'hour' in value || 'calendar' in value;\n};\n\n/** Check if the incoming string represents a plain time (e.g. 09:30 or 09:30:45). */\nconst isTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?$/.test(value);\n};\n\n/** Check if the incoming string is a UTC time-only value (e.g. 09:30Z). */\nconst isUtcTimeOnlyString = (value: string): boolean => {\n return /^\\d{2}:\\d{2}(?::\\d{2}(?:\\.\\d{1,3})?)?Z$/.test(value);\n};\n\n/** Zero-pad integer segments for time serialization. */\nconst pad = (value: number): string => {\n return String(value).padStart(2, '0');\n};\n\n/** Convert an absolute ISO string into UTC time-only store format. */\nconst toUtcTimeString = (\n absoluteIsoString: string,\n granularity: 'hour' | 'minute',\n): string | null => {\n const utcDate = new Date(absoluteIsoString);\n if (Number.isNaN(utcDate.getTime())) {\n return null;\n }\n\n const hour = pad(utcDate.getUTCHours());\n if (granularity === 'hour') {\n return `${hour}:00Z`;\n }\n\n return `${hour}:${pad(utcDate.getUTCMinutes())}Z`;\n};\n\n/** True when an input already carries timezone/offset information. */\nconst hasExplicitTimeZone = (value: string): boolean => {\n if (value.includes('[') && value.includes(']')) {\n return true;\n }\n\n return /(?:[zZ]|[+-]\\d{2}:\\d{2})$/.test(value);\n};\n\n/** True for date-time strings without timezone/offset. */\nconst isNaiveDateTimeString = (value: string): boolean => {\n return /^\\d{4}-\\d{2}-\\d{2}T/.test(value) && !hasExplicitTimeZone(value);\n};\n\n/** Safely run a parser and return `null` on parsing errors. */\nconst tryParse = (parser: () => unknown): TimeValue => {\n try {\n return asTimeValue(parser());\n } catch {\n return null;\n }\n};\n\n/**\n * Parse a form value into a HeroUI TimeInput compatible `TimeValue`.\n *\n * Supports existing `TimeValue` objects, native `Date` instances, plain time\n * strings (`HH:mm[:ss]`), absolute ISO date-time strings, zoned date-time\n * strings, and local date-time strings.\n *\n * Time-only strings are interpreted in the active timezone and normalized to a\n * `ZonedDateTime` (using a fixed reference date) so timezone abbreviations can\n * remain visible in the UI.\n */\nexport const parseTimeValue = (\n value: unknown,\n timeZone?: string,\n): TimeValue => {\n if (value == null || value === '') {\n return null;\n }\n\n if (isTimeValueLike(value)) {\n return asTimeValue(value);\n }\n\n if (value instanceof Date) {\n return asTimeValue(\n timeZone\n ? parseAbsolute(value.toISOString(), timeZone)\n : parseAbsoluteToLocal(value.toISOString()),\n );\n }\n\n if (typeof value !== 'string') {\n return null;\n }\n\n const normalizedValue = value.trim();\n if (normalizedValue === '') {\n return null;\n }\n\n if (isTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const [hourValue, minuteValue, secondValue] = normalizedValue\n .split(':')\n .map(Number);\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const hour = pad(hourValue);\n const minute = pad(minuteValue);\n const second = pad(secondValue ?? 0);\n\n return parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${resolvedTimeZone}]`,\n );\n });\n }\n\n if (isUtcTimeOnlyString(normalizedValue)) {\n return tryParse(() => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return parseAbsolute(`1970-01-01T${normalizedValue}`, resolvedTimeZone);\n });\n }\n\n const parsers: (() => unknown)[] = [\n ...(timeZone && isNaiveDateTimeString(normalizedValue)\n ? [\n () => {\n return parseZonedDateTime(`${normalizedValue}[${timeZone}]`);\n },\n ]\n : []),\n () => {\n return timeZone\n ? parseAbsolute(normalizedValue, timeZone)\n : parseAbsoluteToLocal(normalizedValue);\n },\n () => {\n return parseZonedDateTime(normalizedValue);\n },\n () => {\n return parseDateTime(normalizedValue);\n },\n ];\n\n return (\n parsers\n .map((parser) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return tryParse(parser);\n })\n .find((parsedValue) => {\n return parsedValue != null;\n }) ?? null\n );\n};\n\n/** Resolve the timezone used for parsing and string conversion. */\nexport const resolveTimeFieldTimeZone = (timeZone?: string): string => {\n return timeZone ?? getLocalTimeZone();\n};\n\n/**\n * Build default placeholder value for TimeInput.\n *\n * Uses a fixed reference time to keep snapshots deterministic.\n */\nexport const getTimeFieldPlaceholderValue = (timeZone?: string): TimeValue => {\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n return asTimeValue(\n parseZonedDateTime(`1970-01-01T00:00:00[${resolvedTimeZone}]`),\n );\n};\n\n/**\n * Convert a TimeValue into a UTC time-only string for form state.\n *\n * The stored format is `HH:mmZ` (or `HH:00Z` when granularity is `hour`).\n */\nexport const timeValueToString = (\n value: TimeValue,\n timeZone: string,\n granularity: 'hour' | 'minute' = 'minute',\n): string | null => {\n if (value == null) {\n return null;\n }\n\n const maybeWithAbsoluteString = value as { toAbsoluteString?: () => string };\n if (typeof maybeWithAbsoluteString.toAbsoluteString === 'function') {\n return toUtcTimeString(\n maybeWithAbsoluteString.toAbsoluteString(),\n granularity,\n );\n }\n\n const maybeWithToDate = value as { toDate?: (zone: string) => Date };\n if (typeof maybeWithToDate.toDate === 'function') {\n return toUtcTimeString(\n maybeWithToDate.toDate(timeZone).toISOString(),\n granularity,\n );\n }\n\n const maybeTime = value as {\n hour?: number;\n minute?: number;\n second?: number;\n };\n if (\n typeof maybeTime.hour === 'number' &&\n typeof maybeTime.minute === 'number'\n ) {\n const hour = pad(maybeTime.hour);\n const minute = pad(maybeTime.minute);\n const second = pad(maybeTime.second ?? 0);\n return toUtcTimeString(\n parseZonedDateTime(\n `1970-01-01T${hour}:${minute}:${second}[${timeZone}]`,\n ).toAbsoluteString(),\n granularity,\n );\n }\n\n return null;\n};\n","import type { TVClassName, TVProps } from '@fuf-stack/pixel-utils';\nimport type { ReactNode } from 'react';\nimport type { TimeValue } from './timeHelpers';\n\nimport { TimeInput as HeroTimeInput } from '@heroui/date-input';\n\nimport { tv, variantsToClassNames } from '@fuf-stack/pixel-utils';\n\nimport { useUniformField } from '../hooks/useUniformField';\nimport {\n getTimeFieldPlaceholderValue,\n parseTimeValue,\n resolveTimeFieldTimeZone,\n timeValueToString,\n} from './timeHelpers';\n\nexport const timeVariants = tv({\n slots: {\n /** wrapper around the whole time input */\n base: '',\n /** helper wrapper for error/description */\n helperWrapper: [\n // set padding to 0 for error message exit animation\n 'p-0',\n ],\n /** the segmented input element */\n input: '',\n /** inner wrapper around segments and optional content */\n innerWrapper: '',\n /** outer input wrapper */\n inputWrapper: 'bg-content1 focus-within:border-focus',\n /** field label */\n label: '',\n /** individual segment */\n segment: '',\n },\n});\n\ntype VariantProps = TVProps<typeof timeVariants>;\ntype ClassName = TVClassName<typeof timeVariants>;\n\nexport interface TimeProps extends VariantProps {\n /** Custom aria-label for accessibility. If not provided, falls back to field name when no visible label exists */\n ariaLabel?: string;\n /** CSS class name */\n className?: ClassName;\n /** input is disabled */\n disabled?: boolean;\n /** smallest visible unit in the segmented time input */\n granularity?: 'hour' | 'minute';\n /** hide timezone abbreviation for zoned values */\n hideTimeZone?: boolean;\n /** force hour granularity and store UTC hour as number (0-23) */\n hourAsNumber?: boolean;\n /** hour cycle formatting */\n hourCycle?: 12 | 24;\n /** form field label */\n label?: ReactNode;\n /** form field name */\n name: string;\n /** HTML data-testid attribute used in e2e tests */\n testId?: string;\n /**\n * Optional timezone used for parsing date-time strings and serializing values.\n * When omitted, local timezone is used.\n */\n timeZone?: string;\n /** value format stored in form state (`string` stores UTC minute values, e.g. `10:15Z`) */\n valueType?: 'string' | 'timeValue';\n}\n\n/**\n * Time component based on [HeroUI TimeInput](https://v2.heroui.com/docs/components/time-input)\n */\nconst Time = ({\n className: _className = undefined,\n granularity = 'minute',\n hideTimeZone = false,\n hourAsNumber = false,\n hourCycle = undefined,\n name,\n timeZone = undefined,\n valueType = 'string',\n ...uniformFieldProps\n}: TimeProps) => {\n const {\n ariaLabel,\n disabled,\n errorMessage,\n field: { onBlur, onChange, value },\n invalid,\n label,\n required,\n testId,\n } = useUniformField({ name, ...uniformFieldProps });\n\n // classNames from slots\n const variants = timeVariants();\n const classNames = variantsToClassNames(variants, _className, 'base');\n const resolvedTimeZone = resolveTimeFieldTimeZone(timeZone);\n const effectiveGranularity = hourAsNumber ? 'hour' : granularity;\n\n // `hourAsNumber` stores 0-23; convert this into a parseable UTC time for display.\n const normalizedFieldValue =\n hourAsNumber && typeof value === 'number'\n ? `${String(Math.max(0, Math.min(23, value))).padStart(2, '0')}:00Z`\n : value;\n\n // Normalize incoming form value into HeroUI TimeInput value shape.\n const parsedValue = parseTimeValue(normalizedFieldValue, timeZone);\n const placeholderValue = getTimeFieldPlaceholderValue(timeZone);\n\n // Normalize TimeInput output into the configured storage format.\n const handleChange = (nextValue: TimeValue) => {\n if (nextValue == null) {\n onChange(null);\n return;\n }\n\n if (hourAsNumber) {\n const serializedValue = timeValueToString(\n nextValue,\n resolvedTimeZone,\n 'hour',\n );\n\n if (!serializedValue) {\n onChange(null);\n return;\n }\n\n const [hoursSegment] = serializedValue.split(':');\n const parsedHours = Number(hoursSegment);\n onChange(Number.isNaN(parsedHours) ? null : parsedHours);\n return;\n }\n\n if (valueType === 'timeValue') {\n onChange(nextValue);\n return;\n }\n\n onChange(\n timeValueToString(nextValue, resolvedTimeZone, effectiveGranularity) ??\n String(nextValue),\n );\n };\n\n return (\n <HeroTimeInput\n aria-label={label ? undefined : ariaLabel}\n classNames={{\n base: classNames.base,\n helperWrapper: classNames.helperWrapper,\n innerWrapper: classNames.innerWrapper,\n input: classNames.input,\n inputWrapper: classNames.inputWrapper,\n label: classNames.label,\n segment: classNames.segment,\n }}\n data-testid={testId}\n errorMessage={errorMessage}\n granularity={effectiveGranularity}\n hideTimeZone={hideTimeZone}\n hourCycle={hourCycle}\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={handleChange}\n placeholderValue={placeholderValue ?? undefined}\n radius=\"sm\"\n value={parsedValue ?? undefined}\n variant=\"bordered\"\n />\n );\n};\n\nexport default Time;\n","import Time from './Time';\n\nexport type { TimeProps } from './Time';\n\nexport { timeVariants } from './Time';\n\nexport { Time };\n\nexport default Time;\n"],"mappings":";;;;;;;AAeA,MAAM,eAAe,UAA8B;CACjD,OAAO;AACT;;AAGA,MAAM,mBAAmB,UAAoC;CAC3D,IAAI,CAAC,SAAS,OAAO,UAAU,UAC7B,OAAO;CAGT,OAAO,UAAU,SAAS,cAAc;AAC1C;;AAGA,MAAM,oBAAoB,UAA2B;CACnD,OAAO,yCAAyC,KAAK,KAAK;AAC5D;;AAGA,MAAM,uBAAuB,UAA2B;CACtD,OAAO,0CAA0C,KAAK,KAAK;AAC7D;;AAGA,MAAM,OAAO,UAA0B;CACrC,OAAO,OAAO,KAAK,EAAE,SAAS,GAAG,GAAG;AACtC;;AAGA,MAAM,mBACJ,mBACA,gBACkB;CAClB,MAAM,UAAU,IAAI,KAAK,iBAAiB;CAC1C,IAAI,OAAO,MAAM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,WAAW;GACjB,eAAe,WAAW;GAC1B,cAAc,WAAW;GACzB,OAAO,WAAW;GAClB,cAAc,WAAW;GACzB,OAAO,WAAW;GAClB,SAAS,WAAW;EACtB;EACA,eAAa;EACC;EACd,aAAa;EACC;EACH;EACX,IAAI;EACJ,YAAY;EACZ,WAAW;EACX,YAAY;EACL;EACP,gBAAe;EACT;EACE;EACR,UAAU;EACV,kBAAkB,oBAAoB,KAAA;EACtC,QAAO;EACP,OAAO,eAAe,KAAA;EACtB,SAAQ;CACT,CAAA;AAEL;;;AC5KA,IAAA,eAAe"}
@@ -209,11 +209,26 @@ const Time = ({ className: _className = void 0, granularity = "minute", hideTime
209
209
  });
210
210
  };
211
211
  //#endregion
212
+ //#region src/Time/index.ts
213
+ var Time_default = Time;
214
+ //#endregion
212
215
  Object.defineProperty(exports, "Time", {
213
216
  enumerable: true,
214
217
  get: function() {
215
218
  return Time;
216
219
  }
217
220
  });
221
+ Object.defineProperty(exports, "Time_default", {
222
+ enumerable: true,
223
+ get: function() {
224
+ return Time_default;
225
+ }
226
+ });
227
+ Object.defineProperty(exports, "timeVariants", {
228
+ enumerable: true,
229
+ get: function() {
230
+ return timeVariants;
231
+ }
232
+ });
218
233
 
219
- //# sourceMappingURL=Time-WKgbji5k.cjs.map
234
+ //# sourceMappingURL=Time-CYoWaQsz.cjs.map