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