@sanity/ui 3.0.2 → 4.0.0-static.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (868) hide show
  1. package/README.md +7 -9
  2. package/dist/_chunks-cjs/{refractor.js → refractor.cjs} +3 -4
  3. package/dist/_chunks-cjs/refractor.cjs.map +1 -0
  4. package/dist/_chunks-es/{refractor.mjs → refractor.js} +2 -3
  5. package/dist/_chunks-es/refractor.js.map +1 -0
  6. package/dist/css/index.cjs +966 -0
  7. package/dist/css/index.cjs.map +1 -0
  8. package/dist/css/index.css +1 -0
  9. package/dist/css/index.d.cts +1370 -0
  10. package/dist/css/index.d.ts +1370 -0
  11. package/dist/css/index.js +967 -0
  12. package/dist/css/index.js.map +1 -0
  13. package/dist/index.cjs +4515 -0
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.cts +2521 -0
  16. package/dist/index.d.ts +1379 -1824
  17. package/dist/index.js +3872 -1066
  18. package/dist/index.js.map +1 -1
  19. package/dist/theme.cjs +870 -0
  20. package/dist/theme.cjs.map +1 -0
  21. package/dist/theme.d.cts +499 -0
  22. package/dist/theme.d.ts +375 -1376
  23. package/dist/theme.js +548 -3790
  24. package/dist/theme.js.map +1 -1
  25. package/exports/css.ts +1 -0
  26. package/package.json +77 -76
  27. package/src/core/Root.tsx +88 -0
  28. package/src/core/RootProvider.tsx +40 -0
  29. package/src/core/__workshop__/boundary.tsx +28 -0
  30. package/src/core/__workshop__/index.ts +16 -0
  31. package/src/core/components/autocomplete/__workshop__/async.tsx +7 -7
  32. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +13 -19
  33. package/src/core/components/autocomplete/__workshop__/custom.tsx +19 -17
  34. package/src/core/components/autocomplete/__workshop__/example.tsx +16 -15
  35. package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +6 -6
  36. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +58 -60
  37. package/src/core/components/autocomplete/__workshop__/index.ts +5 -3
  38. package/src/core/components/autocomplete/{__mocks__ → __workshop__/mock}/apiStore.ts +1 -1
  39. package/src/core/components/autocomplete/{__mocks__ → __workshop__/mock}/countries.ts +1 -1
  40. package/src/core/components/autocomplete/autocomplete.tsx +121 -160
  41. package/src/core/components/autocomplete/autocompleteOption.tsx +4 -4
  42. package/src/core/components/autocomplete/autocompleteReducer.ts +1 -1
  43. package/src/core/components/autocomplete/constants.ts +2 -2
  44. package/src/core/components/autocomplete/types.ts +4 -9
  45. package/src/core/components/breadcrumbs/__workshop__/example.tsx +3 -4
  46. package/src/core/components/breadcrumbs/__workshop__/index.ts +5 -3
  47. package/src/core/components/breadcrumbs/breadcrumbs.tsx +62 -30
  48. package/src/core/components/dialog/__workshop__/activate.tsx +17 -10
  49. package/src/core/components/dialog/__workshop__/autoFocus.tsx +3 -3
  50. package/src/core/components/dialog/__workshop__/index.ts +5 -3
  51. package/src/core/components/dialog/__workshop__/layering.tsx +1 -1
  52. package/src/core/components/dialog/__workshop__/nested.tsx +5 -6
  53. package/src/core/components/dialog/__workshop__/onScroll.tsx +17 -5
  54. package/src/core/components/dialog/__workshop__/panes.tsx +13 -6
  55. package/src/core/components/dialog/__workshop__/position.tsx +5 -5
  56. package/src/core/components/dialog/__workshop__/props.tsx +9 -7
  57. package/src/core/components/dialog/__workshop__/provider.tsx +1 -1
  58. package/src/core/components/dialog/__workshop__/wrapped.tsx +3 -3
  59. package/src/core/components/dialog/dialog.tsx +117 -319
  60. package/src/core/components/dialog/dialogCard.tsx +233 -0
  61. package/src/core/components/dialog/dialogContext.ts +8 -7
  62. package/src/core/components/dialog/dialogProvider.tsx +7 -8
  63. package/src/core/components/dialog/isTargetWithinScope.ts +14 -0
  64. package/src/core/{types/dialog.ts → components/dialog/types.ts} +1 -3
  65. package/src/core/components/dialog/useDialog.ts +1 -1
  66. package/src/core/components/hotkeys/__workshop__/index.ts +5 -3
  67. package/src/core/components/hotkeys/__workshop__/plain.tsx +1 -1
  68. package/src/core/components/hotkeys/hotkeys.tsx +42 -44
  69. package/src/core/components/menu/__workshop__/asComponent.tsx +7 -7
  70. package/src/core/components/menu/__workshop__/avatarMenu.tsx +13 -7
  71. package/src/core/components/menu/__workshop__/closableMenuButton.tsx +6 -5
  72. package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +4 -5
  73. package/src/core/components/menu/__workshop__/customMenuItem.tsx +4 -4
  74. package/src/core/components/menu/__workshop__/customSelectedState.tsx +2 -6
  75. package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +2 -2
  76. package/src/core/components/menu/__workshop__/groups.tsx +3 -3
  77. package/src/core/components/menu/__workshop__/index.ts +5 -3
  78. package/src/core/components/menu/__workshop__/menuButton.tsx +6 -6
  79. package/src/core/components/menu/__workshop__/menuGroupRight.tsx +2 -2
  80. package/src/core/components/menu/__workshop__/nestedMenu.tsx +2 -2
  81. package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +14 -5
  82. package/src/core/components/menu/__workshop__/selectedItem.tsx +3 -3
  83. package/src/core/components/menu/__workshop__/shouldFocus.tsx +2 -7
  84. package/src/core/components/menu/__workshop__/tones.tsx +6 -6
  85. package/src/core/components/menu/__workshop__/withoutArrow.tsx +2 -2
  86. package/src/core/components/menu/helpers.ts +1 -1
  87. package/src/core/components/menu/menu.test.tsx +18 -17
  88. package/src/core/components/menu/menu.tsx +48 -46
  89. package/src/core/components/menu/menuButton.tsx +40 -83
  90. package/src/core/components/menu/menuContext.ts +6 -16
  91. package/src/core/components/menu/menuDivider.tsx +32 -0
  92. package/src/core/components/menu/menuGroup.tsx +67 -51
  93. package/src/core/components/menu/menuItem.tsx +76 -72
  94. package/src/core/components/menu/useMenu.ts +1 -1
  95. package/src/core/components/menu/useMenuController.ts +17 -7
  96. package/src/core/components/tab/__workshop__/example.tsx +3 -3
  97. package/src/core/components/tab/__workshop__/index.ts +5 -3
  98. package/src/core/components/tab/tab.tsx +43 -35
  99. package/src/core/components/tab/tabList.tsx +53 -33
  100. package/src/core/components/tab/tabPanel.tsx +30 -22
  101. package/src/core/components/toast/__workshop__/hook.tsx +2 -2
  102. package/src/core/components/toast/__workshop__/index.ts +5 -3
  103. package/src/core/components/toast/__workshop__/toast.tsx +6 -6
  104. package/src/core/components/toast/toast.test.tsx +15 -13
  105. package/src/core/components/toast/toast.tsx +59 -66
  106. package/src/core/components/toast/toastContext.ts +5 -5
  107. package/src/core/components/toast/toastLayer.tsx +35 -32
  108. package/src/core/components/toast/toastProvider.tsx +20 -21
  109. package/src/core/components/toast/types.ts +6 -8
  110. package/src/core/components/toast/useToast.ts +2 -4
  111. package/src/core/components/tree/__workshop__/basic.perf.ts +2 -2
  112. package/src/core/components/tree/__workshop__/basic.tsx +2 -2
  113. package/src/core/components/tree/__workshop__/index.ts +5 -3
  114. package/src/core/components/tree/__workshop__/tabFromElement.tsx +2 -2
  115. package/src/core/components/tree/helpers.ts +1 -1
  116. package/src/core/components/tree/tree.tsx +198 -187
  117. package/src/core/components/tree/treeContext.ts +5 -5
  118. package/src/core/components/tree/treeGroup.tsx +28 -12
  119. package/src/core/components/tree/treeItem.tsx +90 -58
  120. package/src/core/components/tree/types.ts +4 -1
  121. package/src/core/components/tree/useTree.ts +1 -1
  122. package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +1 -1
  123. package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +1 -1
  124. package/src/core/{utils → components}/virtualList/__workshop__/index.ts +6 -4
  125. package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +2 -2
  126. package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +1 -1
  127. package/src/core/{utils → components}/virtualList/virtualList.tsx +96 -61
  128. package/src/core/constants.ts +4 -16
  129. package/src/core/helpers/focus.ts +0 -8
  130. package/src/core/helpers/props.ts +28 -0
  131. package/src/core/hooks/useClickOutsideEvent.test.tsx +4 -5
  132. package/src/core/hooks/useClickOutsideEvent.ts +3 -9
  133. package/src/core/hooks/useDelayed.test.ts +6 -7
  134. package/src/core/hooks/useDelayedState.ts +1 -1
  135. package/src/core/hooks/useElementSize.ts +1 -1
  136. package/src/core/hooks/useMatchMedia.ts +1 -1
  137. package/src/core/hooks/useMediaIndex/__workshop__/index.ts +5 -3
  138. package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +2 -2
  139. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -18
  140. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +20 -15
  141. package/src/core/hooks/usePrefersDark.hydration.test.tsx +5 -5
  142. package/src/core/hooks/usePrefersDark.test.tsx +1 -0
  143. package/src/core/hooks/usePrefersDark.ts +1 -1
  144. package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +5 -5
  145. package/src/core/hooks/usePrefersReducedMotion.test.tsx +1 -0
  146. package/src/core/hooks/usePrefersReducedMotion.ts +1 -1
  147. package/src/core/hooks/useResponsiveProp.ts +28 -0
  148. package/src/core/index.ts +114 -9
  149. package/src/core/lib/createGlobalScopedContext.ts +6 -3
  150. package/src/core/lib/globalScope.ts +1 -1
  151. package/src/core/lib/isArray.ts +3 -0
  152. package/src/core/middleware/origin.ts +1 -1
  153. package/src/core/observers/{elementSizeObserver.ts → elementSize.ts} +2 -2
  154. package/src/core/primitives/arrow/arrow.tsx +74 -0
  155. package/src/core/primitives/avatar/__workshop__/asButton.tsx +3 -3
  156. package/src/core/primitives/avatar/__workshop__/index.ts +5 -3
  157. package/src/core/primitives/avatar/__workshop__/stack.tsx +3 -3
  158. package/src/core/primitives/avatar/__workshop__/withinButton.tsx +7 -15
  159. package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +28 -26
  160. package/src/core/primitives/avatar/avatar.tsx +77 -122
  161. package/src/core/primitives/avatar/avatarCounter.tsx +52 -77
  162. package/src/core/primitives/avatar/avatarStack.tsx +55 -77
  163. package/src/core/primitives/avatar/types.ts +2 -17
  164. package/src/core/primitives/badge/__workshop__/index.ts +5 -3
  165. package/src/core/primitives/badge/__workshop__/props.tsx +7 -18
  166. package/src/core/primitives/badge/__workshop__/tones.tsx +7 -12
  167. package/src/core/primitives/badge/badge.test.tsx +3 -3
  168. package/src/core/primitives/badge/badge.tsx +41 -42
  169. package/src/core/primitives/box/__workshop__/index.ts +5 -3
  170. package/src/core/primitives/box/__workshop__/props.tsx +3 -3
  171. package/src/core/primitives/box/__workshop__/responsive.tsx +3 -3
  172. package/src/core/primitives/box/box.tsx +188 -97
  173. package/src/core/primitives/button/__workshop__/custom.tsx +20 -44
  174. package/src/core/primitives/button/__workshop__/customIcons.tsx +4 -4
  175. package/src/core/primitives/button/__workshop__/disabled.tsx +41 -61
  176. package/src/core/primitives/button/__workshop__/index.ts +10 -3
  177. package/src/core/primitives/button/__workshop__/mixedChildren.tsx +1 -1
  178. package/src/core/primitives/button/__workshop__/props.tsx +20 -20
  179. package/src/core/primitives/button/__workshop__/sanityUploadButton.tsx +4 -4
  180. package/src/core/primitives/button/__workshop__/stacked.tsx +15 -15
  181. package/src/core/primitives/button/__workshop__/styled1.tsx +1 -1
  182. package/src/core/primitives/button/__workshop__/styled2.tsx +1 -1
  183. package/src/core/primitives/button/__workshop__/textOverflow.tsx +13 -0
  184. package/src/core/primitives/button/__workshop__/uploadButton.tsx +3 -2
  185. package/src/core/primitives/button/button.test.tsx +5 -19
  186. package/src/core/primitives/button/button.tsx +149 -143
  187. package/src/core/primitives/button/types.ts +2 -0
  188. package/src/core/primitives/card/__workshop__/asButton.tsx +15 -15
  189. package/src/core/primitives/card/__workshop__/asComponent.tsx +4 -4
  190. package/src/core/primitives/card/__workshop__/checkered.tsx +4 -4
  191. package/src/core/primitives/card/__workshop__/index.ts +6 -4
  192. package/src/core/primitives/card/__workshop__/interactive.tsx +4 -5
  193. package/src/core/primitives/card/__workshop__/listNavigation.tsx +6 -8
  194. package/src/core/primitives/card/__workshop__/props.tsx +14 -15
  195. package/src/core/primitives/card/__workshop__/selected.tsx +11 -43
  196. package/src/core/primitives/card/__workshop__/styled.tsx +1 -1
  197. package/src/core/primitives/card/__workshop__/tones.tsx +27 -0
  198. package/src/core/primitives/card/card.tsx +77 -84
  199. package/src/core/primitives/card/cardContext.ts +10 -0
  200. package/src/core/primitives/card/cardProvider.tsx +27 -0
  201. package/src/core/primitives/card/types.ts +15 -9
  202. package/src/core/primitives/card/useCard.ts +15 -0
  203. package/src/core/primitives/checkbox/__workshop__/example.tsx +1 -1
  204. package/src/core/primitives/checkbox/__workshop__/index.ts +5 -3
  205. package/src/core/primitives/checkbox/__workshop__/props.tsx +7 -5
  206. package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +1 -1
  207. package/src/core/primitives/checkbox/__workshop__/tones.tsx +20 -21
  208. package/src/core/primitives/checkbox/checkbox.tsx +33 -26
  209. package/src/core/primitives/code/__workshop__/index.ts +5 -3
  210. package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +18 -43
  211. package/src/core/primitives/code/__workshop__/props.tsx +5 -8
  212. package/src/core/primitives/code/code.tsx +33 -25
  213. package/src/core/primitives/code/refractor.tsx +2 -4
  214. package/src/core/primitives/container/__workshop__/example.tsx +3 -3
  215. package/src/core/primitives/container/__workshop__/index.ts +5 -3
  216. package/src/core/primitives/container/container.tsx +27 -31
  217. package/src/core/primitives/flex/__workshop__/example.tsx +3 -3
  218. package/src/core/primitives/flex/__workshop__/gap.tsx +7 -7
  219. package/src/core/primitives/flex/__workshop__/index.ts +5 -3
  220. package/src/core/primitives/flex/flex.tsx +43 -39
  221. package/src/core/primitives/grid/__workshop__/index.ts +5 -3
  222. package/src/core/primitives/grid/__workshop__/responsive.tsx +3 -3
  223. package/src/core/primitives/grid/grid.tsx +22 -35
  224. package/src/core/primitives/heading/__workshop__/index.ts +5 -3
  225. package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +3 -3
  226. package/src/core/primitives/heading/__workshop__/plain.tsx +13 -16
  227. package/src/core/primitives/heading/heading.tsx +60 -62
  228. package/src/core/primitives/inline/__workshop__/index.ts +5 -3
  229. package/src/core/primitives/inline/__workshop__/plain.tsx +3 -6
  230. package/src/core/primitives/inline/inline.tsx +47 -32
  231. package/src/core/primitives/kbd/__workshop__/index.ts +5 -3
  232. package/src/core/primitives/kbd/__workshop__/plain.tsx +1 -1
  233. package/src/core/primitives/kbd/kbd.tsx +43 -47
  234. package/src/core/primitives/label/__workshop__/index.ts +5 -3
  235. package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +14 -8
  236. package/src/core/primitives/label/__workshop__/plain.tsx +16 -12
  237. package/src/core/primitives/label/label.tsx +57 -61
  238. package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +1 -1
  239. package/src/core/{utils → primitives}/layer/__workshop__/index.ts +6 -4
  240. package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +6 -6
  241. package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +4 -4
  242. package/src/core/primitives/layer/__workshop__/responsiveZOffset.tsx +17 -0
  243. package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +3 -1
  244. package/src/core/{utils → primitives}/layer/getLayerContext.ts +1 -1
  245. package/src/core/{utils → primitives}/layer/layer.test.tsx +16 -14
  246. package/src/core/primitives/layer/layer.tsx +42 -0
  247. package/src/core/{utils/layer/layer.tsx → primitives/layer/layerCard.tsx} +40 -48
  248. package/src/core/primitives/layer/layerContext.ts +7 -0
  249. package/src/core/{utils → primitives}/layer/layerProvider.tsx +13 -17
  250. package/src/core/{utils → primitives}/layer/useLayer.ts +2 -4
  251. package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +8 -8
  252. package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +1 -1
  253. package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +4 -4
  254. package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +2 -2
  255. package/src/core/primitives/popover/__workshop__/PlainStory.tsx +3 -3
  256. package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +4 -6
  257. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +20 -13
  258. package/src/core/primitives/popover/__workshop__/TestStory.tsx +10 -7
  259. package/src/core/primitives/popover/__workshop__/index.ts +5 -3
  260. package/src/core/primitives/popover/constants.ts +1 -1
  261. package/src/core/primitives/popover/floating-ui/size.ts +2 -2
  262. package/src/core/primitives/popover/helpers.ts +4 -3
  263. package/src/core/primitives/popover/popover.tsx +310 -351
  264. package/src/core/primitives/popover/popoverLayer.tsx +149 -0
  265. package/src/core/primitives/popover/types.ts +8 -2
  266. package/src/core/primitives/radio/__workshop__/example.tsx +4 -4
  267. package/src/core/primitives/radio/__workshop__/index.ts +5 -3
  268. package/src/core/primitives/radio/__workshop__/plain.tsx +4 -4
  269. package/src/core/primitives/radio/radio.tsx +36 -23
  270. package/src/core/primitives/select/__workshop__/index.ts +5 -3
  271. package/src/core/primitives/select/__workshop__/plain.tsx +18 -6
  272. package/src/core/primitives/select/__workshop__/readOnly.tsx +2 -2
  273. package/src/core/primitives/select/select.tsx +42 -54
  274. package/src/core/primitives/selectable/selectable.tsx +50 -0
  275. package/src/core/{components → primitives}/skeleton/__workshop__/delay.tsx +4 -4
  276. package/src/core/{components → primitives}/skeleton/__workshop__/index.ts +6 -4
  277. package/src/core/{components → primitives}/skeleton/__workshop__/skeleton.tsx +6 -6
  278. package/src/core/primitives/skeleton/codeSkeleton.tsx +49 -0
  279. package/src/core/primitives/skeleton/headingSkeleton.tsx +48 -0
  280. package/src/core/primitives/skeleton/labelSkeleton.tsx +47 -0
  281. package/src/core/primitives/skeleton/skeleton.tsx +70 -0
  282. package/src/core/primitives/skeleton/textSkeleton.tsx +49 -0
  283. package/src/core/primitives/spinner/__workshop__/Props.tsx +4 -4
  284. package/src/core/primitives/spinner/__workshop__/index.ts +5 -3
  285. package/src/core/primitives/spinner/animatedSpinnerIcon.tsx +14 -0
  286. package/src/core/primitives/spinner/spinner.tsx +31 -32
  287. package/src/core/primitives/srOnly/srOnly.tsx +33 -0
  288. package/src/core/primitives/stack/__workshop__/index.ts +5 -3
  289. package/src/core/primitives/stack/__workshop__/plain.tsx +3 -3
  290. package/src/core/primitives/stack/stack.tsx +46 -29
  291. package/src/core/primitives/switch/__workshop__/example.tsx +1 -1
  292. package/src/core/primitives/switch/__workshop__/index.ts +5 -3
  293. package/src/core/primitives/switch/__workshop__/props.tsx +1 -1
  294. package/src/core/primitives/switch/switch.tsx +50 -34
  295. package/src/core/primitives/text/__workshop__/colored.tsx +10 -17
  296. package/src/core/primitives/text/__workshop__/example.tsx +10 -21
  297. package/src/core/primitives/text/__workshop__/index.ts +5 -3
  298. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +18 -43
  299. package/src/core/primitives/text/text.tsx +59 -64
  300. package/src/core/primitives/textArea/__workshop__/index.ts +5 -3
  301. package/src/core/primitives/textArea/__workshop__/plain.tsx +45 -34
  302. package/src/core/primitives/textArea/textArea.tsx +49 -84
  303. package/src/core/primitives/textInput/__workshop__/clearButton.tsx +1 -1
  304. package/src/core/primitives/textInput/__workshop__/customValidity.tsx +3 -3
  305. package/src/core/primitives/textInput/__workshop__/index.ts +5 -3
  306. package/src/core/primitives/textInput/__workshop__/plain.tsx +36 -24
  307. package/src/core/primitives/textInput/__workshop__/readOnly.tsx +1 -1
  308. package/src/core/primitives/textInput/__workshop__/states.tsx +6 -6
  309. package/src/core/primitives/textInput/__workshop__/tones.tsx +3 -3
  310. package/src/core/primitives/textInput/__workshop__/typed.tsx +3 -3
  311. package/src/core/primitives/textInput/textInput.tsx +173 -304
  312. package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +6 -6
  313. package/src/core/primitives/tooltip/__workshop__/index.ts +5 -3
  314. package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +3 -3
  315. package/src/core/primitives/tooltip/__workshop__/props.tsx +14 -9
  316. package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +2 -2
  317. package/src/core/primitives/tooltip/constants.ts +1 -1
  318. package/src/core/primitives/tooltip/tooltip.test.tsx +63 -63
  319. package/src/core/primitives/tooltip/tooltip.tsx +115 -98
  320. package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +5 -3
  321. package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +4 -6
  322. package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +1 -1
  323. package/src/core/primitives/tooltip/tooltipLayer.tsx +106 -0
  324. package/src/core/types.ts +56 -0
  325. package/src/core/utils/boundaryElement/__workshop__/index.ts +5 -3
  326. package/src/core/utils/boundaryElement/__workshop__/plain.tsx +1 -1
  327. package/src/core/utils/boundaryElement/boundaryElement.test.tsx +15 -13
  328. package/src/core/utils/boundaryElement/boundaryElementContext.ts +8 -5
  329. package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +5 -11
  330. package/src/core/utils/boundaryElement/types.ts +1 -3
  331. package/src/core/utils/boundaryElement/useBoundaryElement.ts +2 -4
  332. package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +20 -9
  333. package/src/core/utils/elementQuery/__workshop__/index.ts +5 -3
  334. package/src/core/utils/elementQuery/elementQuery.tsx +42 -20
  335. package/src/core/utils/errorBoundary.tsx +8 -6
  336. package/src/core/utils/getElementRef.ts +4 -1
  337. package/src/core/utils/portal/__workshop__/index.ts +5 -3
  338. package/src/core/utils/portal/__workshop__/named.tsx +4 -4
  339. package/src/core/utils/portal/portal.test.tsx +15 -13
  340. package/src/core/utils/portal/portal.tsx +36 -0
  341. package/src/core/utils/portal/portalContext.ts +16 -10
  342. package/src/core/utils/portal/portalProvider.tsx +10 -19
  343. package/src/core/utils/portal/types.ts +1 -3
  344. package/src/core/utils/portal/usePortal.ts +2 -4
  345. package/src/css/_assign.ts +3 -0
  346. package/src/css/_composeClassNames.ts +12 -0
  347. package/src/css/_fromEntries.ts +3 -0
  348. package/src/css/_getClassNames.ts +9 -0
  349. package/src/css/_responsiveClassName.ts +45 -0
  350. package/src/css/_responsiveStyle.css.ts +34 -0
  351. package/src/css/_style.css.ts +9 -0
  352. package/src/css/components/breadcrumbs/breadcrumbs.css.ts +6 -0
  353. package/src/css/components/breadcrumbs/breadcrumbs.ts +7 -0
  354. package/src/css/components/dialog/dialog.css.ts +98 -0
  355. package/src/css/components/dialog/dialog.ts +58 -0
  356. package/src/css/components/menu/menu.css.ts +14 -0
  357. package/src/css/components/menu/menu.ts +12 -0
  358. package/src/css/components/skeleton/skeleton.css.ts +128 -0
  359. package/src/css/components/skeleton/skeleton.ts +38 -0
  360. package/src/css/components/skeleton/types.ts +36 -0
  361. package/src/css/components/toast/toast.css.ts +17 -0
  362. package/src/css/components/toast/toast.ts +11 -0
  363. package/src/css/components/tree/tree.css.ts +65 -0
  364. package/src/css/components/tree/tree.ts +7 -0
  365. package/src/css/constants.ts +10 -0
  366. package/src/css/getVarName.ts +27 -0
  367. package/src/css/index.ts +146 -0
  368. package/src/css/layers.css.ts +12 -0
  369. package/src/css/primitives/_arrow/_arrow.css.ts +68 -0
  370. package/src/css/primitives/_arrow/_arrow.ts +26 -0
  371. package/src/css/primitives/_input/_input.css.ts +261 -0
  372. package/src/css/primitives/_input/input.ts +29 -0
  373. package/src/css/primitives/_input/types.ts +13 -0
  374. package/src/css/primitives/avatar/avatar.css.ts +197 -0
  375. package/src/css/primitives/avatar/avatar.ts +68 -0
  376. package/src/css/primitives/avatar/types.ts +10 -0
  377. package/src/css/primitives/badge/badge.css.ts +27 -0
  378. package/src/css/primitives/badge/badge.ts +8 -0
  379. package/src/css/primitives/badge/types.ts +13 -0
  380. package/src/css/primitives/box/box.css.ts +19 -0
  381. package/src/css/primitives/box/box.ts +82 -0
  382. package/src/css/primitives/box/types.ts +75 -0
  383. package/src/css/primitives/button/button.css.ts +287 -0
  384. package/src/css/primitives/button/button.ts +26 -0
  385. package/src/css/primitives/button/types.ts +12 -0
  386. package/src/css/primitives/card/__workshop__/color.tsx +75 -0
  387. package/src/css/primitives/card/__workshop__/index.ts +16 -0
  388. package/src/css/primitives/card/card.css.ts +387 -0
  389. package/src/css/primitives/card/card.ts +13 -0
  390. package/src/css/primitives/card/types.ts +9 -0
  391. package/src/css/primitives/checkbox/checkbox.css.ts +193 -0
  392. package/src/css/primitives/checkbox/checkbox.ts +17 -0
  393. package/src/css/primitives/code/code.css.ts +272 -0
  394. package/src/css/primitives/code/code.ts +19 -0
  395. package/src/css/primitives/code/types.ts +11 -0
  396. package/src/css/primitives/container/container.css.ts +4 -0
  397. package/src/css/primitives/container/container.ts +17 -0
  398. package/src/css/primitives/container/types.ts +9 -0
  399. package/src/css/primitives/heading/heading.css.ts +86 -0
  400. package/src/css/primitives/heading/heading.ts +22 -0
  401. package/src/css/primitives/heading/types.ts +14 -0
  402. package/src/css/primitives/kbd/kbd.css.ts +16 -0
  403. package/src/css/primitives/kbd/kbd.ts +9 -0
  404. package/src/css/primitives/kbd/types.ts +6 -0
  405. package/src/css/primitives/label/label.css.ts +87 -0
  406. package/src/css/primitives/label/label.ts +22 -0
  407. package/src/css/primitives/label/types.ts +14 -0
  408. package/src/css/primitives/popover/popover.css.ts +6 -0
  409. package/src/css/primitives/popover/popover.ts +12 -0
  410. package/src/css/primitives/radio/radio.css.ts +78 -0
  411. package/src/css/primitives/radio/radio.ts +17 -0
  412. package/src/css/primitives/root/root.css.ts +19 -0
  413. package/src/css/primitives/root/root.ts +17 -0
  414. package/src/css/primitives/root/types.ts +10 -0
  415. package/src/css/primitives/select/select.css.ts +24 -0
  416. package/src/css/primitives/select/select.ts +14 -0
  417. package/src/css/primitives/select/types.ts +5 -0
  418. package/src/css/primitives/selectable/selectable.css.ts +131 -0
  419. package/src/css/primitives/selectable/selectable.ts +9 -0
  420. package/src/css/primitives/selectable/types.ts +9 -0
  421. package/src/css/primitives/spinner/spinner.css.ts +19 -0
  422. package/src/css/primitives/spinner/spinner.ts +13 -0
  423. package/src/css/primitives/spinner/types.ts +4 -0
  424. package/src/css/primitives/srOnly/srOnly.css.ts +10 -0
  425. package/src/css/primitives/srOnly/srOnly.ts +7 -0
  426. package/src/css/primitives/stack/stack.css.ts +6 -0
  427. package/src/css/primitives/stack/stack.ts +7 -0
  428. package/src/css/primitives/switch/switch.css.ts +98 -0
  429. package/src/css/primitives/switch/switch.ts +27 -0
  430. package/src/css/primitives/text/text.css.ts +86 -0
  431. package/src/css/primitives/text/text.ts +24 -0
  432. package/src/css/primitives/text/types.ts +18 -0
  433. package/src/css/primitives/textArea/textArea.css.ts +4 -0
  434. package/src/css/primitives/textArea/textArea.ts +9 -0
  435. package/src/css/primitives/textArea/types.ts +7 -0
  436. package/src/css/primitives/textInput/textInput.css.ts +43 -0
  437. package/src/css/primitives/textInput/textInput.ts +24 -0
  438. package/src/css/primitives/textInput/types.ts +7 -0
  439. package/src/css/primitives/tooltip/tooltip.css.ts +4 -0
  440. package/src/css/primitives/tooltip/tooltip.ts +8 -0
  441. package/src/css/primitives/tooltip/types.ts +4 -0
  442. package/src/css/props/alignItems/alignItems.css.ts +22 -0
  443. package/src/css/props/alignItems/alignItems.ts +8 -0
  444. package/src/css/props/alignItems/types.ts +9 -0
  445. package/src/css/props/border/border.css.ts +65 -0
  446. package/src/css/props/border/border.ts +21 -0
  447. package/src/css/props/border/types.ts +13 -0
  448. package/src/css/props/boxSizing/boxSizing.css.ts +12 -0
  449. package/src/css/props/boxSizing/boxSizing.ts +7 -0
  450. package/src/css/props/boxSizing/types.ts +7 -0
  451. package/src/css/props/display/display.css.ts +56 -0
  452. package/src/css/props/display/display.ts +8 -0
  453. package/src/css/props/display/types.ts +16 -0
  454. package/src/css/props/flex/flex.css.ts +52 -0
  455. package/src/css/props/flex/flex.ts +8 -0
  456. package/src/css/props/flex/types.ts +9 -0
  457. package/src/css/props/flexDirection/flexDirection.css.ts +19 -0
  458. package/src/css/props/flexDirection/flexDirection.ts +8 -0
  459. package/src/css/props/flexDirection/types.ts +9 -0
  460. package/src/css/props/flexWrap/flexWrap.css.ts +16 -0
  461. package/src/css/props/flexWrap/flexWrap.ts +8 -0
  462. package/src/css/props/flexWrap/types.ts +9 -0
  463. package/src/css/props/font/font.css.ts +94 -0
  464. package/src/css/props/font/font.ts +8 -0
  465. package/src/css/props/font/types.ts +6 -0
  466. package/src/css/props/gap/gap.css.ts +40 -0
  467. package/src/css/props/gap/gap.ts +13 -0
  468. package/src/css/props/gap/types.ts +10 -0
  469. package/src/css/props/gridAutoColumns/gridAutoColumns.css.ts +19 -0
  470. package/src/css/props/gridAutoColumns/gridAutoColumns.ts +8 -0
  471. package/src/css/props/gridAutoColumns/types.ts +9 -0
  472. package/src/css/props/gridAutoFlow/gridAutoFlow.css.ts +19 -0
  473. package/src/css/props/gridAutoFlow/gridAutoFlow.ts +8 -0
  474. package/src/css/props/gridAutoFlow/types.ts +9 -0
  475. package/src/css/props/gridAutoRows/gridAutoRows.css.ts +19 -0
  476. package/src/css/props/gridAutoRows/gridAutoRows.ts +8 -0
  477. package/src/css/props/gridAutoRows/types.ts +9 -0
  478. package/src/css/props/gridColumn/gridColumn.css.ts +49 -0
  479. package/src/css/props/gridColumn/gridColumn.ts +8 -0
  480. package/src/css/props/gridColumn/types.ts +9 -0
  481. package/src/css/props/gridColumnEnd/gridColumnEnd.css.ts +46 -0
  482. package/src/css/props/gridColumnEnd/gridColumnEnd.ts +8 -0
  483. package/src/css/props/gridColumnEnd/types.ts +9 -0
  484. package/src/css/props/gridColumnStart/gridColumnStart.css.ts +46 -0
  485. package/src/css/props/gridColumnStart/gridColumnStart.ts +8 -0
  486. package/src/css/props/gridColumnStart/types.ts +9 -0
  487. package/src/css/props/gridRow/gridRow.css.ts +49 -0
  488. package/src/css/props/gridRow/gridRow.ts +8 -0
  489. package/src/css/props/gridRow/types.ts +9 -0
  490. package/src/css/props/gridRowEnd/gridRowEnd.css.ts +46 -0
  491. package/src/css/props/gridRowEnd/gridRowEnd.ts +8 -0
  492. package/src/css/props/gridRowEnd/types.ts +9 -0
  493. package/src/css/props/gridRowStart/gridRowStart.css.ts +46 -0
  494. package/src/css/props/gridRowStart/gridRowStart.ts +8 -0
  495. package/src/css/props/gridRowStart/types.ts +9 -0
  496. package/src/css/props/gridTemplateColumns/gridTemplateColumns.css.ts +43 -0
  497. package/src/css/props/gridTemplateColumns/gridTemplateColumns.ts +8 -0
  498. package/src/css/props/gridTemplateColumns/types.ts +9 -0
  499. package/src/css/props/gridTemplateRows/gridTemplateRows.css.ts +43 -0
  500. package/src/css/props/gridTemplateRows/gridTemplateRows.ts +8 -0
  501. package/src/css/props/gridTemplateRows/types.ts +9 -0
  502. package/src/css/props/height/height.css.ts +25 -0
  503. package/src/css/props/height/height.ts +8 -0
  504. package/src/css/props/height/types.ts +9 -0
  505. package/src/css/props/inset/inset.css.ts +37 -0
  506. package/src/css/props/inset/inset.ts +21 -0
  507. package/src/css/props/inset/types.ts +13 -0
  508. package/src/css/props/justifyContent/justifyContent.css.ts +25 -0
  509. package/src/css/props/justifyContent/justifyContent.ts +8 -0
  510. package/src/css/props/justifyContent/types.ts +15 -0
  511. package/src/css/props/margin/margin.css.ts +117 -0
  512. package/src/css/props/margin/margin.ts +25 -0
  513. package/src/css/props/margin/types.ts +17 -0
  514. package/src/css/props/maxWidth/maxWidth.css.ts +32 -0
  515. package/src/css/props/maxWidth/maxWidth.ts +8 -0
  516. package/src/css/props/maxWidth/types.ts +11 -0
  517. package/src/css/props/minHeight/minHeight.css.ts +13 -0
  518. package/src/css/props/minHeight/minHeight.ts +8 -0
  519. package/src/css/props/minHeight/types.ts +9 -0
  520. package/src/css/props/minWidth/minWidth.css.ts +25 -0
  521. package/src/css/props/minWidth/minWidth.ts +8 -0
  522. package/src/css/props/minWidth/types.ts +9 -0
  523. package/src/css/props/outline/outline.css.ts +10 -0
  524. package/src/css/props/outline/outline.ts +8 -0
  525. package/src/css/props/outline/types.ts +7 -0
  526. package/src/css/props/overflow/overflow.css.ts +16 -0
  527. package/src/css/props/overflow/overflow.ts +8 -0
  528. package/src/css/props/overflow/types.ts +11 -0
  529. package/src/css/props/padding/padding.css.ts +87 -0
  530. package/src/css/props/padding/padding.ts +25 -0
  531. package/src/css/props/padding/types.ts +17 -0
  532. package/src/css/props/pointerEvents/pointerEvents.css.ts +13 -0
  533. package/src/css/props/pointerEvents/pointerEvents.ts +8 -0
  534. package/src/css/props/pointerEvents/types.ts +7 -0
  535. package/src/css/props/position/position.css.ts +22 -0
  536. package/src/css/props/position/position.ts +8 -0
  537. package/src/css/props/position/types.ts +9 -0
  538. package/src/css/props/radius/radius.css.ts +21 -0
  539. package/src/css/props/radius/radius.ts +8 -0
  540. package/src/css/props/radius/types.ts +8 -0
  541. package/src/css/props/shadow/shadow.css.ts +23 -0
  542. package/src/css/props/shadow/shadow.ts +8 -0
  543. package/src/css/props/shadow/types.ts +8 -0
  544. package/src/css/props/textAlign/textAlign.css.ts +22 -0
  545. package/src/css/props/textAlign/textAlign.ts +8 -0
  546. package/src/css/props/textAlign/types.ts +7 -0
  547. package/src/css/props/textOverflow/textOverflow.css.ts +19 -0
  548. package/src/css/props/textOverflow/textOverflow.ts +8 -0
  549. package/src/css/props/textOverflow/types.ts +12 -0
  550. package/src/css/props/width/types.ts +11 -0
  551. package/src/css/props/width/width.css.ts +31 -0
  552. package/src/css/props/width/width.ts +8 -0
  553. package/src/css/theme/buildCSSTheme.ts +488 -0
  554. package/src/css/theme/defaultTheme.css.ts +64 -0
  555. package/src/css/types.ts +427 -0
  556. package/src/css/vars.css.ts +676 -0
  557. package/src/theme/_parseColorToken.ts +180 -0
  558. package/src/theme/buildTheme.ts +32 -0
  559. package/src/theme/constants.ts +90 -0
  560. package/src/theme/defaults/color.ts +197 -0
  561. package/src/theme/defaults/{config.ts → common.ts} +4 -17
  562. package/src/theme/defaults/fonts.ts +54 -31
  563. package/src/theme/index.ts +5 -5
  564. package/src/theme/{build/merge.ts → merge.ts} +6 -8
  565. package/src/theme/resolveTokens.ts +204 -0
  566. package/src/theme/types.ts +366 -0
  567. package/dist/_chunks-cjs/_visual-editing.js +0 -5409
  568. package/dist/_chunks-cjs/_visual-editing.js.map +0 -1
  569. package/dist/_chunks-cjs/refractor.js.map +0 -1
  570. package/dist/_chunks-es/_visual-editing.mjs +0 -5415
  571. package/dist/_chunks-es/_visual-editing.mjs.map +0 -1
  572. package/dist/_chunks-es/refractor.mjs.map +0 -1
  573. package/dist/_visual-editing.d.mts +0 -1011
  574. package/dist/_visual-editing.d.ts +0 -1011
  575. package/dist/_visual-editing.js +0 -31
  576. package/dist/_visual-editing.js.map +0 -1
  577. package/dist/_visual-editing.mjs +0 -31
  578. package/dist/_visual-editing.mjs.map +0 -1
  579. package/dist/index.d.mts +0 -2966
  580. package/dist/index.mjs +0 -1726
  581. package/dist/index.mjs.map +0 -1
  582. package/dist/theme.d.mts +0 -1500
  583. package/dist/theme.mjs +0 -4112
  584. package/dist/theme.mjs.map +0 -1
  585. package/exports/_visual-editing.ts +0 -31
  586. package/src/core/__workshop__/constants.ts +0 -293
  587. package/src/core/_compat.ts +0 -264
  588. package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -39
  589. package/src/core/components/autocomplete/index.ts +0 -2
  590. package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -18
  591. package/src/core/components/breadcrumbs/index.ts +0 -1
  592. package/src/core/components/dialog/index.ts +0 -4
  593. package/src/core/components/dialog/styles.ts +0 -77
  594. package/src/core/components/hotkeys/index.ts +0 -1
  595. package/src/core/components/index.ts +0 -9
  596. package/src/core/components/menu/index.ts +0 -5
  597. package/src/core/components/menu/menuDivider.ts +0 -12
  598. package/src/core/components/skeleton/index.ts +0 -2
  599. package/src/core/components/skeleton/skeleton.tsx +0 -57
  600. package/src/core/components/skeleton/styles.ts +0 -50
  601. package/src/core/components/skeleton/textSkeleton.tsx +0 -123
  602. package/src/core/components/tab/index.ts +0 -3
  603. package/src/core/components/toast/index.ts +0 -4
  604. package/src/core/components/toast/styles.ts +0 -77
  605. package/src/core/components/tree/index.ts +0 -4
  606. package/src/core/components/tree/style.ts +0 -105
  607. package/src/core/global.ts +0 -6
  608. package/src/core/helpers/index.ts +0 -4
  609. package/src/core/hooks/index.ts +0 -12
  610. package/src/core/hooks/useArrayProp.ts +0 -31
  611. package/src/core/hooks/useClickOutside.test.tsx +0 -482
  612. package/src/core/hooks/useClickOutside.ts +0 -117
  613. package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
  614. package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
  615. package/src/core/hooks/useElementRect/index.ts +0 -1
  616. package/src/core/hooks/useElementRect/useElementRect.ts +0 -13
  617. package/src/core/hooks/useForwardedRef.ts +0 -19
  618. package/src/core/hooks/useIsomorphicEffect.ts +0 -7
  619. package/src/core/hooks/useMediaIndex/index.ts +0 -1
  620. package/src/core/observers/index.ts +0 -2
  621. package/src/core/primitives/_selectable/index.ts +0 -1
  622. package/src/core/primitives/_selectable/selectable.tsx +0 -15
  623. package/src/core/primitives/_selectable/style.ts +0 -115
  624. package/src/core/primitives/avatar/index.ts +0 -4
  625. package/src/core/primitives/avatar/styles.ts +0 -167
  626. package/src/core/primitives/badge/index.ts +0 -1
  627. package/src/core/primitives/badge/styles.ts +0 -20
  628. package/src/core/primitives/badge/types.ts +0 -8
  629. package/src/core/primitives/box/index.ts +0 -1
  630. package/src/core/primitives/button/index.ts +0 -1
  631. package/src/core/primitives/button/styles.ts +0 -117
  632. package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
  633. package/src/core/primitives/card/index.ts +0 -2
  634. package/src/core/primitives/card/styles.ts +0 -147
  635. package/src/core/primitives/checkbox/index.ts +0 -1
  636. package/src/core/primitives/checkbox/styles.ts +0 -128
  637. package/src/core/primitives/code/index.ts +0 -1
  638. package/src/core/primitives/code/styles.ts +0 -77
  639. package/src/core/primitives/container/index.ts +0 -2
  640. package/src/core/primitives/container/styles.ts +0 -23
  641. package/src/core/primitives/flex/index.ts +0 -1
  642. package/src/core/primitives/grid/index.ts +0 -1
  643. package/src/core/primitives/heading/index.ts +0 -1
  644. package/src/core/primitives/heading/styles.ts +0 -64
  645. package/src/core/primitives/heading/types.ts +0 -7
  646. package/src/core/primitives/index.ts +0 -27
  647. package/src/core/primitives/inline/index.ts +0 -1
  648. package/src/core/primitives/inline/styles.ts +0 -32
  649. package/src/core/primitives/inline/types.ts +0 -6
  650. package/src/core/primitives/kbd/index.ts +0 -1
  651. package/src/core/primitives/label/index.ts +0 -1
  652. package/src/core/primitives/label/styles.ts +0 -45
  653. package/src/core/primitives/popover/index.ts +0 -2
  654. package/src/core/primitives/popover/popoverCard.tsx +0 -168
  655. package/src/core/primitives/radio/index.ts +0 -1
  656. package/src/core/primitives/radio/styles.ts +0 -117
  657. package/src/core/primitives/select/index.ts +0 -1
  658. package/src/core/primitives/select/styles.ts +0 -166
  659. package/src/core/primitives/spinner/index.ts +0 -1
  660. package/src/core/primitives/stack/index.ts +0 -1
  661. package/src/core/primitives/stack/styles.ts +0 -32
  662. package/src/core/primitives/switch/index.ts +0 -1
  663. package/src/core/primitives/switch/styles.ts +0 -173
  664. package/src/core/primitives/text/index.ts +0 -1
  665. package/src/core/primitives/text/styles.ts +0 -74
  666. package/src/core/primitives/textArea/index.ts +0 -1
  667. package/src/core/primitives/textInput/index.ts +0 -1
  668. package/src/core/primitives/tooltip/index.ts +0 -2
  669. package/src/core/primitives/tooltip/tooltipCard.tsx +0 -111
  670. package/src/core/primitives/types.ts +0 -146
  671. package/src/core/styles/border/borderStyle.ts +0 -56
  672. package/src/core/styles/border/index.ts +0 -2
  673. package/src/core/styles/border/types.ts +0 -10
  674. package/src/core/styles/box/boxStyle.ts +0 -69
  675. package/src/core/styles/box/index.ts +0 -2
  676. package/src/core/styles/box/types.ts +0 -11
  677. package/src/core/styles/card/_cardColorStyle.ts +0 -108
  678. package/src/core/styles/card/index.ts +0 -1
  679. package/src/core/styles/flex/flexItemStyle.ts +0 -27
  680. package/src/core/styles/flex/flexStyle.ts +0 -70
  681. package/src/core/styles/flex/index.ts +0 -3
  682. package/src/core/styles/flex/types.ts +0 -25
  683. package/src/core/styles/focusRing/index.ts +0 -25
  684. package/src/core/styles/font/codeFontStyle.ts +0 -13
  685. package/src/core/styles/font/headingFontStyle.ts +0 -13
  686. package/src/core/styles/font/index.ts +0 -6
  687. package/src/core/styles/font/labelFontStyle.ts +0 -13
  688. package/src/core/styles/font/responsiveFont.ts +0 -101
  689. package/src/core/styles/font/textAlignStyle.ts +0 -19
  690. package/src/core/styles/font/textFontStyle.ts +0 -13
  691. package/src/core/styles/font/types.ts +0 -35
  692. package/src/core/styles/grid/gridItemStyle.ts +0 -82
  693. package/src/core/styles/grid/gridStyle.ts +0 -108
  694. package/src/core/styles/grid/index.ts +0 -3
  695. package/src/core/styles/grid/types.ts +0 -37
  696. package/src/core/styles/helpers.ts +0 -72
  697. package/src/core/styles/index.ts +0 -5
  698. package/src/core/styles/input/index.ts +0 -2
  699. package/src/core/styles/input/responsiveInputPaddingStyle.ts +0 -78
  700. package/src/core/styles/input/textInputStyle.ts +0 -263
  701. package/src/core/styles/internal.ts +0 -12
  702. package/src/core/styles/margin/index.ts +0 -2
  703. package/src/core/styles/margin/marginStyle.ts +0 -21
  704. package/src/core/styles/margin/marginsStyle.test.ts +0 -33
  705. package/src/core/styles/margin/types.ts +0 -9
  706. package/src/core/styles/padding/index.ts +0 -2
  707. package/src/core/styles/padding/paddingStyle.test.ts +0 -33
  708. package/src/core/styles/padding/paddingStyle.ts +0 -21
  709. package/src/core/styles/padding/types.ts +0 -12
  710. package/src/core/styles/radius/index.ts +0 -2
  711. package/src/core/styles/radius/radiusStyle.ts +0 -23
  712. package/src/core/styles/radius/types.ts +0 -8
  713. package/src/core/styles/shadow/index.ts +0 -2
  714. package/src/core/styles/shadow/shadowStyle.ts +0 -29
  715. package/src/core/styles/shadow/types.ts +0 -6
  716. package/src/core/styles/types.ts +0 -8
  717. package/src/core/theme/__workshop__/build/Root.tsx +0 -367
  718. package/src/core/theme/__workshop__/build/helpers.ts +0 -46
  719. package/src/core/theme/__workshop__/build/story.tsx +0 -465
  720. package/src/core/theme/__workshop__/canvas.tsx +0 -351
  721. package/src/core/theme/__workshop__/color.tsx +0 -62
  722. package/src/core/theme/__workshop__/debug/story.tsx +0 -408
  723. package/src/core/theme/__workshop__/index.ts +0 -39
  724. package/src/core/theme/__workshop__/layer.tsx +0 -78
  725. package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
  726. package/src/core/theme/index.ts +0 -5
  727. package/src/core/theme/theme.test.tsx +0 -73
  728. package/src/core/theme/themeColorProvider.tsx +0 -29
  729. package/src/core/theme/themeContext.ts +0 -10
  730. package/src/core/theme/themeProvider.tsx +0 -62
  731. package/src/core/theme/types.ts +0 -12
  732. package/src/core/theme/useRootTheme.ts +0 -17
  733. package/src/core/theme/useTheme.ts +0 -16
  734. package/src/core/types/avatar.ts +0 -14
  735. package/src/core/types/badge.ts +0 -12
  736. package/src/core/types/box.ts +0 -19
  737. package/src/core/types/button.ts +0 -21
  738. package/src/core/types/card.ts +0 -6
  739. package/src/core/types/flex.ts +0 -30
  740. package/src/core/types/grid.ts +0 -14
  741. package/src/core/types/gridItem.ts +0 -29
  742. package/src/core/types/index.ts +0 -14
  743. package/src/core/types/placement.ts +0 -18
  744. package/src/core/types/popover.ts +0 -4
  745. package/src/core/types/radius.ts +0 -4
  746. package/src/core/types/selectable.ts +0 -6
  747. package/src/core/types/text.ts +0 -4
  748. package/src/core/utils/arrow/arrow.tsx +0 -123
  749. package/src/core/utils/arrow/index.ts +0 -1
  750. package/src/core/utils/boundaryElement/index.ts +0 -3
  751. package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +0 -21
  752. package/src/core/utils/conditionalWrapper/index.ts +0 -1
  753. package/src/core/utils/elementQuery/index.ts +0 -1
  754. package/src/core/utils/index.ts +0 -9
  755. package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
  756. package/src/core/utils/layer/index.ts +0 -4
  757. package/src/core/utils/layer/layerContext.ts +0 -7
  758. package/src/core/utils/portal/index.ts +0 -4
  759. package/src/core/utils/portal/portal.ts +0 -32
  760. package/src/core/utils/spanWithTextOverflow.tsx +0 -10
  761. package/src/core/utils/srOnly/index.ts +0 -1
  762. package/src/core/utils/srOnly/srOnly.tsx +0 -36
  763. package/src/core/utils/virtualList/index.ts +0 -1
  764. package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -76
  765. package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +0 -54
  766. package/src/theme/build/_deprecated/color/button/createButtonModes.ts +0 -22
  767. package/src/theme/build/_deprecated/color/button/createButtonTones.ts +0 -55
  768. package/src/theme/build/_deprecated/color/card/createCardStates.ts +0 -60
  769. package/src/theme/build/_deprecated/color/color.test.ts +0 -63
  770. package/src/theme/build/_deprecated/color/defaults.ts +0 -390
  771. package/src/theme/build/_deprecated/color/factory.ts +0 -142
  772. package/src/theme/build/_deprecated/color/index.ts +0 -1
  773. package/src/theme/build/_deprecated/color/input/createInputModes.ts +0 -81
  774. package/src/theme/build/_deprecated/color/muted/createMuted.ts +0 -54
  775. package/src/theme/build/_deprecated/color/spot/createSpot.ts +0 -20
  776. package/src/theme/build/buildColorTheme.test.ts +0 -183
  777. package/src/theme/build/buildColorTheme.ts +0 -494
  778. package/src/theme/build/buildTheme.test.ts +0 -87
  779. package/src/theme/build/buildTheme.ts +0 -36
  780. package/src/theme/build/colorToken/colorToken.ts +0 -19
  781. package/src/theme/build/colorToken/compileColorToken.ts +0 -21
  782. package/src/theme/build/colorToken/index.ts +0 -2
  783. package/src/theme/build/colorToken/types.ts +0 -6
  784. package/src/theme/build/index.ts +0 -3
  785. package/src/theme/build/lib/color-fns/blend/index.ts +0 -3
  786. package/src/theme/build/lib/color-fns/blend/mix.ts +0 -21
  787. package/src/theme/build/lib/color-fns/blend/multiply.ts +0 -18
  788. package/src/theme/build/lib/color-fns/blend/screen.ts +0 -18
  789. package/src/theme/build/lib/color-fns/color-fns.test.ts +0 -68
  790. package/src/theme/build/lib/color-fns/contrastRatio.ts +0 -31
  791. package/src/theme/build/lib/color-fns/convert.ts +0 -150
  792. package/src/theme/build/lib/color-fns/index.ts +0 -6
  793. package/src/theme/build/lib/color-fns/parse.ts +0 -60
  794. package/src/theme/build/lib/color-fns/rgba.ts +0 -10
  795. package/src/theme/build/lib/color-fns/types.ts +0 -28
  796. package/src/theme/build/lib/isRecord.ts +0 -3
  797. package/src/theme/build/lib/utils.ts +0 -19
  798. package/src/theme/build/mixThemeColor.test.ts +0 -21
  799. package/src/theme/build/mixThemeColor.ts +0 -53
  800. package/src/theme/build/renderColorTheme.ts +0 -532
  801. package/src/theme/build/renderColorValue.ts +0 -85
  802. package/src/theme/build/resolveColorTokens.ts +0 -268
  803. package/src/theme/build/theme.test.ts +0 -27
  804. package/src/theme/config/helpers.ts +0 -55
  805. package/src/theme/config/index.ts +0 -4
  806. package/src/theme/config/system.ts +0 -115
  807. package/src/theme/config/tokens/color/index.ts +0 -1
  808. package/src/theme/config/tokens/color/types.ts +0 -133
  809. package/src/theme/config/tokens/index.ts +0 -4
  810. package/src/theme/config/tokens/parseTokenKey.test.ts +0 -64
  811. package/src/theme/config/tokens/parseTokenKey.ts +0 -67
  812. package/src/theme/config/tokens/parseTokenValue.test.ts +0 -42
  813. package/src/theme/config/tokens/parseTokenValue.ts +0 -133
  814. package/src/theme/config/tokens/types.ts +0 -53
  815. package/src/theme/config/types.ts +0 -46
  816. package/src/theme/defaults/colorPalette.ts +0 -5
  817. package/src/theme/defaults/colorTokens.ts +0 -648
  818. package/src/theme/getScopedTheme.ts +0 -91
  819. package/src/theme/system/avatar.ts +0 -14
  820. package/src/theme/system/color/_constants.ts +0 -45
  821. package/src/theme/system/color/_helpers.ts +0 -24
  822. package/src/theme/system/color/_system.ts +0 -40
  823. package/src/theme/system/color/avatar.ts +0 -15
  824. package/src/theme/system/color/badge.ts +0 -16
  825. package/src/theme/system/color/button.ts +0 -17
  826. package/src/theme/system/color/color.ts +0 -34
  827. package/src/theme/system/color/index.ts +0 -13
  828. package/src/theme/system/color/input.ts +0 -25
  829. package/src/theme/system/color/kbd.ts +0 -8
  830. package/src/theme/system/color/selectable.ts +0 -12
  831. package/src/theme/system/color/shadow.ts +0 -7
  832. package/src/theme/system/color/state.ts +0 -43
  833. package/src/theme/system/color/syntax.ts +0 -41
  834. package/src/theme/system/css.ts +0 -8
  835. package/src/theme/system/focusRing.ts +0 -7
  836. package/src/theme/system/font.ts +0 -52
  837. package/src/theme/system/index.ts +0 -11
  838. package/src/theme/system/input.ts +0 -33
  839. package/src/theme/system/layer.ts +0 -8
  840. package/src/theme/system/shadow.ts +0 -19
  841. package/src/theme/system/styles.ts +0 -13
  842. package/src/theme/system/theme.ts +0 -138
  843. package/src/theme/system/v0/avatar.ts +0 -10
  844. package/src/theme/system/v0/color/_generic.ts +0 -35
  845. package/src/theme/system/v0/color/_system.ts +0 -17
  846. package/src/theme/system/v0/color/base.ts +0 -21
  847. package/src/theme/system/v0/color/button.ts +0 -42
  848. package/src/theme/system/v0/color/card.ts +0 -19
  849. package/src/theme/system/v0/color/color.ts +0 -40
  850. package/src/theme/system/v0/color/index.ts +0 -11
  851. package/src/theme/system/v0/color/input.ts +0 -34
  852. package/src/theme/system/v0/color/muted.ts +0 -26
  853. package/src/theme/system/v0/color/selectable.ts +0 -31
  854. package/src/theme/system/v0/color/solid.ts +0 -26
  855. package/src/theme/system/v0/color/spot.ts +0 -13
  856. package/src/theme/system/v0/index.ts +0 -3
  857. package/src/theme/system/v0/input.ts +0 -23
  858. package/src/theme/versioning/getTheme_v2.ts +0 -57
  859. package/src/theme/versioning/index.ts +0 -5
  860. package/src/theme/versioning/is_v0.ts +0 -6
  861. package/src/theme/versioning/is_v2.ts +0 -6
  862. package/src/theme/versioning/themeColor_v0_v2.ts +0 -243
  863. package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -49
  864. package/src/theme/versioning/v0_v2.ts +0 -94
  865. package/src/theme/versioning/v2_v0.ts +0 -127
  866. /package/src/core/observers/{resizeObserver.ts → resize.ts} +0 -0
  867. /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
  868. /package/src/core/{utils → primitives}/layer/types.ts +0 -0
