@arshad-shah/cynosure 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (511) hide show
  1. package/README.md +6 -6
  2. package/dist/_virtual/_rolldown/runtime.js +12 -0
  3. package/dist/adapters/astro/index.d.ts +2 -1
  4. package/dist/adapters/astro/index.js.map +1 -1
  5. package/dist/components/Accordion/Accordion.d.ts +1 -1
  6. package/dist/components/Accordion/Accordion.js +26 -26
  7. package/dist/components/Accordion/Accordion.js.map +1 -1
  8. package/dist/components/Announcer/Announcer.d.ts +2 -1
  9. package/dist/components/Announcer/Announcer.js +31 -33
  10. package/dist/components/Announcer/Announcer.js.map +1 -1
  11. package/dist/components/AppShell/AppShell.js +44 -41
  12. package/dist/components/AppShell/AppShell.js.map +1 -1
  13. package/dist/components/Badge/Badge.d.ts +19 -5
  14. package/dist/components/Badge/Badge.js +19 -13
  15. package/dist/components/Badge/Badge.js.map +1 -1
  16. package/dist/components/Button/Button.d.ts +13 -3
  17. package/dist/components/Button/Button.js +34 -33
  18. package/dist/components/Button/Button.js.map +1 -1
  19. package/dist/components/Calendar/Calendar.js +155 -158
  20. package/dist/components/Calendar/Calendar.js.map +1 -1
  21. package/dist/components/Calendar/dates.js +42 -38
  22. package/dist/components/Calendar/dates.js.map +1 -1
  23. package/dist/components/Card/Card.d.ts +14 -1
  24. package/dist/components/Card/Card.js +60 -52
  25. package/dist/components/Card/Card.js.map +1 -1
  26. package/dist/components/ChatMessage/ChatMessage.d.ts +55 -0
  27. package/dist/components/ChatMessage/ChatMessage.js +50 -0
  28. package/dist/components/ChatMessage/ChatMessage.js.map +1 -0
  29. package/dist/components/ChatMessage/index.d.ts +1 -0
  30. package/dist/components/CodeBlock/CodeBlock.d.ts +6 -1
  31. package/dist/components/CodeBlock/CodeBlock.js +40 -37
  32. package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
  33. package/dist/components/ColorField/ColorField.d.ts +3 -2
  34. package/dist/components/ColorField/ColorField.js +138 -139
  35. package/dist/components/ColorField/ColorField.js.map +1 -1
  36. package/dist/components/ColorField/read-color.js +5 -6
  37. package/dist/components/ColorField/read-color.js.map +1 -1
  38. package/dist/components/ColorSwatches/ColorSwatches.js +42 -33
  39. package/dist/components/ColorSwatches/ColorSwatches.js.map +1 -1
  40. package/dist/components/Combobox/Combobox.d.ts +13 -2
  41. package/dist/components/Combobox/Combobox.js +113 -95
  42. package/dist/components/Combobox/Combobox.js.map +1 -1
  43. package/dist/components/CommandPalette/CommandPalette.d.ts +14 -1
  44. package/dist/components/CommandPalette/CommandPalette.js +153 -109
  45. package/dist/components/CommandPalette/CommandPalette.js.map +1 -1
  46. package/dist/components/CommandPalette/index.d.ts +1 -1
  47. package/dist/components/CompareSlider/CompareSlider.js +14 -14
  48. package/dist/components/CompareSlider/CompareSlider.js.map +1 -1
  49. package/dist/components/Container/Container.d.ts +1 -1
  50. package/dist/components/Container/Container.js +1 -1
  51. package/dist/components/Container/Container.js.map +1 -1
  52. package/dist/components/ContextMenu/ContextMenu.d.ts +27 -13
  53. package/dist/components/ContextMenu/ContextMenu.js +64 -46
  54. package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
  55. package/dist/components/CopyButton/CopyButton.js +38 -39
  56. package/dist/components/CopyButton/CopyButton.js.map +1 -1
  57. package/dist/components/DataGrid/DataGrid.d.ts +135 -0
  58. package/dist/components/DataGrid/DataGrid.js +385 -0
  59. package/dist/components/DataGrid/DataGrid.js.map +1 -0
  60. package/dist/components/DataGrid/index.d.ts +1 -0
  61. package/dist/components/DateField/DateField.d.ts +4 -3
  62. package/dist/components/DateField/DateField.js +70 -59
  63. package/dist/components/DateField/DateField.js.map +1 -1
  64. package/dist/components/Dialog/Dialog.js +76 -80
  65. package/dist/components/Dialog/Dialog.js.map +1 -1
  66. package/dist/components/Disclosure/Disclosure.d.ts +15 -1
  67. package/dist/components/Disclosure/Disclosure.js +37 -30
  68. package/dist/components/Disclosure/Disclosure.js.map +1 -1
  69. package/dist/components/DocumentViewport/DocumentViewport.js +54 -57
  70. package/dist/components/DocumentViewport/DocumentViewport.js.map +1 -1
  71. package/dist/components/ErrorBoundary/ErrorBoundary.d.ts +59 -0
  72. package/dist/components/ErrorBoundary/ErrorBoundary.js +53 -0
  73. package/dist/components/ErrorBoundary/ErrorBoundary.js.map +1 -0
  74. package/dist/components/ErrorBoundary/index.d.ts +1 -0
  75. package/dist/components/Field/Field.d.ts +38 -5
  76. package/dist/components/Field/Field.js +47 -39
  77. package/dist/components/Field/Field.js.map +1 -1
  78. package/dist/components/Field/index.d.ts +1 -1
  79. package/dist/components/FileDrop/FileDrop.d.ts +26 -1
  80. package/dist/components/FileDrop/FileDrop.js +149 -98
  81. package/dist/components/FileDrop/FileDrop.js.map +1 -1
  82. package/dist/components/FloatingToolbar/FloatingToolbar.js +83 -81
  83. package/dist/components/FloatingToolbar/FloatingToolbar.js.map +1 -1
  84. package/dist/components/Grid/Grid.d.ts +3 -3
  85. package/dist/components/Grid/Grid.js +55 -47
  86. package/dist/components/Grid/Grid.js.map +1 -1
  87. package/dist/components/HighlightedText/HighlightedText.d.ts +40 -0
  88. package/dist/components/HighlightedText/HighlightedText.js +36 -0
  89. package/dist/components/HighlightedText/HighlightedText.js.map +1 -0
  90. package/dist/components/HighlightedText/index.d.ts +2 -0
  91. package/dist/components/HotkeyField/HotkeyField.d.ts +84 -0
  92. package/dist/components/HotkeyField/HotkeyField.js +161 -0
  93. package/dist/components/HotkeyField/HotkeyField.js.map +1 -0
  94. package/dist/components/HotkeyField/index.d.ts +1 -0
  95. package/dist/components/HoverCard/HoverCard.js +6 -6
  96. package/dist/components/HoverCard/HoverCard.js.map +1 -1
  97. package/dist/components/IconButton/IconButton.js +16 -15
  98. package/dist/components/IconButton/IconButton.js.map +1 -1
  99. package/dist/components/Inline/Inline.d.ts +2 -2
  100. package/dist/components/Inline/Inline.js.map +1 -1
  101. package/dist/components/Kbd/Kbd.d.ts +0 -2
  102. package/dist/components/Kbd/Kbd.js +16 -22
  103. package/dist/components/Kbd/Kbd.js.map +1 -1
  104. package/dist/components/KeyValueEditor/bulk.js +3 -4
  105. package/dist/components/KeyValueEditor/bulk.js.map +1 -1
  106. package/dist/components/ListRow/ListRow.d.ts +105 -0
  107. package/dist/components/ListRow/ListRow.js +164 -0
  108. package/dist/components/ListRow/ListRow.js.map +1 -0
  109. package/dist/components/ListRow/index.d.ts +1 -0
  110. package/dist/components/LoadingDots/LoadingDots.d.ts +7 -2
  111. package/dist/components/LoadingDots/LoadingDots.js +28 -18
  112. package/dist/components/LoadingDots/LoadingDots.js.map +1 -1
  113. package/dist/components/Menu/Menu.d.ts +29 -11
  114. package/dist/components/Menu/Menu.js +204 -111
  115. package/dist/components/Menu/Menu.js.map +1 -1
  116. package/dist/components/Menubar/Menubar.d.ts +40 -0
  117. package/dist/components/Menubar/Menubar.js +82 -0
  118. package/dist/components/Menubar/Menubar.js.map +1 -0
  119. package/dist/components/Menubar/index.d.ts +1 -0
  120. package/dist/components/Notice/Notice.d.ts +11 -2
  121. package/dist/components/Notice/Notice.js +31 -28
  122. package/dist/components/Notice/Notice.js.map +1 -1
  123. package/dist/components/NumberField/NumberField.d.ts +8 -3
  124. package/dist/components/NumberField/NumberField.js +151 -100
  125. package/dist/components/NumberField/NumberField.js.map +1 -1
  126. package/dist/components/OptionList/OptionList.d.ts +36 -3
  127. package/dist/components/OptionList/OptionList.js +65 -42
  128. package/dist/components/OptionList/OptionList.js.map +1 -1
  129. package/dist/components/OptionList/index.d.ts +1 -1
  130. package/dist/components/OverlayFrame/OverlayFrame.d.ts +33 -0
  131. package/dist/components/OverlayFrame/OverlayFrame.js +20 -0
  132. package/dist/components/OverlayFrame/OverlayFrame.js.map +1 -0
  133. package/dist/components/OverlayFrame/index.d.ts +1 -0
  134. package/dist/components/PanZoomCanvas/PanZoomCanvas.d.ts +71 -4
  135. package/dist/components/PanZoomCanvas/PanZoomCanvas.js +197 -141
  136. package/dist/components/PanZoomCanvas/PanZoomCanvas.js.map +1 -1
  137. package/dist/components/PanZoomCanvas/index.d.ts +1 -1
  138. package/dist/components/PathField/PathField.d.ts +68 -0
  139. package/dist/components/PathField/PathField.js +67 -0
  140. package/dist/components/PathField/PathField.js.map +1 -0
  141. package/dist/components/PathField/index.d.ts +1 -0
  142. package/dist/components/Popover/Popover.d.ts +16 -3
  143. package/dist/components/Popover/Popover.js +51 -42
  144. package/dist/components/Popover/Popover.js.map +1 -1
  145. package/dist/components/ProgressBar/ProgressBar.d.ts +4 -3
  146. package/dist/components/ProgressBar/ProgressBar.js.map +1 -1
  147. package/dist/components/RowActions/RowActions.d.ts +35 -0
  148. package/dist/components/RowActions/RowActions.js +38 -0
  149. package/dist/components/RowActions/RowActions.js.map +1 -0
  150. package/dist/components/RowActions/index.d.ts +1 -0
  151. package/dist/components/ScrollArea/ScrollArea.d.ts +55 -0
  152. package/dist/components/ScrollArea/ScrollArea.js +55 -0
  153. package/dist/components/ScrollArea/ScrollArea.js.map +1 -0
  154. package/dist/components/ScrollArea/index.d.ts +1 -0
  155. package/dist/components/SearchField/SearchField.d.ts +17 -0
  156. package/dist/components/SearchField/SearchField.js +31 -17
  157. package/dist/components/SearchField/SearchField.js.map +1 -1
  158. package/dist/components/SearchField/index.d.ts +1 -1
  159. package/dist/components/Section/Section.d.ts +1 -1
  160. package/dist/components/Section/Section.js +1 -1
  161. package/dist/components/Section/Section.js.map +1 -1
  162. package/dist/components/SegmentedControl/SegmentedControl.d.ts +6 -3
  163. package/dist/components/SegmentedControl/SegmentedControl.js +23 -19
  164. package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
  165. package/dist/components/Select/Select.d.ts +22 -6
  166. package/dist/components/Select/Select.js +155 -129
  167. package/dist/components/Select/Select.js.map +1 -1
  168. package/dist/components/SelectionFrame/frame-math.js +19 -20
  169. package/dist/components/SelectionFrame/frame-math.js.map +1 -1
  170. package/dist/components/SideNav/SideNav.d.ts +13 -1
  171. package/dist/components/SideNav/SideNav.js +98 -91
  172. package/dist/components/SideNav/SideNav.js.map +1 -1
  173. package/dist/components/SignaturePad/SignaturePad.js +63 -62
  174. package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
  175. package/dist/components/SignaturePad/ink.js +0 -1
  176. package/dist/components/SignaturePad/ink.js.map +1 -1
  177. package/dist/components/Slider/Slider.js +88 -91
  178. package/dist/components/Slider/Slider.js.map +1 -1
  179. package/dist/components/SortButton/SortButton.d.ts +36 -0
  180. package/dist/components/SortButton/SortButton.js +35 -0
  181. package/dist/components/SortButton/SortButton.js.map +1 -0
  182. package/dist/components/SortButton/index.d.ts +1 -0
  183. package/dist/components/SortableList/SortableList.js +145 -119
  184. package/dist/components/SortableList/SortableList.js.map +1 -1
  185. package/dist/components/SplitPane/SplitPane.d.ts +32 -12
  186. package/dist/components/SplitPane/SplitPane.js +105 -59
  187. package/dist/components/SplitPane/SplitPane.js.map +1 -1
  188. package/dist/components/Stack/Stack.d.ts +2 -2
  189. package/dist/components/Stack/Stack.js +24 -17
  190. package/dist/components/Stack/Stack.js.map +1 -1
  191. package/dist/components/Stack/index.d.ts +1 -1
  192. package/dist/components/Stat/Stat.js +6 -6
  193. package/dist/components/Stat/Stat.js.map +1 -1
  194. package/dist/components/StatusBar/StatusBar.d.ts +95 -0
  195. package/dist/components/StatusBar/StatusBar.js +110 -0
  196. package/dist/components/StatusBar/StatusBar.js.map +1 -0
  197. package/dist/components/StatusBar/index.d.ts +1 -0
  198. package/dist/components/Table/Table.d.ts +6 -6
  199. package/dist/components/Table/Table.js +71 -99
  200. package/dist/components/Table/Table.js.map +1 -1
  201. package/dist/components/Tabs/Tabs.d.ts +51 -5
  202. package/dist/components/Tabs/Tabs.js +289 -171
  203. package/dist/components/Tabs/Tabs.js.map +1 -1
  204. package/dist/components/TagInput/TagInput.d.ts +10 -2
  205. package/dist/components/TagInput/TagInput.js +121 -111
  206. package/dist/components/TagInput/TagInput.js.map +1 -1
  207. package/dist/components/Text/Text.d.ts +6 -0
  208. package/dist/components/Text/Text.js +18 -17
  209. package/dist/components/Text/Text.js.map +1 -1
  210. package/dist/components/TextArea/TextArea.d.ts +37 -6
  211. package/dist/components/TextArea/TextArea.js +200 -72
  212. package/dist/components/TextArea/TextArea.js.map +1 -1
  213. package/dist/components/TextArea/index.d.ts +1 -1
  214. package/dist/components/TextField/TextField.d.ts +18 -6
  215. package/dist/components/TextField/TextField.js +59 -54
  216. package/dist/components/TextField/TextField.js.map +1 -1
  217. package/dist/components/TimeField/TimeField.d.ts +4 -3
  218. package/dist/components/TimeField/TimeField.js +197 -183
  219. package/dist/components/TimeField/TimeField.js.map +1 -1
  220. package/dist/components/TitleBar/TitleBar.d.ts +91 -0
  221. package/dist/components/TitleBar/TitleBar.js +80 -0
  222. package/dist/components/TitleBar/TitleBar.js.map +1 -0
  223. package/dist/components/TitleBar/index.d.ts +1 -0
  224. package/dist/components/Toast/Toast.d.ts +17 -2
  225. package/dist/components/Toast/Toast.js +162 -145
  226. package/dist/components/Toast/Toast.js.map +1 -1
  227. package/dist/components/Toast/index.d.ts +1 -1
  228. package/dist/components/Toolbar/Toolbar.js +11 -12
  229. package/dist/components/Toolbar/Toolbar.js.map +1 -1
  230. package/dist/components/Tooltip/Tooltip.d.ts +18 -1
  231. package/dist/components/Tooltip/Tooltip.js +50 -31
  232. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  233. package/dist/components/Tree/Tree.d.ts +92 -11
  234. package/dist/components/Tree/Tree.js +332 -164
  235. package/dist/components/Tree/Tree.js.map +1 -1
  236. package/dist/components/VirtualList/VirtualList.d.ts +27 -4
  237. package/dist/components/VirtualList/VirtualList.js +179 -145
  238. package/dist/components/VirtualList/VirtualList.js.map +1 -1
  239. package/dist/components/VirtualList/index.d.ts +1 -1
  240. package/dist/components/ZoomControls/ZoomControls.d.ts +6 -2
  241. package/dist/components/ZoomControls/ZoomControls.js +37 -37
  242. package/dist/components/ZoomControls/ZoomControls.js.map +1 -1
  243. package/dist/entries/tokens.js +22 -16
  244. package/dist/foundations/ChoiceBase/ChoiceBase.js +15 -13
  245. package/dist/foundations/ChoiceBase/ChoiceBase.js.map +1 -1
  246. package/dist/foundations/LiveRegion/LiveRegion.d.ts +33 -0
  247. package/dist/foundations/LiveRegion/LiveRegion.js +29 -0
  248. package/dist/foundations/LiveRegion/LiveRegion.js.map +1 -0
  249. package/dist/foundations/LiveRegion/index.d.ts +1 -0
  250. package/dist/foundations/canvas-size.d.ts +14 -0
  251. package/dist/foundations/canvas-size.js +32 -0
  252. package/dist/foundations/canvas-size.js.map +1 -0
  253. package/dist/foundations/dir.js +0 -1
  254. package/dist/foundations/dir.js.map +1 -1
  255. package/dist/foundations/draft.d.ts +14 -0
  256. package/dist/foundations/draft.js +22 -0
  257. package/dist/foundations/draft.js.map +1 -0
  258. package/dist/foundations/edge.d.ts +20 -0
  259. package/dist/foundations/edge.js +26 -0
  260. package/dist/foundations/edge.js.map +1 -0
  261. package/dist/foundations/focus.d.ts +5 -0
  262. package/dist/foundations/focus.js +10 -0
  263. package/dist/foundations/focus.js.map +1 -0
  264. package/dist/foundations/hotkey.d.ts +23 -1
  265. package/dist/foundations/hotkey.js +48 -26
  266. package/dist/foundations/hotkey.js.map +1 -1
  267. package/dist/foundations/icon-size.d.ts +7 -0
  268. package/dist/foundations/icon-size.js +6 -0
  269. package/dist/foundations/icon-size.js.map +1 -0
  270. package/dist/foundations/keys.js +12 -13
  271. package/dist/foundations/keys.js.map +1 -1
  272. package/dist/{components/Stack/space.d.ts → foundations/layout.d.ts} +34 -0
  273. package/dist/foundations/layout.js +29 -0
  274. package/dist/foundations/layout.js.map +1 -0
  275. package/dist/foundations/listbox.d.ts +47 -2
  276. package/dist/foundations/listbox.js +56 -25
  277. package/dist/foundations/listbox.js.map +1 -1
  278. package/dist/foundations/math.d.ts +25 -0
  279. package/dist/foundations/math.js +14 -3
  280. package/dist/foundations/math.js.map +1 -1
  281. package/dist/foundations/media-query.d.ts +5 -0
  282. package/dist/foundations/media-query.js +14 -0
  283. package/dist/foundations/media-query.js.map +1 -0
  284. package/dist/foundations/motion.d.ts +12 -0
  285. package/dist/foundations/motion.js +21 -0
  286. package/dist/foundations/motion.js.map +1 -0
  287. package/dist/foundations/option-icon.d.ts +3 -1
  288. package/dist/foundations/option-icon.js +6 -6
  289. package/dist/foundations/option-icon.js.map +1 -1
  290. package/dist/foundations/qr.js +0 -1
  291. package/dist/foundations/qr.js.map +1 -1
  292. package/dist/foundations/refs.d.ts +8 -0
  293. package/dist/foundations/refs.js +14 -0
  294. package/dist/foundations/refs.js.map +1 -0
  295. package/dist/foundations/reorder.js +5 -6
  296. package/dist/foundations/reorder.js.map +1 -1
  297. package/dist/foundations/roving-focus.d.ts +10 -0
  298. package/dist/foundations/roving-focus.js +34 -31
  299. package/dist/foundations/roving-focus.js.map +1 -1
  300. package/dist/foundations/scroll-align.d.ts +11 -0
  301. package/dist/foundations/scroll-align.js +8 -0
  302. package/dist/foundations/scroll-align.js.map +1 -0
  303. package/dist/foundations/sort.d.ts +13 -0
  304. package/dist/foundations/sort.js +26 -0
  305. package/dist/foundations/sort.js.map +1 -0
  306. package/dist/foundations/text-match.d.ts +11 -0
  307. package/dist/foundations/text-match.js +20 -0
  308. package/dist/foundations/text-match.js.map +1 -0
  309. package/dist/foundations/tone-icons.js +4 -5
  310. package/dist/foundations/tone-icons.js.map +1 -1
  311. package/dist/foundations/use-follow.d.ts +29 -0
  312. package/dist/foundations/use-follow.js +51 -0
  313. package/dist/foundations/use-follow.js.map +1 -0
  314. package/dist/foundations/virtual-window.d.ts +22 -5
  315. package/dist/foundations/virtual-window.js +58 -54
  316. package/dist/foundations/virtual-window.js.map +1 -1
  317. package/dist/foundations/zoom-gestures.d.ts +23 -1
  318. package/dist/foundations/zoom-gestures.js +123 -84
  319. package/dist/foundations/zoom-gestures.js.map +1 -1
  320. package/dist/foundations/zoom.d.ts +10 -4
  321. package/dist/foundations/zoom.js +16 -17
  322. package/dist/foundations/zoom.js.map +1 -1
  323. package/dist/icons/boxes.d.ts +2 -0
  324. package/dist/icons/boxes.js +34 -0
  325. package/dist/icons/boxes.js.map +1 -0
  326. package/dist/icons/by-name.d.ts +11 -0
  327. package/dist/icons/by-name.js +11 -0
  328. package/dist/icons/by-name.js.map +1 -0
  329. package/dist/icons/cable.d.ts +2 -0
  330. package/dist/icons/cable.js +14 -0
  331. package/dist/icons/cable.js.map +1 -0
  332. package/dist/icons/check-check.d.ts +2 -0
  333. package/dist/icons/check-check.js +17 -0
  334. package/dist/icons/check-check.js.map +1 -0
  335. package/dist/icons/clipboard-paste.d.ts +2 -0
  336. package/dist/icons/clipboard-paste.js +30 -0
  337. package/dist/icons/clipboard-paste.js.map +1 -0
  338. package/dist/icons/facet.d.ts +274 -0
  339. package/dist/icons/facet.js +830 -0
  340. package/dist/icons/facet.js.map +1 -0
  341. package/dist/icons/file-plus.d.ts +2 -0
  342. package/dist/icons/file-plus.js +14 -0
  343. package/dist/icons/file-plus.js.map +1 -0
  344. package/dist/icons/file-question.d.ts +2 -0
  345. package/dist/icons/file-question.js +14 -0
  346. package/dist/icons/file-question.js.map +1 -0
  347. package/dist/icons/file-search.d.ts +2 -0
  348. package/dist/icons/file-search.js +24 -0
  349. package/dist/icons/file-search.js.map +1 -0
  350. package/dist/icons/function.d.ts +2 -0
  351. package/dist/icons/function.js +20 -0
  352. package/dist/icons/function.js.map +1 -0
  353. package/dist/icons/gauge.d.ts +2 -0
  354. package/dist/icons/gauge.js +14 -0
  355. package/dist/icons/gauge.js.map +1 -0
  356. package/dist/icons/hourglass.d.ts +2 -0
  357. package/dist/icons/hourglass.js +14 -0
  358. package/dist/icons/hourglass.js.map +1 -0
  359. package/dist/icons/index.d.ts +1 -250
  360. package/dist/icons/index.js +548 -500
  361. package/dist/icons/keywords.d.ts +24 -0
  362. package/dist/icons/keywords.js +185 -0
  363. package/dist/icons/keywords.js.map +1 -1
  364. package/dist/icons/languages.d.ts +2 -0
  365. package/dist/icons/languages.js +14 -0
  366. package/dist/icons/languages.js.map +1 -0
  367. package/dist/icons/loader.d.ts +2 -0
  368. package/dist/icons/loader.js +14 -0
  369. package/dist/icons/loader.js.map +1 -0
  370. package/dist/icons/monitor-down.d.ts +2 -0
  371. package/dist/icons/monitor-down.js +24 -0
  372. package/dist/icons/monitor-down.js.map +1 -0
  373. package/dist/icons/panel-right.d.ts +2 -0
  374. package/dist/icons/panel-right.js +20 -0
  375. package/dist/icons/panel-right.js.map +1 -0
  376. package/dist/icons/party-popper.d.ts +2 -0
  377. package/dist/icons/party-popper.js +14 -0
  378. package/dist/icons/party-popper.js.map +1 -0
  379. package/dist/icons/power-off.d.ts +2 -0
  380. package/dist/icons/power-off.js +14 -0
  381. package/dist/icons/power-off.js.map +1 -0
  382. package/dist/icons/rocket.d.ts +2 -0
  383. package/dist/icons/rocket.js +21 -0
  384. package/dist/icons/rocket.js.map +1 -0
  385. package/dist/icons/rows.d.ts +2 -0
  386. package/dist/icons/rows.js +20 -0
  387. package/dist/icons/rows.js.map +1 -0
  388. package/dist/icons/scissors.d.ts +2 -0
  389. package/dist/icons/scissors.js +26 -0
  390. package/dist/icons/scissors.js.map +1 -0
  391. package/dist/icons/shield-question.d.ts +2 -0
  392. package/dist/icons/shield-question.js +14 -0
  393. package/dist/icons/shield-question.js.map +1 -0
  394. package/dist/icons/square-plus.d.ts +2 -0
  395. package/dist/icons/square-plus.js +20 -0
  396. package/dist/icons/square-plus.js.map +1 -0
  397. package/dist/icons/text-select.d.ts +2 -0
  398. package/dist/icons/text-select.js +14 -0
  399. package/dist/icons/text-select.js.map +1 -0
  400. package/dist/icons/window-maximize.d.ts +2 -0
  401. package/dist/icons/window-maximize.js +14 -0
  402. package/dist/icons/window-maximize.js.map +1 -0
  403. package/dist/icons/window-restore.d.ts +2 -0
  404. package/dist/icons/window-restore.js +20 -0
  405. package/dist/icons/window-restore.js.map +1 -0
  406. package/dist/index.d.ts +24 -9
  407. package/dist/index.js +326 -282
  408. package/dist/overlay/dismiss.js +15 -13
  409. package/dist/overlay/dismiss.js.map +1 -1
  410. package/dist/overlay/floating.d.ts +7 -2
  411. package/dist/overlay/floating.js +29 -21
  412. package/dist/overlay/floating.js.map +1 -1
  413. package/dist/overlay/listbox-layer.d.ts +3 -2
  414. package/dist/overlay/listbox-layer.js.map +1 -1
  415. package/dist/overlay/position.d.ts +5 -2
  416. package/dist/overlay/position.js +19 -19
  417. package/dist/overlay/position.js.map +1 -1
  418. package/dist/overlay/toast-host.js +3 -2
  419. package/dist/overlay/toast-host.js.map +1 -1
  420. package/dist/overlay/use-anchored-position.d.ts +2 -2
  421. package/dist/overlay/use-anchored-position.js +25 -25
  422. package/dist/overlay/use-anchored-position.js.map +1 -1
  423. package/dist/styles/badge.css +1 -1
  424. package/dist/styles/base.css +1 -1
  425. package/dist/styles/button.css +1 -1
  426. package/dist/styles/calendar.css +1 -1
  427. package/dist/styles/card.css +1 -1
  428. package/dist/styles/chat-message.css +1 -0
  429. package/dist/styles/code-block.css +1 -1
  430. package/dist/styles/command-palette.css +1 -1
  431. package/dist/styles/data-grid.css +1 -0
  432. package/dist/styles/disclosure.css +1 -1
  433. package/dist/styles/error-boundary.css +1 -0
  434. package/dist/styles/field.css +1 -1
  435. package/dist/styles/file-drop.css +1 -1
  436. package/dist/styles/generated-css.d.ts +1 -1
  437. package/dist/styles/generated-css.js +3 -3
  438. package/dist/styles/generated-css.js.map +1 -1
  439. package/dist/styles/highlighted-text.css +1 -0
  440. package/dist/styles/hotkey-field.css +1 -0
  441. package/dist/styles/list-row.css +1 -0
  442. package/dist/styles/loading-dots.css +1 -1
  443. package/dist/styles/manifest.json +149 -12
  444. package/dist/styles/menu.css +1 -1
  445. package/dist/styles/menubar.css +1 -0
  446. package/dist/styles/notice.css +1 -1
  447. package/dist/styles/option-list.css +1 -1
  448. package/dist/styles/overlay-frame.css +1 -0
  449. package/dist/styles/pan-zoom-canvas.css +1 -1
  450. package/dist/styles/path-field.css +1 -0
  451. package/dist/styles/popover.css +1 -1
  452. package/dist/styles/progress-bar.css +1 -1
  453. package/dist/styles/row-actions.css +1 -0
  454. package/dist/styles/scroll-area.css +1 -0
  455. package/dist/styles/search-field.css +1 -0
  456. package/dist/styles/segmented-control.css +1 -1
  457. package/dist/styles/select.css +1 -1
  458. package/dist/styles/side-nav.css +1 -1
  459. package/dist/styles/sort-button.css +1 -0
  460. package/dist/styles/split-pane.css +1 -1
  461. package/dist/styles/status-bar.css +1 -0
  462. package/dist/styles/table.css +1 -1
  463. package/dist/styles/tabs.css +1 -1
  464. package/dist/styles/text-area.css +1 -1
  465. package/dist/styles/text-field.css +1 -1
  466. package/dist/styles/text.css +1 -1
  467. package/dist/styles/title-bar.css +1 -0
  468. package/dist/styles/toast.css +1 -1
  469. package/dist/styles/tokens.css +3 -3
  470. package/dist/styles/tree.css +1 -1
  471. package/dist/styles/virtual-list.css +1 -1
  472. package/dist/styles.css +3 -3
  473. package/dist/theme/CynosureTheme.d.ts +7 -3
  474. package/dist/theme/CynosureTheme.js +47 -31
  475. package/dist/theme/CynosureTheme.js.map +1 -1
  476. package/dist/theme/index.d.ts +1 -0
  477. package/dist/theme/theme-context.d.ts +9 -0
  478. package/dist/theme/theme-context.js +8 -0
  479. package/dist/theme/theme-context.js.map +1 -0
  480. package/dist/theme/theme-init-script.js +0 -1
  481. package/dist/theme/theme-init-script.js.map +1 -1
  482. package/dist/theme/use-color-mode.d.ts +3 -2
  483. package/dist/theme/use-color-mode.js +35 -38
  484. package/dist/theme/use-color-mode.js.map +1 -1
  485. package/dist/theme/use-cynosure-theme.d.ts +18 -0
  486. package/dist/theme/use-cynosure-theme.js +23 -0
  487. package/dist/theme/use-cynosure-theme.js.map +1 -0
  488. package/dist/tokens/chart-themes.d.ts +38 -0
  489. package/dist/tokens/chart-themes.js +35 -0
  490. package/dist/tokens/chart-themes.js.map +1 -0
  491. package/dist/tokens/create-theme.d.ts +11 -1
  492. package/dist/tokens/create-theme.js +161 -121
  493. package/dist/tokens/create-theme.js.map +1 -1
  494. package/dist/tokens/defaults.d.ts +3 -3
  495. package/dist/tokens/defaults.js +1 -0
  496. package/dist/tokens/defaults.js.map +1 -1
  497. package/dist/tokens/editor-themes.d.ts +9 -2
  498. package/dist/tokens/editor-themes.js +43 -42
  499. package/dist/tokens/editor-themes.js.map +1 -1
  500. package/dist/tokens/index.d.ts +3 -1
  501. package/dist/tokens/named-themes.d.ts +41 -0
  502. package/dist/tokens/named-themes.js +118 -0
  503. package/dist/tokens/named-themes.js.map +1 -0
  504. package/dist/tokens/schema.d.ts +24 -1
  505. package/dist/tokens/schema.js +13 -0
  506. package/dist/tokens/schema.js.map +1 -0
  507. package/dist/tokens/to-css.js +34 -31
  508. package/dist/tokens/to-css.js.map +1 -1
  509. package/package.json +10 -6
  510. package/dist/components/Stack/space.js +0 -23
  511. package/dist/components/Stack/space.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import { mix as d } from "./color.js";
