@spark-ui/components 18.1.1 → 18.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/{FormFieldRequiredIndicator-DY3STDp1.js → FormFieldRequiredIndicator-BxZgeZ9H.js} +2 -2
  2. package/dist/{FormFieldRequiredIndicator-DY3STDp1.js.map → FormFieldRequiredIndicator-BxZgeZ9H.js.map} +1 -1
  3. package/dist/{FormFieldRequiredIndicator-COKYxTNs.mjs → FormFieldRequiredIndicator-CfE6AOta.mjs} +2 -2
  4. package/dist/{FormFieldRequiredIndicator-COKYxTNs.mjs.map → FormFieldRequiredIndicator-CfE6AOta.mjs.map} +1 -1
  5. package/dist/accordion/index.js +1 -1
  6. package/dist/accordion/index.js.map +1 -1
  7. package/dist/accordion/index.mjs +45 -50
  8. package/dist/accordion/index.mjs.map +1 -1
  9. package/dist/alert-dialog/AlertDialogAction.d.ts +1 -1
  10. package/dist/alert-dialog/AlertDialogCancel.d.ts +1 -1
  11. package/dist/alert-dialog/AlertDialogTrigger.d.ts +1 -1
  12. package/dist/alert-dialog/index.js +1 -1
  13. package/dist/alert-dialog/index.js.map +1 -1
  14. package/dist/alert-dialog/index.mjs +53 -56
  15. package/dist/alert-dialog/index.mjs.map +1 -1
  16. package/dist/avatar/index.js +1 -1
  17. package/dist/avatar/index.mjs +2 -2
  18. package/dist/badge/BadgeItem.styles.d.ts +1 -1
  19. package/dist/badge/index.js +1 -1
  20. package/dist/badge/index.mjs +13 -13
  21. package/dist/breadcrumb/index.js +1 -1
  22. package/dist/breadcrumb/index.mjs +1 -1
  23. package/dist/button/Button.styles.d.ts +1 -1
  24. package/dist/button/index.js +1 -1
  25. package/dist/button/index.mjs +1 -1
  26. package/dist/{button-D0s-21qo.js → button-3vvMrf1L.js} +2 -2
  27. package/dist/{button-D0s-21qo.js.map → button-3vvMrf1L.js.map} +1 -1
  28. package/dist/{button-DwLTXeJX.mjs → button-DBNjh3Bi.mjs} +76 -76
  29. package/dist/{button-DwLTXeJX.mjs.map → button-DBNjh3Bi.mjs.map} +1 -1
  30. package/dist/card/Backdrop.d.ts +1 -1
  31. package/dist/card/Card.styles.d.ts +1 -1
  32. package/dist/card/Content.styles.d.ts +1 -1
  33. package/dist/card/Type.d.ts +1 -1
  34. package/dist/card/index.js +1 -1
  35. package/dist/card/index.mjs +53 -53
  36. package/dist/carousel/index.js +1 -1
  37. package/dist/carousel/index.mjs +2 -2
  38. package/dist/checkbox/CheckboxInput.styles.d.ts +1 -1
  39. package/dist/checkbox/index.js +1 -1
  40. package/dist/checkbox/index.mjs +1 -1
  41. package/dist/{checkbox-uSINHQYe.mjs → checkbox-BEo9AVSB.mjs} +26 -26
  42. package/dist/{checkbox-uSINHQYe.mjs.map → checkbox-BEo9AVSB.mjs.map} +1 -1
  43. package/dist/{checkbox-Cbewcw6G.js → checkbox-Cr60_jql.js} +2 -2
  44. package/dist/{checkbox-Cbewcw6G.js.map → checkbox-Cr60_jql.js.map} +1 -1
  45. package/dist/chip/Chip.styles.d.ts +1 -1
  46. package/dist/chip/index.js +1 -1
  47. package/dist/chip/index.mjs +86 -86
  48. package/dist/collapsible/index.js +1 -1
  49. package/dist/collapsible/index.js.map +1 -1
  50. package/dist/collapsible/index.mjs +18 -24
  51. package/dist/collapsible/index.mjs.map +1 -1
  52. package/dist/combobox/index.js +1 -1
  53. package/dist/combobox/index.mjs +4 -4
  54. package/dist/dialog/DialogClose.d.ts +1 -1
  55. package/dist/dialog/DialogTrigger.d.ts +1 -1
  56. package/dist/dialog/index.js +1 -1
  57. package/dist/dialog/index.js.map +1 -1
  58. package/dist/dialog/index.mjs +13 -11
  59. package/dist/dialog/index.mjs.map +1 -1
  60. package/dist/divider/index.js +1 -1
  61. package/dist/divider/index.mjs +26 -26
  62. package/dist/drawer/DrawerClose.d.ts +1 -1
  63. package/dist/drawer/DrawerTrigger.d.ts +1 -1
  64. package/dist/drawer/index.js +1 -1
  65. package/dist/drawer/index.js.map +1 -1
  66. package/dist/drawer/index.mjs +13 -11
  67. package/dist/drawer/index.mjs.map +1 -1
  68. package/dist/dropdown/index.js +1 -1
  69. package/dist/dropdown/index.mjs +2 -2
  70. package/dist/file-upload/index.js +1 -1
  71. package/dist/file-upload/index.mjs +3 -3
  72. package/dist/form-field/index.js +1 -1
  73. package/dist/form-field/index.mjs +1 -1
  74. package/dist/{form-field-B38U0zp8.js → form-field-DMHwopHt.js} +2 -2
  75. package/dist/{form-field-B38U0zp8.js.map → form-field-DMHwopHt.js.map} +1 -1
  76. package/dist/{form-field-DCKyhBmv.mjs → form-field-Doq4zLEX.mjs} +4 -4
  77. package/dist/{form-field-DCKyhBmv.mjs.map → form-field-Doq4zLEX.mjs.map} +1 -1
  78. package/dist/icon/Icon.styles.d.ts +1 -1
  79. package/dist/icon/index.js +1 -1
  80. package/dist/icon/index.mjs +1 -1
  81. package/dist/icon-CfEsla9z.js +2 -0
  82. package/dist/{icon-DY4l9nsc.js.map → icon-CfEsla9z.js.map} +1 -1
  83. package/dist/{icon-Bs-39J-H.mjs → icon-VM_Ys9Xn.mjs} +11 -11
  84. package/dist/{icon-Bs-39J-H.mjs.map → icon-VM_Ys9Xn.mjs.map} +1 -1
  85. package/dist/icon-button/index.js +1 -1
  86. package/dist/icon-button/index.mjs +1 -1
  87. package/dist/icon-button-B2TM0Xby.js +2 -0
  88. package/dist/{icon-button-DRFf308H.js.map → icon-button-B2TM0Xby.js.map} +1 -1
  89. package/dist/icon-button-CexCkoV0.mjs +29 -0
  90. package/dist/{icon-button-C1ThqdK1.mjs.map → icon-button-CexCkoV0.mjs.map} +1 -1
  91. package/dist/input/index.js +1 -1
  92. package/dist/input/index.mjs +1 -1
  93. package/dist/{input-BoxJZira.js → input-CADvgFpY.js} +2 -2
  94. package/dist/{input-BoxJZira.js.map → input-CADvgFpY.js.map} +1 -1
  95. package/dist/{input-Du9YSgAt.mjs → input-CmlNZ4Bo.mjs} +2 -2
  96. package/dist/{input-Du9YSgAt.mjs.map → input-CmlNZ4Bo.mjs.map} +1 -1
  97. package/dist/label/index.js +1 -1
  98. package/dist/label/index.mjs +1 -1
  99. package/dist/{label-DO48yda7.js → label-B085X0Sg.js} +2 -2
  100. package/dist/{label-DO48yda7.js.map → label-B085X0Sg.js.map} +1 -1
  101. package/dist/{label-RKaPen31.mjs → label-BqWu-wLT.mjs} +6 -6
  102. package/dist/{label-RKaPen31.mjs.map → label-BqWu-wLT.mjs.map} +1 -1
  103. package/dist/menu/MenuItemStyles.d.ts +1 -1
  104. package/dist/menu/index.js +1 -1
  105. package/dist/menu/index.js.map +1 -1
  106. package/dist/menu/index.mjs +131 -140
  107. package/dist/menu/index.mjs.map +1 -1
  108. package/dist/meter/MeterTrack.styles.d.ts +1 -1
  109. package/dist/pagination/index.js +1 -1
  110. package/dist/pagination/index.mjs +3 -3
  111. package/dist/popover/PopoverContent.styles.d.ts +1 -1
  112. package/dist/popover/index.js +1 -1
  113. package/dist/popover/index.mjs +1 -1
  114. package/dist/{popover-DVz0JvON.js → popover-B-mcHcLF.js} +2 -2
  115. package/dist/{popover-DVz0JvON.js.map → popover-B-mcHcLF.js.map} +1 -1
  116. package/dist/{popover-CGhSHQzb.mjs → popover-COqbFikI.mjs} +17 -17
  117. package/dist/{popover-CGhSHQzb.mjs.map → popover-COqbFikI.mjs.map} +1 -1
  118. package/dist/progress/ProgressIndicator.d.ts +1 -1
  119. package/dist/progress-tracker/index.js +1 -1
  120. package/dist/progress-tracker/index.mjs +1 -1
  121. package/dist/radio-group/RadioIndicator.styles.d.ts +1 -1
  122. package/dist/radio-group/RadioInput.styles.d.ts +1 -1
  123. package/dist/radio-group/index.js +1 -1
  124. package/dist/radio-group/index.mjs +37 -37
  125. package/dist/rating/index.js +1 -1
  126. package/dist/rating/index.mjs +2 -2
  127. package/dist/rating-display/index.js +1 -1
  128. package/dist/rating-display/index.mjs +1 -1
  129. package/dist/scrolling-list/index.js +1 -1
  130. package/dist/scrolling-list/index.mjs +3 -3
  131. package/dist/select/index.js +1 -1
  132. package/dist/select/index.mjs +1 -1
  133. package/dist/slider/SliderThumb.styles.d.ts +1 -1
  134. package/dist/slider/SliderTrack.styles.d.ts +1 -1
  135. package/dist/slider/index.js +1 -1
  136. package/dist/slider/index.mjs +2 -2
  137. package/dist/slot/index.js +1 -1
  138. package/dist/slot/index.mjs +3 -3
  139. package/dist/spinner/Spinner.styles.d.ts +1 -1
  140. package/dist/spinner/index.js +1 -1
  141. package/dist/spinner/index.mjs +1 -1
  142. package/dist/{spinner-CmPypfJR.js → spinner-BAreohbs.js} +2 -2
  143. package/dist/{spinner-CmPypfJR.js.map → spinner-BAreohbs.js.map} +1 -1
  144. package/dist/{spinner-TfGcjNm3.mjs → spinner-DnrZf01S.mjs} +9 -9
  145. package/dist/{spinner-TfGcjNm3.mjs.map → spinner-DnrZf01S.mjs.map} +1 -1
  146. package/dist/stepper/index.js +1 -1
  147. package/dist/stepper/index.mjs +3 -3
  148. package/dist/switch/SwitchInput.d.ts +1 -1
  149. package/dist/switch/index.js +1 -1
  150. package/dist/switch/index.js.map +1 -1
  151. package/dist/switch/index.mjs +43 -44
  152. package/dist/switch/index.mjs.map +1 -1
  153. package/dist/table/index.js +1 -1
  154. package/dist/table/index.mjs +3 -3
  155. package/dist/tabs/index.js +1 -1
  156. package/dist/tabs/index.js.map +1 -1
  157. package/dist/tabs/index.mjs +144 -153
  158. package/dist/tabs/index.mjs.map +1 -1
  159. package/dist/tag/Tag.styles.d.ts +1 -1
  160. package/dist/tag/index.js +1 -1
  161. package/dist/tag/index.mjs +37 -37
  162. package/dist/text-link/TextLink.d.ts +1 -1
  163. package/dist/textarea/index.js +1 -1
  164. package/dist/textarea/index.mjs +1 -1
  165. package/dist/toast/Toast.styles.d.ts +1 -1
  166. package/dist/toast/index.js +1 -1
  167. package/dist/toast/index.mjs +3 -3
  168. package/dist/toggle-group/index.js +1 -1
  169. package/dist/toggle-group/index.js.map +1 -1
  170. package/dist/toggle-group/index.mjs +16 -21
  171. package/dist/toggle-group/index.mjs.map +1 -1
  172. package/package.json +5 -5
  173. package/dist/accordion/useRenderSlot.d.ts +0 -3
  174. package/dist/alert-dialog/useRenderSlot.d.ts +0 -3
  175. package/dist/collapsible/useRenderSlot.d.ts +0 -3
  176. package/dist/drawer/useRenderSlot.d.ts +0 -3
  177. package/dist/icon-DY4l9nsc.js +0 -2
  178. package/dist/icon-button-C1ThqdK1.mjs +0 -29
  179. package/dist/icon-button-DRFf308H.js +0 -2
  180. package/dist/menu/useRenderSlot.d.ts +0 -1
  181. package/dist/tabs/useRenderSlot.d.ts +0 -1
  182. package/dist/toast/useRenderSlot.d.ts +0 -3
  183. package/dist/toggle-group/useRenderSlot.d.ts +0 -1
  184. package/dist/useRenderSlot-5CPC9Lkj.mjs +0 -11
  185. package/dist/useRenderSlot-5CPC9Lkj.mjs.map +0 -1
  186. package/dist/useRenderSlot-DHV0CegV.js +0 -2
  187. package/dist/useRenderSlot-DHV0CegV.js.map +0 -1
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../icon-DY4l9nsc.js"),t=require("../icon-button-DRFf308H.js"),n=require("../input-BoxJZira.js");let r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/hooks/use-merge-refs"),s=require("@spark-ui/components/form-field"),c=require("@spark-ui/icons/Minus"),l=require("@base-ui/react/number-field"),u=require("@spark-ui/icons/Plus");var d=(0,i.createContext)(null),f=({children:e,formatOptions:t,minValue:o,maxValue:c,ref:u,onValueChange:f,locale:p=`fr`,name:m,...h})=>{let g=(0,i.useRef)(null),_=(0,s.useFormFieldControl)(),v=(0,i.useRef)(h.value??h.defaultValue??null),y=_.name??m,b=_.disabled??h.disabled,x=_.readOnly??h.readOnly,S=_.isRequired??h.required,C=e=>{f&&e!==v.current&&(v.current=e,f(e))},{"aria-label":w,...T}=h;return(0,a.jsx)(d,{value:{inputRef:g,fieldId:_.id,fieldLabelId:_.labelId,fieldIsInvalid:_.isInvalid,fieldIsRequired:S,state:h.state,ariaLabel:w},children:(0,a.jsx)(l.NumberField.Root,{...T,format:t,min:o,max:c,locale:p,disabled:b,readOnly:x,required:S,name:y,inputRef:g,onValueCommitted:C,"aria-describedby":_.description,children:(0,a.jsx)(`div`,{"data-spark-component":`stepper`,ref:u,className:(0,r.cx)(n.r({disabled:b,readOnly:x}),h.className),children:e})})})};f.displayName=`Stepper`;var p=()=>{let e=(0,i.useContext)(d);if(!e)throw Error(`useStepperContext must be used within a Stepper provider`);return e},m=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:c,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Increment,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-r-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-increment-button`,children:(0,a.jsx)(t.t,{ref:c,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-l-0! -ml-px rounded-r-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(u.Plus,{})})})})}})},h=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:u,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Decrement,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-l-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-decrement-button`,children:(0,a.jsx)(t.t,{ref:u,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-r-0! -mr-px rounded-l-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(c.Minus,{})})})})}})},g=m,_=h;m.displayName=`Stepper.IncrementButton`,h.displayName=`Stepper.DecrementButton`;var v=({ref:e,...t})=>{let{inputRef:r,fieldId:i,fieldLabelId:s,fieldIsInvalid:c,fieldIsRequired:u,ariaLabel:d}=p(),f=(0,o.useMergeRefs)(e,r),{className:m=``,...h}=t,g=!!s;return(0,a.jsx)(`div`,{className:`relative inline-flex w-full`,children:(0,a.jsx)(l.NumberField.Input,{render:e=>{let t;u===void 0?`required`in e&&(t=e.required):t=u;let r=c===void 0?e[`aria-invalid`]:c;return(0,a.jsx)(n.n,{ref:f,...e,...h,id:i||e.id,required:t,"aria-invalid":r,"aria-label":g?void 0:d,className:`min-w-sz-56 text-center rounded-none! ${m}`})}})})},y=v;v.displayName=`Stepper.Input`;var b=Object.assign(f,{IncrementButton:g,DecrementButton:_,Input:y});b.displayName=`Stepper`,g.displayName=`Stepper.IncrementButton`,_.displayName=`Stepper.DecrementButton`,y.displayName=`Stepper.Input`,exports.Stepper=b;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../icon-CfEsla9z.js"),t=require("../icon-button-B2TM0Xby.js"),n=require("../input-CADvgFpY.js");let r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/hooks/use-merge-refs"),s=require("@spark-ui/components/form-field"),c=require("@spark-ui/icons/Minus"),l=require("@base-ui/react/number-field"),u=require("@spark-ui/icons/Plus");var d=(0,i.createContext)(null),f=({children:e,formatOptions:t,minValue:o,maxValue:c,ref:u,onValueChange:f,locale:p=`fr`,name:m,...h})=>{let g=(0,i.useRef)(null),_=(0,s.useFormFieldControl)(),v=(0,i.useRef)(h.value??h.defaultValue??null),y=_.name??m,b=_.disabled??h.disabled,x=_.readOnly??h.readOnly,S=_.isRequired??h.required,C=e=>{f&&e!==v.current&&(v.current=e,f(e))},{"aria-label":w,...T}=h;return(0,a.jsx)(d,{value:{inputRef:g,fieldId:_.id,fieldLabelId:_.labelId,fieldIsInvalid:_.isInvalid,fieldIsRequired:S,state:h.state,ariaLabel:w},children:(0,a.jsx)(l.NumberField.Root,{...T,format:t,min:o,max:c,locale:p,disabled:b,readOnly:x,required:S,name:y,inputRef:g,onValueCommitted:C,"aria-describedby":_.description,children:(0,a.jsx)(`div`,{"data-spark-component":`stepper`,ref:u,className:(0,r.cx)(n.r({disabled:b,readOnly:x}),h.className),children:e})})})};f.displayName=`Stepper`;var p=()=>{let e=(0,i.useContext)(d);if(!e)throw Error(`useStepperContext must be used within a Stepper provider`);return e},m=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:c,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Increment,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-r-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-increment-button`,children:(0,a.jsx)(t.t,{ref:c,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-l-0! -ml-px rounded-r-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(u.Plus,{})})})})}})},h=({children:n,design:i=`ghost`,intent:o=`neutral`,className:s,ref:u,disabled:d,...f})=>{let{fieldId:m,state:h}=p();return(0,a.jsx)(l.NumberField.Decrement,{render:l=>{let p=d||`disabled`in l&&l.disabled,g=`readOnly`in l&&l.readOnly;return(0,a.jsx)(`div`,{className:(0,r.cx)(`rounded-l-lg`,p||g?`bg-on-surface/dim-5`:null),"data-spark-component":`stepper-decrement-button`,children:(0,a.jsx)(t.t,{ref:u,design:i,intent:o,className:(0,r.cx)(`overflow-hidden border-sm shrink-0 h-full focus-visible:relative focus-visible:z-raised mx-0`,`rounded-r-0! -mr-px rounded-l-lg`,h===`error`&&`border-error`,h===`alert`&&`border-alert`,h===`success`&&`border-success`,!h&&`border-outline`,s),...f,...l,"aria-label":f[`aria-label`]||l[`aria-label`],"aria-controls":m,disabled:p,children:n||(0,a.jsx)(e.t,{children:(0,a.jsx)(c.Minus,{})})})})}})},g=m,_=h;m.displayName=`Stepper.IncrementButton`,h.displayName=`Stepper.DecrementButton`;var v=({ref:e,...t})=>{let{inputRef:r,fieldId:i,fieldLabelId:s,fieldIsInvalid:c,fieldIsRequired:u,ariaLabel:d}=p(),f=(0,o.useMergeRefs)(e,r),{className:m=``,...h}=t,g=!!s;return(0,a.jsx)(`div`,{className:`relative inline-flex w-full`,children:(0,a.jsx)(l.NumberField.Input,{render:e=>{let t;u===void 0?`required`in e&&(t=e.required):t=u;let r=c===void 0?e[`aria-invalid`]:c;return(0,a.jsx)(n.n,{ref:f,...e,...h,id:i||e.id,required:t,"aria-invalid":r,"aria-label":g?void 0:d,className:`min-w-sz-56 text-center rounded-none! ${m}`})}})})},y=v;v.displayName=`Stepper.Input`;var b=Object.assign(f,{IncrementButton:g,DecrementButton:_,Input:y});b.displayName=`Stepper`,g.displayName=`Stepper.IncrementButton`,_.displayName=`Stepper.DecrementButton`,y.displayName=`Stepper.Input`,exports.Stepper=b;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import { t as e } from "../icon-Bs-39J-H.mjs";
2
- import { t } from "../icon-button-C1ThqdK1.mjs";
3
- import { n, r } from "../input-Du9YSgAt.mjs";
1
+ import { t as e } from "../icon-VM_Ys9Xn.mjs";
2
+ import { t } from "../icon-button-CexCkoV0.mjs";
3
+ import { n, r } from "../input-CmlNZ4Bo.mjs";
4
4
  import { cx as i } from "class-variance-authority";
5
5
  import { createContext as a, useContext as o, useRef as s } from "react";
6
6
  import { jsx as c } from "react/jsx-runtime";
@@ -48,6 +48,6 @@ export interface SwitchInputProps extends StylesProps, Omit<ComponentPropsWithRe
48
48
  asChild?: boolean;
49
49
  }
50
50
  export declare const SwitchInput: {
51
- ({ checked, checkedIcon, defaultChecked, uncheckedIcon, size, onCheckedChange, className, required, ref, asChild, ...rest }: SwitchInputProps): import("react").JSX.Element;
51
+ ({ checked, checkedIcon, defaultChecked, uncheckedIcon, size, onCheckedChange, className, required, ref, asChild, children, ...rest }: SwitchInputProps): import("react").JSX.Element;
52
52
  displayName: string;
53
53
  };
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../slot/index.js"),t=require("../label-DO48yda7.js"),n=require("../useRenderSlot-DHV0CegV.js");let r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/internal-utils"),s=require("@spark-ui/components/form-field"),c=require("@spark-ui/icons/Check"),l=require("@spark-ui/hooks/use-combined-state"),u=require("@spark-ui/icons/Close"),d=require("@base-ui/react/switch");var f=(0,r.cva)((0,o.tw)([`relative shrink-0 self-baseline`,`cursor-pointer aria-disabled:cursor-not-allowed`,`rounded-full border-transparent`,`hover:ring-4`,`transition-colors duration-200 ease-in-out`,`aria-disabled:opacity-dim-3`,`focus-visible:u-outline`,`text-support bg-support data-unchecked:bg-neutral/dim-3`,`u-shadow-border-transition`,`overflow-x-hidden`,`hover:ring-support-container aria-disabled:hover:ring-transparent `]),{variants:{size:(0,o.makeVariants)({sm:(0,o.tw)([`h-sz-24`,`w-sz-40`,`border-md`]),md:(0,o.tw)([`h-sz-32`,`w-sz-56`,`border-[4px]`])})},defaultVariants:{size:`sm`}}),p=(0,r.cva)([`pointer-events-none absolute inset-0 flex items-center`,`transition-all duration-200 ease-in-out`],{variants:{checked:{true:`translate-x-full`,false:`translate-x-0`}}}),m=(0,r.cva)([`absolute left-0 top-0 flex items-center justify-center`,`bg-surface`,`rounded-full`,`ring-0`,`transition-all duration-200 ease-in-out`],{variants:{size:(0,o.makeVariants)({sm:[`h-sz-20`,`w-sz-20`],md:[`h-sz-24`,`w-sz-24`]}),checked:{true:`-translate-x-full`,false:`translate-x-0 text-on-surface/dim-2`}},defaultVariants:{size:`sm`,checked:!1}}),h=(0,r.cva)([`transition-opacity duration-200`],{variants:{size:(0,o.makeVariants)({sm:[`h-sz-10 w-sz-10`],md:[`h-sz-12 w-sz-12`]})},defaultVariants:{size:`sm`}}),g=({checked:t,checkedIcon:r=(0,a.jsx)(c.Check,{}),defaultChecked:i,uncheckedIcon:o=(0,a.jsx)(u.Close,{}),size:g=`md`,onCheckedChange:_,className:v,required:y,ref:b,asChild:x=!1,...S})=>{let[C,w]=(0,l.useCombinedState)(t,i),{name:T,description:E,isRequired:D,isInvalid:O}=(0,s.useFormFieldControl)(),k=n.t(x,`span`),A=!!(y||D),j=e=>{w(e),_?.(e)};return(0,a.jsx)(d.Switch.Root,{"data-spark-component":`switch-input`,ref:b,render:k,className:f({size:g,className:v}),checked:t,defaultChecked:i,onCheckedChange:e=>j(e),name:T,required:A,"aria-required":A?!0:void 0,"aria-invalid":O,"aria-describedby":E,...S,children:(0,a.jsx)(`span`,{className:p({checked:C}),children:(0,a.jsxs)(d.Switch.Thumb,{className:m({size:g,checked:C}),children:[C&&r&&(0,a.jsx)(e.Slot,{className:h({size:g}),children:r}),!C&&o&&(0,a.jsx)(e.Slot,{className:h({size:g}),children:o})]})})})};g.displayName=`SwitchInput`;var _=(0,r.cva)(`default:text-on-surface`,{variants:{disabled:{true:[`text-neutral/dim-2`,`cursor-not-allowed`],false:[`cursor-pointer`]}},defaultVariants:{disabled:!1}}),v=({className:e,disabled:n,...r})=>(0,a.jsx)(t.t,{"data-spark-component":`switch-label`,className:_({disabled:n,className:e}),...r}),y=`:switch`,b=({size:e=`md`,children:t,className:n,id:o,disabled:c,reverse:l=!1,ref:u,...d})=>{let f=(0,s.useFormFieldControl)(),p=`${y}-label-${(0,i.useId)()}`,m=`${y}-input-${(0,i.useId)()}`,h=f.id||o||m,_=t&&(0,a.jsx)(v,{disabled:c,htmlFor:h,id:p,children:t}),b=(0,a.jsx)(g,{ref:u,size:e,id:h,disabled:c,"aria-labelledby":t?p:f.labelId,...d}),x=l?(0,a.jsxs)(a.Fragment,{children:[_,b]}):(0,a.jsxs)(a.Fragment,{children:[b,_]});return(0,a.jsx)(`div`,{"data-spark-component":`switch`,className:(0,r.cx)(`gap-md text-body-1 flex items-center`,n),children:x})};b.displayName=`Switch`,exports.Switch=b;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../slot/index.js"),t=require("../label-B085X0Sg.js");let n=require("@spark-ui/internal-utils"),r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/components/form-field"),s=require("@spark-ui/icons/Check"),c=require("@spark-ui/hooks/use-combined-state"),l=require("@spark-ui/icons/Close"),u=require("@base-ui/react/switch");var d=(0,r.cva)((0,n.tw)([`relative shrink-0 self-baseline`,`cursor-pointer aria-disabled:cursor-not-allowed`,`rounded-full border-transparent`,`hover:ring-4`,`transition-colors duration-200 ease-in-out`,`aria-disabled:opacity-dim-3`,`focus-visible:u-outline`,`text-support bg-support data-unchecked:bg-neutral/dim-3`,`u-shadow-border-transition`,`overflow-x-hidden`,`hover:ring-support-container aria-disabled:hover:ring-transparent `]),{variants:{size:(0,n.makeVariants)({sm:(0,n.tw)([`h-sz-24`,`w-sz-40`,`border-md`]),md:(0,n.tw)([`h-sz-32`,`w-sz-56`,`border-[4px]`])})},defaultVariants:{size:`sm`}}),f=(0,r.cva)([`pointer-events-none absolute inset-0 flex items-center`,`transition-all duration-200 ease-in-out`],{variants:{checked:{true:`translate-x-full`,false:`translate-x-0`}}}),p=(0,r.cva)([`absolute left-0 top-0 flex items-center justify-center`,`bg-surface`,`rounded-full`,`ring-0`,`transition-all duration-200 ease-in-out`],{variants:{size:(0,n.makeVariants)({sm:[`h-sz-20`,`w-sz-20`],md:[`h-sz-24`,`w-sz-24`]}),checked:{true:`-translate-x-full`,false:`translate-x-0 text-on-surface/dim-2`}},defaultVariants:{size:`sm`,checked:!1}}),m=(0,r.cva)([`transition-opacity duration-200`],{variants:{size:(0,n.makeVariants)({sm:[`h-sz-10 w-sz-10`],md:[`h-sz-12 w-sz-12`]})},defaultVariants:{size:`sm`}}),h=({checked:t,checkedIcon:r=(0,a.jsx)(s.Check,{}),defaultChecked:i,uncheckedIcon:h=(0,a.jsx)(l.Close,{}),size:g=`md`,onCheckedChange:_,className:v,required:y,ref:b,asChild:x=!1,children:S,...C})=>{let[w,T]=(0,c.useCombinedState)(t,i),{name:E,description:D,isRequired:O,isInvalid:k}=(0,o.useFormFieldControl)(),{renderProp:A}=(0,n.createRenderSlot)(x,S),j=!!(y||O),M=e=>{T(e),_?.(e)};return(0,a.jsx)(u.Switch.Root,{"data-spark-component":`switch-input`,ref:b,render:A,className:d({size:g,className:v}),checked:t,defaultChecked:i,onCheckedChange:e=>M(e),name:E,required:j,"aria-required":j?!0:void 0,"aria-invalid":k,"aria-describedby":D,...C,children:(0,a.jsx)(`span`,{className:f({checked:w}),children:(0,a.jsxs)(u.Switch.Thumb,{className:p({size:g,checked:w}),children:[w&&r&&(0,a.jsx)(e.Slot,{className:m({size:g}),children:r}),!w&&h&&(0,a.jsx)(e.Slot,{className:m({size:g}),children:h})]})})})};h.displayName=`SwitchInput`;var g=(0,r.cva)(`default:text-on-surface`,{variants:{disabled:{true:[`text-neutral/dim-2`,`cursor-not-allowed`],false:[`cursor-pointer`]}},defaultVariants:{disabled:!1}}),_=({className:e,disabled:n,...r})=>(0,a.jsx)(t.t,{"data-spark-component":`switch-label`,className:g({disabled:n,className:e}),...r}),v=`:switch`,y=({size:e=`md`,children:t,className:n,id:s,disabled:c,reverse:l=!1,ref:u,...d})=>{let f=(0,o.useFormFieldControl)(),p=`${v}-label-${(0,i.useId)()}`,m=`${v}-input-${(0,i.useId)()}`,g=f.id||s||m,y=t&&(0,a.jsx)(_,{disabled:c,htmlFor:g,id:p,children:t}),b=(0,a.jsx)(h,{ref:u,size:e,id:g,disabled:c,"aria-labelledby":t?p:f.labelId,...d}),x=l?(0,a.jsxs)(a.Fragment,{children:[y,b]}):(0,a.jsxs)(a.Fragment,{children:[b,y]});return(0,a.jsx)(`div`,{"data-spark-component":`switch`,className:(0,r.cx)(`gap-md text-body-1 flex items-center`,n),children:x})};y.displayName=`Switch`,exports.Switch=y;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","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 aria-disabled:cursor-not-allowed',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'aria-disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'text-support bg-support data-unchecked:bg-neutral/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n 'hover:ring-support-container aria-disabled:hover:ring-transparent ',\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 defaultVariants: {\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 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, isRequired, isInvalid } = useFormFieldControl()\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({ 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.js","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 aria-disabled:cursor-not-allowed',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'aria-disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'text-support bg-support data-unchecked:bg-neutral/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n 'hover:ring-support-container aria-disabled:hover:ring-transparent ',\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 defaultVariants: {\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 { createRenderSlot } from '@spark-ui/internal-utils'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\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 uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n children,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, isRequired, isInvalid } = useFormFieldControl()\n const { renderProp } = createRenderSlot(asChild, children)\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={renderProp}\n className={styles({ 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,17 +1,16 @@
1
1
  import { Slot as e } from "../slot/index.mjs";
2
- import { t } from "../label-RKaPen31.mjs";
3
- import { t as n } from "../useRenderSlot-5CPC9Lkj.mjs";
4
- import { cva as r, cx as i } from "class-variance-authority";
5
- import { useId as a } from "react";
6
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
- import { makeVariants as l, tw as u } from "@spark-ui/internal-utils";
2
+ import { t } from "../label-BqWu-wLT.mjs";
3
+ import { createRenderSlot as n, makeVariants as r, tw as i } from "@spark-ui/internal-utils";
4
+ import { cva as a, cx as o } from "class-variance-authority";
5
+ import { useId as s } from "react";
6
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
8
7
  import { useFormFieldControl as d } from "@spark-ui/components/form-field";
9
8
  import { Check as f } from "@spark-ui/icons/Check";
10
9
  import { useCombinedState as p } from "@spark-ui/hooks/use-combined-state";
11
10
  import { Close as m } from "@spark-ui/icons/Close";
12
11
  import { Switch as h } from "@base-ui/react/switch";
13
12
  //#region src/switch/SwitchInput.styles.ts
14
- var g = r(u([
13
+ var g = a(i([
15
14
  "relative shrink-0 self-baseline",
16
15
  "cursor-pointer aria-disabled:cursor-not-allowed",
17
16
  "rounded-full border-transparent",
@@ -24,23 +23,23 @@ var g = r(u([
24
23
  "overflow-x-hidden",
25
24
  "hover:ring-support-container aria-disabled:hover:ring-transparent "
26
25
  ]), {
27
- variants: { size: l({
28
- sm: u([
26
+ variants: { size: r({
27
+ sm: i([
29
28
  "h-sz-24",
30
29
  "w-sz-40",
31
30
  "border-md"
32
31
  ]),
33
- md: u([
32
+ md: i([
34
33
  "h-sz-32",
35
34
  "w-sz-56",
36
35
  "border-[4px]"
37
36
  ])
38
37
  }) },
39
38
  defaultVariants: { size: "sm" }
40
- }), _ = r(["pointer-events-none absolute inset-0 flex items-center", "transition-all duration-200 ease-in-out"], { variants: { checked: {
39
+ }), _ = a(["pointer-events-none absolute inset-0 flex items-center", "transition-all duration-200 ease-in-out"], { variants: { checked: {
41
40
  true: "translate-x-full",
42
41
  false: "translate-x-0"
43
- } } }), v = r([
42
+ } } }), v = a([
44
43
  "absolute left-0 top-0 flex items-center justify-center",
45
44
  "bg-surface",
46
45
  "rounded-full",
@@ -48,7 +47,7 @@ var g = r(u([
48
47
  "transition-all duration-200 ease-in-out"
49
48
  ], {
50
49
  variants: {
51
- size: l({
50
+ size: r({
52
51
  sm: ["h-sz-20", "w-sz-20"],
53
52
  md: ["h-sz-24", "w-sz-24"]
54
53
  }),
@@ -61,44 +60,44 @@ var g = r(u([
61
60
  size: "sm",
62
61
  checked: !1
63
62
  }
64
- }), y = r(["transition-opacity duration-200"], {
65
- variants: { size: l({
63
+ }), y = a(["transition-opacity duration-200"], {
64
+ variants: { size: r({
66
65
  sm: ["h-sz-10 w-sz-10"],
67
66
  md: ["h-sz-12 w-sz-12"]
68
67
  }) },
69
68
  defaultVariants: { size: "sm" }
70
- }), b = ({ checked: t, checkedIcon: r = /* @__PURE__ */ s(f, {}), defaultChecked: i, uncheckedIcon: a = /* @__PURE__ */ s(m, {}), size: o = "md", onCheckedChange: l, className: u, required: b, ref: x, asChild: S = !1, ...C }) => {
71
- let [w, T] = p(t, i), { name: E, description: D, isRequired: O, isInvalid: k } = d(), A = n(S, "span"), j = !!(b || O), M = (e) => {
72
- T(e), l?.(e);
69
+ }), b = ({ checked: t, checkedIcon: r = /* @__PURE__ */ l(f, {}), defaultChecked: i, uncheckedIcon: a = /* @__PURE__ */ l(m, {}), size: o = "md", onCheckedChange: s, className: c, required: b, ref: x, asChild: S = !1, children: C, ...w }) => {
70
+ let [T, E] = p(t, i), { name: D, description: O, isRequired: k, isInvalid: A } = d(), { renderProp: j } = n(S, C), M = !!(b || k), N = (e) => {
71
+ E(e), s?.(e);
73
72
  };
74
- return /* @__PURE__ */ s(h.Root, {
73
+ return /* @__PURE__ */ l(h.Root, {
75
74
  "data-spark-component": "switch-input",
76
75
  ref: x,
77
- render: A,
76
+ render: j,
78
77
  className: g({
79
78
  size: o,
80
- className: u
79
+ className: c
81
80
  }),
82
81
  checked: t,
83
82
  defaultChecked: i,
84
- onCheckedChange: (e) => M(e),
85
- name: E,
86
- required: j,
87
- "aria-required": j ? !0 : void 0,
88
- "aria-invalid": k,
89
- "aria-describedby": D,
90
- ...C,
91
- children: /* @__PURE__ */ s("span", {
92
- className: _({ checked: w }),
93
- children: /* @__PURE__ */ c(h.Thumb, {
83
+ onCheckedChange: (e) => N(e),
84
+ name: D,
85
+ required: M,
86
+ "aria-required": M ? !0 : void 0,
87
+ "aria-invalid": A,
88
+ "aria-describedby": O,
89
+ ...w,
90
+ children: /* @__PURE__ */ l("span", {
91
+ className: _({ checked: T }),
92
+ children: /* @__PURE__ */ u(h.Thumb, {
94
93
  className: v({
95
94
  size: o,
96
- checked: w
95
+ checked: T
97
96
  }),
98
- children: [w && r && /* @__PURE__ */ s(e, {
97
+ children: [T && r && /* @__PURE__ */ l(e, {
99
98
  className: y({ size: o }),
100
99
  children: r
101
- }), !w && a && /* @__PURE__ */ s(e, {
100
+ }), !T && a && /* @__PURE__ */ l(e, {
102
101
  className: y({ size: o }),
103
102
  children: a
104
103
  })]
@@ -109,36 +108,36 @@ var g = r(u([
109
108
  b.displayName = "SwitchInput";
110
109
  //#endregion
111
110
  //#region src/switch/SwitchLabel.styles.ts
112
- var x = r("default:text-on-surface", {
111
+ var x = a("default:text-on-surface", {
113
112
  variants: { disabled: {
114
113
  true: ["text-neutral/dim-2", "cursor-not-allowed"],
115
114
  false: ["cursor-pointer"]
116
115
  } },
117
116
  defaultVariants: { disabled: !1 }
118
- }), S = ({ className: e, disabled: n, ...r }) => /* @__PURE__ */ s(t, {
117
+ }), S = ({ className: e, disabled: n, ...r }) => /* @__PURE__ */ l(t, {
119
118
  "data-spark-component": "switch-label",
120
119
  className: x({
121
120
  disabled: n,
122
121
  className: e
123
122
  }),
124
123
  ...r
125
- }), C = ":switch", w = ({ size: e = "md", children: t, className: n, id: r, disabled: l, reverse: u = !1, ref: f, ...p }) => {
126
- let m = d(), h = `${C}-label-${a()}`, g = `${C}-input-${a()}`, _ = m.id || r || g, v = t && /* @__PURE__ */ s(S, {
127
- disabled: l,
124
+ }), C = ":switch", w = ({ size: e = "md", children: t, className: n, id: r, disabled: i, reverse: a = !1, ref: f, ...p }) => {
125
+ let m = d(), h = `${C}-label-${s()}`, g = `${C}-input-${s()}`, _ = m.id || r || g, v = t && /* @__PURE__ */ l(S, {
126
+ disabled: i,
128
127
  htmlFor: _,
129
128
  id: h,
130
129
  children: t
131
- }), y = /* @__PURE__ */ s(b, {
130
+ }), y = /* @__PURE__ */ l(b, {
132
131
  ref: f,
133
132
  size: e,
134
133
  id: _,
135
- disabled: l,
134
+ disabled: i,
136
135
  "aria-labelledby": t ? h : m.labelId,
137
136
  ...p
138
- }), x = u ? /* @__PURE__ */ c(o, { children: [v, y] }) : /* @__PURE__ */ c(o, { children: [y, v] });
139
- return /* @__PURE__ */ s("div", {
137
+ }), x = a ? /* @__PURE__ */ u(c, { children: [v, y] }) : /* @__PURE__ */ u(c, { children: [y, v] });
138
+ return /* @__PURE__ */ l("div", {
140
139
  "data-spark-component": "switch",
141
- className: i("gap-md text-body-1 flex items-center", n),
140
+ className: o("gap-md text-body-1 flex items-center", n),
142
141
  children: x
143
142
  });
144
143
  };
@@ -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 aria-disabled:cursor-not-allowed',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'aria-disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'text-support bg-support data-unchecked:bg-neutral/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n 'hover:ring-support-container aria-disabled:hover:ring-transparent ',\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 defaultVariants: {\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 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, isRequired, isInvalid } = useFormFieldControl()\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({ 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;CACA;AACF,CAAC,GACD;CACE,UAAU,EAIR,MAAM,EAAmC;EACvC,IAAI,EAAG;GAAC;GAAW;GAAW;EAAW,CAAC;EAC1C,IAAI,EAAG;GAAC;GAAW;GAAW;EAAc,CAAC;CAC/C,CAAC,EACH;CACA,iBAAiB,EACf,MAAM,KACR;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,GCnBY,KAAe,EAC1B,YACA,iBAAc,kBAAC,GAAD,CAAQ,CAAA,GACtB,mBACA,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,eAAY,iBAAc,EAAoB,GACnE,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;GAAM;EAAU,CAAC;EAC5B;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;;;ACtH1B,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
+ {"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 aria-disabled:cursor-not-allowed',\n 'rounded-full border-transparent',\n 'hover:ring-4',\n 'transition-colors duration-200 ease-in-out',\n 'aria-disabled:opacity-dim-3',\n 'focus-visible:u-outline',\n 'text-support bg-support data-unchecked:bg-neutral/dim-3',\n 'u-shadow-border-transition',\n 'overflow-x-hidden',\n 'hover:ring-support-container aria-disabled:hover:ring-transparent ',\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 defaultVariants: {\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 { createRenderSlot } from '@spark-ui/internal-utils'\nimport { type ComponentPropsWithRef, type ReactNode } from 'react'\n\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 uncheckedIcon = <Close />,\n size = 'md',\n onCheckedChange,\n className,\n required,\n ref,\n asChild = false,\n children,\n ...rest\n}: SwitchInputProps) => {\n const [isChecked, setIsChecked] = useCombinedState(checked, defaultChecked)\n const { name, description, isRequired, isInvalid } = useFormFieldControl()\n const { renderProp } = createRenderSlot(asChild, children)\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={renderProp}\n className={styles({ 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,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-CMqjfN_6.js"),t=require("../icon-DY4l9nsc.js"),n=require("../button-D0s-21qo.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-aria"),l=require("react-stately"),u=require("@spark-ui/icons/ArrowDown"),d=require("@spark-ui/icons/ArrowUp"),f=require("@spark-ui/icons/Sort");var p=(0,a.createContext)({isResizable:!1,tableWidth:0});function m(){return(0,a.useContext)(p)}var h=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function g(){return(0,a.useContext)(h)}function _({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:g,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)(h,{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:g,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})})}_.displayName=`Table`;function v({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)(p,{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})})}v.displayName=`ResizableTableContainer`;var y=`[data-spark-component="table-cell"]`;function b(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function x(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 S=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function C(e){return!e||!(e instanceof Element)?null:e.closest(y)}function w(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function T(e){return Array.from(e.querySelectorAll(S)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function E(e,t){for(let n of T(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 D(e){let t=Array.from(e.querySelectorAll(y));for(let e of t)E(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),l=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{l.current=e,s.current=`interaction`,o(`interaction`),E(e,!0)};return(0,c.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=l.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&b(e.target)&&C(e.target)===l.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=C(e.target);t&&t===l.current&&e.stopPropagation();return}if(b(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=C(e.target);if(t&&t===l.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=C(e.target);if(t&&t===l.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=C(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(y));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=C(e.target);if(!t||w(t))return;let n=T(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=C(e.target);if(!t||w(t))return;let n=T(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(x(e.target))return;let t=l.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=l.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)||(l.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=C(t.target);if(s.current===`interaction`&&l.current&&i){let e=!!(a&&a!==l.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!l.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(l.current=null))}if(!a)return;l.current=a;let c=t.target instanceof Element?t.target:null,d=a.matches(y),p=s.current===`grid`,m=!!(c&&c!==a&&a.contains(c)),h=T(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!w(a)&&f(a)},onPointerDownCapture:e=>{let t=C(e.target);t?.matches(y)&&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`){D(t),l.current?.focus?.();return}D(t),l.current&&E(l.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var te=(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}}),ne=(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 O=(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:{}}),k=`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"]`,ie=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function ae(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(k)||t.closest(k)!==null}function oe(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function se(e){for(let t of e.querySelectorAll(ie))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function ce(e){let t=oe(e);if(!t)return!1;if(ae(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:se(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:s}=(0,c.useTableCell)({node:e},t,r),{isFocusVisible:l,focusProps:u}=(0,c.useFocusRing)({within:!0}),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=s,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,c.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0,y=e.props?.className;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,c.mergeProps)(m,{onKeyDownCapture:h},u,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:O({checkbox:!0}),"data-focus-visible":l||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,c.mergeProps)(m,{onKeyDownCapture:h},u,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:(0,i.cx)(O(),y),"data-focus-visible":l||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{ce((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:l}=(0,c.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,c.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,l&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,c.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":l||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:l,inputProps:u,isResizing:d}=(0,c.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`,...l,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...u})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,c.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,l=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),u=i===`all`?l:i,d=[...l].filter(e=>u.has(e)).length,f=l.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:l,isLastColumnInRow:p=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=g(),{columnHeaderProps:_}=(0,c.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,c.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!p,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{..._,ref:m,role:`columnheader`,className:(0,i.cx)(te({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)(u.ArrowDown,{}):(0,o.jsx)(d.ArrowUp,{}):(0,o.jsx)(f.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,c.mergeProps)(_,y),ref:m,role:`columnheader`,className:(0,i.cx)(te({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:ne(),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:l}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:l}=(0,c.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...l,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=m(),p=r.selectionMode===`multiple`,h=(0,l.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,l.useTableColumnResizeState)({tableWidth:f.tableWidth},h),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,c.useTable)({...r},h,d),y=h.collection.headerRows,b=[...h.collection.body.childNodes],x=h.collection.body.props?.renderEmptyState,S=h.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,c.useTableRowGroup)(),{rowGroupProps:T}=(0,c.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,c.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:h,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:h,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function le(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:le(a)},y=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:y,stickyHeader:s},x=B;return i?(0,o.jsx)(v,{className:y,style:_,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:_,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(l.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=l.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}=g();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 J({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 ue=G;ue.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,J.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(l.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=l.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)(l.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=l.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 de(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 fe(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??de,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function pe(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(_,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:ue,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:J});$.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=pe,exports.useTableSort=fe;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-CMqjfN_6.js"),t=require("../icon-CfEsla9z.js"),n=require("../button-3vvMrf1L.js"),r=require("../checkbox-Cr60_jql.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-aria"),l=require("react-stately"),u=require("@spark-ui/icons/ArrowDown"),d=require("@spark-ui/icons/ArrowUp"),f=require("@spark-ui/icons/Sort");var p=(0,a.createContext)({isResizable:!1,tableWidth:0});function m(){return(0,a.useContext)(p)}var h=(0,a.createContext)({selectedCount:0,onClearSelection:()=>{}});function g(){return(0,a.useContext)(h)}function _({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:g,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)(h,{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:g,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})})}_.displayName=`Table`;function v({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)(p,{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})})}v.displayName=`ResizableTableContainer`;var y=`[data-spark-component="table-cell"]`;function b(e){return!e||!(e instanceof Element)?!1:!!e.closest(`[role="combobox"],select,[data-spark-component="dropdown-trigger"],[data-spark-component="combobox-input"]`)}function x(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 S=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function C(e){return!e||!(e instanceof Element)?null:e.closest(y)}function w(e){return e.getAttribute(`data-table-cell-kind`)===`selection`}function T(e){return Array.from(e.querySelectorAll(S)).filter(t=>!(t===e||t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`||t.getAttribute(`hidden`)!==null))}function E(e,t){for(let n of T(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 D(e){let t=Array.from(e.querySelectorAll(y));for(let e of t)E(e,!1)}function ee({ref:e,gridProps:t,onKeyDownCapture:n,onFocusCapture:r}){let[i,o]=(0,a.useState)(`grid`),s=(0,a.useRef)(`grid`),l=(0,a.useRef)(null),u=(0,a.useRef)(!1),d=(0,a.useMemo)(()=>{let{onKeyDown:a,...d}=t,f=e=>{l.current=e,s.current=`interaction`,o(`interaction`),E(e,!0)};return(0,c.mergeProps)(d,{onKeyDown:e=>{if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let e=l.current,t=document.activeElement;if(e&&t instanceof Node&&e.contains(t))return}s.current===`interaction`&&(e.key===`ArrowUp`||e.key===`ArrowDown`)&&b(e.target)&&C(e.target)===l.current||a?.(e)},onKeyDownCapture:e=>{if(n?.(e),s.current===`interaction`&&e.key===`Tab`){let t=C(e.target);t&&t===l.current&&e.stopPropagation();return}if(b(e.target)&&s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=C(e.target);if(t&&t===l.current)return}if(s.current===`interaction`&&(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`)){let t=C(e.target);if(t&&t===l.current){e.stopPropagation();return}}if(s.current===`grid`&&e.key===`ArrowRight`){let t=C(e.target);if(t){let n=t.closest(`tr`);if(n){let r=Array.from(n.querySelectorAll(y));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=C(e.target);if(!t||w(t))return;let n=T(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=C(e.target);if(!t||w(t))return;let n=T(t);if(n.length===0)return;e.preventDefault(),e.stopPropagation(),f(t),n[0]?.focus();return}if(s.current===`interaction`&&e.key===`Escape`){if(x(e.target))return;let t=l.current;if(!t)return;e.preventDefault(),e.stopPropagation(),s.current=`grid`,o(`grid`),t.focus()}if(s.current===`interaction`&&e.key===`F2`){let t=l.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)||(l.current=null,s.current=`grid`,o(`grid`))},onFocusCapture:t=>{r?.(t);let n=u.current;u.current=!1;let i=e.current,a=C(t.target);if(s.current===`interaction`&&l.current&&i){let e=!!(a&&a!==l.current),n=!a&&t.target instanceof Element&&i.contains(t.target)&&!l.current.contains(t.target);(e||n)&&(s.current=`grid`,o(`grid`),n&&(l.current=null))}if(!a)return;l.current=a;let c=t.target instanceof Element?t.target:null,d=a.matches(y),p=s.current===`grid`,m=!!(c&&c!==a&&a.contains(c)),h=T(a).length>0;p&&d&&m&&h&&!n&&queueMicrotask(()=>a.focus()),n&&p&&m&&d&&h&&!w(a)&&f(a)},onPointerDownCapture:e=>{let t=C(e.target);t?.matches(y)&&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`){D(t),l.current?.focus?.();return}D(t),l.current&&E(l.current,!0)}},[i,e]),{gridProps:d,keyboardMode:i}}var te=(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}}),ne=(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 O=(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:{}}),k=`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"]`,ie=`a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]`;function ae(e){if(!e||!(e instanceof Element))return!1;let t=e;return t.matches(k)||t.closest(k)!==null}function oe(e){return e?e instanceof Element?e:e instanceof Text?e.parentElement:null:null}function se(e){for(let t of e.querySelectorAll(ie))if(t!==e&&!t.hasAttribute(`disabled`)&&t.getAttribute(`aria-disabled`)!==`true`&&t.getAttribute(`hidden`)===null)return!0;return!1}function ce(e){let t=oe(e);if(!t)return!1;if(ae(t))return!0;let n=t.closest(`[data-spark-component="table-cell"]`);return!n||n.getAttribute(`data-table-cell-kind`)===`selection`?!1:se(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:s}=(0,c.useTableCell)({node:e},t,r),{isFocusVisible:l,focusProps:u}=(0,c.useFocusRing)({within:!0}),d=(0,a.useContext)(A),f=(0,a.useCallback)(e=>{d===`interaction`&&(e.key!==` `&&e.key!==`Enter`||e.stopPropagation())},[d]),{onKeyDownCapture:p,...m}=s,h=(0,a.useCallback)(e=>{[`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)||p?.(e)},[p]),g=(0,c.useTableSelectionCheckbox)({key:e.parentKey??e.key},t),_=t.collection.columns[e.index??0]?.key??null,v=_?n?.columnWidths?.get?.(_):void 0,y=e.props?.className;return e.props?.isSelectionCell?(0,o.jsx)(`td`,{...(0,c.mergeProps)(m,{onKeyDownCapture:h},u,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,"data-table-cell-kind":`selection`,className:O({checkbox:!0}),"data-focus-visible":l||void 0,children:(0,o.jsx)(j,{suppressFocusWalker:d===`grid`,checkboxProps:g.checkboxProps})}):(0,o.jsx)(`td`,{...(0,c.mergeProps)(m,{onKeyDownCapture:h},u,{onKeyDown:f}),ref:r,"data-spark-component":`table-cell`,className:(0,i.cx)(O(),y),"data-focus-visible":l||void 0,style:v?{width:v}:void 0,children:e.rendered})}M.displayName=`Table.BodyCellRenderer`;function N(e){if(e)return t=>{ce((0,s.getEventTarget)(t.nativeEvent))||e(t)}}function P({item:e,state:t,resizeState:n}){let r=(0,a.useRef)(null),{rowProps:s,isSelected:l}=(0,c.useTableRow)({node:e},t,r),{isFocusVisible:u,focusProps:d}=(0,c.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,l&&`bg-support-container text-on-support-container`);return(0,o.jsx)(`tr`,{...(0,c.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":l||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:l,inputProps:u,isResizing:d}=(0,c.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`,...l,children:(0,o.jsx)(`input`,{ref:s,disabled:!d,...u})})}F.displayName=`Table.ColumnResizer`;function I({state:e}){let{checkboxProps:t}=(0,c.useTableSelectAllCheckbox)(e),{collection:n,selectionManager:r}=e,i=r.selectedKeys,a=n,s=a.body,l=s==null?new Set(n.getKeys()):new Set([...a.getChildren(s.key)].map(e=>e.key)),u=i===`all`?l:i,d=[...l].filter(e=>u.has(e)).length,f=l.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:l,isLastColumnInRow:p=!1}){let m=(0,a.useRef)(null),{resizeColumnAriaLabel:h}=g(),{columnHeaderProps:_}=(0,c.useTableColumnHeader)({node:e},n,m),{isFocusVisible:v,focusProps:y}=(0,c.useFocusRing)(),b=e.props?.allowsResizing!==!1&&!p,x=r?.columnWidths?.get?.(e.key),S=!!(r&&b);if(e.props?.isSelectionCell)return(0,o.jsx)(`th`,{..._,ref:m,role:`columnheader`,className:(0,i.cx)(te({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)(u.ArrowDown,{}):(0,o.jsx)(d.ArrowUp,{}):(0,o.jsx)(f.Sort,{}),D=t=>{C&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),t.stopPropagation(),n.sort?.(e.key)))};return(0,o.jsxs)(`th`,{...(0,c.mergeProps)(_,y),ref:m,role:`columnheader`,className:(0,i.cx)(te({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:ne(),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:l}):null]})}R.displayName=`Table.ColumnHeader`;function z({item:e,state:t,resizeState:n,stickyHeader:r,resizeCallbacks:i}){let s=(0,a.useRef)(null),{rowProps:l}=(0,c.useTableHeaderRow)({node:e},t,s),u=[...e.childNodes];return(0,o.jsx)(`tr`,{...l,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=m(),p=r.selectionMode===`multiple`,h=(0,l.useTableState)({...r,showSelectionCheckboxes:r.selectionMode===`multiple`,children:t}),g=(0,l.useTableColumnResizeState)({tableWidth:f.tableWidth},h),_=f.isResizable&&r.allowsResizing!==!1?g:null,{gridProps:v}=(0,c.useTable)({...r},h,d),y=h.collection.headerRows,b=[...h.collection.body.childNodes],x=h.collection.body.props?.renderEmptyState,S=h.collection.columns.length||1,C=b.length>0||!!x,{rowGroupProps:w}=(0,c.useTableRowGroup)(),{rowGroupProps:T}=(0,c.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,c.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:h,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:h,resizeState:_},e.key))]})]})})}B.displayName=`Table.Grid.Inner`;function le(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:le(a)},y=n??m,b={...h,...e!=null&&{"aria-label":e},...t!=null&&{"aria-labelledby":t},sortDescriptor:f,onSortChange:p,onKeyDownCapture:d,className:y,stickyHeader:s},x=B;return i?(0,o.jsx)(v,{className:y,style:_,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:_,children:(0,o.jsx)(x,{...b,children:r})})}V.displayName=`Table.Grid`;function H(e){return(0,o.jsx)(l.TableBody,{...e})}H.displayName=`Table.Body`,H.getCollectionNode=l.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}=g();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 J({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 ue=G;ue.displayName=`Table.BulkBar`,K.displayName=`Table.BulkBarSelectedCount`,q.displayName=`Table.BulkBarClearButton`,J.displayName=`Table.BulkBarSelectAllButton`;function Y(e){return(0,o.jsx)(l.Cell,{...e})}Y.displayName=`Table.Cell`,Y.getCollectionNode=l.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)(l.TableHeader,{...e})}Z.displayName=`Table.Header`,Z.getCollectionNode=l.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 de(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 fe(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??de,a=i.direction??`ascending`;return[...e].sort((e,r)=>n(e,r,t,a))},[e,i.column,i.direction,r])}}function pe(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(_,{Grid:V,Header:Z,Column:X,Body:H,Row:Q,Cell:Y,BulkBar:ue,BulkBarSelectedCount:K,BulkBarClearButton:q,BulkBarSelectAllButton:J});$.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=pe,exports.useTableSort=fe;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import { t as e } from "../icon-Bs-39J-H.mjs";
2
- import { t } from "../button-DwLTXeJX.mjs";
3
- import { n } from "../checkbox-uSINHQYe.mjs";
1
+ import { t as e } from "../icon-VM_Ys9Xn.mjs";
2
+ import { t } from "../button-DBNjh3Bi.mjs";
3
+ import { n } from "../checkbox-BEo9AVSB.mjs";
4
4
  import { cva as r, cx as i } from "class-variance-authority";
5
5
  import a, { createContext as o, useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
6
6
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../slot/index.js"),t=require("../icon-DY4l9nsc.js"),n=require("../button-D0s-21qo.js"),r=require("../icon-button-DRFf308H.js"),i=require("../popover-DVz0JvON.js");let a=require("class-variance-authority"),o=require("react"),s=require("react/jsx-runtime"),c=require("@spark-ui/internal-utils"),l=require("@spark-ui/hooks/use-merge-refs"),u=require("@spark-ui/icons/ArrowVerticalRight"),d=require("@spark-ui/icons/ArrowVerticalLeft"),f=require("@base-ui/react/tabs"),p=require("@spark-ui/icons/MoreMenuHorizontal");var m=(0,o.createContext)({}),h=()=>{let e=(0,o.useContext)(m);if(!e)throw Error(`useTabsContext must be used within a TabsContext Provider`);return e},g=(0,a.cva)([`flex`,`data-[orientation=horizontal]:flex-col`,`data-[orientation=vertical]:flex-row`,`max-w-full`]);function _(t){return t?({...t})=>(0,s.jsx)(e.Slot,{...t}):void 0}var v=({intent:e=`support`,size:t=`md`,asChild:n=!1,forceMount:r=!1,orientation:i=`horizontal`,children:a,className:o,ref:c,...l})=>{let u=_(n);return(0,s.jsx)(m,{value:{intent:e,size:t,orientation:i,forceMount:r},children:(0,s.jsx)(f.Tabs.Root,{ref:c,orientation:i,className:g({className:o}),"data-spark-component":`tabs`,render:u,...l,children:a})})};v.displayName=`Tabs`;var y=(0,a.cva)([`w-full p-lg`,`focus-visible:u-outline-inset`],{variants:{forceMount:{true:`data-[hidden]:hidden`,false:``}}}),b=({children:e,asChild:t=!1,className:n,ref:r,forceMount:i,...a})=>{let{forceMount:o}=h(),c=_(t),l=o||i;return(0,s.jsx)(f.Tabs.Panel,{"data-spark-component":`tabs-content`,ref:r,keepMounted:l,className:y({className:n,forceMount:l}),render:c,...a,children:e})};b.displayName=`Tabs.Content`;var x=(0,a.cva)([`relative flex`]),S=(0,a.cva)([`flex w-full`,`data-[orientation=horizontal]:flex-row`,`data-[orientation=vertical]:flex-col`,`overflow-y-hidden u-no-scrollbar data-[orientation=vertical]:overflow-x-hidden`,`after:flex after:shrink after:grow after:border-outline`,`data-[orientation=horizontal]:after:border-b-sm`,`data-[orientation=vertical]:after:border-r-sm`]),C=(0,a.cva)([`h-auto! flex-none`,`border-b-sm border-outline`,`outline-hidden`,`focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset!`]),w=(e,t)=>{let[n,r]=(0,o.useState)({width:void 0,height:void 0}),i=(0,o.useRef)(null),a=(0,o.useRef)(t);return(0,o.useEffect)(()=>{a.current=t},[t]),(0,o.useEffect)(()=>{let t=e&&`current`in e?e.current:e;if(!(!t||i.current))return i.current=new ResizeObserver(([e])=>{let{inlineSize:t,blockSize:n}=e?.borderBoxSize?.[0]??{};a.current?.(e),r({width:t,height:n})}),i.current.observe(t),()=>{i.current&&i.current.unobserve(t)}},[e,i,a]),n},T=({asChild:e=!1,loop:r=!1,children:i,className:a,ref:c,...l})=>{let p=(0,o.useRef)(null),m=(0,o.useRef)(null),g=c||m,{orientation:v}=h(),y=_(e),{width:b}=w(p),[T,E]=(0,o.useState)({prev:`hidden`,next:`hidden`});(0,o.useEffect)(()=>{typeof g==`function`||!g.current||E(v===`horizontal`?{prev:g.current.scrollWidth>g.current.clientWidth?`visible`:`hidden`,next:g.current.scrollWidth>g.current.clientWidth?`visible`:`hidden`}:{prev:`hidden`,next:`hidden`})},[v,g,b]),(0,o.useEffect)(()=>{if(typeof g==`function`||!g.current||T.prev===`hidden`||r)return;let e=e=>{E({prev:e.scrollLeft>0?`visible`:`disabled`,next:e.scrollLeft+e.clientWidth<e.scrollWidth?`visible`:`disabled`})},t=g.current;return e(t),t.addEventListener(`scroll`,({target:t})=>e(t)),()=>t.removeEventListener(`scroll`,({target:t})=>e(t))},[g,T.prev,r]);let D=()=>{if(typeof g==`function`||!g.current)return;let e=r&&g.current.scrollLeft<=0;g.current.scrollTo({left:e?g.current.scrollLeft+g.current.scrollWidth-g.current.clientWidth:g.current.scrollLeft-g.current.clientWidth,behavior:`smooth`})},O=()=>{if(typeof g==`function`||!g.current)return;let e=r&&g.current.scrollLeft+g.current.clientWidth>=g.current.scrollWidth;g.current.scrollTo({left:e?0:g.current.scrollLeft+g.current.clientWidth,behavior:`smooth`})};return(0,s.jsxs)(`div`,{className:x({className:a}),ref:p,children:[T.prev!==`hidden`&&(0,s.jsx)(n.t,{shape:`square`,intent:`surface`,size:`sm`,className:C(),onClick:D,disabled:T.prev===`disabled`,"aria-label":`Scroll left`,children:(0,s.jsx)(t.t,{children:(0,s.jsx)(d.ArrowVerticalLeft,{})})}),(0,s.jsx)(f.Tabs.List,{"data-spark-component":`tabs-list`,ref:g,className:S(),render:y,loopFocus:r,activateOnFocus:!0,...l,children:i}),T.next!==`hidden`&&(0,s.jsx)(n.t,{shape:`square`,intent:`surface`,size:`sm`,className:C(),onClick:O,disabled:T.next===`disabled`,"aria-label":`Scroll right`,children:(0,s.jsx)(t.t,{children:(0,s.jsx)(u.ArrowVerticalRight,{})})})]})};T.displayName=`Tabs.List`;var E=(0,o.createContext)(void 0),D=()=>{let e=(0,o.useContext)(E);if(!e)throw Error(`TabsPopover components must be used within TabsPopover`);return e},O=(0,o.forwardRef)(({"aria-label":e,children:n,...a},o)=>{let{popoverTriggerRef:c}=D(),u=(0,l.useMergeRefs)(o,c);return(0,s.jsx)(i.t.Trigger,{asChild:!0,...a,children:(0,s.jsx)(r.t,{ref:u,size:`sm`,intent:`surfaceInverse`,design:`ghost`,"aria-label":e,tabIndex:-1,children:(0,s.jsx)(t.t,{children:n||(0,s.jsx)(p.MoreMenuHorizontal,{})})})})});O.displayName=`Popover.Trigger`;var k=(0,o.forwardRef)(({side:e,align:t=`start`,className:n,...r},o)=>{let{popoverSide:c}=D(),l=(0,a.cx)(`gap-sm flex flex-col`,n);return(0,s.jsx)(i.t.Content,{ref:o,...r,side:e??c,align:t,className:l})});k.displayName=`Popover.Content`;var A=({popoverSide:e,popoverTriggerRef:t,children:n})=>{let r=(0,o.useMemo)(()=>({popoverSide:e,popoverTriggerRef:t}),[e,t]),a=Object.assign((e=>(0,s.jsx)(E,{value:r,children:(0,s.jsx)(i.t,{...e,children:e.children})})),i.t,{Content:k,Trigger:O});return(0,s.jsx)(E,{value:r,children:n(a)})};A.displayName=`Popover`;var j=(0,a.cva)([`px-md`,`relative flex flex-none items-center`,`border-outline`,`hover:not-disabled:bg-surface-hovered`,`after:absolute`,`data-[active]:font-medium`,`not-data-[active]:not-disabled:cursor-pointer`,`data-[orientation=horizontal]:border-b-sm data-[orientation=horizontal]:after:inset-x-0 data-[orientation=horizontal]:after:bottom-[-1px] data-[orientation=horizontal]:after:h-sz-2`,`data-[orientation=vertical]:border-r-sm data-[orientation=vertical]:after:inset-y-0 data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:w-sz-2`,`focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset`,`disabled:cursor-not-allowed disabled:opacity-dim-3`,`gap-md [&>*:first-child]:ml-md [&>*:last-child]:mr-md`,`[&>svg:last-child:first-child]:mx-auto`],{variants:{intent:(0,c.makeVariants)({main:[`data-[active]:text-main data-[active]:after:bg-main`],support:[`data-[active]:text-support data-[active]:after:bg-support`]}),size:{xs:[`h-sz-32 min-w-sz-32 text-caption`],sm:[`h-sz-36 min-w-sz-36 text-body-2`],md:[`h-sz-40 min-w-sz-40 text-body-1`]},hasMenu:{true:`pr-3xl`},orientation:{horizontal:``,vertical:``}},compoundVariants:[{hasMenu:!0,orientation:`vertical`,class:`w-full`}],defaultVariants:{intent:`support`,size:`md`,hasMenu:!1,orientation:`horizontal`}}),M=({asChild:e=!1,value:t,disabled:n=!1,children:r,className:i,ref:a,onKeyDown:c,renderMenu:u,...d})=>{let{intent:p,size:m,orientation:g}=h(),v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=_(e),x=(0,l.useMergeRefs)(a,y),S=e=>{e.key===`F10`&&e.shiftKey&&u&&v.current&&(e.preventDefault(),v.current.click()),c?.(e)},C=!!u,w=g===`vertical`?`right`:`bottom`,T=(0,s.jsx)(f.Tabs.Tab,{"data-spark-component":`tabs-trigger`,ref:x,className:j({intent:p,size:m,hasMenu:C,orientation:g??`horizontal`,className:i}),render:b,disabled:n,value:t,onFocus:({target:e})=>e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),onKeyDown:S,"aria-haspopup":C?`true`:void 0,...d,children:r});return C?(0,s.jsxs)(`div`,{className:g===`vertical`?`relative w-full`:`relative`,children:[T,(0,s.jsx)(`div`,{className:`right-md mr-md pointer-events-auto absolute top-1/2 -translate-y-1/2`,children:(0,s.jsx)(A,{popoverSide:w,popoverTriggerRef:v,children:e=>u?.({Popover:e})})})]}):T};M.displayName=`Tabs.Trigger`;var N=Object.assign(v,{List:T,Trigger:M,Content:b});N.displayName=`Tabs`,T.displayName=`Tabs.List`,M.displayName=`Tabs.Trigger`,b.displayName=`Tabs.Content`,exports.Tabs=N;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../icon-CfEsla9z.js"),t=require("../button-3vvMrf1L.js"),n=require("../icon-button-B2TM0Xby.js"),r=require("../popover-B-mcHcLF.js");let i=require("@spark-ui/internal-utils"),a=require("class-variance-authority"),o=require("react"),s=require("react/jsx-runtime"),c=require("@spark-ui/hooks/use-merge-refs"),l=require("@spark-ui/icons/ArrowVerticalRight"),u=require("@spark-ui/icons/ArrowVerticalLeft"),d=require("@base-ui/react/tabs"),f=require("@spark-ui/icons/MoreMenuHorizontal");var p=(0,o.createContext)({}),m=()=>{let e=(0,o.useContext)(p);if(!e)throw Error(`useTabsContext must be used within a TabsContext Provider`);return e},h=(0,a.cva)([`flex`,`data-[orientation=horizontal]:flex-col`,`data-[orientation=vertical]:flex-row`,`max-w-full`]),g=({intent:e=`support`,size:t=`md`,asChild:n=!1,forceMount:r=!1,orientation:a=`horizontal`,children:o,className:c,ref:l,...u})=>{let{renderProp:f,innerChildren:m}=(0,i.createRenderSlot)(n,o);return(0,s.jsx)(p,{value:{intent:e,size:t,orientation:a,forceMount:r},children:(0,s.jsx)(d.Tabs.Root,{ref:l,orientation:a,className:h({className:c}),"data-spark-component":`tabs`,render:f,...u,children:m})})};g.displayName=`Tabs`;var _=(0,a.cva)([`w-full p-lg`,`focus-visible:u-outline-inset`],{variants:{forceMount:{true:`data-[hidden]:hidden`,false:``}}}),v=({children:e,asChild:t=!1,className:n,ref:r,forceMount:a,...o})=>{let{forceMount:c}=m(),{renderProp:l,innerChildren:u}=(0,i.createRenderSlot)(t,e),f=c||a;return(0,s.jsx)(d.Tabs.Panel,{"data-spark-component":`tabs-content`,ref:r,keepMounted:f,className:_({className:n,forceMount:f}),render:l,...o,children:u})};v.displayName=`Tabs.Content`;var y=(0,a.cva)([`relative flex`]),b=(0,a.cva)([`flex w-full`,`data-[orientation=horizontal]:flex-row`,`data-[orientation=vertical]:flex-col`,`overflow-y-hidden u-no-scrollbar data-[orientation=vertical]:overflow-x-hidden`,`after:flex after:shrink after:grow after:border-outline`,`data-[orientation=horizontal]:after:border-b-sm`,`data-[orientation=vertical]:after:border-r-sm`]),x=(0,a.cva)([`h-auto! flex-none`,`border-b-sm border-outline`,`outline-hidden`,`focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset!`]),S=(e,t)=>{let[n,r]=(0,o.useState)({width:void 0,height:void 0}),i=(0,o.useRef)(null),a=(0,o.useRef)(t);return(0,o.useEffect)(()=>{a.current=t},[t]),(0,o.useEffect)(()=>{let t=e&&`current`in e?e.current:e;if(!(!t||i.current))return i.current=new ResizeObserver(([e])=>{let{inlineSize:t,blockSize:n}=e?.borderBoxSize?.[0]??{};a.current?.(e),r({width:t,height:n})}),i.current.observe(t),()=>{i.current&&i.current.unobserve(t)}},[e,i,a]),n},C=({asChild:n=!1,loop:r=!1,children:a,className:c,ref:f,...p})=>{let h=(0,o.useRef)(null),g=(0,o.useRef)(null),_=f||g,{orientation:v}=m(),{renderProp:C,innerChildren:w}=(0,i.createRenderSlot)(n,a),{width:T}=S(h),[E,D]=(0,o.useState)({prev:`hidden`,next:`hidden`});(0,o.useEffect)(()=>{typeof _==`function`||!_.current||D(v===`horizontal`?{prev:_.current.scrollWidth>_.current.clientWidth?`visible`:`hidden`,next:_.current.scrollWidth>_.current.clientWidth?`visible`:`hidden`}:{prev:`hidden`,next:`hidden`})},[v,_,T]),(0,o.useEffect)(()=>{if(typeof _==`function`||!_.current||E.prev===`hidden`||r)return;let e=e=>{D({prev:e.scrollLeft>0?`visible`:`disabled`,next:e.scrollLeft+e.clientWidth<e.scrollWidth?`visible`:`disabled`})},t=_.current;return e(t),t.addEventListener(`scroll`,({target:t})=>e(t)),()=>t.removeEventListener(`scroll`,({target:t})=>e(t))},[_,E.prev,r]);let O=()=>{if(typeof _==`function`||!_.current)return;let e=r&&_.current.scrollLeft<=0;_.current.scrollTo({left:e?_.current.scrollLeft+_.current.scrollWidth-_.current.clientWidth:_.current.scrollLeft-_.current.clientWidth,behavior:`smooth`})},k=()=>{if(typeof _==`function`||!_.current)return;let e=r&&_.current.scrollLeft+_.current.clientWidth>=_.current.scrollWidth;_.current.scrollTo({left:e?0:_.current.scrollLeft+_.current.clientWidth,behavior:`smooth`})};return(0,s.jsxs)(`div`,{className:y({className:c}),ref:h,children:[E.prev!==`hidden`&&(0,s.jsx)(t.t,{shape:`square`,intent:`surface`,size:`sm`,className:x(),onClick:O,disabled:E.prev===`disabled`,"aria-label":`Scroll left`,children:(0,s.jsx)(e.t,{children:(0,s.jsx)(u.ArrowVerticalLeft,{})})}),(0,s.jsx)(d.Tabs.List,{"data-spark-component":`tabs-list`,ref:_,className:b(),render:C,loopFocus:r,activateOnFocus:!0,...p,children:w}),E.next!==`hidden`&&(0,s.jsx)(t.t,{shape:`square`,intent:`surface`,size:`sm`,className:x(),onClick:k,disabled:E.next===`disabled`,"aria-label":`Scroll right`,children:(0,s.jsx)(e.t,{children:(0,s.jsx)(l.ArrowVerticalRight,{})})})]})};C.displayName=`Tabs.List`;var w=(0,o.createContext)(void 0),T=()=>{let e=(0,o.useContext)(w);if(!e)throw Error(`TabsPopover components must be used within TabsPopover`);return e},E=(0,o.forwardRef)(({"aria-label":t,children:i,...a},o)=>{let{popoverTriggerRef:l}=T(),u=(0,c.useMergeRefs)(o,l);return(0,s.jsx)(r.t.Trigger,{asChild:!0,...a,children:(0,s.jsx)(n.t,{ref:u,size:`sm`,intent:`surfaceInverse`,design:`ghost`,"aria-label":t,tabIndex:-1,children:(0,s.jsx)(e.t,{children:i||(0,s.jsx)(f.MoreMenuHorizontal,{})})})})});E.displayName=`Popover.Trigger`;var D=(0,o.forwardRef)(({side:e,align:t=`start`,className:n,...i},o)=>{let{popoverSide:c}=T(),l=(0,a.cx)(`gap-sm flex flex-col`,n);return(0,s.jsx)(r.t.Content,{ref:o,...i,side:e??c,align:t,className:l})});D.displayName=`Popover.Content`;var O=({popoverSide:e,popoverTriggerRef:t,children:n})=>{let i=(0,o.useMemo)(()=>({popoverSide:e,popoverTriggerRef:t}),[e,t]),a=Object.assign((e=>(0,s.jsx)(w,{value:i,children:(0,s.jsx)(r.t,{...e,children:e.children})})),r.t,{Content:D,Trigger:E});return(0,s.jsx)(w,{value:i,children:n(a)})};O.displayName=`Popover`;var k=(0,a.cva)([`px-md`,`relative flex flex-none items-center`,`border-outline`,`hover:not-disabled:bg-surface-hovered`,`after:absolute`,`data-[active]:font-medium`,`not-data-[active]:not-disabled:cursor-pointer`,`data-[orientation=horizontal]:border-b-sm data-[orientation=horizontal]:after:inset-x-0 data-[orientation=horizontal]:after:bottom-[-1px] data-[orientation=horizontal]:after:h-sz-2`,`data-[orientation=vertical]:border-r-sm data-[orientation=vertical]:after:inset-y-0 data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:w-sz-2`,`focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset`,`disabled:cursor-not-allowed disabled:opacity-dim-3`,`gap-md [&>*:first-child]:ml-md [&>*:last-child]:mr-md`,`[&>svg:last-child:first-child]:mx-auto`],{variants:{intent:(0,i.makeVariants)({main:[`data-[active]:text-main data-[active]:after:bg-main`],support:[`data-[active]:text-support data-[active]:after:bg-support`]}),size:{xs:[`h-sz-32 min-w-sz-32 text-caption`],sm:[`h-sz-36 min-w-sz-36 text-body-2`],md:[`h-sz-40 min-w-sz-40 text-body-1`]},hasMenu:{true:`pr-3xl`},orientation:{horizontal:``,vertical:``}},compoundVariants:[{hasMenu:!0,orientation:`vertical`,class:`w-full`}],defaultVariants:{intent:`support`,size:`md`,hasMenu:!1,orientation:`horizontal`}}),A=({asChild:e=!1,value:t,disabled:n=!1,children:r,className:a,ref:l,onKeyDown:u,renderMenu:f,...p})=>{let{intent:h,size:g,orientation:_}=m(),v=(0,o.useRef)(null),y=(0,c.useMergeRefs)(l,(0,o.useRef)(null)),{renderProp:b,innerChildren:x}=(0,i.createRenderSlot)(e,r),S=e=>{e.key===`F10`&&e.shiftKey&&f&&v.current&&(e.preventDefault(),v.current.click()),u?.(e)},C=!!f,w=_===`vertical`?`right`:`bottom`,T=(0,s.jsx)(d.Tabs.Tab,{"data-spark-component":`tabs-trigger`,ref:y,className:k({intent:h,size:g,hasMenu:C,orientation:_??`horizontal`,className:a}),render:b,disabled:n,value:t,onFocus:({target:e})=>e.scrollIntoView({behavior:`smooth`,block:`nearest`,inline:`nearest`}),onKeyDown:S,"aria-haspopup":C?`true`:void 0,...p,children:x});return C?(0,s.jsxs)(`div`,{className:_===`vertical`?`relative w-full`:`relative`,children:[T,(0,s.jsx)(`div`,{className:`right-md mr-md pointer-events-auto absolute top-1/2 -translate-y-1/2`,children:(0,s.jsx)(O,{popoverSide:w,popoverTriggerRef:v,children:e=>f?.({Popover:e})})})]}):T};A.displayName=`Tabs.Trigger`;var j=Object.assign(g,{List:C,Trigger:A,Content:v});j.displayName=`Tabs`,C.displayName=`Tabs.List`,A.displayName=`Tabs.Trigger`,v.displayName=`Tabs.Content`,exports.Tabs=j;
2
2
  //# sourceMappingURL=index.js.map