package/dist/theme.js CHANGED
@@ -1,1123 +1,310 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var color = require("@sanity/color");
4
- function createSelectableTones(opts, base, dark, solid, muted) {
5
- return {
6
- default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
7
- primary: _createSelectableStates(opts, base, dark, solid, muted, "primary"),
8
- positive: _createSelectableStates(opts, base, dark, solid, muted, "positive"),
9
- caution: _createSelectableStates(opts, base, dark, solid, muted, "caution"),
10
- critical: _createSelectableStates(opts, base, dark, solid, muted, "critical")
11
- };
12
- }
13
- function _createSelectableStates(opts, base, dark, solid, muted, tone) {
14
- return {
15
- enabled: opts.selectable({
16
- base,
17
- dark,
18
- solid,
19
- muted,
20
- state: "enabled",
21
- tone
22
- }),
23
- hovered: opts.selectable({
24
- base,
25
- dark,
26
- solid,
27
- muted,
28
- state: "hovered",
29
- tone
30
- }),
31
- pressed: opts.selectable({
32
- base,
33
- dark,
34
- solid,
35
- muted,
36
- state: "pressed",
37
- tone
38
- }),
39
- selected: opts.selectable({
40
- base,
41
- dark,
42
- solid,
43
- muted,
44
- state: "selected",
45
- tone
46
- }),
47
- disabled: opts.selectable({
48
- base,
49
- dark,
50
- solid,
51
- muted,
52
- state: "disabled",
53
- tone
54
- })
55
- };
1
+ import { hues, white, black } from "@sanity/color";
2
+ const HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], AVATAR_SIZE = [0, 1, 2, 3], CONTAINER_SCALE = [0, 1, 2, 3, 4, 5], CONTAINER = [...CONTAINER_SCALE, "auto"], RADIUS = [0, 1, 2, 3, 4, 5, 6], SPACE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5], FONT_TEXT_SIZE = [0, 1, 2, 3, 4], SHADOW = [0, 1, 2, 3, 4, 5], COLOR_SCHEMES = ["light", "dark"], COLOR_VARIANTS = ["tinted", "solid"], AVATAR_COLORS = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], CARD_TONES = [
3
+ "transparent",
4
+ "default",
5
+ "neutral",
6
+ "primary",
7
+ // selections
8
+ "suggest",
9
+ "positive",
10
+ "caution",
11
+ "critical"
12
+ ], ELEMENT_TONES = [
13
+ "default",
14
+ "neutral",
15
+ "primary",
16
+ // selections
17
+ "suggest",
18
+ "positive",
19
+ "caution",
20
+ "critical"
21
+ ], BUTTON_MODES = ["default", "ghost", "bleed"], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
22
+ function _parseColorToken(str, options) {
23
+ const {
24
+ defaultHue
25
+ } = options;
26
+ let cursor = 0;
27
+ return parseColorNode();
28
+ function _consume(s) {
29
+ if (str.startsWith(s, cursor))
30
+ return cursor += s.length, s;
31
+ }
32
+ function _peek() {
33
+ return str[cursor];
34
+ }
35
+ function parseColorNode() {
36
+ ignoreWhitespace();
37
+ let v = _consume("black") || _consume("white");
38
+ if (v)
39
+ return {
40
+ type: "color",
41
+ name: v,
42
+ opacity: parseOpacity() ?? 1,
43
+ mix: parseMix() ?? 1
44
+ };
45
+ for (const hue of HUES)
46
+ if (v = _consume(String(hue)), v) {
47
+ if (_peek() !== "-")
48
+ throw new Error('Expected "-" after hue key');
49
+ cursor += 1;
50
+ const tint2 = parseTint();
51
+ if (!tint2)
52
+ throw new Error("Expected tint after hue");
53
+ return {
54
+ type: "tint",
55
+ hue,
56
+ tint: tint2,
57
+ opacity: parseOpacity() ?? 1,
58
+ mix: parseMix() ?? 1
59
+ };
60
+ }
61
+ const tint = parseTint();
62
+ if (tint)
63
+ return {
64
+ type: "tint",
65
+ hue: defaultHue,
66
+ tint,
67
+ opacity: parseOpacity() ?? 1,
68
+ mix: parseMix() ?? 1
69
+ };
70
+ if (str === "inherit")
71
+ return {
72
+ type: "inherit"
73
+ };
74
+ throw new Error(`Invalid color: ${str}`);
75
+ }
76
+ function parseTint() {
77
+ ignoreWhitespace();
78
+ let v = Number(str.slice(cursor, cursor + 3));
79
+ if (TINTS.includes(v))
80
+ return cursor += 3, v;
81
+ if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
82
+ return cursor += 2, v;
83
+ }
84
+ function parseMix() {
85
+ ignoreWhitespace();
86
+ const match = RE_PERCENTAGE.exec(str.slice(cursor));
87
+ if (match)
88
+ return cursor += match[0].length, parseFloat(match[1]) / 100;
89
+ }
90
+ function parseOpacity() {
91
+ if (ignoreWhitespace(), _peek() === "/") {
92
+ cursor += 1;
93
+ const match = RE_OPACITY.exec(str.slice(cursor));
94
+ if (match)
95
+ return cursor += match[0].length, parseFloat(match[1]);
96
+ cursor -= 1;
97
+ }
98
+ }
99
+ function ignoreWhitespace() {
100
+ for (; _peek() === " "; )
101
+ cursor++;
102
+ }
56
103
  }