2
2
  import { createTheme as u } from "./create-theme.js";
3
+ import { resolveColors as l } from "./chart-themes.js";
3
4
  function s(o = u(), n = "light") {
4
- const e = o.palettes[n];
5
+ const e = l(o, n);
5
6
  return {
6
7
  background: e.surface,
7
8
  foreground: e.ink,
@@ -25,35 +26,35 @@ function s(o = u(), n = "light") {
25
26
  invalid: e.dangerText
26
27
  };
27
28
  }
28
- var l = (o) => o.replace("#", ""), g = (o) => o.startsWith("dark");
29
- function y(o = u(), n = "light") {
30
- const e = s(o, n), r = n.endsWith("contrast"), t = (a, i, c) => ({
29
+ var m = (o) => o.replace("#", ""), g = (o) => o.startsWith("dark");
30
+ function f(o = u(), n = "light") {
31
+ const e = s(o, n), t = n.endsWith("contrast"), r = (a, i, c) => ({
31
32
  token: a,
32
- foreground: l(i),
33
+ foreground: m(i),
33
34
  ...c ? { fontStyle: c } : {}
34
35
  });
35
36
  return {
36
- base: g(n) ? r ? "hc-black" : "vs-dark" : r ? "hc-light" : "vs",
37
+ base: g(n) ? t ? "hc-black" : "vs-dark" : t ? "hc-light" : "vs",
37
38
  inherit: !0,
38
39
  rules: [
39
- t("", e.foreground),
40
- t("comment", e.comment, "italic"),
41
- t("keyword", e.keyword),
42
- t("string", e.string),
43
- t("number", e.number),
44
- t("regexp", e.regexp),
45
- t("type", e.type),
46
- t("type.identifier", e.type),
47
- t("function", e.function),
48
- t("identifier", e.variable),
49
- t("variable", e.variable),
50
- t("operator", e.operator),
51
- t("delimiter", e.operator),
52
- t("tag", e.tag),
53
- t("attribute.name", e.attribute),
54
- t("attribute.value", e.string),
55
- t("key", e.property),
56
- t("invalid", e.invalid)
40
+ r("", e.foreground),
41
+ r("comment", e.comment, "italic"),
42
+ r("keyword", e.keyword),
43
+ r("string", e.string),
44
+ r("number", e.number),
45
+ r("regexp", e.regexp),
46
+ r("type", e.type),
47
+ r("type.identifier", e.type),
48
+ r("function", e.function),
49
+ r("identifier", e.variable),
50
+ r("variable", e.variable),
51
+ r("operator", e.operator),
52
+ r("delimiter", e.operator),
53
+ r("tag", e.tag),
54
+ r("attribute.name", e.attribute),
55
+ r("attribute.value", e.string),
56
+ r("key", e.property),
57
+ r("invalid", e.invalid)
57
58
  ],
58
59
  colors: {
59
60
  "editor.background": e.background,
@@ -67,9 +68,9 @@ function y(o = u(), n = "light") {
67
68
  }
68
69
  };
69
70
  }
70
- function b(o = u(), n = "light") {
71
- const e = s(o, n), r = (t, a, i) => ({
72
- scope: t,
71
+ function k(o = u(), n = "light") {
72
+ const e = s(o, n), t = (r, a, i) => ({
73
+ scope: r,
73
74
  settings: {
74
75
  foreground: a,
75
76
  ...i ? { fontStyle: i } : {}
@@ -87,52 +88,52 @@ function b(o = u(), n = "light") {
87
88
  "editorCursor.foreground": e.cursor
88
89
  },
89
90
  tokenColors: [
90
- r(["comment", "punctuation.definition.comment"], e.comment, "italic"),
91
- r([
91
+ t(["comment", "punctuation.definition.comment"], e.comment, "italic"),
92
+ t([
92
93
  "keyword",
93
94
  "storage",
94
95
  "storage.type",
95
96
  "keyword.control"
96
97
  ], e.keyword),
97
- r([
98
+ t([
98
99
  "string",
99
100
  "string.quoted",
100
101
  "string.template"
101
102
  ], e.string),
102
- r([
103
+ t([
103
104
  "constant.numeric",
104
105
  "constant.language",
105
106
  "constant.character"
106
107
  ], e.number),
107
- r([
108
+ t([
108
109
  "entity.name.function",
109
110
  "support.function",
110
111
  "meta.function-call"
111
112
  ], e.function),
112
- r([
113
+ t([
113
114
  "entity.name.type",
114
115
  "support.type",
115
116
  "entity.name.class",
116
117
  "support.class"
117
118
  ], e.type),
118
- r(["variable", "variable.other"], e.variable),
119
- r([
119
+ t(["variable", "variable.other"], e.variable),
120
+ t([
120
121
  "variable.other.property",
121
122
  "support.type.property-name",
122
123
  "meta.object-literal.key"
123
124
  ], e.property),
124
- r(["keyword.operator", "punctuation"], e.operator),
125
- r(["entity.name.tag", "meta.tag"], e.tag),
126
- r(["entity.other.attribute-name"], e.attribute),
127
- r(["string.regexp"], e.regexp),
128
- r(["invalid", "invalid.illegal"], e.invalid)
125
+ t(["keyword.operator", "punctuation"], e.operator),
126
+ t(["entity.name.tag", "meta.tag"], e.tag),
127
+ t(["entity.other.attribute-name"], e.attribute),
128
+ t(["string.regexp"], e.regexp),
129
+ t(["invalid", "invalid.illegal"], e.invalid)
129
130
  ]
130
131
  };
131
132
  }
132
133
  export {
133
134
  s as editorColors,
134
- y as monacoTheme,
135
- b as textMateTheme
135
+ f as monacoTheme,
136
+ k as textMateTheme
136
137
  };
137
138
 
138
139
  //# sourceMappingURL=editor-themes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor-themes.js","names":["mix","createTheme","editorColors","theme","palette","p","bare","hex","isDark","monacoTheme","c","contrast","rule","token","color","fontStyle","textMateTheme","scope","scopes","foreground"],"sources":["../../src/tokens/editor-themes.ts"],"sourcesContent":["/**\n * Code colours for any editor or highlighter, from a Cynosure theme. Editors styled with CSS (CodeMirror 6, Prism,\n * highlight.js, Shiki's css-variables theme) use `styles/syntax.css`, which reads the `--cy-color-syntax-*` tokens and\n * so follows light, dark and contrast by itself. Editors that take a theme object instead (Monaco, Shiki with a\n * TextMate theme, VS Code-style themes) get one built here from resolved colours: build one per palette and switch\n * with the page's mode. Nothing here imports an editor, so Cynosure gains no dependency.\n */\nimport { mix } from \"./color.js\";\nimport { createTheme } from \"./create-theme.js\";\nimport type { ColorTokens, PaletteName, Theme } from \"./schema.js\";\n\n/** Every colour an editor needs, as hex: the syntax roles plus the editor's own surfaces. */\nexport interface EditorColors {\n background: string;\n foreground: string;\n /** Line numbers and the gutter's text. */\n lineNumber: string;\n gutter: string;\n /** The line the cursor is on. */\n activeLine: string;\n selection: string;\n cursor: string;\n comment: string;\n keyword: string;\n string: string;\n number: string;\n function: string;\n type: string;\n variable: string;\n property: string;\n operator: string;\n tag: string;\n attribute: string;\n regexp: string;\n invalid: string;\n}\n\n/** The editor colours of one palette of a theme (by default Cynosure's own theme, light). */\nexport function editorColors(theme: Theme = createTheme(), palette: PaletteName = \"light\"): EditorColors {\n const p: ColorTokens = theme.palettes[palette];\n return {\n background: p.surface,\n foreground: p.ink,\n lineNumber: p.muted,\n gutter: p.surface,\n activeLine: p.soft,\n selection: mix(p.accent, p.surface, 0.22),\n cursor: p.accentText,\n comment: p.syntaxComment,\n keyword: p.syntaxKeyword,\n string: p.syntaxString,\n number: p.syntaxNumber,\n function: p.syntaxFunction,\n type: p.syntaxType,\n variable: p.syntaxVariable,\n property: p.syntaxProperty,\n operator: p.syntaxOperator,\n tag: p.syntaxTag,\n attribute: p.syntaxAttribute,\n regexp: p.syntaxRegexp,\n invalid: p.dangerText,\n };\n}\n\nconst bare = (hex: string) => hex.replace(\"#\", \"\");\nconst isDark = (palette: PaletteName) => palette.startsWith(\"dark\");\n\n/** Monaco's theme shape (`monaco.editor.defineTheme(name, monacoTheme(...))`), written out so Monaco is not imported. */\nexport interface MonacoThemeData {\n base: \"vs\" | \"vs-dark\" | \"hc-light\" | \"hc-black\";\n inherit: boolean;\n rules: { token: string; foreground?: string; fontStyle?: string }[];\n colors: Record<string, string>;\n}\n\n/** A Monaco theme from a Cynosure palette. */\nexport function monacoTheme(theme: Theme = createTheme(), palette: PaletteName = \"light\"): MonacoThemeData {\n const c = editorColors(theme, palette);\n const contrast = palette.endsWith(\"contrast\");\n const rule = (token: string, color: string, fontStyle?: string) => ({\n token,\n foreground: bare(color),\n ...(fontStyle ? { fontStyle } : {}),\n });\n return {\n base: isDark(palette) ? (contrast ? \"hc-black\" : \"vs-dark\") : contrast ? \"hc-light\" : \"vs\",\n inherit: true,\n rules: [\n rule(\"\", c.foreground),\n rule(\"comment\", c.comment, \"italic\"),\n rule(\"keyword\", c.keyword),\n rule(\"string\", c.string),\n rule(\"number\", c.number),\n rule(\"regexp\", c.regexp),\n rule(\"type\", c.type),\n rule(\"type.identifier\", c.type),\n rule(\"function\", c.function),\n rule(\"identifier\", c.variable),\n rule(\"variable\", c.variable),\n rule(\"operator\", c.operator),\n rule(\"delimiter\", c.operator),\n rule(\"tag\", c.tag),\n rule(\"attribute.name\", c.attribute),\n rule(\"attribute.value\", c.string),\n rule(\"key\", c.property),\n rule(\"invalid\", c.invalid),\n ],\n colors: {\n \"editor.background\": c.background,\n \"editor.foreground\": c.foreground,\n \"editorLineNumber.foreground\": c.lineNumber,\n \"editorLineNumber.activeForeground\": c.foreground,\n \"editorGutter.background\": c.gutter,\n \"editor.lineHighlightBackground\": c.activeLine,\n \"editor.selectionBackground\": c.selection,\n \"editorCursor.foreground\": c.cursor,\n },\n };\n}\n\n/** A TextMate theme (the format Shiki and VS Code read) from a Cynosure palette. */\nexport interface TextMateTheme {\n name: string;\n type: \"light\" | \"dark\";\n colors: Record<string, string>;\n tokenColors: { scope: string[]; settings: { foreground?: string; fontStyle?: string } }[];\n}\n\nexport function textMateTheme(theme: Theme = createTheme(), palette: PaletteName = \"light\"): TextMateTheme {\n const c = editorColors(theme, palette);\n const scope = (scopes: string[], foreground: string, fontStyle?: string) => ({\n scope: scopes,\n settings: { foreground, ...(fontStyle ? { fontStyle } : {}) },\n });\n return {\n name: `cynosure-${palette}`,\n type: isDark(palette) ? \"dark\" : \"light\",\n colors: {\n \"editor.background\": c.background,\n \"editor.foreground\": c.foreground,\n \"editorLineNumber.foreground\": c.lineNumber,\n \"editor.lineHighlightBackground\": c.activeLine,\n \"editor.selectionBackground\": c.selection,\n \"editorCursor.foreground\": c.cursor,\n },\n tokenColors: [\n scope([\"comment\", \"punctuation.definition.comment\"], c.comment, \"italic\"),\n scope([\"keyword\", \"storage\", \"storage.type\", \"keyword.control\"], c.keyword),\n scope([\"string\", \"string.quoted\", \"string.template\"], c.string),\n scope([\"constant.numeric\", \"constant.language\", \"constant.character\"], c.number),\n scope([\"entity.name.function\", \"support.function\", \"meta.function-call\"], c.function),\n scope([\"entity.name.type\", \"support.type\", \"entity.name.class\", \"support.class\"], c.type),\n scope([\"variable\", \"variable.other\"], c.variable),\n scope([\"variable.other.property\", \"support.type.property-name\", \"meta.object-literal.key\"], c.property),\n scope([\"keyword.operator\", \"punctuation\"], c.operator),\n scope([\"entity.name.tag\", \"meta.tag\"], c.tag),\n scope([\"entity.other.attribute-name\"], c.attribute),\n scope([\"string.regexp\"], c.regexp),\n scope([\"invalid\", \"invalid.illegal\"], c.invalid),\n ],\n };\n}\n"],"mappings":";;AAsCA,SAAgBE,EAAaC,IAAeF,EAAY,GAAGG,IAAuB,SAAuB;AACvG,QAAMC,IAAiBF,EAAM,SAASC,CAAA;AACtC,SAAO;AAAA,IACL,YAAYC,EAAE;AAAA,IACd,YAAYA,EAAE;AAAA,IACd,YAAYA,EAAE;AAAA,IACd,QAAQA,EAAE;AAAA,IACV,YAAYA,EAAE;AAAA,IACd,WAAWL,EAAIK,EAAE,QAAQA,EAAE,SAAS,IAAI;AAAA,IACxC,QAAQA,EAAE;AAAA,IACV,SAASA,EAAE;AAAA,IACX,SAASA,EAAE;AAAA,IACX,QAAQA,EAAE;AAAA,IACV,QAAQA,EAAE;AAAA,IACV,UAAUA,EAAE;AAAA,IACZ,MAAMA,EAAE;AAAA,IACR,UAAUA,EAAE;AAAA,IACZ,UAAUA,EAAE;AAAA,IACZ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AAA,MAAiB,GAAGP,EAAE,MAAM;AAAA,MAC9DO,EAAM;AAAA,QAAC;AAAA,QAAoB;AAAA,QAAqB;AAAA,MAAoB,GAAGP,EAAE,MAAM;AAAA,MAC/EO,EAAM;AAAA,QAAC;AAAA,QAAwB;AAAA,QAAoB;AAAA,MAAoB,GAAGP,EAAE,QAAQ;AAAA,MACpFO,EAAM;AAAA,QAAC;AAAA,QAAoB;AAAA,QAAgB;AAAA,QAAqB;AAAA,MAAe,GAAGP,EAAE,IAAI;AAAA,MACxFO,EAAM,CAAC,YAAY,gBAAgB,GAAGP,EAAE,QAAQ;AAAA,MAChDO,EAAM;AAAA,QAAC;AAAA,QAA2B;AAAA,QAA8B;AAAA,MAAyB,GAAGP,EAAE,QAAQ;AAAA,MACtGO,EAAM,CAAC,oBAAoB,aAAa,GAAGP,EAAE,QAAQ;AAAA,MACrDO,EAAM,CAAC,mBAAmB,UAAU,GAAGP,EAAE,GAAG;AAAA,MAC5CO,EAAM,CAAC,6BAA6B,GAAGP,EAAE,SAAS;AAAA,MAClDO,EAAM,CAAC,eAAe,GAAGP,EAAE,MAAM;AAAA,MACjCO,EAAM,CAAC,WAAW,iBAAiB,GAAGP,EAAE,OAAO;AAAA,IACjD;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"editor-themes.js","names":["mix","createTheme","resolveColors","editorColors","theme","palette","p","bare","hex","isDark","monacoTheme","c","contrast","rule","token","color","fontStyle","textMateTheme","scope","scopes","foreground"],"sources":["../../src/tokens/editor-themes.ts"],"sourcesContent":["/**\n * Code colours for any editor or highlighter, from a Cynosure theme. Editors styled with CSS (CodeMirror 6, Prism,\n * highlight.js, Shiki's css-variables theme) use `styles/syntax.css`, which reads the `--cy-color-syntax-*` tokens and\n * so follows light, dark and contrast by itself. Editors that take a theme object instead (Monaco, Shiki with a\n * TextMate theme, VS Code-style themes) get one built here from resolved colours: build one per palette and switch\n * with the page's mode. Nothing here imports an editor, so Cynosure gains no dependency.\n */\n\nimport { resolveColors } from \"./chart-themes.js\";\nimport { mix } from \"./color.js\";\nimport { createTheme } from \"./create-theme.js\";\nimport type { PaletteName, Theme, ThemeMode } from \"./schema.js\";\n\n/** Every colour an editor needs, as hex: the syntax roles plus the editor's own surfaces. */\nexport interface EditorColors {\n background: string;\n foreground: string;\n /** Line numbers and the gutter's text. */\n lineNumber: string;\n gutter: string;\n /** The line the cursor is on. */\n activeLine: string;\n selection: string;\n cursor: string;\n comment: string;\n keyword: string;\n string: string;\n number: string;\n function: string;\n type: string;\n variable: string;\n property: string;\n operator: string;\n tag: string;\n attribute: string;\n regexp: string;\n invalid: string;\n}\n\n/** The editor colours of one palette of a theme (by default Cynosure's own theme, light). */\nexport function editorColors(theme: Theme = createTheme(), palette: PaletteName = \"light\"): EditorColors {\n const p = resolveColors(theme, palette);\n return {\n background: p.surface,\n foreground: p.ink,\n lineNumber: p.muted,\n gutter: p.surface,\n activeLine: p.soft,\n selection: mix(p.accent, p.surface, 0.22),\n cursor: p.accentText,\n comment: p.syntaxComment,\n keyword: p.syntaxKeyword,\n string: p.syntaxString,\n number: p.syntaxNumber,\n function: p.syntaxFunction,\n type: p.syntaxType,\n variable: p.syntaxVariable,\n property: p.syntaxProperty,\n operator: p.syntaxOperator,\n tag: p.syntaxTag,\n attribute: p.syntaxAttribute,\n regexp: p.syntaxRegexp,\n invalid: p.dangerText,\n };\n}\n\nconst bare = (hex: string) => hex.replace(\"#\", \"\");\nconst isDark = (palette: PaletteName) => palette.startsWith(\"dark\");\n\n/** Monaco's theme shape (`monaco.editor.defineTheme(name, monacoTheme(...))`), written out so Monaco is not imported. */\nexport interface MonacoThemeData {\n base: \"vs\" | \"vs-dark\" | \"hc-light\" | \"hc-black\";\n inherit: boolean;\n rules: { token: string; foreground?: string; fontStyle?: string }[];\n colors: Record<string, string>;\n}\n\n/** A Monaco theme from a Cynosure palette. */\nexport function monacoTheme(theme: Theme = createTheme(), palette: PaletteName = \"light\"): MonacoThemeData {\n const c = editorColors(theme, palette);\n const contrast = palette.endsWith(\"contrast\");\n const rule = (token: string, color: string, fontStyle?: string) => ({\n token,\n foreground: bare(color),\n ...(fontStyle ? { fontStyle } : {}),\n });\n return {\n base: isDark(palette) ? (contrast ? \"hc-black\" : \"vs-dark\") : contrast ? \"hc-light\" : \"vs\",\n inherit: true,\n rules: [\n rule(\"\", c.foreground),\n rule(\"comment\", c.comment, \"italic\"),\n rule(\"keyword\", c.keyword),\n rule(\"string\", c.string),\n rule(\"number\", c.number),\n rule(\"regexp\", c.regexp),\n rule(\"type\", c.type),\n rule(\"type.identifier\", c.type),\n rule(\"function\", c.function),\n rule(\"identifier\", c.variable),\n rule(\"variable\", c.variable),\n rule(\"operator\", c.operator),\n rule(\"delimiter\", c.operator),\n rule(\"tag\", c.tag),\n rule(\"attribute.name\", c.attribute),\n rule(\"attribute.value\", c.string),\n rule(\"key\", c.property),\n rule(\"invalid\", c.invalid),\n ],\n colors: {\n \"editor.background\": c.background,\n \"editor.foreground\": c.foreground,\n \"editorLineNumber.foreground\": c.lineNumber,\n \"editorLineNumber.activeForeground\": c.foreground,\n \"editorGutter.background\": c.gutter,\n \"editor.lineHighlightBackground\": c.activeLine,\n \"editor.selectionBackground\": c.selection,\n \"editorCursor.foreground\": c.cursor,\n },\n };\n}\n\n/** A TextMate theme (the format Shiki and VS Code read) from a Cynosure palette. */\nexport interface TextMateTheme {\n name: string;\n type: ThemeMode;\n colors: Record<string, string>;\n tokenColors: { scope: string[]; settings: { foreground?: string; fontStyle?: string } }[];\n}\n\nexport function textMateTheme(theme: Theme = createTheme(), palette: PaletteName = \"light\"): TextMateTheme {\n const c = editorColors(theme, palette);\n const scope = (scopes: string[], foreground: string, fontStyle?: string) => ({\n scope: scopes,\n settings: { foreground, ...(fontStyle ? { fontStyle } : {}) },\n });\n return {\n name: `cynosure-${palette}`,\n type: isDark(palette) ? \"dark\" : \"light\",\n colors: {\n \"editor.background\": c.background,\n \"editor.foreground\": c.foreground,\n \"editorLineNumber.foreground\": c.lineNumber,\n \"editor.lineHighlightBackground\": c.activeLine,\n \"editor.selectionBackground\": c.selection,\n \"editorCursor.foreground\": c.cursor,\n },\n tokenColors: [\n scope([\"comment\", \"punctuation.definition.comment\"], c.comment, \"italic\"),\n scope([\"keyword\", \"storage\", \"storage.type\", \"keyword.control\"], c.keyword),\n scope([\"string\", \"string.quoted\", \"string.template\"], c.string),\n scope([\"constant.numeric\", \"constant.language\", \"constant.character\"], c.number),\n scope([\"entity.name.function\", \"support.function\", \"meta.function-call\"], c.function),\n scope([\"entity.name.type\", \"support.type\", \"entity.name.class\", \"support.class\"], c.type),\n scope([\"variable\", \"variable.other\"], c.variable),\n scope([\"variable.other.property\", \"support.type.property-name\", \"meta.object-literal.key\"], c.property),\n scope([\"keyword.operator\", \"punctuation\"], c.operator),\n scope([\"entity.name.tag\", \"meta.tag\"], c.tag),\n scope([\"entity.other.attribute-name\"], c.attribute),\n scope([\"string.regexp\"], c.regexp),\n scope([\"invalid\", \"invalid.illegal\"], c.invalid),\n ],\n };\n}\n"],"mappings":";;;AAwCA,SAAgBG,EAAaC,IAAeH,EAAY,GAAGI,IAAuB,SAAuB;AACvG,QAAMC,IAAIJ,EAAcE,GAAOC,CAAO;AACtC,SAAO;AAAA,IACL,YAAYC,EAAE;AAAA,IACd,YAAYA,EAAE;AAAA,IACd,YAAYA,EAAE;AAAA,IACd,QAAQA,EAAE;AAAA,IACV,YAAYA,EAAE;AAAA,IACd,WAAWN,EAAIM,EAAE,QAAQA,EAAE,SAAS,IAAI;AAAA,IACxC,QAAQA,EAAE;AAAA,IACV,SAASA,EAAE;AAAA,IACX,SAASA,EAAE;AAAA,IACX,QAAQA,EAAE;AAAA,IACV,QAAQA,EAAE;AAAA,IACV,UAAUA,EAAE;AAAA,IACZ,MAAMA,EAAE;AAAA,IACR,UAAUA,EAAE;AAAA,IACZ,UAAUA,EAAE;AAAA,IACZ,UAAUA,EAAE;AAAA,IACZ,KAAKA,EAAE;AAAA,IACP,WAAWA,EAAE;AAAA,IACb,Q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AAAA,QAAqB;AAAA,MAAoB,GAAGP,EAAE,MAAM;AAAA,MAC/EO,EAAM;AAAA,QAAC;AAAA,QAAwB;AAAA,QAAoB;AAAA,MAAoB,GAAGP,EAAE,QAAQ;AAAA,MACpFO,EAAM;AAAA,QAAC;AAAA,QAAoB;AAAA,QAAgB;AAAA,QAAqB;AAAA,MAAe,GAAGP,EAAE,IAAI;AAAA,MACxFO,EAAM,CAAC,YAAY,gBAAgB,GAAGP,EAAE,QAAQ;AAAA,MAChDO,EAAM;AAAA,QAAC;AAAA,QAA2B;AAAA,QAA8B;AAAA,MAAyB,GAAGP,EAAE,QAAQ;AAAA,MACtGO,EAAM,CAAC,oBAAoB,aAAa,GAAGP,EAAE,QAAQ;AAAA,MACrDO,EAAM,CAAC,mBAAmB,UAAU,GAAGP,EAAE,GAAG;AAAA,MAC5CO,EAAM,CAAC,6BAA6B,GAAGP,EAAE,SAAS;AAAA,MAClDO,EAAM,CAAC,eAAe,GAAGP,EAAE,MAAM;AAAA,MACjCO,EAAM,CAAC,WAAW,iBAAiB,GAAGP,EAAE,OAAO;AAAA,IACjD;AAAA,EACF;AACF"}
@@ -1,6 +1,8 @@
1
+ export { resolveColors, type SwiftChartTheme, swiftChartTheme } from "./chart-themes.js";
1
2
  export { CynosureThemeError, contrastRatio } from "./color.js";
2
3
  export { createTheme } from "./create-theme.js";
3
4
  export { DEFAULT_ACCENT } from "./defaults.js";
4
5
  export { type EditorColors, editorColors, type MonacoThemeData, monacoTheme, type TextMateTheme, textMateTheme, } from "./editor-themes.js";
5
- export type { ColorTokens, ComponentTokens, GlobalTokens, MotionTokens, PaletteName, Scale, Size, Theme, ThemeInput, Tone, } from "./schema.js";
6
+ export { createThemeRegistry, defineTheme, type NamedTheme, type ThemeDefinition, type ThemeRegistry, } from "./named-themes.js";
7
+ export type { ColorTokens, ComponentTokens, DenseSize, GlobalTokens, MotionTokens, PaletteName, Scale, Size, Theme, ThemeInput, ThemeMode, Tone, } from "./schema.js";
6
8
  export { DEFAULT_SELECTOR, themeProperties, themeToCss } from "./to-css.js";
@@ -0,0 +1,41 @@
1
+ import type { Theme, ThemeInput, ThemeMode } from "./schema.js";
2
+ /** A theme as plain, serialisable data: what a plugin ships and what an app saves. */
3
+ export interface ThemeDefinition extends ThemeInput {
4
+ /** Stable id: lower-case letters, digits and hyphens, starting with a letter (`midnight`, `acme-dusk`). */
5
+ id: string;
6
+ /** The name people see in a theme picker. */
7
+ name: string;
8
+ }
9
+ /** A checked definition and the theme built from it. */
10
+ export interface NamedTheme {
11
+ /** The definition's id. */
12
+ id: string;
13
+ /** The definition's name. */
14
+ name: string;
15
+ /** `light` or `dark` for a theme fixed to one mode; undefined when it follows the colour mode. */
16
+ mode?: ThemeMode;
17
+ /** The definition as given (serialise it with `JSON.stringify`). */
18
+ definition: ThemeDefinition;
19
+ /** The built theme, for `<CynosureTheme theme>`, `themeToCss` and the editor and chart themes. */
20
+ theme: Theme;
21
+ }
22
+ /**
23
+ * Checks a theme definition (typically JSON from a plugin or from storage) and builds it. Throws CynosureThemeError for
24
+ * an unknown field, a value of the wrong type, an invalid or unsafe value, or text that would not read at 4.5:1.
25
+ */
26
+ export declare function defineTheme(input: unknown): NamedTheme;
27
+ /** The named themes an app offers: its own plus any registered at runtime (plugins). */
28
+ export interface ThemeRegistry {
29
+ /** Checks and adds a theme, replacing (in place) one with the same id. Throws CynosureThemeError for bad input. */
30
+ register(definition: unknown): NamedTheme;
31
+ /** Removes a theme. Returns whether it was registered. */
32
+ unregister(id: string): boolean;
33
+ /** The theme with this id, if registered. */
34
+ get(id: string): NamedTheme | undefined;
35
+ /** Every registered theme, in registration order. The same array until something changes. */
36
+ list(): readonly NamedTheme[];
37
+ /** Calls `listener` after every change; returns the function that stops it. Fits `useSyncExternalStore`. */
38
+ subscribe(listener: () => void): () => void;
39
+ }
40
+ /** A registry of named themes, starting with `initial` (checked like any other registration). */
41
+ export declare function createThemeRegistry(initial?: readonly unknown[]): ThemeRegistry;
@@ -0,0 +1,118 @@
1
+ import { CynosureThemeError as l, contrastRatio as b } from "./color.js";
2
+ import { BASE_GLOBAL as $ } from "./defaults.js";
3
+ import { createTheme as g } from "./create-theme.js";
4
+ var k = /^[a-z][a-z0-9-]*$/;
5
+ function c(e) {
6
+ throw new l(`Cynosure theme ${e}`);
7
+ }
8
+ var d = (e) => typeof e == "object" && e !== null && !Array.isArray(e);
9
+ function a(e, t, o) {
10
+ if (!d(t)) {
11
+ typeof e != typeof t && c(`${o} must be a ${typeof t}.`);
12
+ return;
13
+ }
14
+ d(e) || c(`${o} must be an object.`);
15
+ for (const [n, i] of Object.entries(e))
16
+ Object.hasOwn(t, n) || c(`${o}.${n} is not a Cynosure token.`), a(i, t[n], `${o}.${n}`);
17
+ }
18
+ function u(e, t) {
19
+ d(e) || c(`${t} must be an object.`);
20
+ for (const [o, n] of Object.entries(e)) {
21
+ d(n) || c(`${t}.${o} must be an object.`);
22
+ for (const [i, s] of Object.entries(n)) (i === "seriesColors" ? Array.isArray(s) && s.every((r) => typeof r == "string") : typeof s == "string" || typeof s == "number") || c(`${t}.${o}.${i} must be a string.`);
23
+ }
24
+ }
25
+ var m = () => {
26
+ }, y = {
27
+ id: m,
28
+ name: m,
29
+ mode: m,
30
+ accent: (e, t) => a(e, "", t),
31
+ radius: (e, t) => a(e, 1, t),
32
+ scale: (e, t) => a(e, typeof e == "number" ? 1 : "", t),
33
+ font: (e, t) => a(e, {
34
+ sans: "",
35
+ mono: "",
36
+ display: ""
37
+ }, t),
38
+ motion: (e, t) => a(e, e === "reduced" ? e : $.motion, t),
39
+ tokens: (e, t) => a(e, {
40
+ ...$,
41
+ scale: 1
42
+ }, t),
43
+ palettes: u,
44
+ components: u
45
+ };
46
+ function h(e) {
47
+ if (!d(e)) return c("definitions must be an object.");
48
+ (typeof e.id != "string" || !k.test(e.id)) && c(`id must be lower-case letters, digits and hyphens: got ${JSON.stringify(e.id)}.`), (typeof e.name != "string" || !e.name.trim()) && c(`"${e.id}" needs a name.`);
49
+ for (const [t, o] of Object.entries(e)) {
50
+ const n = Object.hasOwn(y, t) ? y[t] : void 0;
51
+ n ? n(o, `"${e.id}".${t}`) : c(`"${e.id}".${t} is not a theme field.`);
52
+ }
53
+ return e;
54
+ }
55
+ var j = [
56
+ ["ink", "bg"],
57
+ ["ink", "surface"],
58
+ ["ink", "surfaceRaised"],
59
+ ["muted", "surface"],
60
+ ["onAccent", "accent"]
61
+ ];
62
+ function O(e, t) {
63
+ const o = t.mode ? [t.mode, `${t.mode}-contrast`] : [
64
+ "light",
65
+ "dark",
66
+ "light-contrast",
67
+ "dark-contrast"
68
+ ];
69
+ for (const n of o) {
70
+ const i = t.palettes[n];
71
+ for (const [s, r] of j) {
72
+ const f = b(i[s], i[r]);
73
+ f < 4.5 && c(`"${e}", ${n} palette: ${s} reads ${f.toFixed(2)}:1 on ${r}; text needs 4.5:1.`);
74
+ }
75
+ }
76
+ }
77
+ function p(e) {
78
+ const t = h(e), o = g(t);
79
+ O(t.id, o);
80
+ const { id: n, name: i, mode: s } = t;
81
+ return {
82
+ id: n,
83
+ name: i,
84
+ ...s ? { mode: s } : {},
85
+ definition: t,
86
+ theme: o
87
+ };
88
+ }
89
+ function C(e = []) {
90
+ const t = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set();
91
+ let n = [];
92
+ const i = () => {
93
+ n = [...t.values()];
94
+ for (const r of [...o]) r();
95
+ }, s = {
96
+ register(r) {
97
+ const f = p(r);
98
+ return t.set(f.id, f), i(), f;
99
+ },
100
+ unregister(r) {
101
+ const f = t.delete(r);
102
+ return f && i(), f;
103
+ },
104
+ get: (r) => t.get(r),
105
+ list: () => n,
106
+ subscribe(r) {
107
+ return o.add(r), () => o.delete(r);
108
+ }
109
+ };
110
+ for (const r of e) s.register(r);
111
+ return s;
112
+ }
113
+ export {
114
+ C as createThemeRegistry,
115
+ p as defineTheme
116
+ };
117
+
118
+ //# sourceMappingURL=named-themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"named-themes.js","names":["CynosureThemeError","contrastRatio","BASE_GLOBAL","createTheme","ID","fail","message","isObject","v","like","value","base","path","k","mapOfMaps","name","entries","c","skip","FIELDS","checkShape","input","key","check","PAIRS","checkContrast","id","theme","shown","p","text","on","ratio","defineTheme","definition","mode","createThemeRegistry","initial","themes","listeners","list","changed","listener","registry","named","had"],"sources":["../../src/tokens/named-themes.ts"],"sourcesContent":["/**\n * Named themes: a theme a person picks by name (Cynosure, Midnight, a plugin's theme), described as plain JSON so it can\n * be saved, shipped by a plugin and checked at runtime. A definition is a `ThemeInput` plus an id and a name; `mode`\n * fixes it to light or dark so the colour-mode switch does not flip it. Nothing here touches the page: apply a theme with\n * `<CynosureTheme theme={…}>` or `themeToCss`.\n */\nimport { CynosureThemeError, contrastRatio } from \"./color.js\";\nimport { createTheme } from \"./create-theme.js\";\nimport { BASE_GLOBAL } from \"./defaults.js\";\nimport type { PaletteName, Theme, ThemeInput, ThemeMode } from \"./schema.js\";\n\n/** A theme as plain, serialisable data: what a plugin ships and what an app saves. */\nexport interface ThemeDefinition extends ThemeInput {\n /** Stable id: lower-case letters, digits and hyphens, starting with a letter (`midnight`, `acme-dusk`). */\n id: string;\n /** The name people see in a theme picker. */\n name: string;\n}\n\n/** A checked definition and the theme built from it. */\nexport interface NamedTheme {\n /** The definition's id. */\n id: string;\n /** The definition's name. */\n name: string;\n /** `light` or `dark` for a theme fixed to one mode; undefined when it follows the colour mode. */\n mode?: ThemeMode;\n /** The definition as given (serialise it with `JSON.stringify`). */\n definition: ThemeDefinition;\n /** The built theme, for `<CynosureTheme theme>`, `themeToCss` and the editor and chart themes. */\n theme: Theme;\n}\n\nconst ID = /^[a-z][a-z0-9-]*$/;\nfunction fail(message: string): never {\n throw new CynosureThemeError(`Cynosure theme ${message}`);\n}\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n typeof v === \"object\" && v !== null && !Array.isArray(v);\n\n/** Checks `value` has the shape of `base`: the same keys (or fewer) and the same type at every leaf. */\nfunction like(value: unknown, base: unknown, path: string): void {\n if (!isObject(base)) {\n if (typeof value !== typeof base) fail(`${path} must be a ${typeof base}.`);\n return;\n }\n if (!isObject(value)) fail(`${path} must be an object.`);\n for (const [k, v] of Object.entries(value as object)) {\n if (!Object.hasOwn(base, k)) fail(`${path}.${k} is not a Cynosure token.`);\n like(v, base[k], `${path}.${k}`);\n }\n}\n\n/** Checks a map of maps (palettes, components) holds only strings or numbers, and `seriesColors` a list of strings. */\nfunction mapOfMaps(value: unknown, path: string): void {\n if (!isObject(value)) fail(`${path} must be an object.`);\n for (const [name, entries] of Object.entries(value as object)) {\n if (!isObject(entries)) fail(`${path}.${name} must be an object.`);\n for (const [k, v] of Object.entries(entries as object)) {\n const ok =\n k === \"seriesColors\"\n ? Array.isArray(v) && v.every((c) => typeof c === \"string\")\n : typeof v === \"string\" || typeof v === \"number\";\n if (!ok) fail(`${path}.${name}.${k} must be a string.`);\n }\n }\n}\n\nconst skip = () => {};\n/** How each field of a definition is checked (mode, like every value, is checked by createTheme). */\nconst FIELDS: Record<string, (value: unknown, path: string) => void> = {\n id: skip,\n name: skip,\n mode: skip,\n accent: (v, path) => like(v, \"\", path),\n radius: (v, path) => like(v, 1, path),\n scale: (v, path) => like(v, typeof v === \"number\" ? 1 : \"\", path),\n font: (v, path) => like(v, { sans: \"\", mono: \"\", display: \"\" }, path),\n motion: (v, path) => like(v, v === \"reduced\" ? v : BASE_GLOBAL.motion, path),\n tokens: (v, path) => like(v, { ...BASE_GLOBAL, scale: 1 }, path),\n palettes: mapOfMaps,\n components: mapOfMaps,\n};\n\n/** Checks the definition's shape: only known fields, each of the right type. Values are checked by createTheme. */\nfunction checkShape(input: unknown): ThemeDefinition {\n if (!isObject(input)) return fail(\"definitions must be an object.\");\n if (typeof input.id !== \"string\" || !ID.test(input.id))\n fail(`id must be lower-case letters, digits and hyphens: got ${JSON.stringify(input.id)}.`);\n if (typeof input.name !== \"string\" || !input.name.trim()) fail(`\"${input.id}\" needs a name.`);\n for (const [key, value] of Object.entries(input)) {\n const check = Object.hasOwn(FIELDS, key) ? FIELDS[key] : undefined;\n if (!check) fail(`\"${input.id}\".${key} is not a theme field.`);\n else check(value, `\"${input.id}\".${key}`);\n }\n return input as unknown as ThemeDefinition;\n}\n\n/** The text pairs every palette a theme shows must read at 4.5:1. */\nconst PAIRS = [\n [\"ink\", \"bg\"],\n [\"ink\", \"surface\"],\n [\"ink\", \"surfaceRaised\"],\n [\"muted\", \"surface\"],\n [\"onAccent\", \"accent\"],\n] as const;\n\n/** Rejects a theme whose text would not read: the check a plugin theme cannot skip. */\nfunction checkContrast(id: string, theme: Theme): void {\n const shown: PaletteName[] = theme.mode\n ? [theme.mode, `${theme.mode}-contrast`]\n : [\"light\", \"dark\", \"light-contrast\", \"dark-contrast\"];\n for (const name of shown) {\n const p = theme.palettes[name];\n for (const [text, on] of PAIRS) {\n const ratio = contrastRatio(p[text], p[on]);\n if (ratio < 4.5)\n fail(`\"${id}\", ${name} palette: ${text} reads ${ratio.toFixed(2)}:1 on ${on}; text needs 4.5:1.`);\n }\n }\n}\n\n/**\n * Checks a theme definition (typically JSON from a plugin or from storage) and builds it. Throws CynosureThemeError for\n * an unknown field, a value of the wrong type, an invalid or unsafe value, or text that would not read at 4.5:1.\n */\nexport function defineTheme(input: unknown): NamedTheme {\n const definition = checkShape(input);\n const theme = createTheme(definition);\n checkContrast(definition.id, theme);\n const { id, name, mode } = definition;\n return { id, name, ...(mode ? { mode } : {}), definition, theme };\n}\n\n/** The named themes an app offers: its own plus any registered at runtime (plugins). */\nexport interface ThemeRegistry {\n /** Checks and adds a theme, replacing (in place) one with the same id. Throws CynosureThemeError for bad input. */\n register(definition: unknown): NamedTheme;\n /** Removes a theme. Returns whether it was registered. */\n unregister(id: string): boolean;\n /** The theme with this id, if registered. */\n get(id: string): NamedTheme | undefined;\n /** Every registered theme, in registration order. The same array until something changes. */\n list(): readonly NamedTheme[];\n /** Calls `listener` after every change; returns the function that stops it. Fits `useSyncExternalStore`. */\n subscribe(listener: () => void): () => void;\n}\n\n/** A registry of named themes, starting with `initial` (checked like any other registration). */\nexport function createThemeRegistry(initial: readonly unknown[] = []): ThemeRegistry {\n const themes = new Map<string, NamedTheme>();\n const listeners = new Set<() => void>();\n let list: readonly NamedTheme[] = [];\n const changed = () => {\n list = [...themes.values()];\n for (const listener of [...listeners]) listener();\n };\n const registry: ThemeRegistry = {\n register(definition) {\n const named = defineTheme(definition);\n themes.set(named.id, named);\n changed();\n return named;\n },\n unregister(id) {\n const had = themes.delete(id);\n if (had) changed();\n return had;\n },\n get: (id) => themes.get(id),\n list: () => list,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n for (const definition of initial) registry.register(definition);\n return registry;\n}\n"],"mappings":";;;AAiCA,IAAMI,IAAK;AACX,SAASC,EAAKC,GAAwB;AACpC,QAAM,IAAIN,EAAmB,kBAAkBM,CAAA,EAAS;AAC1D;AACA,IAAMC,IAAA,CAAYC,MAChB,OAAOA,KAAM,YAAYA,MAAM,QAAQ,CAAC,MAAM,QAAQA,CAAC;AAGzD,SAASC,EAAKC,GAAgBC,GAAeC,GAAoB;AAC/D,MAAI,CAACL,EAASI,CAAI,GAAG;AACnB,IAAI,OAAOD,KAAU,OAAOC,KAAMN,EAAK,GAAGO,CAAA,cAAkB,OAAOD,CAAA,GAAO;AAC1E;AAAA,EACF;AACA,EAAKJ,EAASG,CAAK,KAAGL,EAAK,GAAGO,CAAA,qBAAyB;AACvD,aAAW,CAACC,GAAGL,CAAA,KAAM,OAAO,QAAQE,CAAe;AACjD,IAAK,OAAO,OAAOC,GAAME,CAAC,KAAGR,EAAK,GAAGO,CAAA,IAAQC,CAAA,2BAA4B,GACzEJ,EAAKD,GAAGG,EAAKE,CAAA,GAAI,GAAGD,CAAA,IAAQC,CAAA,EAAG;AAEnC;AAGA,SAASC,EAAUJ,GAAgBE,GAAoB;AACrD,EAAKL,EAASG,CAAK,KAAGL,EAAK,GAAGO,CAAA,qBAAyB;AACvD,aAAW,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AAad,EAAWC,CAAK,GAC7BM,IAAQxB,EAAY+B,CAAU;AACpC,EAAAT,EAAcS,EAAW,IAAIP,CAAK;AAClC,QAAM,EAAE,IAAAD,GAAI,MAAAX,GAAM,MAAAoB,EAAA,IAASD;AAC3B,SAAO;AAAA,IAAE,IAAAR;AAAA,IAAI,MAAAX;AAAA,IAAM,GAAIoB,IAAO,EAAE,MAAAA,EAAK,IAAI,CAAC;AAAA,IAAI,YAAAD;AAAA,IAAY,OAAAP;AAAA,EAAM;AAClE;AAiBA,SAAgBS,EAAoBC,IAA8B,CAAC,GAAkB;AACnF,QAAMC,IAAS,oBAAI,IAAwB,GACrCC,IAAY,oBAAI,IAAgB;AACtC,MAAIC,IAA8B,CAAC;AACnC,QAAMC,IAAA,MAAgB;AACpB,IAAAD,IAAO,CAAC,GAAGF,EAAO,OAAO,CAAC;AAC1B,eAAWI,KAAY,CAAC,GAAGH,CAAS,EAAG,CAAAG,EAAS;AAAA,EAClD,GACMC,IAA0B;AAAA,IAC9B,SAAST,GAAY;AACnB,YAAMU,IAAQX,EAAYC,CAAU;AACpC,aAAAI,EAAO,IAAIM,EAAM,IAAIA,CAAK,GAC1BH,EAAQ,GACDG;AAAA,IACT;AAAA,IACA,WAAWlB,GAAI;AACb,YAAMmB,IAAMP,EAAO,OAAOZ,CAAE;AAC5B,aAAImB,KAAKJ,EAAQ,GACVI;AAAA,IACT;AAAA,IACA,KAAA,CAAMnB,MAAOY,EAAO,IAAIZ,CAAE;AAAA,IAC1B,MAAA,MAAYc;AAAA,IACZ,UAAUE,GAAU;AAClB,aAAAH,EAAU,IAAIG,CAAQ,GACtB,MAAaH,EAAU,OAAOG,CAAQ;AAAA,IACxC;AAAA,EACF;AACA,aAAWR,KAAcG,EAAS,CAAAM,EAAS,SAAST,CAAU;AAC9D,SAAOS;AACT"}
@@ -1,7 +1,16 @@
1
1
  /** The complete Cynosure token schema. Every visual property of every component resolves to one of these. */
2
2
  export type Size = "sm" | "md" | "lg";
3
+ /**
4
+ * `Size` plus `xs`: about 20px tall, for dense desktop chrome (toolbars, inspectors). Only Button, IconButton, Select,
5
+ * TextField, ProgressBar and SegmentedControl take it; their hit area still reaches 24px (44px on coarse pointers).
6
+ */
7
+ export type DenseSize = "xs" | Size;
3
8
  /** Semantic colour shared by every component prop named `tone`. */
4
9
  export type Tone = "accent" | "neutral" | "danger" | "success" | "warning" | "info";
10
+ /** Every `Tone`, in order: for checking a value and for listing the choices (stories, the scaffold). */
11
+ export declare const TONES: readonly ["accent", "neutral", "danger", "success", "warning", "info"];
12
+ /** A palette's mode: the one a fixed-mode theme keeps, and what a colour mode resolves to. */
13
+ export type ThemeMode = "light" | "dark";
5
14
  export type Scale = "compact" | "comfortable" | "spacious" | number;
6
15
  export type PaletteName = "light" | "dark" | "light-contrast" | "dark-contrast";
7
16
  export interface ColorTokens {
@@ -48,6 +57,12 @@ export interface ColorTokens {
48
57
  syntaxTag: string;
49
58
  syntaxAttribute: string;
50
59
  syntaxRegexp: string;
60
+ /**
61
+ * Data visualisation: eight categorical colours for chart series, the first being the accent. Each reads at least 3:1
62
+ * on the background, surface and raised surface (graphics contrast) and they stay apart from each other. CSS:
63
+ * `--cy-color-series-1` to `--cy-color-series-8`. A palette patch must give all eight.
64
+ */
65
+ seriesColors: string[];
51
66
  }
52
67
  export interface MotionTokens {
53
68
  /** Milliseconds. */
@@ -60,8 +75,9 @@ export interface MotionTokens {
60
75
  /** Lengths are CSS px numbers, already multiplied by `scale`. */
61
76
  export interface GlobalTokens {
62
77
  scale: number;
78
+ /** Control heights: `xs` (dense desktop chrome), `sm`, `md`, `lg`. CSS: `--cy-control-height-<size>`. */
63
79
  control: {
64
- height: Record<Size, number>;
80
+ height: Record<DenseSize, number>;
65
81
  };
66
82
  radius: {
67
83
  factor: number;
@@ -122,6 +138,11 @@ export type DeepPartial<T> = {
122
138
  [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
123
139
  };
124
140
  export interface ThemeInput {
141
+ /**
142
+ * Fixes the theme to one mode: a dark-only theme (Midnight) uses its dark palettes whatever the colour mode, and
143
+ * `CynosureTheme` sets that mode on its wrapper. Omit to follow the colour mode.
144
+ */
145
+ mode?: ThemeMode;
125
146
  /** Any hex, rgb(), hsl() or oklch() colour. */
126
147
  accent?: string;
127
148
  scale?: Scale;
@@ -139,4 +160,6 @@ export interface Theme {
139
160
  global: GlobalTokens;
140
161
  palettes: Record<PaletteName, ColorTokens>;
141
162
  components: Record<string, Record<string, string>>;
163
+ /** Set when the theme is fixed to one mode (`ThemeInput.mode`); its light and dark palettes are then the same. */
164
+ mode?: ThemeMode;
142
165
  }
@@ -0,0 +1,13 @@
1
+ var n = [
2
+ "accent",
3
+ "neutral",
4
+ "danger",
5
+ "success",
6
+ "warning",
7
+ "info"
8
+ ];
9
+ export {
10
+ n as TONES
11
+ };
12
+
13
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","names":["TONES"],"sources":["../../src/tokens/schema.ts"],"sourcesContent":["/** The complete Cynosure token schema. Every visual property of every component resolves to one of these. */\n\nexport type Size = \"sm\" | \"md\" | \"lg\";\n/**\n * `Size` plus `xs`: about 20px tall, for dense desktop chrome (toolbars, inspectors). Only Button, IconButton, Select,\n * TextField, ProgressBar and SegmentedControl take it; their hit area still reaches 24px (44px on coarse pointers).\n */\nexport type DenseSize = \"xs\" | Size;\n/** Semantic colour shared by every component prop named `tone`. */\nexport type Tone = \"accent\" | \"neutral\" | \"danger\" | \"success\" | \"warning\" | \"info\";\n/** Every `Tone`, in order: for checking a value and for listing the choices (stories, the scaffold). */\nexport const TONES = [\n \"accent\",\n \"neutral\",\n \"danger\",\n \"success\",\n \"warning\",\n \"info\",\n] as const satisfies readonly Tone[];\n/** A palette's mode: the one a fixed-mode theme keeps, and what a colour mode resolves to. */\nexport type ThemeMode = \"light\" | \"dark\";\nexport type Scale = \"compact\" | \"comfortable\" | \"spacious\" | number;\nexport type PaletteName = \"light\" | \"dark\" | \"light-contrast\" | \"dark-contrast\";\n\nexport interface ColorTokens {\n bg: string;\n surface: string;\n surfaceRaised: string;\n soft: string;\n ink: string;\n muted: string;\n line: string;\n accent: string;\n accentHover: string;\n accentActive: string;\n accentSoft: string;\n onAccent: string;\n ring: string;\n success: string;\n onSuccess: string;\n warning: string;\n onWarning: string;\n danger: string;\n onDanger: string;\n info: string;\n onInfo: string;\n /** Text versions of each tone, readable (≥ 4.5:1) on the surface and on the tone's soft tint. */\n accentText: string;\n dangerText: string;\n successText: string;\n warningText: string;\n infoText: string;\n /**\n * Code: one colour per syntax role, for code blocks and editors (`docs/code-editors.md`). Each reads at least 4.5:1 on\n * the surface, the soft fill and the background (7:1 in the contrast palettes). Keywords follow the accent.\n */\n syntaxComment: string;\n syntaxKeyword: string;\n syntaxString: string;\n syntaxNumber: string;\n syntaxFunction: string;\n syntaxType: string;\n syntaxVariable: string;\n syntaxProperty: string;\n syntaxOperator: string;\n syntaxTag: string;\n syntaxAttribute: string;\n syntaxRegexp: string;\n /**\n * Data visualisation: eight categorical colours for chart series, the first being the accent. Each reads at least 3:1\n * on the background, surface and raised surface (graphics contrast) and they stay apart from each other. CSS:\n * `--cy-color-series-1` to `--cy-color-series-8`. A palette patch must give all eight.\n */\n seriesColors: string[];\n}\n\nexport interface MotionTokens {\n /** Milliseconds. */\n fast: number;\n base: number;\n slow: number;\n ease: string;\n easeInOut: string;\n}\n\n/** Lengths are CSS px numbers, already multiplied by `scale`. */\nexport interface GlobalTokens {\n scale: number;\n /** Control heights: `xs` (dense desktop chrome), `sm`, `md`, `lg`. CSS: `--cy-control-height-<size>`. */\n control: { height: Record<DenseSize, number> };\n radius: { factor: number; segment: number; sm: number; md: number; lg: number; card: number; full: number };\n space: Record<\"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\" | \"10\", number>;\n font: {\n sans: string;\n mono: string;\n display: string;\n size: Record<\"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\", number>;\n weight: { regular: number; medium: number; bold: number };\n lineHeight: number;\n eyebrow: { size: number; tracking: string };\n };\n border: { width: number; focus: number };\n shadow: { sm: string; md: string; lg: string; lit: string };\n motion: MotionTokens;\n z: { dropdown: number; overlay: number; toast: number; tooltip: number };\n hit: { min: number; coarse: number };\n}\n\n/**\n * Per-component tokens. Each component augments this interface:\n * `declare module \"../../tokens/schema.js\" { interface ComponentTokens { button: ButtonTokens } }`.\n * Values are CSS strings; defaults live in the component's CSS as `var()` fallbacks.\n */\n// biome-ignore lint/suspicious/noEmptyInterface: augmented by components via declaration merging\nexport interface ComponentTokens {}\n\nexport type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K] };\n\nexport interface ThemeInput {\n /**\n * Fixes the theme to one mode: a dark-only theme (Midnight) uses its dark palettes whatever the colour mode, and\n * `CynosureTheme` sets that mode on its wrapper. Omit to follow the colour mode.\n */\n mode?: ThemeMode;\n /** Any hex, rgb(), hsl() or oklch() colour. */\n accent?: string;\n scale?: Scale;\n /** Multiplier on the Facet radius factor (1 = default, 0 = square). */\n radius?: number;\n font?: Partial<Record<\"sans\" | \"mono\" | \"display\", string>>;\n motion?: \"reduced\" | Partial<MotionTokens>;\n tokens?: DeepPartial<GlobalTokens>;\n palettes?: Partial<Record<PaletteName, Partial<ColorTokens>>>;\n components?: { [K in keyof ComponentTokens]?: Partial<ComponentTokens[K]> } & Record<\n string,\n Record<string, string> | undefined\n >;\n}\n\nexport interface Theme {\n global: GlobalTokens;\n palettes: Record<PaletteName, ColorTokens>;\n components: Record<string, Record<string, string>>;\n /** Set when the theme is fixed to one mode (`ThemeInput.mode`); its light and dark palettes are then the same. */\n mode?: ThemeMode;\n}\n"],"mappings":"AAWA,IAAaA,IAAQ;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF"}
@@ -1,47 +1,50 @@
1
- var m = ":where(:root,:host)", n = (t) => t.replace(/[A-Z]/g, (o) => `-${o.toLowerCase()}`), y = /* @__PURE__ */ new Set([
1
+ var f = ":where(:root,:host)", i = (t) => t.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`), k = /* @__PURE__ */ new Set([
2
2
  "motion-fast",
3
3
  "motion-base",
4
4
  "motion-slow"
5
- ]), u = /^(scale|radius-factor|radius-segment|font-weight-|font-line-height|z-)/;
6
- function d(t, o, e) {
7
- for (const [c, s] of Object.entries(t)) {
8
- const a = o ? `${o}-${n(c)}` : n(c);
9
- s && typeof s == "object" ? d(s, a, e) : typeof s == "number" ? e.push([a, y.has(a) ? `${s}ms` : u.test(a) ? `${s}` : `${s}px`]) : e.push([a, String(s)]);
5
+ ]), w = /^(scale|radius-factor|radius-segment|font-weight-|font-line-height|z-)/;
6
+ function m(t, a, o) {
7
+ for (const [r, s] of Object.entries(t)) {
8
+ const e = a ? `${a}-${i(r)}` : i(r);
9
+ s && typeof s == "object" ? m(s, e, o) : typeof s == "number" ? o.push([e, k.has(e) ? `${s}ms` : w.test(e) ? `${s}` : `${s}px`]) : o.push([e, String(s)]);
10
10
  }
11
- return e;
11
+ return o;
12
12
  }
13
- var f = (t) => t.map(([o, e]) => `--cy-${o}:${e}`).join(";");
14
- function p(t, o) {
15
- return Object.keys(t).map((e) => [`color-${n(e)}`, t[e] === o[e] ? t[e] : `light-dark(${t[e]},${o[e]})`]);
13
+ var p = (t) => t.map(([a, o]) => `--cy-${a}:${o}`).join(";"), h = (t, a, o) => [`color-${t}`, a === o ? a : `light-dark(${a},${o})`];
14
+ function $(t, a) {
15
+ return Object.keys(t).flatMap((o) => {
16
+ const r = t[o], s = a[o];
17
+ return Array.isArray(r) ? r.map((e, n) => h(`series-${n + 1}`, e, s[n])) : [h(i(o), r, s)];
18
+ });
16
19
  }
17
- function j(t, o = {}) {
18
- const [e, c] = o.contrast ? [t.palettes["light-contrast"], t.palettes["dark-contrast"]] : [t.palettes.light, t.palettes.dark], s = [
19
- ...d(t.global, "", []),
20
- ...p(e, c),
21
- ...Object.entries(t.components).flatMap(([a, i]) => Object.entries(i).map(([r, $]) => [`${n(a)}-${n(r)}`, $]))
20
+ function O(t, a = {}) {
21
+ const [o, r] = a.contrast ? [t.palettes["light-contrast"], t.palettes["dark-contrast"]] : [t.palettes.light, t.palettes.dark], s = [
22
+ ...m(t.global, "", []),
23
+ ...$(o, r),
24
+ ...Object.entries(t.components).flatMap(([e, n]) => Object.entries(n).map(([d, c]) => [`${i(e)}-${i(d)}`, c]))
22
25
  ];
23
- return Object.fromEntries(s.map(([a, i]) => [`--cy-${a}`, i]));
26
+ return Object.fromEntries(s.map(([e, n]) => [`--cy-${e}`, n]));
24
27
  }
25
- function w(t, o = m) {
26
- const { light: e, dark: c } = t.palettes, s = [
27
- ...d(t.global, "", []),
28
- ...p(e, c),
29
- ...Object.entries(t.components).flatMap(([l, h]) => Object.entries(h).map(([b, g]) => [`${n(l)}-${n(b)}`, g]))
30
- ], a = f(p(t.palettes["light-contrast"], t.palettes["dark-contrast"])), i = o.includes(",") ? `:is(${o})` : o, r = (l) => o === ":where(:root,:host)" ? `:where(${l})` : `${i}${l}`, $ = o === m;
28
+ function v(t, a = f) {
29
+ const { light: o, dark: r } = t.palettes, s = [
30
+ ...m(t.global, "", []),
31
+ ...$(o, r),
32
+ ...Object.entries(t.components).flatMap(([l, g]) => Object.entries(g).map(([u, j]) => [`${i(l)}-${i(u)}`, j]))
33
+ ], e = p($(t.palettes["light-contrast"], t.palettes["dark-contrast"])), n = p($(o, r)), d = a.includes(",") ? `:is(${a})` : a, c = (l) => a === ":where(:root,:host)" ? `:where(${l})` : `${d}${l}`, y = a === f, b = y ? `:where([data-cy-contrast="normal"]){${n}}` : `${c('[data-cy-contrast="system"]')} [data-cy-contrast="normal"]{${n}}`;
31
34
  return [
32
- `${o}{${f(s)}}`,
33
- `${r('[data-cy-mode="light"]')}{color-scheme:light}`,
34
- `${r('[data-cy-mode="dark"]')}{color-scheme:dark}`,
35
- `${r('[data-cy-mode="system"]')}{color-scheme:light dark}`,
36
- `@media (prefers-contrast:more){${$ ? ':where(:root:not([data-cy-contrast]),:host,[data-cy-contrast="system"])' : r('[data-cy-contrast="system"]')}{${a}}}`,
37
- `${r('[data-cy-contrast="more"]')}{${a}}`
35
+ `${a}{${p(s)}}`,
36
+ `${c('[data-cy-mode="light"]')}{color-scheme:light}`,
37
+ `${c('[data-cy-mode="dark"]')}{color-scheme:dark}`,
38
+ `${c('[data-cy-mode="system"]')}{color-scheme:light dark}`,
39
+ `@media (prefers-contrast:more){${y ? ':where(:root:not([data-cy-contrast]),:host,[data-cy-contrast="system"])' : c('[data-cy-contrast="system"]')}{${e}}${b}}`,
40
+ `${c('[data-cy-contrast="more"]')}{${e}}`
38
41
  ].join(`
39
42
  `);
40
43
  }
41
44
  export {
42
- m as DEFAULT_SELECTOR,
43
- j as themeProperties,
44
- w as themeToCss
45
+ f as DEFAULT_SELECTOR,
46
+ O as themeProperties,
47
+ v as themeToCss
45
48
  };
46
49
 
47
50
  //# sourceMappingURL=to-css.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-css.js","names":["DEFAULT_SELECTOR","kebab","s","c","MS","UNITLESS","flatten","obj","prefix","out","k","v","name","decl","pairs","colorPairs","a","b","themeProperties","theme","options","t","themeToCss","selector","light","dark","base","contrast","host","scoped","attr","isDefault"],"sources":["../../src/tokens/to-css.ts"],"sourcesContent":["import type { ColorTokens, Theme } from \"./schema.js\";\n\n/** Tokens live on the document root and shadow hosts only, so nested theme wrappers inherit from their ancestors. */\nexport const DEFAULT_SELECTOR = \":where(:root,:host)\";\n\nconst kebab = (s: string) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\nconst MS = new Set([\"motion-fast\", \"motion-base\", \"motion-slow\"]);\nconst UNITLESS = /^(scale|radius-factor|radius-segment|font-weight-|font-line-height|z-)/;\n\nfunction flatten(obj: object, prefix: string, out: [string, string][]): [string, string][] {\n for (const [k, v] of Object.entries(obj)) {\n const name = prefix ? `${prefix}-${kebab(k)}` : kebab(k);\n if (v && typeof v === \"object\") flatten(v, name, out);\n else if (typeof v === \"number\")\n out.push([name, MS.has(name) ? `${v}ms` : UNITLESS.test(name) ? `${v}` : `${v}px`]);\n else out.push([name, String(v)]);\n }\n return out;\n}\n\nconst decl = (pairs: [string, string][]) => pairs.map(([k, v]) => `--cy-${k}:${v}`).join(\";\");\n\nfunction colorPairs(a: ColorTokens, b: ColorTokens): [string, string][] {\n return (Object.keys(a) as (keyof ColorTokens)[]).map((k) => [\n `color-${kebab(k)}`,\n a[k] === b[k] ? a[k] : `light-dark(${a[k]},${b[k]})`,\n ]);\n}\n\n/**\n * The theme as custom-property pairs (`--cy-*` → value), for applying on an element.\n * `contrast: true` swaps in the high-contrast palettes.\n */\nexport function themeProperties(theme: Theme, options: { contrast?: boolean } = {}): Record<string, string> {\n const [a, b] = options.contrast\n ? [theme.palettes[\"light-contrast\"], theme.palettes[\"dark-contrast\"]]\n : [theme.palettes.light, theme.palettes.dark];\n const pairs: [string, string][] = [\n ...flatten(theme.global, \"\", []),\n ...colorPairs(a, b),\n ...Object.entries(theme.components).flatMap(([c, t]) =>\n Object.entries(t).map(([k, v]) => [`${kebab(c)}-${kebab(k)}`, v] as [string, string]),\n ),\n ];\n return Object.fromEntries(pairs.map(([k, v]) => [`--cy-${k}`, v]));\n}\n\n/**\n * Serialises a theme to CSS. The base block holds global, component and light/dark colour tokens\n * (via light-dark()); modes switch through `color-scheme`, contrast through an override block.\n */\nexport function themeToCss(theme: Theme, selector: string = DEFAULT_SELECTOR): string {\n const { light, dark } = theme.palettes;\n const base = [\n ...flatten(theme.global, \"\", []),\n ...colorPairs(light, dark),\n ...Object.entries(theme.components).flatMap(([c, t]) =>\n Object.entries(t).map(([k, v]) => [`${kebab(c)}-${kebab(k)}`, v] as [string, string]),\n ),\n ];\n const contrast = decl(colorPairs(theme.palettes[\"light-contrast\"], theme.palettes[\"dark-contrast\"]));\n // Selector lists are wrapped in :is() so attribute qualifiers apply to every selector in the list.\n const host = selector.includes(\",\") ? `:is(${selector})` : selector;\n const scoped = (attr: string) => (selector === DEFAULT_SELECTOR ? `:where(${attr})` : `${host}${attr}`);\n const isDefault = selector === DEFAULT_SELECTOR;\n return [\n `${selector}{${decl(base)}}`,\n `${scoped('[data-cy-mode=\"light\"]')}{color-scheme:light}`,\n `${scoped('[data-cy-mode=\"dark\"]')}{color-scheme:dark}`,\n `${scoped('[data-cy-mode=\"system\"]')}{color-scheme:light dark}`,\n `@media (prefers-contrast:more){${isDefault ? ':where(:root:not([data-cy-contrast]),:host,[data-cy-contrast=\"system\"])' : scoped('[data-cy-contrast=\"system\"]')}{${contrast}}}`,\n `${scoped('[data-cy-contrast=\"more\"]')}{${contrast}}`,\n ].join(\"\\n\");\n}\n"],"mappings":"AAGA,IAAaA,IAAmB,uBAE1BC,IAAA,CAASC,MAAcA,EAAE,QAAQ,UAAA,CAAWC,MAAM,IAAIA,EAAE,YAAY,CAAA,EAAG,GACvEC,IAAK,oBAAI,IAAI;AAAA,EAAC;AAAA,EAAe;AAAA,EAAe;AAAa,CAAC,GAC1DC,IAAW;AAEjB,SAASC,EAAQC,GAAaC,GAAgBC,GAA6C;AACzF,aAAW,CAACC,GAAGC,CAAA,KAAM,OAAO,QAAQJ,CAAG,GAAG;AACxC,UAAMK,IAAOJ,IAAS,GAAGA,CAAA,IAAUP,EAAMS,CAAC,CAAA,KAAMT,EAAMS,CAAC;AACvD,IAAIC,KAAK,OAAOA,KAAM,WAAUL,EAAQK,GAAGC,GAAMH,CAAG,IAC3C,OAAOE,KAAM,WACpBF,EAAI,KAAK,CAACG,GAAMR,EAAG,IAAIQ,CAAI,IAAI,GAAGD,CAAA,OAAQN,EAAS,KAAKO,CAAI,IAAI,GAAGD,CAAA,KAAM,GAAGA,CAAA,IAAK,CAAC,IAC/EF,EAAI,KAAK,CAACG,GAAM,OAAOD,CAAC,CAAC,CAAC;AAAA,EACjC;AACA,SAAOF;AACT;AAEA,IAAMI,IAAA,CAAQC,MAA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C;AAAA,IAC/B,GAAGJ,EAAWS,GAAOC,CAAI;AAAA,IACzB,GAAG,OAAO,QAAQN,EAAM,UAAU,EAAE,QAAA,CAAS,CAAChB,GAAGkB,CAAA,MAC/C,OAAO,QAAQA,CAAC,EAAE,IAAA,CAAK,CAACX,GAAGC,CAAA,MAAO,CAAC,GAAGV,EAAME,CAAC,CAAA,IAAKF,EAAMS,CAAC,CAAA,IAAKC,CAAC,CAAqB,CACtF;AAAA,EACF,GACMgB,IAAWd,EAAKE,EAAWI,EAAM,SAAS,gBAAA,GAAmBA,EAAM,SAAS,eAAA,CAAgB,CAAC,GAE7FS,IAAOL,EAAS,SAAS,GAAG,IAAI,OAAOA,CAAA,MAAcA,GACrDM,IAAA,CAAUC,MAAkBP,MAAA,wBAAgC,UAAUO,CAAA,MAAU,GAAGF,CAAA,GAAOE,CAAA,IAC1FC,IAAYR,MAAavB;AAC/B,SAAO;AAAA,IACL,GAAGuB,CAAA,IAAYV,EAAKa,CAAI,CAAA;AAAA,IACxB,GAAGG,EAAO,wBAAwB,CAAA;AAAA,IAClC,GAAGA,EAAO,uBAAuB,CAAA;AAAA,IACjC,GAAGA,EAAO,yBAAyB,CAAA;AAAA,IACnC,kCAAkCE,IAAY,4EAA4EF,EAAO,6BAA6B,CAAA,IAAKF,CAAA;AAAA,IACnK,GAAGE,EAAO,2BAA2B,CAAA,IAAKF,CAAA;AAAA,EAC5C,EAAE,KAAK;AAAA,CAAI;AACb"}
1
+ {"version":3,"file":"to-css.js","names":["DEFAULT_SELECTOR","kebab","s","c","MS","UNITLESS","flatten","obj","prefix","out","k","v","name","decl","pairs","pair","x","y","colorPairs","a","b","i","themeProperties","theme","options","t","themeToCss","selector","light","dark","base","contrast","normal","host","scoped","attr","isDefault","undo"],"sources":["../../src/tokens/to-css.ts"],"sourcesContent":["import type { ColorTokens, Theme } from \"./schema.js\";\n\n/** Tokens live on the document root and shadow hosts only, so nested theme wrappers inherit from their ancestors. */\nexport const DEFAULT_SELECTOR = \":where(:root,:host)\";\n\nconst kebab = (s: string) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);\nconst MS = new Set([\"motion-fast\", \"motion-base\", \"motion-slow\"]);\nconst UNITLESS = /^(scale|radius-factor|radius-segment|font-weight-|font-line-height|z-)/;\n\nfunction flatten(obj: object, prefix: string, out: [string, string][]): [string, string][] {\n for (const [k, v] of Object.entries(obj)) {\n const name = prefix ? `${prefix}-${kebab(k)}` : kebab(k);\n if (v && typeof v === \"object\") flatten(v, name, out);\n else if (typeof v === \"number\")\n out.push([name, MS.has(name) ? `${v}ms` : UNITLESS.test(name) ? `${v}` : `${v}px`]);\n else out.push([name, String(v)]);\n }\n return out;\n}\n\nconst decl = (pairs: [string, string][]) => pairs.map(([k, v]) => `--cy-${k}:${v}`).join(\";\");\n\nconst pair = (name: string, x: string, y: string): [string, string] => [\n `color-${name}`,\n x === y ? x : `light-dark(${x},${y})`,\n];\n\n/** One property per colour; the series list becomes `--cy-color-series-1` to `-8`. */\nfunction colorPairs(a: ColorTokens, b: ColorTokens): [string, string][] {\n return (Object.keys(a) as (keyof ColorTokens)[]).flatMap((k) => {\n const x = a[k];\n const y = b[k];\n return Array.isArray(x)\n ? x.map((c, i) => pair(`series-${i + 1}`, c, (y as string[])[i] as string))\n : [pair(kebab(k), x, y as string)];\n });\n}\n\n/**\n * The theme as custom-property pairs (`--cy-*` → value), for applying on an element.\n * `contrast: true` swaps in the high-contrast palettes.\n */\nexport function themeProperties(theme: Theme, options: { contrast?: boolean } = {}): Record<string, string> {\n const [a, b] = options.contrast\n ? [theme.palettes[\"light-contrast\"], theme.palettes[\"dark-contrast\"]]\n : [theme.palettes.light, theme.palettes.dark];\n const pairs: [string, string][] = [\n ...flatten(theme.global, \"\", []),\n ...colorPairs(a, b),\n ...Object.entries(theme.components).flatMap(([c, t]) =>\n Object.entries(t).map(([k, v]) => [`${kebab(c)}-${kebab(k)}`, v] as [string, string]),\n ),\n ];\n return Object.fromEntries(pairs.map(([k, v]) => [`--cy-${k}`, v]));\n}\n\n/**\n * Serialises a theme to CSS. The base block holds global, component and light/dark colour tokens\n * (via light-dark()); modes switch through `color-scheme`, contrast through an override block.\n */\nexport function themeToCss(theme: Theme, selector: string = DEFAULT_SELECTOR): string {\n const { light, dark } = theme.palettes;\n const base = [\n ...flatten(theme.global, \"\", []),\n ...colorPairs(light, dark),\n ...Object.entries(theme.components).flatMap(([c, t]) =>\n Object.entries(t).map(([k, v]) => [`${kebab(c)}-${kebab(k)}`, v] as [string, string]),\n ),\n ];\n const contrast = decl(colorPairs(theme.palettes[\"light-contrast\"], theme.palettes[\"dark-contrast\"]));\n const normal = decl(colorPairs(light, dark));\n // Selector lists are wrapped in :is() so attribute qualifiers apply to every selector in the list.\n const host = selector.includes(\",\") ? `:is(${selector})` : selector;\n const scoped = (attr: string) => (selector === DEFAULT_SELECTOR ? `:where(${attr})` : `${host}${attr}`);\n const isDefault = selector === DEFAULT_SELECTOR;\n // On an OS set to more contrast, a wrapper with contrast=\"normal\" (and no theme of its own) puts the normal colours\n // back over the contrast ones it inherits. It comes after the contrast rule, so it wins at equal specificity.\n const undo = isDefault\n ? `:where([data-cy-contrast=\"normal\"]){${normal}}`\n : `${scoped('[data-cy-contrast=\"system\"]')} [data-cy-contrast=\"normal\"]{${normal}}`;\n return [\n `${selector}{${decl(base)}}`,\n `${scoped('[data-cy-mode=\"light\"]')}{color-scheme:light}`,\n `${scoped('[data-cy-mode=\"dark\"]')}{color-scheme:dark}`,\n `${scoped('[data-cy-mode=\"system\"]')}{color-scheme:light dark}`,\n `@media (prefers-contrast:more){${isDefault ? ':where(:root:not([data-cy-contrast]),:host,[data-cy-contrast=\"system\"])' : scoped('[data-cy-contrast=\"system\"]')}{${contrast}}${undo}}`,\n `${scoped('[data-cy-contrast=\"more\"]')}{${contrast}}`,\n ].join(\"\\n\");\n}\n"],"mappings":"AAGA,IAAaA,IAAmB,uBAE1BC,IAAA,CAASC,MAAcA,EAAE,QAAQ,UAAA,CAAWC,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