@panneau/ui 5.0.0-alpha.0 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/README.md +280 -6
  2. package/bin/check-theme.js +5 -0
  3. package/dist/alert/Alert.css +28 -42
  4. package/dist/alert/Alert.d.ts +18 -4
  5. package/dist/alert/Alert.d.ts.map +1 -1
  6. package/dist/alert/Alert.js +4 -3
  7. package/dist/alert/Alert.js.map +1 -1
  8. package/dist/alert/Alert.module.js +14 -16
  9. package/dist/alert/Alert.module.js.map +1 -1
  10. package/dist/alert/tokens.d.ts +3 -0
  11. package/dist/alert/tokens.d.ts.map +1 -0
  12. package/dist/alert/tokens.js +21 -0
  13. package/dist/alert/tokens.js.map +1 -0
  14. package/dist/badge/Badge.css +24 -36
  15. package/dist/badge/Badge.d.ts +18 -3
  16. package/dist/badge/Badge.d.ts.map +1 -1
  17. package/dist/badge/Badge.js +3 -2
  18. package/dist/badge/Badge.js.map +1 -1
  19. package/dist/badge/Badge.module.js +9 -13
  20. package/dist/badge/Badge.module.js.map +1 -1
  21. package/dist/badge/tokens.d.ts +3 -0
  22. package/dist/badge/tokens.d.ts.map +1 -0
  23. package/dist/badge/tokens.js +23 -0
  24. package/dist/badge/tokens.js.map +1 -0
  25. package/dist/button/Button.css +58 -42
  26. package/dist/button/Button.d.ts +30 -3
  27. package/dist/button/Button.d.ts.map +1 -1
  28. package/dist/button/Button.js +27 -2
  29. package/dist/button/Button.js.map +1 -1
  30. package/dist/button/Button.module.js +14 -14
  31. package/dist/button/Button.module.js.map +1 -1
  32. package/dist/button/tokens.d.ts +3 -0
  33. package/dist/button/tokens.d.ts.map +1 -0
  34. package/dist/button/tokens.js +25 -0
  35. package/dist/button/tokens.js.map +1 -0
  36. package/dist/card/Card.css +27 -20
  37. package/dist/card/Card.js +1 -1
  38. package/dist/card/Card.js.map +1 -1
  39. package/dist/card/Card.module.js +5 -5
  40. package/dist/card/Card.module.js.map +1 -1
  41. package/dist/card/tokens.d.ts +3 -0
  42. package/dist/card/tokens.d.ts.map +1 -0
  43. package/dist/card/tokens.js +31 -0
  44. package/dist/card/tokens.js.map +1 -0
  45. package/dist/checkbox/Checkbox.css +22 -21
  46. package/dist/checkbox/Checkbox.d.ts.map +1 -1
  47. package/dist/checkbox/Checkbox.js +1 -0
  48. package/dist/checkbox/Checkbox.js.map +1 -1
  49. package/dist/checkbox/Checkbox.module.js +4 -4
  50. package/dist/checkbox/Checkbox.module.js.map +1 -1
  51. package/dist/checkbox/ChoiceChrome.d.ts +3 -1
  52. package/dist/checkbox/ChoiceChrome.d.ts.map +1 -1
  53. package/dist/checkbox/ChoiceChrome.js +2 -2
  54. package/dist/checkbox/ChoiceChrome.js.map +1 -1
  55. package/dist/checkbox/tokens.d.ts +3 -0
  56. package/dist/checkbox/tokens.d.ts.map +1 -0
  57. package/dist/checkbox/tokens.js +21 -0
  58. package/dist/checkbox/tokens.js.map +1 -0
  59. package/dist/combo-box/ComboBox.css +4 -4
  60. package/dist/combo-box/ComboBox.js +1 -1
  61. package/dist/combo-box/ComboBox.js.map +1 -1
  62. package/dist/combo-box/ComboBox.module.js +3 -3
  63. package/dist/container/Container.css +32 -0
  64. package/dist/container/Container.d.ts +15 -0
  65. package/dist/container/Container.d.ts.map +1 -0
  66. package/dist/container/Container.js +18 -0
  67. package/dist/container/Container.js.map +1 -0
  68. package/dist/container/Container.module.js +20 -0
  69. package/dist/container/Container.module.js.map +1 -0
  70. package/dist/container/tokens.d.ts +3 -0
  71. package/dist/container/tokens.d.ts.map +1 -0
  72. package/dist/container/tokens.js +19 -0
  73. package/dist/container/tokens.js.map +1 -0
  74. package/dist/date-picker/DatePicker.css +30 -30
  75. package/dist/date-picker/DatePicker.js +1 -1
  76. package/dist/date-picker/DatePicker.js.map +1 -1
  77. package/dist/date-picker/DatePicker.module.js +11 -11
  78. package/dist/date-picker/DatePicker.module.js.map +1 -1
  79. package/dist/date-picker/calendarTokens.d.ts +3 -0
  80. package/dist/date-picker/calendarTokens.d.ts.map +1 -0
  81. package/dist/date-picker/calendarTokens.js +17 -0
  82. package/dist/date-picker/calendarTokens.js.map +1 -0
  83. package/dist/dialog/Dialog.css +40 -36
  84. package/dist/dialog/Dialog.js +1 -1
  85. package/dist/dialog/Dialog.js.map +1 -1
  86. package/dist/dialog/Dialog.module.js +11 -11
  87. package/dist/dialog/Dialog.module.js.map +1 -1
  88. package/dist/dialog/tokens.d.ts +3 -0
  89. package/dist/dialog/tokens.d.ts.map +1 -0
  90. package/dist/dialog/tokens.js +29 -0
  91. package/dist/dialog/tokens.js.map +1 -0
  92. package/dist/disclosure/Disclosure.css +12 -12
  93. package/dist/disclosure/Disclosure.d.ts.map +1 -1
  94. package/dist/disclosure/Disclosure.js +1 -1
  95. package/dist/disclosure/Disclosure.js.map +1 -1
  96. package/dist/disclosure/Disclosure.module.js +7 -7
  97. package/dist/disclosure/Disclosure.module.js.map +1 -1
  98. package/dist/disclosure/tokens.d.ts +3 -0
  99. package/dist/disclosure/tokens.d.ts.map +1 -0
  100. package/dist/disclosure/tokens.js +15 -0
  101. package/dist/disclosure/tokens.js.map +1 -0
  102. package/dist/divider/Divider.css +17 -0
  103. package/dist/divider/Divider.d.ts +8 -0
  104. package/dist/divider/Divider.d.ts.map +1 -0
  105. package/dist/divider/Divider.js +21 -0
  106. package/dist/divider/Divider.js.map +1 -0
  107. package/dist/divider/Divider.module.js +12 -0
  108. package/dist/divider/Divider.module.js.map +1 -0
  109. package/dist/divider/tokens.d.ts +3 -0
  110. package/dist/divider/tokens.d.ts.map +1 -0
  111. package/dist/divider/tokens.js +13 -0
  112. package/dist/divider/tokens.js.map +1 -0
  113. package/dist/field/Field.css +40 -37
  114. package/dist/field/Field.module.js +11 -11
  115. package/dist/field/Field.module.js.map +1 -1
  116. package/dist/field/Fieldset.js +1 -1
  117. package/dist/field/Fieldset.js.map +1 -1
  118. package/dist/field/inputTokens.d.ts +3 -0
  119. package/dist/field/inputTokens.d.ts.map +1 -0
  120. package/dist/field/inputTokens.js +21 -0
  121. package/dist/field/inputTokens.js.map +1 -0
  122. package/dist/field/tokens.d.ts +3 -0
  123. package/dist/field/tokens.d.ts.map +1 -0
  124. package/dist/field/tokens.js +15 -0
  125. package/dist/field/tokens.js.map +1 -0
  126. package/dist/grid/Grid.css +174 -0
  127. package/dist/grid/Grid.d.ts +28 -0
  128. package/dist/grid/Grid.d.ts.map +1 -0
  129. package/dist/grid/Grid.js +31 -0
  130. package/dist/grid/Grid.js.map +1 -0
  131. package/dist/grid/Grid.module.js +12 -0
  132. package/dist/grid/Grid.module.js.map +1 -0
  133. package/dist/grid/GridItem.css +59 -0
  134. package/dist/grid/GridItem.module.js +7 -0
  135. package/dist/grid/GridItem.module.js.map +1 -0
  136. package/dist/grid/tokens.d.ts +3 -0
  137. package/dist/grid/tokens.d.ts.map +1 -0
  138. package/dist/grid/tokens.js +10 -0
  139. package/dist/grid/tokens.js.map +1 -0
  140. package/dist/heading/Heading.css +52 -0
  141. package/dist/heading/Heading.d.ts +17 -0
  142. package/dist/heading/Heading.d.ts.map +1 -0
  143. package/dist/heading/Heading.js +17 -0
  144. package/dist/heading/Heading.js.map +1 -0
  145. package/dist/heading/Heading.module.js +16 -0
  146. package/dist/heading/Heading.module.js.map +1 -0
  147. package/dist/heading/tokens.d.ts +6 -0
  148. package/dist/heading/tokens.d.ts.map +1 -0
  149. package/dist/heading/tokens.js +66 -0
  150. package/dist/heading/tokens.js.map +1 -0
  151. package/dist/icon/Icon.css +1 -1
  152. package/dist/icon/Icon.js +1 -1
  153. package/dist/icon/Icon.js.map +1 -1
  154. package/dist/icon/Icon.module.js +1 -1
  155. package/dist/icon/namedIcons.d.ts +16 -0
  156. package/dist/icon/namedIcons.d.ts.map +1 -0
  157. package/dist/icon/namedIcons.js +90 -0
  158. package/dist/icon/namedIcons.js.map +1 -0
  159. package/dist/icon-button/IconButton.css +2 -2
  160. package/dist/icon-button/IconButton.d.ts +1 -1
  161. package/dist/icon-button/IconButton.d.ts.map +1 -1
  162. package/dist/icon-button/IconButton.js +3 -3
  163. package/dist/icon-button/IconButton.js.map +1 -1
  164. package/dist/icon-button/IconButton.module.js +2 -2
  165. package/dist/index.d.ts +26 -5
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js +21 -2
  168. package/dist/inline/Inline.css +142 -0
  169. package/dist/inline/Inline.d.ts +17 -0
  170. package/dist/inline/Inline.d.ts.map +1 -0
  171. package/dist/inline/Inline.js +21 -0
  172. package/dist/inline/Inline.js.map +1 -0
  173. package/dist/inline/Inline.module.js +12 -0
  174. package/dist/inline/Inline.module.js.map +1 -0
  175. package/dist/inline/tokens.d.ts +3 -0
  176. package/dist/inline/tokens.d.ts.map +1 -0
  177. package/dist/inline/tokens.js +10 -0
  178. package/dist/inline/tokens.js.map +1 -0
  179. package/dist/layout/responsive.d.ts +38 -0
  180. package/dist/layout/responsive.d.ts.map +1 -0
  181. package/dist/layout/responsive.js +49 -0
  182. package/dist/layout/responsive.js.map +1 -0
  183. package/dist/menu/Menu.js +2 -2
  184. package/dist/menu/Menu.js.map +1 -1
  185. package/dist/number-input/NumberInput.css +12 -12
  186. package/dist/number-input/NumberInput.js +1 -1
  187. package/dist/number-input/NumberInput.js.map +1 -1
  188. package/dist/number-input/NumberInput.module.js +4 -4
  189. package/dist/number-input/NumberInput.module.js.map +1 -1
  190. package/dist/number-input/tokens.d.ts +3 -0
  191. package/dist/number-input/tokens.d.ts.map +1 -0
  192. package/dist/number-input/tokens.js +10 -0
  193. package/dist/number-input/tokens.js.map +1 -0
  194. package/dist/popover/Popover.css +13 -12
  195. package/dist/popover/Popover.js +2 -2
  196. package/dist/popover/Popover.js.map +1 -1
  197. package/dist/popover/Popover.module.js +3 -3
  198. package/dist/popover/Popover.module.js.map +1 -1
  199. package/dist/popover/tokens.d.ts +3 -0
  200. package/dist/popover/tokens.d.ts.map +1 -0
  201. package/dist/popover/tokens.js +19 -0
  202. package/dist/popover/tokens.js.map +1 -0
  203. package/dist/prose/Prose.css +141 -0
  204. package/dist/prose/Prose.d.ts +11 -0
  205. package/dist/prose/Prose.d.ts.map +1 -0
  206. package/dist/prose/Prose.js +18 -0
  207. package/dist/prose/Prose.js.map +1 -0
  208. package/dist/prose/Prose.module.js +8 -0
  209. package/dist/prose/Prose.module.js.map +1 -0
  210. package/dist/prose/tokens.d.ts +3 -0
  211. package/dist/prose/tokens.d.ts.map +1 -0
  212. package/dist/prose/tokens.js +33 -0
  213. package/dist/prose/tokens.js.map +1 -0
  214. package/dist/radio-group/RadioGroup.css +21 -20
  215. package/dist/radio-group/RadioGroup.d.ts.map +1 -1
  216. package/dist/radio-group/RadioGroup.js +2 -2
  217. package/dist/radio-group/RadioGroup.js.map +1 -1
  218. package/dist/radio-group/RadioGroup.module.js +6 -6
  219. package/dist/radio-group/RadioGroup.module.js.map +1 -1
  220. package/dist/radio-group/tokens.d.ts +3 -0
  221. package/dist/radio-group/tokens.d.ts.map +1 -0
  222. package/dist/radio-group/tokens.js +19 -0
  223. package/dist/radio-group/tokens.js.map +1 -0
  224. package/dist/root/PanneauRoot.css +243 -20
  225. package/dist/root/PanneauRoot.d.ts +28 -4
  226. package/dist/root/PanneauRoot.d.ts.map +1 -1
  227. package/dist/root/PanneauRoot.js +104 -21
  228. package/dist/root/PanneauRoot.js.map +1 -1
  229. package/dist/root/PanneauRoot.module.js +11 -3
  230. package/dist/root/PanneauRoot.module.js.map +1 -1
  231. package/dist/root/ThemeScope.d.ts +24 -0
  232. package/dist/root/ThemeScope.d.ts.map +1 -0
  233. package/dist/root/ThemeScope.js +49 -0
  234. package/dist/root/ThemeScope.js.map +1 -0
  235. package/dist/select/ListBox.css +23 -22
  236. package/dist/select/ListBox.module.js +12 -12
  237. package/dist/select/ListBox.module.js.map +1 -1
  238. package/dist/select/Select.js +1 -1
  239. package/dist/select/Select.js.map +1 -1
  240. package/dist/select/listBoxTokens.d.ts +3 -0
  241. package/dist/select/listBoxTokens.d.ts.map +1 -0
  242. package/dist/select/listBoxTokens.js +19 -0
  243. package/dist/select/listBoxTokens.js.map +1 -0
  244. package/dist/spinner/Spinner.css +8 -8
  245. package/dist/spinner/Spinner.js +1 -1
  246. package/dist/spinner/Spinner.js.map +1 -1
  247. package/dist/spinner/Spinner.module.js +5 -5
  248. package/dist/spinner/Spinner.module.js.map +1 -1
  249. package/dist/spinner/tokens.d.ts +3 -0
  250. package/dist/spinner/tokens.d.ts.map +1 -0
  251. package/dist/spinner/tokens.js +10 -0
  252. package/dist/spinner/tokens.js.map +1 -0
  253. package/dist/stack/Stack.css +135 -0
  254. package/dist/stack/Stack.d.ts +15 -0
  255. package/dist/stack/Stack.d.ts.map +1 -0
  256. package/dist/stack/Stack.js +21 -0
  257. package/dist/stack/Stack.js.map +1 -0
  258. package/dist/stack/Stack.module.js +8 -0
  259. package/dist/stack/Stack.module.js.map +1 -0
  260. package/dist/stack/tokens.d.ts +3 -0
  261. package/dist/stack/tokens.d.ts.map +1 -0
  262. package/dist/stack/tokens.js +10 -0
  263. package/dist/stack/tokens.js.map +1 -0
  264. package/dist/switch/Switch.css +34 -25
  265. package/dist/switch/Switch.d.ts.map +1 -1
  266. package/dist/switch/Switch.js +1 -0
  267. package/dist/switch/Switch.js.map +1 -1
  268. package/dist/switch/Switch.module.js +4 -4
  269. package/dist/switch/Switch.module.js.map +1 -1
  270. package/dist/switch/tokens.d.ts +3 -0
  271. package/dist/switch/tokens.d.ts.map +1 -0
  272. package/dist/switch/tokens.js +25 -0
  273. package/dist/switch/tokens.js.map +1 -0
  274. package/dist/tabs/Tabs.css +24 -23
  275. package/dist/tabs/Tabs.js +4 -4
  276. package/dist/tabs/Tabs.js.map +1 -1
  277. package/dist/tabs/Tabs.module.js +4 -4
  278. package/dist/tabs/Tabs.module.js.map +1 -1
  279. package/dist/tabs/tokens.d.ts +3 -0
  280. package/dist/tabs/tokens.d.ts.map +1 -0
  281. package/dist/tabs/tokens.js +25 -0
  282. package/dist/tabs/tokens.js.map +1 -0
  283. package/dist/text/Text.css +74 -0
  284. package/dist/text/Text.d.ts +27 -0
  285. package/dist/text/Text.d.ts.map +1 -0
  286. package/dist/text/Text.js +16 -0
  287. package/dist/text/Text.js.map +1 -0
  288. package/dist/text/Text.module.js +30 -0
  289. package/dist/text/Text.module.js.map +1 -0
  290. package/dist/text/tokens.d.ts +3 -0
  291. package/dist/text/tokens.d.ts.map +1 -0
  292. package/dist/text/tokens.js +10 -0
  293. package/dist/text/tokens.js.map +1 -0
  294. package/dist/text-area/TextArea.css +1 -1
  295. package/dist/text-area/TextArea.js +1 -1
  296. package/dist/text-area/TextArea.js.map +1 -1
  297. package/dist/text-area/TextArea.module.js +1 -1
  298. package/dist/text-input/TextInput.js +1 -1
  299. package/dist/text-input/TextInput.js.map +1 -1
  300. package/dist/theme/Tone.css +70 -0
  301. package/dist/theme/Tone.module.js +20 -0
  302. package/dist/theme/Tone.module.js.map +1 -0
  303. package/dist/theme/bootstrap.d.ts +10 -0
  304. package/dist/theme/bootstrap.d.ts.map +1 -1
  305. package/dist/theme/bootstrap.js +48 -5
  306. package/dist/theme/bootstrap.js.map +1 -1
  307. package/dist/theme/chartColors.d.ts +23 -0
  308. package/dist/theme/chartColors.d.ts.map +1 -0
  309. package/dist/theme/chartColors.js +27 -0
  310. package/dist/theme/chartColors.js.map +1 -0
  311. package/dist/theme/checkTheme.d.ts +39 -0
  312. package/dist/theme/checkTheme.d.ts.map +1 -0
  313. package/dist/theme/checkTheme.js +132 -0
  314. package/dist/theme/checkTheme.js.map +1 -0
  315. package/dist/theme/cli.d.ts +14 -0
  316. package/dist/theme/cli.d.ts.map +1 -0
  317. package/dist/theme/cli.js +61 -0
  318. package/dist/theme/cli.js.map +1 -0
  319. package/dist/theme/color.d.ts +30 -0
  320. package/dist/theme/color.d.ts.map +1 -0
  321. package/dist/theme/color.js +94 -0
  322. package/dist/theme/color.js.map +1 -0
  323. package/dist/theme/colorVision.d.ts +23 -0
  324. package/dist/theme/colorVision.d.ts.map +1 -0
  325. package/dist/theme/colorVision.js +140 -0
  326. package/dist/theme/colorVision.js.map +1 -0
  327. package/dist/theme/componentTokens.d.ts +24 -0
  328. package/dist/theme/componentTokens.d.ts.map +1 -0
  329. package/dist/theme/componentTokens.js +20 -0
  330. package/dist/theme/componentTokens.js.map +1 -0
  331. package/dist/theme/components.d.ts +38 -0
  332. package/dist/theme/components.d.ts.map +1 -0
  333. package/dist/theme/components.js +65 -0
  334. package/dist/theme/components.js.map +1 -0
  335. package/dist/theme/defineTheme.d.ts +85 -0
  336. package/dist/theme/defineTheme.d.ts.map +1 -0
  337. package/dist/theme/defineTheme.js +130 -0
  338. package/dist/theme/defineTheme.js.map +1 -0
  339. package/dist/theme/fonts.d.ts +32 -0
  340. package/dist/theme/fonts.d.ts.map +1 -0
  341. package/dist/theme/fonts.js +36 -0
  342. package/dist/theme/fonts.js.map +1 -0
  343. package/dist/theme/index.d.ts +13 -0
  344. package/dist/theme/index.d.ts.map +1 -0
  345. package/dist/theme/index.js +10 -0
  346. package/dist/theme/semanticTokens.d.ts +9 -0
  347. package/dist/theme/semanticTokens.d.ts.map +1 -0
  348. package/dist/theme/semanticTokens.js +110 -0
  349. package/dist/theme/semanticTokens.js.map +1 -0
  350. package/dist/theme/theme.d.ts +61 -7
  351. package/dist/theme/theme.d.ts.map +1 -1
  352. package/dist/theme/theme.js +100 -10
  353. package/dist/theme/theme.js.map +1 -1
  354. package/dist/theme/toneClass.d.ts +8 -0
  355. package/dist/theme/toneClass.d.ts.map +1 -0
  356. package/dist/theme/toneClass.js +15 -0
  357. package/dist/theme/toneClass.js.map +1 -0
  358. package/dist/theme/tones.d.ts +89 -0
  359. package/dist/theme/tones.d.ts.map +1 -0
  360. package/dist/theme/tones.js +127 -0
  361. package/dist/theme/tones.js.map +1 -0
  362. package/dist/time-input/TimeInput.js +1 -1
  363. package/dist/time-input/TimeInput.js.map +1 -1
  364. package/dist/toast/Toast.css +22 -44
  365. package/dist/toast/Toast.d.ts +5 -3
  366. package/dist/toast/Toast.d.ts.map +1 -1
  367. package/dist/toast/Toast.js +4 -3
  368. package/dist/toast/Toast.js.map +1 -1
  369. package/dist/toast/Toast.module.js +10 -16
  370. package/dist/toast/Toast.module.js.map +1 -1
  371. package/dist/toast/tokens.d.ts +3 -0
  372. package/dist/toast/tokens.d.ts.map +1 -0
  373. package/dist/toast/tokens.js +21 -0
  374. package/dist/toast/tokens.js.map +1 -0
  375. package/dist/tooltip/Tooltip.css +12 -11
  376. package/dist/tooltip/Tooltip.js +1 -1
  377. package/dist/tooltip/Tooltip.js.map +1 -1
  378. package/dist/tooltip/Tooltip.module.js +2 -2
  379. package/dist/tooltip/Tooltip.module.js.map +1 -1
  380. package/dist/tooltip/tokens.d.ts +3 -0
  381. package/dist/tooltip/tokens.d.ts.map +1 -0
  382. package/dist/tooltip/tokens.js +21 -0
  383. package/dist/tooltip/tokens.js.map +1 -0
  384. package/dist/utils/cx.d.ts +1 -1
  385. package/dist/utils/cx.d.ts.map +1 -1
  386. package/dist/utils/cx.js +2 -2
  387. package/dist/utils/cx.js.map +1 -1
  388. package/package.json +15 -3