57
- function createSolidTones(opts, base, dark, name) {
58
- return {
59
- default: {
60
- enabled: opts.solid({
61
- base,
62
- dark,
63
- tone: "default",
64
- name,
65
- state: "enabled"
66
- }),
67
- disabled: opts.solid({
68
- base,
69
- dark,
70
- tone: "default",
71
- name,
72
- state: "disabled"
73
- }),
74
- hovered: opts.solid({
75
- base,
76
- dark,
77
- tone: "default",
78
- name,
79
- state: "hovered"
80
- }),
81
- pressed: opts.solid({
82
- base,
83
- dark,
84
- tone: "default",
85
- name,
86
- state: "pressed"
87
- }),
88
- selected: opts.solid({
89
- base,
90
- dark,
91
- tone: "default",
92
- name,
93
- state: "selected"
94
- })
95
- },
96
- transparent: {
97
- enabled: opts.solid({
98
- base,
99
- dark,
100
- tone: "transparent",
101
- name,
102
- state: "enabled"
103
- }),
104
- disabled: opts.solid({
105
- base,
106
- dark,
107
- tone: "transparent",
108
- name,
109
- state: "disabled"
110
- }),
111
- hovered: opts.solid({
112
- base,
113
- dark,
114
- tone: "transparent",
115
- name,
116
- state: "hovered"
117
- }),
118
- pressed: opts.solid({
119
- base,
120
- dark,
121
- tone: "transparent",
122
- name,
123
- state: "pressed"
124
- }),
125
- selected: opts.solid({
126
- base,
127
- dark,
128
- tone: "transparent",
129
- name,
130
- state: "selected"
131
- })
132
- },
133
- primary: {
134
- enabled: opts.solid({
135
- base,
136
- dark,
137
- tone: "primary",
138
- name,
139
- state: "enabled"
140
- }),
141
- disabled: opts.solid({
142
- base,
143
- dark,
144
- tone: "primary",
145
- name,
146
- state: "disabled"
147
- }),
148
- hovered: opts.solid({
149
- base,
150
- dark,
151
- tone: "primary",
152
- name,
153
- state: "hovered"
154
- }),
155
- pressed: opts.solid({
156
- base,
157
- dark,
158
- tone: "primary",
159
- name,
160
- state: "pressed"
161
- }),
162
- selected: opts.solid({
163
- base,
164
- dark,
165
- tone: "primary",
166
- name,
167
- state: "selected"
168
- })
104
+ const defaultColor = {
105
+ "*": {
106
+ backdrop: ["gray-100/0.5", "black/0.5"],
107
+ code: {
108
+ bg: ["50", "950"],
109
+ fg: ["700", "300"],
110
+ token: {
111
+ atrule: ["purple-600", "purple-400"],
112
+ attrName: ["green-600", "green-400"],
113
+ attrValue: ["yellow-600", "yellow-400"],
114
+ attribute: ["yellow-600", "yellow-400"],
115
+ boolean: ["purple-600", "purple-400"],
116
+ builtin: ["purple-600", "purple-400"],
117
+ cdata: ["yellow-600", "yellow-400"],
118
+ char: ["yellow-600", "yellow-400"],
119
+ class: ["orange-600", "orange-400"],
120
+ className: ["cyan-600", "cyan-400"],
121
+ comment: ["gray-400", "gray-600"],
122
+ constant: ["purple-600", "purple-400"],
123
+ deleted: ["red-600", "red-400"],
124
+ entity: ["red-600", "red-400"],
125
+ function: ["green-600", "green-400"],
126
+ hexcode: ["blue-600", "blue-400"],
127
+ id: ["purple-600", "purple-400"],
128
+ important: ["purple-600", "purple-400"],
129
+ inserted: ["green-600", "green-400"],
130
+ keyword: ["magenta-600", "magenta-400"],
131
+ number: ["purple-600", "purple-400"],
132
+ operator: ["magenta-600", "magenta-400"],
133
+ prolog: ["gray-600", "gray-400"],
134
+ property: ["blue-600", "blue-400"],
135
+ pseudoClass: ["yellow-600", "yellow-400"],
136
+ pseudoElement: ["yellow-600", "yellow-400"],
137
+ punctuation: ["gray-600", "gray-400"],
138
+ regex: ["blue-600", "blue-400"],
139
+ selector: ["red-600", "red-400"],
140
+ string: ["yellow-600", "yellow-400"],
141
+ symbol: ["purple-600", "purple-400"],
142
+ tag: ["red-600", "red-400"],
143
+ unit: ["orange-600", "orange-400"],
144
+ url: ["red-600", "red-400"],
145
+ variable: ["red-600", "red-400"]
146
+ }
147
+ },
148
+ focusRing: ["blue-500", "blue-500"],
149
+ link: {
150
+ fg: ["blue-600", "blue-400"]
169
151
  },
170
- positive: {
171
- enabled: opts.solid({
172
- base,
173
- dark,
174
- tone: "positive",
175
- name,
176
- state: "enabled"
177
- }),
178
- disabled: opts.solid({
179
- base,
180
- dark,
181
- tone: "positive",
182
- name,
183
- state: "disabled"
184
- }),
185
- hovered: opts.solid({
186
- base,
187
- dark,
188
- tone: "positive",
189
- name,
190
- state: "hovered"
191
- }),
192
- pressed: opts.solid({
193
- base,
194
- dark,
195
- tone: "positive",
196
- name,
197
- state: "pressed"
198
- }),
199
- selected: opts.solid({
200
- base,
201
- dark,
202
- tone: "positive",
203
- name,
204
- state: "selected"
205
- })
152
+ shadow: {
153
+ outline: ["600/0.3", "500/0.4"],
154
+ umbra: ["600/0.1", "black/0.2"],
155
+ penumbra: ["600/0.07", "black/0.14"],
156
+ ambient: ["600/0.06", "black/0.12"]
206
157
  },
207
- caution: {
208
- enabled: opts.solid({
209
- base,
210
- dark,
211
- tone: "caution",
212
- name,
213
- state: "enabled"
214
- }),
215
- disabled: opts.solid({
216
- base,
217
- dark,
218
- tone: "caution",
219
- name,
220
- state: "disabled"
221
- }),
222
- hovered: opts.solid({
223
- base,
224
- dark,
225
- tone: "caution",
226
- name,
227
- state: "hovered"
228
- }),
229
- pressed: opts.solid({
230
- base,
231
- dark,
232
- tone: "caution",
233
- name,
234
- state: "pressed"
235
- }),
236
- selected: opts.solid({
237
- base,
238
- dark,
239
- tone: "caution",
240
- name,
241
- state: "selected"
242
- })
158
+ skeleton: {
159
+ from: ["200 70%", "800 35%"],
160
+ to: ["200 40%", "800 50%"]
243
161
  },
244
- critical: {
245
- enabled: opts.solid({
246
- base,
247
- dark,
248
- tone: "critical",
249
- name,
250
- state: "enabled"
251
- }),
252
- disabled: opts.solid({
253
- base,
254
- dark,
255
- tone: "critical",
256
- name,
257
- state: "disabled"
258
- }),
259
- hovered: opts.solid({
260
- base,
261
- dark,
262
- tone: "critical",
263
- name,
264
- state: "hovered"
265
- }),
266
- pressed: opts.solid({
267
- base,
268
- dark,
269
- tone: "critical",
270
- name,
271
- state: "pressed"
272
- }),
273
- selected: opts.solid({
274
- base,
275
- dark,
276
- tone: "critical",
277
- name,
278
- state: "selected"
279
- })
162
+ variant: {
163
+ tinted: {
164
+ "*": {
165
+ bg: {
166
+ 0: ["100 75%", "900 75%"],
167
+ 4: ["300", "700"]
168
+ },
169
+ border: {
170
+ 0: ["200", "700 50%"],
171
+ 4: ["300 75%", "500"]
172
+ },
173
+ fg: {
174
+ 0: ["900", "100"],
175
+ 4: ["700", "300"]
176
+ }
177
+ },
178
+ primary: {
179
+ _hue: "blue",
180
+ bg: {
181
+ 0: ["inherit", "inherit"]
182
+ }
183
+ },
184
+ suggest: {
185
+ _hue: "purple",
186
+ bg: {
187
+ 0: ["inherit", "inherit"]
188
+ }
189
+ },
190
+ positive: {
191
+ _hue: "green",
192
+ bg: {
193
+ 0: ["inherit", "inherit"]
194
+ }
195
+ },
196
+ caution: {
197
+ _hue: "yellow",
198
+ bg: {
199
+ 0: ["inherit", "inherit"]
200
+ }
201
+ },
202
+ critical: {
203
+ _hue: "red",
204
+ bg: {
205
+ 0: ["inherit", "inherit"]
206
+ }
207
+ }
208
+ },
209
+ solid: {
210
+ "*": {
211
+ bg: {
212
+ 0: ["500", "400"],
213
+ 4: ["600", "300"]
214
+ },
215
+ border: {
216
+ 0: ["400", "200"],
217
+ 4: ["500", "100"]
218
+ },
219
+ fg: {
220
+ 0: ["white", "black"],
221
+ 4: ["200", "700"]
222
+ }
223
+ },
224
+ default: {
225
+ bg: {
226
+ 0: ["800", "200"],
227
+ 4: ["black", "white"]
228
+ },
229
+ border: {
230
+ 0: ["700", "300"],
231
+ 4: ["800", "200"]
232
+ }
233
+ },
234
+ primary: {
235
+ _hue: "blue"
236
+ },
237
+ suggest: {
238
+ _hue: "purple"
239
+ },
240
+ positive: {
241
+ _hue: "green"
242
+ },
243
+ caution: {
244
+ _hue: "yellow"
245
+ },
246
+ critical: {
247
+ _hue: "red"
248
+ }
249
+ }
280
250
  }
281
- };
282
- }
283
- function createButtonTones(opts, base, dark, solid, muted, mode) {
284
- return {
285
- default: opts.button({
286
- base,
287
- dark,
288
- solid: solid.default,
289
- muted: muted.default,
290
- mode
291
- }),
292
- primary: opts.button({
293
- base,
294
- dark,
295
- solid: solid.primary,
296
- muted: muted.primary,
297
- mode
298
- }),
299
- positive: opts.button({
300
- base,
301
- dark,
302
- solid: solid.positive,
303
- muted: muted.positive,
304
- mode
305
- }),
306
- caution: opts.button({
307
- base,
308
- dark,
309
- solid: solid.caution,
310
- muted: muted.caution,
311
- mode
312
- }),
313
- critical: opts.button({
314
- base,
315
- dark,
316
- solid: solid.critical,
317
- muted: muted.critical,
318
- mode
319
- })
320
- };
321
- }
322
- function createButtonModes(opts, base, dark, solid, muted) {
323
- return {
324
- default: createButtonTones(opts, base, dark, solid, muted, "default"),
325
- ghost: createButtonTones(opts, base, dark, solid, muted, "ghost"),
326
- bleed: createButtonTones(opts, base, dark, solid, muted, "bleed")
327
- };
328
- }
329
- function createCardStates(opts, base, dark, name, solid, muted) {
330
- return {
331
- enabled: opts.card({
332
- base,
333
- dark,
334
- name,
335
- state: "enabled",
336
- solid,
337
- muted
338
- }),
339
- disabled: opts.card({
340
- base,
341
- dark,
342
- name,
343
- state: "disabled",
344
- solid,
345
- muted
346
- }),
347
- hovered: opts.card({
348
- base,
349
- dark,
350
- name,
351
- state: "hovered",
352
- solid,
353
- muted
354
- }),
355
- pressed: opts.card({
356
- base,
357
- dark,
358
- name,
359
- state: "pressed",
360
- solid,
361
- muted
362
- }),
363
- selected: opts.card({
364
- base,
365
- dark,
366
- name,
367
- state: "selected",
368
- solid,
369
- muted
370
- })
371
- };
372
- }
373
- const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
374
- default: {
375
- lightest: "hsl(0, 0%, 95%)",
376
- lighter: "hsl(0, 0%, 70%)",
377
- light: "hsl(0, 0%, 65%)",
378
- base: "hsl(0, 0%, 50%)",
379
- dark: "hsl(0, 0%, 35%)",
380
- darker: "hsl(0, 0%, 20%)",
381
- darkest: "hsl(0, 0%, 5%)"
382
251
  },
383
252
  transparent: {
384
- lightest: "hsl(240, 100%, 95%)",
385
- lighter: "hsl(240, 100%, 70%)",
386
- light: "hsl(240, 100%, 65%)",
387
- base: "hsl(240, 100%, 50%)",
388
- dark: "hsl(240, 100%, 35%)",
389
- darker: "hsl(240, 100%, 20%)",
390
- darkest: "hsl(240, 100%, 5%)"
391
- },
392
- primary: {
393
- lightest: "hsl(240, 100%, 95%)",
394
- lighter: "hsl(240, 100%, 70%)",
395
- light: "hsl(240, 100%, 65%)",
396
- base: "hsl(240, 100%, 50%)",
397
- dark: "hsl(240, 100%, 35%)",
398
- darker: "hsl(240, 100%, 20%)",
399
- darkest: "hsl(240, 100%, 5%)"
400
- },
401
- positive: {
402
- lightest: "hsl(120, 100%, 95%)",
403
- lighter: "hsl(120, 100%, 70%)",
404
- light: "hsl(120, 100%, 65%)",
405
- base: "hsl(120, 100%, 50%)",
406
- dark: "hsl(120, 100%, 35%)",
407
- darker: "hsl(120, 100%, 20%)",
408
- darkest: "hsl(120, 100%, 5%)"
409
- },
410
- caution: {
411
- lightest: "hsl(60, 100%, 95%)",
412
- lighter: "hsl(60, 100%, 70%)",
413
- light: "hsl(60, 100%, 65%)",
414
- base: "hsl(60, 100%, 50%)",
415
- dark: "hsl(60, 100%, 35%)",
416
- darker: "hsl(60, 100%, 20%)",
417
- darkest: "hsl(60, 100%, 5%)"
253
+ variant: {
254
+ tinted: {
255
+ "*": {
256
+ bg: {
257
+ 0: ["gray-50", "black"],
258
+ 4: ["300 75%", "700 75%"]
259
+ },
260
+ border: {
261
+ 0: ["200", "800 75%"],
262
+ 4: ["400", "700"]
263
+ },
264
+ fg: {
265
+ 0: ["black", "100"],
266
+ 4: ["700", "400"]
267
+ }
268
+ }
269
+ }
270
+ }
418
271
  },
419
- critical: {
420
- lightest: "hsl(0, 100%, 95%)",
421
- lighter: "hsl(0, 100%, 70%)",
422
- light: "hsl(0, 100%, 65%)",
423
- base: "hsl(0, 100%, 50%)",
424
- dark: "hsl(0, 100%, 35%)",
425
- darker: "hsl(0, 100%, 20%)",
426
- darkest: "hsl(0, 100%, 5%)"
427
- }
428
- }, spots = {
429
- gray: "hsl(0, 0%, 50%)",
430
- red: "hsl(0, 100%, 50%)",
431
- orange: "hsl(30, 100%, 50%)",
432
- yellow: "hsl(60, 100%, 50%)",
433
- green: "hsl(120, 100%, 50%)",
434
- cyan: "hsl(180, 100%, 50%)",
435
- blue: "hsl(240, 100%, 50%)",
436
- purple: "hsl(270, 100%, 50%)",
437
- magenta: "hsl(300, 100%, 50%)"
438
- }, tones = {
439
- transparent: {
440
- bg: [colors.transparent.darkest, colors.transparent.lightest],
441
- fg: [colors.transparent.lightest, colors.transparent.darkest],
442
- border: [colors.transparent.darker, colors.transparent.lighter],
443
- focusRing: [colors.transparent.base, colors.transparent.base]
272
+ default: {
273
+ variant: {
274
+ tinted: {
275
+ "*": {
276
+ bg: {
277
+ 0: ["white", "950"],
278
+ 4: ["300 75%", "700"]
279
+ },
280
+ border: {
281
+ 0: ["100", "800 75%"],
282
+ 4: ["300", "700"]
283
+ },
284
+ fg: {
285
+ 0: ["black", "white"],
286
+ 4: ["600", "400"]
287
+ }
288
+ }
289
+ }
290
+ }
444
291
  },
445
292
  primary: {
446
- bg: [colors.primary.darkest, colors.primary.lightest],
447
- fg: [colors.primary.lightest, colors.primary.darkest],
448
- border: [colors.primary.darker, colors.primary.lighter],
449
- focusRing: [colors.primary.base, colors.primary.base]
293
+ _hue: "blue"
294
+ },
295
+ suggest: {
296
+ _hue: "purple"
450
297
  },
451
298
  positive: {
452
- bg: [colors.positive.darkest, colors.positive.lightest],
453
- fg: [colors.positive.lightest, colors.positive.darkest],
454
- border: [colors.positive.darker, colors.positive.lighter],
455
- focusRing: [colors.positive.base, colors.positive.base]
299
+ _hue: "green"
456
300
  },
457
301
  caution: {
458
- bg: [colors.caution.darkest, colors.caution.lightest],
459
- fg: [colors.caution.lightest, colors.caution.darkest],
460
- border: [colors.caution.darker, colors.caution.lighter],
461
- focusRing: [colors.caution.base, colors.caution.base]
302
+ _hue: "yellow"
462
303
  },
463
304
  critical: {
464
- bg: [colors.critical.darkest, colors.critical.lightest],
465
- fg: [colors.critical.lightest, colors.critical.darkest],
466
- border: [colors.critical.darker, colors.critical.lighter],
467
- focusRing: [colors.critical.base, colors.critical.base]
305
+ _hue: "red"
468
306
  }
469
- }, defaultOpts = {
470
- base: ({
471
- dark,
472
- name
473
- }) => name === "default" ? {
474
- bg: dark ? black : white,
475
- fg: dark ? white : black,
476
- border: dark ? colors.default.darkest : colors.default.lightest,
477
- focusRing: colors.primary.base,
478
- shadow: {
479
- outline: black,
480
- umbra: black,
481
- penumbra: black,
482
- ambient: black
483
- },
484
- skeleton: {
485
- from: dark ? white : black,
486
- to: dark ? white : black
487
- }
488
- } : {
489
- bg: tones[name].bg[dark ? 0 : 1],
490
- fg: tones[name].fg[dark ? 0 : 1],
491
- border: tones[name].border[dark ? 0 : 1],
492
- focusRing: tones[name].focusRing[dark ? 0 : 1],
493
- shadow: {
494
- outline: black,
495
- umbra: black,
496
- penumbra: black,
497
- ambient: black
498
- },
499
- skeleton: {
500
- from: dark ? white : black,
501
- to: dark ? white : black
502
- }
503
- },
504
- solid: ({
505
- base,
506
- dark,
507
- state,
508
- tone
509
- }) => {
510
- const color2 = colors[tone];
511
- return state === "hovered" ? {
512
- bg: dark ? color2.light : color2.dark,
513
- bg2: dark ? color2.light : color2.dark,
514
- border: dark ? color2.lighter : color2.darker,
515
- fg: dark ? color2.darkest : color2.lightest,
516
- icon: dark ? color2.darkest : color2.lightest,
517
- muted: {
518
- fg: black
519
- },
520
- accent: {
521
- fg: black
522
- },
523
- link: {
524
- fg: black
525
- },
526
- code: {
527
- bg: black,
528
- fg: black
529
- },
530
- skeleton: base.skeleton
531
- } : {
532
- bg: color2.base,
533
- bg2: color2.base,
534
- border: dark ? color2.light : color2.dark,
535
- fg: dark ? color2.darkest : color2.lightest,
536
- icon: dark ? color2.darkest : color2.lightest,
537
- muted: {
538
- fg: black
539
- },
540
- accent: {
541
- fg: black
542
- },
543
- link: {
544
- fg: black
545
- },
546
- code: {
547
- bg: black,
548
- fg: black
549
- },
550
- skeleton: base.skeleton
551
- };
552
- },
553
- muted: ({
554
- base,
555
- dark,
556
- state,
557
- tone
558
- }) => {
559
- const color2 = colors[tone];
560
- return state === "hovered" ? {
561
- bg: dark ? color2.darker : color2.lighter,
562
- bg2: dark ? color2.darker : color2.lighter,
563
- border: dark ? color2.lighter : color2.darker,
564
- fg: dark ? color2.lightest : color2.darkest,
565
- icon: dark ? color2.lightest : color2.darkest,
566
- muted: {
567
- fg: black
568
- },
569
- accent: {
570
- fg: black
571
- },
572
- link: {
573
- fg: black
574
- },
575
- code: {
576
- bg: black,
577
- fg: black
578
- },
579
- skeleton: base.skeleton
580
- } : {
581
- bg: dark ? color2.darkest : color2.lightest,
582
- bg2: dark ? color2.darkest : color2.lightest,
583
- border: dark ? color2.darker : color2.lighter,
584
- fg: dark ? color2.lighter : color2.darker,
585
- icon: dark ? color2.lighter : color2.darker,
586
- muted: {
587
- fg: black
588
- },
589
- accent: {
590
- fg: black
591
- },
592
- link: {
593
- fg: black
594
- },
595
- code: {
596
- bg: black,
597
- fg: black
598
- },
599
- skeleton: base.skeleton
600
- };
601
- },
602
- button: ({
603
- base,
604
- mode,
605
- muted,
606
- solid
607
- }) => mode === "bleed" ? {
608
- ...muted,
609
- enabled: {
610
- bg: "transparent",
611
- bg2: "transparent",
612
- fg: muted.enabled.fg,
613
- icon: muted.enabled.fg,
614
- border: "transparent",
615
- muted: {
616
- fg: black
617
- },
618
- accent: {
619
- fg: black
620
- },
621
- link: {
622
- fg: black
623
- },
624
- code: {
625
- bg: black,
626
- fg: black
627
- },
628
- skeleton: base.skeleton
629
- },
630
- hovered: {
631
- bg: muted.enabled.bg,
632
- bg2: muted.enabled.bg,
633
- fg: muted.hovered.fg,
634
- icon: muted.hovered.fg,
635
- border: "transparent",
636
- muted: {
637
- fg: black
638
- },
639
- accent: {
640
- fg: black
641
- },
642
- link: {
643
- fg: black
644
- },
645
- code: {
646
- bg: black,
647
- fg: black
648
- },
649
- skeleton: base.skeleton
650
- }
651
- } : mode === "ghost" ? {
652
- ...solid,
653
- enabled: muted.enabled
654
- } : solid,
655
- card: ({
656
- base
657
- }) => ({
658
- bg: black,
659
- bg2: black,
660
- fg: black,
661
- icon: black,
662
- border: black,
663
- muted: {
664
- fg: black
665
- },
666
- accent: {
667
- fg: black
668
- },
669
- link: {
670
- fg: black
671
- },
672
- code: {
673
- bg: black,
674
- fg: black
675
- },
676
- skeleton: base.skeleton
677
- }),
678
- input: () => ({
679
- bg: black,
680
- bg2: black,
681
- fg: black,
682
- border: black,
683
- placeholder: black
684
- }),
685
- selectable: ({
686
- muted,
687
- state,
688
- tone
689
- }) => muted[tone][state],
690
- spot: ({
691
- key
692
- }) => spots[key],
693
- syntax: () => ({
694
- atrule: black,
695
- attrName: black,
696
- attrValue: black,
697
- attribute: black,
698
- boolean: black,
699
- builtin: black,
700
- cdata: black,
701
- char: black,
702
- class: black,
703
- className: black,
704
- comment: black,
705
- constant: black,
706
- deleted: black,
707
- doctype: black,
708
- entity: black,
709
- function: black,
710
- hexcode: black,
711
- id: black,
712
- important: black,
713
- inserted: black,
714
- keyword: black,
715
- number: black,
716
- operator: black,
717
- prolog: black,
718
- property: black,
719
- pseudoClass: black,
720
- pseudoElement: black,
721
- punctuation: black,
722
- regex: black,
723
- selector: black,
724
- string: black,
725
- symbol: black,
726
- tag: black,
727
- unit: black,
728
- url: black,
729
- variable: black
730
- })
731
- };
732
- function createInputModes(opts, base, dark, solid, muted) {
733
- return {
734
- default: {
735
- enabled: opts.input({
736
- base,
737
- dark,
738
- mode: "default",
739
- state: "enabled",
740
- solid: solid.default,
741
- muted: muted.default
742
- }),
743
- disabled: opts.input({
744
- base,
745
- dark,
746
- mode: "default",
747
- state: "disabled",
748
- solid: solid.default,
749
- muted: muted.default
750
- }),
751
- hovered: opts.input({
752
- base,
753
- dark,
754
- mode: "default",
755
- state: "hovered",
756
- solid: solid.default,
757
- muted: muted.default
758
- }),
759
- readOnly: opts.input({
760
- base,
761
- dark,
762
- mode: "default",
763
- state: "readOnly",
764
- solid: solid.default,
765
- muted: muted.default
766
- })
767
- },
768
- invalid: {
769
- enabled: opts.input({
770
- base,
771
- dark,
772
- mode: "invalid",
773
- state: "enabled",
774
- solid: solid.default,
775
- muted: muted.default
776
- }),
777
- disabled: opts.input({
778
- base,
779
- dark,
780
- mode: "invalid",
781
- state: "disabled",
782
- solid: solid.default,
783
- muted: muted.default
784
- }),
785
- hovered: opts.input({
786
- base,
787
- dark,
788
- mode: "invalid",
789
- state: "hovered",
790
- solid: solid.default,
791
- muted: muted.default
792
- }),
793
- readOnly: opts.input({
794
- base,
795
- dark,
796
- mode: "invalid",
797
- state: "readOnly",
798
- solid: solid.default,
799
- muted: muted.default
800
- })
801
- }
802
- };
803
- }
804
- function createMutedTones(opts, base, dark, name) {
805
- return {
806
- default: {
807
- enabled: opts.muted({
808
- base,
809
- dark,
810
- tone: "default",
811
- name,
812
- state: "enabled"
813
- }),
814
- disabled: opts.muted({
815
- base,
816
- dark,
817
- tone: "default",
818
- name,
819
- state: "disabled"
820
- }),
821
- hovered: opts.muted({
822
- base,
823
- dark,
824
- tone: "default",
825
- name,
826
- state: "hovered"
827
- }),
828
- pressed: opts.muted({
829
- base,
830
- dark,
831
- tone: "default",
832
- name,
833
- state: "pressed"
834
- }),
835
- selected: opts.muted({
836
- base,
837
- dark,
838
- tone: "default",
839
- name,
840
- state: "selected"
841
- })
842
- },
843
- transparent: {
844
- enabled: opts.muted({
845
- base,
846
- dark,
847
- tone: "transparent",
848
- name,
849
- state: "enabled"
850
- }),
851
- disabled: opts.muted({
852
- base,
853
- dark,
854
- tone: "transparent",
855
- name,
856
- state: "disabled"
857
- }),
858
- hovered: opts.muted({
859
- base,
860
- dark,
861
- tone: "transparent",
862
- name,
863
- state: "hovered"
864
- }),
865
- pressed: opts.muted({
866
- base,
867
- dark,
868
- tone: "transparent",
869
- name,
870
- state: "pressed"
871
- }),
872
- selected: opts.muted({
873
- base,
874
- dark,
875
- tone: "transparent",
876
- name,
877
- state: "selected"
878
- })
879
- },
880
- primary: {
881
- enabled: opts.muted({
882
- base,
883
- dark,
884
- tone: "primary",
885
- name,
886
- state: "enabled"
887
- }),
888
- disabled: opts.muted({
889
- base,
890
- dark,
891
- tone: "primary",
892
- name,
893
- state: "disabled"
894
- }),
895
- hovered: opts.muted({
896
- base,
897
- dark,
898
- tone: "primary",
899
- name,
900
- state: "hovered"
901
- }),
902
- pressed: opts.muted({
903
- base,
904
- dark,
905
- tone: "primary",
906
- name,
907
- state: "pressed"
908
- }),
909
- selected: opts.muted({
910
- base,
911
- dark,
912
- tone: "primary",
913
- name,
914
- state: "selected"
915
- })
916
- },
917
- positive: {
918
- enabled: opts.muted({
919
- base,
920
- dark,
921
- tone: "positive",
922
- name,
923
- state: "enabled"
924
- }),
925
- disabled: opts.muted({
926
- base,
927
- dark,
928
- tone: "positive",
929
- name,
930
- state: "disabled"
931
- }),
932
- hovered: opts.muted({
933
- base,
934
- dark,
935
- tone: "positive",
936
- name,
937
- state: "hovered"
938
- }),
939
- pressed: opts.muted({
940
- base,
941
- dark,
942
- tone: "positive",
943
- name,
944
- state: "pressed"
945
- }),
946
- selected: opts.muted({
947
- base,
948
- dark,
949
- tone: "positive",
950
- name,
951
- state: "selected"
952
- })
953
- },
954
- caution: {
955
- enabled: opts.muted({
956
- base,
957
- dark,
958
- tone: "caution",
959
- name,
960
- state: "enabled"
961
- }),
962
- disabled: opts.muted({
963
- base,
964
- dark,
965
- tone: "caution",
966
- name,
967
- state: "disabled"
968
- }),
969
- hovered: opts.muted({
970
- base,
971
- dark,
972
- tone: "caution",
973
- name,
974
- state: "hovered"
975
- }),
976
- pressed: opts.muted({
977
- base,
978
- dark,
979
- tone: "caution",
980
- name,
981
- state: "pressed"
982
- }),
983
- selected: opts.muted({
984
- base,
985
- dark,
986
- tone: "caution",
987
- name,
988
- state: "selected"
989
- })
990
- },
991
- critical: {
992
- enabled: opts.muted({
993
- base,
994
- dark,
995
- tone: "critical",
996
- name,
997
- state: "enabled"
998
- }),
999
- disabled: opts.muted({
1000
- base,
1001
- dark,
1002
- tone: "critical",
1003
- name,
1004
- state: "disabled"
1005
- }),
1006
- hovered: opts.muted({
1007
- base,
1008
- dark,
1009
- tone: "critical",
1010
- name,
1011
- state: "hovered"
1012
- }),
1013
- pressed: opts.muted({
1014
- base,
1015
- dark,
1016
- tone: "critical",
1017
- name,
1018
- state: "pressed"
1019
- }),
1020
- selected: opts.muted({
1021
- base,
1022
- dark,
1023
- tone: "critical",
1024
- name,
1025
- state: "selected"
1026
- })
1027
- }
1028
- };
1029
- }
1030
- function createSpot(opts, base, dark) {
1031
- return {
1032
- gray: opts.spot({
1033
- base,
1034
- dark,
1035
- key: "gray"
1036
- }),
1037
- blue: opts.spot({
1038
- base,
1039
- dark,
1040
- key: "blue"
1041
- }),
1042
- purple: opts.spot({
1043
- base,
1044
- dark,
1045
- key: "purple"
1046
- }),
1047
- magenta: opts.spot({
1048
- base,
1049
- dark,
1050
- key: "magenta"
1051
- }),
1052
- red: opts.spot({
1053
- base,
1054
- dark,
1055
- key: "red"
1056
- }),
1057
- orange: opts.spot({
1058
- base,
1059
- dark,
1060
- key: "orange"
1061
- }),
1062
- yellow: opts.spot({
1063
- base,
1064
- dark,
1065
- key: "yellow"
1066
- }),
1067
- green: opts.spot({
1068
- base,
1069
- dark,
1070
- key: "green"
1071
- }),
1072
- cyan: opts.spot({
1073
- base,
1074
- dark,
1075
- key: "cyan"
1076
- })
1077
- };
1078
- }
1079
- function createColorTheme(partialOpts = {}) {
1080
- const builders = {
1081
- ...defaultOpts,
1082
- ...partialOpts
1083
- };
1084
- return {
1085
- light: _createColorScheme(builders, !1),
1086
- dark: _createColorScheme(builders, !0)
1087
- };
1088
- }
1089
- function _createColorScheme(opts, dark) {
1090
- return {
1091
- default: _createColor(opts, dark, "default"),
1092
- transparent: _createColor(opts, dark, "transparent"),
1093
- primary: _createColor(opts, dark, "primary"),
1094
- positive: _createColor(opts, dark, "positive"),
1095
- caution: _createColor(opts, dark, "caution"),
1096
- critical: _createColor(opts, dark, "critical")
1097
- };
1098
- }
1099
- function _createColor(opts, dark, name) {
1100
- const base = opts.base({
1101
- dark,
1102
- name
1103
- }), solid = createSolidTones(opts, base, dark, name), muted = createMutedTones(opts, base, dark, name);
1104
- return {
1105
- base,
1106
- button: createButtonModes(opts, base, dark, solid, muted),
1107
- card: createCardStates(opts, base, dark, name, solid, muted),
1108
- dark,
1109
- input: createInputModes(opts, base, dark, solid, muted),
1110
- selectable: createSelectableTones(opts, base, dark, solid, muted),
1111
- spot: createSpot(opts, base, dark),
1112
- syntax: opts.syntax({
1113
- base,
1114
- dark
1115
- }),
1116
- solid,
1117
- muted
1118
- };
1119
- }
1120
- const defaultThemeConfig = {
307
+ }, defaultTheme = {
1121
308
  avatar: {
1122
309
  sizes: [{
1123
310
  distance: -4,
@@ -1172,8 +359,8 @@ const defaultThemeConfig = {
1172
359
  zOffset: 200
1173
360
  }
1174
361
  },
1175
- radius: [0, 1, 3, 6, 9, 12, 21],
1176
- shadow: [null, {
362
+ radius: [0, 1, 3, 7, 11, 15, 23, 43, 75, 127],
363
+ shadow: [void 0, {
1177
364
  umbra: [0, 0, 0, 0],
1178
365
  penumbra: [0, 0, 0, 0],
1179
366
  ambient: [0, 0, 0, 0]
@@ -1237,2876 +424,447 @@ const defaultThemeConfig = {
1237
424
  width: 1
1238
425
  }
1239
426
  }
1240
- },
1241
- style: {
1242
- button: {
1243
- root: {
1244
- transition: "background-color 100ms,border-color 100ms,color 100ms"
1245
- }
1246
- }
1247
- // card: {
1248
- // root: {
1249
- // transition: 'background-color 100ms,border-color 100ms,color 100ms',
1250
- // },
1251
- // },
1252
427
  }
1253
- }, defaultThemeFonts = {
428
+ }, defaultFonts = {
1254
429
  code: {
1255
430
  family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
1256
- weights: {
431
+ weight: {
1257
432
  regular: 400,
1258
433
  medium: 500,
1259
434
  semibold: 600,
1260
435
  bold: 700
1261
436
  },
1262
- sizes: [{
437
+ scale: [{
1263
438
  ascenderHeight: 4,
1264
439
  descenderHeight: 4,
1265
440
  fontSize: 10,
1266
441
  iconSize: 17,
1267
442
  lineHeight: 15,
1268
- letterSpacing: 0
443
+ letterSpacing: 0,
444
+ customIconSize: 12
1269
445
  }, {
1270
446
  ascenderHeight: 5,
1271
447
  descenderHeight: 5,
1272
448
  fontSize: 13,
1273
449
  iconSize: 21,
1274
450
  lineHeight: 19,
1275
- letterSpacing: 0
451
+ letterSpacing: 0,
452
+ customIconSize: 16
1276
453
  }, {
1277
454
  ascenderHeight: 6,
1278
455
  descenderHeight: 6,
1279
456
  fontSize: 16,
1280
457
  iconSize: 25,
1281
458
  lineHeight: 23,
1282
- letterSpacing: 0
459
+ letterSpacing: 0,
460
+ customIconSize: 20
1283
461
  }, {
1284
462
  ascenderHeight: 7,
1285
463
  descenderHeight: 7,
1286
- fontSize: 19,
464
+ fontSize: 18.75,
1287
465
  iconSize: 29,
1288
466
  lineHeight: 27,
1289
- letterSpacing: 0
467
+ letterSpacing: 0,
468
+ customIconSize: 24
1290
469
  }, {
1291
470
  ascenderHeight: 8,
1292
471
  descenderHeight: 8,
1293
- fontSize: 22,
472
+ fontSize: 21.5,
1294
473
  iconSize: 33,
1295
474
  lineHeight: 31,
1296
- letterSpacing: 0
475
+ letterSpacing: 0,
476
+ customIconSize: 28
1297
477
  }]
1298
478
  },
1299
479
  heading: {
1300
480
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1301
- weights: {
1302
- regular: 700,
1303
- medium: 800,
1304
- semibold: 900,
481
+ featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
482
+ weight: {
483
+ regular: 600,
484
+ medium: 700,
485
+ semibold: 800,
1305
486
  bold: 900
1306
487
  },
1307
- sizes: [{
488
+ scale: [{
1308
489
  ascenderHeight: 5,
1309
490
  descenderHeight: 5,
1310
491
  fontSize: 13,
1311
492
  iconSize: 17,
1312
493
  lineHeight: 19,
1313
- letterSpacing: 0
494
+ letterSpacing: 0,
495
+ customIconSize: 12
1314
496
  }, {
1315
497
  ascenderHeight: 6,
1316
498
  descenderHeight: 6,
1317
499
  fontSize: 16,
1318
500
  iconSize: 25,
1319
501
  lineHeight: 23,
1320
- letterSpacing: 0
502
+ letterSpacing: 0,
503
+ customIconSize: 20
1321
504
  }, {
1322
505
  ascenderHeight: 7,
1323
506
  descenderHeight: 7,
1324
507
  fontSize: 21,
1325
508
  iconSize: 33,
1326
509
  lineHeight: 29,
1327
- letterSpacing: 0
510
+ letterSpacing: -0.25,
511
+ customIconSize: 28
1328
512
  }, {
1329
513
  ascenderHeight: 8,
1330
514
  descenderHeight: 8,
1331
515
  fontSize: 27,
1332
516
  iconSize: 41,
1333
517
  lineHeight: 35,
1334
- letterSpacing: 0
518
+ letterSpacing: -0.5,
519
+ customIconSize: 36
1335
520
  }, {
1336
521
  ascenderHeight: 9.5,
1337
522
  descenderHeight: 8.5,
1338
523
  fontSize: 33,
1339
524
  iconSize: 49,
1340
525
  lineHeight: 41,
1341
- letterSpacing: 0
526
+ letterSpacing: -1,
527
+ customIconSize: 44
1342
528
  }, {
1343
529
  ascenderHeight: 10.5,
1344
530
  descenderHeight: 9.5,
1345
531
  fontSize: 38,
1346
532
  iconSize: 53,
1347
533
  lineHeight: 47,
1348
- letterSpacing: 0
534
+ letterSpacing: -1,
535
+ customIconSize: 48
1349
536
  }]
1350
537
  },
1351
538
  label: {
1352
539
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
1353
- weights: {
1354
- regular: 600,
1355
- medium: 700,
1356
- semibold: 800,
1357
- bold: 900
540
+ weight: {
541
+ regular: 500,
542
+ medium: 600,
543
+ semibold: 700,
544
+ bold: 800
1358
545
  },
1359
- sizes: [{
546
+ scale: [{
1360
547
  ascenderHeight: 2,
1361
548
  descenderHeight: 2,
1362
549
  fontSize: 8.1,
1363
550
  iconSize: 13,
1364
551
  lineHeight: 10,
1365
- letterSpacing: 0.5
552
+ letterSpacing: 0.5,
553
+ customIconSize: 8
1366
554
  }, {
1367
- ascenderHeight: 2,
1368
- descenderHeight: 2,
555
+ ascenderHeight: 1.5,
556
+ descenderHeight: 2.5,
1369
557
  fontSize: 9.5,
1370
558
  iconSize: 15,
1371
559
  lineHeight: 11,
1372
- letterSpacing: 0.5
560
+ letterSpacing: 0.5,
561
+ customIconSize: 10
1373
562
  }, {
1374
563
  ascenderHeight: 2,
1375
564
  descenderHeight: 2,
1376
565
  fontSize: 10.8,
1377
566
  iconSize: 17,
1378
567
  lineHeight: 12,
1379
- letterSpacing: 0.5
568
+ letterSpacing: 0.5,
569
+ customIconSize: 12
1380
570
  }, {
1381
571
  ascenderHeight: 2,
1382
572
  descenderHeight: 2,
1383
573
  fontSize: 12.25,
1384
574
  iconSize: 19,
1385
575
  lineHeight: 13,
1386
- letterSpacing: 0.5
576
+ letterSpacing: 0.5,
577
+ customIconSize: 14
1387
578
  }, {
1388
- ascenderHeight: 2,
1389
- descenderHeight: 2,
579
+ ascenderHeight: 1.5,
580
+ descenderHeight: 2.5,
1390
581
  fontSize: 13.6,
1391
582
  iconSize: 21,
1392
583
  lineHeight: 14,
1393
- letterSpacing: 0.5
584
+ letterSpacing: 0.5,
585
+ customIconSize: 16
1394
586
  }, {
1395
587
  ascenderHeight: 2,
1396
588
  descenderHeight: 2,
1397
589
  fontSize: 15,
1398
590
  iconSize: 23,
1399
591
  lineHeight: 15,
1400
- letterSpacing: 0.5
592
+ letterSpacing: 0.5,
593
+ customIconSize: 18
1401
594
  }]
1402
595
  },
1403
596
  text: {
1404
597
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1405
- weights: {
598
+ weight: {
1406
599
  regular: 400,
1407
600
  medium: 500,
1408
601
  semibold: 600,
1409
602
  bold: 700
1410
603
  },
1411
- sizes: [{
604
+ scale: [{
1412
605
  ascenderHeight: 4,
1413
606
  descenderHeight: 4,
1414
- fontSize: 10,
607
+ fontSize: 9.75,
1415
608
  iconSize: 17,
1416
609
  lineHeight: 15,
1417
- letterSpacing: 0
610
+ letterSpacing: 0,
611
+ customIconSize: 12
1418
612
  }, {
1419
613
  ascenderHeight: 5,
1420
614
  descenderHeight: 5,
1421
- fontSize: 13,
615
+ fontSize: 12.5,
1422
616
  iconSize: 21,
1423
617
  lineHeight: 19,
1424
- letterSpacing: 0
618
+ letterSpacing: 0,
619
+ customIconSize: 16
1425
620
  }, {
1426
621
  ascenderHeight: 6,
1427
622
  descenderHeight: 6,
1428
- fontSize: 15,
623
+ fontSize: 15.25,
1429
624
  iconSize: 25,
1430
625
  lineHeight: 23,
1431
- letterSpacing: 0
626
+ letterSpacing: 0,
627
+ customIconSize: 20
1432
628
  }, {
1433
629
  ascenderHeight: 7,
1434
630
  descenderHeight: 7,
1435
631
  fontSize: 18,
1436
632
  iconSize: 29,
1437
633
  lineHeight: 27,
1438
- letterSpacing: 0
634
+ letterSpacing: 0,
635
+ customIconSize: 24
1439
636
  }, {
1440
637
  ascenderHeight: 8,
1441
638
  descenderHeight: 8,
1442
- fontSize: 21,
639
+ fontSize: 20.75,
1443
640
  iconSize: 33,
1444
641
  lineHeight: 31,
1445
- letterSpacing: 0
642
+ letterSpacing: 0,
643
+ customIconSize: 28
1446
644
  }]
1447
645
  }
1448
- }, cache$4 = /* @__PURE__ */ new WeakMap();
1449
- function themeColor_v0_v2(color_v0) {
1450
- const cached_v2 = cache$4.get(color_v0);
1451
- if (cached_v2) return cached_v2;
1452
- const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
1453
- _blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
1454
- _dark: color_v0.dark,
1455
- accent: base.accent,
1456
- avatar: base.avatar,
1457
- backdrop: color_v0.base.shadow.ambient,
1458
- badge: base.badge,
1459
- bg: color_v0.base.bg,
1460
- border: color_v0.base.border,
1461
- button: {
1462
- default: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.default),
1463
- ghost: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.ghost),
1464
- bleed: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.bleed)
1465
- },
1466
- code: base.code,
1467
- fg: color_v0.base.fg,
1468
- focusRing: color_v0.base.focusRing,
1469
- icon: base.muted.fg,
1470
- input: {
1471
- default: inputStatesThemeColor_v0_v2(color_v0.input.default),
1472
- invalid: inputStatesThemeColor_v0_v2(color_v0.input.invalid)
1473
- },
1474
- kbd: base.kbd,
1475
- link: base.link,
1476
- muted: {
1477
- ...base.muted,
1478
- bg: color_v0.selectable?.default.enabled.bg2 || color_v0.base.bg
1479
- },
1480
- selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
1481
- shadow: color_v0.base.shadow,
1482
- skeleton: {
1483
- from: color_v0.skeleton?.from || color_v0.base.border,
1484
- to: color_v0.skeleton?.to || color_v0.base.border
1485
- },
1486
- syntax: color_v0.syntax
1487
- };
1488
- return cache$4.set(color_v0, color_v2), color_v2;
646
+ };
647
+ function merge(...records) {
648
+ return records.filter(Boolean).reduce(_merge, {});
649
+ }
650
+ function _merge(acc, source) {
651
+ for (const key of Object.keys(source)) {
652
+ const prevValue = acc[key], nextValue = source[key];
653
+ isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
654
+ }
655
+ return acc;
656
+ }
657
+ function isRecord(value) {
658
+ return value !== null && typeof value == "object" && !Array.isArray(value);
1489
659
  }
1490
- function stateTonesThemeColor_v0_v2(v0, t) {
660
+ const defaultElementTokens = {
661
+ bg: {
662
+ 0: ["950", "50"],
663
+ 4: ["700", "300"]
664
+ },
665
+ border: {
666
+ 0: ["700", "300"],
667
+ 4: ["400", "600"]
668
+ },
669
+ fg: {
670
+ 0: ["100", "900"],
671
+ 4: ["400", "600"]
672
+ }
673
+ };
674
+ function resolveTokens(tokens = {}) {
1491
675
  return {
1492
- default: {
1493
- enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
1494
- hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
1495
- pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
1496
- selected: stateThemeColor_v0_v2(v0, t.default.selected),
1497
- disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
1498
- },
1499
- neutral: {
1500
- enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
1501
- hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
1502
- pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
1503
- selected: stateThemeColor_v0_v2(v0, t.default.selected),
1504
- disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
1505
- },
1506
- primary: {
1507
- enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
1508
- hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
1509
- pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
1510
- selected: stateThemeColor_v0_v2(v0, t.primary.selected),
1511
- disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
1512
- },
1513
- suggest: {
1514
- enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
1515
- hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
1516
- pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
1517
- selected: stateThemeColor_v0_v2(v0, t.primary.selected),
1518
- disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
1519
- },
1520
- positive: {
1521
- enabled: stateThemeColor_v0_v2(v0, t.positive.enabled),
1522
- hovered: stateThemeColor_v0_v2(v0, t.positive.hovered),
1523
- pressed: stateThemeColor_v0_v2(v0, t.positive.pressed),
1524
- selected: stateThemeColor_v0_v2(v0, t.positive.selected),
1525
- disabled: stateThemeColor_v0_v2(v0, t.positive.disabled)
1526
- },
1527
- caution: {
1528
- enabled: stateThemeColor_v0_v2(v0, t.caution.enabled),
1529
- hovered: stateThemeColor_v0_v2(v0, t.caution.hovered),
1530
- pressed: stateThemeColor_v0_v2(v0, t.caution.pressed),
1531
- selected: stateThemeColor_v0_v2(v0, t.caution.selected),
1532
- disabled: stateThemeColor_v0_v2(v0, t.caution.disabled)
1533
- },
1534
- critical: {
1535
- enabled: stateThemeColor_v0_v2(v0, t.critical.enabled),
1536
- hovered: stateThemeColor_v0_v2(v0, t.critical.hovered),
1537
- pressed: stateThemeColor_v0_v2(v0, t.critical.pressed),
1538
- selected: stateThemeColor_v0_v2(v0, t.critical.selected),
1539
- disabled: stateThemeColor_v0_v2(v0, t.critical.disabled)
676
+ color: {
677
+ "*": resolveCardColorTokens(tokens.color?.["*"]),
678
+ ...CARD_TONES.reduce((acc, tone) => ({
679
+ ...acc,
680
+ [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
681
+ }), {})
1540
682
  }
1541
683
  };
1542
684
  }
1543
- function stateThemeColor_v0_v2(v0, state) {
685
+ function resolveCardColorTokens(tokens) {
1544
686
  return {
1545
- ...state,
687
+ _hue: tokens?._hue ?? "gray",
1546
688
  avatar: {
1547
689
  gray: {
1548
- bg: v0.spot.gray,
1549
- fg: v0.base.bg
690
+ _hue: tokens?.avatar?.gray?._hue ?? "gray",
691
+ bg: tokens?.avatar?.gray?.bg ?? ["500", "400"],
692
+ fg: tokens?.avatar?.gray?.fg ?? ["white", "900"]
1550
693
  },
1551
694
  blue: {
1552
- bg: v0.spot.blue,
1553
- fg: v0.base.bg
695
+ _hue: tokens?.avatar?.blue?._hue ?? "blue",
696
+ bg: tokens?.avatar?.blue?.bg ?? ["500", "400"],
697
+ fg: tokens?.avatar?.blue?.fg ?? ["white", "900"]
1554
698
  },
1555
699
  purple: {
1556
- bg: v0.spot.purple,
1557
- fg: v0.base.bg
700
+ _hue: tokens?.avatar?.purple?._hue ?? "purple",
701
+ bg: tokens?.avatar?.purple?.bg ?? ["500", "400"],
702
+ fg: tokens?.avatar?.purple?.fg ?? ["white", "900"]
1558
703
  },
1559
704
  magenta: {
1560
- bg: v0.spot.magenta,
1561
- fg: v0.base.bg
705
+ _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
706
+ bg: tokens?.avatar?.magenta?.bg ?? ["500", "400"],
707
+ fg: tokens?.avatar?.magenta?.fg ?? ["white", "900"]
1562
708
  },
1563
709
  red: {
1564
- bg: v0.spot.red,
1565
- fg: v0.base.bg
710
+ _hue: tokens?.avatar?.red?._hue ?? "red",
711
+ bg: tokens?.avatar?.red?.bg ?? ["500", "400"],
712
+ fg: tokens?.avatar?.red?.fg ?? ["white", "900"]
1566
713
  },
1567
714
  orange: {
1568
- bg: v0.spot.orange,
1569
- fg: v0.base.bg
715
+ _hue: tokens?.avatar?.orange?._hue ?? "orange",
716
+ bg: tokens?.avatar?.orange?.bg ?? ["500", "400"],
717
+ fg: tokens?.avatar?.orange?.fg ?? ["white", "900"]
1570
718
  },
1571
719
  yellow: {
1572
- bg: v0.spot.yellow,
1573
- fg: v0.base.bg
720
+ _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
721
+ bg: tokens?.avatar?.yellow?.bg ?? ["500", "400"],
722
+ fg: tokens?.avatar?.yellow?.fg ?? ["white", "900"]
1574
723
  },
1575
724
  green: {
1576
- bg: v0.spot.green,
1577
- fg: v0.base.bg
725
+ _hue: tokens?.avatar?.green?._hue ?? "green",
726
+ bg: tokens?.avatar?.green?.bg ?? ["500", "400"],
727
+ fg: tokens?.avatar?.green?.fg ?? ["white", "900"]
1578
728
  },
1579
729
  cyan: {
1580
- bg: v0.spot.cyan,
1581
- fg: v0.base.bg
1582
- }
1583
- },
1584
- badge: {
1585
- default: {
1586
- bg: v0.muted.default.enabled.bg,
1587
- fg: v0.muted.default.enabled.fg,
1588
- dot: v0.muted.default.enabled.muted.fg,
1589
- icon: v0.muted.default.enabled.muted.fg
1590
- },
1591
- neutral: {
1592
- bg: v0.muted.transparent.enabled.bg,
1593
- fg: v0.muted.transparent.enabled.fg,
1594
- dot: v0.muted.transparent.enabled.muted.fg,
1595
- icon: v0.muted.transparent.enabled.muted.fg
1596
- },
1597
- primary: {
1598
- bg: v0.muted.primary.enabled.bg,
1599
- fg: v0.muted.primary.enabled.fg,
1600
- dot: v0.muted.primary.enabled.muted.fg,
1601
- icon: v0.muted.primary.enabled.muted.fg
1602
- },
1603
- suggest: {
1604
- bg: v0.muted.primary.enabled.bg,
1605
- fg: v0.muted.primary.enabled.fg,
1606
- dot: v0.muted.primary.enabled.muted.fg,
1607
- icon: v0.muted.primary.enabled.muted.fg
1608
- },
1609
- positive: {
1610
- bg: v0.muted.positive.enabled.bg,
1611
- fg: v0.muted.positive.enabled.fg,
1612
- dot: v0.muted.positive.enabled.muted.fg,
1613
- icon: v0.muted.positive.enabled.muted.fg
1614
- },
1615
- caution: {
1616
- bg: v0.muted.caution.enabled.bg,
1617
- fg: v0.muted.caution.enabled.fg,
1618
- dot: v0.muted.caution.enabled.muted.fg,
1619
- icon: v0.muted.caution.enabled.muted.fg
1620
- },
1621
- critical: {
1622
- bg: v0.muted.critical.enabled.bg,
1623
- fg: v0.muted.critical.enabled.fg,
1624
- dot: v0.muted.critical.enabled.muted.fg,
1625
- icon: v0.muted.critical.enabled.muted.fg
730
+ _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
731
+ bg: tokens?.avatar?.cyan?.bg ?? ["500", "400"],
732
+ fg: tokens?.avatar?.cyan?.fg ?? ["white", "900"]
1626
733
  }
1627
734
  },
1628
- kbd: {
1629
- bg: v0.muted.default.enabled.bg,
1630
- fg: v0.muted.default.enabled.fg,
1631
- border: v0.muted.default.enabled.border
735
+ backdrop: tokens?.backdrop ?? ["100", "900"],
736
+ code: {
737
+ bg: tokens?.code?.bg ?? ["50", "950"],
738
+ fg: tokens?.code?.fg ?? ["600", "400"],
739
+ token: {
740
+ atrule: tokens?.code?.token?.atrule ?? ["600", "400"],
741
+ attribute: tokens?.code?.token?.attribute ?? ["600", "400"],
742
+ attrName: tokens?.code?.token?.attrName ?? ["600", "400"],
743
+ attrValue: tokens?.code?.token?.attrValue ?? ["600", "400"],
744
+ boolean: tokens?.code?.token?.boolean ?? ["600", "400"],
745
+ builtin: tokens?.code?.token?.builtin ?? ["600", "400"],
746
+ cdata: tokens?.code?.token?.cdata ?? ["600", "400"],
747
+ char: tokens?.code?.token?.char ?? ["600", "400"],
748
+ class: tokens?.code?.token?.class ?? ["600", "400"],
749
+ className: tokens?.code?.token?.className ?? ["600", "400"],
750
+ comment: tokens?.code?.token?.comment ?? ["400", "600"],
751
+ constant: tokens?.code?.token?.constant ?? ["600", "400"],
752
+ deleted: tokens?.code?.token?.deleted ?? ["600", "400"],
753
+ doctype: tokens?.code?.token?.doctype ?? ["600", "400"],
754
+ entity: tokens?.code?.token?.entity ?? ["600", "400"],
755
+ function: tokens?.code?.token?.function ?? ["600", "400"],
756
+ hexcode: tokens?.code?.token?.hexcode ?? ["600", "400"],
757
+ id: tokens?.code?.token?.id ?? ["600", "400"],
758
+ important: tokens?.code?.token?.important ?? ["600", "400"],
759
+ inserted: tokens?.code?.token?.inserted ?? ["600", "400"],
760
+ keyword: tokens?.code?.token?.keyword ?? ["600", "400"],
761
+ number: tokens?.code?.token?.number ?? ["600", "400"],
762
+ operator: tokens?.code?.token?.operator ?? ["600", "400"],
763
+ prolog: tokens?.code?.token?.prolog ?? ["600", "400"],
764
+ property: tokens?.code?.token?.property ?? ["600", "400"],
765
+ pseudoClass: tokens?.code?.token?.pseudoClass ?? ["600", "400"],
766
+ pseudoElement: tokens?.code?.token?.pseudoElement ?? ["600", "400"],
767
+ punctuation: tokens?.code?.token?.punctuation ?? ["600", "400"],
768
+ regex: tokens?.code?.token?.regex ?? ["600", "400"],
769
+ selector: tokens?.code?.token?.selector ?? ["600", "400"],
770
+ string: tokens?.code?.token?.string ?? ["600", "400"],
771
+ symbol: tokens?.code?.token?.symbol ?? ["600", "400"],
772
+ tag: tokens?.code?.token?.tag ?? ["600", "400"],
773
+ unit: tokens?.code?.token?.unit ?? ["600", "400"],
774
+ url: tokens?.code?.token?.url ?? ["600", "400"],
775
+ variable: tokens?.code?.token?.variable ?? ["600", "400"]
776
+ }
777
+ },
778
+ focusRing: tokens?.focusRing ?? ["500", "500"],
779
+ link: {
780
+ fg: tokens?.link?.fg ?? ["600", "400"]
1632
781
  },
1633
- muted: {
1634
- ...v0.muted.default.enabled.muted,
1635
- bg: state.bg2 || state.bg
782
+ shadow: {
783
+ outline: tokens?.shadow?.outline ?? ["500", "500"],
784
+ umbra: tokens?.shadow?.umbra ?? ["500", "500"],
785
+ penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
786
+ ambient: tokens?.shadow?.ambient ?? ["500", "500"]
1636
787
  },
1637
788
  skeleton: {
1638
- from: state.skeleton?.from || state.border,
1639
- to: state.skeleton?.to || state.border
789
+ from: tokens?.skeleton?.from ?? ["100", "900"],
790
+ to: tokens?.skeleton?.to ?? ["50", "950"]
791
+ },
792
+ variant: {
793
+ solid: {
794
+ "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
795
+ ...ELEMENT_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
796
+ },
797
+ tinted: {
798
+ "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
799
+ ...ELEMENT_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
800
+ }
1640
801
  }
1641
802
  };
1642
803
  }
1643
- function inputStatesThemeColor_v0_v2(states) {
804
+ function resolveElementTokens(tokens) {
1644
805
  return {
1645
- enabled: inputStateThemeColor_v0_v2(states.enabled),
1646
- disabled: inputStateThemeColor_v0_v2(states.disabled),
1647
- readOnly: inputStateThemeColor_v0_v2(states.readOnly),
1648
- hovered: inputStateThemeColor_v0_v2(states.hovered)
1649
- };
1650
- }
1651
- function inputStateThemeColor_v0_v2(state) {
1652
- return {
1653
- bg: state.bg,
1654
- border: state.border,
1655
- fg: state.fg,
1656
- muted: {
1657
- bg: state.bg2
1658
- },
1659
- placeholder: state.placeholder
1660
- };
1661
- }
1662
- const cache$3 = /* @__PURE__ */ new WeakMap();
1663
- function getTheme_v2(theme) {
1664
- if (theme.sanity.v2?._resolved) return theme.sanity.v2;
1665
- const cached_v2 = cache$3.get(theme);
1666
- if (cached_v2) return cached_v2;
1667
- const v2 = {
1668
- _version: 2,
1669
- _resolved: !0,
1670
- avatar: {
1671
- ...defaultThemeConfig.avatar,
1672
- ...theme.sanity.avatar
1673
- },
1674
- button: {
1675
- ...defaultThemeConfig.button,
1676
- ...theme.sanity.button
1677
- },
1678
- card: defaultThemeConfig.card,
1679
- color: themeColor_v0_v2(theme.sanity.color),
1680
- container: theme.sanity.container,
1681
- font: theme.sanity.fonts,
1682
- input: {
1683
- ...defaultThemeConfig.input,
1684
- ...theme.sanity.input,
1685
- checkbox: {
1686
- ...defaultThemeConfig.input.checkbox,
1687
- ...theme.sanity.input.checkbox
1688
- },
1689
- radio: {
1690
- ...defaultThemeConfig.input.radio,
1691
- ...theme.sanity.input.radio
1692
- },
1693
- switch: {
1694
- ...defaultThemeConfig.input.switch,
1695
- ...theme.sanity.input.switch
1696
- }
1697
- },
1698
- layer: theme.sanity.layer ?? defaultThemeConfig.layer,
1699
- media: theme.sanity.media,
1700
- radius: theme.sanity.radius,
1701
- shadow: theme.sanity.shadows,
1702
- space: theme.sanity.space,
1703
- style: theme.sanity.styles
1704
- };
1705
- return cache$3.set(theme, v2), v2;
1706
- }
1707
- function is_v0(themeProp) {
1708
- return themeProp._version === 0;
1709
- }
1710
- function is_v2(themeProp) {
1711
- return themeProp._version === 2;
1712
- }
1713
- const cache$2 = /* @__PURE__ */ new WeakMap();
1714
- function v0_v2(v0) {
1715
- if (v0.v2) return v0.v2;
1716
- const cached_v2 = cache$2.get(v0);
1717
- if (cached_v2) return cached_v2;
1718
- const {
1719
- avatar,
1720
- button,
1721
- color: color2,
1722
- container,
1723
- fonts: font,
1724
- input,
1725
- layer,
1726
- media,
1727
- radius,
1728
- shadows: shadow,
1729
- space,
1730
- styles: style
1731
- } = v0, v2 = {
1732
- _version: 2,
1733
- avatar: {
1734
- ...defaultThemeConfig.avatar,
1735
- ...avatar
1736
- },
1737
- button: {
1738
- ...defaultThemeConfig.button,
1739
- ...button
1740
- },
1741
- card: defaultThemeConfig.card,
1742
- color: {
1743
- light: {
1744
- transparent: themeColor_v0_v2(color2.light.transparent),
1745
- default: themeColor_v0_v2(color2.light.default),
1746
- neutral: themeColor_v0_v2(color2.light.transparent),
1747
- primary: themeColor_v0_v2(color2.light.primary),
1748
- suggest: themeColor_v0_v2(color2.light.primary),
1749
- positive: themeColor_v0_v2(color2.light.positive),
1750
- caution: themeColor_v0_v2(color2.light.caution),
1751
- critical: themeColor_v0_v2(color2.light.critical)
1752
- },
1753
- dark: {
1754
- transparent: themeColor_v0_v2(color2.dark.transparent),
1755
- default: themeColor_v0_v2(color2.dark.default),
1756
- neutral: themeColor_v0_v2(color2.dark.transparent),
1757
- primary: themeColor_v0_v2(color2.dark.primary),
1758
- suggest: themeColor_v0_v2(color2.dark.primary),
1759
- positive: themeColor_v0_v2(color2.dark.positive),
1760
- caution: themeColor_v0_v2(color2.dark.caution),
1761
- critical: themeColor_v0_v2(color2.dark.critical)
1762
- }
1763
- },
1764
- container,
1765
- font,
1766
- input: {
1767
- ...defaultThemeConfig.input,
1768
- ...input,
1769
- checkbox: {
1770
- ...defaultThemeConfig.input.checkbox,
1771
- ...input.checkbox
1772
- },
1773
- radio: {
1774
- ...defaultThemeConfig.input.radio,
1775
- ...input.radio
1776
- },
1777
- switch: {
1778
- ...defaultThemeConfig.input.switch,
1779
- ...input.switch
1780
- }
1781
- },
1782
- layer: layer ?? defaultThemeConfig.layer,
1783
- media,
1784
- radius,
1785
- shadow,
1786
- space,
1787
- style
1788
- };
1789
- return cache$2.set(v0, v2), v2;
1790
- }
1791
- const cache$1 = /* @__PURE__ */ new WeakMap();
1792
- function v2_v0(v2) {
1793
- const cachedTheme = cache$1.get(v2);
1794
- if (cachedTheme) return cachedTheme;
1795
- const {
1796
- avatar,
1797
- button,
1798
- color: color2,
1799
- container,
1800
- font: fonts,
1801
- input,
1802
- media,
1803
- radius,
1804
- shadow: shadows,
1805
- space,
1806
- style: styles
1807
- } = v2;
1808
- return {
1809
- _version: 0,
1810
- avatar,
1811
- button,
1812
- container,
1813
- color: {
1814
- light: {
1815
- transparent: themeColor_v2_v0(color2.light.transparent),
1816
- default: themeColor_v2_v0(color2.light.default),
1817
- primary: themeColor_v2_v0(color2.light.primary),
1818
- positive: themeColor_v2_v0(color2.light.positive),
1819
- caution: themeColor_v2_v0(color2.light.caution),
1820
- critical: themeColor_v2_v0(color2.light.critical)
1821
- },
1822
- dark: {
1823
- transparent: themeColor_v2_v0(color2.dark.transparent),
1824
- default: themeColor_v2_v0(color2.dark.default),
1825
- primary: themeColor_v2_v0(color2.dark.primary),
1826
- positive: themeColor_v2_v0(color2.dark.positive),
1827
- caution: themeColor_v2_v0(color2.dark.caution),
1828
- critical: themeColor_v2_v0(color2.dark.critical)
1829
- }
1830
- },
1831
- focusRing: input.text.focusRing,
1832
- fonts,
1833
- input,
1834
- media,
1835
- radius,
1836
- shadows,
1837
- space,
1838
- styles,
1839
- v2
1840
- };
1841
- }
1842
- function themeColor_v2_v0(color_v2) {
1843
- return {
1844
- base: {
1845
- bg: color_v2.bg,
1846
- fg: color_v2.fg,
1847
- border: color_v2.border,
1848
- focusRing: color_v2.focusRing,
1849
- shadow: color_v2.shadow
1850
- },
1851
- button: color_v2.button,
1852
- card: color_v2.selectable.default,
1853
- dark: color_v2._dark,
1854
- input: {
1855
- default: inputStatesThemeColor_v2_v0(color_v2.input.default),
1856
- invalid: inputStatesThemeColor_v2_v0(color_v2.input.invalid)
1857
- },
1858
- muted: {
1859
- ...color_v2.button.ghost,
1860
- transparent: color_v2.button.ghost.default
1861
- },
1862
- solid: {
1863
- ...color_v2.button.default,
1864
- transparent: color_v2.button.default.default
1865
- },
1866
- selectable: color_v2.selectable,
1867
- spot: {
1868
- gray: color_v2.avatar.gray.bg,
1869
- blue: color_v2.avatar.blue.bg,
1870
- purple: color_v2.avatar.purple.bg,
1871
- magenta: color_v2.avatar.magenta.bg,
1872
- red: color_v2.avatar.red.bg,
1873
- orange: color_v2.avatar.orange.bg,
1874
- yellow: color_v2.avatar.yellow.bg,
1875
- green: color_v2.avatar.green.bg,
1876
- cyan: color_v2.avatar.cyan.bg
1877
- },
1878
- syntax: color_v2.syntax
1879
- };
1880
- }
1881
- function inputStatesThemeColor_v2_v0(t) {
1882
- return {
1883
- enabled: inputStateThemeColor_v2_v0(t.enabled),
1884
- disabled: inputStateThemeColor_v2_v0(t.disabled),
1885
- readOnly: inputStateThemeColor_v2_v0(t.readOnly),
1886
- hovered: inputStateThemeColor_v2_v0(t.hovered)
1887
- };
1888
- }
1889
- function inputStateThemeColor_v2_v0(t) {
1890
- return {
1891
- bg: t.bg,
1892
- bg2: t.muted.bg,
1893
- border: t.border,
1894
- fg: t.fg,
1895
- placeholder: t.placeholder
1896
- };
1897
- }
1898
- const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
1899
- "transparent",
1900
- "default",
1901
- "neutral",
1902
- "primary",
1903
- // deprecated
1904
- "suggest",
1905
- "positive",
1906
- "caution",
1907
- "critical"
1908
- ], THEME_COLOR_STATE_TONES = [
1909
- "default",
1910
- "neutral",
1911
- "primary",
1912
- // deprecated
1913
- "suggest",
1914
- "positive",
1915
- "caution",
1916
- "critical"
1917
- ], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = color.COLOR_HUES;
1918
- function isColorBlendModeValue(str) {
1919
- return THEME_COLOR_BLEND_MODES.includes(str);
1920
- }
1921
- function isColorHueKey(str) {
1922
- return color.COLOR_HUES.includes(str);
1923
- }
1924
- function isColorTintKey(str) {
1925
- return color.COLOR_TINTS.includes(str);
1926
- }
1927
- function isColorButtonMode(str) {
1928
- return THEME_COLOR_BUTTON_MODES.includes(str);
1929
- }
1930
- const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
1931
- function parseTokenKey(str) {
1932
- const segments = str.split("/"), segment0 = segments.shift() || "";
1933
- if (isColorConfigBaseTone(segment0)) {
1934
- const key = segments.join("/");
1935
- if (isColorConfigBaseKey(key))
1936
- return {
1937
- type: "base",
1938
- tone: segment0,
1939
- key
1940
- };
1941
- if (isColorConfigBlendKey(key))
1942
- return {
1943
- type: "base",
1944
- tone: segment0,
1945
- key
1946
- };
1947
- }
1948
- if (segment0 === "button") {
1949
- const segment1 = segments.shift() || "";
1950
- if (isColorConfigStateTone(segment1)) {
1951
- const segment2 = segments.shift() || "";
1952
- if (isColorButtonMode(segment2)) {
1953
- const key = segments.join("/");
1954
- if (isColorConfigStateKey(key))
1955
- return {
1956
- type: "button",
1957
- tone: segment1,
1958
- mode: segment2,
1959
- key
1960
- };
1961
- if (isColorConfigBlendKey(key))
1962
- return {
1963
- type: "button",
1964
- tone: segment1,
1965
- mode: segment2,
1966
- key
1967
- };
1968
- }
1969
- }
1970
- }
1971
- }
1972
- function isColorMixPercentValue(str) {
1973
- return /^\d+%$/.test(str);
1974
- }
1975
- function parseTokenValue(str) {
1976
- const segments = str.split("/");
1977
- let nextSegment = segments.shift() || "";
1978
- const [segment0, segment0mix] = nextSegment.split(" ");
1979
- if (isColorTintKey(segment0)) {
1980
- const tint = segment0, segment1 = segments.shift() || "";
1981
- if (isColorMixPercentValue(segment0mix)) {
1982
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1983
- return {
1984
- type: "color",
1985
- tint,
1986
- mix: mix2
1987
- };
1988
- }
1989
- if (isColorOpacityValue(segment1)) {
1990
- const opacity = Number(segment1);
1991
- return {
1992
- type: "color",
1993
- tint,
1994
- opacity
1995
- };
1996
- }
1997
- return {
1998
- type: "color",
1999
- tint
2000
- };
2001
- }
2002
- if (isColorValue(segment0)) {
2003
- const key = segment0, segment1 = segments.shift() || "";
2004
- if (isColorMixPercentValue(segment0mix)) {
2005
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
2006
- return {
2007
- type: "color",
2008
- key,
2009
- mix: mix2
2010
- };
2011
- }
2012
- if (isColorOpacityValue(segment1)) {
2013
- const opacity = Number(segment1);
2014
- return {
2015
- type: "color",
2016
- key,
2017
- opacity
2018
- };
2019
- }
2020
- return {
2021
- type: "color",
2022
- key
2023
- };
2024
- }
2025
- if (isColorHueKey(segment0)) {
2026
- const hue = segment0;
2027
- nextSegment = segments.shift() || "";
2028
- const [segment1, segment1mix] = nextSegment.split(" ");
2029
- if (isColorTintKey(segment1)) {
2030
- const tint = segment1, segment2 = segments.shift() || "";
2031
- if (isColorMixPercentValue(segment1mix)) {
2032
- const mix2 = Number(segment1mix.slice(0, -1)) / 100;
2033
- return {
2034
- type: "color",
2035
- hue,
2036
- tint,
2037
- mix: mix2
2038
- };
2039
- }
2040
- if (isColorOpacityValue(segment2)) {
2041
- const opacity = Number(segment2);
2042
- return {
2043
- type: "color",
2044
- hue,
2045
- tint,
2046
- opacity
2047
- };
2048
- }
2049
- return {
2050
- type: "color",
2051
- hue,
2052
- tint
2053
- };
2054
- }
2055
- return {
2056
- type: "hue",
2057
- value: hue
2058
- };
2059
- }
2060
- if (isColorBlendModeValue(segment0))
2061
- return {
2062
- type: "blendMode",
2063
- value: segment0
2064
- };
2065
- }
2066
- function isColorConfigBaseTone(str) {
2067
- return COLOR_CONFIG_CARD_TONES.includes(str);
2068
- }
2069
- function isColorConfigBaseKey(str) {
2070
- return COLOR_CONFIG_CARD_KEYS.includes(str);
2071
- }
2072
- function isColorConfigStateKey(str) {
2073
- return COLOR_CONFIG_STATE_KEYS.includes(str);
2074
- }
2075
- function isColorConfigStateTone(str) {
2076
- return COLOR_CONFIG_STATE_TONES.includes(str);
2077
- }
2078
- function isColorConfigBlendKey(str) {
2079
- return COLOR_CONFIG_BLEND_KEYS.includes(str);
2080
- }
2081
- function isColorTokenValue(str) {
2082
- return parseTokenValue(str)?.type === "color" || parseTokenValue(str)?.type === "hue";
2083
- }
2084
- function isColorValue(str) {
2085
- return str === "black" || str === "white";
2086
- }
2087
- function isColorOpacityValue(str) {
2088
- return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
2089
- }
2090
- function compileColorTokenValue(node) {
2091
- let key = "";
2092
- return node.key === "black" || node.key === "white" ? key = node.key : key = `${node.hue}/${node.tint}`, node.mix !== void 0 ? `${key} ${node.mix * 100}%` : (node.opacity !== void 0 && (key += `/${node.opacity}`), key);
2093
- }
2094
- const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2095
- function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
2096
- const {
2097
- hue,
2098
- scheme
2099
- } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
2100
- if (!node || node.type !== "color")
2101
- throw new Error(`Invalid color token: ${value[0]}`);
2102
- return compileColorTokenValue({
2103
- ...node,
2104
- hue: node.hue || hue
2105
- });
2106
- }
2107
- const defaultColorTokens = {
2108
- base: {
2109
- "*": {
2110
- _blend: ["multiply", "screen"],
2111
- accent: {
2112
- fg: ["purple/600", "purple/400"]
2113
- },
2114
- avatar: {
2115
- "*": {
2116
- _blend: ["screen", "multiply"],
2117
- bg: ["500", "400"],
2118
- fg: ["white", "black"]
2119
- }
2120
- },
2121
- backdrop: ["gray/200/0.5", "black/0.5"],
2122
- badge: {
2123
- "*": {
2124
- bg: ["100", "900"],
2125
- fg: ["600", "400"],
2126
- icon: ["500", "500"],
2127
- dot: ["500", "500"]
2128
- },
2129
- positive: {
2130
- bg: ["200 50%", "900"],
2131
- fg: ["600", "500"]
2132
- },
2133
- caution: {
2134
- bg: ["200 50%", "900"],
2135
- fg: ["600", "500"]
2136
- }
2137
- },
2138
- bg: ["50", "950"],
2139
- border: ["200", "800"],
2140
- code: {
2141
- bg: ["50", "950"],
2142
- fg: ["600", "400"]
2143
- },
2144
- fg: ["800", "200"],
2145
- focusRing: ["blue/500", "blue/500"],
2146
- icon: ["600", "400"],
2147
- kbd: {
2148
- bg: ["white", "black"],
2149
- fg: ["600", "400"],
2150
- border: ["200", "800"]
2151
- },
2152
- link: {
2153
- fg: ["blue/600", "blue/300"]
2154
- },
2155
- muted: {
2156
- bg: ["50", "950"],
2157
- fg: ["700 75%", "300 75%"]
2158
- },
2159
- shadow: {
2160
- outline: ["500/0.3", "500/0.4"],
2161
- umbra: ["gray/500/0.1", "black/0.2"],
2162
- penumbra: ["gray/500/0.07", "black/0.14"],
2163
- ambient: ["gray/500/0.06", "black/0.12"]
2164
- },
2165
- skeleton: {
2166
- from: ["100", "900"],
2167
- to: ["100 50%", "900 50%"]
2168
- }
2169
- },
2170
- transparent: {
2171
- bg: ["50", "black"]
2172
- },
2173
- default: {
2174
- bg: ["white", "950"],
2175
- fg: ["800", "200"],
2176
- muted: {
2177
- fg: ["600", "400"]
2178
- }
2179
- },
2180
- primary: {
2181
- _hue: "blue"
2182
- },
2183
- suggest: {
2184
- _hue: "purple"
2185
- },
2186
- positive: {
2187
- _hue: "green",
2188
- shadow: {
2189
- outline: ["500/0.4", "500/0.4"]
2190
- }
2191
- },
2192
- caution: {
2193
- _hue: "yellow",
2194
- shadow: {
2195
- outline: ["600/0.3", "500/0.4"]
2196
- }
2197
- },
2198
- critical: {
2199
- _hue: "red"
2200
- }
2201
- },
2202
- button: {
2203
- default: {
2204
- "*": {
2205
- "*": {
2206
- _blend: ["screen", "multiply"],
2207
- accent: {
2208
- fg: ["purple/300", "purple/700"]
2209
- },
2210
- avatar: {
2211
- "*": {
2212
- _blend: ["screen", "multiply"],
2213
- bg: ["500", "400"],
2214
- fg: ["white", "black"]
2215
- }
2216
- },
2217
- badge: {
2218
- "*": {
2219
- bg: ["900", "100"],
2220
- fg: ["400", "600"],
2221
- dot: ["500", "500"],
2222
- icon: ["500", "500"]
2223
- }
2224
- },
2225
- bg: ["500", "400"],
2226
- border: ["500/0", "400/0"],
2227
- code: {
2228
- bg: ["500 20%", "400 20%"],
2229
- fg: ["200", "600"]
2230
- },
2231
- fg: ["white", "black"],
2232
- icon: ["100 70%", "900 70%"],
2233
- kbd: {
2234
- bg: ["black", "white"],
2235
- fg: ["200", "600"],
2236
- border: ["800", "200"]
2237
- },
2238
- link: {
2239
- fg: ["blue/200", "blue/600"]
2240
- },
2241
- muted: {
2242
- bg: ["950", "50"],
2243
- fg: ["100 70%", "900 70%"]
2244
- },
2245
- skeleton: {
2246
- from: ["900", "100"],
2247
- to: ["900 50%", "100 50%"]
2248
- }
2249
- },
2250
- hovered: {
2251
- bg: ["600", "300"],
2252
- border: ["700/0", "300/0"]
2253
- },
2254
- pressed: {
2255
- bg: ["700", "300"]
2256
- },
2257
- selected: {
2258
- bg: ["700", "300"]
2259
- },
2260
- disabled: {
2261
- _hue: "gray",
2262
- accent: {
2263
- fg: ["100 70%", "900 70%"]
2264
- },
2265
- avatar: {
2266
- "*": {
2267
- _blend: ["screen", "multiply"],
2268
- bg: ["gray/500", "gray/400"],
2269
- fg: ["white", "black"]
2270
- }
2271
- },
2272
- badge: {
2273
- "*": {
2274
- bg: ["gray/700", "gray/300"],
2275
- fg: ["white", "black"],
2276
- dot: ["white", "black"],
2277
- icon: ["white", "black"]
2278
- }
2279
- },
2280
- bg: ["300", "600"],
2281
- code: {
2282
- bg: ["950", "50"],
2283
- fg: ["300", "600"]
2284
- },
2285
- fg: ["300", "600"],
2286
- muted: {
2287
- bg: ["950", "50"],
2288
- fg: ["300", "600"]
2289
- },
2290
- kbd: {
2291
- bg: ["black", "white"],
2292
- fg: ["white", "black"],
2293
- border: ["700", "300"]
2294
- },
2295
- link: {
2296
- fg: ["100 70%", "900 70%"]
2297
- }
2298
- }
2299
- },
2300
- default: {
2301
- "*": {
2302
- avatar: {
2303
- "*": {
2304
- _blend: ["screen", "multiply"],
2305
- bg: ["500", "400"],
2306
- fg: ["white", "black"]
2307
- }
2308
- },
2309
- bg: ["800", "200"],
2310
- muted: {
2311
- bg: ["950", "50"],
2312
- fg: ["400", "600"]
2313
- }
2314
- },
2315
- hovered: {
2316
- bg: ["900", "100"]
2317
- },
2318
- pressed: {
2319
- bg: ["black", "white"]
2320
- },
2321
- selected: {
2322
- bg: ["black", "white"]
2323
- }
2324
- }
2325
- },
2326
- ghost: {
2327
- "*": {
2328
- "*": {
2329
- _blend: ["multiply", "screen"],
2330
- accent: {
2331
- fg: ["purple/700 60%", "purple/300 70%"]
2332
- },
2333
- avatar: {
2334
- "*": {
2335
- _blend: ["screen", "multiply"],
2336
- bg: ["500", "400"],
2337
- fg: ["white", "black"]
2338
- }
2339
- },
2340
- badge: {
2341
- "*": {
2342
- bg: ["100", "900"],
2343
- fg: ["600", "400"],
2344
- dot: ["500", "500"],
2345
- icon: ["500", "500"]
2346
- }
2347
- },
2348
- bg: ["50", "950"],
2349
- border: ["100", "900"],
2350
- code: {
2351
- bg: ["500 10%", "400 10%"],
2352
- fg: ["700 60%", "400 60%"]
2353
- },
2354
- fg: ["600", "400"],
2355
- icon: ["700 60%", "300 60%"],
2356
- kbd: {
2357
- bg: ["white", "black"],
2358
- fg: ["600", "400"],
2359
- border: ["200", "800"]
2360
- },
2361
- link: {
2362
- fg: ["blue/700 60%", "blue/300 60%"]
2363
- },
2364
- muted: {
2365
- bg: ["100", "950"],
2366
- fg: ["700 60%", "300 60%"]
2367
- },
2368
- skeleton: {
2369
- from: ["100", "900"],
2370
- to: ["100 50%", "900 50%"]
2371
- }
2372
- },
2373
- hovered: {
2374
- bg: ["100", "900"],
2375
- fg: ["700", "300"]
2376
- },
2377
- pressed: {
2378
- bg: ["200", "800"],
2379
- fg: ["800", "200"]
2380
- },
2381
- selected: {
2382
- bg: ["200", "800"],
2383
- fg: ["800", "200"]
2384
- },
2385
- disabled: {
2386
- _hue: "gray",
2387
- accent: {
2388
- fg: ["200", "800"]
2389
- },
2390
- avatar: {
2391
- "*": {
2392
- _blend: ["screen", "multiply"],
2393
- bg: ["gray/100", "gray/900"],
2394
- fg: ["white", "black"]
2395
- }
2396
- },
2397
- badge: {
2398
- "*": {
2399
- _hue: "gray",
2400
- bg: ["50", "950"],
2401
- fg: ["gray/200", "gray/800"],
2402
- dot: ["gray/200", "gray/800"],
2403
- icon: ["gray/200", "gray/800"]
2404
- }
2405
- },
2406
- border: ["100", "900"],
2407
- code: {
2408
- bg: ["50", "950"],
2409
- fg: ["200", "800"]
2410
- },
2411
- fg: ["400", "600"],
2412
- icon: ["300", "700"],
2413
- muted: {
2414
- fg: ["300", "700"]
2415
- },
2416
- kbd: {
2417
- bg: ["white", "black"],
2418
- fg: ["200", "800"],
2419
- border: ["100", "900"]
2420
- },
2421
- link: {
2422
- fg: ["200", "800"]
2423
- }
2424
- }
2425
- },
2426
- positive: {
2427
- "*": {
2428
- border: ["600 20%", "800"]
2429
- }
2430
- },
2431
- caution: {
2432
- "*": {
2433
- border: ["600 20%", "800"]
2434
- }
2435
- }
2436
- },
2437
- bleed: {
2438
- "*": {
2439
- "*": {
2440
- _blend: ["multiply", "screen"],
2441
- accent: {
2442
- fg: ["purple/700 70%", "purple/300 70%"]
2443
- },
2444
- avatar: {
2445
- "*": {
2446
- _blend: ["screen", "multiply"],
2447
- bg: ["500", "400"],
2448
- fg: ["white", "black"]
2449
- }
2450
- },
2451
- badge: {
2452
- "*": {
2453
- bg: ["100", "900"],
2454
- fg: ["600", "400"],
2455
- dot: ["500", "500"],
2456
- icon: ["500", "500"]
2457
- }
2458
- },
2459
- bg: ["white", "black"],
2460
- border: ["white/0", "black/0"],
2461
- code: {
2462
- bg: ["50", "950"],
2463
- fg: ["700 75%", "300 75%"]
2464
- },
2465
- fg: ["700", "300"],
2466
- icon: ["700 75%", "300 75%"],
2467
- kbd: {
2468
- bg: ["white", "black"],
2469
- fg: ["700", "300"],
2470
- border: ["200", "800"]
2471
- },
2472
- link: {
2473
- fg: ["blue/700 70%", "blue/300 70%"]
2474
- },
2475
- muted: {
2476
- bg: ["100", "950"],
2477
- fg: ["700 75%", "300 75%"]
2478
- },
2479
- skeleton: {
2480
- from: ["100", "900"],
2481
- to: ["100 50%", "900 50%"]
2482
- }
2483
- },
2484
- hovered: {
2485
- bg: ["50", "900"],
2486
- fg: ["800", "200"],
2487
- icon: ["800 70%", "300 70%"]
2488
- },
2489
- pressed: {
2490
- bg: ["100", "800"],
2491
- fg: ["800", "200"],
2492
- icon: ["800 70%", "200 70%"]
2493
- },
2494
- selected: {
2495
- bg: ["100", "900"],
2496
- fg: ["800", "200"],
2497
- icon: ["800 60%", "200 60%"]
2498
- },
2499
- disabled: {
2500
- _hue: "gray",
2501
- accent: {
2502
- fg: ["200", "800"]
2503
- },
2504
- avatar: {
2505
- "*": {
2506
- _blend: ["screen", "multiply"],
2507
- bg: ["gray/100", "gray/900"],
2508
- fg: ["white", "black"]
2509
- }
2510
- },
2511
- badge: {
2512
- "*": {
2513
- _hue: "gray",
2514
- bg: ["50", "950"],
2515
- fg: ["gray/200", "gray/800"],
2516
- dot: ["gray/200", "gray/800"],
2517
- icon: ["gray/200", "gray/800"]
2518
- }
2519
- },
2520
- code: {
2521
- bg: ["50", "950"],
2522
- fg: ["200", "800"]
2523
- },
2524
- fg: ["400", "600"],
2525
- icon: ["300", "700"],
2526
- muted: {
2527
- fg: ["400", "600"]
2528
- },
2529
- kbd: {
2530
- bg: ["white", "black"],
2531
- fg: ["200", "800"],
2532
- border: ["100", "900"]
2533
- },
2534
- link: {
2535
- fg: ["200", "800"]
2536
- }
2537
- }
2538
- }
2539
- }
2540
- },
2541
- input: {
2542
- "*": {
2543
- "*": {
2544
- _blend: ["multiply", "screen"],
2545
- bg: ["white", "black"],
2546
- border: ["200", "700"],
2547
- fg: ["black", "200"],
2548
- muted: {
2549
- bg: ["50", "950"]
2550
- },
2551
- placeholder: ["400", "600"]
2552
- },
2553
- hovered: {
2554
- border: ["300", "700"]
2555
- },
2556
- readOnly: {
2557
- bg: ["50", "950"],
2558
- border: ["200", "800"],
2559
- fg: ["800", "200"]
2560
- },
2561
- disabled: {
2562
- bg: ["50", "950"],
2563
- fg: ["400", "600"],
2564
- border: ["100", "900"],
2565
- placeholder: ["200", "800 50%"]
2566
- }
2567
- },
2568
- invalid: {
2569
- "*": {
2570
- _hue: "red",
2571
- bg: ["100", "950"]
2572
- }
2573
- }
2574
- },
2575
- selectable: {
2576
- "*": {
2577
- "*": {
2578
- _blend: ["multiply", "screen"],
2579
- accent: {
2580
- fg: ["purple/700 70%", "purple/300 70%"]
2581
- },
2582
- avatar: {
2583
- "*": {
2584
- _blend: ["screen", "multiply"],
2585
- bg: ["500", "400"],
2586
- fg: ["white", "black"]
2587
- }
2588
- },
2589
- badge: {
2590
- "*": {
2591
- bg: ["100", "900"],
2592
- fg: ["600", "400"],
2593
- dot: ["500", "500"],
2594
- icon: ["500", "500"]
2595
- }
2596
- },
2597
- bg: ["white", "black"],
2598
- border: ["200", "800"],
2599
- code: {
2600
- bg: ["50", "950"],
2601
- fg: ["600", "400"]
2602
- },
2603
- fg: ["700", "300"],
2604
- icon: ["700 75%", "300 75%"],
2605
- kbd: {
2606
- bg: ["white", "black"],
2607
- fg: ["600", "400"],
2608
- border: ["200", "800"]
2609
- },
2610
- link: {
2611
- fg: ["blue/700 70%", "blue/300 70%"]
2612
- },
2613
- muted: {
2614
- bg: ["50", "950"],
2615
- fg: ["700 75%", "300 75%"]
2616
- },
2617
- skeleton: {
2618
- from: ["100", "900"],
2619
- to: ["100 50%", "900 50%"]
2620
- }
2621
- },
2622
- hovered: {
2623
- bg: ["50", "950"]
2624
- },
2625
- pressed: {
2626
- bg: ["100", "900"]
2627
- },
2628
- selected: {
2629
- _blend: ["screen", "multiply"],
2630
- accent: {
2631
- fg: ["purple/300", "purple/700"]
2632
- },
2633
- avatar: {
2634
- "*": {
2635
- _blend: ["multiply", "screen"],
2636
- bg: ["white", "black"],
2637
- fg: ["black", "white"]
2638
- }
2639
- },
2640
- badge: {
2641
- "*": {
2642
- bg: ["900", "100"],
2643
- fg: ["400", "600"],
2644
- dot: ["500", "500"],
2645
- icon: ["500", "500"]
2646
- }
2647
- },
2648
- bg: ["500", "400"],
2649
- border: ["500 20%", "400 20%"],
2650
- code: {
2651
- bg: ["500 20%", "400 20%"],
2652
- fg: ["200", "600"]
2653
- },
2654
- fg: ["white", "black"],
2655
- icon: ["100 70%", "900 70%"],
2656
- kbd: {
2657
- bg: ["black", "white"],
2658
- fg: ["200", "600"],
2659
- border: ["800", "200"]
2660
- },
2661
- link: {
2662
- fg: ["blue/200", "blue/600"]
2663
- },
2664
- muted: {
2665
- bg: ["500 10%", "400 10%"],
2666
- fg: ["100 70%", "900 70%"]
2667
- },
2668
- skeleton: {
2669
- from: ["900", "100"],
2670
- to: ["900 50%", "100 50%"]
2671
- }
2672
- },
2673
- disabled: {
2674
- _hue: "gray",
2675
- accent: {
2676
- fg: ["200", "800"]
2677
- },
2678
- avatar: {
2679
- "*": {
2680
- _blend: ["screen", "multiply"],
2681
- bg: ["gray/100", "gray/900"],
2682
- fg: ["white", "black"]
2683
- }
2684
- },
2685
- badge: {
2686
- "*": {
2687
- _hue: "gray",
2688
- bg: ["50", "950"],
2689
- fg: ["gray/200", "gray/800"],
2690
- dot: ["gray/200", "gray/800"],
2691
- icon: ["gray/200", "gray/800"]
2692
- }
2693
- },
2694
- border: ["100", "900"],
2695
- code: {
2696
- bg: ["50", "950"],
2697
- fg: ["200", "800"]
2698
- },
2699
- fg: ["200", "800"],
2700
- icon: ["200", "800"],
2701
- kbd: {
2702
- bg: ["white", "black"],
2703
- fg: ["200", "800"],
2704
- border: ["100", "900"]
2705
- },
2706
- link: {
2707
- fg: ["200", "800"]
2708
- },
2709
- muted: {
2710
- bg: ["50 50%", "950 50%"],
2711
- fg: ["200", "800"]
2712
- }
2713
- }
2714
- },
2715
- default: {
2716
- selected: {
2717
- _hue: "blue"
2718
- }
2719
- },
2720
- critical: {
2721
- disabled: {
2722
- bg: ["50 50%", "950 50%"]
2723
- }
2724
- }
2725
- },
2726
- syntax: {
2727
- atrule: ["purple/600", "purple/400"],
2728
- attrName: ["green/600", "green/400"],
2729
- attrValue: ["yellow/600", "yellow/400"],
2730
- attribute: ["yellow/600", "yellow/400"],
2731
- boolean: ["purple/600", "purple/400"],
2732
- builtin: ["purple/600", "purple/400"],
2733
- cdata: ["yellow/600", "yellow/400"],
2734
- char: ["yellow/600", "yellow/400"],
2735
- class: ["orange/600", "orange/400"],
2736
- className: ["cyan/600", "cyan/400"],
2737
- comment: ["gray/400", "gray/600"],
2738
- constant: ["purple/600", "purple/400"],
2739
- deleted: ["red/600", "red/400"],
2740
- entity: ["red/600", "red/400"],
2741
- function: ["green/600", "green/400"],
2742
- hexcode: ["blue/600", "blue/400"],
2743
- id: ["purple/600", "purple/400"],
2744
- important: ["purple/600", "purple/400"],
2745
- inserted: ["yellow/600", "yellow/400"],
2746
- keyword: ["magenta/600", "magenta/400"],
2747
- number: ["purple/600", "purple/400"],
2748
- operator: ["magenta/600", "magenta/400"],
2749
- property: ["blue/600", "blue/400"],
2750
- pseudoClass: ["yellow/600", "yellow/400"],
2751
- pseudoElement: ["yellow/600", "yellow/400"],
2752
- punctuation: ["gray/600", "gray/400"],
2753
- regex: ["blue/600", "blue/400"],
2754
- selector: ["red/600", "red/400"],
2755
- string: ["yellow/600", "yellow/400"],
2756
- symbol: ["purple/600", "purple/400"],
2757
- tag: ["red/600", "red/400"],
2758
- unit: ["orange/600", "orange/400"],
2759
- url: ["red/600", "red/400"],
2760
- variable: ["red/600", "red/400"]
2761
- }
2762
- };
2763
- function isRecord(value) {
2764
- return !!(value && typeof value == "object" && !Array.isArray(value));
2765
- }
2766
- function merge(...records) {
2767
- const _records = records.filter(Boolean);
2768
- return _records.length === 0 ? {} : _records.reduce(_merge, {});
2769
- }
2770
- function _merge(acc, source) {
2771
- for (const key of Object.keys(source)) {
2772
- const prevValue = acc[key], nextValue = source[key];
2773
- isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
2774
- }
2775
- return acc;
2776
- }
2777
- function resolveColorTokens(inputTokens) {
2778
- const tokens = merge(defaultColorTokens, inputTokens);
2779
- return {
2780
- base: resolveBaseColorTokens(tokens),
2781
- button: resolveButtonColorTokens(tokens),
2782
- input: resolveInputColorTokens(tokens),
2783
- selectable: resolveSelectableColorTokens(tokens),
2784
- syntax: tokens.syntax
2785
- };
2786
- }
2787
- function resolveBaseColorTokens(sparseTokens) {
2788
- const tokens = {};
2789
- for (const tone of THEME_COLOR_CARD_TONES)
2790
- tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
2791
- return tokens;
2792
- }
2793
- function resolveBaseColorTones(inputTokens, tone) {
2794
- const spec = merge(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
2795
- return {
2796
- ...spec,
2797
- _hue: hue,
2798
- avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2799
- ...acc,
2800
- [hue2]: merge({
2801
- _hue: hue2
2802
- }, spec.avatar?.["*"], spec.avatar?.[hue2])
2803
- }), {}),
2804
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2805
- ...acc,
2806
- [tone2]: {
2807
- _hue: inputTokens?.base?.[tone2]?._hue || hue,
2808
- ...spec.badge?.["*"],
2809
- ...spec.badge?.[tone2]
2810
- }
2811
- }), {})
2812
- };
2813
- }
2814
- function resolveButtonColorTokens(inputTokens) {
2815
- const tokens = {};
2816
- for (const mode of THEME_COLOR_BUTTON_MODES)
2817
- tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
2818
- return tokens;
2819
- }
2820
- function resolveButtonToneColorTokens(inputTokens, mode) {
2821
- const tokens = {};
2822
- for (const tone of THEME_COLOR_STATE_TONES)
2823
- tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
2824
- return tokens;
2825
- }
2826
- function resolveButtonModeColorTokens(inputTokens, mode, tone) {
2827
- const tokens = {};
2828
- for (const state of THEME_COLOR_STATES)
2829
- tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
2830
- return tokens;
2831
- }
2832
- function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
2833
- const spec = merge(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2834
- return {
2835
- ...spec,
2836
- _hue: hue,
2837
- avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2838
- ...acc,
2839
- [hue2]: merge({
2840
- _hue: hue2
2841
- }, spec.avatar?.["*"], spec.avatar?.[hue2])
2842
- }), {}),
2843
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2844
- ...acc,
2845
- [tone2]: {
2846
- _hue: inputTokens?.base?.[tone2]?._hue || hue,
2847
- ...spec.badge?.["*"],
2848
- ...spec.badge?.[tone2]
2849
- }
2850
- }), {})
2851
- };
2852
- }
2853
- function resolveInputColorTokens(inputTokens) {
2854
- const tokens = {};
2855
- for (const mode of THEME_COLOR_INPUT_MODES)
2856
- tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
2857
- return tokens;
2858
- }
2859
- function resolveInputModeColorTokens(inputTokens, mode) {
2860
- const states = {};
2861
- for (const state of THEME_COLOR_INPUT_STATES)
2862
- states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
2863
- return states;
2864
- }
2865
- function resolveInputStateColorTokens(inputTokens, mode, state) {
2866
- const spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
2867
- return {
2868
- ...spec,
2869
- _hue: hue
2870
- };
2871
- }
2872
- function resolveSelectableColorTokens(inputTokens) {
2873
- const tokens = {};
2874
- for (const tone of THEME_COLOR_STATE_TONES)
2875
- tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
2876
- return tokens;
2877
- }
2878
- function resolveSelectableToneColorTokens(inputTokens, tone) {
2879
- const states = {
2880
- _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue
2881
- };
2882
- for (const state of THEME_COLOR_STATES)
2883
- states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
2884
- return states;
2885
- }
2886
- function resolveSelectableStateColorTokens(inputTokens, tone, state) {
2887
- const spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2888
- return {
2889
- ...spec,
2890
- _hue: hue,
2891
- avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2892
- ...acc,
2893
- [hue2]: merge({
2894
- _hue: hue2
2895
- }, spec.avatar?.["*"], spec.avatar?.[hue2])
2896
- }), {}),
2897
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2898
- ...acc,
2899
- [tone2]: {
2900
- _hue: inputTokens?.base?.[tone2]?._hue || hue,
2901
- ...spec.badge?.["*"],
2902
- ...spec.badge?.[tone2]
2903
- }
2904
- }), {})
2905
- };
2906
- }
2907
- function buildColorTheme(config) {
2908
- const resolvedConfig = {
2909
- color: resolveColorTokens(config?.color)
2910
- };
2911
- return {
2912
- light: buildColorScheme({
2913
- scheme: "light"
2914
- }, resolvedConfig),
2915
- dark: buildColorScheme({
2916
- scheme: "dark"
2917
- }, resolvedConfig)
2918
- };
2919
- }
2920
- function buildColorScheme(options, config) {
2921
- const {
2922
- scheme
2923
- } = options, colorScheme = {};
2924
- for (const tone of THEME_COLOR_CARD_TONES)
2925
- colorScheme[tone] = buildCardColorTheme({
2926
- scheme,
2927
- tone
2928
- }, config);
2929
- return colorScheme;
2930
- }
2931
- function buildCardColorTheme(options, config) {
2932
- const {
2933
- scheme,
2934
- tone
2935
- } = options, tokens = config?.color?.base?.[tone], context = {
2936
- hue: tokens?._hue || "gray",
2937
- scheme
2938
- };
2939
- return {
2940
- _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
2941
- _dark: scheme === "dark",
2942
- accent: {
2943
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
2944
- },
2945
- avatar: buildAvatarColorTheme({
2946
- scheme
2947
- }, tokens),
2948
- backdrop: resolveColorTokenValue(context, tokens?.backdrop),
2949
- badge: buildBadgeColorTheme(tokens?.badge, {
2950
- scheme
2951
- }, config),
2952
- bg: resolveColorTokenValue(context, tokens?.bg),
2953
- border: resolveColorTokenValue(context, tokens?.border),
2954
- button: buildButtonColorTheme({
2955
- scheme,
2956
- tone
2957
- }, config),
2958
- code: {
2959
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
2960
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
2961
- },
2962
- fg: resolveColorTokenValue(context, tokens?.fg),
2963
- focusRing: resolveColorTokenValue(context, tokens?.focusRing),
2964
- icon: resolveColorTokenValue(context, tokens?.icon),
2965
- input: buildInputColorTheme({
2966
- scheme,
2967
- tone
2968
- }, config),
2969
- kbd: {
2970
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
2971
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
2972
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
2973
- },
2974
- link: {
2975
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
2976
- },
2977
- muted: {
2978
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
2979
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
2980
- },
2981
- selectable: buildSelectableColorTheme({
2982
- scheme,
2983
- tone
2984
- }, config),
2985
- shadow: buildShadowColorTheme({
2986
- scheme,
2987
- tone
2988
- }, config),
2989
- skeleton: {
2990
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
2991
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
2992
- },
2993
- syntax: buildSyntaxColorTheme({
2994
- scheme
2995
- }, config)
2996
- };
2997
- }
2998
- function buildShadowColorTheme(options, config) {
2999
- const {
3000
- scheme,
3001
- tone
3002
- } = options, tokens = config?.color?.base?.[tone], context = {
3003
- hue: tokens?._hue || "gray",
3004
- scheme
3005
- };
3006
- return {
3007
- outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
3008
- umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
3009
- penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
3010
- ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
3011
- };
3012
- }
3013
- function buildAvatarColorTheme(options, stateTokens) {
3014
- const {
3015
- scheme
3016
- } = options;
3017
- return {
3018
- gray: _buildAvatarColorTheme({
3019
- color: "gray",
3020
- scheme
3021
- }, stateTokens),
3022
- blue: _buildAvatarColorTheme({
3023
- color: "blue",
3024
- scheme
3025
- }, stateTokens),
3026
- purple: _buildAvatarColorTheme({
3027
- color: "purple",
3028
- scheme
3029
- }, stateTokens),
3030
- magenta: _buildAvatarColorTheme({
3031
- color: "magenta",
3032
- scheme
3033
- }, stateTokens),
3034
- red: _buildAvatarColorTheme({
3035
- color: "red",
3036
- scheme
3037
- }, stateTokens),
3038
- orange: _buildAvatarColorTheme({
3039
- color: "orange",
3040
- scheme
3041
- }, stateTokens),
3042
- yellow: _buildAvatarColorTheme({
3043
- color: "yellow",
3044
- scheme
3045
- }, stateTokens),
3046
- green: _buildAvatarColorTheme({
3047
- color: "green",
3048
- scheme
3049
- }, stateTokens),
3050
- cyan: _buildAvatarColorTheme({
3051
- color: "cyan",
3052
- scheme
3053
- }, stateTokens)
3054
- };
3055
- }
3056
- function _buildAvatarColorTheme(options, stateTokens) {
3057
- const {
3058
- color: color2,
3059
- scheme
3060
- } = options, tokens = stateTokens?.avatar?.[color2], context = {
3061
- hue: tokens?._hue || "gray",
3062
- scheme
3063
- };
3064
- return {
3065
- _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
3066
- bg: resolveColorTokenValue(context, tokens?.bg),
3067
- fg: resolveColorTokenValue(context, tokens?.fg)
3068
- };
3069
- }
3070
- function buildBadgeColorTheme(tokens, options, config) {
3071
- const {
3072
- scheme
3073
- } = options, colorBadge = {};
3074
- for (const tone of THEME_COLOR_STATE_TONES)
3075
- colorBadge[tone] = _buildBadgeColorTheme(tokens, {
3076
- scheme,
3077
- tone
3078
- }, config);
3079
- return colorBadge;
3080
- }
3081
- function _buildBadgeColorTheme(parentTokens, options, config) {
3082
- const {
3083
- scheme,
3084
- tone
3085
- } = options, tokens = parentTokens?.[tone], context = {
3086
- hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
3087
- scheme
3088
- };
3089
- return {
3090
- bg: resolveColorTokenValue(context, tokens?.bg),
3091
- fg: resolveColorTokenValue(context, tokens?.fg),
3092
- dot: resolveColorTokenValue(context, tokens?.dot),
3093
- icon: resolveColorTokenValue(context, tokens?.icon)
3094
- };
3095
- }
3096
- function buildButtonColorTheme(options, config) {
3097
- const {
3098
- scheme,
3099
- tone: cardTone
3100
- } = options, modes = {};
3101
- for (const mode of THEME_COLOR_BUTTON_MODES)
3102
- modes[mode] = buildButtonTonesColorTheme({
3103
- cardTone,
3104
- scheme,
3105
- mode
3106
- }, config);
3107
- return modes;
3108
- }
3109
- function buildButtonTonesColorTheme(options, config) {
3110
- const {
3111
- cardTone,
3112
- mode,
3113
- scheme
3114
- } = options, tones2 = {};
3115
- for (const tone of THEME_COLOR_STATE_TONES)
3116
- tones2[tone] = buildButtonStatesColorTheme({
3117
- cardTone,
3118
- mode,
3119
- scheme,
3120
- tone
3121
- }, config);
3122
- return tones2;
3123
- }
3124
- function buildButtonStatesColorTheme(options, config) {
3125
- const {
3126
- cardTone,
3127
- mode,
3128
- scheme,
3129
- tone
3130
- } = options, states = {};
3131
- for (const state of THEME_COLOR_STATES)
3132
- states[state] = buildButtonStateColorTheme({
3133
- cardTone,
3134
- mode,
3135
- tone,
3136
- scheme,
3137
- state
3138
- }, config);
3139
- return states;
3140
- }
3141
- function buildButtonStateColorTheme(options, config) {
3142
- const {
3143
- cardTone,
3144
- mode,
3145
- tone,
3146
- scheme,
3147
- state
3148
- } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3149
- hue,
3150
- scheme
3151
- };
3152
- return {
3153
- _blend: blendMode[scheme === "light" ? 0 : 1],
3154
- accent: {
3155
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3156
- },
3157
- avatar: buildAvatarColorTheme({
3158
- scheme
3159
- }, tokens),
3160
- badge: buildBadgeColorTheme(tokens?.badge, {
3161
- scheme
3162
- }, config),
3163
- bg: resolveColorTokenValue(context, tokens?.bg),
3164
- border: resolveColorTokenValue(context, tokens?.border),
3165
- code: {
3166
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3167
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3168
- },
3169
- fg: resolveColorTokenValue(context, tokens?.fg),
3170
- icon: resolveColorTokenValue(context, tokens?.icon),
3171
- muted: {
3172
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3173
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3174
- },
3175
- kbd: {
3176
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3177
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3178
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3179
- },
3180
- link: {
3181
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3182
- },
3183
- skeleton: {
3184
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3185
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3186
- }
3187
- };
3188
- }
3189
- function buildInputColorTheme(options, config) {
3190
- const {
3191
- scheme,
3192
- tone
3193
- } = options;
3194
- return {
3195
- default: buildInputStatesColorTheme({
3196
- mode: "default",
3197
- scheme,
3198
- tone
3199
- }, config),
3200
- invalid: buildInputStatesColorTheme({
3201
- mode: "invalid",
3202
- scheme,
3203
- tone
3204
- }, config)
3205
- };
3206
- }
3207
- function buildInputStatesColorTheme(options, config) {
3208
- const {
3209
- mode,
3210
- scheme,
3211
- tone
3212
- } = options;
3213
- return {
3214
- enabled: buildInputStateColorTheme({
3215
- mode,
3216
- scheme,
3217
- state: "enabled",
3218
- cardTone: tone
3219
- }, config),
3220
- hovered: buildInputStateColorTheme({
3221
- mode,
3222
- scheme,
3223
- state: "hovered",
3224
- cardTone: tone
3225
- }, config),
3226
- readOnly: buildInputStateColorTheme({
3227
- mode,
3228
- scheme,
3229
- state: "readOnly",
3230
- cardTone: tone
3231
- }, config),
3232
- disabled: buildInputStateColorTheme({
3233
- mode,
3234
- scheme,
3235
- state: "disabled",
3236
- cardTone: tone
3237
- }, config)
3238
- };
3239
- }
3240
- function buildInputStateColorTheme(options, config) {
3241
- const {
3242
- cardTone,
3243
- mode,
3244
- scheme,
3245
- state
3246
- } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3247
- hue,
3248
- scheme
3249
- };
3250
- return {
3251
- _blend: blendMode[scheme === "light" ? 0 : 1],
3252
- bg: resolveColorTokenValue(context, tokens?.bg),
3253
- border: resolveColorTokenValue(context, tokens?.border),
3254
- fg: resolveColorTokenValue(context, tokens?.fg),
3255
- muted: {
3256
- bg: resolveColorTokenValue(context, tokens?.muted?.bg)
3257
- },
3258
- placeholder: resolveColorTokenValue(context, tokens?.placeholder)
3259
- };
3260
- }
3261
- function buildSelectableColorTheme(options, config) {
3262
- const {
3263
- scheme,
3264
- tone: cardTone
3265
- } = options, tones2 = {};
3266
- for (const tone of THEME_COLOR_STATE_TONES)
3267
- tones2[tone] = buildSelectableStatesColorTheme({
3268
- cardTone,
3269
- scheme,
3270
- tone
3271
- }, config);
3272
- return tones2;
3273
- }
3274
- function buildSelectableStatesColorTheme(options, config) {
3275
- const {
3276
- cardTone,
3277
- scheme,
3278
- tone
3279
- } = options, states = {};
3280
- for (const state of THEME_COLOR_STATES)
3281
- states[state] = buildSelectableStateColorTheme({
3282
- cardTone,
3283
- tone,
3284
- scheme,
3285
- state
3286
- }, config);
3287
- return states;
3288
- }
3289
- function buildSelectableStateColorTheme(options, config) {
3290
- const {
3291
- cardTone,
3292
- scheme,
3293
- state,
3294
- tone
3295
- } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3296
- hue,
3297
- scheme
3298
- };
3299
- return {
3300
- _blend: blendMode[scheme === "light" ? 0 : 1],
3301
- accent: {
3302
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3303
- },
3304
- avatar: buildAvatarColorTheme({
3305
- scheme
3306
- }, tokens),
3307
- badge: buildBadgeColorTheme(tokens?.badge, {
3308
- scheme
3309
- }, config),
3310
- bg: resolveColorTokenValue(context, tokens?.bg),
3311
- border: resolveColorTokenValue(context, tokens?.border),
3312
- code: {
3313
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3314
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3315
- },
3316
- fg: resolveColorTokenValue(context, tokens?.fg),
3317
- icon: resolveColorTokenValue(context, tokens?.icon),
3318
- muted: {
3319
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3320
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3321
- },
3322
- kbd: {
3323
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3324
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3325
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3326
- },
3327
- link: {
3328
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3329
- },
3330
- skeleton: {
3331
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3332
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3333
- }
3334
- };
3335
- }
3336
- function buildSyntaxColorTheme(options, config) {
3337
- const {
3338
- scheme
3339
- } = options, tokens = config?.color?.syntax, context = {
3340
- hue: "gray",
3341
- scheme
3342
- };
3343
- return {
3344
- atrule: resolveColorTokenValue(context, tokens?.atrule),
3345
- attrName: resolveColorTokenValue(context, tokens?.attrName),
3346
- attrValue: resolveColorTokenValue(context, tokens?.attrValue),
3347
- attribute: resolveColorTokenValue(context, tokens?.attribute),
3348
- boolean: resolveColorTokenValue(context, tokens?.boolean),
3349
- builtin: resolveColorTokenValue(context, tokens?.builtin),
3350
- cdata: resolveColorTokenValue(context, tokens?.cdata),
3351
- char: resolveColorTokenValue(context, tokens?.char),
3352
- class: resolveColorTokenValue(context, tokens?.class),
3353
- className: resolveColorTokenValue(context, tokens?.className),
3354
- comment: resolveColorTokenValue(context, tokens?.comment),
3355
- constant: resolveColorTokenValue(context, tokens?.constant),
3356
- deleted: resolveColorTokenValue(context, tokens?.deleted),
3357
- doctype: resolveColorTokenValue(context, tokens?.doctype),
3358
- entity: resolveColorTokenValue(context, tokens?.entity),
3359
- function: resolveColorTokenValue(context, tokens?.function),
3360
- hexcode: resolveColorTokenValue(context, tokens?.hexcode),
3361
- id: resolveColorTokenValue(context, tokens?.id),
3362
- important: resolveColorTokenValue(context, tokens?.important),
3363
- inserted: resolveColorTokenValue(context, tokens?.inserted),
3364
- keyword: resolveColorTokenValue(context, tokens?.keyword),
3365
- number: resolveColorTokenValue(context, tokens?.number),
3366
- operator: resolveColorTokenValue(context, tokens?.operator),
3367
- prolog: resolveColorTokenValue(context, tokens?.prolog),
3368
- property: resolveColorTokenValue(context, tokens?.property),
3369
- pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
3370
- pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
3371
- punctuation: resolveColorTokenValue(context, tokens?.punctuation),
3372
- regex: resolveColorTokenValue(context, tokens?.regex),
3373
- selector: resolveColorTokenValue(context, tokens?.selector),
3374
- string: resolveColorTokenValue(context, tokens?.string),
3375
- symbol: resolveColorTokenValue(context, tokens?.symbol),
3376
- tag: resolveColorTokenValue(context, tokens?.tag),
3377
- unit: resolveColorTokenValue(context, tokens?.unit),
3378
- url: resolveColorTokenValue(context, tokens?.url),
3379
- variable: resolveColorTokenValue(context, tokens?.variable)
3380
- };
3381
- }
3382
- const defaultColorPalette = color.color;
3383
- function mixChannel(b, s, weight) {
3384
- const delta = (s - b) * weight;
3385
- return b + delta;
3386
- }
3387
- function mix(b, s, weight) {
3388
- return {
3389
- r: mixChannel(b.r, s.r, weight),
3390
- g: mixChannel(b.g, s.g, weight),
3391
- b: mixChannel(b.b, s.b, weight)
3392
- };
3393
- }
3394
- function multiplyChannel(b, s) {
3395
- return b * s;
3396
- }
3397
- function multiply(b, s) {
3398
- return {
3399
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
3400
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
3401
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
3402
- };
3403
- }
3404
- function screenChannel(b, s) {
3405
- return b + s - b * s;
3406
- }
3407
- function screen(b, s) {
3408
- return {
3409
- r: screenChannel(b.r / 255, s.r / 255) * 255,
3410
- g: screenChannel(b.g / 255, s.g / 255) * 255,
3411
- b: screenChannel(b.b / 255, s.b / 255) * 255
3412
- };
3413
- }
3414
- function lerp(x, y, a) {
3415
- return x * (1 - a) + y * a;
3416
- }
3417
- function invlerp(x, y, a) {
3418
- return clamp((a - x) / (y - x));
3419
- }
3420
- function clamp(a, min = 0, max = 1) {
3421
- return Math.min(max, Math.max(min, a));
3422
- }
3423
- function range(x1, y1, x2, y2, a) {
3424
- return lerp(x2, y2, invlerp(x1, y1, a));
3425
- }
3426
- function round(value) {
3427
- return Math.round(value);
3428
- }
3429
- function hexToRgb(hex) {
3430
- if (hex.length === 4) {
3431
- const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
3432
- return {
3433
- r: parseInt(hexR + hexR, 16),
3434
- g: parseInt(hexG + hexG, 16),
3435
- b: parseInt(hexB + hexB, 16)
3436
- };
3437
- }
3438
- return {
3439
- r: parseInt(hex.slice(1, 3), 16),
3440
- g: parseInt(hex.slice(3, 5), 16),
3441
- b: parseInt(hex.slice(5, 7), 16)
3442
- };
3443
- }
3444
- function rgbaToRGBA(rgba2) {
3445
- const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
3446
- return {
3447
- r: parseInt(values[0]),
3448
- g: parseInt(values[1]),
3449
- b: parseInt(values[2]),
3450
- a: parseFloat(values[3])
3451
- };
3452
- }
3453
- function rgbToHex(color2) {
3454
- const r = round(clamp(Math.round(color2.r), 0, 255)), g = round(clamp(Math.round(color2.g), 0, 255)), b = round(clamp(Math.round(color2.b), 0, 255));
3455
- return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3456
- }
3457
- function rgbToHsl({
3458
- r,
3459
- g,
3460
- b
3461
- }) {
3462
- r /= 255, g /= 255, b /= 255;
3463
- const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
3464
- let h = 0, s = 0, l = 0;
3465
- return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
3466
- h,
3467
- s,
3468
- l
3469
- };
3470
- }
3471
- function hslToRgb(hsl) {
3472
- const s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2;
3473
- let r = 0, g = 0, b = 0;
3474
- return 0 <= hsl.h && hsl.h < 60 ? (r = c, g = x, b = 0) : 60 <= hsl.h && hsl.h < 120 ? (r = x, g = c, b = 0) : 120 <= hsl.h && hsl.h < 180 ? (r = 0, g = c, b = x) : 180 <= hsl.h && hsl.h < 240 ? (r = 0, g = x, b = c) : 240 <= hsl.h && hsl.h < 300 ? (r = x, g = 0, b = c) : 300 <= hsl.h && hsl.h < 360 && (r = c, g = 0, b = x), {
3475
- r: Math.round((r + m) * 255),
3476
- g: Math.round((g + m) * 255),
3477
- b: Math.round((b + m) * 255)
3478
- };
3479
- }
3480
- const HEX_CHARS = "0123456789ABCDEFabcdef", HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
3481
- function isHexChars(str) {
3482
- for (const c of str)
3483
- if (HEX_CHARS.indexOf(c) === -1)
3484
- return !1;
3485
- return !0;
3486
- }
3487
- function isHex(str) {
3488
- return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
3489
- }
3490
- function parseHsl(str) {
3491
- const res = HSL_RE.exec(str);
3492
- if (!res)
3493
- throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
3494
- return {
3495
- h: parseInt(res[1]),
3496
- s: parseFloat(res[3]),
3497
- l: parseFloat(res[5])
3498
- };
3499
- }
3500
- function parseColor(color2) {
3501
- if (!color2) return {
3502
- r: 0,
3503
- g: 0,
3504
- b: 0
3505
- };
3506
- if (typeof color2 != "string")
3507
- throw new Error("parseColor: expected a string");
3508
- if (isHex(color2))
3509
- return hexToRgb(color2);
3510
- if (color2.startsWith("hsl("))
3511
- return hslToRgb(parseHsl(color2));
3512
- if (color2.startsWith("rgba("))
3513
- return rgbaToRGBA(color2);
3514
- throw new Error(`parseColor: unexpected color format: "${color2}"`);
3515
- }
3516
- function getContrastRatio(bg, fg) {
3517
- const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
3518
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
3519
- }
3520
- function rgb_lrgb({
3521
- r,
3522
- g,
3523
- b
3524
- }) {
3525
- return [rgb_lrgb1(r / 255), rgb_lrgb1(g / 255), rgb_lrgb1(b / 255)];
3526
- }
3527
- function rgb_lrgb1(v) {
3528
- return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
3529
- }
3530
- function lrgb_luminance([r, g, b]) {
3531
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
3532
- }
3533
- function rgba(color2, a) {
3534
- const rgb = parseColor(color2);
3535
- return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3536
- }
3537
- const RGB_RANGE = [0, 255];
3538
- function mixThemeColor(value, options) {
3539
- const {
3540
- blendMode
3541
- } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
3542
- r: [black2.r, white2.r],
3543
- g: [black2.g, white2.g],
3544
- b: [black2.b, white2.b]
3545
- }, convertedBgColor = {
3546
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
3547
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
3548
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
3549
- }, convertedColor = {
3550
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
3551
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
3552
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
3553
- }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
3554
- r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
3555
- g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
3556
- b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
3557
- };
3558
- return rgbToHex(v);
3559
- }
3560
- function renderColorValue(str, options) {
3561
- const {
3562
- bg,
3563
- blendMode,
3564
- colorPalette
3565
- } = options;
3566
- if (bg === "white")
3567
- throw new Error("Cannot blend with white background");
3568
- const node = parseTokenValue(str);
3569
- if (!node || node.type !== "color")
3570
- throw new Error(`Invalid color token value: ${str}`);
3571
- let hex = "";
3572
- if (node.key === "black" && (hex = renderColorHex(colorPalette.black)), node.key === "white" && (hex = renderColorHex(colorPalette.white)), node.hue && node.tint && (hex = renderColorHex(colorPalette[node.hue][node.tint])), !hex)
3573
- throw new Error(`Invalid color token value: ${str}`);
3574
- const hexBeforeMix = hex, mixOptions = {
3575
- blendMode,
3576
- bg,
3577
- black: renderColorHex(colorPalette.black),
3578
- // opacity: node.opacity,
3579
- white: renderColorHex(colorPalette.white)
3580
- };
3581
- try {
3582
- if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
3583
- const from = hexToRgb(bg), to = hexToRgb(hex);
3584
- hex = rgbToHex(mix(from, to, node.mix));
3585
- }
3586
- } catch (err) {
3587
- throw console.warn("could not blend", hex, mixOptions), err;
3588
- }
3589
- return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
3590
- }
3591
- function renderColorHex(color2) {
3592
- return typeof color2 == "string" ? color2 : color2.hex;
3593
- }
3594
- function renderThemeColorSchemes(value, config) {
3595
- const colorPalette = config?.palette ?? defaultColorPalette;
3596
- return {
3597
- light: renderThemeColorScheme(colorPalette, value.light),
3598
- dark: renderThemeColorScheme(colorPalette, value.dark)
3599
- };
3600
- }
3601
- function renderThemeColorScheme(colorPalette, value) {
3602
- const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
3603
- colorPalette
3604
- }), renderedDefaultTone = renderThemeColor(defaultTone, {
3605
- colorPalette
3606
- }), bg = renderedDefaultTone.bg;
3607
- if (bg === "white")
3608
- throw new Error("Cannot blend with white background");
3609
- return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
3610
- bg,
3611
- colorPalette
3612
- })])]);
3613
- }
3614
- function renderThemeColor(value, options) {
3615
- const {
3616
- colorPalette,
3617
- bg
3618
- } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
3619
- colorPalette,
3620
- bg,
3621
- blendMode
3622
- }), colorOptions = {
3623
- colorPalette,
3624
- bg: baseBg,
3625
- blendMode
3626
- }, button = renderThemeColorButton(value.button, {
3627
- baseBg,
3628
- blendMode,
3629
- colorPalette
3630
- }), selectable = renderThemeColorSelectable(value.selectable, {
3631
- colorPalette,
3632
- baseBg,
3633
- blendMode
3634
- }), shadow = {
3635
- outline: renderColorValue(value.shadow.outline, colorOptions),
3636
- umbra: renderColorValue(value.shadow.umbra, {
3637
- ...colorOptions,
3638
- bg: void 0,
3639
- colorPalette: {
3640
- ...colorPalette,
3641
- black: "#000000"
3642
- }
3643
- }),
3644
- penumbra: renderColorValue(value.shadow.penumbra, {
3645
- ...colorOptions,
3646
- bg: void 0,
3647
- colorPalette: {
3648
- ...colorPalette,
3649
- black: "#000000"
3650
- }
3651
- }),
3652
- ambient: renderColorValue(value.shadow.ambient, {
3653
- ...colorOptions,
3654
- bg: void 0,
3655
- colorPalette: {
3656
- ...colorPalette,
3657
- black: "#000000"
3658
- }
3659
- })
3660
- };
3661
- return {
3662
- _blend: blendMode,
3663
- _dark: value._dark,
3664
- accent: {
3665
- fg: renderColorValue(value.accent.fg, colorOptions)
3666
- },
3667
- avatar: renderThemeColorAvatar(value.avatar, {
3668
- baseBg,
3669
- colorPalette,
3670
- blendMode
3671
- }),
3672
- backdrop: renderColorValue(value.backdrop, colorOptions),
3673
- badge: renderThemeColorBadge(value.badge, {
3674
- baseBg,
3675
- colorPalette,
3676
- blendMode
3677
- }),
3678
- bg: baseBg,
3679
- border: renderColorValue(value.border, colorOptions),
3680
- button,
3681
- code: {
3682
- bg: renderColorValue(value.code.bg, colorOptions),
3683
- fg: renderColorValue(value.code.fg, colorOptions)
3684
- },
3685
- fg: renderColorValue(value.fg, colorOptions),
3686
- focusRing: renderColorValue(value.focusRing, colorOptions),
3687
- icon: renderColorValue(value.icon, colorOptions),
3688
- input: renderThemeColorInput(value.input, {
3689
- baseBg,
3690
- colorPalette,
3691
- blendMode
3692
- }),
3693
- kbd: renderThemeColorKBD(value.kbd, {
3694
- baseBg,
3695
- colorPalette,
3696
- blendMode
3697
- }),
3698
- link: {
3699
- fg: renderColorValue(value.link.fg, colorOptions)
3700
- },
3701
- muted: {
3702
- bg: renderColorValue(value.muted.bg, colorOptions),
3703
- fg: renderColorValue(value.muted.fg, colorOptions)
3704
- },
3705
- shadow,
3706
- skeleton: {
3707
- from: renderColorValue(value.skeleton.from, colorOptions),
3708
- to: renderColorValue(value.skeleton.to, colorOptions)
3709
- },
3710
- syntax: renderSyntaxColorTheme(value.syntax, {
3711
- baseBg,
3712
- colorPalette,
3713
- blendMode
3714
- }),
3715
- selectable
3716
- };
3717
- }
3718
- function renderThemeColorKBD(value, options) {
3719
- const {
3720
- baseBg,
3721
- blendMode,
3722
- colorPalette
3723
- } = options, rootOptions = {
3724
- bg: baseBg,
3725
- blendMode,
3726
- colorPalette
3727
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3728
- bg,
3729
- blendMode,
3730
- colorPalette
3731
- };
3732
- return {
3733
- bg,
3734
- fg: renderColorValue(value.fg, colorOptions),
3735
- border: renderColorValue(value.border, colorOptions)
3736
- };
3737
- }
3738
- function renderThemeColorAvatar(value, options) {
3739
- const colorAvatar = {};
3740
- for (const hue of color.COLOR_HUES)
3741
- colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
3742
- return colorAvatar;
3743
- }
3744
- function renderThemeColorAvatarColor(value, options) {
3745
- const {
3746
- baseBg,
3747
- blendMode: rootBlendMode,
3748
- colorPalette
3749
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3750
- bg: baseBg,
3751
- blendMode: rootBlendMode,
3752
- colorPalette
3753
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3754
- bg,
3755
- blendMode,
3756
- colorPalette
3757
- };
3758
- return {
3759
- _blend: blendMode,
3760
- bg,
3761
- fg: renderColorValue(value.fg, colorOptions)
3762
- };
3763
- }
3764
- function renderThemeColorBadge(value, options) {
3765
- const colorBadge = {};
3766
- for (const tone of THEME_COLOR_STATE_TONES)
3767
- colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
3768
- return colorBadge;
3769
- }
3770
- function renderThemeColorBadgeColor(value, options) {
3771
- const {
3772
- baseBg,
3773
- blendMode: rootBlendMode,
3774
- colorPalette
3775
- } = options, blendMode = rootBlendMode, rootOptions = {
3776
- bg: baseBg,
3777
- blendMode: rootBlendMode,
3778
- colorPalette
3779
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3780
- bg,
3781
- blendMode,
3782
- colorPalette
3783
- };
3784
- return {
3785
- bg,
3786
- dot: renderColorValue(value.dot, colorOptions),
3787
- fg: renderColorValue(value.fg, colorOptions),
3788
- icon: renderColorValue(value.icon, colorOptions)
3789
- };
3790
- }
3791
- function renderThemeColorButton(value, options) {
3792
- return {
3793
- default: renderThemeColorButtonTones(value.default, options),
3794
- ghost: renderThemeColorButtonTones(value.ghost, options),
3795
- bleed: renderThemeColorButtonTones(value.bleed, options)
3796
- };
3797
- }
3798
- function renderThemeColorButtonTones(value, options) {
3799
- const colorButtonMode = {};
3800
- for (const tone of THEME_COLOR_STATE_TONES)
3801
- colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
3802
- return colorButtonMode;
3803
- }
3804
- function renderThemeColorButtonStates(value, options) {
3805
- return {
3806
- enabled: renderThemeColorState(value.enabled, options),
3807
- hovered: renderThemeColorState(value.hovered, options),
3808
- pressed: renderThemeColorState(value.pressed, options),
3809
- selected: renderThemeColorState(value.selected, options),
3810
- disabled: renderThemeColorState(value.disabled, options)
3811
- };
3812
- }
3813
- function renderThemeColorState(value, options) {
3814
- const {
3815
- baseBg,
3816
- blendMode: rootBlendMode,
3817
- colorPalette
3818
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3819
- bg: baseBg,
3820
- blendMode: rootBlendMode,
3821
- colorPalette
3822
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3823
- bg,
3824
- blendMode,
3825
- colorPalette
3826
- };
3827
- return {
3828
- _blend: blendMode,
3829
- accent: {
3830
- fg: renderColorValue(value.accent.fg, colorOptions)
3831
- },
3832
- avatar: renderThemeColorAvatar(value.avatar, {
3833
- baseBg: bg,
3834
- colorPalette,
3835
- blendMode
3836
- }),
3837
- badge: renderThemeColorBadge(value.badge, {
3838
- baseBg: bg,
3839
- colorPalette,
3840
- blendMode
3841
- }),
3842
- bg,
3843
- border: renderColorValue(value.border, colorOptions),
3844
- code: {
3845
- bg: renderColorValue(value.code.bg, colorOptions),
3846
- fg: renderColorValue(value.code.fg, colorOptions)
806
+ _hue: tokens?._hue ?? "gray",
807
+ bg: {
808
+ 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
809
+ 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
3847
810
  },
3848
- fg: renderColorValue(value.fg, colorOptions),
3849
- icon: renderColorValue(value.icon, colorOptions),
3850
- link: {
3851
- fg: renderColorValue(value.link.fg, colorOptions)
3852
- },
3853
- muted: {
3854
- bg: renderColorValue(value.muted.bg, colorOptions),
3855
- fg: renderColorValue(value.muted.fg, colorOptions)
3856
- },
3857
- kbd: {
3858
- bg: renderColorValue(value.kbd.bg, colorOptions),
3859
- fg: renderColorValue(value.kbd.fg, colorOptions),
3860
- border: renderColorValue(value.kbd.border, colorOptions)
811
+ border: {
812
+ 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
813
+ 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
3861
814
  },
3862
- skeleton: {
3863
- from: renderColorValue(value.skeleton?.from, colorOptions),
3864
- to: renderColorValue(value.skeleton?.to, colorOptions)
815
+ fg: {
816
+ 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
817
+ 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
3865
818
  }
3866
819
  };
3867
820
  }
3868
- function renderThemeColorInput(value, options) {
3869
- return {
3870
- default: renderInputStatesColorTheme(value.default, options),
3871
- invalid: renderInputStatesColorTheme(value.invalid, options)
3872
- };
3873
- }
3874
- function renderInputStatesColorTheme(value, options) {
3875
- return {
3876
- enabled: renderInputStateColorTheme(value.enabled, options),
3877
- hovered: renderInputStateColorTheme(value.hovered, options),
3878
- readOnly: renderInputStateColorTheme(value.readOnly, options),
3879
- disabled: renderInputStateColorTheme(value.disabled, options)
3880
- };
3881
- }
3882
- function renderInputStateColorTheme(value, options) {
3883
- const {
3884
- baseBg,
3885
- blendMode: rootBlendMode,
3886
- colorPalette
3887
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3888
- colorPalette,
3889
- bg: baseBg,
3890
- blendMode: rootBlendMode
3891
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3892
- colorPalette,
3893
- bg,
3894
- blendMode
3895
- };
3896
- return {
3897
- _blend: blendMode,
3898
- bg,
3899
- border: renderColorValue(value.border, colorOptions),
3900
- fg: renderColorValue(value.fg, colorOptions),
3901
- muted: {
3902
- bg: renderColorValue(value.muted.bg, colorOptions)
3903
- },
3904
- placeholder: renderColorValue(value.placeholder, colorOptions)
3905
- };
3906
- }
3907
- function renderThemeColorSelectable(value, options) {
3908
- const colorSelectable = {};
3909
- for (const tone of THEME_COLOR_STATE_TONES)
3910
- colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
3911
- return colorSelectable;
3912
- }
3913
- function renderThemeColorSelectableStates(value, options) {
3914
- return {
3915
- enabled: renderThemeColorState(value.enabled, options),
3916
- hovered: renderThemeColorState(value.hovered, options),
3917
- pressed: renderThemeColorState(value.pressed, options),
3918
- selected: renderThemeColorState(value.selected, options),
3919
- disabled: renderThemeColorState(value.disabled, options)
3920
- };
3921
- }
3922
- function renderSyntaxColorTheme(value, options) {
3923
- const {
3924
- colorPalette,
3925
- baseBg,
3926
- blendMode
3927
- } = options, colorOptions = {
3928
- colorPalette,
3929
- bg: baseBg,
3930
- blendMode
3931
- };
3932
- return {
3933
- atrule: renderColorValue(value.atrule, colorOptions),
3934
- attrName: renderColorValue(value.attrName, colorOptions),
3935
- attrValue: renderColorValue(value.attrValue, colorOptions),
3936
- attribute: renderColorValue(value.attribute, colorOptions),
3937
- boolean: renderColorValue(value.boolean, colorOptions),
3938
- builtin: renderColorValue(value.builtin, colorOptions),
3939
- cdata: renderColorValue(value.cdata, colorOptions),
3940
- char: renderColorValue(value.char, colorOptions),
3941
- class: renderColorValue(value.class, colorOptions),
3942
- className: renderColorValue(value.className, colorOptions),
3943
- comment: renderColorValue(value.comment, colorOptions),
3944
- constant: renderColorValue(value.constant, colorOptions),
3945
- deleted: renderColorValue(value.deleted, colorOptions),
3946
- doctype: renderColorValue(value.doctype, colorOptions),
3947
- entity: renderColorValue(value.entity, colorOptions),
3948
- function: renderColorValue(value.function, colorOptions),
3949
- hexcode: renderColorValue(value.hexcode, colorOptions),
3950
- id: renderColorValue(value.id, colorOptions),
3951
- important: renderColorValue(value.important, colorOptions),
3952
- inserted: renderColorValue(value.inserted, colorOptions),
3953
- keyword: renderColorValue(value.keyword, colorOptions),
3954
- number: renderColorValue(value.number, colorOptions),
3955
- operator: renderColorValue(value.operator, colorOptions),
3956
- prolog: renderColorValue(value.prolog, colorOptions),
3957
- property: renderColorValue(value.property, colorOptions),
3958
- pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
3959
- pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
3960
- punctuation: renderColorValue(value.punctuation, colorOptions),
3961
- regex: renderColorValue(value.regex, colorOptions),
3962
- selector: renderColorValue(value.selector, colorOptions),
3963
- string: renderColorValue(value.string, colorOptions),
3964
- symbol: renderColorValue(value.symbol, colorOptions),
3965
- tag: renderColorValue(value.tag, colorOptions),
3966
- unit: renderColorValue(value.unit, colorOptions),
3967
- url: renderColorValue(value.url, colorOptions),
3968
- variable: renderColorValue(value.variable, colorOptions)
3969
- };
3970
- }
3971
- function buildTheme(config) {
3972
- const colorTheme = buildColorTheme(config), v2 = {
3973
- _version: 2,
3974
- avatar: config?.avatar ?? defaultThemeConfig.avatar,
3975
- button: config?.button ?? defaultThemeConfig.button,
3976
- card: config?.card ?? defaultThemeConfig.card,
3977
- // How colors are generated:
3978
- // 1. Merge custom tokens with default tokens
3979
- // 2. Generate tree of color keys (gray/500, black, white, etc.)
3980
- // 3. Apply mixing and render to hex values
3981
- // render(build(mergeWithDefaults()))
3982
- color: renderThemeColorSchemes(colorTheme, config),
3983
- container: config?.container ?? defaultThemeConfig.container,
3984
- font: config?.font ?? defaultThemeFonts,
3985
- input: config?.input ?? defaultThemeConfig.input,
3986
- layer: config?.layer ?? defaultThemeConfig.layer,
3987
- media: config?.media ?? defaultThemeConfig.media,
3988
- radius: config?.radius ?? defaultThemeConfig.radius,
3989
- shadow: config?.shadow ?? defaultThemeConfig.shadow,
3990
- space: config?.space ?? defaultThemeConfig.space,
3991
- style: config?.style ?? defaultThemeConfig.style
3992
- };
3993
- return v2_v0(v2);
3994
- }
3995
- function themeColor_v0_v2_9(color2) {
3996
- if ("neutral" in color2.badge)
3997
- return color2;
3998
- const colors2 = color2;
821
+ function buildTheme(options) {
822
+ const tokens = resolveTokens({
823
+ color: options?.color ?? defaultColor
824
+ });
3999
825
  return {
4000
- ...colors2,
4001
- badge: {
4002
- ...colors2.badge,
4003
- neutral: colors2.badge.default,
4004
- suggest: colors2.badge.primary
4005
- },
4006
- button: {
4007
- bleed: {
4008
- ...colors2.button.bleed,
4009
- neutral: colors2.button.bleed.default,
4010
- suggest: colors2.button.bleed.primary
4011
- },
4012
- default: {
4013
- ...colors2.button.default,
4014
- neutral: colors2.button.default.default,
4015
- suggest: colors2.button.default.primary
4016
- },
4017
- ghost: {
4018
- ...colors2.button.ghost,
4019
- neutral: colors2.button.ghost.default,
4020
- suggest: colors2.button.ghost.primary
4021
- }
4022
- },
4023
- selectable: {
4024
- ...colors2.selectable,
4025
- neutral: colors2.selectable.default,
4026
- suggest: colors2.selectable.primary
4027
- }
4028
- };
4029
- }
4030
- const cache = /* @__PURE__ */ new Map();
4031
- function getScopedTheme(themeProp, scheme, tone) {
4032
- const cachedTheme = _getCachedTheme(themeProp, scheme, tone);
4033
- if (cachedTheme) return cachedTheme;
4034
- const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp, v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp), colorScheme_v0 = v0.color[scheme] || v0.color.light, color_v0 = colorScheme_v0[tone] || colorScheme_v0.default, layer_v0 = v0.layer || defaultThemeConfig.layer, colorScheme_v2 = v2.color[scheme] || v2.color.light, color_v2 = colorScheme_v2[tone] || colorScheme_v2.default, color_v2_9 = themeColor_v0_v2_9(color_v2), layer_v2 = v2.layer || defaultThemeConfig.layer, theme = {
4035
- sanity: {
4036
- ...v0,
4037
- color: color_v0,
4038
- layer: layer_v0,
4039
- v2: {
4040
- ...v2,
4041
- _resolved: !0,
4042
- color: color_v2_9,
4043
- layer: layer_v2
4044
- }
4045
- }
4046
- };
4047
- return _setCachedTheme(themeProp, scheme, tone, theme), theme;
4048
- }
4049
- function _getCachedTheme(rootTheme, scheme, tone) {
4050
- const schemeCache = cache.get(scheme);
4051
- if (!schemeCache) return;
4052
- const toneCache = schemeCache.get(tone);
4053
- if (toneCache)
4054
- return toneCache.get(rootTheme);
4055
- }
4056
- function _setCachedTheme(rootTheme, scheme, tone, theme) {
4057
- cache.has(scheme) || cache.set(scheme, /* @__PURE__ */ new Map());
4058
- const schemeCache = cache.get(scheme);
4059
- schemeCache.has(tone) || schemeCache.set(tone, /* @__PURE__ */ new WeakMap()), schemeCache.get(tone).set(rootTheme, theme);
4060
- }
4061
- exports.COLOR_CONFIG_AVATAR_COLORS = COLOR_CONFIG_AVATAR_COLORS;
4062
- exports.COLOR_CONFIG_BLEND_KEYS = COLOR_CONFIG_BLEND_KEYS;
4063
- exports.COLOR_CONFIG_CARD_KEYS = COLOR_CONFIG_CARD_KEYS;
4064
- exports.COLOR_CONFIG_CARD_TONES = COLOR_CONFIG_CARD_TONES;
4065
- exports.COLOR_CONFIG_INPUT_MODES = COLOR_CONFIG_INPUT_MODES;
4066
- exports.COLOR_CONFIG_INPUT_STATES = COLOR_CONFIG_INPUT_STATES;
4067
- exports.COLOR_CONFIG_STATES = COLOR_CONFIG_STATES;
4068
- exports.COLOR_CONFIG_STATE_KEYS = COLOR_CONFIG_STATE_KEYS;
4069
- exports.COLOR_CONFIG_STATE_TONES = COLOR_CONFIG_STATE_TONES;
4070
- exports.THEME_COLOR_AVATAR_COLORS = THEME_COLOR_AVATAR_COLORS;
4071
- exports.THEME_COLOR_BLEND_MODES = THEME_COLOR_BLEND_MODES;
4072
- exports.THEME_COLOR_BUTTON_MODES = THEME_COLOR_BUTTON_MODES;
4073
- exports.THEME_COLOR_CARD_TONES = THEME_COLOR_CARD_TONES;
4074
- exports.THEME_COLOR_INPUT_MODES = THEME_COLOR_INPUT_MODES;
4075
- exports.THEME_COLOR_INPUT_STATES = THEME_COLOR_INPUT_STATES;
4076
- exports.THEME_COLOR_SCHEMES = THEME_COLOR_SCHEMES;
4077
- exports.THEME_COLOR_STATES = THEME_COLOR_STATES;
4078
- exports.THEME_COLOR_STATE_TONES = THEME_COLOR_STATE_TONES;
4079
- exports.buildTheme = buildTheme;
4080
- exports.createColorTheme = createColorTheme;
4081
- exports.getContrastRatio = getContrastRatio;
4082
- exports.getScopedTheme = getScopedTheme;
4083
- exports.getTheme_v2 = getTheme_v2;
4084
- exports.hexToRgb = hexToRgb;
4085
- exports.hslToRgb = hslToRgb;
4086
- exports.isColorBlendModeValue = isColorBlendModeValue;
4087
- exports.isColorButtonMode = isColorButtonMode;
4088
- exports.isColorConfigBaseKey = isColorConfigBaseKey;
4089
- exports.isColorConfigBaseTone = isColorConfigBaseTone;
4090
- exports.isColorConfigBlendKey = isColorConfigBlendKey;
4091
- exports.isColorConfigStateKey = isColorConfigStateKey;
4092
- exports.isColorConfigStateTone = isColorConfigStateTone;
4093
- exports.isColorHueKey = isColorHueKey;
4094
- exports.isColorOpacityValue = isColorOpacityValue;
4095
- exports.isColorTintKey = isColorTintKey;
4096
- exports.isColorTokenValue = isColorTokenValue;
4097
- exports.isColorValue = isColorValue;
4098
- exports.is_v0 = is_v0;
4099
- exports.is_v2 = is_v2;
4100
- exports.mix = mix;
4101
- exports.multiply = multiply;
4102
- exports.parseColor = parseColor;
4103
- exports.parseTokenKey = parseTokenKey;
4104
- exports.parseTokenValue = parseTokenValue;
4105
- exports.rgbToHex = rgbToHex;
4106
- exports.rgbToHsl = rgbToHsl;
4107
- exports.rgba = rgba;
4108
- exports.rgbaToRGBA = rgbaToRGBA;
4109
- exports.screen = screen;
4110
- exports.v0_v2 = v0_v2;
4111
- exports.v2_v0 = v2_v0;
826
+ _version: 3,
827
+ _tokens: tokens,
828
+ avatar: defaultTheme.avatar,
829
+ button: defaultTheme.button,
830
+ card: defaultTheme.card,
831
+ color: tokens.color,
832
+ container: defaultTheme.container,
833
+ font: defaultFonts,
834
+ input: defaultTheme.input,
835
+ layer: defaultTheme.layer,
836
+ media: defaultTheme.media,
837
+ palette: {
838
+ black,
839
+ white,
840
+ hues
841
+ },
842
+ radius: defaultTheme.radius,
843
+ shadow: defaultTheme.shadow,
844
+ space: defaultTheme.space
845
+ };
846
+ }
847
+ export {
848
+ AVATAR_COLORS,
849
+ AVATAR_SIZE,
850
+ BUTTON_MODES,
851
+ CARD_TONES,
852
+ COLOR_SCHEMES,
853
+ COLOR_VARIANTS,
854
+ CONTAINER,
855
+ CONTAINER_SCALE,
856
+ ELEMENT_TONES,
857
+ FONT_CODE_SIZE,
858
+ FONT_HEADING_SIZE,
859
+ FONT_LABEL_SIZE,
860
+ FONT_TEXT_SIZE,
861
+ HUES,
862
+ RADIUS,
863
+ SHADOW,
864
+ SPACE,
865
+ TINTS,
866
+ _parseColorToken,
867
+ buildTheme,
868
+ resolveTokens
869
+ };
4112
870
  //# sourceMappingURL=theme.js.map