@spark-ui/components 17.2.3 → 17.2.4-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/dist/DialogContent.styles-BSxCCi-u.mjs +62 -0
  2. package/dist/DialogContent.styles-BSxCCi-u.mjs.map +1 -0
  3. package/dist/DialogContent.styles-CAhJtUud.js +2 -0
  4. package/dist/DialogContent.styles-CAhJtUud.js.map +1 -0
  5. package/dist/FormFieldRequiredIndicator-CtgkvPZo.js +2 -0
  6. package/dist/FormFieldRequiredIndicator-CtgkvPZo.js.map +1 -0
  7. package/dist/FormFieldRequiredIndicator-DOGQ_HxO.mjs +14 -0
  8. package/dist/FormFieldRequiredIndicator-DOGQ_HxO.mjs.map +1 -0
  9. package/dist/accordion/index.js +2 -2
  10. package/dist/accordion/index.js.map +1 -1
  11. package/dist/accordion/index.mjs +99 -161
  12. package/dist/accordion/index.mjs.map +1 -1
  13. package/dist/alert-dialog/index.js +2 -2
  14. package/dist/alert-dialog/index.js.map +1 -1
  15. package/dist/alert-dialog/index.mjs +169 -235
  16. package/dist/alert-dialog/index.mjs.map +1 -1
  17. package/dist/avatar/index.js +2 -2
  18. package/dist/avatar/index.js.map +1 -1
  19. package/dist/avatar/index.mjs +187 -224
  20. package/dist/avatar/index.mjs.map +1 -1
  21. package/dist/badge/index.js +2 -2
  22. package/dist/badge/index.js.map +1 -1
  23. package/dist/badge/index.mjs +115 -81
  24. package/dist/badge/index.mjs.map +1 -1
  25. package/dist/breadcrumb/index.js +2 -2
  26. package/dist/breadcrumb/index.js.map +1 -1
  27. package/dist/breadcrumb/index.mjs +73 -106
  28. package/dist/breadcrumb/index.mjs.map +1 -1
  29. package/dist/button/index.js +1 -2
  30. package/dist/button/index.mjs +2 -5
  31. package/dist/button-BTDRzvpB.js +2 -0
  32. package/dist/button-BTDRzvpB.js.map +1 -0
  33. package/dist/button-_YZ_4J42.mjs +643 -0
  34. package/dist/button-_YZ_4J42.mjs.map +1 -0
  35. package/dist/card/index.js +2 -2
  36. package/dist/card/index.js.map +1 -1
  37. package/dist/card/index.mjs +327 -394
  38. package/dist/card/index.mjs.map +1 -1
  39. package/dist/carousel/index.js +2 -2
  40. package/dist/carousel/index.js.map +1 -1
  41. package/dist/carousel/index.mjs +515 -618
  42. package/dist/carousel/index.mjs.map +1 -1
  43. package/dist/checkbox/index.js +2 -2
  44. package/dist/checkbox/index.js.map +1 -1
  45. package/dist/checkbox/index.mjs +213 -246
  46. package/dist/checkbox/index.mjs.map +1 -1
  47. package/dist/chip/index.js +2 -2
  48. package/dist/chip/index.js.map +1 -1
  49. package/dist/chip/index.mjs +601 -652
  50. package/dist/chip/index.mjs.map +1 -1
  51. package/dist/chunk-C91j1N6u.js +1 -0
  52. package/dist/circular-meter/index.js +2 -2
  53. package/dist/circular-meter/index.js.map +1 -1
  54. package/dist/circular-meter/index.mjs +354 -309
  55. package/dist/circular-meter/index.mjs.map +1 -1
  56. package/dist/collapsible/index.js +2 -2
  57. package/dist/collapsible/index.js.map +1 -1
  58. package/dist/collapsible/index.mjs +53 -53
  59. package/dist/collapsible/index.mjs.map +1 -1
  60. package/dist/combobox/index.js +2 -2
  61. package/dist/combobox/index.js.map +1 -1
  62. package/dist/combobox/index.mjs +721 -876
  63. package/dist/combobox/index.mjs.map +1 -1
  64. package/dist/dialog/index.js +2 -2
  65. package/dist/dialog/index.js.map +1 -1
  66. package/dist/dialog/index.mjs +181 -206
  67. package/dist/dialog/index.mjs.map +1 -1
  68. package/dist/divider/index.js +2 -2
  69. package/dist/divider/index.js.map +1 -1
  70. package/dist/divider/index.mjs +178 -183
  71. package/dist/divider/index.mjs.map +1 -1
  72. package/dist/drawer/index.js +2 -2
  73. package/dist/drawer/index.js.map +1 -1
  74. package/dist/drawer/index.mjs +277 -309
  75. package/dist/drawer/index.mjs.map +1 -1
  76. package/dist/dropdown/index.js +2 -2
  77. package/dist/dropdown/index.js.map +1 -1
  78. package/dist/dropdown/index.mjs +429 -492
  79. package/dist/dropdown/index.mjs.map +1 -1
  80. package/dist/file-upload/index.js +2 -2
  81. package/dist/file-upload/index.js.map +1 -1
  82. package/dist/file-upload/index.mjs +540 -677
  83. package/dist/file-upload/index.mjs.map +1 -1
  84. package/dist/form-field/index.js +1 -2
  85. package/dist/form-field/index.mjs +2 -284
  86. package/dist/form-field-B8QzM655.mjs +231 -0
  87. package/dist/form-field-B8QzM655.mjs.map +1 -0
  88. package/dist/form-field-Bu_0E9tb.js +2 -0
  89. package/dist/form-field-Bu_0E9tb.js.map +1 -0
  90. package/dist/icon/index.js +1 -2
  91. package/dist/icon/index.mjs +2 -5
  92. package/dist/icon-CRPcdgYp.js +2 -0
  93. package/dist/icon-CRPcdgYp.js.map +1 -0
  94. package/dist/icon-D05Uqh8_.mjs +41 -0
  95. package/dist/icon-D05Uqh8_.mjs.map +1 -0
  96. package/dist/icon-button/index.js +1 -2
  97. package/dist/icon-button/index.mjs +2 -5
  98. package/dist/icon-button-6p3O7NIm.mjs +28 -0
  99. package/dist/icon-button-6p3O7NIm.mjs.map +1 -0
  100. package/dist/icon-button-CykysbgJ.js +2 -0
  101. package/dist/icon-button-CykysbgJ.js.map +1 -0
  102. package/dist/input/index.js +1 -2
  103. package/dist/input/index.mjs +2 -455
  104. package/dist/input-CmYeHYWQ.mjs +355 -0
  105. package/dist/input-CmYeHYWQ.mjs.map +1 -0
  106. package/dist/input-DNr40G2Z.js +2 -0
  107. package/dist/input-DNr40G2Z.js.map +1 -0
  108. package/dist/input-otp/index.js +2 -2
  109. package/dist/input-otp/index.js.map +1 -1
  110. package/dist/input-otp/index.mjs +344 -407
  111. package/dist/input-otp/index.mjs.map +1 -1
  112. package/dist/kbd/index.js +2 -2
  113. package/dist/kbd/index.js.map +1 -1
  114. package/dist/kbd/index.mjs +12 -17
  115. package/dist/kbd/index.mjs.map +1 -1
  116. package/dist/label/index.js +1 -2
  117. package/dist/label/index.mjs +2 -40
  118. package/dist/label-BqRlrca0.mjs +31 -0
  119. package/dist/label-BqRlrca0.mjs.map +1 -0
  120. package/dist/label-DU0p0d-f.js +2 -0
  121. package/dist/label-DU0p0d-f.js.map +1 -0
  122. package/dist/link-box/index.js +2 -2
  123. package/dist/link-box/index.js.map +1 -1
  124. package/dist/link-box/index.mjs +36 -34
  125. package/dist/link-box/index.mjs.map +1 -1
  126. package/dist/meter/index.js +2 -2
  127. package/dist/meter/index.js.map +1 -1
  128. package/dist/meter/index.mjs +149 -171
  129. package/dist/meter/index.mjs.map +1 -1
  130. package/dist/pagination/index.js +2 -2
  131. package/dist/pagination/index.js.map +1 -1
  132. package/dist/pagination/index.mjs +253 -214
  133. package/dist/pagination/index.mjs.map +1 -1
  134. package/dist/popover/index.js +1 -2
  135. package/dist/popover/index.mjs +2 -239
  136. package/dist/popover-CxZAQmw6.mjs +211 -0
  137. package/dist/popover-CxZAQmw6.mjs.map +1 -0
  138. package/dist/popover-GOovJ27J.js +2 -0
  139. package/dist/popover-GOovJ27J.js.map +1 -0
  140. package/dist/portal/index.js +2 -2
  141. package/dist/portal/index.js.map +1 -1
  142. package/dist/portal/index.mjs +8 -7
  143. package/dist/portal/index.mjs.map +1 -1
  144. package/dist/progress/index.js +1 -2
  145. package/dist/progress/index.mjs +2 -178
  146. package/dist/progress-cEf3tFbn.mjs +132 -0
  147. package/dist/progress-cEf3tFbn.mjs.map +1 -0
  148. package/dist/progress-rJZcPJsZ.js +2 -0
  149. package/dist/progress-rJZcPJsZ.js.map +1 -0
  150. package/dist/progress-tracker/index.js +2 -2
  151. package/dist/progress-tracker/index.js.map +1 -1
  152. package/dist/progress-tracker/index.mjs +303 -380
  153. package/dist/progress-tracker/index.mjs.map +1 -1
  154. package/dist/radio-group/index.js +2 -2
  155. package/dist/radio-group/index.js.map +1 -1
  156. package/dist/radio-group/index.mjs +204 -213
  157. package/dist/radio-group/index.mjs.map +1 -1
  158. package/dist/rating/index.js +2 -2
  159. package/dist/rating/index.js.map +1 -1
  160. package/dist/rating/index.mjs +189 -244
  161. package/dist/rating/index.mjs.map +1 -1
  162. package/dist/rating-display/index.js +2 -2
  163. package/dist/rating-display/index.js.map +1 -1
  164. package/dist/rating-display/index.mjs +165 -166
  165. package/dist/rating-display/index.mjs.map +1 -1
  166. package/dist/scrolling-list/index.js +2 -2
  167. package/dist/scrolling-list/index.js.map +1 -1
  168. package/dist/scrolling-list/index.mjs +216 -273
  169. package/dist/scrolling-list/index.mjs.map +1 -1
  170. package/dist/segmented-control/index.js +2 -2
  171. package/dist/segmented-control/index.js.map +1 -1
  172. package/dist/segmented-control/index.mjs +146 -180
  173. package/dist/segmented-control/index.mjs.map +1 -1
  174. package/dist/segmented-gauge/index.js +2 -2
  175. package/dist/segmented-gauge/index.js.map +1 -1
  176. package/dist/segmented-gauge/index.mjs +146 -195
  177. package/dist/segmented-gauge/index.mjs.map +1 -1
  178. package/dist/select/index.js +2 -2
  179. package/dist/select/index.js.map +1 -1
  180. package/dist/select/index.mjs +279 -327
  181. package/dist/select/index.mjs.map +1 -1
  182. package/dist/skeleton/index.js +2 -2
  183. package/dist/skeleton/index.js.map +1 -1
  184. package/dist/skeleton/index.mjs +92 -114
  185. package/dist/skeleton/index.mjs.map +1 -1
  186. package/dist/slider/index.js +2 -2
  187. package/dist/slider/index.js.map +1 -1
  188. package/dist/slider/index.mjs +259 -326
  189. package/dist/slider/index.mjs.map +1 -1
  190. package/dist/slot/index.js +2 -2
  191. package/dist/slot/index.js.map +1 -1
  192. package/dist/slot/index.mjs +12 -7
  193. package/dist/slot/index.mjs.map +1 -1
  194. package/dist/snackbar/index.js +2 -2
  195. package/dist/snackbar/index.js.map +1 -1
  196. package/dist/snackbar/index.mjs +404 -529
  197. package/dist/snackbar/index.mjs.map +1 -1
  198. package/dist/spinner/index.js +1 -2
  199. package/dist/spinner/index.mjs +2 -5
  200. package/dist/spinner-DFUoYvmm.js +2 -0
  201. package/dist/spinner-DFUoYvmm.js.map +1 -0
  202. package/dist/spinner-DULLiM6a.mjs +56 -0
  203. package/dist/spinner-DULLiM6a.mjs.map +1 -0
  204. package/dist/src/avatar/index.d.mts +2 -2
  205. package/dist/src/avatar/index.d.ts +2 -2
  206. package/dist/src/file-upload/index.d.mts +1 -1
  207. package/dist/src/file-upload/index.d.ts +1 -1
  208. package/dist/stepper/index.js +2 -2
  209. package/dist/stepper/index.js.map +1 -1
  210. package/dist/stepper/index.mjs +139 -176
  211. package/dist/stepper/index.mjs.map +1 -1
  212. package/dist/switch/index.js +2 -2
  213. package/dist/switch/index.js.map +1 -1
  214. package/dist/switch/index.mjs +194 -197
  215. package/dist/switch/index.mjs.map +1 -1
  216. package/dist/tabs/index.js +2 -2
  217. package/dist/tabs/index.js.map +1 -1
  218. package/dist/tabs/index.mjs +337 -389
  219. package/dist/tabs/index.mjs.map +1 -1
  220. package/dist/tag/index.js +2 -2
  221. package/dist/tag/index.js.map +1 -1
  222. package/dist/tag/index.mjs +192 -211
  223. package/dist/tag/index.mjs.map +1 -1
  224. package/dist/text-link/index.js +2 -2
  225. package/dist/text-link/index.js.map +1 -1
  226. package/dist/text-link/index.mjs +44 -5
  227. package/dist/text-link/index.mjs.map +1 -1
  228. package/dist/textarea/index.js +2 -2
  229. package/dist/textarea/index.js.map +1 -1
  230. package/dist/textarea/index.mjs +51 -50
  231. package/dist/textarea/index.mjs.map +1 -1
  232. package/dist/toast/index.js +2 -2
  233. package/dist/toast/index.js.map +1 -1
  234. package/dist/toast/index.mjs +314 -367
  235. package/dist/toast/index.mjs.map +1 -1
  236. package/dist/useRenderSlot-DP4fYerF.mjs +11 -0
  237. package/dist/useRenderSlot-DP4fYerF.mjs.map +1 -0
  238. package/dist/useRenderSlot-Xxf_s88b.js +2 -0
  239. package/dist/useRenderSlot-Xxf_s88b.js.map +1 -0
  240. package/dist/visually-hidden/index.js +2 -2
  241. package/dist/visually-hidden/index.js.map +1 -1
  242. package/dist/visually-hidden/index.mjs +25 -5
  243. package/dist/visually-hidden/index.mjs.map +1 -1
  244. package/package.json +4 -4
  245. package/dist/Button-1M9DcZl0.mjs +0 -704
  246. package/dist/Button-1M9DcZl0.mjs.map +0 -1
  247. package/dist/Button-FZceRWG2.js +0 -2
  248. package/dist/Button-FZceRWG2.js.map +0 -1
  249. package/dist/DialogContent.styles-CziMQtYr.js +0 -2
  250. package/dist/DialogContent.styles-CziMQtYr.js.map +0 -1
  251. package/dist/DialogContent.styles-Du7_Dkde.mjs +0 -60
  252. package/dist/DialogContent.styles-Du7_Dkde.mjs.map +0 -1
  253. package/dist/FormFieldRequiredIndicator-CHfcoT2y.js +0 -2
  254. package/dist/FormFieldRequiredIndicator-CHfcoT2y.js.map +0 -1
  255. package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs +0 -13
  256. package/dist/FormFieldRequiredIndicator-DTnCGiX2.mjs.map +0 -1
  257. package/dist/Icon-BO327oHU.mjs +0 -57
  258. package/dist/Icon-BO327oHU.mjs.map +0 -1
  259. package/dist/Icon-C-cNTnzd.js +0 -2
  260. package/dist/Icon-C-cNTnzd.js.map +0 -1
  261. package/dist/IconButton-BR1bJSQA.js +0 -2
  262. package/dist/IconButton-BR1bJSQA.js.map +0 -1
  263. package/dist/IconButton-DdB3Pq13.mjs +0 -43
  264. package/dist/IconButton-DdB3Pq13.mjs.map +0 -1
  265. package/dist/Slot-DLY1rJrG.mjs +0 -14
  266. package/dist/Slot-DLY1rJrG.mjs.map +0 -1
  267. package/dist/Slot-DQ8z2zsy.js +0 -2
  268. package/dist/Slot-DQ8z2zsy.js.map +0 -1
  269. package/dist/Spinner-Br4Rp9V2.js +0 -2
  270. package/dist/Spinner-Br4Rp9V2.js.map +0 -1
  271. package/dist/Spinner-Co3AjkQV.mjs +0 -68
  272. package/dist/Spinner-Co3AjkQV.mjs.map +0 -1
  273. package/dist/TextLink-5MvP0P8D.js +0 -2
  274. package/dist/TextLink-5MvP0P8D.js.map +0 -1
  275. package/dist/TextLink-Cc_LeVcx.mjs +0 -57
  276. package/dist/TextLink-Cc_LeVcx.mjs.map +0 -1
  277. package/dist/VisuallyHidden-CB6Nx76j.js +0 -2
  278. package/dist/VisuallyHidden-CB6Nx76j.js.map +0 -1
  279. package/dist/VisuallyHidden-DjlV0-CW.mjs +0 -28
  280. package/dist/VisuallyHidden-DjlV0-CW.mjs.map +0 -1
  281. package/dist/button/index.js.map +0 -1
  282. package/dist/button/index.mjs.map +0 -1
  283. package/dist/form-field/index.js.map +0 -1
  284. package/dist/form-field/index.mjs.map +0 -1
  285. package/dist/icon/index.js.map +0 -1
  286. package/dist/icon/index.mjs.map +0 -1
  287. package/dist/icon-button/index.js.map +0 -1
  288. package/dist/icon-button/index.mjs.map +0 -1
  289. package/dist/input/index.js.map +0 -1
  290. package/dist/input/index.mjs.map +0 -1
  291. package/dist/label/index.js.map +0 -1
  292. package/dist/label/index.mjs.map +0 -1
  293. package/dist/popover/index.js.map +0 -1
  294. package/dist/popover/index.mjs.map +0 -1
  295. package/dist/progress/index.js.map +0 -1
  296. package/dist/progress/index.mjs.map +0 -1
  297. package/dist/spinner/index.js.map +0 -1
  298. package/dist/spinner/index.mjs.map +0 -1
  299. package/dist/useRenderSlot-Bta2kdp4.mjs +0 -10
  300. package/dist/useRenderSlot-Bta2kdp4.mjs.map +0 -1
  301. package/dist/useRenderSlot-DATwjgpo.js +0 -2
  302. package/dist/useRenderSlot-DATwjgpo.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-lg px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"names":["findElement","children","name","Children","isValidElement","child","getElementDisplayName","element","getOrderedItems","result","childProps","getItemsFromChildren","newMap","itemData","SelectContext","createContext","ID_PREFIX","SelectProvider","defaultValue","valueProp","onValueChange","disabledProp","readOnlyProp","stateProp","itemsComponent","nameProp","requiredProp","value","setValue","useCombinedState","placeholder","setPlaceholder","useState","itemsMap","setItemsMap","ariaLabel","setAriaLabel","firstItem","selectedItem","isControlled","field","useFormFieldControl","state","internalFieldID","useId","fieldId","fieldLabelId","disabled","readOnly","required","useEffect","previousItems","newItems","item","index","hasUpdatedValue","hasUpdatedText","jsx","useSelectContext","context","useContext","Select","props","finder","trigger","items","SelectGroupContext","SelectGroupProvider","groupLabel","setGroupLabel","useSelectGroupContext","Group","forwardedRef","GroupContent","className","cx","Item","styles","cva","Items","ref","rest","handleChange","event","Label","LeadingIcon","Icon","Placeholder","Trigger","jsxs","ArrowHorizontalDown","Value","customPlaceholder","isPlaceholderSelected","valuePlaceholder","Root"],"mappings":";;;;;;;AAKO,MAAMA,KAAc,CAACC,MAAwB,CAACC,MAC7BC,EAAS,QAAQF,CAAQ,EAAE,OAAOG,CAAc,EAEjD,KAAK,CAAAC,MACjBC,EAAsBD,CAAK,GAAG,SAASH,CAAI,CACnD,GAGGI,IAAwB,CAACC,MACtBA,IAAWA,EAAQ,KAAuC,cAAc,IAG3EC,IAAkB,CAACP,GAAqBQ,IAAuB,QACnEN,EAAS,QAAQF,GAAU,CAAAI,MAAS;AAClC,MAAKD,EAAeC,CAAK,GAEzB;AAAA,QACEC,EAAsBD,CAAK,MAAM,iBAC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AQ,CAAC;AAAA,EACpB,UAAA1F;AAAA,EACA,WAAAyE;AAAA,EACA,aAAakB;AAAA,EACb,KAAKpB;AACP,MAAkB;AAChB,QAAM,EAAE,cAAAlC,GAAc,aAAAR,GAAa,UAAAiB,EAAA,IAAaW,EAAA,GAE1CmC,IAAwBvD,GAAc,SAAS,MAC/CwD,IAAmBF,KAAqB9D;AAE9C,SACE,gBAAA2B;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,wBAAqB;AAAA,MACrB,KAAKe;AAAA,MACL,WAAWG,EAAG,sCAAsCD,CAAS;AAAA,MAE7D,UAAA,gBAAAjB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWkB;AAAA,YACT;AAAA,YACAkB,KAAyB,CAAC9C,KAAY;AAAA,UAAA;AAAA,UAGvC,UAAA8C,IAAwBC,IAAmB7F,KAAYqC,GAAc;AAAA,QAAA;AAAA,MAAA;AAAA,IACxE;AAAA,EAAA;AAGN;AAEAqD,EAAM,cAAc;ACjCb,MAAM9B,KAST,OAAO,OAAOkC,GAAM;AAAA,EACtB,OAAAxB;AAAA,EACA,MAAAK;AAAA,EACA,OAAAG;AAAA,EACA,aAAAQ;AAAA,EACA,OAAAH;AAAA,EACA,SAAAI;AAAA,EACA,OAAAG;AAAA,EACA,aAAAN;AACF,CAAC;AAEDxB,GAAO,cAAc;AACrBU,EAAM,cAAc;AACpBQ,EAAM,cAAc;AACpBH,EAAK,cAAc;AACnBW,EAAY,cAAc;AAC1BH,EAAM,cAAc;AACpBI,EAAQ,cAAc;AACtBG,EAAM,cAAc;AACpBN,EAAY,cAAc;"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/select/utils.ts","../../src/select/SelectContext.tsx","../../src/select/Select.tsx","../../src/select/SelectItemsGroupContext.tsx","../../src/select/SelectGroup.tsx","../../src/select/SelectItem.tsx","../../src/select/SelectItems.tsx","../../src/select/SelectLabel.tsx","../../src/select/SelectLeadingIcon.tsx","../../src/select/SelectPlaceholder.tsx","../../src/select/SelectTrigger.styles.tsx","../../src/select/SelectTrigger.tsx","../../src/select/SelectValue.tsx","../../src/select/index.ts"],"sourcesContent":["import { Children, type FC, isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport { type ItemProps } from './SelectItem'\nimport { type ItemsMap, type SelectItem } from './types'\n\nexport const findElement = (children: ReactNode) => (name: string) => {\n const validChildren = Children.toArray(children).filter(isValidElement)\n\n return validChildren.find(child => {\n return getElementDisplayName(child)?.includes(name)\n })\n}\n\nconst getElementDisplayName = (element?: ReactElement) => {\n return element ? (element.type as FC & { displayName?: string }).displayName : ''\n}\n\nconst getOrderedItems = (children: ReactNode, result: SelectItem[] = []): SelectItem[] => {\n Children.forEach(children, child => {\n if (!isValidElement(child)) return\n\n if (\n getElementDisplayName(child) === 'Select.Item' ||\n getElementDisplayName(child) === 'Select.Placeholder'\n ) {\n const childProps = child.props as ItemProps\n result.push({\n value: childProps.value,\n disabled: !!childProps.disabled,\n text: childProps.children,\n })\n }\n\n if ((child.props as { children: ReactNode }).children) {\n getOrderedItems((child.props as { children: ReactNode }).children, result)\n }\n })\n\n return result\n}\n\nexport const getItemsFromChildren = (children: ReactNode): ItemsMap => {\n const newMap: ItemsMap = new Map()\n\n getOrderedItems(children).forEach(itemData => {\n newMap.set(itemData.value, itemData)\n })\n\n return newMap\n}\n","import { useFormFieldControl } from '@spark-ui/components/form-field'\nimport { useCombinedState } from '@spark-ui/hooks/use-combined-state'\nimport {\n createContext,\n Dispatch,\n PropsWithChildren,\n ReactElement,\n SetStateAction,\n useContext,\n useEffect,\n useId,\n useState,\n} from 'react'\n\nimport { type ItemsMap, SelectItem } from './types'\nimport { getItemsFromChildren } from './utils'\n\nexport interface SelectContextState {\n itemsMap: ItemsMap\n disabled: boolean\n readOnly: boolean\n state?: 'error' | 'alert' | 'success'\n itemsComponent: ReactElement | undefined\n selectedItem: SelectItem | undefined\n setValue: (value: string) => void\n isControlled: boolean\n onValueChange?: (value: string) => void\n ariaLabel: string | undefined\n setAriaLabel: Dispatch<SetStateAction<string | undefined>>\n fieldId: string\n fieldLabelId: string | undefined\n name: string | undefined\n required: boolean\n placeholder: string | undefined\n setPlaceholder: Dispatch<SetStateAction<string | undefined>>\n}\n\nexport type SelectContextProps = PropsWithChildren<{\n /**\n * Use `state` prop to assign a specific state to the select, choosing from: `error`, `alert` and `success`. By doing so, the outline styles will be updated.\n */\n state?: 'error' | 'alert' | 'success'\n /**\n * When true, prevents the user from interacting with the select.\n */\n disabled?: boolean\n /**\n * Sets the select as interactive or not.\n */\n readOnly?: boolean\n /**\n * The value of the select when initially rendered. Use when you do not need to control the state of the select.\n */\n defaultValue?: string\n /**\n * The controlled value of the select. Should be used in conjunction with `onValueChange`.\n */\n value?: string\n /**\n * Event handler called when the value changes.\n */\n onValueChange?: (value: string) => void\n\n itemsComponent: ReactElement | undefined\n /**\n * This attribute is used to specify the name of the control.\n * If wrapped with a FormField with a name, will be inherited from it.\n */\n name?: string\n /**\n * A Boolean attribute indicating that an option with a non-empty string value must be selected.\n */\n required?: boolean\n}>\n\nconst SelectContext = createContext<SelectContextState | null>(null)\n\nconst ID_PREFIX = ':select'\n\nexport const SelectProvider = ({\n children,\n defaultValue,\n value: valueProp,\n onValueChange,\n disabled: disabledProp = false,\n readOnly: readOnlyProp = false,\n state: stateProp,\n itemsComponent,\n name: nameProp,\n required: requiredProp,\n}: SelectContextProps) => {\n const [value, setValue] = useCombinedState(valueProp, defaultValue, onValueChange)\n const [placeholder, setPlaceholder] = useState<string | undefined>(undefined)\n const [itemsMap, setItemsMap] = useState<ItemsMap>(getItemsFromChildren(itemsComponent))\n const [ariaLabel, setAriaLabel] = useState<string>()\n\n // Computed state\n const firstItem = itemsMap.entries().next()?.value?.[1]\n const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem\n const isControlled = valueProp != null\n\n // Derivated from FormField context\n const field = useFormFieldControl()\n const state = field.state || stateProp\n\n const internalFieldID = `${ID_PREFIX}-field-${useId()}`\n const fieldId = field.id || internalFieldID\n const fieldLabelId = field.labelId\n const disabled = field.disabled ?? disabledProp\n const readOnly = field.readOnly ?? readOnlyProp\n const name = field.name ?? nameProp\n const required = !!(field.isRequired ?? requiredProp)\n\n /**\n * Indices in a Map are set when an element is added to the Map.\n * If for some reason, in the Select:\n * - items order changes\n * - items are added\n * - items are removed\n *\n * The Map must be rebuilt from the new children in order to preserve logical indices.\n *\n */\n useEffect(() => {\n const newMap = getItemsFromChildren(itemsComponent)\n\n const previousItems = [...itemsMap.values()]\n const newItems = [...newMap.values()]\n\n const hasItemsChanges =\n previousItems.length !== newItems.length ||\n previousItems.some((item, index) => {\n const hasUpdatedValue = item.value !== newItems[index]?.value\n const hasUpdatedText = item.text !== newItems[index]?.text\n\n return hasUpdatedValue || hasUpdatedText\n })\n\n if (hasItemsChanges) {\n setItemsMap(newMap)\n }\n }, [children])\n\n return (\n <SelectContext.Provider\n value={{\n disabled,\n readOnly,\n itemsMap,\n state,\n itemsComponent,\n selectedItem,\n setValue,\n isControlled,\n onValueChange,\n ariaLabel,\n setAriaLabel,\n fieldId,\n fieldLabelId,\n name,\n required,\n placeholder,\n setPlaceholder,\n }}\n >\n {children}\n </SelectContext.Provider>\n )\n}\n\nexport const useSelectContext = () => {\n const context = useContext(SelectContext)\n\n if (!context) {\n throw Error('useSelectContext must be used within a Select provider')\n }\n\n return context\n}\n","import { type SelectContextProps, SelectProvider } from './SelectContext'\nimport { findElement } from './utils'\n\nexport type SelectProps = Omit<SelectContextProps, 'itemsComponent'>\n\nexport const Select = ({ children, ...props }: SelectProps) => {\n const finder = findElement(children)\n const trigger = finder('Trigger')\n const items = finder('Items')\n\n return (\n <SelectProvider {...props} itemsComponent={items}>\n {trigger}\n </SelectProvider>\n )\n}\n\nSelect.displayName = 'Select'\n","import { createContext, type PropsWithChildren, useContext, useState } from 'react'\n\nexport interface SelectContextState {\n groupLabel: string\n setGroupLabel: (label: string) => void\n}\n\ntype SelectContextProps = PropsWithChildren\n\nconst SelectGroupContext = createContext<SelectContextState | null>(null)\n\nexport const SelectGroupProvider = ({ children }: SelectContextProps) => {\n const [groupLabel, setGroupLabel] = useState('')\n\n return (\n <SelectGroupContext.Provider value={{ groupLabel, setGroupLabel }}>\n {children}\n </SelectGroupContext.Provider>\n )\n}\n\nexport const useSelectGroupContext = () => {\n const context = useContext(SelectGroupContext)\n\n if (!context) {\n throw Error('useSelectGroupContext must be used within a SelectGroup provider')\n }\n\n return context\n}\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { SelectGroupProvider, useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface GroupProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLOptGroupElement>\n}\n\nexport const Group = ({ children, ref: forwardedRef, ...props }: GroupProps) => {\n return (\n <SelectGroupProvider>\n <GroupContent ref={forwardedRef} {...props}>\n {children}\n </GroupContent>\n </SelectGroupProvider>\n )\n}\n\nconst GroupContent = ({ children, className, ref: forwardedRef }: GroupProps) => {\n const { groupLabel } = useSelectGroupContext()\n\n return (\n <optgroup\n data-spark-component=\"select-group\"\n ref={forwardedRef}\n className={cx(className)}\n label={groupLabel}\n >\n {children}\n </optgroup>\n )\n}\n\nGroup.displayName = 'Select.Group'\n","import { type Ref } from 'react'\n\nexport interface ItemProps {\n disabled?: boolean\n value: string\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Item = ({ disabled = false, value, children, ref: forwardedRef }: ItemProps) => {\n return (\n <option\n data-spark-component=\"select-item\"\n ref={forwardedRef}\n key={value}\n value={value}\n disabled={disabled}\n // label\n >\n {children}\n </option>\n )\n}\n\nItem.displayName = 'Select.Item'\n","import { cva } from 'class-variance-authority'\nimport { ChangeEvent, ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport const styles = cva(\n [\n 'absolute left-0 top-0 size-full rounded-lg opacity-0',\n 'min-h-sz-44',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus:ring-2',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline focus:ring-outline-high',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n true: 'cursor-not-allowed',\n },\n readOnly: {\n true: 'cursor-default',\n },\n },\n compoundVariants: [\n {\n disabled: false,\n state: undefined,\n class: 'hover:ring-outline-high',\n },\n ],\n }\n)\n\nexport const Items = ({\n children,\n className,\n ref,\n ...rest\n}: PropsWithChildren<ComponentPropsWithRef<'select'>>) => {\n const {\n state,\n disabled,\n readOnly,\n ariaLabel,\n fieldLabelId,\n isControlled,\n onValueChange,\n selectedItem,\n setValue,\n name,\n required,\n fieldId,\n } = useSelectContext()\n\n const handleChange = (event: ChangeEvent<HTMLSelectElement>) => {\n if (isControlled) {\n event.preventDefault()\n onValueChange?.(event.target.value)\n } else {\n setValue(event.target.value)\n }\n }\n\n return (\n <select\n data-spark-component=\"select-items\"\n ref={ref}\n disabled={disabled || readOnly}\n name={name}\n required={required}\n aria-labelledby={fieldLabelId}\n {...(ariaLabel && { 'aria-label': ariaLabel })}\n className={styles({ className, state, disabled, readOnly })}\n value={selectedItem?.value}\n onChange={handleChange}\n id={fieldId}\n {...rest}\n >\n {children}\n </select>\n )\n}\n\nItems.displayName = 'Select.Items'\n","import { useEffect } from 'react'\n\nimport { useSelectGroupContext } from './SelectItemsGroupContext'\n\ninterface LabelProps {\n children: string\n}\n\nexport const Label = ({ children }: LabelProps) => {\n const { setGroupLabel } = useSelectGroupContext()\n\n useEffect(() => {\n setGroupLabel(children)\n }, [children])\n\n return null\n}\n\nLabel.displayName = 'Select.Label'\n","import { ReactElement } from 'react'\n\nimport { Icon } from '../icon'\n\nexport const LeadingIcon = ({ children }: { children: ReactElement }) => {\n return (\n <Icon size={'sm'} className=\"shrink-0\">\n {children}\n </Icon>\n )\n}\n\nLeadingIcon.displayName = 'Select.LeadingIcon'\n","import { type Ref, useEffect } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface PlaceholderProps {\n disabled?: boolean\n children: string\n ref?: Ref<HTMLOptionElement>\n}\n\nexport const Placeholder = ({\n disabled = false,\n children,\n ref: forwardedRef,\n}: PlaceholderProps) => {\n const { setPlaceholder } = useSelectContext()\n\n useEffect(() => {\n setPlaceholder(children)\n }, [children])\n\n return (\n <option\n data-spark-component=\"select-placeholder\"\n ref={forwardedRef}\n key=\"placeholder\"\n value=\"\"\n disabled={disabled}\n >\n {children}\n </option>\n )\n}\n\nPlaceholder.displayName = 'Select.Placeholder'\n","import { cva } from 'class-variance-authority'\n\nexport const styles = cva(\n [\n 'relative flex w-full items-center justify-between',\n 'min-h-sz-44 rounded-lg px-lg',\n 'text-body-1',\n // outline styles\n 'ring-1 outline-hidden ring-inset focus-within:ring-focus',\n ],\n {\n variants: {\n state: {\n undefined: 'ring-outline',\n error: 'ring-error',\n alert: 'ring-alert',\n success: 'ring-success',\n },\n disabled: {\n false: 'focus-within:ring-2',\n },\n readOnly: {\n true: '',\n },\n },\n compoundVariants: [\n {\n readOnly: false,\n disabled: false,\n class: 'bg-surface text-on-surface',\n },\n {\n readOnly: true,\n class: 'bg-on-surface/dim-5 text-on-surface cursor-default',\n },\n {\n disabled: true,\n class: ['bg-on-surface/dim-5 text-on-surface/dim-3', 'cursor-not-allowed'],\n },\n {\n disabled: false,\n state: undefined,\n class: 'default:hover:ring-outline-high',\n },\n ],\n }\n)\n","import { ArrowHorizontalDown } from '@spark-ui/icons/ArrowHorizontalDown'\nimport { ReactNode, type Ref, useEffect } from 'react'\n\nimport { Icon } from '../icon'\nimport { useSelectContext } from './SelectContext'\nimport { styles } from './SelectTrigger.styles'\n\ninterface TriggerProps {\n 'aria-label'?: string\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * This trigger acts as a fake button for the `select` tag.\n * It is not interactive.\n */\nexport const Trigger = ({\n 'aria-label': ariaLabel,\n children,\n className,\n ref: forwardedRef,\n}: TriggerProps) => {\n const { disabled, readOnly, state, setAriaLabel, itemsComponent } = useSelectContext()\n\n useEffect(() => {\n if (ariaLabel) {\n setAriaLabel(ariaLabel)\n }\n }, [ariaLabel])\n\n return (\n <div\n data-spark-component=\"select-trigger\"\n ref={forwardedRef}\n className={styles({ className, state, disabled, readOnly })}\n >\n <span className=\"gap-md flex items-center justify-start\">{children}</span>\n\n <Icon className=\"ml-md shrink-0\" size=\"sm\">\n <ArrowHorizontalDown />\n </Icon>\n\n {itemsComponent}\n </div>\n )\n}\n\nTrigger.displayName = 'Select.Trigger'\n","import { cx } from 'class-variance-authority'\nimport { ReactNode, type Ref } from 'react'\n\nimport { useSelectContext } from './SelectContext'\n\nexport interface ValueProps {\n children?: ReactNode\n className?: string\n /**\n * Optional placeholder value for the trigger.\n * If not specified, the value inside `Select.Placeholder` item will be used.\n */\n placeholder?: string\n ref?: Ref<HTMLSpanElement>\n}\n\nexport const Value = ({\n children,\n className,\n placeholder: customPlaceholder,\n ref: forwardedRef,\n}: ValueProps) => {\n const { selectedItem, placeholder, disabled } = useSelectContext()\n\n const isPlaceholderSelected = selectedItem?.value == null\n const valuePlaceholder = customPlaceholder || placeholder\n\n return (\n <span\n role=\"presentation\"\n data-spark-component=\"select-value\"\n ref={forwardedRef}\n className={cx('flex shrink items-center text-left', className)}\n >\n <span\n className={cx(\n 'line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis',\n isPlaceholderSelected && !disabled && 'text-on-surface/dim-1'\n )}\n >\n {isPlaceholderSelected ? valuePlaceholder : children || selectedItem?.text}\n </span>\n </span>\n )\n}\n\nValue.displayName = 'Select.Value'\n","import { Select as Root } from './Select'\nimport { SelectProvider, useSelectContext } from './SelectContext'\nimport { Group } from './SelectGroup'\nimport { Item } from './SelectItem'\nimport { Items } from './SelectItems'\nimport { Label } from './SelectLabel'\nimport { LeadingIcon } from './SelectLeadingIcon'\nimport { Placeholder } from './SelectPlaceholder'\nimport { Trigger } from './SelectTrigger'\nimport { Value } from './SelectValue'\n\nexport { useSelectContext, SelectProvider }\n\nexport const Select: typeof Root & {\n Group: typeof Group\n Item: typeof Item\n Items: typeof Items\n Placeholder: typeof Placeholder\n Label: typeof Label\n Trigger: typeof Trigger\n Value: typeof Value\n LeadingIcon: typeof LeadingIcon\n} = Object.assign(Root, {\n Group,\n Item,\n Items,\n Placeholder,\n Label,\n Trigger,\n Value,\n LeadingIcon,\n})\n\nSelect.displayName = 'Select'\nGroup.displayName = 'Select.Group'\nItems.displayName = 'Select.Items'\nItem.displayName = 'Select.Item'\nPlaceholder.displayName = 'Select.Placeholder'\nLabel.displayName = 'Select.Label'\nTrigger.displayName = 'Select.Trigger'\nValue.displayName = 'Select.Value'\nLeadingIcon.displayName = 'Select.LeadingIcon'\n"],"mappings":";;;;;;;;AAKA,IAAa,KAAe,OAAyB,MAC7B,EAAS,QAAQ,EAAS,CAAC,OAAO,EAAe,CAElD,MAAK,MACjB,EAAsB,EAAM,EAAE,SAAS,EAAK,CACnD,EAGE,KAAyB,MACtB,IAAW,EAAQ,KAAuC,cAAc,IAG3E,KAAmB,GAAqB,IAAuB,EAAE,MACrE,EAAS,QAAQ,IAAU,MAAS;AAC7B,OAAe,EAAM,EAE1B;MACE,EAAsB,EAAM,KAAK,iBACjC,EAAsB,EAAM,KAAK,sBACjC;GACA,IAAM,IAAa,EAAM;AACzB,KAAO,KAAK;IACV,OAAO,EAAW;IAClB,UAAU,CAAC,CAAC,EAAW;IACvB,MAAM,EAAW;IAClB,CAAC;;AAGJ,EAAK,EAAM,MAAkC,YAC3C,EAAiB,EAAM,MAAkC,UAAU,EAAO;;EAE5E,EAEK,IAGI,KAAwB,MAAkC;CACrE,IAAM,oBAAmB,IAAI,KAAK;AAMlC,QAJA,EAAgB,EAAS,CAAC,SAAQ,MAAY;AAC5C,IAAO,IAAI,EAAS,OAAO,EAAS;GACpC,EAEK;GC2BH,IAAgB,EAAyC,KAAK,EAE9D,IAAY,WAEL,KAAkB,EAC7B,aACA,iBACA,OAAO,GACP,kBACA,UAAU,IAAe,IACz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AAY,cAAc,sBAC1B,EAAM,cAAc,gBACpB,EAAQ,cAAc,kBACtB,EAAM,cAAc,gBACpB,EAAY,cAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),h=require("../VisuallyHidden-CB6Nx76j.js"),r=require("class-variance-authority"),S=r.cva([],{variants:{isAnimated:{true:["[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]","[mask-size:200%_100%]","animate-standalone-shimmer motion-reduce:animate-none!"],false:[]}},defaultVariants:{isAnimated:!0}}),p=({isAnimated:e=!0,label:a,className:t,children:n,ref:s,...g})=>l.jsxs("div",{ref:s,"data-spark-component":"skeleton",role:"presentation",className:S({isAnimated:e,className:t}),...g,children:[n,a&&l.jsx(h.VisuallyHidden,{children:a})]});p.displayName="Skeleton";const y=r.cva(["bg-neutral/dim-4","min-h-lg min-w-lg"],{variants:{shape:{line:["w-full [&:last-child:not(:first-child)]:w-5/6","rounded-lg"],rectangle:["rounded-sm"],circle:["flex-none","rounded-full"]}},defaultVariants:{shape:"rectangle"}}),f=r.cva(["flex flex-col","w-full"],{variants:{gap:{sm:"gap-sm",md:"gap-md",lg:"gap-lg",xl:"gap-xl","2xl":"gap-2xl","3xl":"gap-3xl"}},defaultVariants:{gap:"md"}}),i=e=>typeof e=="number"?`${e}px`:e,c=({shape:e,className:a,ref:t,...n})=>l.jsx("div",{ref:t,"aria-hidden":"true",className:y({shape:e,className:a}),...n}),o=({width:e="100%",height:a,...t})=>l.jsx(c,{style:{"--skeleton-rect-width":i(e),"--skeleton-rect-height":i(a)},className:"h-(--skeleton-rect-height) w-(--skeleton-rect-width)",...t,shape:"rectangle","data-shape":"rectangle"}),d=({size:e,...a})=>l.jsx(c,{style:{"--skeleton-circle-size":i(e)},className:"size-(--skeleton-circle-size)",...a,shape:"circle","data-shape":"circle"}),m=({lines:e=1,gap:a,className:t,...n})=>{const s=a||"md";return l.jsx("div",{className:f({gap:s,className:t}),"aria-hidden":"true",children:[...new Array(e)].map((g,k)=>l.jsx(c,{...n,shape:"line","data-shape":"line"},`line_${k}`))})};o.displayName="Skeleton.Rectangle";d.displayName="Skeleton.Circle";m.displayName="Skeleton.Line";const u=Object.assign(p,{Circle:d,Line:m,Rectangle:o});u.displayName="Skeleton";m.displayName="Skeleton.Line";d.displayName="Skeleton.Circle";o.displayName="Skeleton.Rectangle";exports.Skeleton=u;
2
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../visually-hidden/index.js`);let t=require(`class-variance-authority`),n=require(`react/jsx-runtime`);var r=(0,t.cva)([],{variants:{isAnimated:{true:[`[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]`,`[mask-size:200%_100%]`,`animate-standalone-shimmer motion-reduce:animate-none!`],false:[]}},defaultVariants:{isAnimated:!0}}),i=({isAnimated:t=!0,label:i,className:a,children:o,ref:s,...c})=>(0,n.jsxs)(`div`,{ref:s,"data-spark-component":`skeleton`,role:`presentation`,className:r({isAnimated:t,className:a}),...c,children:[o,i&&(0,n.jsx)(e.VisuallyHidden,{children:i})]});i.displayName=`Skeleton`;var a=(0,t.cva)([`bg-neutral/dim-4`,`min-h-lg min-w-lg`],{variants:{shape:{line:[`w-full [&:last-child:not(:first-child)]:w-5/6`,`rounded-lg`],rectangle:[`rounded-sm`],circle:[`flex-none`,`rounded-full`]}},defaultVariants:{shape:`rectangle`}}),o=(0,t.cva)([`flex flex-col`,`w-full`],{variants:{gap:{sm:`gap-sm`,md:`gap-md`,lg:`gap-lg`,xl:`gap-xl`,"2xl":`gap-2xl`,"3xl":`gap-3xl`}},defaultVariants:{gap:`md`}}),s=e=>typeof e==`number`?`${e}px`:e,c=({shape:e,className:t,ref:r,...i})=>(0,n.jsx)(`div`,{ref:r,"aria-hidden":`true`,className:a({shape:e,className:t}),...i}),l=({width:e=`100%`,height:t,...r})=>(0,n.jsx)(c,{style:{"--skeleton-rect-width":s(e),"--skeleton-rect-height":s(t)},className:`h-(--skeleton-rect-height) w-(--skeleton-rect-width)`,...r,shape:`rectangle`,"data-shape":`rectangle`}),u=({size:e,...t})=>(0,n.jsx)(c,{style:{"--skeleton-circle-size":s(e)},className:`size-(--skeleton-circle-size)`,...t,shape:`circle`,"data-shape":`circle`}),d=({lines:e=1,gap:t,className:r,...i})=>(0,n.jsx)(`div`,{className:o({gap:t||`md`,className:r}),"aria-hidden":`true`,children:[...Array(e)].map((e,t)=>(0,n.jsx)(c,{...i,shape:`line`,"data-shape":`line`},`line_${t}`))});l.displayName=`Skeleton.Rectangle`,u.displayName=`Skeleton.Circle`,d.displayName=`Skeleton.Line`;var f=Object.assign(i,{Circle:u,Line:d,Rectangle:l});f.displayName=`Skeleton`,d.displayName=`Skeleton.Line`,u.displayName=`Skeleton.Circle`,l.displayName=`Skeleton.Rectangle`,exports.Skeleton=f;
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/skeleton/Skeleton.styles.ts","../../src/skeleton/Skeleton.tsx","../../src/skeleton/SkeletonItem.styles.ts","../../src/skeleton/SkeletonItem.tsx","../../src/skeleton/index.ts"],"sourcesContent":["import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonStyles = cva([], {\n variants: {\n isAnimated: {\n true: [\n '[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]',\n '[mask-size:200%_100%]',\n 'animate-standalone-shimmer motion-reduce:animate-none!',\n ],\n false: [],\n },\n },\n defaultVariants: {\n isAnimated: true,\n },\n})\n\nexport type SkeletonStyleProps = ExcludeNull<VariantProps<typeof skeletonStyles>>\n","import { ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { VisuallyHidden } from '../visually-hidden'\nimport { type SkeletonStyleProps, skeletonStyles } from './Skeleton.styles'\n\nexport interface SkeletonProps extends ComponentPropsWithRef<'div'>, SkeletonStyleProps {\n /**\n * Displays an animated light effect.\n * @default true\n */\n isAnimated?: boolean\n /**\n * Adds an accessible fallback label.\n */\n label?: string\n}\n\nexport const Skeleton = ({\n isAnimated = true,\n label,\n className,\n children,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<SkeletonProps>) => (\n <div\n ref={forwardedRef}\n data-spark-component=\"skeleton\"\n role=\"presentation\"\n className={skeletonStyles({ isAnimated, className })}\n {...rest}\n >\n {children}\n\n {label && <VisuallyHidden>{label}</VisuallyHidden>}\n </div>\n)\n\nSkeleton.displayName = 'Skeleton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], {\n variants: {\n shape: {\n line: ['w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'],\n rectangle: ['rounded-sm'],\n circle: ['flex-none', 'rounded-full'],\n },\n },\n defaultVariants: {\n shape: 'rectangle',\n },\n})\n\nexport const skeletonLineStyles = cva(['flex flex-col', 'w-full'], {\n variants: {\n gap: {\n sm: 'gap-sm',\n md: 'gap-md',\n lg: 'gap-lg',\n xl: 'gap-xl',\n '2xl': 'gap-2xl',\n '3xl': 'gap-3xl',\n },\n },\n defaultVariants: {\n gap: 'md',\n },\n})\n\nexport type SkeletonItemStyleProps = ExcludeNull<VariantProps<typeof skeletonItemStyles>>\n","import { ComponentPropsWithRef, CSSProperties } from 'react'\n\nimport {\n type SkeletonItemStyleProps,\n skeletonItemStyles,\n skeletonLineStyles,\n} from './SkeletonItem.styles'\n\ninterface SkeletonItemProps extends ComponentPropsWithRef<'div'>, SkeletonItemStyleProps {}\n\nexport type SkeletonRectangleProps = Omit<SkeletonItemProps, 'shape'> & {\n width?: string | number\n height?: string | number\n}\nexport type SkeletonCircleProps = Omit<SkeletonItemProps, 'shape'> & { size: string | number }\nexport type SkeletonLineProps = Omit<SkeletonItemProps, 'shape'> & {\n lines?: number\n /**\n * Sets the gaps between group items.\n */\n gap?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'\n}\n\nconst getSizeValue = (size?: number | string): string | undefined => {\n if (typeof size === 'number') return `${size}px`\n\n return size\n}\n\nconst SkeletonItem = ({ shape, className, ref: forwardedRef, ...rest }: SkeletonItemProps) => {\n return (\n <div\n ref={forwardedRef}\n aria-hidden=\"true\"\n className={skeletonItemStyles({ shape, className })}\n {...rest}\n />\n )\n}\n\nexport const SkeletonRectangle = ({ width = '100%', height, ...rest }: SkeletonRectangleProps) => {\n return (\n <SkeletonItem\n style={\n {\n '--skeleton-rect-width': getSizeValue(width),\n '--skeleton-rect-height': getSizeValue(height),\n } as CSSProperties\n }\n className=\"h-(--skeleton-rect-height) w-(--skeleton-rect-width)\"\n {...rest}\n shape=\"rectangle\"\n data-shape=\"rectangle\"\n />\n )\n}\n\nexport const SkeletonCircle = ({ size, ...rest }: SkeletonCircleProps) => (\n <SkeletonItem\n style={{ '--skeleton-circle-size': getSizeValue(size) } as CSSProperties}\n className=\"size-(--skeleton-circle-size)\"\n {...rest}\n shape=\"circle\"\n data-shape=\"circle\"\n />\n)\n\nexport const SkeletonLine = ({\n lines = 1,\n gap: gapProp,\n className,\n ...rest\n}: SkeletonLineProps) => {\n const gap = gapProp || 'md'\n\n return (\n <div className={skeletonLineStyles({ gap, className })} aria-hidden=\"true\">\n {[...new Array(lines)].map((_, index) => (\n <SkeletonItem key={`line_${index}`} {...rest} shape=\"line\" data-shape=\"line\" />\n ))}\n </div>\n )\n}\n\nSkeletonRectangle.displayName = 'Skeleton.Rectangle'\nSkeletonCircle.displayName = 'Skeleton.Circle'\nSkeletonLine.displayName = 'Skeleton.Line'\n","import { Skeleton as Root } from './Skeleton'\nimport {\n SkeletonCircle as Circle,\n SkeletonLine as Line,\n SkeletonRectangle as Rectangle,\n} from './SkeletonItem'\n\nexport const Skeleton: typeof Root & {\n Circle: typeof Circle\n Line: typeof Line\n Rectangle: typeof Rectangle\n} = Object.assign(Root, {\n Circle,\n Line,\n Rectangle,\n})\n\nSkeleton.displayName = 'Skeleton'\nLine.displayName = 'Skeleton.Line'\nCircle.displayName = 'Skeleton.Circle'\nRectangle.displayName = 'Skeleton.Rectangle'\n\nexport type { SkeletonProps } from './Skeleton'\n"],"names":["skeletonStyles","cva","Skeleton","isAnimated","label","className","children","forwardedRef","rest","jsxs","jsx","VisuallyHidden","skeletonItemStyles","skeletonLineStyles","getSizeValue","size","SkeletonItem","shape","SkeletonRectangle","width","height","SkeletonCircle","SkeletonLine","lines","gapProp","gap","_","index","Root","Circle","Line","Rectangle"],"mappings":"sMAEaA,EAAiBC,EAAAA,IAAI,GAAI,CACpC,SAAU,CACR,WAAY,CACV,KAAM,CACJ,4EACA,wBACA,wDAAA,EAEF,MAAO,CAAA,CAAC,CACV,EAEF,gBAAiB,CACf,WAAY,EAAA,CAEhB,CAAC,ECCYC,EAAW,CAAC,CACvB,WAAAC,EAAa,GACb,MAAAC,EACA,UAAAC,EACA,SAAAC,EACA,IAAKC,EACL,GAAGC,CACL,IACEC,EAAAA,KAAC,MAAA,CACC,IAAKF,EACL,uBAAqB,WACrB,KAAK,eACL,UAAWP,EAAe,CAAE,WAAAG,EAAY,UAAAE,EAAW,EAClD,GAAGG,EAEH,SAAA,CAAAF,EAEAF,GAASM,EAAAA,IAACC,EAAAA,eAAA,CAAgB,SAAAP,CAAA,CAAM,CAAA,CAAA,CACnC,EAGFF,EAAS,YAAc,WCpChB,MAAMU,EAAqBX,EAAAA,IAAI,CAAC,mBAAoB,mBAAmB,EAAG,CAC/E,SAAU,CACR,MAAO,CACL,KAAM,CAAC,gDAAiD,YAAY,EACpE,UAAW,CAAC,YAAY,EACxB,OAAQ,CAAC,YAAa,cAAc,CAAA,CACtC,EAEF,gBAAiB,CACf,MAAO,WAAA,CAEX,CAAC,EAEYY,EAAqBZ,EAAAA,IAAI,CAAC,gBAAiB,QAAQ,EAAG,CACjE,SAAU,CACR,IAAK,CACH,GAAI,SACJ,GAA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c,kBAC7BC,EAAa,YAAc,gBC/EpB,MAAMpB,EAIT,OAAO,OAAO0B,EAAM,CAAA,OACtBC,EAAA,KACAC,EAAA,UACAC,CACF,CAAC,EAED7B,EAAS,YAAc,WACvB4B,EAAK,YAAc,gBACnBD,EAAO,YAAc,kBACrBE,EAAU,YAAc"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/skeleton/Skeleton.styles.ts","../../src/skeleton/Skeleton.tsx","../../src/skeleton/SkeletonItem.styles.ts","../../src/skeleton/SkeletonItem.tsx","../../src/skeleton/index.ts"],"sourcesContent":["import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonStyles = cva([], {\n variants: {\n isAnimated: {\n true: [\n '[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]',\n '[mask-size:200%_100%]',\n 'animate-standalone-shimmer motion-reduce:animate-none!',\n ],\n false: [],\n },\n },\n defaultVariants: {\n isAnimated: true,\n },\n})\n\nexport type SkeletonStyleProps = ExcludeNull<VariantProps<typeof skeletonStyles>>\n","import { ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { VisuallyHidden } from '../visually-hidden'\nimport { type SkeletonStyleProps, skeletonStyles } from './Skeleton.styles'\n\nexport interface SkeletonProps extends ComponentPropsWithRef<'div'>, SkeletonStyleProps {\n /**\n * Displays an animated light effect.\n * @default true\n */\n isAnimated?: boolean\n /**\n * Adds an accessible fallback label.\n */\n label?: string\n}\n\nexport const Skeleton = ({\n isAnimated = true,\n label,\n className,\n children,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<SkeletonProps>) => (\n <div\n ref={forwardedRef}\n data-spark-component=\"skeleton\"\n role=\"presentation\"\n className={skeletonStyles({ isAnimated, className })}\n {...rest}\n >\n {children}\n\n {label && <VisuallyHidden>{label}</VisuallyHidden>}\n </div>\n)\n\nSkeleton.displayName = 'Skeleton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], {\n variants: {\n shape: {\n line: ['w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'],\n rectangle: ['rounded-sm'],\n circle: ['flex-none', 'rounded-full'],\n },\n },\n defaultVariants: {\n shape: 'rectangle',\n },\n})\n\nexport const skeletonLineStyles = cva(['flex flex-col', 'w-full'], {\n variants: {\n gap: {\n sm: 'gap-sm',\n md: 'gap-md',\n lg: 'gap-lg',\n xl: 'gap-xl',\n '2xl': 'gap-2xl',\n '3xl': 'gap-3xl',\n },\n },\n defaultVariants: {\n gap: 'md',\n },\n})\n\nexport type SkeletonItemStyleProps = ExcludeNull<VariantProps<typeof skeletonItemStyles>>\n","import { ComponentPropsWithRef, CSSProperties } from 'react'\n\nimport {\n type SkeletonItemStyleProps,\n skeletonItemStyles,\n skeletonLineStyles,\n} from './SkeletonItem.styles'\n\ninterface SkeletonItemProps extends ComponentPropsWithRef<'div'>, SkeletonItemStyleProps {}\n\nexport type SkeletonRectangleProps = Omit<SkeletonItemProps, 'shape'> & {\n width?: string | number\n height?: string | number\n}\nexport type SkeletonCircleProps = Omit<SkeletonItemProps, 'shape'> & { size: string | number }\nexport type SkeletonLineProps = Omit<SkeletonItemProps, 'shape'> & {\n lines?: number\n /**\n * Sets the gaps between group items.\n */\n gap?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'\n}\n\nconst getSizeValue = (size?: number | string): string | undefined => {\n if (typeof size === 'number') return `${size}px`\n\n return size\n}\n\nconst SkeletonItem = ({ shape, className, ref: forwardedRef, ...rest }: SkeletonItemProps) => {\n return (\n <div\n ref={forwardedRef}\n aria-hidden=\"true\"\n className={skeletonItemStyles({ shape, className })}\n {...rest}\n />\n )\n}\n\nexport const SkeletonRectangle = ({ width = '100%', height, ...rest }: SkeletonRectangleProps) => {\n return (\n <SkeletonItem\n style={\n {\n '--skeleton-rect-width': getSizeValue(width),\n '--skeleton-rect-height': getSizeValue(height),\n } as CSSProperties\n }\n className=\"h-(--skeleton-rect-height) w-(--skeleton-rect-width)\"\n {...rest}\n shape=\"rectangle\"\n data-shape=\"rectangle\"\n />\n )\n}\n\nexport const SkeletonCircle = ({ size, ...rest }: SkeletonCircleProps) => (\n <SkeletonItem\n style={{ '--skeleton-circle-size': getSizeValue(size) } as CSSProperties}\n className=\"size-(--skeleton-circle-size)\"\n {...rest}\n shape=\"circle\"\n data-shape=\"circle\"\n />\n)\n\nexport const SkeletonLine = ({\n lines = 1,\n gap: gapProp,\n className,\n ...rest\n}: SkeletonLineProps) => {\n const gap = gapProp || 'md'\n\n return (\n <div className={skeletonLineStyles({ gap, className })} aria-hidden=\"true\">\n {[...new Array(lines)].map((_, index) => (\n <SkeletonItem key={`line_${index}`} {...rest} shape=\"line\" data-shape=\"line\" />\n ))}\n </div>\n )\n}\n\nSkeletonRectangle.displayName = 'Skeleton.Rectangle'\nSkeletonCircle.displayName = 'Skeleton.Circle'\nSkeletonLine.displayName = 'Skeleton.Line'\n","import { Skeleton as Root } from './Skeleton'\nimport {\n SkeletonCircle as Circle,\n SkeletonLine as Line,\n SkeletonRectangle as Rectangle,\n} from './SkeletonItem'\n\nexport const Skeleton: typeof Root & {\n Circle: typeof Circle\n Line: typeof Line\n Rectangle: typeof Rectangle\n} = Object.assign(Root, {\n Circle,\n Line,\n Rectangle,\n})\n\nSkeleton.displayName = 'Skeleton'\nLine.displayName = 'Skeleton.Line'\nCircle.displayName = 'Skeleton.Circle'\nRectangle.displayName = 'Skeleton.Rectangle'\n\nexport type { SkeletonProps } from './Skeleton'\n"],"mappings":"2NAEA,IAAa,GAAA,EAAA,EAAA,KAAqB,EAAE,CAAE,CACpC,SAAU,CACR,WAAY,CACV,KAAM,CACJ,4EACA,wBACA,yDACD,CACD,MAAO,EAAE,CACV,CACF,CACD,gBAAiB,CACf,WAAY,GACb,CACF,CAAC,CCCW,GAAY,CACvB,aAAa,GACb,QACA,YACA,WACA,IAAK,EACL,GAAG,MAEH,EAAA,EAAA,MAAC,MAAD,CAC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C3B,QAAQ,EACR,IAAK,EACL,YACA,GAAG,MAKD,EAAA,EAAA,KAAC,MAAD,CAAK,UAAW,EAAmB,CAAE,IAH3B,GAAW,KAGqB,YAAW,CAAC,CAAE,cAAY,gBACjE,CAAC,GAAO,MAAM,EAAM,CAAC,CAAC,KAAK,EAAG,KAC7B,EAAA,EAAA,KAAC,EAAD,CAAoC,GAAI,EAAM,MAAM,OAAO,aAAW,OAAS,CAA5D,QAAQ,IAAoD,CAC/E,CACE,CAAA,CAIV,EAAkB,YAAc,qBAChC,EAAe,YAAc,kBAC7B,EAAa,YAAc,gBC/E3B,IAAa,EAIT,OAAO,OAAO,EAAM,CACtB,OAAA,EACA,KAAA,EACA,UAAA,EACD,CAAC,CAEF,EAAS,YAAc,WACvB,EAAK,YAAc,gBACnB,EAAO,YAAc,kBACrB,EAAU,YAAc"}
@@ -1,115 +1,93 @@
1
- import { jsxs as h, jsx as l } from "react/jsx-runtime";
2
- import { V as u } from "../VisuallyHidden-DjlV0-CW.mjs";
3
- import { cva as i } from "class-variance-authority";
4
- const f = i([], {
5
- variants: {
6
- isAnimated: {
7
- true: [
8
- "[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]",
9
- "[mask-size:200%_100%]",
10
- "animate-standalone-shimmer motion-reduce:animate-none!"
11
- ],
12
- false: []
13
- }
14
- },
15
- defaultVariants: {
16
- isAnimated: !0
17
- }
18
- }), g = ({
19
- isAnimated: e = !0,
20
- label: a,
21
- className: t,
22
- children: n,
23
- ref: m,
24
- ...p
25
- }) => /* @__PURE__ */ h(
26
- "div",
27
- {
28
- ref: m,
29
- "data-spark-component": "skeleton",
30
- role: "presentation",
31
- className: f({ isAnimated: e, className: t }),
32
- ...p,
33
- children: [
34
- n,
35
- a && /* @__PURE__ */ l(u, { children: a })
36
- ]
37
- }
38
- );
39
- g.displayName = "Skeleton";
40
- const S = i(["bg-neutral/dim-4", "min-h-lg min-w-lg"], {
41
- variants: {
42
- shape: {
43
- line: ["w-full [&:last-child:not(:first-child)]:w-5/6", "rounded-lg"],
44
- rectangle: ["rounded-sm"],
45
- circle: ["flex-none", "rounded-full"]
46
- }
47
- },
48
- defaultVariants: {
49
- shape: "rectangle"
50
- }
51
- }), y = i(["flex flex-col", "w-full"], {
52
- variants: {
53
- gap: {
54
- sm: "gap-sm",
55
- md: "gap-md",
56
- lg: "gap-lg",
57
- xl: "gap-xl",
58
- "2xl": "gap-2xl",
59
- "3xl": "gap-3xl"
60
- }
61
- },
62
- defaultVariants: {
63
- gap: "md"
64
- }
65
- }), s = (e) => typeof e == "number" ? `${e}px` : e, r = ({ shape: e, className: a, ref: t, ...n }) => /* @__PURE__ */ l(
66
- "div",
67
- {
68
- ref: t,
69
- "aria-hidden": "true",
70
- className: S({ shape: e, className: a }),
71
- ...n
72
- }
73
- ), o = ({ width: e = "100%", height: a, ...t }) => /* @__PURE__ */ l(
74
- r,
75
- {
76
- style: {
77
- "--skeleton-rect-width": s(e),
78
- "--skeleton-rect-height": s(a)
79
- },
80
- className: "h-(--skeleton-rect-height) w-(--skeleton-rect-width)",
81
- ...t,
82
- shape: "rectangle",
83
- "data-shape": "rectangle"
84
- }
85
- ), c = ({ size: e, ...a }) => /* @__PURE__ */ l(
86
- r,
87
- {
88
- style: { "--skeleton-circle-size": s(e) },
89
- className: "size-(--skeleton-circle-size)",
90
- ...a,
91
- shape: "circle",
92
- "data-shape": "circle"
93
- }
94
- ), d = ({
95
- lines: e = 1,
96
- gap: a,
97
- className: t,
98
- ...n
99
- }) => /* @__PURE__ */ l("div", { className: y({ gap: a || "md", className: t }), "aria-hidden": "true", children: [...new Array(e)].map((p, k) => /* @__PURE__ */ l(r, { ...n, shape: "line", "data-shape": "line" }, `line_${k}`)) });
100
- o.displayName = "Skeleton.Rectangle";
101
- c.displayName = "Skeleton.Circle";
102
- d.displayName = "Skeleton.Line";
103
- const x = Object.assign(g, {
104
- Circle: c,
105
- Line: d,
106
- Rectangle: o
1
+ import { VisuallyHidden as e } from "../visually-hidden/index.mjs";
2
+ import { cva as t } from "class-variance-authority";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/skeleton/Skeleton.styles.ts
5
+ var i = t([], {
6
+ variants: { isAnimated: {
7
+ true: [
8
+ "[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]",
9
+ "[mask-size:200%_100%]",
10
+ "animate-standalone-shimmer motion-reduce:animate-none!"
11
+ ],
12
+ false: []
13
+ } },
14
+ defaultVariants: { isAnimated: !0 }
15
+ }), a = ({ isAnimated: t = !0, label: a, className: o, children: s, ref: c, ...l }) => /* @__PURE__ */ r("div", {
16
+ ref: c,
17
+ "data-spark-component": "skeleton",
18
+ role: "presentation",
19
+ className: i({
20
+ isAnimated: t,
21
+ className: o
22
+ }),
23
+ ...l,
24
+ children: [s, a && /* @__PURE__ */ n(e, { children: a })]
107
25
  });
108
- x.displayName = "Skeleton";
109
- d.displayName = "Skeleton.Line";
110
- c.displayName = "Skeleton.Circle";
111
- o.displayName = "Skeleton.Rectangle";
112
- export {
113
- x as Skeleton
114
- };
115
- //# sourceMappingURL=index.mjs.map
26
+ a.displayName = "Skeleton";
27
+ //#endregion
28
+ //#region src/skeleton/SkeletonItem.styles.ts
29
+ var o = t(["bg-neutral/dim-4", "min-h-lg min-w-lg"], {
30
+ variants: { shape: {
31
+ line: ["w-full [&:last-child:not(:first-child)]:w-5/6", "rounded-lg"],
32
+ rectangle: ["rounded-sm"],
33
+ circle: ["flex-none", "rounded-full"]
34
+ } },
35
+ defaultVariants: { shape: "rectangle" }
36
+ }), s = t(["flex flex-col", "w-full"], {
37
+ variants: { gap: {
38
+ sm: "gap-sm",
39
+ md: "gap-md",
40
+ lg: "gap-lg",
41
+ xl: "gap-xl",
42
+ "2xl": "gap-2xl",
43
+ "3xl": "gap-3xl"
44
+ } },
45
+ defaultVariants: { gap: "md" }
46
+ }), c = (e) => typeof e == "number" ? `${e}px` : e, l = ({ shape: e, className: t, ref: r, ...i }) => /* @__PURE__ */ n("div", {
47
+ ref: r,
48
+ "aria-hidden": "true",
49
+ className: o({
50
+ shape: e,
51
+ className: t
52
+ }),
53
+ ...i
54
+ }), u = ({ width: e = "100%", height: t, ...r }) => /* @__PURE__ */ n(l, {
55
+ style: {
56
+ "--skeleton-rect-width": c(e),
57
+ "--skeleton-rect-height": c(t)
58
+ },
59
+ className: "h-(--skeleton-rect-height) w-(--skeleton-rect-width)",
60
+ ...r,
61
+ shape: "rectangle",
62
+ "data-shape": "rectangle"
63
+ }), d = ({ size: e, ...t }) => /* @__PURE__ */ n(l, {
64
+ style: { "--skeleton-circle-size": c(e) },
65
+ className: "size-(--skeleton-circle-size)",
66
+ ...t,
67
+ shape: "circle",
68
+ "data-shape": "circle"
69
+ }), f = ({ lines: e = 1, gap: t, className: r, ...i }) => /* @__PURE__ */ n("div", {
70
+ className: s({
71
+ gap: t || "md",
72
+ className: r
73
+ }),
74
+ "aria-hidden": "true",
75
+ children: [...Array(e)].map((e, t) => /* @__PURE__ */ n(l, {
76
+ ...i,
77
+ shape: "line",
78
+ "data-shape": "line"
79
+ }, `line_${t}`))
80
+ });
81
+ u.displayName = "Skeleton.Rectangle", d.displayName = "Skeleton.Circle", f.displayName = "Skeleton.Line";
82
+ //#endregion
83
+ //#region src/skeleton/index.ts
84
+ var p = Object.assign(a, {
85
+ Circle: d,
86
+ Line: f,
87
+ Rectangle: u
88
+ });
89
+ p.displayName = "Skeleton", f.displayName = "Skeleton.Line", d.displayName = "Skeleton.Circle", u.displayName = "Skeleton.Rectangle";
90
+ //#endregion
91
+ export { p as Skeleton };
92
+
93
+ //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/skeleton/Skeleton.styles.ts","../../src/skeleton/Skeleton.tsx","../../src/skeleton/SkeletonItem.styles.ts","../../src/skeleton/SkeletonItem.tsx","../../src/skeleton/index.ts"],"sourcesContent":["import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonStyles = cva([], {\n variants: {\n isAnimated: {\n true: [\n '[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]',\n '[mask-size:200%_100%]',\n 'animate-standalone-shimmer motion-reduce:animate-none!',\n ],\n false: [],\n },\n },\n defaultVariants: {\n isAnimated: true,\n },\n})\n\nexport type SkeletonStyleProps = ExcludeNull<VariantProps<typeof skeletonStyles>>\n","import { ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { VisuallyHidden } from '../visually-hidden'\nimport { type SkeletonStyleProps, skeletonStyles } from './Skeleton.styles'\n\nexport interface SkeletonProps extends ComponentPropsWithRef<'div'>, SkeletonStyleProps {\n /**\n * Displays an animated light effect.\n * @default true\n */\n isAnimated?: boolean\n /**\n * Adds an accessible fallback label.\n */\n label?: string\n}\n\nexport const Skeleton = ({\n isAnimated = true,\n label,\n className,\n children,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<SkeletonProps>) => (\n <div\n ref={forwardedRef}\n data-spark-component=\"skeleton\"\n role=\"presentation\"\n className={skeletonStyles({ isAnimated, className })}\n {...rest}\n >\n {children}\n\n {label && <VisuallyHidden>{label}</VisuallyHidden>}\n </div>\n)\n\nSkeleton.displayName = 'Skeleton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], {\n variants: {\n shape: {\n line: ['w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'],\n rectangle: ['rounded-sm'],\n circle: ['flex-none', 'rounded-full'],\n },\n },\n defaultVariants: {\n shape: 'rectangle',\n },\n})\n\nexport const skeletonLineStyles = cva(['flex flex-col', 'w-full'], {\n variants: {\n gap: {\n sm: 'gap-sm',\n md: 'gap-md',\n lg: 'gap-lg',\n xl: 'gap-xl',\n '2xl': 'gap-2xl',\n '3xl': 'gap-3xl',\n },\n },\n defaultVariants: {\n gap: 'md',\n },\n})\n\nexport type SkeletonItemStyleProps = ExcludeNull<VariantProps<typeof skeletonItemStyles>>\n","import { ComponentPropsWithRef, CSSProperties } from 'react'\n\nimport {\n type SkeletonItemStyleProps,\n skeletonItemStyles,\n skeletonLineStyles,\n} from './SkeletonItem.styles'\n\ninterface SkeletonItemProps extends ComponentPropsWithRef<'div'>, SkeletonItemStyleProps {}\n\nexport type SkeletonRectangleProps = Omit<SkeletonItemProps, 'shape'> & {\n width?: string | number\n height?: string | number\n}\nexport type SkeletonCircleProps = Omit<SkeletonItemProps, 'shape'> & { size: string | number }\nexport type SkeletonLineProps = Omit<SkeletonItemProps, 'shape'> & {\n lines?: number\n /**\n * Sets the gaps between group items.\n */\n gap?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'\n}\n\nconst getSizeValue = (size?: number | string): string | undefined => {\n if (typeof size === 'number') return `${size}px`\n\n return size\n}\n\nconst SkeletonItem = ({ shape, className, ref: forwardedRef, ...rest }: SkeletonItemProps) => {\n return (\n <div\n ref={forwardedRef}\n aria-hidden=\"true\"\n className={skeletonItemStyles({ shape, className })}\n {...rest}\n />\n )\n}\n\nexport const SkeletonRectangle = ({ width = '100%', height, ...rest }: SkeletonRectangleProps) => {\n return (\n <SkeletonItem\n style={\n {\n '--skeleton-rect-width': getSizeValue(width),\n '--skeleton-rect-height': getSizeValue(height),\n } as CSSProperties\n }\n className=\"h-(--skeleton-rect-height) w-(--skeleton-rect-width)\"\n {...rest}\n shape=\"rectangle\"\n data-shape=\"rectangle\"\n />\n )\n}\n\nexport const SkeletonCircle = ({ size, ...rest }: SkeletonCircleProps) => (\n <SkeletonItem\n style={{ '--skeleton-circle-size': getSizeValue(size) } as CSSProperties}\n className=\"size-(--skeleton-circle-size)\"\n {...rest}\n shape=\"circle\"\n data-shape=\"circle\"\n />\n)\n\nexport const SkeletonLine = ({\n lines = 1,\n gap: gapProp,\n className,\n ...rest\n}: SkeletonLineProps) => {\n const gap = gapProp || 'md'\n\n return (\n <div className={skeletonLineStyles({ gap, className })} aria-hidden=\"true\">\n {[...new Array(lines)].map((_, index) => (\n <SkeletonItem key={`line_${index}`} {...rest} shape=\"line\" data-shape=\"line\" />\n ))}\n </div>\n )\n}\n\nSkeletonRectangle.displayName = 'Skeleton.Rectangle'\nSkeletonCircle.displayName = 'Skeleton.Circle'\nSkeletonLine.displayName = 'Skeleton.Line'\n","import { Skeleton as Root } from './Skeleton'\nimport {\n SkeletonCircle as Circle,\n SkeletonLine as Line,\n SkeletonRectangle as Rectangle,\n} from './SkeletonItem'\n\nexport const Skeleton: typeof Root & {\n Circle: typeof Circle\n Line: typeof Line\n Rectangle: typeof Rectangle\n} = Object.assign(Root, {\n Circle,\n Line,\n Rectangle,\n})\n\nSkeleton.displayName = 'Skeleton'\nLine.displayName = 'Skeleton.Line'\nCircle.displayName = 'Skeleton.Circle'\nRectangle.displayName = 'Skeleton.Rectangle'\n\nexport type { SkeletonProps } from './Skeleton'\n"],"names":["skeletonStyles","cva","Skeleton","isAnimated","label","className","children","forwardedRef","rest","jsxs","jsx","VisuallyHidden","skeletonItemStyles","skeletonLineStyles","getSizeValue","size","SkeletonItem","shape","SkeletonRectangle","width","height","SkeletonCircle","SkeletonLine","lines","gapProp","_","index","Root","Circle","Line","Rectangle"],"mappings":";;;AAEO,MAAMA,IAAiBC,EAAI,IAAI;AAAA,EACpC,UAAU;AAAA,IACR,YAAY;AAAA,MACV,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,OAAO,CAAA;AAAA,IAAC;AAAA,EACV;AAAA,EAEF,iBAAiB;AAAA,IACf,YAAY;AAAA,EAAA;AAEhB,CAAC,GCCYC,IAAW,CAAC;AAAA,EACvB,YAAAC,IAAa;AAAA,EACb,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,KAAKC;AAAA,EACL,GAAGC;AACL,MACE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAKF;AAAA,IACL,wBAAqB;AAAA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AAAA,MACE,yBAAyBF,EAAaK,CAAK;AAAA,MAC3C,0BAA0BL,EAAaM,CAAM;AAAA,IAAA;AAAA,IAGjD,WAAU;AAAA,IACT,GAAGZ;AAAA,IACJ,OAAM;AAAA,IACN,cAAW;AAAA,EAAA;AAAA,GAKJa,IAAiB,CAAC,EAAE,MAAAN,GAAM,GAAGP,QACxC,gBAAAE;AAAA,EAACM;AAAA,EAAA;AAAA,IACC,OAAO,EAAE,0BAA0BF,EAAaC,CAAI,EAAA;AAAA,IACpD,WAAU;AAAA,IACT,GAAGP;AAAA,IACJ,OAAM;AAAA,IACN,cAAW;AAAA,EAAA;AACb,GAGWc,IAAe,CAAC;AAAA,EAC3B,OAAAC,IAAQ;AAAA,EACR,KAAKC;AAAA,EACL,WAAAnB;AAAA,EACA,GAAGG;AACL,MAII,gBAAAE,EAAC,OAAA,EAAI,WAAWG,EAAmB,EAAE,KAH3BW,KAAW,MAGqB,WAAAnB,EAAA,CAAW,GAAG,eAAY,QACjE,UAAA,CAAC,GAAG,IAAI,MAAMkB,CAAK,CAAC,EAAE,IAAI,CAACE,GAAGC,MAC7B,gBAAAhB,EAACM,KAAoC,GAAGR,GAAM,OAAM,QAAO,cAAW,OAAA,GAAnD,QAAQkB,CAAK,EAA6C,CAC9E,GACH;AAIJR,EAAkB,cAAc;AAChCG,EAAe,cAAc;AAC7BC,EAAa,cAAc;AC/EpB,MAAMpB,IAIT,OAAO,OAAOyB,GAAM;AAAA,EAAA,QACtBC;AAAAA,EAAA,MACAC;AAAAA,EAAA,WACAC;AACF,CAAC;AAED5B,EAAS,cAAc;AACvB2B,EAAK,cAAc;AACnBD,EAAO,cAAc;AACrBE,EAAU,cAAc;"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/skeleton/Skeleton.styles.ts","../../src/skeleton/Skeleton.tsx","../../src/skeleton/SkeletonItem.styles.ts","../../src/skeleton/SkeletonItem.tsx","../../src/skeleton/index.ts"],"sourcesContent":["import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonStyles = cva([], {\n variants: {\n isAnimated: {\n true: [\n '[mask-image:linear-gradient(90deg,#000_40%,rgba(0,0,0,.3)_60%,#000_100%)]',\n '[mask-size:200%_100%]',\n 'animate-standalone-shimmer motion-reduce:animate-none!',\n ],\n false: [],\n },\n },\n defaultVariants: {\n isAnimated: true,\n },\n})\n\nexport type SkeletonStyleProps = ExcludeNull<VariantProps<typeof skeletonStyles>>\n","import { ComponentPropsWithRef, PropsWithChildren } from 'react'\n\nimport { VisuallyHidden } from '../visually-hidden'\nimport { type SkeletonStyleProps, skeletonStyles } from './Skeleton.styles'\n\nexport interface SkeletonProps extends ComponentPropsWithRef<'div'>, SkeletonStyleProps {\n /**\n * Displays an animated light effect.\n * @default true\n */\n isAnimated?: boolean\n /**\n * Adds an accessible fallback label.\n */\n label?: string\n}\n\nexport const Skeleton = ({\n isAnimated = true,\n label,\n className,\n children,\n ref: forwardedRef,\n ...rest\n}: PropsWithChildren<SkeletonProps>) => (\n <div\n ref={forwardedRef}\n data-spark-component=\"skeleton\"\n role=\"presentation\"\n className={skeletonStyles({ isAnimated, className })}\n {...rest}\n >\n {children}\n\n {label && <VisuallyHidden>{label}</VisuallyHidden>}\n </div>\n)\n\nSkeleton.displayName = 'Skeleton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const skeletonItemStyles = cva(['bg-neutral/dim-4', 'min-h-lg min-w-lg'], {\n variants: {\n shape: {\n line: ['w-full [&:last-child:not(:first-child)]:w-5/6', 'rounded-lg'],\n rectangle: ['rounded-sm'],\n circle: ['flex-none', 'rounded-full'],\n },\n },\n defaultVariants: {\n shape: 'rectangle',\n },\n})\n\nexport const skeletonLineStyles = cva(['flex flex-col', 'w-full'], {\n variants: {\n gap: {\n sm: 'gap-sm',\n md: 'gap-md',\n lg: 'gap-lg',\n xl: 'gap-xl',\n '2xl': 'gap-2xl',\n '3xl': 'gap-3xl',\n },\n },\n defaultVariants: {\n gap: 'md',\n },\n})\n\nexport type SkeletonItemStyleProps = ExcludeNull<VariantProps<typeof skeletonItemStyles>>\n","import { ComponentPropsWithRef, CSSProperties } from 'react'\n\nimport {\n type SkeletonItemStyleProps,\n skeletonItemStyles,\n skeletonLineStyles,\n} from './SkeletonItem.styles'\n\ninterface SkeletonItemProps extends ComponentPropsWithRef<'div'>, SkeletonItemStyleProps {}\n\nexport type SkeletonRectangleProps = Omit<SkeletonItemProps, 'shape'> & {\n width?: string | number\n height?: string | number\n}\nexport type SkeletonCircleProps = Omit<SkeletonItemProps, 'shape'> & { size: string | number }\nexport type SkeletonLineProps = Omit<SkeletonItemProps, 'shape'> & {\n lines?: number\n /**\n * Sets the gaps between group items.\n */\n gap?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl'\n}\n\nconst getSizeValue = (size?: number | string): string | undefined => {\n if (typeof size === 'number') return `${size}px`\n\n return size\n}\n\nconst SkeletonItem = ({ shape, className, ref: forwardedRef, ...rest }: SkeletonItemProps) => {\n return (\n <div\n ref={forwardedRef}\n aria-hidden=\"true\"\n className={skeletonItemStyles({ shape, className })}\n {...rest}\n />\n )\n}\n\nexport const SkeletonRectangle = ({ width = '100%', height, ...rest }: SkeletonRectangleProps) => {\n return (\n <SkeletonItem\n style={\n {\n '--skeleton-rect-width': getSizeValue(width),\n '--skeleton-rect-height': getSizeValue(height),\n } as CSSProperties\n }\n className=\"h-(--skeleton-rect-height) w-(--skeleton-rect-width)\"\n {...rest}\n shape=\"rectangle\"\n data-shape=\"rectangle\"\n />\n )\n}\n\nexport const SkeletonCircle = ({ size, ...rest }: SkeletonCircleProps) => (\n <SkeletonItem\n style={{ '--skeleton-circle-size': getSizeValue(size) } as CSSProperties}\n className=\"size-(--skeleton-circle-size)\"\n {...rest}\n shape=\"circle\"\n data-shape=\"circle\"\n />\n)\n\nexport const SkeletonLine = ({\n lines = 1,\n gap: gapProp,\n className,\n ...rest\n}: SkeletonLineProps) => {\n const gap = gapProp || 'md'\n\n return (\n <div className={skeletonLineStyles({ gap, className })} aria-hidden=\"true\">\n {[...new Array(lines)].map((_, index) => (\n <SkeletonItem key={`line_${index}`} {...rest} shape=\"line\" data-shape=\"line\" />\n ))}\n </div>\n )\n}\n\nSkeletonRectangle.displayName = 'Skeleton.Rectangle'\nSkeletonCircle.displayName = 'Skeleton.Circle'\nSkeletonLine.displayName = 'Skeleton.Line'\n","import { Skeleton as Root } from './Skeleton'\nimport {\n SkeletonCircle as Circle,\n SkeletonLine as Line,\n SkeletonRectangle as Rectangle,\n} from './SkeletonItem'\n\nexport const Skeleton: typeof Root & {\n Circle: typeof Circle\n Line: typeof Line\n Rectangle: typeof Rectangle\n} = Object.assign(Root, {\n Circle,\n Line,\n Rectangle,\n})\n\nSkeleton.displayName = 'Skeleton'\nLine.displayName = 'Skeleton.Line'\nCircle.displayName = 'Skeleton.Circle'\nRectangle.displayName = 'Skeleton.Rectangle'\n\nexport type { SkeletonProps } from './Skeleton'\n"],"mappings":";;;;AAEA,IAAa,IAAiB,EAAI,EAAE,EAAE;CACpC,UAAU,EACR,YAAY;EACV,MAAM;GACJ;GACA;GACA;GACD;EACD,OAAO,EAAE;EACV,EACF;CACD,iBAAiB,EACf,YAAY,IACb;CACF,CAAC,ECCW,KAAY,EACvB,gBAAa,IACb,UACA,cACA,aACA,KAAK,GACL,GAAG,QAEH,kBAAC,OAAD;CACE,KAAK;CACL,wBAAqB;CACrB,MAAK;CACL,WAAW,EAAe;EAAE;EAAY;EAAW,CAAC;CACpD,GAAI;WALN,CAOG,GAEA,KAAS,kBAAC,GAAD,EAAA,UAAiB,GAAuB,CAAA,CAC9C;;AAGR,EAAS,cAAc;;;ACpCvB,IAAa,IAAqB,EAAI,CAAC,oBAAoB,oBAAoB,EAAE;CAC/E,UAAU,EACR,OAAO;EACL,MAAM,CAAC,iDAAiD,aAAa;EACrE,WAAW,CAAC,aAAa;EACzB,QAAQ,CAAC,aAAa,eAAe;EACtC,EACF;CACD,iBAAiB,EACf,OAAO,aACR;CACF,CAAC,EAEW,I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AO,cAAc,mBACrB,EAAU,cAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),N=require("@base-ui/react/slider"),X=require("@spark-ui/components/form-field"),t=require("react"),S=require("class-variance-authority"),M=require("@spark-ui/hooks/use-merge-refs"),H=require("../FormFieldRequiredIndicator-CHfcoT2y.js"),J=require("../label/index.js"),K=require("../Slot-DQ8z2zsy.js"),Q=S.cva(["grid grid-cols-[1fr_auto] gap-y-sm gap-x-md relative","touch-none select-none","data-disabled:cursor-not-allowed data-disabled:opacity-dim-3"]),$=t.createContext({}),C=()=>t.useContext($),B=({intent:r="support",children:e,className:a,ref:n,value:o,defaultValue:d,disabled:f,readOnly:v,name:s,onValueChange:c,onValueCommit:m,min:b=0,max:p=100,...h})=>{const l=X.useFormFieldControl(),x=l.disabled??f,g=l.readOnly??v,y=l.name??s,[I,R]=t.useState(l.labelId),[V,T]=t.useState(0),k=t.useRef(null),_=t.useRef(null),D=t.useCallback(u=>{R(u)},[]),G=t.useCallback(()=>(T(u=>u+1),()=>T(u=>u-1)),[]);return i.jsx($.Provider,{value:{intent:r,min:b,max:p,fieldLabelId:l.labelId||I,fieldId:l.id,onLabelId:D,hasValueInThumb:V>0,registerValueInThumb:G,controlRef:k,thumbRef:_},children:i.jsx(N.Slider.Root,{ref:n,"data-spark-component":"slider",className:Q({className:a}),orientation:"horizontal",disabled:x||g,thumbAlignment:"edge",name:y,"aria-describedby":l.description,"aria-invalid":l.isInvalid,"aria-disabled":x||g?!0:void 0,value:o!==void 0?[o]:void 0,defaultValue:d!==void 0?[d]:void 0,onValueChange:c?u=>{const j=Array.isArray(u)?u[0]??0:u;c(j)}:void 0,onValueCommitted:m?u=>{const j=Array.isArray(u)?u[0]??0:u;m(j)}:void 0,min:b,max:p,...h,children:e})})};B.displayName="Slider";const z=({className:r,ref:e,...a})=>{const{hasValueInThumb:n,controlRef:o}=C(),d=M.useMergeRefs(o,e);return i.jsx(N.Slider.Control,{"data-spark-component":"slider-control",ref:d,className:S.cx("min-h-sz-24 relative col-span-2 flex w-full min-w-0 flex-1 items-center",n&&"mt-xl",r),...a})};z.displayName="Slider.Control";const U=S.cva(["relative grow h-sz-4 bg-on-background/dim-4 rounded-sm"]),Y=S.cva(["absolute h-full rounded-sm","transition-none"],{variants:{intent:{main:["bg-main"],support:["bg-support"],accent:["bg-accent"],info:["bg-info"],neutral:["bg-neutral"],success:["bg-success"],alert:["bg-alert"],error:["bg-error"]}},defaultVariants:{intent:"support"}}),q=({className:r,ref:e,...a})=>{const{intent:n}=C();return i.jsx(N.Slider.Indicator,{"data-spark-component":"slider-indicator",ref:e,className:Y({intent:n,className:r}),...a})};q.displayName="Slider.Indicator";const Z=":slider-label",F=({htmlFor:r,id:e,className:a,children:n,requiredIndicator:o=i.jsx(H.FormFieldRequiredIndicator,{}),asChild:d,ref:f,...v})=>{const s=X.useFormFieldControl(),{fieldLabelId:c,fieldId:m,onLabelId:b}=C(),p=t.useId(),h=`${Z}-${p}`,l=e||c||s.labelId||h,x=d?void 0:r||m||s.id,g=s.disabled,y=s.isRequired,I=t.useRef(null),R=M.useMergeRefs(f,I);return t.useEffect(()=>{b&&!c&&!s.labelId&&b(l)},[b,c,s.labelId,l]),i.jsx(J.Label,{ref:R,id:l,"data-spark-component":"slider-label",htmlFor:x,className:S.cx(g?"text-on-surface/dim-3 pointer-events-none":void 0,a),asChild:d,...v,children:i.jsxs(i.Fragment,{children:[i.jsx(K.Slottable,{children:n}),y&&o]})})};F.displayName="Slider.Label";const L=t.forwardRef(({className:r,children:e},a)=>{const{max:n=100}=C(),o=e?e(n):n;return i.jsx("div",{"data-spark-component":"slider-max-value",ref:a,className:S.cx("text-on-surface/dim-1 text-body-2 col-start-2 text-right",r),children:o})});L.displayName="Slider.MaxValue";const w=t.forwardRef(({className:r,children:e},a)=>{const{min:n=0}=C(),o=e?e(n):n;return i.jsx("div",{"data-spark-component":"slider-min-value",ref:a,className:S.cx("text-on-surface/dim-1 text-body-2 col-start-1 text-left",r),children:o})});w.displayName="Slider.MinValue";const P=t.createContext(null),ee=()=>t.useContext(P),te=S.cva(["relative block size-sz-24 rounded-full cursor-pointer","outline-hidden","has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-focus","data-disabled:hover:ring-0 data-disabled:cursor-not-allowed data-disabled:before:hidden","after:absolute after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2","after:size-sz-24 after:rounded-full","before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2","before:size-sz-24 before:rounded-full before:border-solid before:border-sm before:transition-all before:duration-75","hover:before:size-sz-32 data-dragging:before:size-sz-32"],{variants:{intent:{main:["after:bg-main","before:bg-main-container before:border-main"],support:["after:bg-support","before:bg-support-container before:border-support"],accent:["after:bg-accent","before:bg-accent-container before:border-accent"],info:["after:bg-info","before:bg-info-container before:border-info"],neutral:["after:bg-neutral","before:bg-neutral-container before:border-neutral"],success:["after:bg-success","before:bg-success-container before:border-success"],alert:["after:bg-alert","before:bg-alert-container before:border-alert"],error:["after:bg-error","before:bg-error-container before:border-error"]}},defaultVariants:{intent:"support"}}),A=({className:r,ref:e,children:a,...n})=>{const{intent:o,fieldLabelId:d,fieldId:f,thumbRef:v}=C(),s=t.useRef(null),c=M.useMergeRefs(v,e??s);return i.jsx(P.Provider,{value:{isInsideThumb:!0},children:i.jsx(N.Slider.Thumb,{"data-spark-component":"slider-thumb",ref:c,id:f,className:te({intent:o,className:r}),"aria-labelledby":d,...n,children:a})})};A.displayName="Slider.Thumb";const O=({className:r,ref:e,...a})=>i.jsx(N.Slider.Track,{"data-spark-component":"slider-track",ref:e,className:U({className:r}),...a});O.displayName="Slider.Track";function re(r,e,a,n){const[o,d]=t.useState(0),[f,v]=t.useState(!1);return t.useLayoutEffect(()=>{const s=r.current,c=e.current,m=a.current;if(!s||!c||!m){d(0),f||requestAnimationFrame(()=>v(!0));return}let b=!1;const p=()=>{if(b)return;const l=s.getBoundingClientRect(),x=c.getBoundingClientRect(),g=m.scrollWidth;if(g===0){requestAnimationFrame(p);return}const y=x.left-l.left+x.width/2,I=g/2,R=l.width-g/2,T=Math.max(I,Math.min(R,y))-y;d(k=>k!==T?T:k)};p();const h=new ResizeObserver(p);return h.observe(s),h.observe(m),()=>{b=!0,h.disconnect()}},[r,e,a,n,f]),o}const E=({className:r,children:e,ref:a,...n})=>{const{registerValueInThumb:o,controlRef:d,thumbRef:f}=C(),s=ee()!==null,c=t.useRef(null),m=M.useMergeRefs(c,a),[b,p]=t.useState(0),h=re(d,f,c,b);t.useEffect(()=>{if(s)return o()},[s,o]);const l=S.cx(s?"absolute left-1/2 -translate-x-1/2 top-[calc(-100%-var(--spacing-sm))] text-body-1 font-bold whitespace-nowrap":"default:text-body-1 col-start-2 text-right default:font-bold",r),x=t.useCallback((y,I)=>{const R=y[0]??String(I[0]??""),V=I[0]??0;return p(V),typeof e=="function"?e(R,V):R},[e]),g=s?{transform:`translate(calc(0% + ${h}px), 0)`}:void 0;return i.jsx(N.Slider.Value,{"data-spark-component":"slider-value",ref:m,className:l,style:g,...n,children:x})};E.displayName="Slider.Value";const W=Object.assign(B,{Control:z,Indicator:q,Label:F,MaxValue:L,MinValue:w,Thumb:A,Track:O,Value:E});W.displayName="Slider";z.displayName="Slider.Control";q.displayName="Slider.Indicator";F.displayName="Slider.Label";L.displayName="Slider.MaxValue";w.displayName="Slider.MinValue";A.displayName="Slider.Thumb";O.displayName="Slider.Track";E.displayName="Slider.Value";exports.Slider=W;
2
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-C91j1N6u.js`);const e=require(`../slot/index.js`),t=require(`../label-DU0p0d-f.js`),n=require(`../FormFieldRequiredIndicator-CtgkvPZo.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(`@base-ui/react/slider`);var l=(0,r.cva)([`grid grid-cols-[1fr_auto] gap-y-sm gap-x-md relative`,`touch-none select-none`,`data-disabled:cursor-not-allowed data-disabled:opacity-dim-3`]),u=(0,i.createContext)({}),d=()=>(0,i.useContext)(u),f=({intent:e=`support`,children:t,className:n,ref:r,value:o,defaultValue:d,disabled:f,readOnly:p,name:m,onValueChange:h,onValueCommit:g,min:_=0,max:v=100,...y})=>{let b=(0,s.useFormFieldControl)(),x=b.disabled??f,S=b.readOnly??p,C=b.name??m,[w,T]=(0,i.useState)(b.labelId),[E,D]=(0,i.useState)(0),O=(0,i.useRef)(null),k=(0,i.useRef)(null),A=(0,i.useCallback)(e=>{T(e)},[]),j=(0,i.useCallback)(()=>(D(e=>e+1),()=>D(e=>e-1)),[]);return(0,a.jsx)(u.Provider,{value:{intent:e,min:_,max:v,fieldLabelId:b.labelId||w,fieldId:b.id,onLabelId:A,hasValueInThumb:E>0,registerValueInThumb:j,controlRef:O,thumbRef:k},children:(0,a.jsx)(c.Slider.Root,{ref:r,"data-spark-component":`slider`,className:l({className:n}),orientation:`horizontal`,disabled:x||S,thumbAlignment:`edge`,name:C,"aria-describedby":b.description,"aria-invalid":b.isInvalid,"aria-disabled":x||S?!0:void 0,value:o===void 0?void 0:[o],defaultValue:d===void 0?void 0:[d],onValueChange:h?e=>{h(Array.isArray(e)?e[0]??0:e)}:void 0,onValueCommitted:g?e=>{g(Array.isArray(e)?e[0]??0:e)}:void 0,min:_,max:v,...y,children:t})})};f.displayName=`Slider`;var p=({className:e,ref:t,...n})=>{let{hasValueInThumb:i,controlRef:s}=d(),l=(0,o.useMergeRefs)(s,t);return(0,a.jsx)(c.Slider.Control,{"data-spark-component":`slider-control`,ref:l,className:(0,r.cx)(`min-h-sz-24 relative col-span-2 flex w-full min-w-0 flex-1 items-center`,i&&`mt-xl`,e),...n})};p.displayName=`Slider.Control`;var m=(0,r.cva)([`relative grow h-sz-4 bg-on-background/dim-4 rounded-sm`]),h=(0,r.cva)([`absolute h-full rounded-sm`,`transition-none`],{variants:{intent:{main:[`bg-main`],support:[`bg-support`],accent:[`bg-accent`],info:[`bg-info`],neutral:[`bg-neutral`],success:[`bg-success`],alert:[`bg-alert`],error:[`bg-error`]}},defaultVariants:{intent:`support`}}),g=({className:e,ref:t,...n})=>{let{intent:r}=d();return(0,a.jsx)(c.Slider.Indicator,{"data-spark-component":`slider-indicator`,ref:t,className:h({intent:r,className:e}),...n})};g.displayName=`Slider.Indicator`;var _=`:slider-label`,v=({htmlFor:c,id:l,className:u,children:f,requiredIndicator:p=(0,a.jsx)(n.t,{}),asChild:m,ref:h,...g})=>{let v=(0,s.useFormFieldControl)(),{fieldLabelId:y,fieldId:b,onLabelId:x}=d(),S=`${_}-${(0,i.useId)()}`,C=l||y||v.labelId||S,w=m?void 0:c||b||v.id,T=v.disabled,E=v.isRequired,D=(0,o.useMergeRefs)(h,(0,i.useRef)(null));return(0,i.useEffect)(()=>{x&&!y&&!v.labelId&&x(C)},[x,y,v.labelId,C]),(0,a.jsx)(t.t,{ref:D,id:C,"data-spark-component":`slider-label`,htmlFor:w,className:(0,r.cx)(T?`text-on-surface/dim-3 pointer-events-none`:void 0,u),asChild:m,...g,children:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e.Slottable,{children:f}),E&&p]})})};v.displayName=`Slider.Label`;var y=(0,i.forwardRef)(({className:e,children:t},n)=>{let{max:i=100}=d(),o=t?t(i):i;return(0,a.jsx)(`div`,{"data-spark-component":`slider-max-value`,ref:n,className:(0,r.cx)(`text-on-surface/dim-1 text-body-2 col-start-2 text-right`,e),children:o})});y.displayName=`Slider.MaxValue`;var b=(0,i.forwardRef)(({className:e,children:t},n)=>{let{min:i=0}=d(),o=t?t(i):i;return(0,a.jsx)(`div`,{"data-spark-component":`slider-min-value`,ref:n,className:(0,r.cx)(`text-on-surface/dim-1 text-body-2 col-start-1 text-left`,e),children:o})});b.displayName=`Slider.MinValue`;var x=(0,r.cva)([`relative block size-sz-24 rounded-full cursor-pointer`,`outline-hidden`,`has-focus-visible:ring-2 has-focus-visible:ring-offset-2 has-focus-visible:ring-focus`,`data-disabled:hover:ring-0 data-disabled:cursor-not-allowed data-disabled:before:hidden`,`after:absolute after:left-1/2 after:top-1/2 after:-translate-x-1/2 after:-translate-y-1/2`,`after:size-sz-24 after:rounded-full`,`before:absolute before:left-1/2 before:top-1/2 before:-translate-x-1/2 before:-translate-y-1/2`,`before:size-sz-24 before:rounded-full before:border-solid before:border-sm before:transition-all before:duration-75`,`hover:before:size-sz-32 data-dragging:before:size-sz-32`],{variants:{intent:{main:[`after:bg-main`,`before:bg-main-container before:border-main`],support:[`after:bg-support`,`before:bg-support-container before:border-support`],accent:[`after:bg-accent`,`before:bg-accent-container before:border-accent`],info:[`after:bg-info`,`before:bg-info-container before:border-info`],neutral:[`after:bg-neutral`,`before:bg-neutral-container before:border-neutral`],success:[`after:bg-success`,`before:bg-success-container before:border-success`],alert:[`after:bg-alert`,`before:bg-alert-container before:border-alert`],error:[`after:bg-error`,`before:bg-error-container before:border-error`]}},defaultVariants:{intent:`support`}}),S=(0,i.createContext)(null),C=()=>(0,i.useContext)(S),w=({className:e,ref:t,children:n,...r})=>{let{intent:s,fieldLabelId:l,fieldId:u,thumbRef:f}=d(),p=(0,i.useRef)(null),m=(0,o.useMergeRefs)(f,t??p);return(0,a.jsx)(S.Provider,{value:{isInsideThumb:!0},children:(0,a.jsx)(c.Slider.Thumb,{"data-spark-component":`slider-thumb`,ref:m,id:u,className:x({intent:s,className:e}),"aria-labelledby":l,...r,children:n})})};w.displayName=`Slider.Thumb`;var T=({className:e,ref:t,...n})=>(0,a.jsx)(c.Slider.Track,{"data-spark-component":`slider-track`,ref:t,className:m({className:e}),...n});T.displayName=`Slider.Track`;function E(e,t,n,r){let[a,o]=(0,i.useState)(0),[s,c]=(0,i.useState)(!1);return(0,i.useLayoutEffect)(()=>{let r=e.current,i=t.current,a=n.current;if(!r||!i||!a){o(0),s||requestAnimationFrame(()=>c(!0));return}let l=!1,u=()=>{if(l)return;let e=r.getBoundingClientRect(),t=i.getBoundingClientRect(),n=a.scrollWidth;if(n===0){requestAnimationFrame(u);return}let s=t.left-e.left+t.width/2,c=n/2,d=e.width-n/2,f=Math.max(c,Math.min(d,s))-s;o(e=>e===f?e:f)};u();let d=new ResizeObserver(u);return d.observe(r),d.observe(a),()=>{l=!0,d.disconnect()}},[e,t,n,r,s]),a}var D=({className:e,children:t,ref:n,...s})=>{let{registerValueInThumb:l,controlRef:u,thumbRef:f}=d(),p=C()!==null,m=(0,i.useRef)(null),h=(0,o.useMergeRefs)(m,n),[g,_]=(0,i.useState)(0),v=E(u,f,m,g);(0,i.useEffect)(()=>{if(p)return l()},[p,l]);let y=(0,r.cx)(p?`absolute left-1/2 -translate-x-1/2 top-[calc(-100%-var(--spacing-sm))] text-body-1 font-bold whitespace-nowrap`:`default:text-body-1 col-start-2 text-right default:font-bold`,e),b=(0,i.useCallback)((e,n)=>{let r=e[0]??String(n[0]??``),i=n[0]??0;return _(i),typeof t==`function`?t(r,i):r},[t]),x=p?{transform:`translate(calc(0% + ${v}px), 0)`}:void 0;return(0,a.jsx)(c.Slider.Value,{"data-spark-component":`slider-value`,ref:h,className:y,style:x,...s,children:b})};D.displayName=`Slider.Value`;var O=Object.assign(f,{Control:p,Indicator:g,Label:v,MaxValue:y,MinValue:b,Thumb:w,Track:T,Value:D});O.displayName=`Slider`,p.displayName=`Slider.Control`,g.displayName=`Slider.Indicator`,v.displayName=`Slider.Label`,y.displayName=`Slider.MaxValue`,b.displayName=`Slider.MinValue`,w.displayName=`Slider.Thumb`,T.displayName=`Slider.Track`,D.displayName=`Slider.Value`,exports.Slider=O;
2
+ //# sourceMappingURL=index.js.map