@spark-ui/components 17.15.4 → 17.15.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 (245) hide show
  1. package/dist/{DialogContent.styles-BSxCCi-u.mjs → DialogContent.styles-ClKRO43s.mjs} +1 -1
  2. package/dist/{DialogContent.styles-BSxCCi-u.mjs.map → DialogContent.styles-ClKRO43s.mjs.map} +1 -1
  3. package/dist/DialogContent.styles-FnwXayCC.js +2 -0
  4. package/dist/{DialogContent.styles-CAhJtUud.js.map → DialogContent.styles-FnwXayCC.js.map} +1 -1
  5. package/dist/{FormFieldRequiredIndicator-CzdpinIz.mjs → FormFieldRequiredIndicator-COKYxTNs.mjs} +2 -2
  6. package/dist/{FormFieldRequiredIndicator-CzdpinIz.mjs.map → FormFieldRequiredIndicator-COKYxTNs.mjs.map} +1 -1
  7. package/dist/FormFieldRequiredIndicator-DY3STDp1.js +2 -0
  8. package/dist/{FormFieldRequiredIndicator-CEB8Ez-q.js.map → FormFieldRequiredIndicator-DY3STDp1.js.map} +1 -1
  9. package/dist/accordion/index.js +1 -1
  10. package/dist/accordion/index.js.map +1 -1
  11. package/dist/accordion/index.mjs +1 -1
  12. package/dist/accordion/index.mjs.map +1 -1
  13. package/dist/alert-dialog/index.js +1 -1
  14. package/dist/alert-dialog/index.js.map +1 -1
  15. package/dist/alert-dialog/index.mjs +1 -1
  16. package/dist/alert-dialog/index.mjs.map +1 -1
  17. package/dist/avatar/index.js +1 -1
  18. package/dist/avatar/index.js.map +1 -1
  19. package/dist/avatar/index.mjs +2 -2
  20. package/dist/avatar/index.mjs.map +1 -1
  21. package/dist/badge/index.js +1 -1
  22. package/dist/badge/index.js.map +1 -1
  23. package/dist/badge/index.mjs.map +1 -1
  24. package/dist/breadcrumb/index.js +1 -1
  25. package/dist/breadcrumb/index.js.map +1 -1
  26. package/dist/breadcrumb/index.mjs +1 -1
  27. package/dist/breadcrumb/index.mjs.map +1 -1
  28. package/dist/button/index.js +1 -1
  29. package/dist/button/index.mjs +1 -1
  30. package/dist/{button-CzHtbgj7.mjs → button-BeLA-Evk.mjs} +2 -2
  31. package/dist/{button-CzHtbgj7.mjs.map → button-BeLA-Evk.mjs.map} +1 -1
  32. package/dist/button-pb2JbL37.js +2 -0
  33. package/dist/{button-jlscsCw0.js.map → button-pb2JbL37.js.map} +1 -1
  34. package/dist/card/index.js +1 -1
  35. package/dist/card/index.js.map +1 -1
  36. package/dist/card/index.mjs.map +1 -1
  37. package/dist/carousel/index.js +1 -1
  38. package/dist/carousel/index.js.map +1 -1
  39. package/dist/carousel/index.mjs +2 -2
  40. package/dist/carousel/index.mjs.map +1 -1
  41. package/dist/checkbox/index.js +1 -1
  42. package/dist/checkbox/index.mjs +1 -1
  43. package/dist/checkbox-Cbewcw6G.js +2 -0
  44. package/dist/{checkbox-hVGRiWC_.js.map → checkbox-Cbewcw6G.js.map} +1 -1
  45. package/dist/{checkbox-CbMh-21q.mjs → checkbox-uSINHQYe.mjs} +3 -3
  46. package/dist/{checkbox-CbMh-21q.mjs.map → checkbox-uSINHQYe.mjs.map} +1 -1
  47. package/dist/chip/index.js +1 -1
  48. package/dist/chip/index.js.map +1 -1
  49. package/dist/chip/index.mjs +1 -1
  50. package/dist/chip/index.mjs.map +1 -1
  51. package/dist/circular-meter/index.js +1 -1
  52. package/dist/circular-meter/index.js.map +1 -1
  53. package/dist/circular-meter/index.mjs.map +1 -1
  54. package/dist/collapsible/index.js +1 -1
  55. package/dist/collapsible/index.js.map +1 -1
  56. package/dist/collapsible/index.mjs.map +1 -1
  57. package/dist/combobox/index.js +1 -1
  58. package/dist/combobox/index.js.map +1 -1
  59. package/dist/combobox/index.mjs +9 -6
  60. package/dist/combobox/index.mjs.map +1 -1
  61. package/dist/dialog/index.js +1 -1
  62. package/dist/dialog/index.js.map +1 -1
  63. package/dist/dialog/index.mjs +4 -4
  64. package/dist/dialog/index.mjs.map +1 -1
  65. package/dist/divider/index.js +1 -1
  66. package/dist/divider/index.js.map +1 -1
  67. package/dist/divider/index.mjs.map +1 -1
  68. package/dist/drawer/index.js +1 -1
  69. package/dist/drawer/index.js.map +1 -1
  70. package/dist/drawer/index.mjs +3 -3
  71. package/dist/drawer/index.mjs.map +1 -1
  72. package/dist/dropdown/index.js +1 -1
  73. package/dist/dropdown/index.js.map +1 -1
  74. package/dist/dropdown/index.mjs +2 -2
  75. package/dist/dropdown/index.mjs.map +1 -1
  76. package/dist/file-upload/index.js +1 -1
  77. package/dist/file-upload/index.js.map +1 -1
  78. package/dist/file-upload/index.mjs +7 -7
  79. package/dist/file-upload/index.mjs.map +1 -1
  80. package/dist/form-field/index.js +1 -1
  81. package/dist/form-field/index.mjs +1 -1
  82. package/dist/form-field-B38U0zp8.js +2 -0
  83. package/dist/{form-field-BCqHBvWN.js.map → form-field-B38U0zp8.js.map} +1 -1
  84. package/dist/{form-field-ByLHXtzx.mjs → form-field-DCKyhBmv.mjs} +4 -4
  85. package/dist/{form-field-ByLHXtzx.mjs.map → form-field-DCKyhBmv.mjs.map} +1 -1
  86. package/dist/global.d.ts +12 -0
  87. package/dist/icon/index.js +1 -1
  88. package/dist/icon/index.mjs +1 -1
  89. package/dist/{icon-D05Uqh8_.mjs → icon-Bs-39J-H.mjs} +1 -1
  90. package/dist/{icon-D05Uqh8_.mjs.map → icon-Bs-39J-H.mjs.map} +1 -1
  91. package/dist/icon-DY4l9nsc.js +2 -0
  92. package/dist/{icon-CRPcdgYp.js.map → icon-DY4l9nsc.js.map} +1 -1
  93. package/dist/icon-button/index.js +1 -1
  94. package/dist/icon-button/index.mjs +1 -1
  95. package/dist/icon-button-4kkwICAr.js +2 -0
  96. package/dist/{icon-button-Iv9kq84M.js.map → icon-button-4kkwICAr.js.map} +1 -1
  97. package/dist/{icon-button-BLG7VjR7.mjs → icon-button-DQAzrC_Q.mjs} +2 -2
  98. package/dist/{icon-button-BLG7VjR7.mjs.map → icon-button-DQAzrC_Q.mjs.map} +1 -1
  99. package/dist/input/index.js +1 -1
  100. package/dist/input/index.mjs +1 -1
  101. package/dist/input-Bmkrsnjd.js +2 -0
  102. package/dist/{input-BSCMbnO4.js.map → input-Bmkrsnjd.js.map} +1 -1
  103. package/dist/{input-cKdm2R3n.mjs → input-Dy5t-hhE.mjs} +2 -2
  104. package/dist/{input-cKdm2R3n.mjs.map → input-Dy5t-hhE.mjs.map} +1 -1
  105. package/dist/input-otp/index.js +1 -1
  106. package/dist/input-otp/index.js.map +1 -1
  107. package/dist/input-otp/index.mjs.map +1 -1
  108. package/dist/kbd/index.js +1 -1
  109. package/dist/kbd/index.js.map +1 -1
  110. package/dist/kbd/index.mjs.map +1 -1
  111. package/dist/label/index.js +1 -1
  112. package/dist/label/index.mjs +1 -1
  113. package/dist/label-DO48yda7.js +2 -0
  114. package/dist/{label-BCSEss4U.js.map → label-DO48yda7.js.map} +1 -1
  115. package/dist/{label-DDBRKLUX.mjs → label-RKaPen31.mjs} +1 -1
  116. package/dist/{label-DDBRKLUX.mjs.map → label-RKaPen31.mjs.map} +1 -1
  117. package/dist/link-box/index.js +1 -1
  118. package/dist/link-box/index.js.map +1 -1
  119. package/dist/link-box/index.mjs.map +1 -1
  120. package/dist/menu/index.js +1 -1
  121. package/dist/menu/index.js.map +1 -1
  122. package/dist/menu/index.mjs +1 -1
  123. package/dist/menu/index.mjs.map +1 -1
  124. package/dist/meter/index.js +1 -1
  125. package/dist/meter/index.js.map +1 -1
  126. package/dist/meter/index.mjs.map +1 -1
  127. package/dist/pagination/index.js +1 -1
  128. package/dist/pagination/index.js.map +1 -1
  129. package/dist/pagination/index.mjs +3 -3
  130. package/dist/pagination/index.mjs.map +1 -1
  131. package/dist/popover/index.js +1 -1
  132. package/dist/popover/index.mjs +1 -1
  133. package/dist/popover-DK2-MWUF.js +2 -0
  134. package/dist/{popover-qoueDrzR.js.map → popover-DK2-MWUF.js.map} +1 -1
  135. package/dist/{popover-Ds6xXjgT.mjs → popover-Dj95Y-ex.mjs} +3 -3
  136. package/dist/{popover-Ds6xXjgT.mjs.map → popover-Dj95Y-ex.mjs.map} +1 -1
  137. package/dist/portal/index.js +1 -1
  138. package/dist/portal/index.js.map +1 -1
  139. package/dist/portal/index.mjs.map +1 -1
  140. package/dist/progress/index.js +1 -1
  141. package/dist/progress/index.mjs +1 -1
  142. package/dist/progress-B_zfJmtJ.js +2 -0
  143. package/dist/{progress-DBD2FiQ1.js.map → progress-B_zfJmtJ.js.map} +1 -1
  144. package/dist/progress-tracker/index.js +1 -1
  145. package/dist/progress-tracker/index.js.map +1 -1
  146. package/dist/progress-tracker/index.mjs +1 -1
  147. package/dist/progress-tracker/index.mjs.map +1 -1
  148. package/dist/{progress-BfpWgeE1.mjs → progress-xbOXCGXi.mjs} +1 -1
  149. package/dist/{progress-BfpWgeE1.mjs.map → progress-xbOXCGXi.mjs.map} +1 -1
  150. package/dist/radio-group/index.js +1 -1
  151. package/dist/radio-group/index.js.map +1 -1
  152. package/dist/radio-group/index.mjs.map +1 -1
  153. package/dist/rating/index.js +1 -1
  154. package/dist/rating/index.js.map +1 -1
  155. package/dist/rating/index.mjs +5 -3
  156. package/dist/rating/index.mjs.map +1 -1
  157. package/dist/rating-display/index.js +1 -1
  158. package/dist/rating-display/index.js.map +1 -1
  159. package/dist/rating-display/index.mjs +1 -1
  160. package/dist/rating-display/index.mjs.map +1 -1
  161. package/dist/{chunk-C91j1N6u.js → rolldown-runtime-CMqjfN_6.js} +1 -1
  162. package/dist/scrolling-list/index.js +1 -1
  163. package/dist/scrolling-list/index.js.map +1 -1
  164. package/dist/scrolling-list/index.mjs +3 -3
  165. package/dist/scrolling-list/index.mjs.map +1 -1
  166. package/dist/segmented-control/index.js +1 -1
  167. package/dist/segmented-control/index.js.map +1 -1
  168. package/dist/segmented-control/index.mjs.map +1 -1
  169. package/dist/segmented-gauge/index.js +1 -1
  170. package/dist/segmented-gauge/index.js.map +1 -1
  171. package/dist/segmented-gauge/index.mjs.map +1 -1
  172. package/dist/select/index.js +1 -1
  173. package/dist/select/index.js.map +1 -1
  174. package/dist/select/index.mjs +1 -1
  175. package/dist/select/index.mjs.map +1 -1
  176. package/dist/skeleton/index.js +1 -1
  177. package/dist/skeleton/index.js.map +1 -1
  178. package/dist/skeleton/index.mjs.map +1 -1
  179. package/dist/slider/index.js +1 -1
  180. package/dist/slider/index.js.map +1 -1
  181. package/dist/slider/index.mjs +2 -2
  182. package/dist/slider/index.mjs.map +1 -1
  183. package/dist/slot/index.js +1 -1
  184. package/dist/slot/index.js.map +1 -1
  185. package/dist/slot/index.mjs.map +1 -1
  186. package/dist/spinner/index.js +1 -1
  187. package/dist/spinner/index.mjs +1 -1
  188. package/dist/spinner-CmPypfJR.js +2 -0
  189. package/dist/{spinner-DFUoYvmm.js.map → spinner-CmPypfJR.js.map} +1 -1
  190. package/dist/{spinner-DULLiM6a.mjs → spinner-TfGcjNm3.mjs} +1 -1
  191. package/dist/{spinner-DULLiM6a.mjs.map → spinner-TfGcjNm3.mjs.map} +1 -1
  192. package/dist/stepper/index.js +1 -1
  193. package/dist/stepper/index.js.map +1 -1
  194. package/dist/stepper/index.mjs +3 -3
  195. package/dist/stepper/index.mjs.map +1 -1
  196. package/dist/switch/index.js +1 -1
  197. package/dist/switch/index.js.map +1 -1
  198. package/dist/switch/index.mjs +2 -2
  199. package/dist/switch/index.mjs.map +1 -1
  200. package/dist/table/index.js +1 -1
  201. package/dist/table/index.js.map +1 -1
  202. package/dist/table/index.mjs +3 -3
  203. package/dist/table/index.mjs.map +1 -1
  204. package/dist/tabs/index.js +1 -1
  205. package/dist/tabs/index.js.map +1 -1
  206. package/dist/tabs/index.mjs +4 -4
  207. package/dist/tabs/index.mjs.map +1 -1
  208. package/dist/tag/index.js +1 -1
  209. package/dist/tag/index.js.map +1 -1
  210. package/dist/tag/index.mjs.map +1 -1
  211. package/dist/text-link/index.js +1 -1
  212. package/dist/text-link/index.js.map +1 -1
  213. package/dist/text-link/index.mjs.map +1 -1
  214. package/dist/textarea/index.js +1 -1
  215. package/dist/textarea/index.js.map +1 -1
  216. package/dist/textarea/index.mjs +1 -1
  217. package/dist/textarea/index.mjs.map +1 -1
  218. package/dist/toast/index.js +1 -1
  219. package/dist/toast/index.js.map +1 -1
  220. package/dist/toast/index.mjs +3 -3
  221. package/dist/toast/index.mjs.map +1 -1
  222. package/dist/toggle-group/index.js +1 -1
  223. package/dist/toggle-group/index.js.map +1 -1
  224. package/dist/toggle-group/index.mjs.map +1 -1
  225. package/dist/{useRenderSlot-DKIwoqpO.mjs → useRenderSlot-5CPC9Lkj.mjs} +1 -1
  226. package/dist/{useRenderSlot-DKIwoqpO.mjs.map → useRenderSlot-5CPC9Lkj.mjs.map} +1 -1
  227. package/dist/useRenderSlot-DHV0CegV.js +2 -0
  228. package/dist/{useRenderSlot-C4UVWhDN.js.map → useRenderSlot-DHV0CegV.js.map} +1 -1
  229. package/dist/visually-hidden/index.js +1 -1
  230. package/dist/visually-hidden/index.js.map +1 -1
  231. package/dist/visually-hidden/index.mjs.map +1 -1
  232. package/package.json +5 -5
  233. package/dist/DialogContent.styles-CAhJtUud.js +0 -2
  234. package/dist/FormFieldRequiredIndicator-CEB8Ez-q.js +0 -2
  235. package/dist/button-jlscsCw0.js +0 -2
  236. package/dist/checkbox-hVGRiWC_.js +0 -2
  237. package/dist/form-field-BCqHBvWN.js +0 -2
  238. package/dist/icon-CRPcdgYp.js +0 -2
  239. package/dist/icon-button-Iv9kq84M.js +0 -2
  240. package/dist/input-BSCMbnO4.js +0 -2
  241. package/dist/label-BCSEss4U.js +0 -2
  242. package/dist/popover-qoueDrzR.js +0 -2
  243. package/dist/progress-DBD2FiQ1.js +0 -2
  244. package/dist/spinner-DFUoYvmm.js +0 -2
  245. package/dist/useRenderSlot-C4UVWhDN.js +0 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-unchecked:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['[&[data-checked]]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: ['[&[data-checked]]:bg-support', 'hover:ring-support-container', 'text-support'],\n accent: ['[&[data-checked]]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n success: ['[&[data-checked]]:bg-success', 'hover:ring-success-container', 'text-success'],\n alert: ['[&[data-checked]]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['[&[data-checked]]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['[&[data-checked]]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: ['[&[data-checked]]:bg-neutral', 'hover:ring-neutral-container', 'text-neutral'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { Switch as BaseSwitch } from '@base-ui/react/switch'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends\n StylesProps,\n Omit<ComponentPropsWithRef<typeof BaseSwitch.Root>, 'value' | 'render' | 'onCheckedChange'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n const renderSlot = useRenderSlot(asChild, 'span')\n const isRequiredComputed = Boolean(required || isRequired)\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <BaseSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n render={renderSlot}\n className={styles({ intent, size, className })}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={nextChecked => handleCheckedChange(nextChecked)}\n name={name}\n required={isRequiredComputed}\n aria-required={isRequiredComputed ? true : undefined}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <BaseSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </BaseSwitch.Thumb>\n </span>\n </BaseSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\n/**\n * A toggle control that allows users to switch between two states, typically on and off.\n */\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/switch/SwitchInput.styles.ts","../../src/switch/SwitchInput.tsx","../../src/switch/SwitchLabel.styles.ts","../../src/switch/SwitchLabel.tsx","../../src/switch/Switch.tsx"],"sourcesContent":["import { makeVariants, tw } from '@spark-ui/internal-utils'\nimport { cva, VariantProps } from 'class-variance-authority'\n\nexport const styles = cva(\n tw([\n 'relative shrink-0 self-baseline',\n 'cursor-pointer',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'disabled:hover:ring-transparent disabled:cursor-not-allowed disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'data-unchecked:bg-on-surface/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n ]),\n {\n variants: {\n /**\n * Size of the switch input.\n */\n size: makeVariants<'size', ['sm', 'md']>({\n sm: tw(['h-sz-24', 'w-sz-40', 'border-md']),\n md: tw(['h-sz-32', 'w-sz-56', 'border-[4px]']),\n }),\n /**\n * Color scheme of the switch input.\n */\n intent: makeVariants<\n 'intent',\n ['main', 'support', 'accent', 'success', 'alert', 'error', 'info', 'neutral']\n >({\n main: ['[&[data-checked]]:bg-main', 'hover:ring-main-container', 'text-main'],\n support: ['[&[data-checked]]:bg-support', 'hover:ring-support-container', 'text-support'],\n accent: ['[&[data-checked]]:bg-accent', 'hover:ring-accent-container', 'text-accent'],\n success: ['[&[data-checked]]:bg-success', 'hover:ring-success-container', 'text-success'],\n alert: ['[&[data-checked]]:bg-alert', 'hover:ring-alert-container', 'text-alert'],\n error: ['[&[data-checked]]:bg-error', 'hover:ring-error-container', 'text-error'],\n info: ['[&[data-checked]]:bg-info', 'hover:ring-info-container', 'text-info'],\n neutral: ['[&[data-checked]]:bg-neutral', 'hover:ring-neutral-container', 'text-neutral'],\n }),\n },\n defaultVariants: {\n intent: 'support',\n size: 'sm',\n },\n }\n)\n\nexport type StylesProps = VariantProps<typeof styles>\n\nexport const thumbWrapperStyles = cva(\n [\n 'pointer-events-none absolute inset-0 flex items-center',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n checked: {\n true: 'translate-x-full',\n false: 'translate-x-0',\n },\n },\n }\n)\n\nexport const thumbStyles = cva(\n [\n 'absolute left-0 top-0 flex items-center justify-center',\n 'bg-surface',\n 'rounded-full',\n 'ring-0',\n 'transition-all duration-200 ease-in-out',\n ],\n {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-20', 'w-sz-20'],\n md: ['h-sz-24', 'w-sz-24'],\n }),\n checked: {\n true: '-translate-x-full',\n false: 'translate-x-0 text-on-surface/dim-2',\n },\n },\n defaultVariants: {\n size: 'sm',\n checked: false,\n },\n }\n)\n\nexport const thumbCheckSVGStyles = cva(['transition-opacity duration-200'], {\n variants: {\n size: makeVariants<'size', ['sm', 'md']>({\n sm: ['h-sz-10 w-sz-10'],\n md: ['h-sz-12 w-sz-12'],\n }),\n },\n defaultVariants: {\n size: 'sm',\n },\n})\n","import { Switch as BaseSwitch } from '@base-ui/react/switch'\nimport { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport { Check } from '@spark-ui/icons/Check'\nimport { Close } from '@spark-ui/icons/Close'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\nimport { useRenderSlot } from '../drawer/useRenderSlot'\nimport { Slot } from '../slot'\nimport {\n styles,\n type StylesProps,\n thumbCheckSVGStyles,\n thumbStyles,\n thumbWrapperStyles,\n} from './SwitchInput.styles'\n\nexport interface SwitchInputProps\n extends\n StylesProps,\n Omit<ComponentPropsWithRef<typeof BaseSwitch.Root>, 'value' | 'render' | 'onCheckedChange'> {\n /**\n * The state of the switch when it is initially rendered. Use when you do not need to control its state.\n */\n defaultChecked?: boolean\n /**\n * The controlled state of the switch. Must be used in conjunction with `onCheckedChange`.\n */\n checked?: boolean\n /**\n * Event handler called when the state of the switch changes.\n */\n onCheckedChange?: (checked: boolean) => void\n /**\n * When `true`, prevents the user from interacting with the switch.\n */\n disabled?: boolean\n /**\n * When true, indicates that the user must check the switch before the owning form can be submitted.\n */\n required?: boolean\n /**\n * The name of the switch. Submitted with its owning form as part of a name/value pair.\n */\n name?: string\n /**\n * The value given as data when submitted with a name.\n */\n value?: string\n /**\n * Icon shown inside the thumb of the Switch whenever it is checked\n */\n checkedIcon?: ReactNode\n /**\n * Icon shown inside the thumb of the Switch whenever it is unchecked\n */\n uncheckedIcon?: ReactNode\n /**\n * When true, the label will be placed on the left side of the Switch\n */\n reverse?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const SwitchInput = ({\n checked,\n checkedIcon = <Check />,\n defaultChecked,\n intent: intentProp,\n uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, state, isRequired, isInvalid } = useFormFieldControl()\n const intent = state ?? intentProp\n const renderSlot = useRenderSlot(asChild, 'span')\n const isRequiredComputed = Boolean(required || isRequired)\n\n const handleCheckedChange = (updatedValue: boolean): void => {\n setIsChecked(updatedValue)\n onCheckedChange?.(updatedValue)\n }\n\n return (\n <BaseSwitch.Root\n data-spark-component=\"switch-input\"\n ref={ref}\n render={renderSlot}\n className={styles({ intent, size, className })}\n checked={checked}\n defaultChecked={defaultChecked}\n onCheckedChange={nextChecked => handleCheckedChange(nextChecked)}\n name={name}\n required={isRequiredComputed}\n aria-required={isRequiredComputed ? true : undefined}\n aria-invalid={isInvalid}\n aria-describedby={description}\n {...rest}\n >\n <span className={thumbWrapperStyles({ checked: isChecked })}>\n <BaseSwitch.Thumb className={thumbStyles({ size, checked: isChecked })}>\n {isChecked && checkedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{checkedIcon}</Slot>\n )}\n {!isChecked && uncheckedIcon && (\n <Slot className={thumbCheckSVGStyles({ size })}>{uncheckedIcon}</Slot>\n )}\n </BaseSwitch.Thumb>\n </span>\n </BaseSwitch.Root>\n )\n}\n\nSwitchInput.displayName = 'SwitchInput'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const labelStyles = cva('default:text-on-surface', {\n variants: {\n disabled: {\n true: ['text-neutral/dim-2', 'cursor-not-allowed'],\n false: ['cursor-pointer'],\n },\n },\n defaultVariants: {\n disabled: false,\n },\n})\n\nexport type LabelStylesProps = VariantProps<typeof labelStyles>\n","import { Label, LabelProps } from '../label'\nimport { labelStyles, LabelStylesProps } from './SwitchLabel.styles'\n\nexport interface SwitchLabelProps extends LabelStylesProps, LabelProps {\n /**\n * Change the component to the HTML tag or custom component of the only child.\n */\n asChild?: boolean\n /**\n * The id of the element the label is associated with.\n */\n htmlFor?: string\n /**\n * When true, prevents the user from interacting with the switch item.\n */\n disabled?: boolean\n}\n\nexport const SwitchLabel = ({ className, disabled, ...others }: SwitchLabelProps) => (\n <Label\n data-spark-component=\"switch-label\"\n className={labelStyles({ disabled, className })}\n {...others}\n />\n)\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { cx } from 'class-variance-authority'\nimport { useId } from 'react'\n\nimport { SwitchInput, SwitchInputProps } from './SwitchInput'\nimport { SwitchLabel } from './SwitchLabel'\n\nexport type SwitchProps = SwitchInputProps\n\nconst ID_PREFIX = ':switch'\n\n/**\n * A toggle control that allows users to switch between two states, typically on and off.\n */\nexport const Switch = ({\n size = 'md',\n children,\n className,\n id,\n disabled,\n reverse = false,\n ref,\n ...rest\n}: SwitchProps) => {\n const field = useFormFieldControl()\n\n const labelID = `${ID_PREFIX}-label-${useId()}`\n const innerID = `${ID_PREFIX}-input-${useId()}`\n const fieldID = field.id || id || innerID\n\n const switchLabel = children && (\n <SwitchLabel disabled={disabled} htmlFor={fieldID} id={labelID}>\n {children}\n </SwitchLabel>\n )\n\n const switchInput = (\n <SwitchInput\n ref={ref}\n size={size}\n id={fieldID}\n disabled={disabled}\n /**\n * If the switch doesn't have any direct label (children) then we should try to\n * get an eventual alternative label from FormField.\n * On last resort, we shouldn't forget to define an aria-label attribute.\n */\n aria-labelledby={children ? labelID : field.labelId}\n {...rest}\n />\n )\n\n const content = reverse ? (\n <>\n {switchLabel}\n {switchInput}\n </>\n ) : (\n <>\n {switchInput}\n {switchLabel}\n </>\n )\n\n return (\n <div\n data-spark-component=\"switch\"\n className={cx('gap-md text-body-1 flex items-center', className)}\n >\n {content}\n </div>\n )\n}\n\nSwitch.displayName = 'Switch'\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAa,IAAS,EACpB,EAAG;CACD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,GACD;CACE,UAAU;EAIR,MAAM,EAAmC;GACvC,IAAI,EAAG;IAAC;IAAW;IAAW;GAAW,CAAC;GAC1C,IAAI,EAAG;IAAC;IAAW;IAAW;GAAc,CAAC;EAC/C,CAAC;EAID,QAAQ,EAGN;GACA,MAAM;IAAC;IAA6B;IAA6B;GAAW;GAC5E,SAAS;IAAC;IAAgC;IAAgC;GAAc;GACxF,QAAQ;IAAC;IAA+B;IAA+B;GAAa;GACpF,SAAS;IAAC;IAAgC;IAAgC;GAAc;GACxF,OAAO;IAAC;IAA8B;IAA8B;GAAY;GAChF,OAAO;IAAC;IAA8B;IAA8B;GAAY;GAChF,MAAM;IAAC;IAA6B;IAA6B;GAAW;GAC5E,SAAS;IAAC;IAAgC;IAAgC;GAAc;EAC1F,CAAC;CACH;CACA,iBAAiB;EACf,QAAQ;EACR,MAAM;CACR;AACF,CACF,GAIa,IAAqB,EAChC,CACE,0DACA,yCACF,GACA,EACE,UAAU,EACR,SAAS;CACP,MAAM;CACN,OAAO;AACT,EACF,EACF,CACF,GAEa,IAAc,EACzB;CACE;CACA;CACA;CACA;CACA;AACF,GACA;CACE,UAAU;EACR,MAAM,EAAmC;GACvC,IAAI,CAAC,WAAW,SAAS;GACzB,IAAI,CAAC,WAAW,SAAS;EAC3B,CAAC;EACD,SAAS;GACP,MAAM;GACN,OAAO;EACT;CACF;CACA,iBAAiB;EACf,MAAM;EACN,SAAS;CACX;AACF,CACF,GAEa,IAAsB,EAAI,CAAC,iCAAiC,GAAG;CAC1E,UAAU,EACR,MAAM,EAAmC;EACvC,IAAI,CAAC,iBAAiB;EACtB,IAAI,CAAC,iBAAiB;CACxB,CAAC,EACH;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC,GCnCY,KAAe,EAC1B,YACA,iBAAc,kBAAC,GAAD,CAAQ,CAAA,GACtB,mBACA,QAAQ,GACR,mBAAgB,kBAAC,GAAD,CAAQ,CAAA,GACxB,UAAO,MACP,oBACA,cACA,aACA,QACA,aAAU,IACV,GAAG,QACmB;CACtB,IAAM,CAAC,GAAW,KAAgB,EAAiB,GAAS,CAAc,GACpE,EAAE,SAAM,gBAAa,UAAO,eAAY,iBAAc,EAAoB,GAC1E,IAAS,KAAS,GAClB,IAAa,EAAc,GAAS,MAAM,GAC1C,IAAqB,GAAQ,KAAY,IAEzC,KAAuB,MAAgC;EAE3D,AADA,EAAa,CAAY,GACzB,IAAkB,CAAY;CAChC;CAEA,OACE,kBAAC,EAAW,MAAZ;EACE,wBAAqB;EAChB;EACL,QAAQ;EACR,WAAW,EAAO;GAAE;GAAQ;GAAM;EAAU,CAAC;EACpC;EACO;EAChB,kBAAiB,MAAe,EAAoB,CAAW;EACzD;EACN,UAAU;EACV,iBAAe,IAAqB,KAAO,KAAA;EAC3C,gBAAc;EACd,oBAAkB;EAClB,GAAI;YAEJ,kBAAC,QAAD;GAAM,WAAW,EAAmB,EAAE,SAAS,EAAU,CAAC;aACxD,kBAAC,EAAW,OAAZ;IAAkB,WAAW,EAAY;KAAE;KAAM,SAAS;IAAU,CAAC;cAArE,CACG,KAAa,KACZ,kBAAC,GAAD;KAAM,WAAW,EAAoB,EAAE,QAAK,CAAC;eAAI;IAAkB,CAAA,GAEpE,CAAC,KAAa,KACb,kBAAC,GAAD;KAAM,WAAW,EAAoB,EAAE,QAAK,CAAC;eAAI;IAAoB,CAAA,CAEvD;;EACd,CAAA;CACS,CAAA;AAErB;AAEA,EAAY,cAAc;;;ACxH1B,IAAa,IAAc,EAAI,2BAA2B;CACxD,UAAU,EACR,UAAU;EACR,MAAM,CAAC,sBAAsB,oBAAoB;EACjD,OAAO,CAAC,gBAAgB;CAC1B,EACF;CACA,iBAAiB,EACf,UAAU,GACZ;AACF,CAAC,GCMY,KAAe,EAAE,cAAW,aAAU,GAAG,QACpD,kBAAC,GAAD;CACE,wBAAqB;CACrB,WAAW,EAAY;EAAE;EAAU;CAAU,CAAC;CAC9C,GAAI;AACL,CAAA,GCdG,IAAY,WAKL,KAAU,EACrB,UAAO,MACP,aACA,cACA,OACA,aACA,aAAU,IACV,QACA,GAAG,QACc;CACjB,IAAM,IAAQ,EAAoB,GAE5B,IAAU,GAAG,EAAU,SAAS,EAAM,KACtC,IAAU,GAAG,EAAU,SAAS,EAAM,KACtC,IAAU,EAAM,MAAM,KAAM,GAE5B,IAAc,KAClB,kBAAC,GAAD;EAAuB;EAAU,SAAS;EAAS,IAAI;EACpD;CACU,CAAA,GAGT,IACJ,kBAAC,GAAD;EACO;EACC;EACN,IAAI;EACM;EAMV,mBAAiB,IAAW,IAAU,EAAM;EAC5C,GAAI;CACL,CAAA,GAGG,IAAU,IACd,kBAAA,GAAA,EAAA,UAAA,CACG,GACA,CACD,EAAA,CAAA,IAEF,kBAAA,GAAA,EAAA,UAAA,CACG,GACA,CACD,EAAA,CAAA;CAGJ,OACE,kBAAC,OAAD;EACE,wBAAqB;EACrB,WAAW,EAAG,wCAAwC,CAAS;YAE9D;CACE,CAAA;AAET;AAEA,EAAO,cAAc"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-C91j1N6u.js`),t=require(`../icon-CRPcdgYp.js`),n=require(`../button-jlscsCw0.js`),r=require(`../checkbox-hVGRiWC_.js`);let i=require(`class-variance-authority`),a=require(`react`);a=e.t(a);let o=require(`react/jsx-runtime`),s=require(`@react-aria/utils`),c=require(`@react-stately/table`),l=require(`react-aria`),u=require(`@react-aria/table`),d=require(`@spark-ui/icons/ArrowDown`),f=require(`@spark-ui/icons/ArrowUp`),p=require(`@spark-ui/icons/Sort`);var m=(0,a.createContext)({isResizable:!1,tableWidth:0});function h(){return(0,a.useContext)(m)}var g=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function _(){return(0,a.useContext)(g)}function v({children:e,className:t,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onClearSelection:c,onSelectAll:l,allowsResizing:u=!0,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,...x}){let S=0;n===`all`?S=a??0:n instanceof Set?S=n.size:n&&(S=new Set(n).size);let C=c??(()=>r?.(new Set));return(0,o.jsx)(g,{value:{...x,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onSelectAll:l,selectedCount:S,onClearSelection:C,allowsResizing:u,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,className:t},children:(0,o.jsx)(`div`,{className:(0,i.cx)(`gap-md flex flex-col`,t),children:e})})}v.displayName=`Table`;function y({className:e,children:t,...n}){let r=(0,a.useRef)(null),[c,l]=(0,a.useState)(0);return(0,a.useLayoutEffect)(()=>{let e=r.current;e&&l(e.clientWidth)},[]),(0,s.useResizeObserver)({ref:r,onResize:()=>{let e=r.current;e&&l(e.clientWidth)}}),(0,o.jsx)(m,{value:{isResizable:!0,tableWidth:c},children:(0,o.jsx)(`div`,{ref:r,"data-spark-component":`resizable-table-container`,className:(0,i.cx)(`relative w-full overflow-auto`,e),...n,children:t})})}y.displayName=`ResizableTableContainer`;var b=`[data-spark-component="table-cell"]`;function x(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function S(e){if(!e||!(e instanceof Element))return!1;let t=e.closest(`[role="combobox"],[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`);return t?t.getAttribute(`aria-expanded`)===`true`:!1}var C=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function w(e){return!e||!(e instanceof Element)?null:e.closest(b)}function T(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function E(e){return Array.from(e.querySelectorAll(C)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function D(e,t){for(let n of E(e)){let e=`data-prev-tabindex`;if(!t)n.hasAttribute(e)||n.setAttribute(e,n.getAttribute(`tabindex`)??``),n.setAttribute(`tabindex`,`-1`);else{let t=n.getAttribute(e);if(t===null)continue;n.removeAttribute(e),t===``?n.removeAttribute(`tabindex`):n.setAttribute(`tabindex`,t)}}}function O(e){let t=Array.from(e.querySelectorAll(b));for(let e of t)D(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),c=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{c.current=e,s.current=`interaction`,o(`interaction`),D(e,!0)};return(0,l.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=c.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&x(e.target)&&w(e.target)===c.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=w(e.target);t&&t===c.current&&e.stopPropagation();return}if(x(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=w(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(b));if(r.length>0&&r[r.length-1]===t){e.preventDefault(),e.stopPropagation(),n.focus();return}}}}if(s.current===`grid`&&e.key===`Enter`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`grid`&&e.key===`F2`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(S(e.target))return;let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}},onBlurCapture:t=>{if(s.current!==`interaction`)return;let n=e.current;if(!n)return;let r=t.relatedTarget;r instanceof Node&&n.contains(r)||(c.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=w(t.target);if(s.current===`interaction`&&c.current&&i){let e=!!(a&&a!==c.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!c.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(c.current=null))}if(!a)return;c.current=a;let l=t.target instanceof Element?t.target:null,d=a.matches(b),p=s.current===`grid`,m=!!(l&&l!==a&&a.contains(l)),h=E(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!T(a)&&f(a)},onPointerDownCapture:e=>{let t=w(e.target);t?.matches(b)&&e.target instanceof Element&&e.target!==t&&t.contains(e.target)&&(u.current=!0)},"data-table-keyboard-mode":i})},[t,i,e,r,n]);return(0,a.useEffect)(()=>{s.current=i;let t=e.current;if(t){if(i===`grid`){O(t),c.current?.focus?.();return}O(t),c.current&&D(c.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var k=(0,i.cva)([`h-sz-64 min-w-sz-64`,`relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container`,`pl-lg pr-lg py-sm text-left outline-none box-border`,`cursor-default`,`data-focus-visible:u-outline data-focus-visible:-outline-offset-2`],{variants:{checkbox:{true:[`w-sz-64 min-w-sz-64 max-w-sz-64`,`px-0 align-middle`]},resizable:{true:[`pr-xl`]}},defaultVariants:{checkbox:!1,resizable:!1}}),te=(0,i.cva)([`flex flex-1 justify-between items-center gap-md`,`font-inherit text-left text-inherit`,`whitespace-nowrap text-ellipsis`,`border-transparent`,`data-focus-visible:u-outline data-focus-visible:outline-offset-2`],{variants:{},defaultVariants:{}});(0,i.cva)([`empty:italic empty:text-center empty:text-body-2 empty:py-lg`],{variants:{},defaultVariants:{}});var ne=(0,i.cva)([`p-lg outline-none box-border default:overflow-hidden`,`border-b-sm border-outline [tr:last-child>&]:border-b-0`,`[-webkit-tap-highlight-color:transparent]`,`data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`],{variants:{checkbox:{true:[`w-sz-64 py-sm px-0 align-middle`]}},defaultVariants:{checkbox:!1}}),re=(0,i.cva)([`pointer-events-none`,`[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle`],{variants:{},defaultVariants:{}}),ie=`button, [role="button"], [role="switch"], [role="checkbox"], [role="option"], input:not([type="hidden"]), select, textarea, [href], [data-spark-component="dropdown-trigger"], [data-spark-component="icon-button"], [data-spark-component="switch"], [data-spark-component="switch-input"], [data-spark-component="combobox-input"]`,ae=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function oe(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(ie)||t.closest(ie)!==null}function se(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function ce(e){for(let t of e.querySelectorAll(ae))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function le(e){let t=se(e);if(!t)return!1;if(oe(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:ce(n)}var A=(0,a.createContext)(`grid`);function j({checkboxProps:e,className:t,suppressFocusWalker:n}){let{isSelected:i,isIndeterminate:a,isDisabled:s,onChange:c,...l}=e,u=a===!0?`indeterminate`:!!i;return(0,o.jsx)(`span`,{...n?{"data-react-aria-prevent-focus":!0}:void 0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:t??`flex h-full min-h-full items-center justify-center`,children:(0,o.jsx)(r.n,{checked:u,disabled:s,onCheckedChange:c,...l})})}j.displayName=`Table.SelectionCheckbox`;function M({cell:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{gridCellProps:i}=(0,l.useTableCell)({node:e},t,r),{isFocusVisible:s,focusProps:c}=(0,l.useFocusRing)(),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=i,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,u.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:ne({checkbox:!0}),"data-focus-visible":s||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:ne(),"data-focus-visible":s||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{le((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:c}=(0,l.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,l.useFocusRing)(),{onClick:f,onPointerDown:p,onMouseDown:m,onPointerUp:h,onPointerCancel:g,..._}=s,v=(0,i.cx)(`outline-none box-border data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`,_.className,c&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,l.mergeProps)(_,d),onPointerDown:N(p),onMouseDown:N(m),onPointerUp:N(h),onPointerCancel:N(g),onClick:N(f),ref:r,"data-spark-component":`table-row`,"data-selected":c||void 0,"data-focus-visible":u||void 0,className:v,tabIndex:-1,children:[...e.childNodes].map(e=>(0,o.jsx)(M,{cell:e,state:t,resizeState:n},e.key))})}P.displayName=`Table.BodyRowRenderer`;function F({column:e,ariaLabel:t,resizeState:n,resizeCallbacks:r}){let s=(0,a.useRef)(null),{resizerProps:c,inputProps:l,isResizing:d}=(0,u.useTableColumnResize)({column:e,"aria-label":t??`Resize column`,onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd},n,s);return(0,o.jsx)(`div`,{role:`presentation`,className:(0,i.cx)(`cursor-col-resize absolute inset-y-lg right-0 flex w-lg items-center justify-center`,`after:block after:h-full after:w-[2px] after:bg-outline after:transition-all after:duration-75`,`has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2`,d&&`after:bg-outline-high after:scale-120`),"data-resizable-direction":`both`,...c,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...l})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,u.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,c=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),l=i===`all`?c:i,d=[...c].filter(e=>l.has(e)).length,f=c.size,p=f>0&&d===f,m=d>0&&d<f,{isSelected:h,isIndeterminate:g,onChange:_,...v}=t,y=e=>{(e.key===` `||e.key===`Enter`)&&e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),t.isDisabled||_?.(!p))};return(0,o.jsx)(j,{checkboxProps:{...v,isSelected:p,isIndeterminate:m,onChange:_,onKeyDown:y}})}I.displayName=`Table.HeaderSelectionCheckbox`;var L=(0,i.cx)(`sticky top-0 z-sticky`);function R({column:e,state:n,resizeState:r,stickyHeader:s,resizeCallbacks:c,isLastColumnInRow:u=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=_(),{columnHeaderProps:g}=(0,l.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,l.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!u,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{...g,ref:m,role:`columnheader`,className:(0,i.cx)(k({checkbox:!0}),s&&L),"data-spark-component":`table-column`,"data-table-selection-columnheader":!0,"data-focus-visible":v||void 0,children:(0,o.jsx)(I,{state:n})});let C=!!e.props?.allowsSorting,w=n.sortDescriptor?.column===e.key,T=n.sortDescriptor?.direction??`ascending`,E=w?T===`descending`?(0,o.jsx)(d.ArrowDown,{}):(0,o.jsx)(f.ArrowUp,{}):(0,o.jsx)(p.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,l.mergeProps)(g,y),ref:m,role:`columnheader`,className:(0,i.cx)(k({resizable:S}),s&&L),style:x?{width:x}:void 0,"data-spark-component":`table-column`,"data-focus-visible":v||void 0,onKeyDown:D,children:[(0,o.jsxs)(`div`,{className:te(),children:[(0,o.jsx)(`button`,{type:`button`,className:(0,i.cx)(`gap-md flex min-w-0 flex-1 items-center text-left`,`focus-visible:u-outline outline-none`,`bg-transparent p-0 border-0`),onKeyDown:D,children:(0,o.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:e.rendered})}),C?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:(0,i.cx)(`shrink-0 opacity-dim-2 group-hover/column:opacity-100`,w&&`opacity-100`),children:(0,o.jsx)(t.t,{size:`sm`,children:E})}):null]}),r&&b?(0,o.jsx)(F,{column:e,ariaLabel:typeof h==`function`?h(e):h,resizeState:r,resizeCallbacks:c}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:c}=(0,l.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...c,ref:s,children:u.map((e,a)=>(0,o.jsx)(R,{column:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i,isLastColumnInRow:a===u.length-1},e.key))})}z.displayName=`Table.HeaderRowRenderer`;function B({className:e,children:t,stickyHeader:n,...r}){let u=!!n,d=(0,a.useRef)(null),f=h(),p=r.selectionMode===`multiple`,m=(0,c.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,c.useTableColumnResizeState)({tableWidth:f.tableWidth},m),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,l.useTable)({...r},m,d),y=m.collection.headerRows,b=[...m.collection.body.childNodes],x=m.collection.body.props?.renderEmptyState,S=m.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,l.useTableRowGroup)(),{rowGroupProps:T}=(0,l.useTableRowGroup)(),{gridProps:E,keyboardMode:D}=ee({ref:d,gridProps:v,onKeyDownCapture:r.onKeyDownCapture,onFocusCapture:r.onFocusCapture});return(0,o.jsx)(A,{value:D,children:(0,o.jsxs)(`table`,{...(0,l.mergeProps)(E,(0,s.filterDOMProps)(r,{global:!0})),ref:d,"data-spark-component":`table`,className:(0,i.cx)(`default:w-full`,p?`table-fixed`:void 0,`border-separate border-spacing-y-0`,`bg-surface`,`outline-none`,`text-body-1`,`forced-color-adjust-none`,`data-focus-visible:u-outline-inset`,`has-[>[data-empty]]:h-full`,e),children:[(0,o.jsx)(`thead`,{...w,"data-spark-component":`table-header`,children:y.map(e=>(0,o.jsx)(z,{item:e,state:m,resizeState:_,stickyHeader:u,resizeCallbacks:{onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd}},e.key))}),(0,o.jsxs)(`tbody`,{...T,"data-spark-component":`table-body`,children:[C?(0,o.jsx)(`tr`,{"aria-hidden":`true`,className:re(),role:`presentation`,"data-spark-component":`table-body-spacer`,children:(0,o.jsx)(`td`,{colSpan:S,role:`presentation`})}):null,b.length===0&&x?(0,o.jsx)(`tr`,{"data-empty":!0,children:(0,o.jsx)(`td`,{colSpan:S,children:x({isEmpty:!0})})}):null,b.map(e=>(0,o.jsx)(P,{item:e,state:m,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function ue(e){return typeof e==`number`?`${e}px`:e}function V({"aria-label":e,"aria-labelledby":t,className:n,children:r}){let{allowsResizing:i=!0,maxHeight:a,stickyHeader:s,onResizeStart:c,onResize:l,onResizeEnd:u,onKeyDownCapture:d,sortDescriptor:f,onSortChange:p,className:m,...h}=_(),g=a==null?void 0:{maxHeight:ue(a)},v=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:v,stickyHeader:s},x=B;return i?(0,o.jsx)(y,{className:v,style:g,onResizeStart:c,onResize:l,onResizeEnd:u,children:(0,o.jsx)(x,{...b,children:r})}):(0,o.jsx)(`div`,{className:`relative w-full overflow-auto`,style:g,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(c.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=c.TableBody.getCollectionNode;var U=(0,a.createContext)(null);function W(){let e=(0,a.useContext)(U);if(!e)throw Error(`Table.BulkBar subcomponents must be used within Table.BulkBar`);return e}function G({children:e,className:t,rootProps:n,...r}){let{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u}=_();return(0,o.jsx)(U,{value:{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u},children:(0,o.jsx)(`div`,{role:`toolbar`,"aria-label":r[`aria-label`]??`Table bulk actions`,"data-spark-component":`table-bulk-bar`,className:(0,i.cx)(`gap-lg min-h-sz-64 flex w-full flex-wrap items-center justify-between`,`rounded-lg`,`bg-support-container text-on-support-container p-lg`,t),...n,children:e})})}function K({children:e}){return W(),(0,o.jsx)(`span`,{className:`text-body-1-highlight`,children:e})}function q({className:e,children:t,...r}){let{selectedCount:a,onClearSelection:s,hasMultiplePages:c}=W();return c?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:a===0,onClick:s,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}function de({className:e,children:t,...r}){let{selectedCount:a,totalCount:s,onSelectAll:c,hasMultiplePages:l}=W();return l?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:s==null||c==null||a>=s,onClick:c,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}G.displayName=`Table.BulkBar`;var J=G;J.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,de.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(c.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=c.Cell.getCollectionNode;function X({label:e,allowsResizing:t=!0,...n}){return null}X.displayName=`Table.Column`,X.getCollectionNode=function*(e,t){let n=e.title??e.label??e.children??null,r=e.textValue||(typeof n==`string`?n:``)||e[`aria-label`],i=yield{type:`column`,key:e.id??null,hasChildNodes:!!e.childColumns||!!e.title&&a.default.Children.count(e.children)>0,rendered:n,textValue:r,props:{...e,title:e.title??e.label,allowsResizing:e.allowsResizing},*childNodes(){if(e.childColumns)for(let t of e.childColumns)yield{type:`column`,value:t};else if(e.title){let t=[];a.default.Children.forEach(e.children,e=>{t.push({type:`column`,element:e})}),yield*t}},shouldInvalidate(e){return o(e),!1}},o=e=>{for(let t of i)t.hasChildNodes||e.columns.push(t)};o(t)};function Z(e){return(0,o.jsx)(c.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=c.TableHeader.getCollectionNode;function Q(e){return null}Q.displayName=`Table.Row`,Q.getCollectionNode=function*(e,t){let{children:n,textValue:r,UNSTABLE_childItems:i}=e;yield{type:`item`,key:e.id??null,props:e,textValue:r,"aria-label":e[`aria-label`],hasChildNodes:!0,*childNodes(){if(t.showDragButtons&&(yield{type:`cell`,key:`header-drag`,props:{isDragButtonCell:!0}}),t.showSelectionCheckboxes&&t.selectionMode!==`none`&&(yield{type:`cell`,key:`header`,props:{isSelectionCell:!0}}),typeof n==`function`){for(let e of t.columns)yield{type:`cell`,element:n(e.key),key:e.key};if(i)for(let e of i)yield{type:`item`,value:e}}else{let e=[],r=[],i=0;if(a.default.Children.forEach(n,n=>{if(n)if(n.type===Q){if(e.length<t.columns.length)throw Error(`All of a Row's child Cells must be positioned before any child Rows.`);r.push({type:`item`,element:n})}else e.push({type:`cell`,element:n}),i+=n.props?.colSpan??1}),i!==t.columns.length)throw Error(`Cell count must match column count. Found ${i} cells and ${t.columns.length} columns.`);yield*e,yield*r}},shouldInvalidate(e){return e.columns.length!==t.columns.length||e.columns.some((e,n)=>e.key!==t.columns[n].key)||e.showSelectionCheckboxes!==t.showSelectionCheckboxes||e.showDragButtons!==t.showDragButtons||e.selectionMode!==t.selectionMode}}};function fe(e,t,n,r){let i=e[n],a=t[n];if(i===a)return 0;let o;return o=typeof i==`number`&&typeof a==`number`?i<a?-1:1:String(i).localeCompare(String(a)),r===`descending`?-o:o}function pe(e,t={}){let{initialSort:n,compare:r}=t,[i,o]=(0,a.useState)(()=>n?{column:n.column,direction:n.direction}:{column:`id`,direction:`ascending`});return{sortDescriptor:i,onSortChange:o,setSortDescriptor:o,sortedItems:(0,a.useMemo)(()=>{let t=i.column;if(!t)return[...e];let n=r??fe,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function me(e,t){let{pageSize:n,initialPage:r=1,getId:i}=t,[o,s]=(0,a.useState)(r),[c,l]=(0,a.useState)(()=>new Set),u=e.length,d=Math.max(1,Math.ceil(u/n));(0,a.useEffect)(()=>{s(e=>e<1?1:e>d?d:e)},[d]);let f=o;f<1?f=1:f>d&&(f=d);let p=(0,a.useMemo)(()=>{let t=(f-1)*n,r=t+n;return e.slice(t,r)},[e,f,n]),m=(0,a.useMemo)(()=>{let t=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(e.map(e=>t(e)))},[i,e]),h=(0,a.useMemo)(()=>{let e=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(p.map(t=>e(t)))},[i,p]);return{page:f,setPage:s,pageItems:p,totalItems:u,totalPages:d,allKeys:m,selectedKeys:c,onSelectionChange:e=>{let t=e===`all`?new Set(h):new Set(e);l(e=>{let n=new Set(t);for(let t of e)h.has(t)||n.add(t);return n})},onPageChange:e=>{s(e.page)},clearSelection:()=>{l(()=>new Set)}}}var $=Object.assign(v,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:J,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:de});$.displayName=`Table`,Z.displayName=`Table.Header`,X.displayName=`Table.Column`,H.displayName=`Table.Body`,Q.displayName=`Table.Row`,Y.displayName=`Table.Cell`,exports.Table=$,exports.TableCompound=$,exports.useTablePagination=me,exports.useTableSort=pe;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-CMqjfN_6.js"),t=require("../icon-DY4l9nsc.js"),n=require("../button-pb2JbL37.js"),r=require("../checkbox-Cbewcw6G.js");let i=require("class-variance-authority"),a=require("react");a=e.t(a);let o=require("react/jsx-runtime"),s=require("@react-aria/utils"),c=require("@react-stately/table"),l=require("react-aria"),u=require("@react-aria/table"),d=require("@spark-ui/icons/ArrowDown"),f=require("@spark-ui/icons/ArrowUp"),p=require("@spark-ui/icons/Sort");var m=(0,a.createContext)({isResizable:!1,tableWidth:0});function h(){return(0,a.useContext)(m)}var g=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function _(){return(0,a.useContext)(g)}function v({children:e,className:t,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onClearSelection:c,onSelectAll:l,allowsResizing:u=!0,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,...x}){let S=0;n===`all`?S=a??0:n instanceof Set?S=n.size:n&&(S=new Set(n).size);let C=c??(()=>r?.(new Set));return(0,o.jsx)(g,{value:{...x,selectedKeys:n,onSelectionChange:r,totalCount:a,hasMultiplePages:s,onSelectAll:l,selectedCount:S,onClearSelection:C,allowsResizing:u,resizeColumnAriaLabel:d,maxHeight:f,stickyHeader:p,onResizeStart:m,onResize:h,onResizeEnd:_,onKeyDownCapture:v,sortDescriptor:y,onSortChange:b,className:t},children:(0,o.jsx)(`div`,{className:(0,i.cx)(`gap-md flex flex-col`,t),children:e})})}v.displayName=`Table`;function y({className:e,children:t,...n}){let r=(0,a.useRef)(null),[c,l]=(0,a.useState)(0);return(0,a.useLayoutEffect)(()=>{let e=r.current;e&&l(e.clientWidth)},[]),(0,s.useResizeObserver)({ref:r,onResize:()=>{let e=r.current;e&&l(e.clientWidth)}}),(0,o.jsx)(m,{value:{isResizable:!0,tableWidth:c},children:(0,o.jsx)(`div`,{ref:r,"data-spark-component":`resizable-table-container`,className:(0,i.cx)(`relative w-full overflow-auto`,e),...n,children:t})})}y.displayName=`ResizableTableContainer`;var b=`[data-spark-component="table-cell"]`;function x(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function S(e){if(!e||!(e instanceof Element))return!1;let t=e.closest(`[role="combobox"],[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`);return t?t.getAttribute(`aria-expanded`)===`true`:!1}var C=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function w(e){return!e||!(e instanceof Element)?null:e.closest(b)}function T(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function E(e){return Array.from(e.querySelectorAll(C)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function D(e,t){for(let n of E(e)){let e=`data-prev-tabindex`;if(!t)n.hasAttribute(e)||n.setAttribute(e,n.getAttribute(`tabindex`)??``),n.setAttribute(`tabindex`,`-1`);else{let t=n.getAttribute(e);if(t===null)continue;n.removeAttribute(e),t===``?n.removeAttribute(`tabindex`):n.setAttribute(`tabindex`,t)}}}function O(e){let t=Array.from(e.querySelectorAll(b));for(let e of t)D(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),c=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{c.current=e,s.current=`interaction`,o(`interaction`),D(e,!0)};return(0,l.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=c.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&x(e.target)&&w(e.target)===c.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=w(e.target);t&&t===c.current&&e.stopPropagation();return}if(x(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=w(e.target);if(t&&t===c.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=w(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(b));if(r.length>0&&r[r.length-1]===t){e.preventDefault(),e.stopPropagation(),n.focus();return}}}}if(s.current===`grid`&&e.key===`Enter`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`grid`&&e.key===`F2`){let t=w(e.target);if(!t||T(t))return;let n=E(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(S(e.target))return;let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=c.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}},onBlurCapture:t=>{if(s.current!==`interaction`)return;let n=e.current;if(!n)return;let r=t.relatedTarget;r instanceof Node&&n.contains(r)||(c.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=w(t.target);if(s.current===`interaction`&&c.current&&i){let e=!!(a&&a!==c.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!c.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(c.current=null))}if(!a)return;c.current=a;let l=t.target instanceof Element?t.target:null,d=a.matches(b),p=s.current===`grid`,m=!!(l&&l!==a&&a.contains(l)),h=E(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!T(a)&&f(a)},onPointerDownCapture:e=>{let t=w(e.target);t?.matches(b)&&e.target instanceof Element&&e.target!==t&&t.contains(e.target)&&(u.current=!0)},"data-table-keyboard-mode":i})},[t,i,e,r,n]);return(0,a.useEffect)(()=>{s.current=i;let t=e.current;if(t){if(i===`grid`){O(t),c.current?.focus?.();return}O(t),c.current&&D(c.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var k=(0,i.cva)([`h-sz-64 min-w-sz-64`,`relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container`,`pl-lg pr-lg py-sm text-left outline-none box-border`,`cursor-default`,`data-focus-visible:u-outline data-focus-visible:-outline-offset-2`],{variants:{checkbox:{true:[`w-sz-64 min-w-sz-64 max-w-sz-64`,`px-0 align-middle`]},resizable:{true:[`pr-xl`]}},defaultVariants:{checkbox:!1,resizable:!1}}),te=(0,i.cva)([`flex flex-1 justify-between items-center gap-md`,`font-inherit text-left text-inherit`,`whitespace-nowrap text-ellipsis`,`border-transparent`,`data-focus-visible:u-outline data-focus-visible:outline-offset-2`],{variants:{},defaultVariants:{}});(0,i.cva)([`empty:italic empty:text-center empty:text-body-2 empty:py-lg`],{variants:{},defaultVariants:{}});var ne=(0,i.cva)([`p-lg outline-none box-border default:overflow-hidden`,`border-b-sm border-outline [tr:last-child>&]:border-b-0`,`[-webkit-tap-highlight-color:transparent]`,`data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`],{variants:{checkbox:{true:[`w-sz-64 py-sm px-0 align-middle`]}},defaultVariants:{checkbox:!1}}),re=(0,i.cva)([`pointer-events-none`,`[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle`],{variants:{},defaultVariants:{}}),ie=`button, [role="button"], [role="switch"], [role="checkbox"], [role="option"], input:not([type="hidden"]), select, textarea, [href], [data-spark-component="dropdown-trigger"], [data-spark-component="icon-button"], [data-spark-component="switch"], [data-spark-component="switch-input"], [data-spark-component="combobox-input"]`,ae=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function oe(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(ie)||t.closest(ie)!==null}function se(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function ce(e){for(let t of e.querySelectorAll(ae))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function le(e){let t=se(e);if(!t)return!1;if(oe(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:ce(n)}var A=(0,a.createContext)(`grid`);function j({checkboxProps:e,className:t,suppressFocusWalker:n}){let{isSelected:i,isIndeterminate:a,isDisabled:s,onChange:c,...l}=e,u=a===!0?`indeterminate`:!!i;return(0,o.jsx)(`span`,{...n?{"data-react-aria-prevent-focus":!0}:void 0,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),className:t??`flex h-full min-h-full items-center justify-center`,children:(0,o.jsx)(r.n,{checked:u,disabled:s,onCheckedChange:c,...l})})}j.displayName=`Table.SelectionCheckbox`;function M({cell:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{gridCellProps:i}=(0,l.useTableCell)({node:e},t,r),{isFocusVisible:s,focusProps:c}=(0,l.useFocusRing)(),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=i,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,u.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:ne({checkbox:!0}),"data-focus-visible":s||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,l.mergeProps)(m,{onKeyDownCapture:h},c,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:ne(),"data-focus-visible":s||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{le((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:c}=(0,l.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,l.useFocusRing)(),{onClick:f,onPointerDown:p,onMouseDown:m,onPointerUp:h,onPointerCancel:g,..._}=s,v=(0,i.cx)(`outline-none box-border data-focus-visible:u-outline-inset data-focus-visible:outline-dashed`,_.className,c&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,l.mergeProps)(_,d),onPointerDown:N(p),onMouseDown:N(m),onPointerUp:N(h),onPointerCancel:N(g),onClick:N(f),ref:r,"data-spark-component":`table-row`,"data-selected":c||void 0,"data-focus-visible":u||void 0,className:v,tabIndex:-1,children:[...e.childNodes].map(e=>(0,o.jsx)(M,{cell:e,state:t,resizeState:n},e.key))})}P.displayName=`Table.BodyRowRenderer`;function F({column:e,ariaLabel:t,resizeState:n,resizeCallbacks:r}){let s=(0,a.useRef)(null),{resizerProps:c,inputProps:l,isResizing:d}=(0,u.useTableColumnResize)({column:e,"aria-label":t??`Resize column`,onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd},n,s);return(0,o.jsx)(`div`,{role:`presentation`,className:(0,i.cx)(`cursor-col-resize absolute inset-y-lg right-0 flex w-lg items-center justify-center`,`after:block after:h-full after:w-[2px] after:bg-outline after:transition-all after:duration-75`,`has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2`,d&&`after:bg-outline-high after:scale-120`),"data-resizable-direction":`both`,...c,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...l})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,u.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,c=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),l=i===`all`?c:i,d=[...c].filter(e=>l.has(e)).length,f=c.size,p=f>0&&d===f,m=d>0&&d<f,{isSelected:h,isIndeterminate:g,onChange:_,...v}=t,y=e=>{(e.key===` `||e.key===`Enter`)&&e.stopPropagation(),e.key===`Enter`&&(e.preventDefault(),t.isDisabled||_?.(!p))};return(0,o.jsx)(j,{checkboxProps:{...v,isSelected:p,isIndeterminate:m,onChange:_,onKeyDown:y}})}I.displayName=`Table.HeaderSelectionCheckbox`;var L=(0,i.cx)(`sticky top-0 z-sticky`);function R({column:e,state:n,resizeState:r,stickyHeader:s,resizeCallbacks:c,isLastColumnInRow:u=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=_(),{columnHeaderProps:g}=(0,l.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,l.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!u,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{...g,ref:m,role:`columnheader`,className:(0,i.cx)(k({checkbox:!0}),s&&L),"data-spark-component":`table-column`,"data-table-selection-columnheader":!0,"data-focus-visible":v||void 0,children:(0,o.jsx)(I,{state:n})});let C=!!e.props?.allowsSorting,w=n.sortDescriptor?.column===e.key,T=n.sortDescriptor?.direction??`ascending`,E=w?T===`descending`?(0,o.jsx)(d.ArrowDown,{}):(0,o.jsx)(f.ArrowUp,{}):(0,o.jsx)(p.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,l.mergeProps)(g,y),ref:m,role:`columnheader`,className:(0,i.cx)(k({resizable:S}),s&&L),style:x?{width:x}:void 0,"data-spark-component":`table-column`,"data-focus-visible":v||void 0,onKeyDown:D,children:[(0,o.jsxs)(`div`,{className:te(),children:[(0,o.jsx)(`button`,{type:`button`,className:(0,i.cx)(`gap-md flex min-w-0 flex-1 items-center text-left`,`focus-visible:u-outline outline-none`,`bg-transparent p-0 border-0`),onKeyDown:D,children:(0,o.jsx)(`span`,{className:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`,children:e.rendered})}),C?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:(0,i.cx)(`shrink-0 opacity-dim-2 group-hover/column:opacity-100`,w&&`opacity-100`),children:(0,o.jsx)(t.t,{size:`sm`,children:E})}):null]}),r&&b?(0,o.jsx)(F,{column:e,ariaLabel:typeof h==`function`?h(e):h,resizeState:r,resizeCallbacks:c}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:c}=(0,l.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...c,ref:s,children:u.map((e,a)=>(0,o.jsx)(R,{column:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i,isLastColumnInRow:a===u.length-1},e.key))})}z.displayName=`Table.HeaderRowRenderer`;function B({className:e,children:t,stickyHeader:n,...r}){let u=!!n,d=(0,a.useRef)(null),f=h(),p=r.selectionMode===`multiple`,m=(0,c.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,c.useTableColumnResizeState)({tableWidth:f.tableWidth},m),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,l.useTable)({...r},m,d),y=m.collection.headerRows,b=[...m.collection.body.childNodes],x=m.collection.body.props?.renderEmptyState,S=m.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,l.useTableRowGroup)(),{rowGroupProps:T}=(0,l.useTableRowGroup)(),{gridProps:E,keyboardMode:D}=ee({ref:d,gridProps:v,onKeyDownCapture:r.onKeyDownCapture,onFocusCapture:r.onFocusCapture});return(0,o.jsx)(A,{value:D,children:(0,o.jsxs)(`table`,{...(0,l.mergeProps)(E,(0,s.filterDOMProps)(r,{global:!0})),ref:d,"data-spark-component":`table`,className:(0,i.cx)(`default:w-full`,p?`table-fixed`:void 0,`border-separate border-spacing-y-0`,`bg-surface`,`outline-none`,`text-body-1`,`forced-color-adjust-none`,`data-focus-visible:u-outline-inset`,`has-[>[data-empty]]:h-full`,e),children:[(0,o.jsx)(`thead`,{...w,"data-spark-component":`table-header`,children:y.map(e=>(0,o.jsx)(z,{item:e,state:m,resizeState:_,stickyHeader:u,resizeCallbacks:{onResizeStart:r.onResizeStart,onResize:r.onResize,onResizeEnd:r.onResizeEnd}},e.key))}),(0,o.jsxs)(`tbody`,{...T,"data-spark-component":`table-body`,children:[C?(0,o.jsx)(`tr`,{"aria-hidden":`true`,className:re(),role:`presentation`,"data-spark-component":`table-body-spacer`,children:(0,o.jsx)(`td`,{colSpan:S,role:`presentation`})}):null,b.length===0&&x?(0,o.jsx)(`tr`,{"data-empty":!0,children:(0,o.jsx)(`td`,{colSpan:S,children:x({isEmpty:!0})})}):null,b.map(e=>(0,o.jsx)(P,{item:e,state:m,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function ue(e){return typeof e==`number`?`${e}px`:e}function V({"aria-label":e,"aria-labelledby":t,className:n,children:r}){let{allowsResizing:i=!0,maxHeight:a,stickyHeader:s,onResizeStart:c,onResize:l,onResizeEnd:u,onKeyDownCapture:d,sortDescriptor:f,onSortChange:p,className:m,...h}=_(),g=a==null?void 0:{maxHeight:ue(a)},v=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:v,stickyHeader:s},x=B;return i?(0,o.jsx)(y,{className:v,style:g,onResizeStart:c,onResize:l,onResizeEnd:u,children:(0,o.jsx)(x,{...b,children:r})}):(0,o.jsx)(`div`,{className:`relative w-full overflow-auto`,style:g,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(c.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=c.TableBody.getCollectionNode;var U=(0,a.createContext)(null);function W(){let e=(0,a.useContext)(U);if(!e)throw Error(`Table.BulkBar subcomponents must be used within Table.BulkBar`);return e}function G({children:e,className:t,rootProps:n,...r}){let{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u}=_();return(0,o.jsx)(U,{value:{selectedCount:a,totalCount:s,onClearSelection:c,onSelectAll:l,hasMultiplePages:u},children:(0,o.jsx)(`div`,{role:`toolbar`,"aria-label":r[`aria-label`]??`Table bulk actions`,"data-spark-component":`table-bulk-bar`,className:(0,i.cx)(`gap-lg min-h-sz-64 flex w-full flex-wrap items-center justify-between`,`rounded-lg`,`bg-support-container text-on-support-container p-lg`,t),...n,children:e})})}function K({children:e}){return W(),(0,o.jsx)(`span`,{className:`text-body-1-highlight`,children:e})}function q({className:e,children:t,...r}){let{selectedCount:a,onClearSelection:s,hasMultiplePages:c}=W();return c?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:a===0,onClick:s,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}function de({className:e,children:t,...r}){let{selectedCount:a,totalCount:s,onSelectAll:c,hasMultiplePages:l}=W();return l?(0,o.jsx)(n.t,{size:`sm`,design:`ghost`,intent:`support`,underline:!0,ariaDisabled:s==null||c==null||a>=s,onClick:c,className:(0,i.cx)(`text-body-2`,e),...r,children:t}):null}G.displayName=`Table.BulkBar`;var J=G;J.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,de.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(c.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=c.Cell.getCollectionNode;function X({label:e,allowsResizing:t=!0,...n}){return null}X.displayName=`Table.Column`,X.getCollectionNode=function*(e,t){let n=e.title??e.label??e.children??null,r=e.textValue||(typeof n==`string`?n:``)||e[`aria-label`],i=yield{type:`column`,key:e.id??null,hasChildNodes:!!e.childColumns||!!e.title&&a.default.Children.count(e.children)>0,rendered:n,textValue:r,props:{...e,title:e.title??e.label,allowsResizing:e.allowsResizing},*childNodes(){if(e.childColumns)for(let t of e.childColumns)yield{type:`column`,value:t};else if(e.title){let t=[];a.default.Children.forEach(e.children,e=>{t.push({type:`column`,element:e})}),yield*t}},shouldInvalidate(e){return o(e),!1}},o=e=>{for(let t of i)t.hasChildNodes||e.columns.push(t)};o(t)};function Z(e){return(0,o.jsx)(c.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=c.TableHeader.getCollectionNode;function Q(e){return null}Q.displayName=`Table.Row`,Q.getCollectionNode=function*(e,t){let{children:n,textValue:r,UNSTABLE_childItems:i}=e;yield{type:`item`,key:e.id??null,props:e,textValue:r,"aria-label":e[`aria-label`],hasChildNodes:!0,*childNodes(){if(t.showDragButtons&&(yield{type:`cell`,key:`header-drag`,props:{isDragButtonCell:!0}}),t.showSelectionCheckboxes&&t.selectionMode!==`none`&&(yield{type:`cell`,key:`header`,props:{isSelectionCell:!0}}),typeof n==`function`){for(let e of t.columns)yield{type:`cell`,element:n(e.key),key:e.key};if(i)for(let e of i)yield{type:`item`,value:e}}else{let e=[],r=[],i=0;if(a.default.Children.forEach(n,n=>{if(n)if(n.type===Q){if(e.length<t.columns.length)throw Error(`All of a Row's child Cells must be positioned before any child Rows.`);r.push({type:`item`,element:n})}else e.push({type:`cell`,element:n}),i+=n.props?.colSpan??1}),i!==t.columns.length)throw Error(`Cell count must match column count. Found ${i} cells and ${t.columns.length} columns.`);yield*e,yield*r}},shouldInvalidate(e){return e.columns.length!==t.columns.length||e.columns.some((e,n)=>e.key!==t.columns[n].key)||e.showSelectionCheckboxes!==t.showSelectionCheckboxes||e.showDragButtons!==t.showDragButtons||e.selectionMode!==t.selectionMode}}};function fe(e,t,n,r){let i=e[n],a=t[n];if(i===a)return 0;let o;return o=typeof i==`number`&&typeof a==`number`?i<a?-1:1:String(i).localeCompare(String(a)),r===`descending`?-o:o}function pe(e,t={}){let{initialSort:n,compare:r}=t,[i,o]=(0,a.useState)(()=>n?{column:n.column,direction:n.direction}:{column:`id`,direction:`ascending`});return{sortDescriptor:i,onSortChange:o,setSortDescriptor:o,sortedItems:(0,a.useMemo)(()=>{let t=i.column;if(!t)return[...e];let n=r??fe,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function me(e,t){let{pageSize:n,initialPage:r=1,getId:i}=t,[o,s]=(0,a.useState)(r),[c,l]=(0,a.useState)(()=>new Set),u=e.length,d=Math.max(1,Math.ceil(u/n));(0,a.useEffect)(()=>{s(e=>e<1?1:e>d?d:e)},[d]);let f=o;f<1?f=1:f>d&&(f=d);let p=(0,a.useMemo)(()=>{let t=(f-1)*n,r=t+n;return e.slice(t,r)},[e,f,n]),m=(0,a.useMemo)(()=>{let t=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(e.map(e=>t(e)))},[i,e]),h=(0,a.useMemo)(()=>{let e=i??(e=>{let t=e.id;if(t==null)throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");return t});return new Set(p.map(t=>e(t)))},[i,p]);return{page:f,setPage:s,pageItems:p,totalItems:u,totalPages:d,allKeys:m,selectedKeys:c,onSelectionChange:e=>{let t=e===`all`?new Set(h):new Set(e);l(e=>{let n=new Set(t);for(let t of e)h.has(t)||n.add(t);return n})},onPageChange:e=>{s(e.page)},clearSelection:()=>{l(()=>new Set)}}}var $=Object.assign(v,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:J,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:de});$.displayName=`Table`,Z.displayName=`Table.Header`,X.displayName=`Table.Column`,H.displayName=`Table.Body`,Q.displayName=`Table.Row`,Y.displayName=`Table.Cell`,exports.Table=$,exports.TableCompound=$,exports.useTablePagination=me,exports.useTableSort=pe;
2
2
  //# sourceMappingURL=index.js.map