@sanity/ui 4.2.0 → 5.0.0-alpha.10

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 (339) hide show
  1. package/README.md +194 -28
  2. package/bin/sanity-ui.js +14 -0
  3. package/dist/_chunks-es/LazyRefractor.js +20 -0
  4. package/dist/_chunks-es/LazyRefractor.js.map +1 -0
  5. package/dist/cli/checks.js +148 -0
  6. package/dist/cli/config.js +23 -0
  7. package/dist/cli/detect.js +181 -0
  8. package/dist/cli/doctor.js +49 -0
  9. package/dist/cli/index.js +69 -0
  10. package/dist/cli/init.js +189 -0
  11. package/dist/cli/install.js +79 -0
  12. package/dist/cli/log.js +66 -0
  13. package/dist/cli/selfPackage.js +11 -0
  14. package/dist/cli/styles.js +185 -0
  15. package/dist/cli/test-utils.js +8 -0
  16. package/dist/cli/tsconfig.js +236 -0
  17. package/dist/cli/types.js +1 -0
  18. package/dist/cli/versions.js +45 -0
  19. package/dist/index.d.ts +1203 -1469
  20. package/dist/index.js +2123 -1989
  21. package/dist/index.js.map +1 -1
  22. package/dist/polyfills.d.ts +1 -0
  23. package/dist/polyfills.js +5 -0
  24. package/dist/polyfills.js.map +1 -0
  25. package/dist/styles.css +1 -547
  26. package/package.json +57 -58
  27. package/src/cli/checks.test.ts +38 -0
  28. package/src/cli/checks.ts +200 -0
  29. package/src/cli/config.ts +44 -0
  30. package/src/cli/detect.test.ts +191 -0
  31. package/src/cli/detect.ts +205 -0
  32. package/src/cli/doctor.test.ts +52 -0
  33. package/src/cli/doctor.ts +65 -0
  34. package/src/cli/index.ts +77 -0
  35. package/src/cli/init.ts +225 -0
  36. package/src/cli/install.test.ts +52 -0
  37. package/src/cli/install.ts +108 -0
  38. package/src/cli/log.ts +79 -0
  39. package/src/cli/selfPackage.ts +14 -0
  40. package/src/cli/styles.test.ts +130 -0
  41. package/src/cli/styles.ts +205 -0
  42. package/src/cli/test-utils.ts +10 -0
  43. package/src/cli/tsconfig.test.ts +174 -0
  44. package/src/cli/tsconfig.ts +282 -0
  45. package/src/cli/types.ts +77 -0
  46. package/src/cli/versions.test.ts +35 -0
  47. package/src/cli/versions.ts +41 -0
  48. package/src/components/badge/Badge.tsx +53 -0
  49. package/src/components/badge/badge.css +6 -0
  50. package/src/components/badge/badge.props.ts +31 -0
  51. package/src/components/box/Box.tsx +30 -0
  52. package/src/components/box/box.css +4 -0
  53. package/src/components/box/box.props.ts +29 -0
  54. package/src/components/button/Button.tsx +78 -0
  55. package/src/components/button/button.css +72 -0
  56. package/src/components/button/button.props.ts +122 -0
  57. package/src/components/card/Card.tsx +31 -0
  58. package/src/components/card/card.css +4 -0
  59. package/src/components/card/card.props.ts +58 -0
  60. package/src/components/checkbox/Checkbox.tsx +64 -0
  61. package/src/components/checkbox/checkbox.css +100 -0
  62. package/src/components/checkbox/checkbox.props.ts +33 -0
  63. package/src/components/code/Code.tsx +38 -0
  64. package/src/components/code/LazyRefractor.tsx +9 -0
  65. package/src/components/code/code.css +40 -0
  66. package/src/components/code/code.props.ts +44 -0
  67. package/src/components/container/Container.tsx +30 -0
  68. package/src/components/container/container.css +4 -0
  69. package/src/components/container/container.props.ts +28 -0
  70. package/src/components/dialog/Dialog.tsx +139 -0
  71. package/src/components/dialog/dialog.css +49 -0
  72. package/src/components/dialog/dialog.props.ts +45 -0
  73. package/src/components/divider/Divider.tsx +23 -0
  74. package/src/components/divider/divider.props.ts +9 -0
  75. package/src/components/eyebrow/Eyebrow.tsx +54 -0
  76. package/src/components/eyebrow/eyebrow.css +11 -0
  77. package/src/components/eyebrow/eyebrow.props.ts +28 -0
  78. package/src/components/flex/Flex.tsx +30 -0
  79. package/src/components/flex/flex.css +4 -0
  80. package/src/components/flex/flex.props.ts +33 -0
  81. package/src/components/grid/Grid.tsx +30 -0
  82. package/src/components/grid/grid.css +4 -0
  83. package/src/components/grid/grid.props.ts +33 -0
  84. package/src/components/h-stack/HStack.tsx +34 -0
  85. package/src/components/h-stack/hStack.props.ts +17 -0
  86. package/src/components/heading/Heading.tsx +54 -0
  87. package/src/components/heading/heading.css +9 -0
  88. package/src/components/heading/heading.props.ts +31 -0
  89. package/src/components/icon/Icon.tsx +24 -0
  90. package/src/components/icon/icon.css +17 -0
  91. package/src/components/icon/icon.props.ts +35 -0
  92. package/src/components/icon-button/IconButton.tsx +32 -0
  93. package/src/components/icon-button/iconButton.props.ts +31 -0
  94. package/src/components/index.css +28 -0
  95. package/src/components/indicator/Indicator.tsx +42 -0
  96. package/src/components/indicator/indicator.css +4 -0
  97. package/src/components/indicator/indicator.props.ts +24 -0
  98. package/src/components/indicator-stack/IndicatorStack.tsx +31 -0
  99. package/src/components/indicator-stack/indicator-stack.css +7 -0
  100. package/src/components/indicator-stack/indicatorStack.props.ts +15 -0
  101. package/src/components/inline/Inline.tsx +38 -0
  102. package/src/components/inline/inline.css +4 -0
  103. package/src/components/inline/inline.props.ts +100 -0
  104. package/src/components/label/Label.tsx +34 -0
  105. package/src/components/label/label.css +3 -0
  106. package/src/components/label/label.props.ts +25 -0
  107. package/src/components/link/Link.tsx +29 -0
  108. package/src/components/link/link.css +12 -0
  109. package/src/components/link/link.props.ts +23 -0
  110. package/src/components/list/List.tsx +167 -0
  111. package/src/components/list/list.css +25 -0
  112. package/src/components/list/list.props.ts +130 -0
  113. package/src/components/popover/Popover.tsx +85 -0
  114. package/src/components/popover/popover.css +21 -0
  115. package/src/components/popover/popover.props.ts +38 -0
  116. package/src/components/press-area/PressArea.tsx +29 -0
  117. package/src/components/press-area/press-area.css +22 -0
  118. package/src/components/press-area/pressArea.props.ts +16 -0
  119. package/src/components/radio/Radio.tsx +48 -0
  120. package/src/components/radio/radio.css +97 -0
  121. package/src/components/radio/radio.props.ts +25 -0
  122. package/src/components/skip-to-content/SkipToContent.tsx +35 -0
  123. package/src/components/skip-to-content/skip-to-content.css +9 -0
  124. package/src/components/skip-to-content/skipToContent.props.ts +25 -0
  125. package/src/components/spinner/Spinner.tsx +28 -0
  126. package/src/components/spinner/spinner.css +10 -0
  127. package/src/components/spinner/spinner.props.ts +19 -0
  128. package/src/components/switch/Switch.tsx +48 -0
  129. package/src/components/switch/switch.css +119 -0
  130. package/src/components/switch/switch.props.ts +25 -0
  131. package/src/components/text/Text.tsx +53 -0
  132. package/src/components/text/text.css +9 -0
  133. package/src/components/text/text.props.ts +28 -0
  134. package/src/components/tooltip/Tooltip.tsx +97 -0
  135. package/src/components/tooltip/tooltip.css +31 -0
  136. package/src/components/tooltip/tooltip.props.ts +36 -0
  137. package/src/components/tooltip-group/TooltipGroup.tsx +64 -0
  138. package/src/components/tooltip-group/tooltipGroup.props.ts +15 -0
  139. package/src/components/v-stack/VStack.tsx +32 -0
  140. package/src/components/v-stack/vStack.props.ts +17 -0
  141. package/src/components/visually-hidden/VisuallyHidden.tsx +29 -0
  142. package/src/components/visually-hidden/visually-hidden.css +9 -0
  143. package/src/components/visually-hidden/visuallyHidden.props.ts +23 -0
  144. package/src/css/classes/dynamic/flex-child.css +5 -0
  145. package/src/css/classes/dynamic/grid-child.css +8 -0
  146. package/src/css/classes/dynamic/grid-parent.css +6 -0
  147. package/src/css/classes/dynamic/height.css +5 -0
  148. package/src/css/classes/dynamic/index.css +7 -0
  149. package/src/css/classes/dynamic/line-clamp.css +5 -0
  150. package/src/css/classes/dynamic/readme.md +3 -0
  151. package/src/css/classes/dynamic/width.css +7 -0
  152. package/src/css/classes/dynamic/z-index.css +3 -0
  153. package/src/css/classes/generic/display.css +10 -0
  154. package/src/css/classes/generic/flex.css +24 -0
  155. package/src/css/classes/generic/grid.css +7 -0
  156. package/src/css/classes/generic/index.css +7 -0
  157. package/src/css/classes/generic/overflow.css +19 -0
  158. package/src/css/classes/generic/placement.css +202 -0
  159. package/src/css/classes/generic/position.css +7 -0
  160. package/src/css/classes/generic/readme.md +3 -0
  161. package/src/css/classes/generic/text-align.css +5 -0
  162. package/src/css/classes/index.css +4 -0
  163. package/src/css/classes/local/animation.css +4 -0
  164. package/src/css/classes/local/border.css +20 -0
  165. package/src/css/classes/local/index.css +6 -0
  166. package/src/css/classes/local/readme.md +3 -0
  167. package/src/css/classes/local/text-overflow.css +5 -0
  168. package/src/css/classes/local/text-trim.css +45 -0
  169. package/src/css/classes/local/tone.css +75 -0
  170. package/src/css/classes/local/top-anchor.css +4 -0
  171. package/src/css/classes/system/color.css +223 -0
  172. package/src/css/classes/system/container.css +8 -0
  173. package/src/css/classes/system/font-family.css +2 -0
  174. package/src/css/classes/system/font-weight.css +4 -0
  175. package/src/css/classes/system/gap.css +37 -0
  176. package/src/css/classes/system/index.css +10 -0
  177. package/src/css/classes/system/inset.css +56 -0
  178. package/src/css/classes/system/margin.css +148 -0
  179. package/src/css/classes/system/padding.css +78 -0
  180. package/src/css/classes/system/radius.css +10 -0
  181. package/src/css/classes/system/readme.md +3 -0
  182. package/src/css/classes/system/shadow.css +6 -0
  183. package/src/css/classes/system/typography.css +31 -0
  184. package/src/css/global/font-face.css +20 -0
  185. package/src/css/global/index.css +2 -0
  186. package/src/css/global/reset.css +76 -0
  187. package/src/css/tokens/index.css +3 -0
  188. package/src/css/tokens/opacity.css +6 -0
  189. package/src/css/tokens/semantic.css +25 -0
  190. package/src/css/tokens/surface.css +27 -0
  191. package/src/hooks/useIsClient.ts +10 -0
  192. package/src/index.css +18 -0
  193. package/src/index.ts +65 -0
  194. package/src/polyfills.ts +15 -0
  195. package/src/props/border.ts +51 -0
  196. package/src/props/flexChild.ts +29 -0
  197. package/src/props/flexParent.ts +47 -0
  198. package/src/props/gap.ts +31 -0
  199. package/src/props/gridChild.ts +50 -0
  200. package/src/props/gridParent.ts +45 -0
  201. package/src/props/height.ts +29 -0
  202. package/src/props/layout.ts +44 -0
  203. package/src/props/margin.ts +59 -0
  204. package/src/props/overflow.ts +30 -0
  205. package/src/props/padding.ts +59 -0
  206. package/src/props/placement.ts +16 -0
  207. package/src/props/position.ts +52 -0
  208. package/src/props/shadow.ts +15 -0
  209. package/src/props/tone.ts +15 -0
  210. package/src/props/typography.ts +62 -0
  211. package/src/props/width.ts +29 -0
  212. package/src/props/zIndex.ts +15 -0
  213. package/src/styles.css.d.ts +1 -0
  214. package/src/styles.css.node.js +2 -0
  215. package/src/styles.css.test.ts +24 -0
  216. package/src/types/Button.ts +8 -0
  217. package/src/types/Code.ts +6 -0
  218. package/src/types/Container.ts +3 -0
  219. package/src/types/Density.ts +3 -0
  220. package/src/types/Display.ts +11 -0
  221. package/src/types/Eyebrow.ts +3 -0
  222. package/src/types/Flex.ts +22 -0
  223. package/src/types/FontWeight.ts +3 -0
  224. package/src/types/Grid.ts +3 -0
  225. package/src/types/Heading.ts +6 -0
  226. package/src/types/Icon.ts +3 -0
  227. package/src/types/Interactive.ts +8 -0
  228. package/src/types/List.ts +2 -0
  229. package/src/types/Overflow.ts +3 -0
  230. package/src/types/Placement.ts +16 -0
  231. package/src/types/Position.ts +3 -0
  232. package/src/types/PropDef.ts +73 -0
  233. package/src/types/Radius.ts +3 -0
  234. package/src/types/Responsive.ts +10 -0
  235. package/src/types/Shadow.ts +3 -0
  236. package/src/types/Space.ts +15 -0
  237. package/src/types/Text.ts +3 -0
  238. package/src/types/TextAlign.ts +3 -0
  239. package/src/types/Tone.ts +3 -0
  240. package/src/utils/getProps.test.ts +156 -0
  241. package/src/utils/getProps.ts +156 -0
  242. package/src/utils/mergeTriggerProps.ts +66 -0
  243. package/src/utils/renderPortal.tsx +14 -0
  244. package/src/utils/suffixClassName.ts +5 -0
  245. package/src/version.ts +3 -0
  246. package/LICENSE +0 -21
  247. package/dist/_system-CTe2lb5l.d.ts +0 -40
  248. package/dist/_system-CTe2lb5l.d.ts.map +0 -1
  249. package/dist/arrow-BmX6qbAS.js +0 -170
  250. package/dist/arrow-BmX6qbAS.js.map +0 -1
  251. package/dist/autocomplete.d.ts +0 -140
  252. package/dist/autocomplete.d.ts.map +0 -1
  253. package/dist/autocomplete.js +0 -470
  254. package/dist/autocomplete.js.map +0 -1
  255. package/dist/breadcrumbs.d.ts +0 -18
  256. package/dist/breadcrumbs.d.ts.map +0 -1
  257. package/dist/breadcrumbs.js +0 -119
  258. package/dist/breadcrumbs.js.map +0 -1
  259. package/dist/button-BNyKSDyA.js +0 -180
  260. package/dist/button-BNyKSDyA.js.map +0 -1
  261. package/dist/button-dnqMFkWg.d.ts +0 -76
  262. package/dist/button-dnqMFkWg.d.ts.map +0 -1
  263. package/dist/card-C0a0wQTc.d.ts +0 -7
  264. package/dist/card-C0a0wQTc.d.ts.map +0 -1
  265. package/dist/code.d.ts +0 -20
  266. package/dist/code.d.ts.map +0 -1
  267. package/dist/code.js +0 -90
  268. package/dist/code.js.map +0 -1
  269. package/dist/codeFontStyle-84SMhFtI.js +0 -11
  270. package/dist/codeFontStyle-84SMhFtI.js.map +0 -1
  271. package/dist/component-DVlwaWB-.d.ts +0 -25
  272. package/dist/component-DVlwaWB-.d.ts.map +0 -1
  273. package/dist/element-BYgCE_iK.js +0 -51
  274. package/dist/element-BYgCE_iK.js.map +0 -1
  275. package/dist/factory-BzXTX8_Q.js +0 -3056
  276. package/dist/factory-BzXTX8_Q.js.map +0 -1
  277. package/dist/flex-DmbDG2ks.js +0 -76
  278. package/dist/flex-DmbDG2ks.js.map +0 -1
  279. package/dist/font-EtfxKPUz.d.ts +0 -49
  280. package/dist/font-EtfxKPUz.d.ts.map +0 -1
  281. package/dist/getElementRef-Jw7gY0eV.js +0 -102
  282. package/dist/getElementRef-Jw7gY0eV.js.map +0 -1
  283. package/dist/getScopedTheme-C-sZsyAz.js +0 -267
  284. package/dist/getScopedTheme-C-sZsyAz.js.map +0 -1
  285. package/dist/getTheme_v2-y09KqtEb.js +0 -487
  286. package/dist/getTheme_v2-y09KqtEb.js.map +0 -1
  287. package/dist/grid-6JSgMj1O.js +0 -115
  288. package/dist/grid-6JSgMj1O.js.map +0 -1
  289. package/dist/helpers-C8xxXAQC.js +0 -63
  290. package/dist/helpers-C8xxXAQC.js.map +0 -1
  291. package/dist/hotkeys-CaHsQlsO.js +0 -168
  292. package/dist/hotkeys-CaHsQlsO.js.map +0 -1
  293. package/dist/index.d.ts.map +0 -1
  294. package/dist/layer-Bl5R3uNR.js +0 -61
  295. package/dist/layer-Bl5R3uNR.js.map +0 -1
  296. package/dist/layer-ChlP9Ik6.d.ts +0 -242
  297. package/dist/layer-ChlP9Ik6.d.ts.map +0 -1
  298. package/dist/menu.d.ts +0 -146
  299. package/dist/menu.d.ts.map +0 -1
  300. package/dist/menu.js +0 -626
  301. package/dist/menu.js.map +0 -1
  302. package/dist/popover-B7-28L8y.js +0 -408
  303. package/dist/popover-B7-28L8y.js.map +0 -1
  304. package/dist/popover-CMlQeKn0.d.ts +0 -96
  305. package/dist/popover-CMlQeKn0.d.ts.map +0 -1
  306. package/dist/popover.d.ts +0 -2
  307. package/dist/popover.js +0 -3
  308. package/dist/refractor-CC48DwHi.js +0 -20
  309. package/dist/refractor-CC48DwHi.js.map +0 -1
  310. package/dist/responsiveFont-CilwaORG.js +0 -55
  311. package/dist/responsiveFont-CilwaORG.js.map +0 -1
  312. package/dist/rgba-BSYaEUW6.d.ts +0 -846
  313. package/dist/rgba-BSYaEUW6.d.ts.map +0 -1
  314. package/dist/selectable-B0GUIL74.d.ts +0 -7
  315. package/dist/selectable-B0GUIL74.d.ts.map +0 -1
  316. package/dist/stack-rsNFPq2-.js +0 -112
  317. package/dist/stack-rsNFPq2-.js.map +0 -1
  318. package/dist/styles-css.d.ts +0 -2
  319. package/dist/styles-css.js +0 -4
  320. package/dist/textInput-pSfQjkmx.js +0 -313
  321. package/dist/textInput-pSfQjkmx.js.map +0 -1
  322. package/dist/theme.d.ts +0 -280
  323. package/dist/theme.d.ts.map +0 -1
  324. package/dist/theme.js +0 -55
  325. package/dist/theme.js.map +0 -1
  326. package/dist/toast.d.ts +0 -73
  327. package/dist/toast.d.ts.map +0 -1
  328. package/dist/toast.js +0 -302
  329. package/dist/toast.js.map +0 -1
  330. package/dist/tooltip.d.ts +0 -88
  331. package/dist/tooltip.d.ts.map +0 -1
  332. package/dist/tooltip.js +0 -435
  333. package/dist/tooltip.js.map +0 -1
  334. package/dist/useClickOutsideEvent-wGLGWBZN.js +0 -36
  335. package/dist/useClickOutsideEvent-wGLGWBZN.js.map +0 -1
  336. package/dist/useElementSize-BJvbGHq8.js +0 -51
  337. package/dist/useElementSize-BJvbGHq8.js.map +0 -1
  338. package/dist/useLayer-D1usxIE0.js +0 -712
  339. package/dist/useLayer-D1usxIE0.js.map +0 -1