@@ -0,0 +1,130 @@
1
+ import { componentTokens } from "./components.js";
2
+ import { SEMANTIC_TOKENS } from "./semanticTokens.js";
3
+ //#region src/theme/defineTheme.ts
4
+ function mergeRecords(first, second) {
5
+ return first === void 0 && second === void 0 ? void 0 : {
6
+ ...first,
7
+ ...second
8
+ };
9
+ }
10
+ function mergeComponents(first, second) {
11
+ const components = mergeRecords(first, second);
12
+ if (components === void 0) return;
13
+ return Object.fromEntries(Object.keys(components).map((component) => {
14
+ const before = first?.[component];
15
+ const after = second?.[component];
16
+ const variants = mergeRecords(before?.variants, after?.variants);
17
+ return [component, {
18
+ ...before,
19
+ ...after,
20
+ ...variants !== void 0 && { variants: Object.fromEntries(Object.keys(variants).map((name) => [name, {
21
+ ...before?.variants?.[name],
22
+ ...after?.variants?.[name]
23
+ }])) }
24
+ }];
25
+ }));
26
+ }
27
+ var DENSITIES = [
28
+ "compact",
29
+ "comfortable",
30
+ "touch"
31
+ ];
32
+ function mergeDensities(first, second) {
33
+ if (first === void 0 && second === void 0) return;
34
+ const densities = {
35
+ ...first,
36
+ ...second
37
+ };
38
+ DENSITIES.forEach((density) => {
39
+ if (first?.[density] !== void 0 && second?.[density] !== void 0) densities[density] = {
40
+ ...first[density],
41
+ ...second[density]
42
+ };
43
+ });
44
+ return densities;
45
+ }
46
+ function mergeFonts(first, second) {
47
+ if (first === void 0 && second === void 0) return;
48
+ const fonts = [...first ?? [], ...second ?? []];
49
+ return fonts.filter((font, index) => fonts.findIndex((other) => JSON.stringify(other) === JSON.stringify(font)) === index);
50
+ }
51
+ /**
52
+ * Merges themes, in order: each one overrides the tokens, palette colors, tones and variants of
53
+ * those before it. A token a theme sets in `tokens` but not in `dark` applies to both schemes, so it
54
+ * also replaces the dark value of earlier themes. Variants merge token by token; tones are replaced
55
+ * whole; densities merge token by token; fonts add up. The label is the last one set. Same as `mergeThemes()` of `@panneau/protocol`.
56
+ */
57
+ function mergeThemes(...themes) {
58
+ return themes.reduce((merged, theme) => {
59
+ const tokens = theme.tokens ?? {};
60
+ const dark = mergeRecords(merged.dark !== void 0 ? Object.fromEntries(Object.entries(merged.dark).filter(([name]) => !Object.hasOwn(tokens, name))) : void 0, theme.dark);
61
+ const result = {
62
+ ...merged,
63
+ ...theme,
64
+ label: theme.label ?? merged.label,
65
+ tokens: {
66
+ ...merged.tokens,
67
+ ...tokens
68
+ },
69
+ dark: dark !== void 0 && Object.keys(dark).length > 0 ? dark : void 0,
70
+ palette: mergeRecords(merged.palette, theme.palette),
71
+ tones: mergeRecords(merged.tones, theme.tones),
72
+ components: mergeComponents(merged.components, theme.components),
73
+ densities: mergeDensities(merged.densities, theme.densities),
74
+ fonts: mergeFonts(merged.fonts, theme.fonts)
75
+ };
76
+ return Object.fromEntries(Object.entries(result).filter(([, value]) => value !== void 0));
77
+ }, { tokens: {} });
78
+ }
79
+ /** The first segments of the semantic tokens, and the components: names Panneau owns. */
80
+ var NAMESPACES = [.../* @__PURE__ */ new Set([
81
+ ...SEMANTIC_TOKENS.map((name) => name.split("-")[1]),
82
+ ...Object.keys(componentTokens),
83
+ "tone"
84
+ ])];
85
+ var KNOWN_TOKENS = /* @__PURE__ */ new Set([...SEMANTIC_TOKENS, ...Object.values(componentTokens).flatMap((tokens) => Object.keys(tokens))]);
86
+ /**
87
+ * Tokens of a theme (in its tokens, dark tokens, densities and variants) that Panneau doesn't know although they are in its namespaces
88
+ * (`panneau-color-*`, `panneau-button-*`…): most likely typos. Tokens of a project's own components
89
+ * are outside these namespaces, and palette colors are always accepted.
90
+ */
91
+ function findUnknownTokens(theme) {
92
+ const names = [
93
+ ...Object.keys(theme.tokens),
94
+ ...Object.keys(theme.dark ?? {}),
95
+ ...Object.values(theme.densities ?? {}).flatMap((tokens) => Object.keys(tokens)),
96
+ ...Object.values(theme.components ?? {}).flatMap(({ variants = {} }) => Object.values(variants).flatMap((tokens) => Object.keys(tokens)))
97
+ ];
98
+ return [...new Set(names.filter((name) => !KNOWN_TOKENS.has(name) && !name.startsWith("panneau-palette-") && NAMESPACES.some((namespace) => name.startsWith(`panneau-${namespace}-`))))];
99
+ }
100
+ /**
101
+ * Declares a theme: TypeScript checks the names of its tokens, and `extends` builds it on other
102
+ * themes (`bootstrapTheme`, a shared brand theme), whose values its own override. It returns a
103
+ * plain `Theme`, which `PanneauRoot`, plugins and JSON files all take. Tokens that Panneau doesn't
104
+ * know in its own namespaces, most likely typos, are reported in the console.
105
+ *
106
+ * ```ts
107
+ * const brand = defineTheme({
108
+ * palette: { orange: '#f25c05' },
109
+ * tokens: { 'panneau-color-accent': 'var(--panneau-palette-orange)' },
110
+ * tones: { signal: 'var(--panneau-palette-orange)' },
111
+ * });
112
+ * const compact = defineTheme({ extends: brand, tokens: { 'panneau-control-height': '2rem' } });
113
+ * ```
114
+ */
115
+ function defineTheme(definition) {
116
+ const { extends: extended = [], ...own } = definition;
117
+ const bases = Array.isArray(extended) ? extended : [extended];
118
+ const ownTheme = {
119
+ ...own,
120
+ tokens: own.tokens ?? {}
121
+ };
122
+ const theme = mergeThemes(...bases, ownTheme);
123
+ const unknown = findUnknownTokens(ownTheme);
124
+ if (unknown.length > 0) console.warn(`[panneau] Unknown tokens in theme${theme.label !== void 0 ? ` "${theme.label}"` : ""}: ${unknown.join(", ")}.`);
125
+ return theme;
126
+ }
127
+ //#endregion
128
+ export { defineTheme, findUnknownTokens, mergeThemes };
129
+
130
+ //# sourceMappingURL=defineTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineTheme.js","names":[],"sources":["../../src/theme/defineTheme.ts"],"sourcesContent":["import { type ComponentTokenName, componentTokens } from './components';\nimport type { ThemeFont } from './fonts';\nimport { SEMANTIC_TOKENS, type SemanticTokenName } from './semanticTokens';\nimport type { Density, Theme } from './theme';\nimport type { ToneInput } from './tones';\n\n/**\n * Tokens that a project adds, such as those of its own components: declare them here so that\n * `defineTheme()` accepts them.\n *\n * ```ts\n * declare module '@panneau/ui' {\n * interface PanneauTokens {\n * 'panneau-map-marker-color': true;\n * }\n * }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- extended by projects\nexport interface PanneauTokens {}\n\n/** The variable of a palette color: `panneau-palette-orange`. */\nexport type PaletteTokenName = `panneau-palette-${string}`;\n\n/**\n * The name of a token a theme can set, without the leading `--`: a semantic token, a component\n * token, a palette color, or a token declared in `PanneauTokens`.\n */\nexport type TokenName =\n SemanticTokenName | ComponentTokenName | PaletteTokenName | (keyof PanneauTokens & string);\n\n/** Values of tokens, keyed by their name: only known names type-check. */\nexport type ThemeTokens = {\n [Name in SemanticTokenName | ComponentTokenName | (keyof PanneauTokens & string)]?: string;\n} & { [Name in PaletteTokenName]?: string };\n\n/** A theme as `defineTheme()` takes it: like `Theme`, with typed tokens and `extends`. */\nexport interface ThemeDefinition {\n /** A name for theme pickers. */\n label?: string;\n /** Themes this one builds on, in order: its own values override theirs. */\n extends?: Theme | readonly Theme[];\n /** Tokens of the light scheme, or of both schemes when `dark` does not set them. */\n tokens?: ThemeTokens;\n /** Tokens that change in the dark scheme. */\n dark?: ThemeTokens;\n /** Raw colors, used with `var(--panneau-palette-<name>)`. */\n palette?: Record<string, string>;\n /** Tones added or redefined by the theme. Declare added tones in `PanneauTones`. */\n tones?: Record<string, ToneInput>;\n /** Named variants of components. Declare them in `BadgeVariants` (and the like). */\n components?: Record<string, { variants?: Record<string, ThemeTokens> }>;\n /** Tokens of each density, which change with the density of the root. */\n densities?: Partial<Record<Exclude<Density, 'auto'>, ThemeTokens>>;\n /** Font faces and font stylesheets. */\n fonts?: ThemeFont[];\n}\n\nfunction mergeRecords<T>(\n first: Readonly<Record<string, T>> | undefined,\n second: Readonly<Record<string, T>> | undefined,\n): Record<string, T> | undefined {\n return first === undefined && second === undefined ? undefined : { ...first, ...second };\n}\n\nfunction mergeComponents(\n first: Theme['components'],\n second: Theme['components'],\n): Theme['components'] {\n const components = mergeRecords(first, second);\n if (components === undefined) {\n return undefined;\n }\n return Object.fromEntries(\n Object.keys(components).map((component) => {\n const before = first?.[component];\n const after = second?.[component];\n const variants = mergeRecords(before?.variants, after?.variants);\n return [\n component,\n {\n ...before,\n ...after,\n ...(variants !== undefined && {\n variants: Object.fromEntries(\n Object.keys(variants).map((name) => [\n name,\n { ...before?.variants?.[name], ...after?.variants?.[name] },\n ]),\n ),\n }),\n },\n ];\n }),\n );\n}\n\nconst DENSITIES = ['compact', 'comfortable', 'touch'] as const;\n\nfunction mergeDensities(first: Theme['densities'], second: Theme['densities']): Theme['densities'] {\n if (first === undefined && second === undefined) {\n return undefined;\n }\n const densities = { ...first, ...second };\n DENSITIES.forEach((density) => {\n if (first?.[density] !== undefined && second?.[density] !== undefined) {\n densities[density] = { ...first[density], ...second[density] };\n }\n });\n return densities;\n}\n\nfunction mergeFonts(first: Theme['fonts'], second: Theme['fonts']): Theme['fonts'] {\n if (first === undefined && second === undefined) {\n return undefined;\n }\n const fonts = [...(first ?? []), ...(second ?? [])];\n return fonts.filter(\n (font, index) =>\n fonts.findIndex((other) => JSON.stringify(other) === JSON.stringify(font)) === index,\n );\n}\n\n/**\n * Merges themes, in order: each one overrides the tokens, palette colors, tones and variants of\n * those before it. A token a theme sets in `tokens` but not in `dark` applies to both schemes, so it\n * also replaces the dark value of earlier themes. Variants merge token by token; tones are replaced\n * whole; densities merge token by token; fonts add up. The label is the last one set. Same as `mergeThemes()` of `@panneau/protocol`.\n */\nexport function mergeThemes(...themes: readonly Partial<Theme>[]): Theme {\n return themes.reduce<Theme>(\n (merged, theme) => {\n const tokens = theme.tokens ?? {};\n const dark = mergeRecords(\n merged.dark !== undefined\n ? Object.fromEntries(\n Object.entries(merged.dark).filter(\n ([name]) => !Object.hasOwn(tokens, name),\n ),\n )\n : undefined,\n theme.dark,\n );\n const result: Theme = {\n ...merged,\n ...theme,\n label: theme.label ?? merged.label,\n tokens: { ...merged.tokens, ...tokens },\n dark: dark !== undefined && Object.keys(dark).length > 0 ? dark : undefined,\n palette: mergeRecords(merged.palette, theme.palette),\n tones: mergeRecords(merged.tones, theme.tones),\n components: mergeComponents(merged.components, theme.components),\n densities: mergeDensities(merged.densities, theme.densities),\n fonts: mergeFonts(merged.fonts, theme.fonts),\n };\n return Object.fromEntries(\n Object.entries(result).filter(([, value]) => value !== undefined),\n ) as unknown as Theme;\n },\n { tokens: {} },\n );\n}\n\n/** The first segments of the semantic tokens, and the components: names Panneau owns. */\nconst NAMESPACES = [\n ...new Set([\n ...SEMANTIC_TOKENS.map((name) => name.split('-')[1]),\n ...Object.keys(componentTokens),\n 'tone',\n ]),\n];\n\nconst KNOWN_TOKENS = new Set<string>([\n ...SEMANTIC_TOKENS,\n ...Object.values(componentTokens).flatMap((tokens) => Object.keys(tokens)),\n]);\n\n/**\n * Tokens of a theme (in its tokens, dark tokens, densities and variants) that Panneau doesn't know although they are in its namespaces\n * (`panneau-color-*`, `panneau-button-*`…): most likely typos. Tokens of a project's own components\n * are outside these namespaces, and palette colors are always accepted.\n */\nexport function findUnknownTokens(theme: Theme): string[] {\n const names = [\n ...Object.keys(theme.tokens),\n ...Object.keys(theme.dark ?? {}),\n ...Object.values(theme.densities ?? {}).flatMap((tokens) => Object.keys(tokens)),\n ...Object.values(theme.components ?? {}).flatMap(({ variants = {} }) =>\n Object.values(variants).flatMap((tokens) => Object.keys(tokens)),\n ),\n ];\n return [\n ...new Set(\n names.filter(\n (name) =>\n !KNOWN_TOKENS.has(name) &&\n !name.startsWith('panneau-palette-') &&\n NAMESPACES.some((namespace) => name.startsWith(`panneau-${namespace}-`)),\n ),\n ),\n ];\n}\n\n/**\n * Declares a theme: TypeScript checks the names of its tokens, and `extends` builds it on other\n * themes (`bootstrapTheme`, a shared brand theme), whose values its own override. It returns a\n * plain `Theme`, which `PanneauRoot`, plugins and JSON files all take. Tokens that Panneau doesn't\n * know in its own namespaces, most likely typos, are reported in the console.\n *\n * ```ts\n * const brand = defineTheme({\n * palette: { orange: '#f25c05' },\n * tokens: { 'panneau-color-accent': 'var(--panneau-palette-orange)' },\n * tones: { signal: 'var(--panneau-palette-orange)' },\n * });\n * const compact = defineTheme({ extends: brand, tokens: { 'panneau-control-height': '2rem' } });\n * ```\n */\nexport function defineTheme(definition: ThemeDefinition): Theme {\n const { extends: extended = [], ...own } = definition;\n const bases: readonly Theme[] = Array.isArray(extended) ? extended : [extended as Theme];\n const ownTheme = { ...own, tokens: own.tokens ?? {} } as Theme;\n const theme = mergeThemes(...bases, ownTheme);\n const unknown = findUnknownTokens(ownTheme);\n if (unknown.length > 0) {\n console.warn(\n `[panneau] Unknown tokens in theme${theme.label !== undefined ? ` \"${theme.label}\"` : ''}: ${unknown.join(', ')}.`,\n );\n }\n return theme;\n}\n"],"mappings":"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"}
@@ -0,0 +1,32 @@
1
+ /** A font face of a theme, written as an `@font-face` rule. */
2
+ export type ThemeFontFace = {
3
+ /** The family name that font tokens use: `'Geist'`. */
4
+ family: string;
5
+ /** The `src` descriptor: `url(/fonts/geist.woff2) format('woff2')`. */
6
+ src: string;
7
+ /** A weight or a range of a variable font: `400`, `400 700`. */
8
+ weight?: string;
9
+ /** `normal` or `italic`. */
10
+ style?: string;
11
+ /** Defaults to `swap`. */
12
+ display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
13
+ unicodeRange?: string;
14
+ };
15
+ /** A hosted stylesheet that declares font faces: Google Fonts, Adobe Fonts, a site's own. */
16
+ export type ThemeFontStylesheet = {
17
+ stylesheet: string;
18
+ };
19
+ /**
20
+ * A font of a theme: a face, or a stylesheet that declares faces. `PanneauRoot` adds them to the
21
+ * page once, however many roots use the theme. Font faces are global by nature, unlike tokens.
22
+ */
23
+ export type ThemeFont = ThemeFontFace | ThemeFontStylesheet;
24
+ /**
25
+ * The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the
26
+ * rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and
27
+ * quotes or backslashes in the family.
28
+ */
29
+ export declare function getFontFaceCss(fonts?: readonly ThemeFont[]): string;
30
+ /** The URLs of the font stylesheets of a theme, without duplicates. */
31
+ export declare function getFontStylesheets(fonts?: readonly ThemeFont[]): string[];
32
+ //# sourceMappingURL=fonts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../src/theme/fonts.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,MAAM,aAAa,GAAG;IACxB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,6FAA6F;AAC7F,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAW5D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,GAAE,SAAS,SAAS,EAAO,GAAG,MAAM,CAsBvE;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,SAAS,SAAS,EAAO,GAAG,MAAM,EAAE,CAU7E"}
@@ -0,0 +1,36 @@
1
+ //#region src/theme/fonts.ts
2
+ /** Values that could break out of an `@font-face` rule, or out of the family name. */
3
+ var UNSAFE = /[{}<]/;
4
+ var UNSAFE_FAMILY = /[{}<;"\\]/;
5
+ var UNSAFE_DESCRIPTOR = /[{}<;]/;
6
+ function isFace(font) {
7
+ return "family" in font && "src" in font;
8
+ }
9
+ /**
10
+ * The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the
11
+ * rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and
12
+ * quotes or backslashes in the family.
13
+ */
14
+ function getFontFaceCss(fonts = []) {
15
+ return fonts.filter(isFace).filter((face) => !UNSAFE_FAMILY.test(face.family) && !UNSAFE.test(face.src) && [
16
+ face.weight,
17
+ face.style,
18
+ face.display,
19
+ face.unicodeRange
20
+ ].every((value) => value === void 0 || !UNSAFE_DESCRIPTOR.test(value))).map((face) => [
21
+ `@font-face{font-family:"${face.family}";src:${face.src};`,
22
+ face.weight !== void 0 ? `font-weight:${face.weight};` : "",
23
+ face.style !== void 0 ? `font-style:${face.style};` : "",
24
+ `font-display:${face.display ?? "swap"};`,
25
+ face.unicodeRange !== void 0 ? `unicode-range:${face.unicodeRange};` : "",
26
+ "}"
27
+ ].join("")).join("");
28
+ }
29
+ /** The URLs of the font stylesheets of a theme, without duplicates. */
30
+ function getFontStylesheets(fonts = []) {
31
+ return [...new Set(fonts.flatMap((font) => "stylesheet" in font && typeof font.stylesheet === "string" ? [font.stylesheet] : []))];
32
+ }
33
+ //#endregion
34
+ export { getFontFaceCss, getFontStylesheets };
35
+
36
+ //# sourceMappingURL=fonts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fonts.js","names":[],"sources":["../../src/theme/fonts.ts"],"sourcesContent":["/** A font face of a theme, written as an `@font-face` rule. */\nexport type ThemeFontFace = {\n /** The family name that font tokens use: `'Geist'`. */\n family: string;\n /** The `src` descriptor: `url(/fonts/geist.woff2) format('woff2')`. */\n src: string;\n /** A weight or a range of a variable font: `400`, `400 700`. */\n weight?: string;\n /** `normal` or `italic`. */\n style?: string;\n /** Defaults to `swap`. */\n display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';\n unicodeRange?: string;\n};\n\n/** A hosted stylesheet that declares font faces: Google Fonts, Adobe Fonts, a site's own. */\nexport type ThemeFontStylesheet = {\n stylesheet: string;\n};\n\n/**\n * A font of a theme: a face, or a stylesheet that declares faces. `PanneauRoot` adds them to the\n * page once, however many roots use the theme. Font faces are global by nature, unlike tokens.\n */\nexport type ThemeFont = ThemeFontFace | ThemeFontStylesheet;\n\n/** Values that could break out of an `@font-face` rule, or out of the family name. */\nconst UNSAFE = /[{}<]/;\nconst UNSAFE_FAMILY = /[{}<;\"\\\\]/;\nconst UNSAFE_DESCRIPTOR = /[{}<;]/;\n\nfunction isFace(font: ThemeFont): font is ThemeFontFace {\n return 'family' in font && 'src' in font;\n}\n\n/**\n * The `@font-face` rules of the fonts of a theme. Faces with a value that could break out of the\n * rule are ignored: `{`, `}` or `<` anywhere, `;` outside of `src` (which can hold data URLs), and\n * quotes or backslashes in the family.\n */\nexport function getFontFaceCss(fonts: readonly ThemeFont[] = []): string {\n return fonts\n .filter(isFace)\n .filter(\n (face) =>\n !UNSAFE_FAMILY.test(face.family) &&\n !UNSAFE.test(face.src) &&\n [face.weight, face.style, face.display, face.unicodeRange].every(\n (value) => value === undefined || !UNSAFE_DESCRIPTOR.test(value),\n ),\n )\n .map((face) =>\n [\n `@font-face{font-family:\"${face.family}\";src:${face.src};`,\n face.weight !== undefined ? `font-weight:${face.weight};` : '',\n face.style !== undefined ? `font-style:${face.style};` : '',\n `font-display:${face.display ?? 'swap'};`,\n face.unicodeRange !== undefined ? `unicode-range:${face.unicodeRange};` : '',\n '}',\n ].join(''),\n )\n .join('');\n}\n\n/** The URLs of the font stylesheets of a theme, without duplicates. */\nexport function getFontStylesheets(fonts: readonly ThemeFont[] = []): string[] {\n return [\n ...new Set(\n fonts.flatMap((font) =>\n 'stylesheet' in font && typeof font.stylesheet === 'string'\n ? [font.stylesheet]\n : [],\n ),\n ),\n ];\n}\n"],"mappings":";;AA2BA,IAAM,SAAS;AACf,IAAM,gBAAgB;AACtB,IAAM,oBAAoB;AAE1B,SAAS,OAAO,MAAwC;CACpD,OAAO,YAAY,QAAQ,SAAS;AACxC;;;;;;AAOA,SAAgB,eAAe,QAA8B,CAAA,GAAY;CACrE,OAAO,MACF,OAAO,MAAM,CAAC,CACd,QACI,SACG,CAAC,cAAc,KAAK,KAAK,MAAM,KAC/B,CAAC,OAAO,KAAK,KAAK,GAAG,KACrB;EAAC,KAAK;EAAQ,KAAK;EAAO,KAAK;EAAS,KAAK;CAAY,CAAC,CAAC,OACtD,UAAU,UAAU,KAAA,KAAa,CAAC,kBAAkB,KAAK,KAAK,CACnE,CACR,CAAC,CACA,KAAK,SACF;EACI,2BAA2B,KAAK,OAAM,QAAS,KAAK,IAAG;EACvD,KAAK,WAAW,KAAA,IAAY,eAAe,KAAK,OAAM,KAAM;EAC5D,KAAK,UAAU,KAAA,IAAY,cAAc,KAAK,MAAK,KAAM;EACzD,gBAAgB,KAAK,WAAW,OAAM;EACtC,KAAK,iBAAiB,KAAA,IAAY,iBAAiB,KAAK,aAAY,KAAM;EAC1E;CAAG,CACN,CAAC,KAAK,EAAE,CACb,CAAC,CACA,KAAK,EAAE;AAChB;;AAGA,SAAgB,mBAAmB,QAA8B,CAAA,GAAc;CAC3E,OAAO,CACH,GAAG,IAAI,IACH,MAAM,SAAS,SACX,gBAAgB,QAAQ,OAAO,KAAK,eAAe,WAC7C,CAAC,KAAK,UAAU,IAChB,CAAA,CACV,CACJ,CAAC;AAET"}
@@ -0,0 +1,13 @@
1
+ export { bootstrapTheme, bootstrapTone } from './bootstrap';
2
+ export { CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, chartColors } from './chartColors';
3
+ export { type ThemeContrastCheck, type ThemeReport, checkTheme } from './checkTheme';
4
+ export { type ColorDifferenceCheck, type ColorVisionDeficiency, checkColorDifferences, } from './colorVision';
5
+ export { type Rgb } from './color';
6
+ export { type ComponentTokens, defineComponentTokens } from './componentTokens';
7
+ export { type ComponentTokenName, componentTokens } from './components';
8
+ export { type PaletteTokenName, type PanneauTokens, type ThemeDefinition, type ThemeTokens, type TokenName, defineTheme, findUnknownTokens, mergeThemes, } from './defineTheme';
9
+ export { type ThemeFont, type ThemeFontFace, type ThemeFontStylesheet } from './fonts';
10
+ export { SEMANTIC_TOKENS, type SemanticTokenName } from './semanticTokens';
11
+ export { type ColorScheme, type Density, type Theme } from './theme';
12
+ export { BUILT_IN_TONES, type PanneauTones, type Tone, type ToneInput, type ToneSurfaces, type ToneValues, deriveTone, toneClassName, } from './tones';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,qBAAqB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,KAAK,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,KAAK,kBAAkB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,WAAW,EACX,iBAAiB,EACjB,WAAW,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EACH,cAAc,EACd,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,UAAU,EACV,aAAa,GAChB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { BUILT_IN_TONES, deriveTone, toneClassName } from "./tones.js";
2
+ import { bootstrapTheme, bootstrapTone } from "./bootstrap.js";
3
+ import { CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, chartColors } from "./chartColors.js";
4
+ import { checkColorDifferences } from "./colorVision.js";
5
+ import { checkTheme } from "./checkTheme.js";
6
+ import { defineComponentTokens } from "./componentTokens.js";
7
+ import { componentTokens } from "./components.js";
8
+ import { SEMANTIC_TOKENS } from "./semanticTokens.js";
9
+ import { defineTheme, findUnknownTokens, mergeThemes } from "./defineTheme.js";
10
+ export { BUILT_IN_TONES, CHART_CATEGORICAL_COUNT, CHART_SEQUENTIAL_COUNT, SEMANTIC_TOKENS, bootstrapTheme, bootstrapTone, chartColors, checkColorDifferences, checkTheme, componentTokens, defineComponentTokens, defineTheme, deriveTone, findUnknownTokens, mergeThemes, toneClassName };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the
3
+ * root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once
4
+ * (decision 0024). A test keeps this list in sync with the stylesheet.
5
+ */
6
+ export declare const SEMANTIC_TOKENS: readonly ["panneau-color-bg", "panneau-color-surface", "panneau-color-surface-sunken", "panneau-color-surface-raised", "panneau-color-hover", "panneau-color-pressed", "panneau-color-backdrop", "panneau-color-text", "panneau-color-text-muted", "panneau-color-link", "panneau-color-border", "panneau-color-border-control", "panneau-color-accent", "panneau-color-accent-hover", "panneau-color-accent-text", "panneau-color-accent-subtle", "panneau-color-focus", "panneau-color-danger", "panneau-color-danger-subtle", "panneau-color-danger-border", "panneau-color-danger-solid", "panneau-color-danger-solid-hover", "panneau-color-danger-solid-text", "panneau-color-success", "panneau-color-success-subtle", "panneau-color-success-border", "panneau-color-success-solid", "panneau-color-success-solid-hover", "panneau-color-success-solid-text", "panneau-color-warning", "panneau-color-warning-subtle", "panneau-color-warning-border", "panneau-color-warning-solid", "panneau-color-warning-solid-hover", "panneau-color-warning-solid-text", "panneau-color-info", "panneau-color-info-subtle", "panneau-color-info-border", "panneau-color-info-solid", "panneau-color-info-solid-hover", "panneau-color-info-solid-text", "panneau-chart-categorical-1", "panneau-chart-categorical-2", "panneau-chart-categorical-3", "panneau-chart-categorical-4", "panneau-chart-categorical-5", "panneau-chart-categorical-6", "panneau-chart-categorical-7", "panneau-chart-categorical-8", "panneau-chart-sequential-1", "panneau-chart-sequential-2", "panneau-chart-sequential-3", "panneau-chart-sequential-4", "panneau-chart-sequential-5", "panneau-chart-diverging-negative", "panneau-chart-diverging-neutral", "panneau-chart-diverging-positive", "panneau-font-family-body", "panneau-font-family-heading", "panneau-font-family-display", "panneau-font-family-mono", "panneau-font-family", "panneau-font-numeric", "panneau-font-size-xs", "panneau-font-size-sm", "panneau-font-size-md", "panneau-font-size-lg", "panneau-font-size-xl", "panneau-font-size-control", "panneau-line-height", "panneau-line-height-tight", "panneau-font-weight-normal", "panneau-font-weight-medium", "panneau-font-weight-bold", "panneau-space-1", "panneau-space-2", "panneau-space-3", "panneau-space-4", "panneau-space-5", "panneau-space-6", "panneau-space-8", "panneau-space-10", "panneau-radius-sm", "panneau-radius-md", "panneau-radius-lg", "panneau-radius-full", "panneau-border-width", "panneau-shadow-sm", "panneau-shadow-md", "panneau-shadow-lg", "panneau-control-height", "panneau-control-height-sm", "panneau-control-padding-x", "panneau-row-padding-y", "panneau-focus-width", "panneau-duration", "panneau-z-overlay", "panneau-z-toast"];
7
+ /** The name of a semantic token, without the leading `--`. */
8
+ export type SemanticTokenName = (typeof SEMANTIC_TOKENS)[number];
9
+ //# sourceMappingURL=semanticTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticTokens.d.ts","sourceRoot":"","sources":["../../src/theme/semanticTokens.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,eAAe,4nFAmGlB,CAAC;AAEX,8DAA8D;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,110 @@
1
+ //#region src/theme/semanticTokens.ts
2
+ /**
3
+ * The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the
4
+ * root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once
5
+ * (decision 0024). A test keeps this list in sync with the stylesheet.
6
+ */
7
+ var SEMANTIC_TOKENS = [
8
+ "panneau-color-bg",
9
+ "panneau-color-surface",
10
+ "panneau-color-surface-sunken",
11
+ "panneau-color-surface-raised",
12
+ "panneau-color-hover",
13
+ "panneau-color-pressed",
14
+ "panneau-color-backdrop",
15
+ "panneau-color-text",
16
+ "panneau-color-text-muted",
17
+ "panneau-color-link",
18
+ "panneau-color-border",
19
+ "panneau-color-border-control",
20
+ "panneau-color-accent",
21
+ "panneau-color-accent-hover",
22
+ "panneau-color-accent-text",
23
+ "panneau-color-accent-subtle",
24
+ "panneau-color-focus",
25
+ "panneau-color-danger",
26
+ "panneau-color-danger-subtle",
27
+ "panneau-color-danger-border",
28
+ "panneau-color-danger-solid",
29
+ "panneau-color-danger-solid-hover",
30
+ "panneau-color-danger-solid-text",
31
+ "panneau-color-success",
32
+ "panneau-color-success-subtle",
33
+ "panneau-color-success-border",
34
+ "panneau-color-success-solid",
35
+ "panneau-color-success-solid-hover",
36
+ "panneau-color-success-solid-text",
37
+ "panneau-color-warning",
38
+ "panneau-color-warning-subtle",
39
+ "panneau-color-warning-border",
40
+ "panneau-color-warning-solid",
41
+ "panneau-color-warning-solid-hover",
42
+ "panneau-color-warning-solid-text",
43
+ "panneau-color-info",
44
+ "panneau-color-info-subtle",
45
+ "panneau-color-info-border",
46
+ "panneau-color-info-solid",
47
+ "panneau-color-info-solid-hover",
48
+ "panneau-color-info-solid-text",
49
+ "panneau-chart-categorical-1",
50
+ "panneau-chart-categorical-2",
51
+ "panneau-chart-categorical-3",
52
+ "panneau-chart-categorical-4",
53
+ "panneau-chart-categorical-5",
54
+ "panneau-chart-categorical-6",
55
+ "panneau-chart-categorical-7",
56
+ "panneau-chart-categorical-8",
57
+ "panneau-chart-sequential-1",
58
+ "panneau-chart-sequential-2",
59
+ "panneau-chart-sequential-3",
60
+ "panneau-chart-sequential-4",
61
+ "panneau-chart-sequential-5",
62
+ "panneau-chart-diverging-negative",
63
+ "panneau-chart-diverging-neutral",
64
+ "panneau-chart-diverging-positive",
65
+ "panneau-font-family-body",
66
+ "panneau-font-family-heading",
67
+ "panneau-font-family-display",
68
+ "panneau-font-family-mono",
69
+ "panneau-font-family",
70
+ "panneau-font-numeric",
71
+ "panneau-font-size-xs",
72
+ "panneau-font-size-sm",
73
+ "panneau-font-size-md",
74
+ "panneau-font-size-lg",
75
+ "panneau-font-size-xl",
76
+ "panneau-font-size-control",
77
+ "panneau-line-height",
78
+ "panneau-line-height-tight",
79
+ "panneau-font-weight-normal",
80
+ "panneau-font-weight-medium",
81
+ "panneau-font-weight-bold",
82
+ "panneau-space-1",
83
+ "panneau-space-2",
84
+ "panneau-space-3",
85
+ "panneau-space-4",
86
+ "panneau-space-5",
87
+ "panneau-space-6",
88
+ "panneau-space-8",
89
+ "panneau-space-10",
90
+ "panneau-radius-sm",
91
+ "panneau-radius-md",
92
+ "panneau-radius-lg",
93
+ "panneau-radius-full",
94
+ "panneau-border-width",
95
+ "panneau-shadow-sm",
96
+ "panneau-shadow-md",
97
+ "panneau-shadow-lg",
98
+ "panneau-control-height",
99
+ "panneau-control-height-sm",
100
+ "panneau-control-padding-x",
101
+ "panneau-row-padding-y",
102
+ "panneau-focus-width",
103
+ "panneau-duration",
104
+ "panneau-z-overlay",
105
+ "panneau-z-toast"
106
+ ];
107
+ //#endregion
108
+ export { SEMANTIC_TOKENS };
109
+
110
+ //# sourceMappingURL=semanticTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semanticTokens.js","names":[],"sources":["../../src/theme/semanticTokens.ts"],"sourcesContent":["/**\n * The semantic tokens of Panneau, without the leading `--`: what the default theme defines on the\n * root (`PanneauRoot.module.css`), and what a theme sets to restyle every component at once\n * (decision 0024). A test keeps this list in sync with the stylesheet.\n */\nexport const SEMANTIC_TOKENS = [\n 'panneau-color-bg',\n 'panneau-color-surface',\n 'panneau-color-surface-sunken',\n 'panneau-color-surface-raised',\n 'panneau-color-hover',\n 'panneau-color-pressed',\n 'panneau-color-backdrop',\n 'panneau-color-text',\n 'panneau-color-text-muted',\n 'panneau-color-link',\n 'panneau-color-border',\n 'panneau-color-border-control',\n 'panneau-color-accent',\n 'panneau-color-accent-hover',\n 'panneau-color-accent-text',\n 'panneau-color-accent-subtle',\n 'panneau-color-focus',\n 'panneau-color-danger',\n 'panneau-color-danger-subtle',\n 'panneau-color-danger-border',\n 'panneau-color-danger-solid',\n 'panneau-color-danger-solid-hover',\n 'panneau-color-danger-solid-text',\n 'panneau-color-success',\n 'panneau-color-success-subtle',\n 'panneau-color-success-border',\n 'panneau-color-success-solid',\n 'panneau-color-success-solid-hover',\n 'panneau-color-success-solid-text',\n 'panneau-color-warning',\n 'panneau-color-warning-subtle',\n 'panneau-color-warning-border',\n 'panneau-color-warning-solid',\n 'panneau-color-warning-solid-hover',\n 'panneau-color-warning-solid-text',\n 'panneau-color-info',\n 'panneau-color-info-subtle',\n 'panneau-color-info-border',\n 'panneau-color-info-solid',\n 'panneau-color-info-solid-hover',\n 'panneau-color-info-solid-text',\n 'panneau-chart-categorical-1',\n 'panneau-chart-categorical-2',\n 'panneau-chart-categorical-3',\n 'panneau-chart-categorical-4',\n 'panneau-chart-categorical-5',\n 'panneau-chart-categorical-6',\n 'panneau-chart-categorical-7',\n 'panneau-chart-categorical-8',\n 'panneau-chart-sequential-1',\n 'panneau-chart-sequential-2',\n 'panneau-chart-sequential-3',\n 'panneau-chart-sequential-4',\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-neutral',\n 'panneau-chart-diverging-positive',\n 'panneau-font-family-body',\n 'panneau-font-family-heading',\n 'panneau-font-family-display',\n 'panneau-font-family-mono',\n 'panneau-font-family',\n 'panneau-font-numeric',\n 'panneau-font-size-xs',\n 'panneau-font-size-sm',\n 'panneau-font-size-md',\n 'panneau-font-size-lg',\n 'panneau-font-size-xl',\n 'panneau-font-size-control',\n 'panneau-line-height',\n 'panneau-line-height-tight',\n 'panneau-font-weight-normal',\n 'panneau-font-weight-medium',\n 'panneau-font-weight-bold',\n 'panneau-space-1',\n 'panneau-space-2',\n 'panneau-space-3',\n 'panneau-space-4',\n 'panneau-space-5',\n 'panneau-space-6',\n 'panneau-space-8',\n 'panneau-space-10',\n 'panneau-radius-sm',\n 'panneau-radius-md',\n 'panneau-radius-lg',\n 'panneau-radius-full',\n 'panneau-border-width',\n 'panneau-shadow-sm',\n 'panneau-shadow-md',\n 'panneau-shadow-lg',\n 'panneau-control-height',\n 'panneau-control-height-sm',\n 'panneau-control-padding-x',\n 'panneau-row-padding-y',\n 'panneau-focus-width',\n 'panneau-duration',\n 'panneau-z-overlay',\n 'panneau-z-toast',\n] as const;\n\n/** The name of a semantic token, without the leading `--`. */\nexport type SemanticTokenName = (typeof SEMANTIC_TOKENS)[number];\n"],"mappings":";;;;;;AAKA,IAAa,kBAAkB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAAiB"}
@@ -1,23 +1,77 @@
1
+ import type { ThemeFont } from './fonts';
2
+ import { type ToneInput, type ToneSurfaces } from './tones';
1
3
  /**
2
4
  * A theme: design tokens, as CSS variables without the leading `--`, with optional overrides for
3
- * the dark scheme. It has the same shape as the `Theme` of `@panneau/core` plugins.
5
+ * the dark scheme, raw palette colors, its own tones, and named variants of components (decision
6
+ * 0024). A theme is plain data: the `Theme` schema of `@panneau/protocol` validates it, and plugins
7
+ * of `@panneau/core` register it. Write one with `defineTheme()` to check token names.
8
+ *
9
+ * It is a type rather than an interface so that it is assignable to the `Theme` of
10
+ * `@panneau/protocol`, which accepts properties of later versions.
4
11
  */
5
- export interface Theme {
12
+ export type Theme = {
13
+ /** A name for theme pickers. */
6
14
  label?: string;
7
15
  /** Tokens of the light scheme, or of both schemes without `dark`: `{ 'panneau-color-accent': '#05f' }`. */
8
16
  tokens: Record<string, string>;
9
17
  /** Tokens that change in the dark scheme. */
10
18
  dark?: Record<string, string>;
11
- }
19
+ /**
20
+ * Raw colors, written as `--panneau-palette-<name>`: tokens and tones use them with
21
+ * `var(--panneau-palette-<name>)`, so that a theme names its brand colors once.
22
+ */
23
+ palette?: Record<string, string>;
24
+ /**
25
+ * Tones added or redefined by the theme: one color, from which Panneau derives the others,
26
+ * or every value. Declare added tones in `PanneauTones` so that `tone="signal"` type-checks.
27
+ */
28
+ tones?: Record<string, ToneInput>;
29
+ /**
30
+ * Named variants of components: token overrides that `<Badge variant="tag">` applies through
31
+ * its `panneau-badge-variant-tag` class. Declare them in `BadgeVariants` (and the like).
32
+ */
33
+ components?: Record<string, {
34
+ variants?: Record<string, Record<string, string>>;
35
+ }>;
36
+ /**
37
+ * Tokens of each density, such as `panneau-control-height`: tokens set here change with the
38
+ * density of the root, while the same tokens in `tokens` would apply to every density.
39
+ */
40
+ densities?: Partial<Record<Exclude<Density, 'auto'>, Record<string, string>>>;
41
+ /**
42
+ * Font faces and font stylesheets, which `PanneauRoot` adds to the page once. Font tokens
43
+ * (`panneau-font-family-heading`) then use their families.
44
+ */
45
+ fonts?: ThemeFont[];
46
+ };
12
47
  /** `auto` follows the system setting (`prefers-color-scheme`). */
13
48
  export type ColorScheme = 'light' | 'dark' | 'auto';
49
+ /**
50
+ * How much room controls and rows take: `compact`, `comfortable`, or `touch`, with larger targets.
51
+ * `auto` is `touch` on coarse pointers (touch screens) and `comfortable` otherwise.
52
+ */
53
+ export type Density = 'compact' | 'comfortable' | 'touch' | 'auto';
14
54
  /** A short, stable hash of a string, to scope the CSS of a theme. */
15
55
  export declare function hashString(value: string): string;
56
+ /** The palette of a theme, as variables: `{ 'panneau-palette-orange': '#f25c05' }`. */
57
+ export declare function paletteVariables(palette?: Readonly<Record<string, string>>): Record<string, string>;
58
+ /**
59
+ * Follows `var(--name)` references through the given variables (tokens, palette colors), until a
60
+ * value that is not one: `var(--panneau-palette-orange)` becomes `#f25c05`. A reference to a
61
+ * variable that isn't given is returned as is.
62
+ */
63
+ export declare function resolveReference(value: string, variables: Readonly<Record<string, string>>): string;
64
+ /**
65
+ * The surfaces of a theme in each scheme, when it sets ones Panneau can read: tones derived from
66
+ * one color are made readable on them.
67
+ */
68
+ export declare function themeSurfaces(theme: Theme): ToneSurfaces;
16
69
  /**
17
- * The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"`. Its rules are
18
- * more specific than the default tokens, and dark overrides more specific than light ones. Token
19
- * names must be plain identifiers, and values can't contain `{`, `}`, `;` or `<`: other entries are
20
- * ignored.
70
+ * The CSS of a theme, scoped to the roots that carry `data-panneau-theme="<scope>"`: its palette and
71
+ * tokens, its densities, its tones and the variants of components. Its rules are more specific than the default
72
+ * tokens and the built-in tones, and dark overrides more specific than light ones. Token, tone,
73
+ * component and variant names must be plain identifiers, and values can't contain `{`, `}`, `;` or
74
+ * `<`: other entries are ignored.
21
75
  */
22
76
  export declare function getThemeCss(theme: Theme, scope: string): string;
23
77
  //# sourceMappingURL=theme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2GAA2G;IAC3G,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AASpD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAW/D"}
1
+ {"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAEH,KAAK,SAAS,EACd,KAAK,YAAY,EAIpB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;GAQG;AACH,MAAM,MAAM,KAAK,GAAG;IAChB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2GAA2G;IAC3G,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;KAAE,CAAC,CAAC;IACnF;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9E;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB,CAAC;AAEF,kEAAkE;AAClE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,CAAC;AASnE,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAMD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC/C,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC5C,MAAM,CAUR;AAaD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAgBxD;AAoBD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CA+C/D"}