@@ -1,3056 +0,0 @@
1
- import { r as defaultThemeConfig } from "./getTheme_v2-y09KqtEb.js";
2
- import { a as defineLazyProperty, n as v2_v0 } from "./getScopedTheme-C-sZsyAz.js";
3
- import { COLOR_HUES, COLOR_TINTS, color } from "@sanity/color";
4
- const defaultThemeFonts = {
5
- code: {
6
- family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
7
- weights: {
8
- regular: 400,
9
- medium: 500,
10
- semibold: 600,
11
- bold: 700
12
- },
13
- sizes: [
14
- {
15
- ascenderHeight: 4,
16
- descenderHeight: 4,
17
- fontSize: 10,
18
- iconSize: 17,
19
- lineHeight: 15,
20
- letterSpacing: 0
21
- },
22
- {
23
- ascenderHeight: 5,
24
- descenderHeight: 5,
25
- fontSize: 13,
26
- iconSize: 21,
27
- lineHeight: 19,
28
- letterSpacing: 0
29
- },
30
- {
31
- ascenderHeight: 6,
32
- descenderHeight: 6,
33
- fontSize: 16,
34
- iconSize: 25,
35
- lineHeight: 23,
36
- letterSpacing: 0
37
- },
38
- {
39
- ascenderHeight: 7,
40
- descenderHeight: 7,
41
- fontSize: 19,
42
- iconSize: 29,
43
- lineHeight: 27,
44
- letterSpacing: 0
45
- },
46
- {
47
- ascenderHeight: 8,
48
- descenderHeight: 8,
49
- fontSize: 22,
50
- iconSize: 33,
51
- lineHeight: 31,
52
- letterSpacing: 0
53
- }
54
- ]
55
- },
56
- heading: {
57
- family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", Helvetica, Arial, system-ui, sans-serif",
58
- weights: {
59
- regular: 700,
60
- medium: 800,
61
- semibold: 900,
62
- bold: 900
63
- },
64
- sizes: [
65
- {
66
- ascenderHeight: 5,
67
- descenderHeight: 5,
68
- fontSize: 13,
69
- iconSize: 17,
70
- lineHeight: 19,
71
- letterSpacing: 0
72
- },
73
- {
74
- ascenderHeight: 6,
75
- descenderHeight: 6,
76
- fontSize: 16,
77
- iconSize: 25,
78
- lineHeight: 23,
79
- letterSpacing: 0
80
- },
81
- {
82
- ascenderHeight: 7,
83
- descenderHeight: 7,
84
- fontSize: 21,
85
- iconSize: 33,
86
- lineHeight: 29,
87
- letterSpacing: 0
88
- },
89
- {
90
- ascenderHeight: 8,
91
- descenderHeight: 8,
92
- fontSize: 27,
93
- iconSize: 41,
94
- lineHeight: 35,
95
- letterSpacing: 0
96
- },
97
- {
98
- ascenderHeight: 9.5,
99
- descenderHeight: 8.5,
100
- fontSize: 33,
101
- iconSize: 49,
102
- lineHeight: 41,
103
- letterSpacing: 0
104
- },
105
- {
106
- ascenderHeight: 10.5,
107
- descenderHeight: 9.5,
108
- fontSize: 38,
109
- iconSize: 53,
110
- lineHeight: 47,
111
- letterSpacing: 0
112
- }
113
- ]
114
- },
115
- label: {
116
- family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", system-ui, sans-serif",
117
- weights: {
118
- regular: 600,
119
- medium: 700,
120
- semibold: 800,
121
- bold: 900
122
- },
123
- sizes: [
124
- {
125
- ascenderHeight: 2,
126
- descenderHeight: 2,
127
- fontSize: 8.1,
128
- iconSize: 13,
129
- lineHeight: 10,
130
- letterSpacing: .5
131
- },
132
- {
133
- ascenderHeight: 2,
134
- descenderHeight: 2,
135
- fontSize: 9.5,
136
- iconSize: 15,
137
- lineHeight: 11,
138
- letterSpacing: .5
139
- },
140
- {
141
- ascenderHeight: 2,
142
- descenderHeight: 2,
143
- fontSize: 10.8,
144
- iconSize: 17,
145
- lineHeight: 12,
146
- letterSpacing: .5
147
- },
148
- {
149
- ascenderHeight: 2,
150
- descenderHeight: 2,
151
- fontSize: 12.25,
152
- iconSize: 19,
153
- lineHeight: 13,
154
- letterSpacing: .5
155
- },
156
- {
157
- ascenderHeight: 2,
158
- descenderHeight: 2,
159
- fontSize: 13.6,
160
- iconSize: 21,
161
- lineHeight: 14,
162
- letterSpacing: .5
163
- },
164
- {
165
- ascenderHeight: 2,
166
- descenderHeight: 2,
167
- fontSize: 15,
168
- iconSize: 23,
169
- lineHeight: 15,
170
- letterSpacing: .5
171
- }
172
- ]
173
- },
174
- text: {
175
- family: "Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Liberation Sans\", Helvetica, Arial, system-ui, sans-serif",
176
- weights: {
177
- regular: 400,
178
- medium: 500,
179
- semibold: 600,
180
- bold: 700
181
- },
182
- sizes: [
183
- {
184
- ascenderHeight: 4,
185
- descenderHeight: 4,
186
- fontSize: 10,
187
- iconSize: 17,
188
- lineHeight: 15,
189
- letterSpacing: 0
190
- },
191
- {
192
- ascenderHeight: 5,
193
- descenderHeight: 5,
194
- fontSize: 13,
195
- iconSize: 21,
196
- lineHeight: 19,
197
- letterSpacing: 0
198
- },
199
- {
200
- ascenderHeight: 6,
201
- descenderHeight: 6,
202
- fontSize: 15,
203
- iconSize: 25,
204
- lineHeight: 23,
205
- letterSpacing: 0
206
- },
207
- {
208
- ascenderHeight: 7,
209
- descenderHeight: 7,
210
- fontSize: 18,
211
- iconSize: 29,
212
- lineHeight: 27,
213
- letterSpacing: 0
214
- },
215
- {
216
- ascenderHeight: 8,
217
- descenderHeight: 8,
218
- fontSize: 21,
219
- iconSize: 33,
220
- lineHeight: 31,
221
- letterSpacing: 0
222
- }
223
- ]
224
- }
225
- }, THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
226
- "transparent",
227
- "default",
228
- "neutral",
229
- "primary",
230
- "suggest",
231
- "positive",
232
- "caution",
233
- "critical"
234
- ], THEME_COLOR_STATE_TONES = [
235
- "default",
236
- "neutral",
237
- "primary",
238
- "suggest",
239
- "positive",
240
- "caution",
241
- "critical"
242
- ], THEME_COLOR_STATES = [
243
- "enabled",
244
- "hovered",
245
- "pressed",
246
- "selected",
247
- "disabled"
248
- ], THEME_COLOR_BUTTON_MODES = [
249
- "default",
250
- "ghost",
251
- "bleed"
252
- ], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = [
253
- "enabled",
254
- "hovered",
255
- "readOnly",
256
- "disabled"
257
- ], THEME_COLOR_AVATAR_COLORS = COLOR_HUES;
258
- /** @internal */
259
- function isColorBlendModeValue(str) {
260
- return THEME_COLOR_BLEND_MODES.includes(str);
261
- }
262
- /** @internal */
263
- function isColorHueKey(str) {
264
- return COLOR_HUES.includes(str);
265
- }
266
- /** @internal */
267
- function isColorTintKey(str) {
268
- return COLOR_TINTS.includes(str);
269
- }
270
- /** @internal */
271
- function isColorButtonMode(str) {
272
- return THEME_COLOR_BUTTON_MODES.includes(str);
273
- }
274
- /** @public */
275
- const COLOR_CONFIG_STATE_KEYS = [
276
- "_hue",
277
- "bg",
278
- "fg",
279
- "border",
280
- "focusRing",
281
- "muted/fg",
282
- "accent/fg",
283
- "link/fg",
284
- "code/bg",
285
- "code/fg",
286
- "skeleton/from",
287
- "skeleton/to",
288
- "status/dot",
289
- "status/icon"
290
- ], COLOR_CONFIG_CARD_KEYS = [
291
- ...COLOR_CONFIG_STATE_KEYS,
292
- "_hue",
293
- "bg",
294
- "fg",
295
- "border",
296
- "focusRing",
297
- "shadow/outline",
298
- "shadow/umbra",
299
- "shadow/penumbra",
300
- "shadow/ambient"
301
- ], 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];
302
- /** @internal */
303
- function isColorConfigBaseTone(str) {
304
- return COLOR_CONFIG_CARD_TONES.includes(str);
305
- }
306
- /** @internal */
307
- function isColorConfigBaseKey(str) {
308
- return COLOR_CONFIG_CARD_KEYS.includes(str);
309
- }
310
- /** @internal */
311
- function isColorConfigStateKey(str) {
312
- return COLOR_CONFIG_STATE_KEYS.includes(str);
313
- }
314
- /** @internal */
315
- function isColorConfigStateTone(str) {
316
- return COLOR_CONFIG_STATE_TONES.includes(str);
317
- }
318
- /** @internal */
319
- function isColorConfigBlendKey(str) {
320
- return COLOR_CONFIG_BLEND_KEYS.includes(str);
321
- }
322
- /** @internal */
323
- function isColorTokenValue(str) {
324
- return parseTokenValue(str)?.type === "color" || parseTokenValue(str)?.type === "hue";
325
- }
326
- /** @internal */
327
- function isColorValue(str) {
328
- return str === "black" || str === "white";
329
- }
330
- /** @internal */
331
- function isColorOpacityValue(str) {
332
- return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
333
- }
334
- function isColorMixPercentValue(str) {
335
- return /^\d+%$/.test(str);
336
- }
337
- /** @internal */
338
- function parseTokenValue(str) {
339
- let segments = str.split("/"), nextSegment = segments.shift() || "", [segment0, segment0mix] = nextSegment.split(" ");
340
- if (isColorTintKey(segment0)) {
341
- let tint = segment0, segment1 = segments.shift() || "";
342
- return isColorMixPercentValue(segment0mix) ? {
343
- type: "color",
344
- tint,
345
- mix: Number(segment0mix.slice(0, -1)) / 100
346
- } : isColorOpacityValue(segment1) ? {
347
- type: "color",
348
- tint,
349
- opacity: Number(segment1)
350
- } : {
351
- type: "color",
352
- tint
353
- };
354
- }
355
- if (isColorValue(segment0)) {
356
- let key = segment0, segment1 = segments.shift() || "";
357
- return isColorMixPercentValue(segment0mix) ? {
358
- type: "color",
359
- key,
360
- mix: Number(segment0mix.slice(0, -1)) / 100
361
- } : isColorOpacityValue(segment1) ? {
362
- type: "color",
363
- key,
364
- opacity: Number(segment1)
365
- } : {
366
- type: "color",
367
- key
368
- };
369
- }
370
- if (isColorHueKey(segment0)) {
371
- let hue = segment0;
372
- nextSegment = segments.shift() || "";
373
- let [segment1, segment1mix] = nextSegment.split(" ");
374
- if (isColorTintKey(segment1)) {
375
- let tint = segment1, segment2 = segments.shift() || "";
376
- return isColorMixPercentValue(segment1mix) ? {
377
- type: "color",
378
- hue,
379
- tint,
380
- mix: Number(segment1mix.slice(0, -1)) / 100
381
- } : isColorOpacityValue(segment2) ? {
382
- type: "color",
383
- hue,
384
- tint,
385
- opacity: Number(segment2)
386
- } : {
387
- type: "color",
388
- hue,
389
- tint
390
- };
391
- }
392
- return {
393
- type: "hue",
394
- value: hue
395
- };
396
- }
397
- if (isColorBlendModeValue(segment0)) return {
398
- type: "blendMode",
399
- value: segment0
400
- };
401
- }
402
- function compileColorTokenValue(node) {
403
- let key = "";
404
- return key = node.key === "black" || node.key === "white" ? node.key : `${node.hue}/${node.tint}`, node.mix === void 0 ? (node.opacity !== void 0 && (key += `/${node.opacity}`), key) : `${key} ${node.mix * 100}%`;
405
- }
406
- const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
407
- function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
408
- let { hue, scheme } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
409
- if (!node || node.type !== "color") throw Error(`Invalid color token: ${value[0]}`);
410
- return compileColorTokenValue({
411
- ...node,
412
- hue: node.hue || hue
413
- });
414
- }
415
- const defaultColorTokens = {
416
- base: {
417
- "*": {
418
- _blend: ["multiply", "screen"],
419
- accent: { fg: ["purple/600", "purple/400"] },
420
- avatar: { "*": {
421
- _blend: ["screen", "multiply"],
422
- bg: ["500", "400"],
423
- fg: ["white", "black"]
424
- } },
425
- backdrop: ["gray/200/0.5", "black/0.5"],
426
- badge: {
427
- "*": {
428
- bg: ["100", "900"],
429
- fg: ["600", "400"],
430
- icon: ["500", "500"],
431
- dot: ["500", "500"]
432
- },
433
- positive: {
434
- bg: ["200 50%", "900"],
435
- fg: ["600", "500"]
436
- },
437
- caution: {
438
- bg: ["200 50%", "900"],
439
- fg: ["600", "500"]
440
- }
441
- },
442
- bg: ["50", "950"],
443
- border: ["200", "800"],
444
- code: {
445
- bg: ["50", "950"],
446
- fg: ["600", "400"]
447
- },
448
- fg: ["800", "200"],
449
- focusRing: ["blue/500", "blue/500"],
450
- icon: ["600", "400"],
451
- kbd: {
452
- bg: ["white", "black"],
453
- fg: ["600", "400"],
454
- border: ["200", "800"]
455
- },
456
- link: { fg: ["blue/600", "blue/300"] },
457
- muted: {
458
- bg: ["50", "950"],
459
- fg: ["700 75%", "300 75%"]
460
- },
461
- shadow: {
462
- outline: ["500/0.3", "500/0.4"],
463
- umbra: ["gray/500/0.1", "black/0.2"],
464
- penumbra: ["gray/500/0.07", "black/0.14"],
465
- ambient: ["gray/500/0.06", "black/0.12"]
466
- },
467
- skeleton: {
468
- from: ["100", "900"],
469
- to: ["100 50%", "900 50%"]
470
- }
471
- },
472
- transparent: { bg: ["50", "black"] },
473
- default: {
474
- bg: ["white", "950"],
475
- fg: ["800", "200"],
476
- muted: { fg: ["600", "400"] }
477
- },
478
- primary: { _hue: "blue" },
479
- suggest: { _hue: "purple" },
480
- positive: {
481
- _hue: "green",
482
- shadow: { outline: ["500/0.4", "500/0.4"] }
483
- },
484
- caution: {
485
- _hue: "yellow",
486
- shadow: { outline: ["600/0.3", "500/0.4"] }
487
- },
488
- critical: { _hue: "red" }
489
- },
490
- button: {
491
- default: {
492
- "*": {
493
- "*": {
494
- _blend: ["screen", "multiply"],
495
- accent: { fg: ["purple/300", "purple/700"] },
496
- avatar: { "*": {
497
- _blend: ["screen", "multiply"],
498
- bg: ["500", "400"],
499
- fg: ["white", "black"]
500
- } },
501
- badge: { "*": {
502
- bg: ["900", "100"],
503
- fg: ["400", "600"],
504
- dot: ["500", "500"],
505
- icon: ["500", "500"]
506
- } },
507
- bg: ["500", "400"],
508
- border: ["500/0", "400/0"],
509
- code: {
510
- bg: ["500 20%", "400 20%"],
511
- fg: ["200", "600"]
512
- },
513
- fg: ["white", "black"],
514
- icon: ["100 70%", "900 70%"],
515
- kbd: {
516
- bg: ["black", "white"],
517
- fg: ["200", "600"],
518
- border: ["800", "200"]
519
- },
520
- link: { fg: ["blue/200", "blue/600"] },
521
- muted: {
522
- bg: ["950", "50"],
523
- fg: ["100 70%", "900 70%"]
524
- },
525
- skeleton: {
526
- from: ["900", "100"],
527
- to: ["900 50%", "100 50%"]
528
- }
529
- },
530
- hovered: {
531
- bg: ["600", "300"],
532
- border: ["700/0", "300/0"]
533
- },
534
- pressed: { bg: ["700", "300"] },
535
- selected: { bg: ["700", "300"] },
536
- disabled: {
537
- _hue: "gray",
538
- accent: { fg: ["100 70%", "900 70%"] },
539
- avatar: { "*": {
540
- _blend: ["screen", "multiply"],
541
- bg: ["gray/500", "gray/400"],
542
- fg: ["white", "black"]
543
- } },
544
- badge: { "*": {
545
- bg: ["gray/700", "gray/300"],
546
- fg: ["white", "black"],
547
- dot: ["white", "black"],
548
- icon: ["white", "black"]
549
- } },
550
- bg: ["300", "600"],
551
- code: {
552
- bg: ["950", "50"],
553
- fg: ["300", "600"]
554
- },
555
- fg: ["300", "600"],
556
- muted: {
557
- bg: ["950", "50"],
558
- fg: ["300", "600"]
559
- },
560
- kbd: {
561
- bg: ["black", "white"],
562
- fg: ["white", "black"],
563
- border: ["700", "300"]
564
- },
565
- link: { fg: ["100 70%", "900 70%"] }
566
- }
567
- },
568
- default: {
569
- "*": {
570
- avatar: { "*": {
571
- _blend: ["screen", "multiply"],
572
- bg: ["500", "400"],
573
- fg: ["white", "black"]
574
- } },
575
- bg: ["800", "200"],
576
- muted: {
577
- bg: ["950", "50"],
578
- fg: ["400", "600"]
579
- }
580
- },
581
- hovered: { bg: ["900", "100"] },
582
- pressed: { bg: ["black", "white"] },
583
- selected: { bg: ["black", "white"] }
584
- }
585
- },
586
- ghost: {
587
- "*": {
588
- "*": {
589
- _blend: ["multiply", "screen"],
590
- accent: { fg: ["purple/700 60%", "purple/300 70%"] },
591
- avatar: { "*": {
592
- _blend: ["screen", "multiply"],
593
- bg: ["500", "400"],
594
- fg: ["white", "black"]
595
- } },
596
- badge: { "*": {
597
- bg: ["100", "900"],
598
- fg: ["600", "400"],
599
- dot: ["500", "500"],
600
- icon: ["500", "500"]
601
- } },
602
- bg: ["50", "950"],
603
- border: ["100", "900"],
604
- code: {
605
- bg: ["500 10%", "400 10%"],
606
- fg: ["700 60%", "400 60%"]
607
- },
608
- fg: ["600", "400"],
609
- icon: ["700 60%", "300 60%"],
610
- kbd: {
611
- bg: ["white", "black"],
612
- fg: ["600", "400"],
613
- border: ["200", "800"]
614
- },
615
- link: { fg: ["blue/700 60%", "blue/300 60%"] },
616
- muted: {
617
- bg: ["100", "950"],
618
- fg: ["700 60%", "300 60%"]
619
- },
620
- skeleton: {
621
- from: ["100", "900"],
622
- to: ["100 50%", "900 50%"]
623
- }
624
- },
625
- hovered: {
626
- bg: ["100", "900"],
627
- fg: ["700", "300"]
628
- },
629
- pressed: {
630
- bg: ["200", "800"],
631
- fg: ["800", "200"]
632
- },
633
- selected: {
634
- bg: ["200", "800"],
635
- fg: ["800", "200"]
636
- },
637
- disabled: {
638
- _hue: "gray",
639
- accent: { fg: ["200", "800"] },
640
- avatar: { "*": {
641
- _blend: ["screen", "multiply"],
642
- bg: ["gray/100", "gray/900"],
643
- fg: ["white", "black"]
644
- } },
645
- badge: { "*": {
646
- _hue: "gray",
647
- bg: ["50", "950"],
648
- fg: ["gray/200", "gray/800"],
649
- dot: ["gray/200", "gray/800"],
650
- icon: ["gray/200", "gray/800"]
651
- } },
652
- border: ["100", "900"],
653
- code: {
654
- bg: ["50", "950"],
655
- fg: ["200", "800"]
656
- },
657
- fg: ["400", "600"],
658
- icon: ["300", "700"],
659
- muted: { fg: ["300", "700"] },
660
- kbd: {
661
- bg: ["white", "black"],
662
- fg: ["200", "800"],
663
- border: ["100", "900"]
664
- },
665
- link: { fg: ["200", "800"] }
666
- }
667
- },
668
- positive: { "*": { border: ["600 20%", "800"] } },
669
- caution: { "*": { border: ["600 20%", "800"] } }
670
- },
671
- bleed: { "*": {
672
- "*": {
673
- _blend: ["multiply", "screen"],
674
- accent: { fg: ["purple/700 70%", "purple/300 70%"] },
675
- avatar: { "*": {
676
- _blend: ["screen", "multiply"],
677
- bg: ["500", "400"],
678
- fg: ["white", "black"]
679
- } },
680
- badge: { "*": {
681
- bg: ["100", "900"],
682
- fg: ["600", "400"],
683
- dot: ["500", "500"],
684
- icon: ["500", "500"]
685
- } },
686
- bg: ["white", "black"],
687
- border: ["white/0", "black/0"],
688
- code: {
689
- bg: ["50", "950"],
690
- fg: ["700 75%", "300 75%"]
691
- },
692
- fg: ["700", "300"],
693
- icon: ["700 75%", "300 75%"],
694
- kbd: {
695
- bg: ["white", "black"],
696
- fg: ["700", "300"],
697
- border: ["200", "800"]
698
- },
699
- link: { fg: ["blue/700 70%", "blue/300 70%"] },
700
- muted: {
701
- bg: ["100", "950"],
702
- fg: ["700 75%", "300 75%"]
703
- },
704
- skeleton: {
705
- from: ["100", "900"],
706
- to: ["100 50%", "900 50%"]
707
- }
708
- },
709
- hovered: {
710
- bg: ["50", "900"],
711
- fg: ["800", "200"],
712
- icon: ["800 70%", "300 70%"]
713
- },
714
- pressed: {
715
- bg: ["100", "800"],
716
- fg: ["800", "200"],
717
- icon: ["800 70%", "200 70%"]
718
- },
719
- selected: {
720
- bg: ["100", "900"],
721
- fg: ["800", "200"],
722
- icon: ["800 60%", "200 60%"]
723
- },
724
- disabled: {
725
- _hue: "gray",
726
- accent: { fg: ["200", "800"] },
727
- avatar: { "*": {
728
- _blend: ["screen", "multiply"],
729
- bg: ["gray/100", "gray/900"],
730
- fg: ["white", "black"]
731
- } },
732
- badge: { "*": {
733
- _hue: "gray",
734
- bg: ["50", "950"],
735
- fg: ["gray/200", "gray/800"],
736
- dot: ["gray/200", "gray/800"],
737
- icon: ["gray/200", "gray/800"]
738
- } },
739
- code: {
740
- bg: ["50", "950"],
741
- fg: ["200", "800"]
742
- },
743
- fg: ["400", "600"],
744
- icon: ["300", "700"],
745
- muted: { fg: ["400", "600"] },
746
- kbd: {
747
- bg: ["white", "black"],
748
- fg: ["200", "800"],
749
- border: ["100", "900"]
750
- },
751
- link: { fg: ["200", "800"] }
752
- }
753
- } }
754
- },
755
- input: {
756
- "*": {
757
- "*": {
758
- _blend: ["multiply", "screen"],
759
- bg: ["white", "black"],
760
- border: ["200", "700"],
761
- fg: ["black", "200"],
762
- muted: { bg: ["50", "950"] },
763
- placeholder: ["400", "600"]
764
- },
765
- hovered: { border: ["300", "700"] },
766
- readOnly: {
767
- bg: ["50", "950"],
768
- border: ["200", "800"],
769
- fg: ["800", "200"]
770
- },
771
- disabled: {
772
- bg: ["50", "950"],
773
- fg: ["400", "600"],
774
- border: ["100", "900"],
775
- placeholder: ["200", "800 50%"]
776
- }
777
- },
778
- invalid: { "*": {
779
- _hue: "red",
780
- bg: ["100", "950"]
781
- } }
782
- },
783
- selectable: {
784
- "*": {
785
- "*": {
786
- _blend: ["multiply", "screen"],
787
- accent: { fg: ["purple/700 70%", "purple/300 70%"] },
788
- avatar: { "*": {
789
- _blend: ["screen", "multiply"],
790
- bg: ["500", "400"],
791
- fg: ["white", "black"]
792
- } },
793
- badge: { "*": {
794
- bg: ["100", "900"],
795
- fg: ["600", "400"],
796
- dot: ["500", "500"],
797
- icon: ["500", "500"]
798
- } },
799
- bg: ["white", "black"],
800
- border: ["200", "800"],
801
- code: {
802
- bg: ["50", "950"],
803
- fg: ["600", "400"]
804
- },
805
- fg: ["700", "300"],
806
- icon: ["700 75%", "300 75%"],
807
- kbd: {
808
- bg: ["white", "black"],
809
- fg: ["600", "400"],
810
- border: ["200", "800"]
811
- },
812
- link: { fg: ["blue/700 70%", "blue/300 70%"] },
813
- muted: {
814
- bg: ["50", "950"],
815
- fg: ["700 75%", "300 75%"]
816
- },
817
- skeleton: {
818
- from: ["100", "900"],
819
- to: ["100 50%", "900 50%"]
820
- }
821
- },
822
- hovered: { bg: ["50", "950"] },
823
- pressed: { bg: ["100", "900"] },
824
- selected: {
825
- _blend: ["screen", "multiply"],
826
- accent: { fg: ["purple/300", "purple/700"] },
827
- avatar: { "*": {
828
- _blend: ["multiply", "screen"],
829
- bg: ["white", "black"],
830
- fg: ["black", "white"]
831
- } },
832
- badge: { "*": {
833
- bg: ["900", "100"],
834
- fg: ["400", "600"],
835
- dot: ["500", "500"],
836
- icon: ["500", "500"]
837
- } },
838
- bg: ["500", "400"],
839
- border: ["500 20%", "400 20%"],
840
- code: {
841
- bg: ["500 20%", "400 20%"],
842
- fg: ["200", "600"]
843
- },
844
- fg: ["white", "black"],
845
- icon: ["100 70%", "900 70%"],
846
- kbd: {
847
- bg: ["black", "white"],
848
- fg: ["200", "600"],
849
- border: ["800", "200"]
850
- },
851
- link: { fg: ["blue/200", "blue/600"] },
852
- muted: {
853
- bg: ["500 10%", "400 10%"],
854
- fg: ["100 70%", "900 70%"]
855
- },
856
- skeleton: {
857
- from: ["900", "100"],
858
- to: ["900 50%", "100 50%"]
859
- }
860
- },
861
- disabled: {
862
- _hue: "gray",
863
- accent: { fg: ["200", "800"] },
864
- avatar: { "*": {
865
- _blend: ["screen", "multiply"],
866
- bg: ["gray/100", "gray/900"],
867
- fg: ["white", "black"]
868
- } },
869
- badge: { "*": {
870
- _hue: "gray",
871
- bg: ["50", "950"],
872
- fg: ["gray/200", "gray/800"],
873
- dot: ["gray/200", "gray/800"],
874
- icon: ["gray/200", "gray/800"]
875
- } },
876
- border: ["100", "900"],
877
- code: {
878
- bg: ["50", "950"],
879
- fg: ["200", "800"]
880
- },
881
- fg: ["200", "800"],
882
- icon: ["200", "800"],
883
- kbd: {
884
- bg: ["white", "black"],
885
- fg: ["200", "800"],
886
- border: ["100", "900"]
887
- },
888
- link: { fg: ["200", "800"] },
889
- muted: {
890
- bg: ["50 50%", "950 50%"],
891
- fg: ["200", "800"]
892
- }
893
- }
894
- },
895
- default: { selected: { _hue: "blue" } },
896
- critical: { disabled: { bg: ["50 50%", "950 50%"] } }
897
- },
898
- syntax: {
899
- atrule: ["purple/600", "purple/400"],
900
- attrName: ["green/600", "green/400"],
901
- attrValue: ["yellow/600", "yellow/400"],
902
- attribute: ["yellow/600", "yellow/400"],
903
- boolean: ["purple/600", "purple/400"],
904
- builtin: ["purple/600", "purple/400"],
905
- cdata: ["yellow/600", "yellow/400"],
906
- char: ["yellow/600", "yellow/400"],
907
- class: ["orange/600", "orange/400"],
908
- className: ["cyan/600", "cyan/400"],
909
- comment: ["gray/400", "gray/600"],
910
- constant: ["purple/600", "purple/400"],
911
- deleted: ["red/600", "red/400"],
912
- entity: ["red/600", "red/400"],
913
- function: ["green/600", "green/400"],
914
- hexcode: ["blue/600", "blue/400"],
915
- id: ["purple/600", "purple/400"],
916
- important: ["purple/600", "purple/400"],
917
- inserted: ["yellow/600", "yellow/400"],
918
- keyword: ["magenta/600", "magenta/400"],
919
- number: ["purple/600", "purple/400"],
920
- operator: ["magenta/600", "magenta/400"],
921
- property: ["blue/600", "blue/400"],
922
- pseudoClass: ["yellow/600", "yellow/400"],
923
- pseudoElement: ["yellow/600", "yellow/400"],
924
- punctuation: ["gray/600", "gray/400"],
925
- regex: ["blue/600", "blue/400"],
926
- selector: ["red/600", "red/400"],
927
- string: ["yellow/600", "yellow/400"],
928
- symbol: ["purple/600", "purple/400"],
929
- tag: ["red/600", "red/400"],
930
- unit: ["orange/600", "orange/400"],
931
- url: ["red/600", "red/400"],
932
- variable: ["red/600", "red/400"]
933
- }
934
- };
935
- function isRecord(value) {
936
- return !(!value || typeof value != "object" || Array.isArray(value));
937
- }
938
- function merge(...records) {
939
- let _records = records.filter(Boolean);
940
- return _records.length === 0 ? {} : _records.reduce(_merge, {});
941
- }
942
- function _merge(acc, source) {
943
- for (let key of Object.keys(source)) {
944
- let prevValue = acc[key], nextValue = source[key];
945
- acc[key] = isRecord(prevValue) && isRecord(nextValue) ? merge(prevValue, nextValue) : nextValue;
946
- }
947
- return acc;
948
- }
949
- /**
950
- * Convert a tree of color tokens from a sparse format to a dense format.
951
- */
952
- function resolveColorTokens(inputTokens) {
953
- let tokens = merge(defaultColorTokens, inputTokens);
954
- return {
955
- base: resolveBaseColorTokens(tokens),
956
- button: resolveButtonColorTokens(tokens),
957
- input: resolveInputColorTokens(tokens),
958
- selectable: resolveSelectableColorTokens(tokens),
959
- syntax: tokens.syntax
960
- };
961
- }
962
- function resolveBaseColorTokens(sparseTokens) {
963
- let tokens = {};
964
- for (let tone of THEME_COLOR_CARD_TONES) tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
965
- return tokens;
966
- }
967
- function resolveBaseColorTones(inputTokens, tone) {
968
- let spec = merge(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
969
- return {
970
- ...spec,
971
- _hue: hue,
972
- avatar: COLOR_HUES.reduce((acc, hue) => ({
973
- ...acc,
974
- [hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
975
- }), {}),
976
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
977
- ...acc,
978
- [tone]: {
979
- _hue: inputTokens?.base?.[tone]?._hue || hue,
980
- ...spec.badge?.["*"],
981
- ...spec.badge?.[tone]
982
- }
983
- }), {})
984
- };
985
- }
986
- function resolveButtonColorTokens(inputTokens) {
987
- let tokens = {};
988
- for (let mode of THEME_COLOR_BUTTON_MODES) tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
989
- return tokens;
990
- }
991
- function resolveButtonToneColorTokens(inputTokens, mode) {
992
- let tokens = {};
993
- for (let tone of THEME_COLOR_STATE_TONES) tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
994
- return tokens;
995
- }
996
- function resolveButtonModeColorTokens(inputTokens, mode, tone) {
997
- let tokens = {};
998
- for (let state of THEME_COLOR_STATES) tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
999
- return tokens;
1000
- }
1001
- function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
1002
- let 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;
1003
- return {
1004
- ...spec,
1005
- _hue: hue,
1006
- avatar: COLOR_HUES.reduce((acc, hue) => ({
1007
- ...acc,
1008
- [hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
1009
- }), {}),
1010
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
1011
- ...acc,
1012
- [tone]: {
1013
- _hue: inputTokens?.base?.[tone]?._hue || hue,
1014
- ...spec.badge?.["*"],
1015
- ...spec.badge?.[tone]
1016
- }
1017
- }), {})
1018
- };
1019
- }
1020
- function resolveInputColorTokens(inputTokens) {
1021
- let tokens = {};
1022
- for (let mode of THEME_COLOR_INPUT_MODES) tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
1023
- return tokens;
1024
- }
1025
- function resolveInputModeColorTokens(inputTokens, mode) {
1026
- let states = {};
1027
- for (let state of THEME_COLOR_INPUT_STATES) states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
1028
- return states;
1029
- }
1030
- function resolveInputStateColorTokens(inputTokens, mode, state) {
1031
- let spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
1032
- return {
1033
- ...spec,
1034
- _hue: hue
1035
- };
1036
- }
1037
- function resolveSelectableColorTokens(inputTokens) {
1038
- let tokens = {};
1039
- for (let tone of THEME_COLOR_STATE_TONES) tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
1040
- return tokens;
1041
- }
1042
- function resolveSelectableToneColorTokens(inputTokens, tone) {
1043
- let states = { _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue };
1044
- for (let state of THEME_COLOR_STATES) states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
1045
- return states;
1046
- }
1047
- function resolveSelectableStateColorTokens(inputTokens, tone, state) {
1048
- let spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
1049
- return {
1050
- ...spec,
1051
- _hue: hue,
1052
- avatar: COLOR_HUES.reduce((acc, hue) => ({
1053
- ...acc,
1054
- [hue]: merge({ _hue: hue }, spec.avatar?.["*"], spec.avatar?.[hue])
1055
- }), {}),
1056
- badge: THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
1057
- ...acc,
1058
- [tone]: {
1059
- _hue: inputTokens?.base?.[tone]?._hue || hue,
1060
- ...spec.badge?.["*"],
1061
- ...spec.badge?.[tone]
1062
- }
1063
- }), {})
1064
- };
1065
- }
1066
- function buildColorTheme(config) {
1067
- let resolvedConfig = {
1068
- ...config,
1069
- color: resolveColorTokens(config?.color)
1070
- }, schemes = {};
1071
- return defineLazyProperty(schemes, "light", () => buildColorScheme({ scheme: "light" }, resolvedConfig)), defineLazyProperty(schemes, "dark", () => buildColorScheme({ scheme: "dark" }, resolvedConfig)), schemes;
1072
- }
1073
- function buildColorScheme(options, config) {
1074
- let { scheme } = options, colorScheme = {};
1075
- for (let tone of THEME_COLOR_CARD_TONES) defineLazyProperty(colorScheme, tone, () => buildCardColorTheme({
1076
- scheme,
1077
- tone
1078
- }, config));
1079
- return colorScheme;
1080
- }
1081
- function buildCardColorTheme(options, config) {
1082
- let { scheme, tone } = options, tokens = config?.color?.base?.[tone], context = {
1083
- hue: tokens?._hue || "gray",
1084
- scheme
1085
- };
1086
- return {
1087
- _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
1088
- _dark: scheme === "dark",
1089
- accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
1090
- avatar: buildAvatarColorTheme({ scheme }, tokens),
1091
- backdrop: resolveColorTokenValue(context, tokens?.backdrop),
1092
- badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
1093
- bg: resolveColorTokenValue(context, tokens?.bg),
1094
- border: resolveColorTokenValue(context, tokens?.border),
1095
- button: buildButtonColorTheme({
1096
- scheme,
1097
- tone
1098
- }, config),
1099
- code: {
1100
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
1101
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
1102
- },
1103
- fg: resolveColorTokenValue(context, tokens?.fg),
1104
- focusRing: resolveColorTokenValue(context, tokens?.focusRing),
1105
- icon: resolveColorTokenValue(context, tokens?.icon),
1106
- input: buildInputColorTheme({
1107
- scheme,
1108
- tone
1109
- }, config),
1110
- kbd: {
1111
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
1112
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
1113
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
1114
- },
1115
- link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
1116
- muted: {
1117
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
1118
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
1119
- },
1120
- selectable: buildSelectableColorTheme({
1121
- scheme,
1122
- tone
1123
- }, config),
1124
- shadow: buildShadowColorTheme({
1125
- scheme,
1126
- tone
1127
- }, config),
1128
- skeleton: {
1129
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
1130
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
1131
- },
1132
- syntax: buildSyntaxColorTheme({ scheme }, config)
1133
- };
1134
- }
1135
- function buildShadowColorTheme(options, config) {
1136
- let { scheme, tone } = options, tokens = config?.color?.base?.[tone], context = {
1137
- hue: tokens?._hue || "gray",
1138
- scheme
1139
- };
1140
- return {
1141
- outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
1142
- umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
1143
- penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
1144
- ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
1145
- };
1146
- }
1147
- function buildAvatarColorTheme(options, stateTokens) {
1148
- let { scheme } = options;
1149
- return {
1150
- gray: _buildAvatarColorTheme({
1151
- color: "gray",
1152
- scheme
1153
- }, stateTokens),
1154
- blue: _buildAvatarColorTheme({
1155
- color: "blue",
1156
- scheme
1157
- }, stateTokens),
1158
- purple: _buildAvatarColorTheme({
1159
- color: "purple",
1160
- scheme
1161
- }, stateTokens),
1162
- magenta: _buildAvatarColorTheme({
1163
- color: "magenta",
1164
- scheme
1165
- }, stateTokens),
1166
- red: _buildAvatarColorTheme({
1167
- color: "red",
1168
- scheme
1169
- }, stateTokens),
1170
- orange: _buildAvatarColorTheme({
1171
- color: "orange",
1172
- scheme
1173
- }, stateTokens),
1174
- yellow: _buildAvatarColorTheme({
1175
- color: "yellow",
1176
- scheme
1177
- }, stateTokens),
1178
- green: _buildAvatarColorTheme({
1179
- color: "green",
1180
- scheme
1181
- }, stateTokens),
1182
- cyan: _buildAvatarColorTheme({
1183
- color: "cyan",
1184
- scheme
1185
- }, stateTokens)
1186
- };
1187
- }
1188
- function _buildAvatarColorTheme(options, stateTokens) {
1189
- let { color, scheme } = options, tokens = stateTokens?.avatar?.[color], context = {
1190
- hue: tokens?._hue || "gray",
1191
- scheme
1192
- };
1193
- return {
1194
- _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
1195
- bg: resolveColorTokenValue(context, tokens?.bg),
1196
- fg: resolveColorTokenValue(context, tokens?.fg)
1197
- };
1198
- }
1199
- function buildBadgeColorTheme(tokens, options, config) {
1200
- let { scheme } = options, colorBadge = {};
1201
- for (let tone of THEME_COLOR_STATE_TONES) colorBadge[tone] = _buildBadgeColorTheme(tokens, {
1202
- scheme,
1203
- tone
1204
- }, config);
1205
- return colorBadge;
1206
- }
1207
- function _buildBadgeColorTheme(parentTokens, options, config) {
1208
- let { scheme, tone } = options, tokens = parentTokens?.[tone], context = {
1209
- hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
1210
- scheme
1211
- };
1212
- return {
1213
- bg: resolveColorTokenValue(context, tokens?.bg),
1214
- fg: resolveColorTokenValue(context, tokens?.fg),
1215
- dot: resolveColorTokenValue(context, tokens?.dot),
1216
- icon: resolveColorTokenValue(context, tokens?.icon)
1217
- };
1218
- }
1219
- function buildButtonColorTheme(options, config) {
1220
- let { scheme, tone: cardTone } = options, modes = {};
1221
- for (let mode of THEME_COLOR_BUTTON_MODES) modes[mode] = buildButtonTonesColorTheme({
1222
- cardTone,
1223
- scheme,
1224
- mode
1225
- }, config);
1226
- return modes;
1227
- }
1228
- function buildButtonTonesColorTheme(options, config) {
1229
- let { cardTone, mode, scheme } = options, tones = {};
1230
- for (let tone of THEME_COLOR_STATE_TONES) tones[tone] = buildButtonStatesColorTheme({
1231
- cardTone,
1232
- mode,
1233
- scheme,
1234
- tone
1235
- }, config);
1236
- return tones;
1237
- }
1238
- function buildButtonStatesColorTheme(options, config) {
1239
- let { cardTone, mode, scheme, tone } = options, states = {};
1240
- for (let state of THEME_COLOR_STATES) states[state] = buildButtonStateColorTheme({
1241
- cardTone,
1242
- mode,
1243
- tone,
1244
- scheme,
1245
- state
1246
- }, config);
1247
- return states;
1248
- }
1249
- function buildButtonStateColorTheme(options, config) {
1250
- let { cardTone, mode, tone, scheme, state } = 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 = {
1251
- hue,
1252
- scheme
1253
- };
1254
- return {
1255
- _blend: blendMode[scheme === "light" ? 0 : 1],
1256
- accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
1257
- avatar: buildAvatarColorTheme({ scheme }, tokens),
1258
- badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
1259
- bg: resolveColorTokenValue(context, tokens?.bg),
1260
- border: resolveColorTokenValue(context, tokens?.border),
1261
- code: {
1262
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
1263
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
1264
- },
1265
- fg: resolveColorTokenValue(context, tokens?.fg),
1266
- icon: resolveColorTokenValue(context, tokens?.icon),
1267
- muted: {
1268
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
1269
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
1270
- },
1271
- kbd: {
1272
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
1273
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
1274
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
1275
- },
1276
- link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
1277
- skeleton: {
1278
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
1279
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
1280
- }
1281
- };
1282
- }
1283
- function buildInputColorTheme(options, config) {
1284
- let { scheme, tone } = options;
1285
- return {
1286
- default: buildInputStatesColorTheme({
1287
- mode: "default",
1288
- scheme,
1289
- tone
1290
- }, config),
1291
- invalid: buildInputStatesColorTheme({
1292
- mode: "invalid",
1293
- scheme,
1294
- tone
1295
- }, config)
1296
- };
1297
- }
1298
- function buildInputStatesColorTheme(options, config) {
1299
- let { mode, scheme, tone } = options;
1300
- return {
1301
- enabled: buildInputStateColorTheme({
1302
- mode,
1303
- scheme,
1304
- state: "enabled",
1305
- cardTone: tone
1306
- }, config),
1307
- hovered: buildInputStateColorTheme({
1308
- mode,
1309
- scheme,
1310
- state: "hovered",
1311
- cardTone: tone
1312
- }, config),
1313
- readOnly: buildInputStateColorTheme({
1314
- mode,
1315
- scheme,
1316
- state: "readOnly",
1317
- cardTone: tone
1318
- }, config),
1319
- disabled: buildInputStateColorTheme({
1320
- mode,
1321
- scheme,
1322
- state: "disabled",
1323
- cardTone: tone
1324
- }, config)
1325
- };
1326
- }
1327
- function buildInputStateColorTheme(options, config) {
1328
- let { cardTone, mode, scheme, state } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
1329
- hue,
1330
- scheme
1331
- };
1332
- return {
1333
- _blend: blendMode[scheme === "light" ? 0 : 1],
1334
- bg: resolveColorTokenValue(context, tokens?.bg),
1335
- border: resolveColorTokenValue(context, tokens?.border),
1336
- fg: resolveColorTokenValue(context, tokens?.fg),
1337
- muted: { bg: resolveColorTokenValue(context, tokens?.muted?.bg) },
1338
- placeholder: resolveColorTokenValue(context, tokens?.placeholder)
1339
- };
1340
- }
1341
- function buildSelectableColorTheme(options, config) {
1342
- let { scheme, tone: cardTone } = options, tones = {};
1343
- for (let tone of THEME_COLOR_STATE_TONES) tones[tone] = buildSelectableStatesColorTheme({
1344
- cardTone,
1345
- scheme,
1346
- tone
1347
- }, config);
1348
- return tones;
1349
- }
1350
- function buildSelectableStatesColorTheme(options, config) {
1351
- let { cardTone, scheme, tone } = options, states = {};
1352
- for (let state of THEME_COLOR_STATES) states[state] = buildSelectableStateColorTheme({
1353
- cardTone,
1354
- tone,
1355
- scheme,
1356
- state
1357
- }, config);
1358
- return states;
1359
- }
1360
- function buildSelectableStateColorTheme(options, config) {
1361
- let { cardTone, scheme, state, tone } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
1362
- hue,
1363
- scheme
1364
- };
1365
- return {
1366
- _blend: blendMode[scheme === "light" ? 0 : 1],
1367
- accent: { fg: resolveColorTokenValue(context, tokens?.accent?.fg) },
1368
- avatar: buildAvatarColorTheme({ scheme }, tokens),
1369
- badge: buildBadgeColorTheme(tokens?.badge, { scheme }, config),
1370
- bg: resolveColorTokenValue(context, tokens?.bg),
1371
- border: resolveColorTokenValue(context, tokens?.border),
1372
- code: {
1373
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
1374
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
1375
- },
1376
- fg: resolveColorTokenValue(context, tokens?.fg),
1377
- icon: resolveColorTokenValue(context, tokens?.icon),
1378
- muted: {
1379
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
1380
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
1381
- },
1382
- kbd: {
1383
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
1384
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
1385
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
1386
- },
1387
- link: { fg: resolveColorTokenValue(context, tokens?.link?.fg) },
1388
- skeleton: {
1389
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
1390
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
1391
- }
1392
- };
1393
- }
1394
- function buildSyntaxColorTheme(options, config) {
1395
- let { scheme } = options, tokens = config?.color?.syntax, context = {
1396
- hue: "gray",
1397
- scheme
1398
- };
1399
- return {
1400
- atrule: resolveColorTokenValue(context, tokens?.atrule),
1401
- attrName: resolveColorTokenValue(context, tokens?.attrName),
1402
- attrValue: resolveColorTokenValue(context, tokens?.attrValue),
1403
- attribute: resolveColorTokenValue(context, tokens?.attribute),
1404
- boolean: resolveColorTokenValue(context, tokens?.boolean),
1405
- builtin: resolveColorTokenValue(context, tokens?.builtin),
1406
- cdata: resolveColorTokenValue(context, tokens?.cdata),
1407
- char: resolveColorTokenValue(context, tokens?.char),
1408
- class: resolveColorTokenValue(context, tokens?.class),
1409
- className: resolveColorTokenValue(context, tokens?.className),
1410
- comment: resolveColorTokenValue(context, tokens?.comment),
1411
- constant: resolveColorTokenValue(context, tokens?.constant),
1412
- deleted: resolveColorTokenValue(context, tokens?.deleted),
1413
- doctype: resolveColorTokenValue(context, tokens?.doctype),
1414
- entity: resolveColorTokenValue(context, tokens?.entity),
1415
- function: resolveColorTokenValue(context, tokens?.function),
1416
- hexcode: resolveColorTokenValue(context, tokens?.hexcode),
1417
- id: resolveColorTokenValue(context, tokens?.id),
1418
- important: resolveColorTokenValue(context, tokens?.important),
1419
- inserted: resolveColorTokenValue(context, tokens?.inserted),
1420
- keyword: resolveColorTokenValue(context, tokens?.keyword),
1421
- number: resolveColorTokenValue(context, tokens?.number),
1422
- operator: resolveColorTokenValue(context, tokens?.operator),
1423
- prolog: resolveColorTokenValue(context, tokens?.prolog),
1424
- property: resolveColorTokenValue(context, tokens?.property),
1425
- pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
1426
- pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
1427
- punctuation: resolveColorTokenValue(context, tokens?.punctuation),
1428
- regex: resolveColorTokenValue(context, tokens?.regex),
1429
- selector: resolveColorTokenValue(context, tokens?.selector),
1430
- string: resolveColorTokenValue(context, tokens?.string),
1431
- symbol: resolveColorTokenValue(context, tokens?.symbol),
1432
- tag: resolveColorTokenValue(context, tokens?.tag),
1433
- unit: resolveColorTokenValue(context, tokens?.unit),
1434
- url: resolveColorTokenValue(context, tokens?.url),
1435
- variable: resolveColorTokenValue(context, tokens?.variable)
1436
- };
1437
- }
1438
- const defaultColorPalette = color;
1439
- function mixChannel(b, s, weight) {
1440
- return b + (s - b) * weight;
1441
- }
1442
- /**
1443
- * Apply the \`mix\` blend mode
1444
- * @internal
1445
- */
1446
- function mix(b, s, weight) {
1447
- return {
1448
- r: mixChannel(b.r, s.r, weight),
1449
- g: mixChannel(b.g, s.g, weight),
1450
- b: mixChannel(b.b, s.b, weight)
1451
- };
1452
- }
1453
- function lerp(x, y, a) {
1454
- return x * (1 - a) + y * a;
1455
- }
1456
- function invlerp(x, y, a) {
1457
- return clamp((a - x) / (y - x));
1458
- }
1459
- function clamp(a, min = 0, max = 1) {
1460
- return Math.min(max, Math.max(min, a));
1461
- }
1462
- function range(x1, y1, x2, y2, a) {
1463
- return lerp(x2, y2, invlerp(x1, y1, a));
1464
- }
1465
- function round(value) {
1466
- return Math.round(value);
1467
- }
1468
- /**
1469
- * @internal
1470
- */
1471
- function hexToRgb(hex) {
1472
- if (hex.length === 4) {
1473
- let hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
1474
- return {
1475
- r: parseInt(hexR + hexR, 16),
1476
- g: parseInt(hexG + hexG, 16),
1477
- b: parseInt(hexB + hexB, 16)
1478
- };
1479
- }
1480
- return {
1481
- r: parseInt(hex.slice(1, 3), 16),
1482
- g: parseInt(hex.slice(3, 5), 16),
1483
- b: parseInt(hex.slice(5, 7), 16)
1484
- };
1485
- }
1486
- /**
1487
- * @internal
1488
- */
1489
- function rgbaToRGBA(rgba) {
1490
- let values = rgba.replace(/rgba\(|\)/g, "").split(",");
1491
- return {
1492
- r: parseInt(values[0]),
1493
- g: parseInt(values[1]),
1494
- b: parseInt(values[2]),
1495
- a: parseFloat(values[3])
1496
- };
1497
- }
1498
- /**
1499
- * @internal
1500
- */
1501
- function rgbToHex(color) {
1502
- let r = round(clamp(Math.round(color.r), 0, 255)), g = round(clamp(Math.round(color.g), 0, 255)), b = round(clamp(Math.round(color.b), 0, 255));
1503
- return "a" in color ? `rgba(${r},${g},${b},${color.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
1504
- }
1505
- /**
1506
- * @internal
1507
- * @see https://css-tricks.com/converting-color-spaces-in-javascript/
1508
- */
1509
- function rgbToHsl({ r, g, b }) {
1510
- r /= 255, g /= 255, b /= 255;
1511
- let cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin, h = 0, s = 0, l = 0;
1512
- return h = delta == 0 ? 0 : cmax == r ? (g - b) / delta % 6 : cmax == g ? (b - r) / delta + 2 : (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), {
1513
- h,
1514
- s,
1515
- l
1516
- };
1517
- }
1518
- /**
1519
- * @internal
1520
- */
1521
- function hslToRgb(hsl) {
1522
- let 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, r = 0, g = 0, b = 0;
1523
- 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), {
1524
- r: Math.round((r + m) * 255),
1525
- g: Math.round((g + m) * 255),
1526
- b: Math.round((b + m) * 255)
1527
- };
1528
- }
1529
- const HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
1530
- function isHexChars(str) {
1531
- for (let c of str) if ("0123456789ABCDEFabcdef".indexOf(c) === -1) return !1;
1532
- return !0;
1533
- }
1534
- function isHex(str) {
1535
- return str[0] !== "#" || str.length !== 4 && str.length !== 7 ? !1 : isHexChars(str.slice(1));
1536
- }
1537
- function parseHsl(str) {
1538
- let res = HSL_RE.exec(str);
1539
- if (!res) throw Error(`parseHsl: string is not a HSL color: "${str}"`);
1540
- return {
1541
- h: parseInt(res[1]),
1542
- s: parseFloat(res[3]),
1543
- l: parseFloat(res[5])
1544
- };
1545
- }
1546
- /**
1547
- * @internal
1548
- */
1549
- function parseColor(color) {
1550
- if (!color) return {
1551
- r: 0,
1552
- g: 0,
1553
- b: 0
1554
- };
1555
- if (typeof color != "string") throw Error("parseColor: expected a string");
1556
- if (isHex(color)) return hexToRgb(color);
1557
- if (color.startsWith("hsl(")) return hslToRgb(parseHsl(color));
1558
- if (color.startsWith("rgba(")) return rgbaToRGBA(color);
1559
- throw Error(`parseColor: unexpected color format: "${color}"`);
1560
- }
1561
- /**
1562
- * @internal
1563
- */
1564
- function rgba(color, a) {
1565
- let rgb = parseColor(color);
1566
- return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
1567
- }
1568
- function multiplyChannel(b, s) {
1569
- return b * s;
1570
- }
1571
- /**
1572
- * Apply the \`multiply\` blend mode
1573
- * Source: https://www.w3.org/TR/compositing-1/#blendingmultiply
1574
- * @internal
1575
- */
1576
- function multiply(b, s) {
1577
- return {
1578
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
1579
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
1580
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
1581
- };
1582
- }
1583
- function screenChannel(b, s) {
1584
- return b + s - b * s;
1585
- }
1586
- /**
1587
- * Apply the \`screen\` blend mode
1588
- * Source: https://www.w3.org/TR/compositing-1/#blendingscreen
1589
- * @internal
1590
- */
1591
- function screen(b, s) {
1592
- return {
1593
- r: screenChannel(b.r / 255, s.r / 255) * 255,
1594
- g: screenChannel(b.g / 255, s.g / 255) * 255,
1595
- b: screenChannel(b.b / 255, s.b / 255) * 255
1596
- };
1597
- }
1598
- const RGB_RANGE = [0, 255];
1599
- function mixThemeColor(value, options) {
1600
- let { blendMode } = options, color = parseColor(value), black = parseColor(options.black), white = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white : black, paletteRange = {
1601
- r: [black.r, white.r],
1602
- g: [black.g, white.g],
1603
- b: [black.b, white.b]
1604
- }, convertedBgColor = {
1605
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
1606
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
1607
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
1608
- }, convertedColor = {
1609
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, color.r), ...RGB_RANGE),
1610
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, color.g), ...RGB_RANGE),
1611
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, color.b), ...RGB_RANGE)
1612
- }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor);
1613
- return rgbToHex({
1614
- r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
1615
- g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
1616
- b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
1617
- });
1618
- }
1619
- function renderColorValue(str, options) {
1620
- let { bg, blendMode, colorPalette } = options;
1621
- if (bg === "white") throw Error("Cannot blend with white background");
1622
- let node = parseTokenValue(str);
1623
- if (!node || node.type !== "color") throw Error(`Invalid color token value: ${str}`);
1624
- let hex = "";
1625
- 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) throw Error(`Invalid color token value: ${str}`);
1626
- let hexBeforeMix = hex, mixOptions = {
1627
- blendMode,
1628
- bg,
1629
- black: renderColorHex(colorPalette.black),
1630
- white: renderColorHex(colorPalette.white)
1631
- };
1632
- try {
1633
- hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0 && (hex = rgbToHex(mix(hexToRgb(bg), hexToRgb(hex), node.mix)));
1634
- } catch (err) {
1635
- throw console.warn("could not blend", hex, mixOptions), err;
1636
- }
1637
- return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
1638
- }
1639
- function renderColorHex(color) {
1640
- return typeof color == "string" ? color : color.hex;
1641
- }
1642
- function renderThemeColorSchemes(value, config) {
1643
- let colorPalette = config?.palette ?? defaultColorPalette, schemes = {};
1644
- return defineLazyProperty(schemes, "light", () => renderThemeColorScheme(colorPalette, value.light)), defineLazyProperty(schemes, "dark", () => renderThemeColorScheme(colorPalette, value.dark)), schemes;
1645
- }
1646
- function renderThemeColorScheme(colorPalette, value) {
1647
- let renderedDefaultTone = renderThemeColor(value.default, { colorPalette }), bg = renderedDefaultTone.bg;
1648
- if (bg === "white") throw Error("Cannot blend with white background");
1649
- let scheme = { default: renderedDefaultTone };
1650
- for (let tone of THEME_COLOR_CARD_TONES) {
1651
- if (tone === "default") continue;
1652
- let opts = tone === "transparent" ? { colorPalette } : {
1653
- bg,
1654
- colorPalette
1655
- };
1656
- defineLazyProperty(scheme, tone, () => renderThemeColor(value[tone], opts));
1657
- }
1658
- return scheme;
1659
- }
1660
- function renderThemeColor(value, options) {
1661
- let { colorPalette, bg } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
1662
- colorPalette,
1663
- bg,
1664
- blendMode
1665
- }), colorOptions = {
1666
- colorPalette,
1667
- bg: baseBg,
1668
- blendMode
1669
- }, button = renderThemeColorButton(value.button, {
1670
- baseBg,
1671
- blendMode,
1672
- colorPalette
1673
- }), selectable = renderThemeColorSelectable(value.selectable, {
1674
- colorPalette,
1675
- baseBg,
1676
- blendMode
1677
- }), shadow = {
1678
- outline: renderColorValue(value.shadow.outline, colorOptions),
1679
- umbra: renderColorValue(value.shadow.umbra, {
1680
- ...colorOptions,
1681
- bg: void 0,
1682
- colorPalette: {
1683
- ...colorPalette,
1684
- black: "#000000"
1685
- }
1686
- }),
1687
- penumbra: renderColorValue(value.shadow.penumbra, {
1688
- ...colorOptions,
1689
- bg: void 0,
1690
- colorPalette: {
1691
- ...colorPalette,
1692
- black: "#000000"
1693
- }
1694
- }),
1695
- ambient: renderColorValue(value.shadow.ambient, {
1696
- ...colorOptions,
1697
- bg: void 0,
1698
- colorPalette: {
1699
- ...colorPalette,
1700
- black: "#000000"
1701
- }
1702
- })
1703
- };
1704
- return {
1705
- _blend: blendMode,
1706
- _dark: value._dark,
1707
- accent: { fg: renderColorValue(value.accent.fg, colorOptions) },
1708
- avatar: renderThemeColorAvatar(value.avatar, {
1709
- baseBg,
1710
- colorPalette,
1711
- blendMode
1712
- }),
1713
- backdrop: renderColorValue(value.backdrop, colorOptions),
1714
- badge: renderThemeColorBadge(value.badge, {
1715
- baseBg,
1716
- colorPalette,
1717
- blendMode
1718
- }),
1719
- bg: baseBg,
1720
- border: renderColorValue(value.border, colorOptions),
1721
- button,
1722
- code: {
1723
- bg: renderColorValue(value.code.bg, colorOptions),
1724
- fg: renderColorValue(value.code.fg, colorOptions)
1725
- },
1726
- fg: renderColorValue(value.fg, colorOptions),
1727
- focusRing: renderColorValue(value.focusRing, colorOptions),
1728
- icon: renderColorValue(value.icon, colorOptions),
1729
- input: renderThemeColorInput(value.input, {
1730
- baseBg,
1731
- colorPalette,
1732
- blendMode
1733
- }),
1734
- kbd: renderThemeColorKBD(value.kbd, {
1735
- baseBg,
1736
- colorPalette,
1737
- blendMode
1738
- }),
1739
- link: { fg: renderColorValue(value.link.fg, colorOptions) },
1740
- muted: {
1741
- bg: renderColorValue(value.muted.bg, colorOptions),
1742
- fg: renderColorValue(value.muted.fg, colorOptions)
1743
- },
1744
- shadow,
1745
- skeleton: {
1746
- from: renderColorValue(value.skeleton.from, colorOptions),
1747
- to: renderColorValue(value.skeleton.to, colorOptions)
1748
- },
1749
- syntax: renderSyntaxColorTheme(value.syntax, {
1750
- baseBg,
1751
- colorPalette,
1752
- blendMode
1753
- }),
1754
- selectable
1755
- };
1756
- }
1757
- function renderThemeColorKBD(value, options) {
1758
- let { baseBg, blendMode, colorPalette } = options, rootOptions = {
1759
- bg: baseBg,
1760
- blendMode,
1761
- colorPalette
1762
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
1763
- bg,
1764
- blendMode,
1765
- colorPalette
1766
- };
1767
- return {
1768
- bg,
1769
- fg: renderColorValue(value.fg, colorOptions),
1770
- border: renderColorValue(value.border, colorOptions)
1771
- };
1772
- }
1773
- function renderThemeColorAvatar(value, options) {
1774
- let colorAvatar = {};
1775
- for (let hue of COLOR_HUES) colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
1776
- return colorAvatar;
1777
- }
1778
- function renderThemeColorAvatarColor(value, options) {
1779
- let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
1780
- bg: baseBg,
1781
- blendMode: rootBlendMode,
1782
- colorPalette
1783
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
1784
- bg,
1785
- blendMode,
1786
- colorPalette
1787
- };
1788
- return {
1789
- _blend: blendMode,
1790
- bg,
1791
- fg: renderColorValue(value.fg, colorOptions)
1792
- };
1793
- }
1794
- function renderThemeColorBadge(value, options) {
1795
- let colorBadge = {};
1796
- for (let tone of THEME_COLOR_STATE_TONES) colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
1797
- return colorBadge;
1798
- }
1799
- function renderThemeColorBadgeColor(value, options) {
1800
- let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = rootBlendMode, rootOptions = {
1801
- bg: baseBg,
1802
- blendMode: rootBlendMode,
1803
- colorPalette
1804
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
1805
- bg,
1806
- blendMode,
1807
- colorPalette
1808
- };
1809
- return {
1810
- bg,
1811
- dot: renderColorValue(value.dot, colorOptions),
1812
- fg: renderColorValue(value.fg, colorOptions),
1813
- icon: renderColorValue(value.icon, colorOptions)
1814
- };
1815
- }
1816
- function renderThemeColorButton(value, options) {
1817
- return {
1818
- default: renderThemeColorButtonTones(value.default, options),
1819
- ghost: renderThemeColorButtonTones(value.ghost, options),
1820
- bleed: renderThemeColorButtonTones(value.bleed, options)
1821
- };
1822
- }
1823
- function renderThemeColorButtonTones(value, options) {
1824
- let colorButtonMode = {};
1825
- for (let tone of THEME_COLOR_STATE_TONES) colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
1826
- return colorButtonMode;
1827
- }
1828
- function renderThemeColorButtonStates(value, options) {
1829
- return {
1830
- enabled: renderThemeColorState(value.enabled, options),
1831
- hovered: renderThemeColorState(value.hovered, options),
1832
- pressed: renderThemeColorState(value.pressed, options),
1833
- selected: renderThemeColorState(value.selected, options),
1834
- disabled: renderThemeColorState(value.disabled, options)
1835
- };
1836
- }
1837
- function renderThemeColorState(value, options) {
1838
- let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
1839
- bg: baseBg,
1840
- blendMode: rootBlendMode,
1841
- colorPalette
1842
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
1843
- bg,
1844
- blendMode,
1845
- colorPalette
1846
- };
1847
- return {
1848
- _blend: blendMode,
1849
- accent: { fg: renderColorValue(value.accent.fg, colorOptions) },
1850
- avatar: renderThemeColorAvatar(value.avatar, {
1851
- baseBg: bg,
1852
- colorPalette,
1853
- blendMode
1854
- }),
1855
- badge: renderThemeColorBadge(value.badge, {
1856
- baseBg: bg,
1857
- colorPalette,
1858
- blendMode
1859
- }),
1860
- bg,
1861
- border: renderColorValue(value.border, colorOptions),
1862
- code: {
1863
- bg: renderColorValue(value.code.bg, colorOptions),
1864
- fg: renderColorValue(value.code.fg, colorOptions)
1865
- },
1866
- fg: renderColorValue(value.fg, colorOptions),
1867
- icon: renderColorValue(value.icon, colorOptions),
1868
- link: { fg: renderColorValue(value.link.fg, colorOptions) },
1869
- muted: {
1870
- bg: renderColorValue(value.muted.bg, colorOptions),
1871
- fg: renderColorValue(value.muted.fg, colorOptions)
1872
- },
1873
- kbd: {
1874
- bg: renderColorValue(value.kbd.bg, colorOptions),
1875
- fg: renderColorValue(value.kbd.fg, colorOptions),
1876
- border: renderColorValue(value.kbd.border, colorOptions)
1877
- },
1878
- skeleton: {
1879
- from: renderColorValue(value.skeleton?.from, colorOptions),
1880
- to: renderColorValue(value.skeleton?.to, colorOptions)
1881
- }
1882
- };
1883
- }
1884
- function renderThemeColorInput(value, options) {
1885
- return {
1886
- default: renderInputStatesColorTheme(value.default, options),
1887
- invalid: renderInputStatesColorTheme(value.invalid, options)
1888
- };
1889
- }
1890
- function renderInputStatesColorTheme(value, options) {
1891
- return {
1892
- enabled: renderInputStateColorTheme(value.enabled, options),
1893
- hovered: renderInputStateColorTheme(value.hovered, options),
1894
- readOnly: renderInputStateColorTheme(value.readOnly, options),
1895
- disabled: renderInputStateColorTheme(value.disabled, options)
1896
- };
1897
- }
1898
- function renderInputStateColorTheme(value, options) {
1899
- let { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
1900
- colorPalette,
1901
- bg: baseBg,
1902
- blendMode: rootBlendMode
1903
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
1904
- colorPalette,
1905
- bg,
1906
- blendMode
1907
- };
1908
- return {
1909
- _blend: blendMode,
1910
- bg,
1911
- border: renderColorValue(value.border, colorOptions),
1912
- fg: renderColorValue(value.fg, colorOptions),
1913
- muted: { bg: renderColorValue(value.muted.bg, colorOptions) },
1914
- placeholder: renderColorValue(value.placeholder, colorOptions)
1915
- };
1916
- }
1917
- function renderThemeColorSelectable(value, options) {
1918
- let colorSelectable = {};
1919
- for (let tone of THEME_COLOR_STATE_TONES) colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
1920
- return colorSelectable;
1921
- }
1922
- function renderThemeColorSelectableStates(value, options) {
1923
- return {
1924
- enabled: renderThemeColorState(value.enabled, options),
1925
- hovered: renderThemeColorState(value.hovered, options),
1926
- pressed: renderThemeColorState(value.pressed, options),
1927
- selected: renderThemeColorState(value.selected, options),
1928
- disabled: renderThemeColorState(value.disabled, options)
1929
- };
1930
- }
1931
- function renderSyntaxColorTheme(value, options) {
1932
- let { colorPalette, baseBg, blendMode } = options, colorOptions = {
1933
- colorPalette,
1934
- bg: baseBg,
1935
- blendMode
1936
- };
1937
- return {
1938
- atrule: renderColorValue(value.atrule, colorOptions),
1939
- attrName: renderColorValue(value.attrName, colorOptions),
1940
- attrValue: renderColorValue(value.attrValue, colorOptions),
1941
- attribute: renderColorValue(value.attribute, colorOptions),
1942
- boolean: renderColorValue(value.boolean, colorOptions),
1943
- builtin: renderColorValue(value.builtin, colorOptions),
1944
- cdata: renderColorValue(value.cdata, colorOptions),
1945
- char: renderColorValue(value.char, colorOptions),
1946
- class: renderColorValue(value.class, colorOptions),
1947
- className: renderColorValue(value.className, colorOptions),
1948
- comment: renderColorValue(value.comment, colorOptions),
1949
- constant: renderColorValue(value.constant, colorOptions),
1950
- deleted: renderColorValue(value.deleted, colorOptions),
1951
- doctype: renderColorValue(value.doctype, colorOptions),
1952
- entity: renderColorValue(value.entity, colorOptions),
1953
- function: renderColorValue(value.function, colorOptions),
1954
- hexcode: renderColorValue(value.hexcode, colorOptions),
1955
- id: renderColorValue(value.id, colorOptions),
1956
- important: renderColorValue(value.important, colorOptions),
1957
- inserted: renderColorValue(value.inserted, colorOptions),
1958
- keyword: renderColorValue(value.keyword, colorOptions),
1959
- number: renderColorValue(value.number, colorOptions),
1960
- operator: renderColorValue(value.operator, colorOptions),
1961
- prolog: renderColorValue(value.prolog, colorOptions),
1962
- property: renderColorValue(value.property, colorOptions),
1963
- pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
1964
- pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
1965
- punctuation: renderColorValue(value.punctuation, colorOptions),
1966
- regex: renderColorValue(value.regex, colorOptions),
1967
- selector: renderColorValue(value.selector, colorOptions),
1968
- string: renderColorValue(value.string, colorOptions),
1969
- symbol: renderColorValue(value.symbol, colorOptions),
1970
- tag: renderColorValue(value.tag, colorOptions),
1971
- unit: renderColorValue(value.unit, colorOptions),
1972
- url: renderColorValue(value.url, colorOptions),
1973
- variable: renderColorValue(value.variable, colorOptions)
1974
- };
1975
- }
1976
- /** @internal */
1977
- function buildTheme(config) {
1978
- let colorTheme = buildColorTheme(config), v2 = {
1979
- _version: 2,
1980
- avatar: config?.avatar ?? defaultThemeConfig.avatar,
1981
- button: config?.button ?? defaultThemeConfig.button,
1982
- card: config?.card ?? defaultThemeConfig.card,
1983
- color: renderThemeColorSchemes(colorTheme, config),
1984
- container: config?.container ?? defaultThemeConfig.container,
1985
- font: config?.font ?? defaultThemeFonts,
1986
- input: config?.input ?? defaultThemeConfig.input,
1987
- layer: config?.layer ?? defaultThemeConfig.layer,
1988
- media: config?.media ?? defaultThemeConfig.media,
1989
- radius: config?.radius ?? defaultThemeConfig.radius,
1990
- shadow: config?.shadow ?? defaultThemeConfig.shadow,
1991
- space: config?.space ?? defaultThemeConfig.space,
1992
- style: config?.style ?? defaultThemeConfig.style
1993
- };
1994
- return v2_v0(v2);
1995
- }
1996
- function createSelectableTones(opts, base, dark, solid, muted) {
1997
- return {
1998
- default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
1999
- primary: _createSelectableStates(opts, base, dark, solid, muted, "primary"),
2000
- positive: _createSelectableStates(opts, base, dark, solid, muted, "positive"),
2001
- caution: _createSelectableStates(opts, base, dark, solid, muted, "caution"),
2002
- critical: _createSelectableStates(opts, base, dark, solid, muted, "critical")
2003
- };
2004
- }
2005
- function _createSelectableStates(opts, base, dark, solid, muted, tone) {
2006
- return {
2007
- enabled: opts.selectable({
2008
- base,
2009
- dark,
2010
- solid,
2011
- muted,
2012
- state: "enabled",
2013
- tone
2014
- }),
2015
- hovered: opts.selectable({
2016
- base,
2017
- dark,
2018
- solid,
2019
- muted,
2020
- state: "hovered",
2021
- tone
2022
- }),
2023
- pressed: opts.selectable({
2024
- base,
2025
- dark,
2026
- solid,
2027
- muted,
2028
- state: "pressed",
2029
- tone
2030
- }),
2031
- selected: opts.selectable({
2032
- base,
2033
- dark,
2034
- solid,
2035
- muted,
2036
- state: "selected",
2037
- tone
2038
- }),
2039
- disabled: opts.selectable({
2040
- base,
2041
- dark,
2042
- solid,
2043
- muted,
2044
- state: "disabled",
2045
- tone
2046
- })
2047
- };
2048
- }
2049
- function createSolidTones(opts, base, dark, name) {
2050
- return {
2051
- default: {
2052
- enabled: opts.solid({
2053
- base,
2054
- dark,
2055
- tone: "default",
2056
- name,
2057
- state: "enabled"
2058
- }),
2059
- disabled: opts.solid({
2060
- base,
2061
- dark,
2062
- tone: "default",
2063
- name,
2064
- state: "disabled"
2065
- }),
2066
- hovered: opts.solid({
2067
- base,
2068
- dark,
2069
- tone: "default",
2070
- name,
2071
- state: "hovered"
2072
- }),
2073
- pressed: opts.solid({
2074
- base,
2075
- dark,
2076
- tone: "default",
2077
- name,
2078
- state: "pressed"
2079
- }),
2080
- selected: opts.solid({
2081
- base,
2082
- dark,
2083
- tone: "default",
2084
- name,
2085
- state: "selected"
2086
- })
2087
- },
2088
- transparent: {
2089
- enabled: opts.solid({
2090
- base,
2091
- dark,
2092
- tone: "transparent",
2093
- name,
2094
- state: "enabled"
2095
- }),
2096
- disabled: opts.solid({
2097
- base,
2098
- dark,
2099
- tone: "transparent",
2100
- name,
2101
- state: "disabled"
2102
- }),
2103
- hovered: opts.solid({
2104
- base,
2105
- dark,
2106
- tone: "transparent",
2107
- name,
2108
- state: "hovered"
2109
- }),
2110
- pressed: opts.solid({
2111
- base,
2112
- dark,
2113
- tone: "transparent",
2114
- name,
2115
- state: "pressed"
2116
- }),
2117
- selected: opts.solid({
2118
- base,
2119
- dark,
2120
- tone: "transparent",
2121
- name,
2122
- state: "selected"
2123
- })
2124
- },
2125
- primary: {
2126
- enabled: opts.solid({
2127
- base,
2128
- dark,
2129
- tone: "primary",
2130
- name,
2131
- state: "enabled"
2132
- }),
2133
- disabled: opts.solid({
2134
- base,
2135
- dark,
2136
- tone: "primary",
2137
- name,
2138
- state: "disabled"
2139
- }),
2140
- hovered: opts.solid({
2141
- base,
2142
- dark,
2143
- tone: "primary",
2144
- name,
2145
- state: "hovered"
2146
- }),
2147
- pressed: opts.solid({
2148
- base,
2149
- dark,
2150
- tone: "primary",
2151
- name,
2152
- state: "pressed"
2153
- }),
2154
- selected: opts.solid({
2155
- base,
2156
- dark,
2157
- tone: "primary",
2158
- name,
2159
- state: "selected"
2160
- })
2161
- },
2162
- positive: {
2163
- enabled: opts.solid({
2164
- base,
2165
- dark,
2166
- tone: "positive",
2167
- name,
2168
- state: "enabled"
2169
- }),
2170
- disabled: opts.solid({
2171
- base,
2172
- dark,
2173
- tone: "positive",
2174
- name,
2175
- state: "disabled"
2176
- }),
2177
- hovered: opts.solid({
2178
- base,
2179
- dark,
2180
- tone: "positive",
2181
- name,
2182
- state: "hovered"
2183
- }),
2184
- pressed: opts.solid({
2185
- base,
2186
- dark,
2187
- tone: "positive",
2188
- name,
2189
- state: "pressed"
2190
- }),
2191
- selected: opts.solid({
2192
- base,
2193
- dark,
2194
- tone: "positive",
2195
- name,
2196
- state: "selected"
2197
- })
2198
- },
2199
- caution: {
2200
- enabled: opts.solid({
2201
- base,
2202
- dark,
2203
- tone: "caution",
2204
- name,
2205
- state: "enabled"
2206
- }),
2207
- disabled: opts.solid({
2208
- base,
2209
- dark,
2210
- tone: "caution",
2211
- name,
2212
- state: "disabled"
2213
- }),
2214
- hovered: opts.solid({
2215
- base,
2216
- dark,
2217
- tone: "caution",
2218
- name,
2219
- state: "hovered"
2220
- }),
2221
- pressed: opts.solid({
2222
- base,
2223
- dark,
2224
- tone: "caution",
2225
- name,
2226
- state: "pressed"
2227
- }),
2228
- selected: opts.solid({
2229
- base,
2230
- dark,
2231
- tone: "caution",
2232
- name,
2233
- state: "selected"
2234
- })
2235
- },
2236
- critical: {
2237
- enabled: opts.solid({
2238
- base,
2239
- dark,
2240
- tone: "critical",
2241
- name,
2242
- state: "enabled"
2243
- }),
2244
- disabled: opts.solid({
2245
- base,
2246
- dark,
2247
- tone: "critical",
2248
- name,
2249
- state: "disabled"
2250
- }),
2251
- hovered: opts.solid({
2252
- base,
2253
- dark,
2254
- tone: "critical",
2255
- name,
2256
- state: "hovered"
2257
- }),
2258
- pressed: opts.solid({
2259
- base,
2260
- dark,
2261
- tone: "critical",
2262
- name,
2263
- state: "pressed"
2264
- }),
2265
- selected: opts.solid({
2266
- base,
2267
- dark,
2268
- tone: "critical",
2269
- name,
2270
- state: "selected"
2271
- })
2272
- }
2273
- };
2274
- }
2275
- function createButtonTones(opts, base, dark, solid, muted, mode) {
2276
- return {
2277
- default: opts.button({
2278
- base,
2279
- dark,
2280
- solid: solid.default,
2281
- muted: muted.default,
2282
- mode
2283
- }),
2284
- primary: opts.button({
2285
- base,
2286
- dark,
2287
- solid: solid.primary,
2288
- muted: muted.primary,
2289
- mode
2290
- }),
2291
- positive: opts.button({
2292
- base,
2293
- dark,
2294
- solid: solid.positive,
2295
- muted: muted.positive,
2296
- mode
2297
- }),
2298
- caution: opts.button({
2299
- base,
2300
- dark,
2301
- solid: solid.caution,
2302
- muted: muted.caution,
2303
- mode
2304
- }),
2305
- critical: opts.button({
2306
- base,
2307
- dark,
2308
- solid: solid.critical,
2309
- muted: muted.critical,
2310
- mode
2311
- })
2312
- };
2313
- }
2314
- function createButtonModes(opts, base, dark, solid, muted) {
2315
- return {
2316
- default: createButtonTones(opts, base, dark, solid, muted, "default"),
2317
- ghost: createButtonTones(opts, base, dark, solid, muted, "ghost"),
2318
- bleed: createButtonTones(opts, base, dark, solid, muted, "bleed")
2319
- };
2320
- }
2321
- function createCardStates(opts, base, dark, name, solid, muted) {
2322
- return {
2323
- enabled: opts.card({
2324
- base,
2325
- dark,
2326
- name,
2327
- state: "enabled",
2328
- solid,
2329
- muted
2330
- }),
2331
- disabled: opts.card({
2332
- base,
2333
- dark,
2334
- name,
2335
- state: "disabled",
2336
- solid,
2337
- muted
2338
- }),
2339
- hovered: opts.card({
2340
- base,
2341
- dark,
2342
- name,
2343
- state: "hovered",
2344
- solid,
2345
- muted
2346
- }),
2347
- pressed: opts.card({
2348
- base,
2349
- dark,
2350
- name,
2351
- state: "pressed",
2352
- solid,
2353
- muted
2354
- }),
2355
- selected: opts.card({
2356
- base,
2357
- dark,
2358
- name,
2359
- state: "selected",
2360
- solid,
2361
- muted
2362
- })
2363
- };
2364
- }
2365
- const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
2366
- default: {
2367
- lightest: "hsl(0, 0%, 95%)",
2368
- lighter: "hsl(0, 0%, 70%)",
2369
- light: "hsl(0, 0%, 65%)",
2370
- base: "hsl(0, 0%, 50%)",
2371
- dark: "hsl(0, 0%, 35%)",
2372
- darker: "hsl(0, 0%, 20%)",
2373
- darkest: "hsl(0, 0%, 5%)"
2374
- },
2375
- transparent: {
2376
- lightest: "hsl(240, 100%, 95%)",
2377
- lighter: "hsl(240, 100%, 70%)",
2378
- light: "hsl(240, 100%, 65%)",
2379
- base: "hsl(240, 100%, 50%)",
2380
- dark: "hsl(240, 100%, 35%)",
2381
- darker: "hsl(240, 100%, 20%)",
2382
- darkest: "hsl(240, 100%, 5%)"
2383
- },
2384
- primary: {
2385
- lightest: "hsl(240, 100%, 95%)",
2386
- lighter: "hsl(240, 100%, 70%)",
2387
- light: "hsl(240, 100%, 65%)",
2388
- base: "hsl(240, 100%, 50%)",
2389
- dark: "hsl(240, 100%, 35%)",
2390
- darker: "hsl(240, 100%, 20%)",
2391
- darkest: "hsl(240, 100%, 5%)"
2392
- },
2393
- positive: {
2394
- lightest: "hsl(120, 100%, 95%)",
2395
- lighter: "hsl(120, 100%, 70%)",
2396
- light: "hsl(120, 100%, 65%)",
2397
- base: "hsl(120, 100%, 50%)",
2398
- dark: "hsl(120, 100%, 35%)",
2399
- darker: "hsl(120, 100%, 20%)",
2400
- darkest: "hsl(120, 100%, 5%)"
2401
- },
2402
- caution: {
2403
- lightest: "hsl(60, 100%, 95%)",
2404
- lighter: "hsl(60, 100%, 70%)",
2405
- light: "hsl(60, 100%, 65%)",
2406
- base: "hsl(60, 100%, 50%)",
2407
- dark: "hsl(60, 100%, 35%)",
2408
- darker: "hsl(60, 100%, 20%)",
2409
- darkest: "hsl(60, 100%, 5%)"
2410
- },
2411
- critical: {
2412
- lightest: "hsl(0, 100%, 95%)",
2413
- lighter: "hsl(0, 100%, 70%)",
2414
- light: "hsl(0, 100%, 65%)",
2415
- base: "hsl(0, 100%, 50%)",
2416
- dark: "hsl(0, 100%, 35%)",
2417
- darker: "hsl(0, 100%, 20%)",
2418
- darkest: "hsl(0, 100%, 5%)"
2419
- }
2420
- }, spots = {
2421
- gray: "hsl(0, 0%, 50%)",
2422
- red: "hsl(0, 100%, 50%)",
2423
- orange: "hsl(30, 100%, 50%)",
2424
- yellow: "hsl(60, 100%, 50%)",
2425
- green: "hsl(120, 100%, 50%)",
2426
- cyan: "hsl(180, 100%, 50%)",
2427
- blue: "hsl(240, 100%, 50%)",
2428
- purple: "hsl(270, 100%, 50%)",
2429
- magenta: "hsl(300, 100%, 50%)"
2430
- }, tones = {
2431
- transparent: {
2432
- bg: [colors.transparent.darkest, colors.transparent.lightest],
2433
- fg: [colors.transparent.lightest, colors.transparent.darkest],
2434
- border: [colors.transparent.darker, colors.transparent.lighter],
2435
- focusRing: [colors.transparent.base, colors.transparent.base]
2436
- },
2437
- primary: {
2438
- bg: [colors.primary.darkest, colors.primary.lightest],
2439
- fg: [colors.primary.lightest, colors.primary.darkest],
2440
- border: [colors.primary.darker, colors.primary.lighter],
2441
- focusRing: [colors.primary.base, colors.primary.base]
2442
- },
2443
- positive: {
2444
- bg: [colors.positive.darkest, colors.positive.lightest],
2445
- fg: [colors.positive.lightest, colors.positive.darkest],
2446
- border: [colors.positive.darker, colors.positive.lighter],
2447
- focusRing: [colors.positive.base, colors.positive.base]
2448
- },
2449
- caution: {
2450
- bg: [colors.caution.darkest, colors.caution.lightest],
2451
- fg: [colors.caution.lightest, colors.caution.darkest],
2452
- border: [colors.caution.darker, colors.caution.lighter],
2453
- focusRing: [colors.caution.base, colors.caution.base]
2454
- },
2455
- critical: {
2456
- bg: [colors.critical.darkest, colors.critical.lightest],
2457
- fg: [colors.critical.lightest, colors.critical.darkest],
2458
- border: [colors.critical.darker, colors.critical.lighter],
2459
- focusRing: [colors.critical.base, colors.critical.base]
2460
- }
2461
- }, defaultOpts = {
2462
- base: ({ dark, name }) => name === "default" ? {
2463
- bg: dark ? black : white,
2464
- fg: dark ? white : black,
2465
- border: dark ? colors.default.darkest : colors.default.lightest,
2466
- focusRing: colors.primary.base,
2467
- shadow: {
2468
- outline: black,
2469
- umbra: black,
2470
- penumbra: black,
2471
- ambient: black
2472
- },
2473
- skeleton: {
2474
- from: dark ? white : black,
2475
- to: dark ? white : black
2476
- }
2477
- } : {
2478
- bg: tones[name].bg[+!dark],
2479
- fg: tones[name].fg[+!dark],
2480
- border: tones[name].border[+!dark],
2481
- focusRing: tones[name].focusRing[+!dark],
2482
- shadow: {
2483
- outline: black,
2484
- umbra: black,
2485
- penumbra: black,
2486
- ambient: black
2487
- },
2488
- skeleton: {
2489
- from: dark ? white : black,
2490
- to: dark ? white : black
2491
- }
2492
- },
2493
- solid: ({ base, dark, state, tone }) => {
2494
- let color = colors[tone];
2495
- return state === "hovered" ? {
2496
- bg: dark ? color.light : color.dark,
2497
- bg2: dark ? color.light : color.dark,
2498
- border: dark ? color.lighter : color.darker,
2499
- fg: dark ? color.darkest : color.lightest,
2500
- icon: dark ? color.darkest : color.lightest,
2501
- muted: { fg: black },
2502
- accent: { fg: black },
2503
- link: { fg: black },
2504
- code: {
2505
- bg: black,
2506
- fg: black
2507
- },
2508
- skeleton: base.skeleton
2509
- } : {
2510
- bg: color.base,
2511
- bg2: color.base,
2512
- border: dark ? color.light : color.dark,
2513
- fg: dark ? color.darkest : color.lightest,
2514
- icon: dark ? color.darkest : color.lightest,
2515
- muted: { fg: black },
2516
- accent: { fg: black },
2517
- link: { fg: black },
2518
- code: {
2519
- bg: black,
2520
- fg: black
2521
- },
2522
- skeleton: base.skeleton
2523
- };
2524
- },
2525
- muted: ({ base, dark, state, tone }) => {
2526
- let color = colors[tone];
2527
- return state === "hovered" ? {
2528
- bg: dark ? color.darker : color.lighter,
2529
- bg2: dark ? color.darker : color.lighter,
2530
- border: dark ? color.lighter : color.darker,
2531
- fg: dark ? color.lightest : color.darkest,
2532
- icon: dark ? color.lightest : color.darkest,
2533
- muted: { fg: black },
2534
- accent: { fg: black },
2535
- link: { fg: black },
2536
- code: {
2537
- bg: black,
2538
- fg: black
2539
- },
2540
- skeleton: base.skeleton
2541
- } : {
2542
- bg: dark ? color.darkest : color.lightest,
2543
- bg2: dark ? color.darkest : color.lightest,
2544
- border: dark ? color.darker : color.lighter,
2545
- fg: dark ? color.lighter : color.darker,
2546
- icon: dark ? color.lighter : color.darker,
2547
- muted: { fg: black },
2548
- accent: { fg: black },
2549
- link: { fg: black },
2550
- code: {
2551
- bg: black,
2552
- fg: black
2553
- },
2554
- skeleton: base.skeleton
2555
- };
2556
- },
2557
- button: ({ base, mode, muted, solid }) => mode === "bleed" ? {
2558
- ...muted,
2559
- enabled: {
2560
- bg: "transparent",
2561
- bg2: "transparent",
2562
- fg: muted.enabled.fg,
2563
- icon: muted.enabled.fg,
2564
- border: "transparent",
2565
- muted: { fg: black },
2566
- accent: { fg: black },
2567
- link: { fg: black },
2568
- code: {
2569
- bg: black,
2570
- fg: black
2571
- },
2572
- skeleton: base.skeleton
2573
- },
2574
- hovered: {
2575
- bg: muted.enabled.bg,
2576
- bg2: muted.enabled.bg,
2577
- fg: muted.hovered.fg,
2578
- icon: muted.hovered.fg,
2579
- border: "transparent",
2580
- muted: { fg: black },
2581
- accent: { fg: black },
2582
- link: { fg: black },
2583
- code: {
2584
- bg: black,
2585
- fg: black
2586
- },
2587
- skeleton: base.skeleton
2588
- }
2589
- } : mode === "ghost" ? {
2590
- ...solid,
2591
- enabled: muted.enabled
2592
- } : solid,
2593
- card: ({ base }) => ({
2594
- bg: black,
2595
- bg2: black,
2596
- fg: black,
2597
- icon: black,
2598
- border: black,
2599
- muted: { fg: black },
2600
- accent: { fg: black },
2601
- link: { fg: black },
2602
- code: {
2603
- bg: black,
2604
- fg: black
2605
- },
2606
- skeleton: base.skeleton
2607
- }),
2608
- input: () => ({
2609
- bg: black,
2610
- bg2: black,
2611
- fg: black,
2612
- border: black,
2613
- placeholder: black
2614
- }),
2615
- selectable: ({ muted, state, tone }) => muted[tone][state],
2616
- spot: ({ key }) => spots[key],
2617
- syntax: () => ({
2618
- atrule: black,
2619
- attrName: black,
2620
- attrValue: black,
2621
- attribute: black,
2622
- boolean: black,
2623
- builtin: black,
2624
- cdata: black,
2625
- char: black,
2626
- class: black,
2627
- className: black,
2628
- comment: black,
2629
- constant: black,
2630
- deleted: black,
2631
- doctype: black,
2632
- entity: black,
2633
- function: black,
2634
- hexcode: black,
2635
- id: black,
2636
- important: black,
2637
- inserted: black,
2638
- keyword: black,
2639
- number: black,
2640
- operator: black,
2641
- prolog: black,
2642
- property: black,
2643
- pseudoClass: black,
2644
- pseudoElement: black,
2645
- punctuation: black,
2646
- regex: black,
2647
- selector: black,
2648
- string: black,
2649
- symbol: black,
2650
- tag: black,
2651
- unit: black,
2652
- url: black,
2653
- variable: black
2654
- })
2655
- };
2656
- function createInputModes(opts, base, dark, solid, muted) {
2657
- return {
2658
- default: {
2659
- enabled: opts.input({
2660
- base,
2661
- dark,
2662
- mode: "default",
2663
- state: "enabled",
2664
- solid: solid.default,
2665
- muted: muted.default
2666
- }),
2667
- disabled: opts.input({
2668
- base,
2669
- dark,
2670
- mode: "default",
2671
- state: "disabled",
2672
- solid: solid.default,
2673
- muted: muted.default
2674
- }),
2675
- hovered: opts.input({
2676
- base,
2677
- dark,
2678
- mode: "default",
2679
- state: "hovered",
2680
- solid: solid.default,
2681
- muted: muted.default
2682
- }),
2683
- readOnly: opts.input({
2684
- base,
2685
- dark,
2686
- mode: "default",
2687
- state: "readOnly",
2688
- solid: solid.default,
2689
- muted: muted.default
2690
- })
2691
- },
2692
- invalid: {
2693
- enabled: opts.input({
2694
- base,
2695
- dark,
2696
- mode: "invalid",
2697
- state: "enabled",
2698
- solid: solid.default,
2699
- muted: muted.default
2700
- }),
2701
- disabled: opts.input({
2702
- base,
2703
- dark,
2704
- mode: "invalid",
2705
- state: "disabled",
2706
- solid: solid.default,
2707
- muted: muted.default
2708
- }),
2709
- hovered: opts.input({
2710
- base,
2711
- dark,
2712
- mode: "invalid",
2713
- state: "hovered",
2714
- solid: solid.default,
2715
- muted: muted.default
2716
- }),
2717
- readOnly: opts.input({
2718
- base,
2719
- dark,
2720
- mode: "invalid",
2721
- state: "readOnly",
2722
- solid: solid.default,
2723
- muted: muted.default
2724
- })
2725
- }
2726
- };
2727
- }
2728
- function createMutedTones(opts, base, dark, name) {
2729
- return {
2730
- default: {
2731
- enabled: opts.muted({
2732
- base,
2733
- dark,
2734
- tone: "default",
2735
- name,
2736
- state: "enabled"
2737
- }),
2738
- disabled: opts.muted({
2739
- base,
2740
- dark,
2741
- tone: "default",
2742
- name,
2743
- state: "disabled"
2744
- }),
2745
- hovered: opts.muted({
2746
- base,
2747
- dark,
2748
- tone: "default",
2749
- name,
2750
- state: "hovered"
2751
- }),
2752
- pressed: opts.muted({
2753
- base,
2754
- dark,
2755
- tone: "default",
2756
- name,
2757
- state: "pressed"
2758
- }),
2759
- selected: opts.muted({
2760
- base,
2761
- dark,
2762
- tone: "default",
2763
- name,
2764
- state: "selected"
2765
- })
2766
- },
2767
- transparent: {
2768
- enabled: opts.muted({
2769
- base,
2770
- dark,
2771
- tone: "transparent",
2772
- name,
2773
- state: "enabled"
2774
- }),
2775
- disabled: opts.muted({
2776
- base,
2777
- dark,
2778
- tone: "transparent",
2779
- name,
2780
- state: "disabled"
2781
- }),
2782
- hovered: opts.muted({
2783
- base,
2784
- dark,
2785
- tone: "transparent",
2786
- name,
2787
- state: "hovered"
2788
- }),
2789
- pressed: opts.muted({
2790
- base,
2791
- dark,
2792
- tone: "transparent",
2793
- name,
2794
- state: "pressed"
2795
- }),
2796
- selected: opts.muted({
2797
- base,
2798
- dark,
2799
- tone: "transparent",
2800
- name,
2801
- state: "selected"
2802
- })
2803
- },
2804
- primary: {
2805
- enabled: opts.muted({
2806
- base,
2807
- dark,
2808
- tone: "primary",
2809
- name,
2810
- state: "enabled"
2811
- }),
2812
- disabled: opts.muted({
2813
- base,
2814
- dark,
2815
- tone: "primary",
2816
- name,
2817
- state: "disabled"
2818
- }),
2819
- hovered: opts.muted({
2820
- base,
2821
- dark,
2822
- tone: "primary",
2823
- name,
2824
- state: "hovered"
2825
- }),
2826
- pressed: opts.muted({
2827
- base,
2828
- dark,
2829
- tone: "primary",
2830
- name,
2831
- state: "pressed"
2832
- }),
2833
- selected: opts.muted({
2834
- base,
2835
- dark,
2836
- tone: "primary",
2837
- name,
2838
- state: "selected"
2839
- })
2840
- },
2841
- positive: {
2842
- enabled: opts.muted({
2843
- base,
2844
- dark,
2845
- tone: "positive",
2846
- name,
2847
- state: "enabled"
2848
- }),
2849
- disabled: opts.muted({
2850
- base,
2851
- dark,
2852
- tone: "positive",
2853
- name,
2854
- state: "disabled"
2855
- }),
2856
- hovered: opts.muted({
2857
- base,
2858
- dark,
2859
- tone: "positive",
2860
- name,
2861
- state: "hovered"
2862
- }),
2863
- pressed: opts.muted({
2864
- base,
2865
- dark,
2866
- tone: "positive",
2867
- name,
2868
- state: "pressed"
2869
- }),
2870
- selected: opts.muted({
2871
- base,
2872
- dark,
2873
- tone: "positive",
2874
- name,
2875
- state: "selected"
2876
- })
2877
- },
2878
- caution: {
2879
- enabled: opts.muted({
2880
- base,
2881
- dark,
2882
- tone: "caution",
2883
- name,
2884
- state: "enabled"
2885
- }),
2886
- disabled: opts.muted({
2887
- base,
2888
- dark,
2889
- tone: "caution",
2890
- name,
2891
- state: "disabled"
2892
- }),
2893
- hovered: opts.muted({
2894
- base,
2895
- dark,
2896
- tone: "caution",
2897
- name,
2898
- state: "hovered"
2899
- }),
2900
- pressed: opts.muted({
2901
- base,
2902
- dark,
2903
- tone: "caution",
2904
- name,
2905
- state: "pressed"
2906
- }),
2907
- selected: opts.muted({
2908
- base,
2909
- dark,
2910
- tone: "caution",
2911
- name,
2912
- state: "selected"
2913
- })
2914
- },
2915
- critical: {
2916
- enabled: opts.muted({
2917
- base,
2918
- dark,
2919
- tone: "critical",
2920
- name,
2921
- state: "enabled"
2922
- }),
2923
- disabled: opts.muted({
2924
- base,
2925
- dark,
2926
- tone: "critical",
2927
- name,
2928
- state: "disabled"
2929
- }),
2930
- hovered: opts.muted({
2931
- base,
2932
- dark,
2933
- tone: "critical",
2934
- name,
2935
- state: "hovered"
2936
- }),
2937
- pressed: opts.muted({
2938
- base,
2939
- dark,
2940
- tone: "critical",
2941
- name,
2942
- state: "pressed"
2943
- }),
2944
- selected: opts.muted({
2945
- base,
2946
- dark,
2947
- tone: "critical",
2948
- name,
2949
- state: "selected"
2950
- })
2951
- }
2952
- };
2953
- }
2954
- function createSpot(opts, base, dark) {
2955
- return {
2956
- gray: opts.spot({
2957
- base,
2958
- dark,
2959
- key: "gray"
2960
- }),
2961
- blue: opts.spot({
2962
- base,
2963
- dark,
2964
- key: "blue"
2965
- }),
2966
- purple: opts.spot({
2967
- base,
2968
- dark,
2969
- key: "purple"
2970
- }),
2971
- magenta: opts.spot({
2972
- base,
2973
- dark,
2974
- key: "magenta"
2975
- }),
2976
- red: opts.spot({
2977
- base,
2978
- dark,
2979
- key: "red"
2980
- }),
2981
- orange: opts.spot({
2982
- base,
2983
- dark,
2984
- key: "orange"
2985
- }),
2986
- yellow: opts.spot({
2987
- base,
2988
- dark,
2989
- key: "yellow"
2990
- }),
2991
- green: opts.spot({
2992
- base,
2993
- dark,
2994
- key: "green"
2995
- }),
2996
- cyan: opts.spot({
2997
- base,
2998
- dark,
2999
- key: "cyan"
3000
- })
3001
- };
3002
- }
3003
- /**
3004
- * @public
3005
- * @deprecated Use `buildColorTheme` instead.
3006
- */
3007
- function createColorTheme(partialOpts = {}) {
3008
- let builders = {
3009
- ...defaultOpts,
3010
- ...partialOpts
3011
- };
3012
- return {
3013
- light: _createColorScheme(builders, !1),
3014
- dark: _createColorScheme(builders, !0)
3015
- };
3016
- }
3017
- /**
3018
- * @internal
3019
- */
3020
- function _createColorScheme(opts, dark) {
3021
- return {
3022
- default: _createColor(opts, dark, "default"),
3023
- transparent: _createColor(opts, dark, "transparent"),
3024
- primary: _createColor(opts, dark, "primary"),
3025
- positive: _createColor(opts, dark, "positive"),
3026
- caution: _createColor(opts, dark, "caution"),
3027
- critical: _createColor(opts, dark, "critical")
3028
- };
3029
- }
3030
- /**
3031
- * @internal
3032
- */
3033
- function _createColor(opts, dark, name) {
3034
- let base = opts.base({
3035
- dark,
3036
- name
3037
- }), solid = createSolidTones(opts, base, dark, name), muted = createMutedTones(opts, base, dark, name);
3038
- return {
3039
- base,
3040
- button: createButtonModes(opts, base, dark, solid, muted),
3041
- card: createCardStates(opts, base, dark, name, solid, muted),
3042
- dark,
3043
- input: createInputModes(opts, base, dark, solid, muted),
3044
- selectable: createSelectableTones(opts, base, dark, solid, muted),
3045
- spot: createSpot(opts, base, dark),
3046
- syntax: opts.syntax({
3047
- base,
3048
- dark
3049
- }),
3050
- solid,
3051
- muted
3052
- };
3053
- }
3054
- export { COLOR_CONFIG_STATE_TONES as A, THEME_COLOR_INPUT_STATES as B, COLOR_CONFIG_BLEND_KEYS as C, COLOR_CONFIG_INPUT_STATES as D, COLOR_CONFIG_INPUT_MODES as E, THEME_COLOR_AVATAR_COLORS as F, THEME_COLOR_STATES as H, THEME_COLOR_BLEND_MODES as I, THEME_COLOR_BUTTON_MODES as L, isColorButtonMode as M, isColorHueKey as N, COLOR_CONFIG_STATES as O, isColorTintKey as P, THEME_COLOR_CARD_TONES as R, COLOR_CONFIG_AVATAR_COLORS as S, COLOR_CONFIG_CARD_TONES as T, THEME_COLOR_STATE_TONES as U, THEME_COLOR_SCHEMES as V, isColorConfigStateKey as _, rgba as a, isColorTokenValue as b, hslToRgb as c, rgbaToRGBA as d, mix as f, isColorConfigBlendKey as g, isColorConfigBaseTone as h, multiply as i, isColorBlendModeValue as j, COLOR_CONFIG_STATE_KEYS as k, rgbToHex as l, isColorConfigBaseKey as m, buildTheme as n, parseColor as o, parseTokenValue as p, screen as r, hexToRgb as s, createColorTheme as t, rgbToHsl as u, isColorConfigStateTone as v, COLOR_CONFIG_CARD_KEYS as w, isColorValue as x, isColorOpacityValue as y, THEME_COLOR_INPUT_MODES as z };
3055
-
3056
- //# sourceMappingURL=factory-BzXTX8_Q.js.map