@panneau/ui 5.0.0-alpha.4 → 5.0.0-alpha.42

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 (485) hide show
  1. package/README.md +138 -4
  2. package/dist/alert/Alert.d.ts +2 -2
  3. package/dist/alert/Alert.js +108 -40
  4. package/dist/alert/Alert.js.map +1 -1
  5. package/dist/alert/tokens.d.ts +1 -1
  6. package/dist/alert/tokens.js.map +1 -1
  7. package/dist/aside/Aside.css +255 -0
  8. package/dist/aside/Aside.d.ts +86 -0
  9. package/dist/aside/Aside.d.ts.map +1 -0
  10. package/dist/aside/Aside.js +403 -0
  11. package/dist/aside/Aside.js.map +1 -0
  12. package/dist/aside/Aside.module.js +46 -0
  13. package/dist/aside/Aside.module.js.map +1 -0
  14. package/dist/aside/tokens.d.ts +3 -0
  15. package/dist/aside/tokens.d.ts.map +1 -0
  16. package/dist/aside/tokens.js +23 -0
  17. package/dist/aside/tokens.js.map +1 -0
  18. package/dist/badge/Badge.d.ts +1 -1
  19. package/dist/badge/Badge.js +34 -6
  20. package/dist/badge/Badge.js.map +1 -1
  21. package/dist/badge/tokens.d.ts +1 -1
  22. package/dist/badge/tokens.js.map +1 -1
  23. package/dist/bar-chart/BarChart.css +76 -0
  24. package/dist/bar-chart/BarChart.d.ts +33 -0
  25. package/dist/bar-chart/BarChart.d.ts.map +1 -0
  26. package/dist/bar-chart/BarChart.js +151 -0
  27. package/dist/bar-chart/BarChart.js.map +1 -0
  28. package/dist/bar-chart/BarChart.module.js +26 -0
  29. package/dist/bar-chart/BarChart.module.js.map +1 -0
  30. package/dist/bar-chart/tokens.d.ts +3 -0
  31. package/dist/bar-chart/tokens.d.ts.map +1 -0
  32. package/dist/bar-chart/tokens.js +17 -0
  33. package/dist/bar-chart/tokens.js.map +1 -0
  34. package/dist/button/Button.css +13 -1
  35. package/dist/button/Button.d.ts +20 -6
  36. package/dist/button/Button.d.ts.map +1 -1
  37. package/dist/button/Button.js +169 -22
  38. package/dist/button/Button.js.map +1 -1
  39. package/dist/button/Button.module.js.map +1 -1
  40. package/dist/button/LinkButton.d.ts +22 -0
  41. package/dist/button/LinkButton.d.ts.map +1 -0
  42. package/dist/button/LinkButton.js +113 -0
  43. package/dist/button/LinkButton.js.map +1 -0
  44. package/dist/button/tokens.d.ts +1 -1
  45. package/dist/button/tokens.d.ts.map +1 -1
  46. package/dist/button/tokens.js +4 -0
  47. package/dist/button/tokens.js.map +1 -1
  48. package/dist/card/Card.css +1 -0
  49. package/dist/card/Card.js +76 -23
  50. package/dist/card/Card.js.map +1 -1
  51. package/dist/card/Card.module.js.map +1 -1
  52. package/dist/card/tokens.d.ts +1 -1
  53. package/dist/card/tokens.js.map +1 -1
  54. package/dist/chart-legend/ChartLegend.css +73 -0
  55. package/dist/chart-legend/ChartLegend.d.ts +32 -0
  56. package/dist/chart-legend/ChartLegend.d.ts.map +1 -0
  57. package/dist/chart-legend/ChartLegend.js +76 -0
  58. package/dist/chart-legend/ChartLegend.js.map +1 -0
  59. package/dist/chart-legend/ChartLegend.module.js +26 -0
  60. package/dist/chart-legend/ChartLegend.module.js.map +1 -0
  61. package/dist/checkbox/Checkbox.css +15 -16
  62. package/dist/checkbox/Checkbox.d.ts +1 -1
  63. package/dist/checkbox/Checkbox.js +86 -25
  64. package/dist/checkbox/Checkbox.js.map +1 -1
  65. package/dist/checkbox/Checkbox.module.js.map +1 -1
  66. package/dist/checkbox/ChoiceChrome.js +82 -21
  67. package/dist/checkbox/ChoiceChrome.js.map +1 -1
  68. package/dist/checkbox/tokens.d.ts +1 -1
  69. package/dist/checkbox/tokens.js +2 -2
  70. package/dist/checkbox/tokens.js.map +1 -1
  71. package/dist/combo-box/ComboBox.css +10 -0
  72. package/dist/combo-box/ComboBox.d.ts +7 -2
  73. package/dist/combo-box/ComboBox.d.ts.map +1 -1
  74. package/dist/combo-box/ComboBox.js +310 -78
  75. package/dist/combo-box/ComboBox.js.map +1 -1
  76. package/dist/combo-box/ComboBox.module.js +4 -2
  77. package/dist/combo-box/ComboBox.module.js.map +1 -1
  78. package/dist/command-palette/CommandPalette.css +299 -0
  79. package/dist/command-palette/CommandPalette.d.ts +37 -0
  80. package/dist/command-palette/CommandPalette.d.ts.map +1 -0
  81. package/dist/command-palette/CommandPalette.js +497 -0
  82. package/dist/command-palette/CommandPalette.js.map +1 -0
  83. package/dist/command-palette/CommandPalette.module.js +62 -0
  84. package/dist/command-palette/CommandPalette.module.js.map +1 -0
  85. package/dist/command-palette/match.d.ts +39 -0
  86. package/dist/command-palette/match.d.ts.map +1 -0
  87. package/dist/command-palette/match.js +44 -0
  88. package/dist/command-palette/match.js.map +1 -0
  89. package/dist/command-palette/tokens.d.ts +3 -0
  90. package/dist/command-palette/tokens.d.ts.map +1 -0
  91. package/dist/command-palette/tokens.js +23 -0
  92. package/dist/command-palette/tokens.js.map +1 -0
  93. package/dist/command-palette/useCommandShortcut.d.ts +12 -0
  94. package/dist/command-palette/useCommandShortcut.d.ts.map +1 -0
  95. package/dist/command-palette/useCommandShortcut.js +48 -0
  96. package/dist/command-palette/useCommandShortcut.js.map +1 -0
  97. package/dist/container/Container.js +48 -5
  98. package/dist/container/Container.js.map +1 -1
  99. package/dist/container/tokens.d.ts +1 -1
  100. package/dist/container/tokens.js.map +1 -1
  101. package/dist/date-picker/DatePicker.css +56 -4
  102. package/dist/date-picker/DatePicker.d.ts +16 -3
  103. package/dist/date-picker/DatePicker.d.ts.map +1 -1
  104. package/dist/date-picker/DatePicker.js +359 -72
  105. package/dist/date-picker/DatePicker.js.map +1 -1
  106. package/dist/date-picker/DatePicker.module.js +8 -2
  107. package/dist/date-picker/DatePicker.module.js.map +1 -1
  108. package/dist/date-picker/calendarTokens.d.ts +1 -1
  109. package/dist/date-picker/calendarTokens.js +2 -2
  110. package/dist/date-picker/calendarTokens.js.map +1 -1
  111. package/dist/date-range-picker/DateRangePicker.css +37 -0
  112. package/dist/date-range-picker/DateRangePicker.d.ts +41 -0
  113. package/dist/date-range-picker/DateRangePicker.d.ts.map +1 -0
  114. package/dist/date-range-picker/DateRangePicker.js +438 -0
  115. package/dist/date-range-picker/DateRangePicker.js.map +1 -0
  116. package/dist/date-range-picker/DateRangePicker.module.js +20 -0
  117. package/dist/date-range-picker/DateRangePicker.module.js.map +1 -0
  118. package/dist/dialog/Dialog.css +44 -5
  119. package/dist/dialog/Dialog.d.ts +15 -3
  120. package/dist/dialog/Dialog.d.ts.map +1 -1
  121. package/dist/dialog/Dialog.js +161 -32
  122. package/dist/dialog/Dialog.js.map +1 -1
  123. package/dist/dialog/Dialog.module.js +10 -2
  124. package/dist/dialog/Dialog.module.js.map +1 -1
  125. package/dist/dialog/tokens.d.ts +1 -1
  126. package/dist/dialog/tokens.d.ts.map +1 -1
  127. package/dist/dialog/tokens.js +2 -0
  128. package/dist/dialog/tokens.js.map +1 -1
  129. package/dist/disclosure/Disclosure.js +132 -28
  130. package/dist/disclosure/Disclosure.js.map +1 -1
  131. package/dist/disclosure/tokens.d.ts +1 -1
  132. package/dist/disclosure/tokens.js.map +1 -1
  133. package/dist/divider/Divider.js +55 -11
  134. package/dist/divider/Divider.js.map +1 -1
  135. package/dist/divider/tokens.d.ts +1 -1
  136. package/dist/divider/tokens.js.map +1 -1
  137. package/dist/field/Field.css +30 -4
  138. package/dist/field/Field.module.js +6 -2
  139. package/dist/field/Field.module.js.map +1 -1
  140. package/dist/field/FieldParts.d.ts +1 -1
  141. package/dist/field/FieldParts.js +69 -15
  142. package/dist/field/FieldParts.js.map +1 -1
  143. package/dist/field/Fieldset.d.ts +6 -1
  144. package/dist/field/Fieldset.d.ts.map +1 -1
  145. package/dist/field/Fieldset.js +132 -33
  146. package/dist/field/Fieldset.js.map +1 -1
  147. package/dist/field/inputTokens.d.ts +1 -1
  148. package/dist/field/inputTokens.d.ts.map +1 -1
  149. package/dist/field/inputTokens.js +7 -1
  150. package/dist/field/inputTokens.js.map +1 -1
  151. package/dist/field/tokens.d.ts +1 -1
  152. package/dist/field/tokens.d.ts.map +1 -1
  153. package/dist/field/tokens.js +3 -1
  154. package/dist/field/tokens.js.map +1 -1
  155. package/dist/grid/Grid.d.ts +1 -1
  156. package/dist/grid/Grid.js +123 -14
  157. package/dist/grid/Grid.js.map +1 -1
  158. package/dist/grid/tokens.d.ts +1 -1
  159. package/dist/grid/tokens.js.map +1 -1
  160. package/dist/heading/Heading.js +41 -6
  161. package/dist/heading/Heading.js.map +1 -1
  162. package/dist/heading/tokens.d.ts +1 -1
  163. package/dist/heading/tokens.js.map +1 -1
  164. package/dist/icon/Icon.css +5 -0
  165. package/dist/icon/Icon.d.ts +5 -1
  166. package/dist/icon/Icon.d.ts.map +1 -1
  167. package/dist/icon/Icon.js +38 -12
  168. package/dist/icon/Icon.js.map +1 -1
  169. package/dist/icon/Icon.module.js.map +1 -1
  170. package/dist/icon/lucideIconLoader.d.ts +1 -1
  171. package/dist/icon/lucideIconLoader.js.map +1 -1
  172. package/dist/icon/namedIcons.d.ts +1 -1
  173. package/dist/icon/namedIcons.js +87 -26
  174. package/dist/icon/namedIcons.js.map +1 -1
  175. package/dist/icon/tokens.d.ts +3 -0
  176. package/dist/icon/tokens.d.ts.map +1 -0
  177. package/dist/icon/tokens.js +13 -0
  178. package/dist/icon/tokens.js.map +1 -0
  179. package/dist/icon-button/IconButton.d.ts +2 -2
  180. package/dist/icon-button/IconButton.js +70 -13
  181. package/dist/icon-button/IconButton.js.map +1 -1
  182. package/dist/index.d.ts +71 -52
  183. package/dist/index.d.ts.map +1 -1
  184. package/dist/index.js +25 -6
  185. package/dist/inline/Inline.d.ts +1 -1
  186. package/dist/inline/Inline.js +65 -7
  187. package/dist/inline/Inline.js.map +1 -1
  188. package/dist/inline/tokens.d.ts +1 -1
  189. package/dist/inline/tokens.js.map +1 -1
  190. package/dist/intl/usePanneauIntl.js.map +1 -1
  191. package/dist/layout/responsive.js.map +1 -1
  192. package/dist/line-chart/LineChart.css +314 -0
  193. package/dist/line-chart/LineChart.d.ts +84 -0
  194. package/dist/line-chart/LineChart.d.ts.map +1 -0
  195. package/dist/line-chart/LineChart.js +626 -0
  196. package/dist/line-chart/LineChart.js.map +1 -0
  197. package/dist/line-chart/LineChart.module.js +73 -0
  198. package/dist/line-chart/LineChart.module.js.map +1 -0
  199. package/dist/line-chart/geometry.d.ts +37 -0
  200. package/dist/line-chart/geometry.d.ts.map +1 -0
  201. package/dist/line-chart/geometry.js +115 -0
  202. package/dist/line-chart/geometry.js.map +1 -0
  203. package/dist/line-chart/tokens.d.ts +3 -0
  204. package/dist/line-chart/tokens.d.ts.map +1 -0
  205. package/dist/line-chart/tokens.js +23 -0
  206. package/dist/line-chart/tokens.js.map +1 -0
  207. package/dist/locales/index.js.map +1 -1
  208. package/dist/menu/Menu.css +84 -0
  209. package/dist/menu/Menu.d.ts +34 -7
  210. package/dist/menu/Menu.d.ts.map +1 -1
  211. package/dist/menu/Menu.js +243 -32
  212. package/dist/menu/Menu.js.map +1 -1
  213. package/dist/menu/Menu.module.js +22 -0
  214. package/dist/menu/Menu.module.js.map +1 -0
  215. package/dist/menu/tokens.d.ts +3 -0
  216. package/dist/menu/tokens.d.ts.map +1 -0
  217. package/dist/menu/tokens.js +31 -0
  218. package/dist/menu/tokens.js.map +1 -0
  219. package/dist/meter/Meter.css +23 -0
  220. package/dist/meter/Meter.d.ts +26 -0
  221. package/dist/meter/Meter.d.ts.map +1 -0
  222. package/dist/meter/Meter.js +99 -0
  223. package/dist/meter/Meter.js.map +1 -0
  224. package/dist/meter/Meter.module.js +16 -0
  225. package/dist/meter/Meter.module.js.map +1 -0
  226. package/dist/meter/tokens.d.ts +3 -0
  227. package/dist/meter/tokens.d.ts.map +1 -0
  228. package/dist/meter/tokens.js +15 -0
  229. package/dist/meter/tokens.js.map +1 -0
  230. package/dist/named-icons/index.d.ts +1 -1
  231. package/dist/node_modules/@internationalized/date/dist/private/CalendarDate.js +136 -0
  232. package/dist/node_modules/@internationalized/date/dist/private/CalendarDate.js.map +1 -0
  233. package/dist/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js +117 -0
  234. package/dist/node_modules/@internationalized/date/dist/private/calendars/GregorianCalendar.js.map +1 -0
  235. package/dist/node_modules/@internationalized/date/dist/private/conversion.js +116 -0
  236. package/dist/node_modules/@internationalized/date/dist/private/conversion.js.map +1 -0
  237. package/dist/node_modules/@internationalized/date/dist/private/manipulation.js +206 -0
  238. package/dist/node_modules/@internationalized/date/dist/private/manipulation.js.map +1 -0
  239. package/dist/node_modules/@internationalized/date/dist/private/queries.js +26 -0
  240. package/dist/node_modules/@internationalized/date/dist/private/queries.js.map +1 -0
  241. package/dist/node_modules/@internationalized/date/dist/private/string.js +19 -0
  242. package/dist/node_modules/@internationalized/date/dist/private/string.js.map +1 -0
  243. package/dist/node_modules/@internationalized/date/dist/private/utils.js +8 -0
  244. package/dist/node_modules/@internationalized/date/dist/private/utils.js.map +1 -0
  245. package/dist/number-input/NumberInput.css +18 -0
  246. package/dist/number-input/NumberInput.d.ts +1 -1
  247. package/dist/number-input/NumberInput.js +232 -60
  248. package/dist/number-input/NumberInput.js.map +1 -1
  249. package/dist/number-input/NumberInput.module.js +3 -1
  250. package/dist/number-input/NumberInput.module.js.map +1 -1
  251. package/dist/number-input/tokens.d.ts +1 -1
  252. package/dist/number-input/tokens.js.map +1 -1
  253. package/dist/pill-trigger/PillTrigger.css +104 -0
  254. package/dist/pill-trigger/PillTrigger.d.ts +20 -0
  255. package/dist/pill-trigger/PillTrigger.d.ts.map +1 -0
  256. package/dist/pill-trigger/PillTrigger.js +94 -0
  257. package/dist/pill-trigger/PillTrigger.js.map +1 -0
  258. package/dist/pill-trigger/PillTrigger.module.js +18 -0
  259. package/dist/pill-trigger/PillTrigger.module.js.map +1 -0
  260. package/dist/pill-trigger/tokens.d.ts +3 -0
  261. package/dist/pill-trigger/tokens.d.ts.map +1 -0
  262. package/dist/pill-trigger/tokens.js +37 -0
  263. package/dist/pill-trigger/tokens.js.map +1 -0
  264. package/dist/popover/Popover.css +7 -2
  265. package/dist/popover/Popover.d.ts.map +1 -1
  266. package/dist/popover/Popover.js +116 -20
  267. package/dist/popover/Popover.js.map +1 -1
  268. package/dist/popover/Popover.module.js +4 -2
  269. package/dist/popover/Popover.module.js.map +1 -1
  270. package/dist/popover/tokens.d.ts +1 -1
  271. package/dist/popover/tokens.js.map +1 -1
  272. package/dist/prose/Prose.js +36 -5
  273. package/dist/prose/Prose.js.map +1 -1
  274. package/dist/prose/tokens.d.ts +1 -1
  275. package/dist/prose/tokens.js.map +1 -1
  276. package/dist/radio-group/RadioGroup.css +214 -9
  277. package/dist/radio-group/RadioGroup.d.ts +34 -5
  278. package/dist/radio-group/RadioGroup.d.ts.map +1 -1
  279. package/dist/radio-group/RadioGroup.js +258 -43
  280. package/dist/radio-group/RadioGroup.js.map +1 -1
  281. package/dist/radio-group/RadioGroup.module.js +22 -2
  282. package/dist/radio-group/RadioGroup.module.js.map +1 -1
  283. package/dist/radio-group/tokens.d.ts +2 -2
  284. package/dist/radio-group/tokens.d.ts.map +1 -1
  285. package/dist/radio-group/tokens.js +31 -3
  286. package/dist/radio-group/tokens.js.map +1 -1
  287. package/dist/root/PanneauRoot.css +35 -0
  288. package/dist/root/PanneauRoot.d.ts +37 -6
  289. package/dist/root/PanneauRoot.d.ts.map +1 -1
  290. package/dist/root/PanneauRoot.js +283 -85
  291. package/dist/root/PanneauRoot.js.map +1 -1
  292. package/dist/root/PanneauRoot.module.js.map +1 -1
  293. package/dist/root/ThemeScope.d.ts +1 -1
  294. package/dist/root/ThemeScope.d.ts.map +1 -1
  295. package/dist/root/ThemeScope.js +110 -27
  296. package/dist/root/ThemeScope.js.map +1 -1
  297. package/dist/segmented-control/SegmentedControl.css +87 -0
  298. package/dist/segmented-control/SegmentedControl.d.ts +35 -0
  299. package/dist/segmented-control/SegmentedControl.d.ts.map +1 -0
  300. package/dist/segmented-control/SegmentedControl.js +142 -0
  301. package/dist/segmented-control/SegmentedControl.js.map +1 -0
  302. package/dist/segmented-control/SegmentedControl.module.js +16 -0
  303. package/dist/segmented-control/SegmentedControl.module.js.map +1 -0
  304. package/dist/segmented-control/tokens.d.ts +3 -0
  305. package/dist/segmented-control/tokens.d.ts.map +1 -0
  306. package/dist/segmented-control/tokens.js +33 -0
  307. package/dist/segmented-control/tokens.js.map +1 -0
  308. package/dist/select/ListBox.css +86 -1
  309. package/dist/select/ListBox.module.js +11 -3
  310. package/dist/select/ListBox.module.js.map +1 -1
  311. package/dist/select/Select.d.ts +14 -1
  312. package/dist/select/Select.d.ts.map +1 -1
  313. package/dist/select/Select.js +352 -92
  314. package/dist/select/Select.js.map +1 -1
  315. package/dist/select/listBoxTokens.d.ts +1 -1
  316. package/dist/select/listBoxTokens.d.ts.map +1 -1
  317. package/dist/select/listBoxTokens.js +2 -0
  318. package/dist/select/listBoxTokens.js.map +1 -1
  319. package/dist/skeleton/LoadingRegion.d.ts +16 -0
  320. package/dist/skeleton/LoadingRegion.d.ts.map +1 -0
  321. package/dist/skeleton/LoadingRegion.js +65 -0
  322. package/dist/skeleton/LoadingRegion.js.map +1 -0
  323. package/dist/skeleton/Skeleton.css +62 -0
  324. package/dist/skeleton/Skeleton.d.ts +25 -0
  325. package/dist/skeleton/Skeleton.d.ts.map +1 -0
  326. package/dist/skeleton/Skeleton.js +106 -0
  327. package/dist/skeleton/Skeleton.js.map +1 -0
  328. package/dist/skeleton/Skeleton.module.js +22 -0
  329. package/dist/skeleton/Skeleton.module.js.map +1 -0
  330. package/dist/skeleton/tokens.d.ts +3 -0
  331. package/dist/skeleton/tokens.d.ts.map +1 -0
  332. package/dist/skeleton/tokens.js +15 -0
  333. package/dist/skeleton/tokens.js.map +1 -0
  334. package/dist/slider/Slider.css +94 -0
  335. package/dist/slider/Slider.d.ts +20 -0
  336. package/dist/slider/Slider.d.ts.map +1 -0
  337. package/dist/slider/Slider.js +248 -0
  338. package/dist/slider/Slider.js.map +1 -0
  339. package/dist/slider/Slider.module.js +20 -0
  340. package/dist/slider/Slider.module.js.map +1 -0
  341. package/dist/sparkline/Sparkline.css +44 -0
  342. package/dist/sparkline/Sparkline.d.ts +23 -0
  343. package/dist/sparkline/Sparkline.d.ts.map +1 -0
  344. package/dist/sparkline/Sparkline.js +164 -0
  345. package/dist/sparkline/Sparkline.js.map +1 -0
  346. package/dist/sparkline/Sparkline.module.js +20 -0
  347. package/dist/sparkline/Sparkline.module.js.map +1 -0
  348. package/dist/sparkline/tokens.d.ts +3 -0
  349. package/dist/sparkline/tokens.d.ts.map +1 -0
  350. package/dist/sparkline/tokens.js +17 -0
  351. package/dist/sparkline/tokens.js.map +1 -0
  352. package/dist/spinner/Spinner.css +21 -6
  353. package/dist/spinner/Spinner.d.ts.map +1 -1
  354. package/dist/spinner/Spinner.js +60 -10
  355. package/dist/spinner/Spinner.js.map +1 -1
  356. package/dist/spinner/Spinner.module.js +5 -1
  357. package/dist/spinner/Spinner.module.js.map +1 -1
  358. package/dist/spinner/tokens.d.ts +1 -1
  359. package/dist/spinner/tokens.js.map +1 -1
  360. package/dist/stack/Stack.d.ts +1 -1
  361. package/dist/stack/Stack.js +60 -7
  362. package/dist/stack/Stack.js.map +1 -1
  363. package/dist/stack/tokens.d.ts +1 -1
  364. package/dist/stack/tokens.js.map +1 -1
  365. package/dist/stat/Stat.css +79 -0
  366. package/dist/stat/Stat.d.ts +49 -0
  367. package/dist/stat/Stat.d.ts.map +1 -0
  368. package/dist/stat/Stat.js +127 -0
  369. package/dist/stat/Stat.js.map +1 -0
  370. package/dist/stat/Stat.module.js +28 -0
  371. package/dist/stat/Stat.module.js.map +1 -0
  372. package/dist/stat/tokens.d.ts +3 -0
  373. package/dist/stat/tokens.d.ts.map +1 -0
  374. package/dist/stat/tokens.js +21 -0
  375. package/dist/stat/tokens.js.map +1 -0
  376. package/dist/switch/Switch.css +16 -10
  377. package/dist/switch/Switch.d.ts +1 -1
  378. package/dist/switch/Switch.js +68 -11
  379. package/dist/switch/Switch.js.map +1 -1
  380. package/dist/switch/Switch.module.js.map +1 -1
  381. package/dist/switch/tokens.d.ts +1 -1
  382. package/dist/switch/tokens.d.ts.map +1 -1
  383. package/dist/switch/tokens.js +4 -2
  384. package/dist/switch/tokens.js.map +1 -1
  385. package/dist/tabs/Tabs.css +11 -4
  386. package/dist/tabs/Tabs.js +1 -1
  387. package/dist/tabs/Tabs.js.map +1 -1
  388. package/dist/tabs/Tabs.module.js.map +1 -1
  389. package/dist/tabs/tokens.d.ts +1 -1
  390. package/dist/tabs/tokens.js +1 -1
  391. package/dist/tabs/tokens.js.map +1 -1
  392. package/dist/tags-input/TagsInput.css +73 -0
  393. package/dist/tags-input/TagsInput.d.ts +32 -0
  394. package/dist/tags-input/TagsInput.d.ts.map +1 -0
  395. package/dist/tags-input/TagsInput.js +316 -0
  396. package/dist/tags-input/TagsInput.js.map +1 -0
  397. package/dist/tags-input/TagsInput.module.js +20 -0
  398. package/dist/tags-input/TagsInput.module.js.map +1 -0
  399. package/dist/text/Text.d.ts +1 -1
  400. package/dist/text/Text.js +70 -5
  401. package/dist/text/Text.js.map +1 -1
  402. package/dist/text/tokens.d.ts +1 -1
  403. package/dist/text/tokens.js.map +1 -1
  404. package/dist/text-area/TextArea.d.ts +1 -1
  405. package/dist/text-area/TextArea.js +135 -28
  406. package/dist/text-area/TextArea.js.map +1 -1
  407. package/dist/text-input/TextInput.d.ts +7 -3
  408. package/dist/text-input/TextInput.d.ts.map +1 -1
  409. package/dist/text-input/TextInput.js +164 -47
  410. package/dist/text-input/TextInput.js.map +1 -1
  411. package/dist/theme/Tone.css +14 -0
  412. package/dist/theme/Tone.module.js +4 -2
  413. package/dist/theme/Tone.module.js.map +1 -1
  414. package/dist/theme/bootstrap.d.ts +2 -2
  415. package/dist/theme/bootstrap.d.ts.map +1 -1
  416. package/dist/theme/bootstrap.js +6 -0
  417. package/dist/theme/bootstrap.js.map +1 -1
  418. package/dist/theme/chartColors.js.map +1 -1
  419. package/dist/theme/checkTheme.d.ts +6 -4
  420. package/dist/theme/checkTheme.d.ts.map +1 -1
  421. package/dist/theme/checkTheme.js +54 -7
  422. package/dist/theme/checkTheme.js.map +1 -1
  423. package/dist/theme/cli.d.ts +2 -2
  424. package/dist/theme/cli.js.map +1 -1
  425. package/dist/theme/color.d.ts +13 -0
  426. package/dist/theme/color.d.ts.map +1 -1
  427. package/dist/theme/color.js +41 -1
  428. package/dist/theme/color.js.map +1 -1
  429. package/dist/theme/colorVision.d.ts +1 -1
  430. package/dist/theme/colorVision.js.map +1 -1
  431. package/dist/theme/componentTokens.js.map +1 -1
  432. package/dist/theme/components.d.ts +24 -11
  433. package/dist/theme/components.d.ts.map +1 -1
  434. package/dist/theme/components.js +26 -0
  435. package/dist/theme/components.js.map +1 -1
  436. package/dist/theme/defineTheme.d.ts +5 -5
  437. package/dist/theme/defineTheme.js.map +1 -1
  438. package/dist/theme/fonts.js.map +1 -1
  439. package/dist/theme/index.d.ts +12 -12
  440. package/dist/theme/index.js +1 -1
  441. package/dist/theme/selectedTokens.d.ts +11 -0
  442. package/dist/theme/selectedTokens.d.ts.map +1 -0
  443. package/dist/theme/selectedTokens.js +23 -0
  444. package/dist/theme/selectedTokens.js.map +1 -0
  445. package/dist/theme/semanticTokens.d.ts +1 -1
  446. package/dist/theme/semanticTokens.d.ts.map +1 -1
  447. package/dist/theme/semanticTokens.js +10 -0
  448. package/dist/theme/semanticTokens.js.map +1 -1
  449. package/dist/theme/theme.d.ts +2 -2
  450. package/dist/theme/theme.js.map +1 -1
  451. package/dist/theme/toneClass.d.ts +1 -1
  452. package/dist/theme/toneClass.js.map +1 -1
  453. package/dist/theme/tones.d.ts +15 -3
  454. package/dist/theme/tones.d.ts.map +1 -1
  455. package/dist/theme/tones.js +14 -2
  456. package/dist/theme/tones.js.map +1 -1
  457. package/dist/time-input/TimeInput.d.ts +1 -1
  458. package/dist/time-input/TimeInput.js +138 -31
  459. package/dist/time-input/TimeInput.js.map +1 -1
  460. package/dist/toast/Toast.css +180 -19
  461. package/dist/toast/Toast.d.ts +61 -10
  462. package/dist/toast/Toast.d.ts.map +1 -1
  463. package/dist/toast/Toast.js +246 -70
  464. package/dist/toast/Toast.js.map +1 -1
  465. package/dist/toast/Toast.module.js +6 -3
  466. package/dist/toast/Toast.module.js.map +1 -1
  467. package/dist/toast/tokens.d.ts +1 -1
  468. package/dist/toast/tokens.js +1 -1
  469. package/dist/toast/tokens.js.map +1 -1
  470. package/dist/tooltip/Tooltip.css +1 -1
  471. package/dist/tooltip/Tooltip.js +38 -8
  472. package/dist/tooltip/Tooltip.js.map +1 -1
  473. package/dist/tooltip/Tooltip.module.js.map +1 -1
  474. package/dist/tooltip/tokens.d.ts +1 -1
  475. package/dist/tooltip/tokens.js.map +1 -1
  476. package/dist/utils/cx.js.map +1 -1
  477. package/dist/utils/events.d.ts +4 -0
  478. package/dist/utils/events.d.ts.map +1 -0
  479. package/dist/utils/events.js +9 -0
  480. package/dist/utils/events.js.map +1 -0
  481. package/dist/utils/preference.d.ts +7 -0
  482. package/dist/utils/preference.d.ts.map +1 -0
  483. package/dist/utils/preference.js +54 -0
  484. package/dist/utils/preference.js.map +1 -0
  485. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
- import { type ColorDifferenceCheck } from './colorVision';
2
- import { type Theme } from './theme';
1
+ import { type ColorDifferenceCheck } from './colorVision.js';
2
+ import { type Theme } from './theme.js';
3
3
  /** A pair of colors that a theme must keep readable. */
4
4
  export interface ThemeContrastCheck {
5
5
  scheme: 'light' | 'dark';
@@ -32,8 +32,10 @@ export interface ThemeReport {
32
32
  * on the surface, its solid text on the solid background and its hover), and chart colors (3:1
33
33
  * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes
34
34
  * from the default theme and is not set by the theme are skipped, except the surface, which falls
35
- * back to the default one. Values that refer to the theme's palette or tokens with `var()` are
36
- * checked as what they refer to; colors Panneau can't read are listed as unchecked.
35
+ * back to the default one. Selections (`panneau-selected-*`) are checked against the surface, as
36
+ * the accent when the theme doesn't set them. Values that refer to the theme's palette or tokens
37
+ * with `var()` are checked as what they refer to, in tokens and in tones, and translucent colors as
38
+ * they show over what is under them; colors Panneau can't read are listed as unchecked.
37
39
  */
38
40
  export declare function checkTheme(theme: Theme): ThemeReport;
39
41
  //# sourceMappingURL=checkTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkTheme.d.ts","sourceRoot":"","sources":["../../src/theme/checkTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAyB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,SAAS,CAAC;AAGxF,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IACxB,0BAA0B;IAC1B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,sEAAsE;IACtE,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;;OAGG;IACH,gBAAgB,EAAE,CAAC,oBAAoB,GAAG;QAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CAC7E;AA2CD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAgHpD"}
1
+ {"version":3,"file":"checkTheme.d.ts","sourceRoot":"","sources":["../../src/theme/checkTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAyB,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,SAAS,CAAC;AAGxF,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gGAAgG;IAChG,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IACxB,0BAA0B;IAC1B,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC7B,uCAAuC;IACvC,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,sEAAsE;IACtE,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC;;;OAGG;IACH,gBAAgB,EAAE,CAAC,oBAAoB,GAAG;QAAE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;CAC7E;AAkFD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CA+HpD"}
@@ -1,4 +1,4 @@
1
- import { WHITE, contrastRatio, mixColors, parseColor } from "./color.js";
1
+ import { WHITE, contrastRatio, mixColors, parseColor, parseColorOver } from "./color.js";
2
2
  import { MIN_CONTRAST_RATIO, SUBTLE_AMOUNTS, resolveTone } from "./tones.js";
3
3
  import { paletteVariables, resolveReference, themeSurfaces } from "./theme.js";
4
4
  import { checkColorDifferences } from "./colorVision.js";
@@ -19,6 +19,11 @@ var CHART_TOKENS = [
19
19
  "panneau-chart-diverging-negative",
20
20
  "panneau-chart-diverging-positive"
21
21
  ];
22
+ /** Component tokens checked here, and the token each one falls back to when a theme omits it. */
23
+ var FALLBACKS = {
24
+ "panneau-selected-bg": "panneau-color-accent",
25
+ "panneau-selected-text": "panneau-color-accent-text"
26
+ };
22
27
  /** Non-text elements (borders of controls, outlines) need 3:1 (WCAG 2 non-text contrast). */
23
28
  var MIN_NON_TEXT_RATIO = 3;
24
29
  var TOKEN_PAIRS = [
@@ -57,6 +62,42 @@ var TOKEN_PAIRS = [
57
62
  "panneau-color-border-control",
58
63
  "panneau-color-surface",
59
64
  MIN_NON_TEXT_RATIO
65
+ ],
66
+ [
67
+ "selected text on selected",
68
+ "panneau-selected-text",
69
+ "panneau-selected-bg",
70
+ MIN_CONTRAST_RATIO
71
+ ],
72
+ [
73
+ "selected on surface",
74
+ "panneau-selected-bg",
75
+ "panneau-color-surface",
76
+ MIN_NON_TEXT_RATIO
77
+ ],
78
+ [
79
+ "muted tone text on surface",
80
+ "panneau-color-muted",
81
+ "panneau-color-surface",
82
+ MIN_CONTRAST_RATIO
83
+ ],
84
+ [
85
+ "muted tone border on surface",
86
+ "panneau-color-muted-border",
87
+ "panneau-color-surface",
88
+ MIN_NON_TEXT_RATIO
89
+ ],
90
+ [
91
+ "muted tone solid text on solid",
92
+ "panneau-color-muted-solid-text",
93
+ "panneau-color-muted-solid",
94
+ MIN_CONTRAST_RATIO
95
+ ],
96
+ [
97
+ "muted tone solid text on hover",
98
+ "panneau-color-muted-solid-text",
99
+ "panneau-color-muted-solid-hover",
100
+ MIN_CONTRAST_RATIO
60
101
  ]
61
102
  ];
62
103
  /**
@@ -65,8 +106,10 @@ var TOKEN_PAIRS = [
65
106
  * on the surface, its solid text on the solid background and its hover), and chart colors (3:1
66
107
  * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes
67
108
  * from the default theme and is not set by the theme are skipped, except the surface, which falls
68
- * back to the default one. Values that refer to the theme's palette or tokens with `var()` are
69
- * checked as what they refer to; colors Panneau can't read are listed as unchecked.
109
+ * back to the default one. Selections (`panneau-selected-*`) are checked against the surface, as
110
+ * the accent when the theme doesn't set them. Values that refer to the theme's palette or tokens
111
+ * with `var()` are checked as what they refer to, in tokens and in tones, and translucent colors as
112
+ * they show over what is under them; colors Panneau can't read are listed as unchecked.
70
113
  */
71
114
  function checkTheme(theme) {
72
115
  const checks = [];
@@ -80,10 +123,14 @@ function checkTheme(theme) {
80
123
  ...scheme === "dark" ? theme.dark : void 0
81
124
  };
82
125
  const tokens = Object.fromEntries(Object.entries(variables).map(([name, value]) => [name, resolveReference(value, variables)]));
126
+ Object.entries(FALLBACKS).forEach(([name, fallback]) => {
127
+ const value = tokens[fallback];
128
+ if (tokens[name] === void 0 && value !== void 0) tokens[name] = value;
129
+ });
83
130
  const surface = tokens["panneau-color-surface"];
84
131
  const surfaceColor = surface !== void 0 ? parseColor(surface) : DEFAULT_SURFACES[scheme];
85
- const add = (name, foreground, background, minimum, backgroundColor = parseColor(background)) => {
86
- const foregroundColor = parseColor(foreground);
132
+ const add = (name, foreground, background, minimum, backgroundColor = parseColorOver(background, surfaceColor)) => {
133
+ const foregroundColor = parseColorOver(foreground, backgroundColor);
87
134
  checks.push({
88
135
  scheme,
89
136
  name,
@@ -110,10 +157,10 @@ function checkTheme(theme) {
110
157
  })));
111
158
  Object.entries(theme.tones ?? {}).forEach(([tone, toneInput]) => {
112
159
  const input = typeof toneInput === "string" ? resolveReference(toneInput, palette) : toneInput;
113
- const values = resolveTone(input, surfaces)[scheme];
160
+ const values = Object.fromEntries(Object.entries(resolveTone(input, surfaces)[scheme]).map(([key, value]) => [key, resolveReference(value, variables)]));
114
161
  add(`tone ${tone}: text on surface`, values.text, surface ?? (scheme === "light" ? "#ffffff" : "#18181b"), MIN_CONTRAST_RATIO, surfaceColor);
115
162
  const color = typeof input === "string" ? parseColor(input) : null;
116
- const subtleColor = parseColor(values.subtle) ?? (color !== null && surfaceColor !== null ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme]) : null);
163
+ const subtleColor = parseColorOver(values.subtle, surfaceColor) ?? (color !== null && surfaceColor !== null ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme]) : null);
117
164
  add(`tone ${tone}: text on subtle`, values.text, values.subtle, MIN_CONTRAST_RATIO, subtleColor);
118
165
  add(`tone ${tone}: solid text on solid`, values.solidText, values.solid, MIN_CONTRAST_RATIO);
119
166
  add(`tone ${tone}: solid text on hover`, values.solidText, values.solidHover, MIN_CONTRAST_RATIO);
@@ -1 +1 @@
1
- {"version":3,"file":"checkTheme.js","names":[],"sources":["../../src/theme/checkTheme.ts"],"sourcesContent":["import { type Rgb, WHITE, contrastRatio, mixColors, parseColor } from './color';\nimport { type ColorDifferenceCheck, checkColorDifferences } from './colorVision';\nimport { type Theme, paletteVariables, resolveReference, themeSurfaces } from './theme';\nimport { MIN_CONTRAST_RATIO, SUBTLE_AMOUNTS, resolveTone } from './tones';\n\n/** A pair of colors that a theme must keep readable. */\nexport interface ThemeContrastCheck {\n scheme: 'light' | 'dark';\n /** What is checked: `tone signal: text on surface`, `tokens: text on bg`. */\n name: string;\n foreground: string;\n background: string;\n /** The contrast ratio, or `null` when a color can't be read (a CSS variable, `color-mix()`). */\n ratio: number | null;\n minimum: number;\n}\n\nexport interface ThemeReport {\n /** Every pair checked. */\n checks: ThemeContrastCheck[];\n /** Pairs below their minimum ratio. */\n failures: ThemeContrastCheck[];\n /** Pairs with a color Panneau can't read: check them in a browser. */\n unchecked: ThemeContrastCheck[];\n /**\n * Categorical chart colors of the theme that look too alike, for typical vision or with a\n * color vision deficiency.\n */\n colorDifferences: (ColorDifferenceCheck & { scheme: 'light' | 'dark' })[];\n}\n\n/** Surfaces of the default theme, used when a theme doesn't set its own. */\nconst DEFAULT_SURFACES: Record<'light' | 'dark', Rgb> = {\n light: WHITE,\n dark: { r: 24, g: 24, b: 27 },\n};\n\n/** Chart colors that must stand out from the surface: series, the high step and diverging ends. */\nconst CHART_TOKENS = [\n ...Array.from({ length: 8 }, (_, index) => `panneau-chart-categorical-${index + 1}`),\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-positive',\n];\n\n/** Non-text elements (borders of controls, outlines) need 3:1 (WCAG 2 non-text contrast). */\nconst MIN_NON_TEXT_RATIO = 3;\n\nconst TOKEN_PAIRS: [name: string, foreground: string, background: string, minimum: number][] = [\n ['text on bg', 'panneau-color-text', 'panneau-color-bg', MIN_CONTRAST_RATIO],\n ['text on surface', 'panneau-color-text', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'muted text on surface',\n 'panneau-color-text-muted',\n 'panneau-color-surface',\n MIN_CONTRAST_RATIO,\n ],\n ['link on surface', 'panneau-color-link', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'accent text on accent',\n 'panneau-color-accent-text',\n 'panneau-color-accent',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'control border on surface',\n 'panneau-color-border-control',\n 'panneau-color-surface',\n MIN_NON_TEXT_RATIO,\n ],\n];\n\n/**\n * Checks the contrast of a theme, like Bootstrap's `$min-contrast-ratio`, but as a report: text\n * tokens against backgrounds (4.5:1), control borders (3:1), and every tone of the theme (its text\n * on the surface, its solid text on the solid background and its hover), and chart colors (3:1\n * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes\n * from the default theme and is not set by the theme are skipped, except the surface, which falls\n * back to the default one. Values that refer to the theme's palette or tokens with `var()` are\n * checked as what they refer to; colors Panneau can't read are listed as unchecked.\n */\nexport function checkTheme(theme: Theme): ThemeReport {\n const checks: ThemeContrastCheck[] = [];\n const colorDifferences: ThemeReport['colorDifferences'] = [];\n const palette = paletteVariables(theme.palette);\n const surfaces = themeSurfaces(theme);\n (['light', 'dark'] as const).forEach((scheme) => {\n const variables = {\n ...palette,\n ...theme.tokens,\n ...(scheme === 'dark' ? theme.dark : undefined),\n };\n const tokens = Object.fromEntries(\n Object.entries(variables).map(([name, value]) => [\n name,\n resolveReference(value, variables),\n ]),\n );\n const surface = tokens['panneau-color-surface'];\n const surfaceColor = surface !== undefined ? parseColor(surface) : DEFAULT_SURFACES[scheme];\n const add = (\n name: string,\n foreground: string,\n background: string,\n minimum: number,\n backgroundColor: Rgb | null = parseColor(background),\n ) => {\n const foregroundColor = parseColor(foreground);\n checks.push({\n scheme,\n name,\n foreground,\n background,\n ratio:\n foregroundColor !== null && backgroundColor !== null\n ? Math.round(contrastRatio(foregroundColor, backgroundColor) * 100) / 100\n : null,\n minimum,\n });\n };\n TOKEN_PAIRS.forEach(([name, foreground, background, minimum]) => {\n const foregroundValue = tokens[foreground];\n const backgroundValue = tokens[background];\n if (foregroundValue !== undefined && backgroundValue !== undefined) {\n add(`tokens: ${name}`, foregroundValue, backgroundValue, minimum);\n }\n });\n // Chart colors are graphics: 3:1 against the surface, and distinct from each other.\n const surfaceValue = surface ?? (scheme === 'light' ? '#ffffff' : '#18181b');\n CHART_TOKENS.forEach((token) => {\n const value = tokens[token];\n if (value !== undefined) {\n add(\n `chart: ${token.replace('panneau-chart-', '')} on surface`,\n value,\n surfaceValue,\n MIN_NON_TEXT_RATIO,\n surfaceColor,\n );\n }\n });\n const categorical = CHART_TOKENS.filter((token) => token.includes('categorical')).flatMap(\n (token) => (tokens[token] !== undefined ? [tokens[token]] : []),\n );\n colorDifferences.push(\n ...checkColorDifferences(categorical).map((check) => ({ ...check, scheme })),\n );\n Object.entries(theme.tones ?? {}).forEach(([tone, toneInput]) => {\n const input =\n typeof toneInput === 'string' ? resolveReference(toneInput, palette) : toneInput;\n const values = resolveTone(input, surfaces)[scheme];\n add(\n `tone ${tone}: text on surface`,\n values.text,\n surface ?? (scheme === 'light' ? '#ffffff' : '#18181b'),\n MIN_CONTRAST_RATIO,\n surfaceColor,\n );\n // The subtle background of a tone is often mixed with the surface in CSS: compute it\n // against the surface of the scheme when it can't be read directly.\n const color = typeof input === 'string' ? parseColor(input) : null;\n const subtleColor =\n parseColor(values.subtle) ??\n (color !== null && surfaceColor !== null\n ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme])\n : null);\n add(\n `tone ${tone}: text on subtle`,\n values.text,\n values.subtle,\n MIN_CONTRAST_RATIO,\n subtleColor,\n );\n add(\n `tone ${tone}: solid text on solid`,\n values.solidText,\n values.solid,\n MIN_CONTRAST_RATIO,\n );\n add(\n `tone ${tone}: solid text on hover`,\n values.solidText,\n values.solidHover,\n MIN_CONTRAST_RATIO,\n );\n });\n });\n return {\n checks,\n failures: checks.filter((check) => check.ratio !== null && check.ratio < check.minimum),\n unchecked: checks.filter((check) => check.ratio === null),\n colorDifferences,\n };\n}\n"],"mappings":";;;;;;AAgCA,IAAM,mBAAkD;CACpD,OAAO;CACP,MAAM;EAAE,GAAG;EAAI,GAAG;EAAI,GAAG;CAAG;AAChC;;AAGA,IAAM,eAAe;CACjB,GAAG,MAAM,KAAK,EAAE,QAAQ,EAAE,IAAI,GAAG,UAAU,6BAA6B,QAAQ,GAAG;CACnF;CACA;CACA;AAAkC;;AAItC,IAAM,qBAAqB;AAE3B,IAAM,cAAyF;CAC3F;EAAC;EAAc;EAAsB;EAAoB;CAAkB;CAC3E;EAAC;EAAmB;EAAsB;EAAyB;CAAkB;CACrF;EACI;EACA;EACA;EACA;CAAkB;CAEtB;EAAC;EAAmB;EAAsB;EAAyB;CAAkB;CACrF;EACI;EACA;EACA;EACA;CAAkB;CAEtB;EACI;EACA;EACA;EACA;CAAkB;AACrB;;;;;;;;;;AAYL,SAAgB,WAAW,OAA2B;CAClD,MAAM,SAA+B,CAAA;CACrC,MAAM,mBAAoD,CAAA;CAC1D,MAAM,UAAU,iBAAiB,MAAM,OAAO;CAC9C,MAAM,WAAW,cAAc,KAAK;CACpC,CAAE,SAAS,MAAM,CAAC,CAAW,SAAS,WAAW;EAC7C,MAAM,YAAY;GACd,GAAG;GACH,GAAG,MAAM;GACT,GAAI,WAAW,SAAS,MAAM,OAAO,KAAA;EACzC;EACA,MAAM,SAAS,OAAO,YAClB,OAAO,QAAQ,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC7C,MACA,iBAAiB,OAAO,SAAS,CAAC,CACrC,CACL;EACA,MAAM,UAAU,OAAO;EACvB,MAAM,eAAe,YAAY,KAAA,IAAY,WAAW,OAAO,IAAI,iBAAiB;EACpF,MAAM,OACF,MACA,YACA,YACA,SACA,kBAA8B,WAAW,UAAU,MAClD;GACD,MAAM,kBAA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AC9B,UAAU,cAAc,OAAO,eAAe,OAAO,IACrD;GACV,IACI,QAAQ,KAAI,mBACZ,OAAO,MACP,OAAO,QACP,oBACA,WACJ;GACA,IACI,QAAQ,KAAI,wBACZ,OAAO,WACP,OAAO,OACP,kBACJ;GACA,IACI,QAAQ,KAAI,wBACZ,OAAO,WACP,OAAO,YACP,kBACJ;EACJ,CAAC;CACL,CAAC;CACD,OAAO;EACH;EACA,UAAU,OAAO,QAAQ,UAAU,MAAM,UAAU,QAAQ,MAAM,QAAQ,MAAM,OAAO;EACtF,WAAW,OAAO,QAAQ,UAAU,MAAM,UAAU,IAAI;EACxD;CACJ;AACJ"}
1
+ {"version":3,"file":"checkTheme.js","names":["Rgb","WHITE","contrastRatio","mixColors","parseColor","parseColorOver","ColorDifferenceCheck","checkColorDifferences","Theme","paletteVariables","resolveReference","themeSurfaces","MIN_CONTRAST_RATIO","SUBTLE_AMOUNTS","ToneValues","resolveTone","ThemeContrastCheck","scheme","name","foreground","background","ratio","minimum","ThemeReport","checks","failures","unchecked","colorDifferences","DEFAULT_SURFACES","Record","light","dark","r","g","b","CHART_TOKENS","Array","from","length","_","index","FALLBACKS","Readonly","MIN_NON_TEXT_RATIO","TOKEN_PAIRS","checkTheme","theme","palette","surfaces","const","forEach","variables","tokens","undefined","Object","fromEntries","entries","map","value","fallback","surface","surfaceColor","add","backgroundColor","foregroundColor","push","Math","round","foregroundValue","backgroundValue","surfaceValue","token","replace","categorical","filter","includes","flatMap","check","tones","tone","toneInput","input","values","key","text","color","subtleColor","subtle","solidText","solid","solidHover"],"sources":["../../src/theme/checkTheme.ts"],"sourcesContent":["import { type Rgb, WHITE, contrastRatio, mixColors, parseColor, parseColorOver } from './color';\nimport { type ColorDifferenceCheck, checkColorDifferences } from './colorVision';\nimport { type Theme, paletteVariables, resolveReference, themeSurfaces } from './theme';\nimport { MIN_CONTRAST_RATIO, SUBTLE_AMOUNTS, type ToneValues, resolveTone } from './tones';\n\n/** A pair of colors that a theme must keep readable. */\nexport interface ThemeContrastCheck {\n scheme: 'light' | 'dark';\n /** What is checked: `tone signal: text on surface`, `tokens: text on bg`. */\n name: string;\n foreground: string;\n background: string;\n /** The contrast ratio, or `null` when a color can't be read (a CSS variable, `color-mix()`). */\n ratio: number | null;\n minimum: number;\n}\n\nexport interface ThemeReport {\n /** Every pair checked. */\n checks: ThemeContrastCheck[];\n /** Pairs below their minimum ratio. */\n failures: ThemeContrastCheck[];\n /** Pairs with a color Panneau can't read: check them in a browser. */\n unchecked: ThemeContrastCheck[];\n /**\n * Categorical chart colors of the theme that look too alike, for typical vision or with a\n * color vision deficiency.\n */\n colorDifferences: (ColorDifferenceCheck & { scheme: 'light' | 'dark' })[];\n}\n\n/** Surfaces of the default theme, used when a theme doesn't set its own. */\nconst DEFAULT_SURFACES: Record<'light' | 'dark', Rgb> = {\n light: WHITE,\n dark: { r: 24, g: 24, b: 27 },\n};\n\n/** Chart colors that must stand out from the surface: series, the high step and diverging ends. */\nconst CHART_TOKENS = [\n ...Array.from({ length: 8 }, (_, index) => `panneau-chart-categorical-${index + 1}`),\n 'panneau-chart-sequential-5',\n 'panneau-chart-diverging-negative',\n 'panneau-chart-diverging-positive',\n];\n\n/** Component tokens checked here, and the token each one falls back to when a theme omits it. */\nconst FALLBACKS: Readonly<Record<string, string>> = {\n 'panneau-selected-bg': 'panneau-color-accent',\n 'panneau-selected-text': 'panneau-color-accent-text',\n};\n\n/** Non-text elements (borders of controls, outlines) need 3:1 (WCAG 2 non-text contrast). */\nconst MIN_NON_TEXT_RATIO = 3;\n\nconst TOKEN_PAIRS: [name: string, foreground: string, background: string, minimum: number][] = [\n ['text on bg', 'panneau-color-text', 'panneau-color-bg', MIN_CONTRAST_RATIO],\n ['text on surface', 'panneau-color-text', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'muted text on surface',\n 'panneau-color-text-muted',\n 'panneau-color-surface',\n MIN_CONTRAST_RATIO,\n ],\n ['link on surface', 'panneau-color-link', 'panneau-color-surface', MIN_CONTRAST_RATIO],\n [\n 'accent text on accent',\n 'panneau-color-accent-text',\n 'panneau-color-accent',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'control border on surface',\n 'panneau-color-border-control',\n 'panneau-color-surface',\n MIN_NON_TEXT_RATIO,\n ],\n // Checked boxes, selected rows and the current tab: the accent unless the theme sets them.\n [\n 'selected text on selected',\n 'panneau-selected-text',\n 'panneau-selected-bg',\n MIN_CONTRAST_RATIO,\n ],\n ['selected on surface', 'panneau-selected-bg', 'panneau-color-surface', MIN_NON_TEXT_RATIO],\n // The muted tone has no fill: its text and its outline sit on the surface.\n [\n 'muted tone text on surface',\n 'panneau-color-muted',\n 'panneau-color-surface',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'muted tone border on surface',\n 'panneau-color-muted-border',\n 'panneau-color-surface',\n MIN_NON_TEXT_RATIO,\n ],\n [\n 'muted tone solid text on solid',\n 'panneau-color-muted-solid-text',\n 'panneau-color-muted-solid',\n MIN_CONTRAST_RATIO,\n ],\n [\n 'muted tone solid text on hover',\n 'panneau-color-muted-solid-text',\n 'panneau-color-muted-solid-hover',\n MIN_CONTRAST_RATIO,\n ],\n];\n\n/**\n * Checks the contrast of a theme, like Bootstrap's `$min-contrast-ratio`, but as a report: text\n * tokens against backgrounds (4.5:1), control borders (3:1), and every tone of the theme (its text\n * on the surface, its solid text on the solid background and its hover), and chart colors (3:1\n * against the surface, and categorical colors distinct with color vision deficiencies). Pairs where a color comes\n * from the default theme and is not set by the theme are skipped, except the surface, which falls\n * back to the default one. Selections (`panneau-selected-*`) are checked against the surface, as\n * the accent when the theme doesn't set them. Values that refer to the theme's palette or tokens\n * with `var()` are checked as what they refer to, in tokens and in tones, and translucent colors as\n * they show over what is under them; colors Panneau can't read are listed as unchecked.\n */\nexport function checkTheme(theme: Theme): ThemeReport {\n const checks: ThemeContrastCheck[] = [];\n const colorDifferences: ThemeReport['colorDifferences'] = [];\n const palette = paletteVariables(theme.palette);\n const surfaces = themeSurfaces(theme);\n (['light', 'dark'] as const).forEach((scheme) => {\n const variables = {\n ...palette,\n ...theme.tokens,\n ...(scheme === 'dark' ? theme.dark : undefined),\n };\n const tokens: Record<string, string> = Object.fromEntries(\n Object.entries(variables).map(([name, value]) => [\n name,\n resolveReference(value, variables),\n ]),\n );\n // Tokens that default to another one, as their fallback in the CSS does.\n Object.entries(FALLBACKS).forEach(([name, fallback]) => {\n const value = tokens[fallback];\n if (tokens[name] === undefined && value !== undefined) {\n tokens[name] = value;\n }\n });\n const surface = tokens['panneau-color-surface'];\n const surfaceColor = surface !== undefined ? parseColor(surface) : DEFAULT_SURFACES[scheme];\n const add = (\n name: string,\n foreground: string,\n background: string,\n minimum: number,\n // A translucent background shows the surface through it, and a translucent\n // foreground shows the background.\n backgroundColor: Rgb | null = parseColorOver(background, surfaceColor),\n ) => {\n const foregroundColor = parseColorOver(foreground, backgroundColor);\n checks.push({\n scheme,\n name,\n foreground,\n background,\n ratio:\n foregroundColor !== null && backgroundColor !== null\n ? Math.round(contrastRatio(foregroundColor, backgroundColor) * 100) / 100\n : null,\n minimum,\n });\n };\n TOKEN_PAIRS.forEach(([name, foreground, background, minimum]) => {\n const foregroundValue = tokens[foreground];\n const backgroundValue = tokens[background];\n if (foregroundValue !== undefined && backgroundValue !== undefined) {\n add(`tokens: ${name}`, foregroundValue, backgroundValue, minimum);\n }\n });\n // Chart colors are graphics: 3:1 against the surface, and distinct from each other.\n const surfaceValue = surface ?? (scheme === 'light' ? '#ffffff' : '#18181b');\n CHART_TOKENS.forEach((token) => {\n const value = tokens[token];\n if (value !== undefined) {\n add(\n `chart: ${token.replace('panneau-chart-', '')} on surface`,\n value,\n surfaceValue,\n MIN_NON_TEXT_RATIO,\n surfaceColor,\n );\n }\n });\n const categorical = CHART_TOKENS.filter((token) => token.includes('categorical')).flatMap(\n (token) => (tokens[token] !== undefined ? [tokens[token]] : []),\n );\n colorDifferences.push(\n ...checkColorDifferences(categorical).map((check) => ({ ...check, scheme })),\n );\n Object.entries(theme.tones ?? {}).forEach(([tone, toneInput]) => {\n const input =\n typeof toneInput === 'string' ? resolveReference(toneInput, palette) : toneInput;\n // Values given one by one can refer to the palette or to tokens, like tokens can.\n const values = Object.fromEntries(\n Object.entries(resolveTone(input, surfaces)[scheme]).map(([key, value]) => [\n key,\n resolveReference(value, variables),\n ]),\n ) as ToneValues;\n add(\n `tone ${tone}: text on surface`,\n values.text,\n surface ?? (scheme === 'light' ? '#ffffff' : '#18181b'),\n MIN_CONTRAST_RATIO,\n surfaceColor,\n );\n // The subtle background of a tone is often mixed with the surface in CSS: compute it\n // against the surface of the scheme when it can't be read directly.\n const color = typeof input === 'string' ? parseColor(input) : null;\n const subtleColor =\n parseColorOver(values.subtle, surfaceColor) ??\n (color !== null && surfaceColor !== null\n ? mixColors(surfaceColor, color, SUBTLE_AMOUNTS[scheme])\n : null);\n add(\n `tone ${tone}: text on subtle`,\n values.text,\n values.subtle,\n MIN_CONTRAST_RATIO,\n subtleColor,\n );\n add(\n `tone ${tone}: solid text on solid`,\n values.solidText,\n values.solid,\n MIN_CONTRAST_RATIO,\n );\n add(\n `tone ${tone}: solid text on hover`,\n values.solidText,\n values.solidHover,\n MIN_CONTRAST_RATIO,\n );\n });\n });\n return {\n checks,\n failures: checks.filter((check) => check.ratio !== null && check.ratio < check.minimum),\n unchecked: checks.filter((check) => check.ratio === null),\n colorDifferences,\n };\n}\n"],"mappings":";;;;;;AAgCA,IAAM4B,mBAAkD;CACpDE,OAAO7B;CACP8B,MAAM;EAAEC,GAAG;EAAIC,GAAG;EAAIC,GAAG;CAAG;AAChC;;AAGA,IAAMC,eAAe;CACjB,GAAGC,MAAMC,KAAK,EAAEC,QAAQ,EAAE,IAAIC,GAAGC,UAAU,6BAA6BA,QAAQ,GAAG;CACnF;CACA;CACA;AAAkC;;AAItC,IAAMC,YAA8C;CAChD,uBAAuB;CACvB,yBAAyB;AAC7B;;AAGA,IAAME,qBAAqB;AAE3B,IAAMC,cAAyF;CAC3F;EAAC;EAAc;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AAIiC;GAE3E,MAAME,SAAS5B,OAAOC,YAClBD,OAAOE,QAAQzC,YAAYkE,OAAOjC,QAAQ,CAAC,CAAC/B,OAAO,CAAC,CAACwC,KAAK,CAAC0B,KAAKzB,WAAW,CACvEyB,KACAzE,iBAAiBgD,OAAOP,SAAS,CAAC,CACrC,CACL;GACAW,IACI,QAAQiB,KAAI,oBACZG,OAAOE,MACPxB,YAAY3C,WAAW,UAAU,YAAY,YAC7CL,oBACAiD,YACJ;GAGA,MAAMwB,QAAQ,OAAOJ,UAAU,WAAW7E,WAAW6E,KAAK,IAAI;GAC9D,MAAMK,cACFjF,eAAe6E,OAAOK,QAAQ1B,YAAY,MACzCwB,UAAU,QAAQxB,iBAAiB,OAC9B1D,UAAU0D,cAAcwB,OAAOxE,eAAeI,OAAO,IACrD;GACV6C,IACI,QAAQiB,KAAI,mBACZG,OAAOE,MACPF,OAAOK,QACP3E,oBACA0E,WACJ;GACAxB,IACI,QAAQiB,KAAI,wBACZG,OAAOM,WACPN,OAAOO,OACP7E,kBACJ;GACAkD,IACI,QAAQiB,KAAI,wBACZG,OAAOM,WACPN,OAAOQ,YACP9E,kBACJ;EACJ,CAAC;CACL,CAAC;CACD,OAAO;EACHY;EACAC,UAAUD,OAAOkD,QAAQG,UAAUA,MAAMxD,UAAU,QAAQwD,MAAMxD,QAAQwD,MAAMvD,OAAO;EACtFI,WAAWF,OAAOkD,QAAQG,UAAUA,MAAMxD,UAAU,IAAI;EACxDM;CACJ;AACJ"}
@@ -1,5 +1,5 @@
1
- import { type ThemeReport } from './checkTheme';
2
- import type { Theme } from './theme';
1
+ import { type ThemeReport } from './checkTheme.js';
2
+ import type { Theme } from './theme.js';
3
3
  /** Loads a module from its URL: `import()`, replaced in tests. */
4
4
  export type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;
5
5
  /** Reads a theme from a JSON file or from an export of a module. */
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../../src/theme/cli.ts"],"sourcesContent":["// The `panneau-check-theme` command, for Node only: it is not part of the exports.\n/// <reference types=\"node\" />\nimport { readFile } from 'node:fs/promises';\nimport { extname, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { type ThemeReport, checkTheme } from './checkTheme';\nimport type { Theme } from './theme';\n\nconst USAGE = `Usage: panneau-check-theme <file> [--export <name>] [--json]\n\nChecks the contrast of a theme, and the differences between its chart colors with color vision\ndeficiencies. <file> is a JSON file (the Theme schema of @panneau/protocol), or a module whose\ndefault export, or the export named by --export, is a theme. Exits with 1 when a check fails.`;\n\nfunction isTheme(value: unknown): value is Theme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tokens' in value &&\n typeof value.tokens === 'object' &&\n value.tokens !== null\n );\n}\n\n/** Loads a module from its URL: `import()`, replaced in tests. */\nexport type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: ModuleImporter = (url) => import(url) as Promise<Record<string, unknown>>;\n\n/** Reads a theme from a JSON file or from an export of a module. */\nexport async function loadTheme(\n path: string,\n exportName = 'default',\n load: ModuleImporter = importModule,\n): Promise<Theme> {\n const file = resolve(path);\n const value: unknown =\n extname(file) === '.json'\n ? JSON.parse(await readFile(file, 'utf8'))\n : (await load(pathToFileURL(file).href))[exportName];\n if (!isTheme(value)) {\n throw new Error(\n extname(file) === '.json'\n ? `${path} is not a theme: it has no tokens.`\n : `The export \"${exportName}\" of ${path} is not a theme.`,\n );\n }\n return value;\n}\n\n/** A report as text, one line per check that failed or that Panneau couldn't read. */\nexport function formatThemeReport(report: ThemeReport, label = 'Theme'): string {\n const lines = [\n `${label}: ${report.checks.length} contrast checks, ${report.failures.length} failed, ` +\n `${report.unchecked.length} unchecked, ${report.colorDifferences.length} similar chart colors.`,\n ];\n report.failures.forEach((check) => {\n lines.push(\n ` fail ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background}, ${String(check.ratio)}:1 < ${String(check.minimum)}:1`,\n );\n });\n report.colorDifferences.forEach((check) => {\n lines.push(\n ` similar ${check.scheme.padEnd(5)} chart colors ${check.first} and ` +\n `${check.second} with ${check.vision}: ${String(check.difference)} < ${String(check.minimum)}`,\n );\n });\n report.unchecked.forEach((check) => {\n lines.push(\n ` unchecked ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background} (check it in a browser)`,\n );\n });\n return lines.join('\\n');\n}\n\n/** Runs `panneau-check-theme` with its arguments, and returns the exit code. */\nexport async function runCheckTheme(\n args: readonly string[],\n output: { log: (text: string) => void; error: (text: string) => void } = console,\n load: ModuleImporter = importModule,\n): Promise<number> {\n const json = args.includes('--json');\n const exportIndex = args.indexOf('--export');\n const exportName = exportIndex >= 0 ? args[exportIndex + 1] : undefined;\n const files = args.filter(\n (arg, index) => !arg.startsWith('--') && (exportIndex < 0 || index !== exportIndex + 1),\n );\n const [file] = files;\n if (file === undefined || files.length > 1 || args.includes('--help')) {\n output.error(USAGE);\n return args.includes('--help') ? 0 : 2;\n }\n let theme: Theme;\n try {\n theme = await loadTheme(file, exportName, load);\n } catch (error) {\n output.error(error instanceof Error ? error.message : String(error));\n return 2;\n }\n const report = checkTheme(theme);\n output.log(json ? JSON.stringify(report, null, 2) : formatThemeReport(report, theme.label));\n return report.failures.length > 0 || report.colorDifferences.length > 0 ? 1 : 0;\n}\n"],"mappings":";;;;;AASA,IAAM,QAAQ;;;;;AAMd,SAAS,QAAQ,OAAgC;CAC7C,OACI,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAO,MAAM,WAAW,YACxB,MAAM,WAAW;AAEzB;AAKA,IAAM,gBAAgC,QAAQ,OAAO;;AAGrD,eAAsB,UAClB,MACA,aAAa,WACb,OAAuB,cACT;CACd,MAAM,OAAO,QAAQ,IAAI;CACzB,MAAM,QACF,QAAQ,IAAI,MAAM,UACZ,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC,KACtC,MAAM,KAAK,cAAc,IAAI,CAAC,CAAC,IAAI,EAAA,C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Ac,KAAK,UAAU,cAAc,EACzF;CACA,MAAM,CAAC,QAAQ;CACf,IAAI,SAAS,KAAA,KAAa,MAAM,SAAS,KAAK,KAAK,SAAS,QAAQ,GAAG;EACnE,OAAO,MAAM,KAAK;EAClB,OAAO,KAAK,SAAS,QAAQ,IAAI,IAAI;CACzC;CACA,IAAI;CACJ,IAAI;EACA,QAAQ,MAAM,UAAU,MAAM,YAAY,IAAI;CAClD,SAAS,OAAO;EACZ,OAAO,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EACnE,OAAO;CACX;CACA,MAAM,SAAS,WAAW,KAAK;CAC/B,OAAO,IAAI,OAAO,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,kBAAkB,QAAQ,MAAM,KAAK,CAAC;CAC1F,OAAO,OAAO,SAAS,SAAS,KAAK,OAAO,iBAAiB,SAAS,IAAI,IAAI;AAClF"}
1
+ {"version":3,"file":"cli.js","names":["readFile","extname","resolve","pathToFileURL","ThemeReport","checkTheme","Theme","USAGE","isTheme","value","tokens","ModuleImporter","url","Promise","Record","importModule","loadTheme","path","exportName","load","file","JSON","parse","href","Error","formatThemeReport","report","label","lines","checks","length","failures","unchecked","colorDifferences","forEach","check","push","scheme","padEnd","name","foreground","background","String","ratio","minimum","first","second","vision","difference","join","runCheckTheme","args","output","log","text","error","console","json","includes","exportIndex","indexOf","undefined","files","filter","arg","index","startsWith","theme","message","stringify"],"sources":["../../src/theme/cli.ts"],"sourcesContent":["// The `panneau-check-theme` command, for Node only: it is not part of the exports.\n/// <reference types=\"node\" />\nimport { readFile } from 'node:fs/promises';\nimport { extname, resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\n\nimport { type ThemeReport, checkTheme } from './checkTheme';\nimport type { Theme } from './theme';\n\nconst USAGE = `Usage: panneau-check-theme <file> [--export <name>] [--json]\n\nChecks the contrast of a theme, and the differences between its chart colors with color vision\ndeficiencies. <file> is a JSON file (the Theme schema of @panneau/protocol), or a module whose\ndefault export, or the export named by --export, is a theme. Exits with 1 when a check fails.`;\n\nfunction isTheme(value: unknown): value is Theme {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'tokens' in value &&\n typeof value.tokens === 'object' &&\n value.tokens !== null\n );\n}\n\n/** Loads a module from its URL: `import()`, replaced in tests. */\nexport type ModuleImporter = (url: string) => Promise<Record<string, unknown>>;\n\nconst importModule: ModuleImporter = (url) => import(url) as Promise<Record<string, unknown>>;\n\n/** Reads a theme from a JSON file or from an export of a module. */\nexport async function loadTheme(\n path: string,\n exportName = 'default',\n load: ModuleImporter = importModule,\n): Promise<Theme> {\n const file = resolve(path);\n const value: unknown =\n extname(file) === '.json'\n ? JSON.parse(await readFile(file, 'utf8'))\n : (await load(pathToFileURL(file).href))[exportName];\n if (!isTheme(value)) {\n throw new Error(\n extname(file) === '.json'\n ? `${path} is not a theme: it has no tokens.`\n : `The export \"${exportName}\" of ${path} is not a theme.`,\n );\n }\n return value;\n}\n\n/** A report as text, one line per check that failed or that Panneau couldn't read. */\nexport function formatThemeReport(report: ThemeReport, label = 'Theme'): string {\n const lines = [\n `${label}: ${report.checks.length} contrast checks, ${report.failures.length} failed, ` +\n `${report.unchecked.length} unchecked, ${report.colorDifferences.length} similar chart colors.`,\n ];\n report.failures.forEach((check) => {\n lines.push(\n ` fail ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background}, ${String(check.ratio)}:1 < ${String(check.minimum)}:1`,\n );\n });\n report.colorDifferences.forEach((check) => {\n lines.push(\n ` similar ${check.scheme.padEnd(5)} chart colors ${check.first} and ` +\n `${check.second} with ${check.vision}: ${String(check.difference)} < ${String(check.minimum)}`,\n );\n });\n report.unchecked.forEach((check) => {\n lines.push(\n ` unchecked ${check.scheme.padEnd(5)} ${check.name}: ${check.foreground} on ` +\n `${check.background} (check it in a browser)`,\n );\n });\n return lines.join('\\n');\n}\n\n/** Runs `panneau-check-theme` with its arguments, and returns the exit code. */\nexport async function runCheckTheme(\n args: readonly string[],\n output: { log: (text: string) => void; error: (text: string) => void } = console,\n load: ModuleImporter = importModule,\n): Promise<number> {\n const json = args.includes('--json');\n const exportIndex = args.indexOf('--export');\n const exportName = exportIndex >= 0 ? args[exportIndex + 1] : undefined;\n const files = args.filter(\n (arg, index) => !arg.startsWith('--') && (exportIndex < 0 || index !== exportIndex + 1),\n );\n const [file] = files;\n if (file === undefined || files.length > 1 || args.includes('--help')) {\n output.error(USAGE);\n return args.includes('--help') ? 0 : 2;\n }\n let theme: Theme;\n try {\n theme = await loadTheme(file, exportName, load);\n } catch (error) {\n output.error(error instanceof Error ? error.message : String(error));\n return 2;\n }\n const report = checkTheme(theme);\n output.log(json ? JSON.stringify(report, null, 2) : formatThemeReport(report, theme.label));\n return report.failures.length > 0 || report.colorDifferences.length > 0 ? 1 : 0;\n}\n"],"mappings":";;;;;AASA,IAAMO,QAAQ;;;;;AAMd,SAASC,QAAQC,OAAgC;CAC7C,OACI,OAAOA,UAAU,YACjBA,UAAU,QACV,YAAYA,SACZ,OAAOA,MAAMC,WAAW,YACxBD,MAAMC,WAAW;AAEzB;AAKA,IAAMK,gBAAgCH,QAAQ,OAAOA;;AAGrD,eAAsBI,UAClBC,MACAC,aAAa,WACbC,OAAuBJ,cACT;CACd,MAAMK,OAAOlB,QAAQe,IAAI;CACzB,MAAMR,QACFR,QAAQmB,IAAI,MAAM,UACZC,KAAKC,MAAM,MAAMtB,SAASoB,MAAM,MAAM,CAAC,KACtC,MAAMD,KAAKhB,cAAciB,IAAI,CAAC,CAACG,IAAI,EAAA,CAAGL;CACjD,IAAI,CAACV,QAAQC,KAAK,GACd,MAAM,IAAIe,MACNvB,QAAQmB,IAAI,MAAM,UACZ,GAAGH,KAAI,sCACP,eAAeC,WAAU,OAAQD,KAAI,iBAC/C;CAEJ,OAAOR;AACX;;AAGA,SAAgBgB,kBAAkBC,QAAqBC,QAAQ,SAAiB;CAC5E,MAAMC,QAAQ,CACV,GAAGD,MAAK,IAAKD,OAAOG,OAAOC,O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GAAG;EACnEN,OAAOG,MAAMhD,KAAK;EAClB,OAAO4C,KAAKO,SAAS,QAAQ,IAAI,IAAI;CACzC;CACA,IAAIS;CACJ,IAAI;EACAA,QAAQ,MAAMnD,UAAUI,MAAMF,YAAYC,IAAI;CAClD,SAASoC,OAAO;EACZH,OAAOG,MAAMA,iBAAiB/B,QAAQ+B,MAAMa,UAAU1B,OAAOa,KAAK,CAAC;EACnE,OAAO;CACX;CACA,MAAM7B,SAASrB,WAAW8D,KAAK;CAC/Bf,OAAOC,IAAII,OAAOpC,KAAKgD,UAAU3C,QAAQ,MAAM,CAAC,IAAID,kBAAkBC,QAAQyC,MAAMxC,KAAK,CAAC;CAC1F,OAAOD,OAAOK,SAASD,SAAS,KAAKJ,OAAOO,iBAAiBH,SAAS,IAAI,IAAI;AAClF"}
@@ -9,6 +9,19 @@ export interface Rgb {
9
9
  * variable, a named color, `color-mix()`), which Panneau can't compute with.
10
10
  */
11
11
  export declare function parseColor(value: string): Rgb | null;
12
+ /**
13
+ * Reads a color like `parseColor()`, with its opacity: `rgb(0 0 0 / 0.45)`, `rgba(0, 0, 0, 45%)`,
14
+ * `#00000073`. The opacity is 1 for opaque colors.
15
+ */
16
+ export declare function parseColorWithAlpha(value: string): {
17
+ color: Rgb;
18
+ alpha: number;
19
+ } | null;
20
+ /**
21
+ * Reads a color as it shows over another one: a translucent color is blended with what is under
22
+ * it. Returns `null` for a color Panneau can't read, or a translucent one over an unknown color.
23
+ */
24
+ export declare function parseColorOver(value: string, under: Rgb | null): Rgb | null;
12
25
  /** A color as `#rrggbb`. */
13
26
  export declare function toHex({ r, g, b }: Rgb): string;
14
27
  /** Mixes two colors in sRGB, like `color-mix(in srgb, a, b <amount>)`: 0 gives `a`, 1 gives `b`. */
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/theme/color.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,WAAW,GAAG;IAChB,CAAC,EAAE,MAAM,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B,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqBvF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,CAS3E;AAED,4BAA4B;AAC5B,wBAAgB,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAI9C;AAED,oGAAoG;AACpG,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CAM7D;AAOD,gDAAgD;AAChD,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,GAAG,MAAM,CAElD;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,MAAM,CAGpD;AAED,eAAO,MAAM,KAAK,EAAE,GAAgC,CAAC;AACrD,eAAO,MAAM,KAAK,EAAE,GAA0B,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,CAY9E;AAED,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CAEtD"}
@@ -31,6 +31,46 @@ function parseColor(value) {
31
31
  }
32
32
  return null;
33
33
  }
34
+ var HEX_ALPHA = /^#([0-9a-f]{4}|[0-9a-f]{8})$/i;
35
+ var ALPHA = /^rgba?\(.*[,/]\s*([\d.]+)(%?)\s*\)$/i;
36
+ /**
37
+ * Reads a color like `parseColor()`, with its opacity: `rgb(0 0 0 / 0.45)`, `rgba(0, 0, 0, 45%)`,
38
+ * `#00000073`. The opacity is 1 for opaque colors.
39
+ */
40
+ function parseColorWithAlpha(value) {
41
+ const color = value.trim();
42
+ const hex = HEX_ALPHA.exec(color);
43
+ if (hex?.[1] !== void 0) {
44
+ const digits = hex[1].length === 4 ? [...hex[1]].map((digit) => digit + digit).join("") : hex[1];
45
+ const rgb = parseColor(`#${digits.slice(0, 6)}`);
46
+ return rgb !== null ? {
47
+ color: rgb,
48
+ alpha: Number.parseInt(digits.slice(6, 8), 16) / 255
49
+ } : null;
50
+ }
51
+ const rgb = parseColor(color);
52
+ if (rgb === null) return null;
53
+ const alpha = ALPHA.exec(color);
54
+ if (alpha?.[1] === void 0) return {
55
+ color: rgb,
56
+ alpha: 1
57
+ };
58
+ const amount = Number(alpha[1]) / (alpha[2] === "%" ? 100 : 1);
59
+ return {
60
+ color: rgb,
61
+ alpha: Math.min(1, Math.max(0, amount))
62
+ };
63
+ }
64
+ /**
65
+ * Reads a color as it shows over another one: a translucent color is blended with what is under
66
+ * it. Returns `null` for a color Panneau can't read, or a translucent one over an unknown color.
67
+ */
68
+ function parseColorOver(value, under) {
69
+ const parsed = parseColorWithAlpha(value);
70
+ if (parsed === null) return null;
71
+ if (parsed.alpha >= 1) return parsed.color;
72
+ return under !== null ? mixColors(under, parsed.color, parsed.alpha) : null;
73
+ }
34
74
  /** A color as `#rrggbb`. */
35
75
  function toHex({ r, g, b }) {
36
76
  return `#${[
@@ -89,6 +129,6 @@ function readableTextColor(background) {
89
129
  return contrastRatio(WHITE, background) >= contrastRatio(BLACK, background) ? WHITE : BLACK;
90
130
  }
91
131
  //#endregion
92
- export { BLACK, WHITE, contrastRatio, ensureContrast, luminance, mixColors, parseColor, readableTextColor, toHex };
132
+ export { BLACK, WHITE, contrastRatio, ensureContrast, luminance, mixColors, parseColor, parseColorOver, parseColorWithAlpha, readableTextColor, toHex };
93
133
 
94
134
  //# sourceMappingURL=color.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"color.js","names":[],"sources":["../../src/theme/color.ts"],"sourcesContent":["/** An sRGB color, with channels from 0 to 255. */\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\nconst HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\nconst RGB =\n /^rgba?\\(\\s*(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)\\s*(?:[,/]\\s*[\\d.]+%?\\s*)?\\)$/i;\n\n/**\n * Reads a hex (`#05f`, `#0055ff`) or `rgb()` color. Returns `null` for anything else (a CSS\n * variable, a named color, `color-mix()`), which Panneau can't compute with.\n */\nexport function parseColor(value: string): Rgb | null {\n const color = value.trim();\n const hex = HEX.exec(color);\n if (hex?.[1] !== undefined) {\n const digits =\n hex[1].length === 3 ? [...hex[1]].map((digit) => digit + digit).join('') : hex[1];\n return {\n r: Number.parseInt(digits.slice(0, 2), 16),\n g: Number.parseInt(digits.slice(2, 4), 16),\n b: Number.parseInt(digits.slice(4, 6), 16),\n };\n }\n const rgb = RGB.exec(color);\n if (rgb !== null) {\n const [r, g, b] = [rgb[1], rgb[2], rgb[3]].map((channel) =>\n Math.min(255, Math.max(0, Number(channel))),\n );\n return { r: r ?? 0, g: g ?? 0, b: b ?? 0 };\n }\n return null;\n}\n\n/** A color as `#rrggbb`. */\nexport function toHex({ r, g, b }: Rgb): string {\n return `#${[r, g, b]\n .map((channel) => Math.round(channel).toString(16).padStart(2, '0'))\n .join('')}`;\n}\n\n/** Mixes two colors in sRGB, like `color-mix(in srgb, a, b <amount>)`: 0 gives `a`, 1 gives `b`. */\nexport function mixColors(a: Rgb, b: Rgb, amount: number): Rgb {\n return {\n r: a.r + (b.r - a.r) * amount,\n g: a.g + (b.g - a.g) * amount,\n b: a.b + (b.b - a.b) * amount,\n };\n}\n\nfunction linear(channel: number): number {\n const value = channel / 255;\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n\n/** Relative luminance, as defined by WCAG 2. */\nexport function luminance({ r, g, b }: Rgb): number {\n return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);\n}\n\n/** Contrast ratio between two colors, from 1 to 21 (WCAG 2). */\nexport function contrastRatio(a: Rgb, b: Rgb): number {\n const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n return (light + 0.05) / (dark + 0.05);\n}\n\nexport const WHITE: Rgb = { r: 255, g: 255, b: 255 };\nexport const BLACK: Rgb = { r: 0, g: 0, b: 0 };\n\n/**\n * The closest color to `color` that reaches `ratio` against `background`, by mixing it with black\n * or white (whichever moves away from the background), like Bootstrap's shade and tint. Returns\n * the color itself when it already passes.\n */\nexport function ensureContrast(color: Rgb, background: Rgb, ratio: number): Rgb {\n if (contrastRatio(color, background) >= ratio) {\n return color;\n }\n const target = luminance(background) > 0.18 ? BLACK : WHITE;\n for (let step = 1; step <= 20; step += 1) {\n const mixed = mixColors(color, target, step / 20);\n if (contrastRatio(mixed, background) >= ratio) {\n return mixed;\n }\n }\n return target;\n}\n\n/** White or black, whichever reads better on `background`, like Bootstrap's `color-contrast()`. */\nexport function readableTextColor(background: Rgb): Rgb {\n return contrastRatio(WHITE, background) >= contrastRatio(BLACK, background) ? WHITE : BLACK;\n}\n"],"mappings":";AAOA,IAAM,MAAM;AACZ,IAAM,MACF;;;;;AAMJ,SAAgB,WAAW,OAA2B;CAClD,MAAM,QAAQ,MAAM,KAAK;CACzB,MAAM,MAAM,IAAI,KAAK,KAAK;CAC1B,IAAI,MAAM,OAAO,KAAA,GAAW;EACxB,MAAM,SACF,IAAI,EAAE,CAAC,WAAW,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,KAAK,UAAU,QAAQ,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI;EACnF,OAAO;GACH,GAAG,OAAO,SAAS,OAAO,MAAM,GAAG,CAAC,GAAG,EAAE;GACzC,GAAG,OAAO,SAAS,OAAO,MAAM,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AAM,IAAI,CAAC;CACvE,QAAQ,QAAQ,QAAS,OAAO;AACpC;AAEA,IAAa,QAAa;CAAE,GAAG;CAAK,GAAG;CAAK,GAAG;AAAI;AACnD,IAAa,QAAa;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;AAAE;;;;;;AAO7C,SAAgB,eAAe,OAAY,YAAiB,OAAoB;CAC5E,IAAI,cAAc,OAAO,UAAU,KAAK,OACpC,OAAO;CAEX,MAAM,SAAS,UAAU,UAAU,IAAI,MAAO,QAAQ;CACtD,KAAK,IAAI,OAAO,GAAG,QAAQ,IAAI,QAAQ,GAAG;EACtC,MAAM,QAAQ,UAAU,OAAO,QAAQ,OAAO,EAAE;EAChD,IAAI,cAAc,OAAO,UAAU,KAAK,OACpC,OAAO;CAEf;CACA,OAAO;AACX;;AAGA,SAAgB,kBAAkB,YAAsB;CACpD,OAAO,cAAc,OAAO,UAAU,KAAK,cAAc,OAAO,UAAU,IAAI,QAAQ;AAC1F"}
1
+ {"version":3,"file":"color.js","names":["Rgb","r","g","b","HEX","RGB","parseColor","value","color","trim","hex","exec","undefined","digits","length","map","digit","join","Number","parseInt","slice","rgb","channel","Math","min","max","HEX_ALPHA","ALPHA","parseColorWithAlpha","alpha","amount","parseColorOver","under","parsed","mixColors","toHex","round","toString","padStart","a","linear","luminance","contrastRatio","light","dark","sort","x","y","WHITE","BLACK","ensureContrast","background","ratio","target","step","mixed","readableTextColor"],"sources":["../../src/theme/color.ts"],"sourcesContent":["/** An sRGB color, with channels from 0 to 255. */\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n}\n\nconst HEX = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;\nconst RGB =\n /^rgba?\\(\\s*(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)[\\s,]+(\\d+(?:\\.\\d+)?)\\s*(?:[,/]\\s*[\\d.]+%?\\s*)?\\)$/i;\n\n/**\n * Reads a hex (`#05f`, `#0055ff`) or `rgb()` color. Returns `null` for anything else (a CSS\n * variable, a named color, `color-mix()`), which Panneau can't compute with.\n */\nexport function parseColor(value: string): Rgb | null {\n const color = value.trim();\n const hex = HEX.exec(color);\n if (hex?.[1] !== undefined) {\n const digits =\n hex[1].length === 3 ? [...hex[1]].map((digit) => digit + digit).join('') : hex[1];\n return {\n r: Number.parseInt(digits.slice(0, 2), 16),\n g: Number.parseInt(digits.slice(2, 4), 16),\n b: Number.parseInt(digits.slice(4, 6), 16),\n };\n }\n const rgb = RGB.exec(color);\n if (rgb !== null) {\n const [r, g, b] = [rgb[1], rgb[2], rgb[3]].map((channel) =>\n Math.min(255, Math.max(0, Number(channel))),\n );\n return { r: r ?? 0, g: g ?? 0, b: b ?? 0 };\n }\n return null;\n}\n\nconst HEX_ALPHA = /^#([0-9a-f]{4}|[0-9a-f]{8})$/i;\nconst ALPHA = /^rgba?\\(.*[,/]\\s*([\\d.]+)(%?)\\s*\\)$/i;\n\n/**\n * Reads a color like `parseColor()`, with its opacity: `rgb(0 0 0 / 0.45)`, `rgba(0, 0, 0, 45%)`,\n * `#00000073`. The opacity is 1 for opaque colors.\n */\nexport function parseColorWithAlpha(value: string): { color: Rgb; alpha: number } | null {\n const color = value.trim();\n const hex = HEX_ALPHA.exec(color);\n if (hex?.[1] !== undefined) {\n const digits =\n hex[1].length === 4 ? [...hex[1]].map((digit) => digit + digit).join('') : hex[1];\n const rgb = parseColor(`#${digits.slice(0, 6)}`);\n return rgb !== null\n ? { color: rgb, alpha: Number.parseInt(digits.slice(6, 8), 16) / 255 }\n : null;\n }\n const rgb = parseColor(color);\n if (rgb === null) {\n return null;\n }\n const alpha = ALPHA.exec(color);\n if (alpha?.[1] === undefined) {\n return { color: rgb, alpha: 1 };\n }\n const amount = Number(alpha[1]) / (alpha[2] === '%' ? 100 : 1);\n return { color: rgb, alpha: Math.min(1, Math.max(0, amount)) };\n}\n\n/**\n * Reads a color as it shows over another one: a translucent color is blended with what is under\n * it. Returns `null` for a color Panneau can't read, or a translucent one over an unknown color.\n */\nexport function parseColorOver(value: string, under: Rgb | null): Rgb | null {\n const parsed = parseColorWithAlpha(value);\n if (parsed === null) {\n return null;\n }\n if (parsed.alpha >= 1) {\n return parsed.color;\n }\n return under !== null ? mixColors(under, parsed.color, parsed.alpha) : null;\n}\n\n/** A color as `#rrggbb`. */\nexport function toHex({ r, g, b }: Rgb): string {\n return `#${[r, g, b]\n .map((channel) => Math.round(channel).toString(16).padStart(2, '0'))\n .join('')}`;\n}\n\n/** Mixes two colors in sRGB, like `color-mix(in srgb, a, b <amount>)`: 0 gives `a`, 1 gives `b`. */\nexport function mixColors(a: Rgb, b: Rgb, amount: number): Rgb {\n return {\n r: a.r + (b.r - a.r) * amount,\n g: a.g + (b.g - a.g) * amount,\n b: a.b + (b.b - a.b) * amount,\n };\n}\n\nfunction linear(channel: number): number {\n const value = channel / 255;\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n}\n\n/** Relative luminance, as defined by WCAG 2. */\nexport function luminance({ r, g, b }: Rgb): number {\n return 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);\n}\n\n/** Contrast ratio between two colors, from 1 to 21 (WCAG 2). */\nexport function contrastRatio(a: Rgb, b: Rgb): number {\n const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number];\n return (light + 0.05) / (dark + 0.05);\n}\n\nexport const WHITE: Rgb = { r: 255, g: 255, b: 255 };\nexport const BLACK: Rgb = { r: 0, g: 0, b: 0 };\n\n/**\n * The closest color to `color` that reaches `ratio` against `background`, by mixing it with black\n * or white (whichever moves away from the background), like Bootstrap's shade and tint. Returns\n * the color itself when it already passes.\n */\nexport function ensureContrast(color: Rgb, background: Rgb, ratio: number): Rgb {\n if (contrastRatio(color, background) >= ratio) {\n return color;\n }\n const target = luminance(background) > 0.18 ? BLACK : WHITE;\n for (let step = 1; step <= 20; step += 1) {\n const mixed = mixColors(color, target, step / 20);\n if (contrastRatio(mixed, background) >= ratio) {\n return mixed;\n }\n }\n return target;\n}\n\n/** White or black, whichever reads better on `background`, like Bootstrap's `color-contrast()`. */\nexport function readableTextColor(background: Rgb): Rgb {\n return contrastRatio(WHITE, background) >= contrastRatio(BLACK, background) ? WHITE : BLACK;\n}\n"],"mappings":";AAOA,IAAMI,MAAM;AACZ,IAAMC,MACF;;;;;AAMJ,SAAgBC,WAAWC,OAA2B;CAClD,MAAMC,QAAQD,MAAME,KAAK;CACzB,MAAMC,MAAMN,IAAIO,KAAKH,KAAK;CAC1B,IAAIE,MAAM,OAAOE,KAAAA,GAAW;EACxB,MAAMC,SACFH,IAAI,EAAE,CAACI,WAAW,IAAI,CAAC,GAAGJ,IAAI,EAAE,CAAC,CAACK,KAAKC,UAAUA,QAAQA,KAAK,CAAC,CAACC,KAAK,EAAE,IAAIP,IAAI;EACnF,OAAO;GACHT,GAAGiB,OAAOC,SAASN,OAAOO,MAAM,GAAG,CAAC,GAAG,EAAE;GACzClB,GAAGgB,OAAOC,SAASN,OAAOO,MAAM,GAAG,CAAC,GAAG,EAAE;GACzCjB,GAAGe,OAAOC,SAASN,OAAOO,MAAM,GAAG,CAAC,GAAG,EAAE;EAC7C;CACJ;CACA,MAAMC,MAAMhB,IAAIM,KAAKH,KAAK;CAC1B,IAAIa,QAAQ,MAAM;EACd,MAAM,CAACpB,GAAGC,GAAGC,KAAK;GAACkB,IAAI;GAAIA,IAAI;GAAIA,IAAI;EAAE,CAAC,CAACN,KAAKO,YAC5CC,KAAKC,IAAI,KAAKD,KAAKE,IAAI,GAAGP,OAAOI,OAAO,CAAC,CAAC,CAC9C;EACA,OAAO;GAAErB,GAAGA,KAAK;GAAGC,GAAGA,KAAK;GAAGC,GAAGA,KAAK;EAAE;CAC7C;CACA,OAAO;AACX;AAEA,IAAMuB,YAAY;AAClB,IAAMC,QAAQ;;;;;AAMd,SAAgBC,oBAAoBrB,OAAqD;CACrF,MAAMC,QAAQD,MAAME,KAAK;CACzB,MAAMC,MAAMgB,UAAUf,KAAKH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AEf;CACA,OAAOF;AACX;;AAGA,SAAgBG,kBAAkBL,YAAsB;CACpD,OAAOT,cAAcM,OAAOG,UAAU,KAAKT,cAAcO,OAAOE,UAAU,IAAIH,QAAQC;AAC1F"}
@@ -1,4 +1,4 @@
1
- import { type Rgb } from './color';
1
+ import { type Rgb } from './color.js';
2
2
  /** A color vision deficiency, at full severity: red-blind, green-blind or blue-blind. */
3
3
  export type ColorVisionDeficiency = 'protanopia' | 'deuteranopia' | 'tritanopia';
4
4
  /** A color as a person with a color vision deficiency sees it. */
@@ -1 +1 @@
1
- {"version":3,"file":"colorVision.js","names":[],"sources":["../../src/theme/colorVision.ts"],"sourcesContent":["import { type Rgb, parseColor } from './color';\n\n/** A color vision deficiency, at full severity: red-blind, green-blind or blue-blind. */\nexport type ColorVisionDeficiency = 'protanopia' | 'deuteranopia' | 'tritanopia';\n\n/** Simulation matrices of Machado, Oliveira and Fernandes (2009), severity 1, on linear RGB. */\nconst MATRICES: Record<ColorVisionDeficiency, readonly (readonly number[])[]> = {\n protanopia: [\n [0.152286, 1.052583, -0.204868],\n [0.114503, 0.786281, 0.099216],\n [-0.003882, -0.048116, 1.051998],\n ],\n deuteranopia: [\n [0.367322, 0.860646, -0.227968],\n [0.280085, 0.672501, 0.047413],\n [-0.01182, 0.04294, 0.968881],\n ],\n tritanopia: [\n [1.255528, -0.076749, -0.178779],\n [-0.078411, 0.930809, 0.147602],\n [0.004733, 0.691367, 0.3039],\n ],\n};\n\nconst toLinear = (channel: number) => {\n const value = channel / 255;\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n};\n\nconst fromLinear = (value: number) => {\n const clamped = Math.min(1, Math.max(0, value));\n return (clamped <= 0.0031308 ? clamped * 12.92 : 1.055 * clamped ** (1 / 2.4) - 0.055) * 255;\n};\n\n/** A color as a person with a color vision deficiency sees it. */\nexport function simulateColorVision(color: Rgb, deficiency: ColorVisionDeficiency): Rgb {\n const linear = [toLinear(color.r), toLinear(color.g), toLinear(color.b)];\n const [r = 0, g = 0, b = 0] = MATRICES[deficiency].map((row) =>\n fromLinear(row.reduce((sum, weight, index) => sum + weight * (linear[index] ?? 0), 0)),\n );\n return { r, g, b };\n}\n\nfunction toLab(color: Rgb): [number, number, number] {\n const [r, g, b] = [toLinear(color.r), toLinear(color.g), toLinear(color.b)];\n const f = (t: number) => (t > 0.008856 ? Math.cbrt(t) : 7.787 * t + 16 / 116);\n const x = f((0.4124 * r + 0.3576 * g + 0.1805 * b) / 0.95047);\n const y = f(0.2126 * r + 0.7152 * g + 0.0722 * b);\n const z = f((0.0193 * r + 0.1192 * g + 0.9505 * b) / 1.08883);\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n}\n\n/** The perceived difference between two colors: the CIE76 distance in CIELAB. */\nexport function colorDifference(first: Rgb, second: Rgb): number {\n const [l1, a1, b1] = toLab(first);\n const [l2, a2, b2] = toLab(second);\n return Math.hypot(l1 - l2, a1 - a2, b1 - b2);\n}\n\n/** Two colors of a palette that look too alike, for everyone or with a deficiency. */\nexport interface ColorDifferenceCheck {\n vision: 'typical' | ColorVisionDeficiency;\n first: string;\n second: string;\n difference: number;\n minimum: number;\n}\n\n/**\n * Checks that the colors of a palette (the categorical colors of charts) stay distinct, for\n * typical vision and under protanopia, deuteranopia and tritanopia: every pair must differ by at\n * least `minimum` (CIE76, 10 by default, a difference anyone notices side by side). Colors Panneau\n * can't read are skipped. Returns the pairs below the minimum.\n */\nexport function checkColorDifferences(\n colors: readonly string[],\n minimum = 10,\n): ColorDifferenceCheck[] {\n const parsed = colors.flatMap((color) => {\n const rgb = parseColor(color);\n return rgb !== null ? [{ color, rgb }] : [];\n });\n const visions = ['typical', 'protanopia', 'deuteranopia', 'tritanopia'] as const;\n return visions.flatMap((vision) => {\n const seen = parsed.map(({ color, rgb }) => ({\n color,\n rgb: vision === 'typical' ? rgb : simulateColorVision(rgb, vision),\n }));\n return seen.flatMap((first, index) =>\n seen.slice(index + 1).flatMap((second) => {\n const difference = Math.round(colorDifference(first.rgb, second.rgb) * 10) / 10;\n return difference < minimum\n ? [{ vision, first: first.color, second: second.color, difference, minimum }]\n : [];\n }),\n );\n });\n}\n"],"mappings":";;;AAMA,IAAM,WAA0E;CAC5E,YAAY;EACR;GAAC;GAAU;GAAU;EAAS;EAC9B;GAAC;GAAU;GAAU;EAAQ;EAC7B;GAAC;GAAW;GAAW;EAAQ;CAAC;CAEpC,cAAc;EACV;GAAC;GAAU;GAAU;EAAS;EAC9B;GAAC;GAAU;GAAU;EAAQ;EAC7B;GAAC;GAAU;GAAS;EAAQ;CAAC;CAEjC,YAAY;EACR;GAAC;GAAU;GAAW;EAAS;EAC/B;GAAC;GAAW;GAAU;EAAQ;EAC9B;GAAC;GAAU;GAAU;EAAM;CAAC;AAEpC;AAEA,IAAM,YAAY,YAAoB;CAClC,MAAM,QAAQ,UAAU;CACxB,OAAO,SAAS,SAAU,QAAQ,UAAU,QAAQ,QAAS,UAAU;AAC3E;AAEA,IAAM,cAAc,UAAkB;CAClC,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;CAC9C,QAAQ,WAAW,WAAY,UAAU,QAAQ,QAAQ,YAAY,IAAI,OAAO,QAAS;AAC7F;;AAGA,SAAgB,oBAAoB,OAAY,YAAwC;CACpF,MAAM,SAAS;EAAC,SAAS,MAAM,CAAC;EAAG,SAAS,MAAM,CAAC;EAAG,SAAS,MAAM,CAAC;CAAC;CACvE,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,KAAK,SAAS,WAAW,CAAC,KAAK,QACpD,WAAW,IAAI,QAAQ,KAAK,QAAQ,UAAU,MAAM,UAAU,OAAO,UAAU,IAAI,CAAC,CAAC,CACzF;CACA,OAAO;EAAE;EAAG;EAAG;CAAE;AACrB;AAEA,SAAS,MAAM,OAAsC;CACjD,MAAM,CAAC,GAAG,GAAG,KAAK;EAAC,SAAS,MAAM,CAAC;EAAG,SAAS,MAAM,CAAC;EAAG,S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ACV,CAAC,CACL;CACJ,CAAC;AACL"}
1
+ {"version":3,"file":"colorVision.js","names":["Rgb","parseColor","ColorVisionDeficiency","MATRICES","Record","protanopia","deuteranopia","tritanopia","toLinear","channel","value","fromLinear","clamped","Math","min","max","simulateColorVision","color","deficiency","linear","r","g","b","map","row","reduce","sum","weight","index","toLab","f","t","cbrt","x","y","z","colorDifference","first","second","l1","a1","b1","l2","a2","b2","hypot","ColorDifferenceCheck","vision","difference","minimum","checkColorDifferences","colors","parsed","flatMap","rgb","visions","const","seen","slice","round"],"sources":["../../src/theme/colorVision.ts"],"sourcesContent":["import { type Rgb, parseColor } from './color';\n\n/** A color vision deficiency, at full severity: red-blind, green-blind or blue-blind. */\nexport type ColorVisionDeficiency = 'protanopia' | 'deuteranopia' | 'tritanopia';\n\n/** Simulation matrices of Machado, Oliveira and Fernandes (2009), severity 1, on linear RGB. */\nconst MATRICES: Record<ColorVisionDeficiency, readonly (readonly number[])[]> = {\n protanopia: [\n [0.152286, 1.052583, -0.204868],\n [0.114503, 0.786281, 0.099216],\n [-0.003882, -0.048116, 1.051998],\n ],\n deuteranopia: [\n [0.367322, 0.860646, -0.227968],\n [0.280085, 0.672501, 0.047413],\n [-0.01182, 0.04294, 0.968881],\n ],\n tritanopia: [\n [1.255528, -0.076749, -0.178779],\n [-0.078411, 0.930809, 0.147602],\n [0.004733, 0.691367, 0.3039],\n ],\n};\n\nconst toLinear = (channel: number) => {\n const value = channel / 255;\n return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n};\n\nconst fromLinear = (value: number) => {\n const clamped = Math.min(1, Math.max(0, value));\n return (clamped <= 0.0031308 ? clamped * 12.92 : 1.055 * clamped ** (1 / 2.4) - 0.055) * 255;\n};\n\n/** A color as a person with a color vision deficiency sees it. */\nexport function simulateColorVision(color: Rgb, deficiency: ColorVisionDeficiency): Rgb {\n const linear = [toLinear(color.r), toLinear(color.g), toLinear(color.b)];\n const [r = 0, g = 0, b = 0] = MATRICES[deficiency].map((row) =>\n fromLinear(row.reduce((sum, weight, index) => sum + weight * (linear[index] ?? 0), 0)),\n );\n return { r, g, b };\n}\n\nfunction toLab(color: Rgb): [number, number, number] {\n const [r, g, b] = [toLinear(color.r), toLinear(color.g), toLinear(color.b)];\n const f = (t: number) => (t > 0.008856 ? Math.cbrt(t) : 7.787 * t + 16 / 116);\n const x = f((0.4124 * r + 0.3576 * g + 0.1805 * b) / 0.95047);\n const y = f(0.2126 * r + 0.7152 * g + 0.0722 * b);\n const z = f((0.0193 * r + 0.1192 * g + 0.9505 * b) / 1.08883);\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n}\n\n/** The perceived difference between two colors: the CIE76 distance in CIELAB. */\nexport function colorDifference(first: Rgb, second: Rgb): number {\n const [l1, a1, b1] = toLab(first);\n const [l2, a2, b2] = toLab(second);\n return Math.hypot(l1 - l2, a1 - a2, b1 - b2);\n}\n\n/** Two colors of a palette that look too alike, for everyone or with a deficiency. */\nexport interface ColorDifferenceCheck {\n vision: 'typical' | ColorVisionDeficiency;\n first: string;\n second: string;\n difference: number;\n minimum: number;\n}\n\n/**\n * Checks that the colors of a palette (the categorical colors of charts) stay distinct, for\n * typical vision and under protanopia, deuteranopia and tritanopia: every pair must differ by at\n * least `minimum` (CIE76, 10 by default, a difference anyone notices side by side). Colors Panneau\n * can't read are skipped. Returns the pairs below the minimum.\n */\nexport function checkColorDifferences(\n colors: readonly string[],\n minimum = 10,\n): ColorDifferenceCheck[] {\n const parsed = colors.flatMap((color) => {\n const rgb = parseColor(color);\n return rgb !== null ? [{ color, rgb }] : [];\n });\n const visions = ['typical', 'protanopia', 'deuteranopia', 'tritanopia'] as const;\n return visions.flatMap((vision) => {\n const seen = parsed.map(({ color, rgb }) => ({\n color,\n rgb: vision === 'typical' ? rgb : simulateColorVision(rgb, vision),\n }));\n return seen.flatMap((first, index) =>\n seen.slice(index + 1).flatMap((second) => {\n const difference = Math.round(colorDifference(first.rgb, second.rgb) * 10) / 10;\n return difference < minimum\n ? [{ vision, first: first.color, second: second.color, difference, minimum }]\n : [];\n }),\n );\n });\n}\n"],"mappings":";;;AAMA,IAAMG,WAA0E;CAC5EE,YAAY;EACR;GAAC;GAAU;GAAU;EAAS;EAC9B;GAAC;GAAU;GAAU;EAAQ;EAC7B;GAAC;GAAW;GAAW;EAAQ;CAAC;CAEpCC,cAAc;EACV;GAAC;GAAU;GAAU;EAAS;EAC9B;GAAC;GAAU;GAAU;EAAQ;EAC7B;GAAC;GAAU;GAAS;EAAQ;CAAC;CAEjCC,YAAY;EACR;GAAC;GAAU;GAAW;EAAS;EAC/B;GAAC;GAAW;GAAU;EAAQ;EAC9B;GAAC;GAAU;GAAU;EAAM;CAAC;AAEpC;AAEA,IAAMC,YAAYC,YAAoB;CAClC,MAAMC,QAAQD,UAAU;CACxB,OAAOC,SAAS,SAAUA,QAAQ,UAAUA,QAAQ,QAAS,UAAU;AAC3E;AAEA,IAAMC,cAAcD,UAAkB;CAClC,MAAME,UAAUC,KAAKC,IAAI,GAAGD,KAAKE,IAAI,GAAGL,KAAK,CAAC;CAC9C,QAAQE,WAAW,WAAYA,UAAU,QAAQ,QAAQA,YAAY,IAAI,OAAO,QAAS;AAC7F;;AAGA,SAAgBI,oBAAoBC,OAAYC,YAAwC;CACpF,MAAMC,SAAS;EAACX,SAASS,MAAMG,CAAC;EAAGZ,SAASS,MAAMI,CAAC;EAAGb,SAASS,MAAMK,CAAC;CAAC;CACvE,MAAM,CAACF,IAAI,GAAGC,IAAI,GAAGC,IAAI,KAAKnB,SAASe,WAAW,CAACK,KAAKC,QACpDb,WAAWa,IAAIC,QAAQC,KAAKC,QAAQC,UAAUF,MAAMC,UAAUR,OAAOS,UAAU,IAAI,CAAC,CAAC,CACzF;CACA,OAAO;EAAER;EAAGC;EAAGC;CAAE;AACrB;AAEA,SAASO,MAAMZ,OAAsC;CACjD,MAAM,CAACG,GAAGC,GAAGC,KAAK;EAACd,SAASS,MAAMG,CAAC;EAAGZ,SAASS,M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OAAOgB,GAAG,IAAI,EAAE,IAAI;GAC7E,OAAON,aAAaC,UACd,CAAC;IAAEF;IAAQV,OAAOA,MAAMpB;IAAOqB,QAAQA,OAAOrB;IAAO+B;IAAYC;GAAQ,CAAC,IAC1E,CAAA;EACV,CAAC,CACL;CACJ,CAAC;AACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"componentTokens.js","names":[],"sources":["../../src/theme/componentTokens.ts"],"sourcesContent":["/**\n * The tokens of one component: CSS variables named `--panneau-<component>-<token>`, with their\n * default values (decision 0024).\n */\nexport interface ComponentTokens<Component extends string = string, Name extends string = string> {\n /**\n * The component or the part it styles, as in its `panneau-<component>` class (`button`,\n * `badge`), or a part shared by several components (`input`, `field`, `list-box`, `calendar`).\n */\n readonly component: Component;\n /** Default values, keyed by token name without the leading `--`: `panneau-button-radius`. */\n readonly tokens: Readonly<Record<Name, string>>;\n}\n\n/**\n * Declares the tokens of a component, as `{ <token>: <default> }`. Each token becomes the CSS\n * variable `--panneau-<component>-<token>`.\n *\n * The component's CSS reads every token with its default as the fallback,\n * `var(--panneau-button-radius, var(--panneau-radius-md))`, and never declares it: a value set by a\n * theme, a scope or any ancestor element then reaches the component, and semantic tokens resolve\n * where the component is. A test checks that the CSS and this declaration agree.\n */\nexport function defineComponentTokens<\n const Component extends string,\n const Tokens extends Record<string, string>,\n>(\n component: Component,\n tokens: Tokens,\n): ComponentTokens<Component, `panneau-${Component}-${keyof Tokens & string}`> {\n return {\n component,\n tokens: Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([name, value]) => [\n `panneau-${component}-${name}`,\n value,\n ]),\n ),\n ) as Record<`panneau-${Component}-${keyof Tokens & string}`, string>,\n };\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgB,sBAIZ,WACA,QAC2E;CAC3E,OAAO;EACH;EACA,QAAQ,OAAO,OACX,OAAO,YACH,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC1C,WAAW,UAAS,GAAI,QACxB,KAAK,CACR,CACL,CACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"componentTokens.js","names":["ComponentTokens","component","Component","tokens","Readonly","Record","Name","defineComponentTokens","Tokens","Object","freeze","fromEntries","entries","map","name","value"],"sources":["../../src/theme/componentTokens.ts"],"sourcesContent":["/**\n * The tokens of one component: CSS variables named `--panneau-<component>-<token>`, with their\n * default values (decision 0024).\n */\nexport interface ComponentTokens<Component extends string = string, Name extends string = string> {\n /**\n * The component or the part it styles, as in its `panneau-<component>` class (`button`,\n * `badge`), or a part shared by several components (`input`, `field`, `list-box`, `calendar`).\n */\n readonly component: Component;\n /** Default values, keyed by token name without the leading `--`: `panneau-button-radius`. */\n readonly tokens: Readonly<Record<Name, string>>;\n}\n\n/**\n * Declares the tokens of a component, as `{ <token>: <default> }`. Each token becomes the CSS\n * variable `--panneau-<component>-<token>`.\n *\n * The component's CSS reads every token with its default as the fallback,\n * `var(--panneau-button-radius, var(--panneau-radius-md))`, and never declares it: a value set by a\n * theme, a scope or any ancestor element then reaches the component, and semantic tokens resolve\n * where the component is. A test checks that the CSS and this declaration agree.\n */\nexport function defineComponentTokens<\n const Component extends string,\n const Tokens extends Record<string, string>,\n>(\n component: Component,\n tokens: Tokens,\n): ComponentTokens<Component, `panneau-${Component}-${keyof Tokens & string}`> {\n return {\n component,\n tokens: Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([name, value]) => [\n `panneau-${component}-${name}`,\n value,\n ]),\n ),\n ) as Record<`panneau-${Component}-${keyof Tokens & string}`, string>,\n };\n}\n"],"mappings":";;;;;;;;;;AAuBA,SAAgBO,sBAIZN,WACAE,QAC2E;CAC3E,OAAO;EACHF;EACAE,QAAQM,OAAOC,OACXD,OAAOE,YACHF,OAAOG,QAAQT,MAAM,CAAC,CAACU,KAAK,CAACC,MAAMC,WAAW,CAC1C,WAAWd,UAAS,GAAIa,QACxBC,KAAK,CACR,CACL,CACJ;CACJ;AACJ"}
@@ -4,32 +4,45 @@
4
4
  */
5
5
  export declare const componentTokens: Readonly<{
6
6
  alert: Readonly<Record<"panneau-alert-radius" | "panneau-alert-gap" | "panneau-alert-padding-y" | "panneau-alert-padding-x" | "panneau-alert-border-width" | "panneau-alert-title-font-weight", string>>;
7
+ aside: Readonly<Record<"panneau-aside-border" | "panneau-aside-width" | "panneau-aside-radius" | "panneau-aside-padding" | "panneau-aside-width-wide" | "panneau-aside-bg" | "panneau-aside-shadow", string>>;
7
8
  badge: Readonly<Record<"panneau-badge-height" | "panneau-badge-radius" | "panneau-badge-gap" | "panneau-badge-padding-x" | "panneau-badge-border-width" | "panneau-badge-font-size" | "panneau-badge-font-weight", string>>;
8
- button: Readonly<Record<"panneau-button-radius" | "panneau-button-gap" | "panneau-button-padding-x" | "panneau-button-border-width" | "panneau-button-font-size" | "panneau-button-font-weight" | "panneau-button-padding-x-sm" | "panneau-button-font-size-sm", string>>;
9
+ 'bar-chart': Readonly<Record<"panneau-bar-chart-gap" | "panneau-bar-chart-font-size" | "panneau-bar-chart-bar-height" | "panneau-bar-chart-bar-radius", string>>;
10
+ button: Readonly<Record<"panneau-button-radius" | "panneau-button-gap" | "panneau-button-padding-x" | "panneau-button-border-width" | "panneau-button-font-size" | "panneau-button-font-weight" | "panneau-button-solid-border-color" | "panneau-button-pressed-scale" | "panneau-button-padding-x-sm" | "panneau-button-font-size-sm", string>>;
9
11
  calendar: Readonly<Record<"panneau-calendar-cell-size" | "panneau-calendar-cell-radius" | "panneau-calendar-selected-color" | "panneau-calendar-selected-bg", string>>;
10
- card: Readonly<Record<"panneau-card-radius" | "panneau-card-gap" | "panneau-card-padding-y" | "panneau-card-padding-x" | "panneau-card-border-width" | "panneau-card-title-font-weight" | "panneau-card-bg" | "panneau-card-border-color" | "panneau-card-shadow" | "panneau-card-header-padding-y" | "panneau-card-title-font-size", string>>;
12
+ card: Readonly<Record<"panneau-card-radius" | "panneau-card-gap" | "panneau-card-padding-y" | "panneau-card-padding-x" | "panneau-card-border-width" | "panneau-card-title-font-weight" | "panneau-card-bg" | "panneau-card-shadow" | "panneau-card-border-color" | "panneau-card-header-padding-y" | "panneau-card-title-font-size", string>>;
11
13
  checkbox: Readonly<Record<"panneau-checkbox-size" | "panneau-checkbox-radius" | "panneau-checkbox-bg" | "panneau-checkbox-border-color" | "panneau-checkbox-checked-color" | "panneau-checkbox-checked-bg", string>>;
14
+ 'command-palette': Readonly<Record<"panneau-command-palette-width" | "panneau-command-palette-radius" | "panneau-command-palette-bg" | "panneau-command-palette-offset-top" | "panneau-command-palette-list-max-height" | "panneau-command-palette-item-radius" | "panneau-command-palette-item-active-bg", string>>;
12
15
  container: Readonly<Record<"panneau-container-padding-x" | "panneau-container-width-sm" | "panneau-container-width-md" | "panneau-container-width-lg" | "panneau-container-width-xl", string>>;
13
- dialog: Readonly<Record<"panneau-dialog-width" | "panneau-dialog-radius" | "panneau-dialog-padding-x" | "panneau-dialog-title-font-weight" | "panneau-dialog-bg" | "panneau-dialog-shadow" | "panneau-dialog-title-font-size" | "panneau-dialog-width-sm" | "panneau-dialog-width-lg" | "panneau-dialog-backdrop", string>>;
16
+ dialog: Readonly<Record<"panneau-dialog-width" | "panneau-dialog-radius" | "panneau-dialog-padding-x" | "panneau-dialog-title-font-weight" | "panneau-dialog-bg" | "panneau-dialog-shadow" | "panneau-dialog-title-font-size" | "panneau-dialog-width-sm" | "panneau-dialog-width-lg" | "panneau-dialog-width-xl" | "panneau-dialog-backdrop", string>>;
14
17
  disclosure: Readonly<Record<"panneau-disclosure-gap" | "panneau-disclosure-title-font-weight" | "panneau-disclosure-title-font-size", string>>;
15
18
  divider: Readonly<Record<"panneau-divider-color" | "panneau-divider-width", string>>;
16
- field: Readonly<Record<"panneau-field-gap" | "panneau-field-label-font-size" | "panneau-field-label-font-weight", string>>;
19
+ field: Readonly<Record<"panneau-field-gap" | "panneau-field-label-font-size" | "panneau-field-label-font-weight" | "panneau-field-required-color", string>>;
17
20
  grid: Readonly<Record<"panneau-grid-gap", string>>;
18
21
  heading: Readonly<Record<"panneau-heading-color" | "panneau-heading-font-family" | "panneau-heading-display-font-family" | "panneau-heading-1-font-size" | "panneau-heading-1-font-weight" | "panneau-heading-1-line-height" | "panneau-heading-1-letter-spacing" | "panneau-heading-2-font-size" | "panneau-heading-2-font-weight" | "panneau-heading-2-line-height" | "panneau-heading-2-letter-spacing" | "panneau-heading-3-font-size" | "panneau-heading-3-font-weight" | "panneau-heading-3-line-height" | "panneau-heading-3-letter-spacing" | "panneau-heading-4-font-size" | "panneau-heading-4-font-weight" | "panneau-heading-4-line-height" | "panneau-heading-4-letter-spacing" | "panneau-heading-display-1-font-size" | "panneau-heading-display-1-font-weight" | "panneau-heading-display-1-line-height" | "panneau-heading-display-1-letter-spacing" | "panneau-heading-display-2-font-size" | "panneau-heading-display-2-font-weight" | "panneau-heading-display-2-line-height" | "panneau-heading-display-2-letter-spacing", string>>;
22
+ icon: Readonly<Record<"panneau-icon-stroke-width", string>>;
19
23
  inline: Readonly<Record<"panneau-inline-gap", string>>;
20
- input: Readonly<Record<"panneau-input-radius" | "panneau-input-padding-x" | "panneau-input-border-width" | "panneau-input-bg" | "panneau-input-border-color" | "panneau-input-border-color-hover", string>>;
21
- 'list-box': Readonly<Record<"panneau-list-box-padding" | "panneau-list-box-item-padding-y" | "panneau-list-box-item-padding-x" | "panneau-list-box-item-radius" | "panneau-list-box-item-bg-hover", string>>;
24
+ input: Readonly<Record<"panneau-input-radius" | "panneau-input-padding-x" | "panneau-input-border-width" | "panneau-input-bg" | "panneau-input-border-color" | "panneau-input-border-color-hover" | "panneau-input-border-color-focus" | "panneau-input-focus-ring" | "panneau-input-focus-ring-invalid", string>>;
25
+ 'line-chart': Readonly<Record<"panneau-line-chart-height" | "panneau-line-chart-label-font-size" | "panneau-line-chart-line-width" | "panneau-line-chart-dot-size" | "panneau-line-chart-area-opacity" | "panneau-line-chart-grid-color" | "panneau-line-chart-reveal-duration", string>>;
26
+ 'list-box': Readonly<Record<"panneau-list-box-padding" | "panneau-list-box-item-radius" | "panneau-list-box-item-padding-y" | "panneau-list-box-item-padding-y-described" | "panneau-list-box-item-padding-x" | "panneau-list-box-item-bg-hover", string>>;
27
+ menu: Readonly<Record<"panneau-menu-header-font-size" | "panneau-menu-header-font-weight" | "panneau-menu-header-color" | "panneau-menu-header-text-transform" | "panneau-menu-header-letter-spacing" | "panneau-menu-footer-font-size" | "panneau-menu-footer-color" | "panneau-menu-media-size" | "panneau-menu-media-size-described" | "panneau-menu-media-radius" | "panneau-menu-item-bg-selected", string>>;
28
+ meter: Readonly<Record<"panneau-meter-height" | "panneau-meter-radius" | "panneau-meter-track-bg", string>>;
22
29
  'number-input': Readonly<Record<"panneau-number-input-stepper-width", string>>;
23
- popover: Readonly<Record<"panneau-popover-radius" | "panneau-popover-padding" | "panneau-popover-bg" | "panneau-popover-border-color" | "panneau-popover-shadow", string>>;
30
+ 'pill-trigger': Readonly<Record<"panneau-pill-trigger-color" | "panneau-pill-trigger-radius" | "panneau-pill-trigger-gap" | "panneau-pill-trigger-padding-x" | "panneau-pill-trigger-bg" | "panneau-pill-trigger-font-size" | "panneau-pill-trigger-font-weight" | "panneau-pill-trigger-padding-x-sm" | "panneau-pill-trigger-font-size-sm" | "panneau-pill-trigger-border-color" | "panneau-pill-trigger-media-size" | "panneau-pill-trigger-media-radius" | "panneau-pill-trigger-bg-hover" | "panneau-pill-trigger-media-size-sm", string>>;
31
+ popover: Readonly<Record<"panneau-popover-radius" | "panneau-popover-padding" | "panneau-popover-bg" | "panneau-popover-shadow" | "panneau-popover-border-color", string>>;
24
32
  prose: Readonly<Record<"panneau-prose-gap" | "panneau-prose-border-color" | "panneau-prose-line-height" | "panneau-prose-heading-gap" | "panneau-prose-list-indent" | "panneau-prose-link-color" | "panneau-prose-code-font-size" | "panneau-prose-code-color" | "panneau-prose-code-bg" | "panneau-prose-code-radius" | "panneau-prose-quote-border-color" | "panneau-prose-quote-color", string>>;
25
- radio: Readonly<Record<"panneau-radio-size" | "panneau-radio-bg" | "panneau-radio-border-color" | "panneau-radio-checked-color" | "panneau-radio-checked-border-width", string>>;
33
+ radio: Readonly<Record<"panneau-radio-size" | "panneau-radio-bg" | "panneau-radio-border-color" | "panneau-radio-checked-color" | "panneau-radio-media-size" | "panneau-radio-media-radius" | "panneau-radio-checked-border-width" | "panneau-radio-card-gap" | "panneau-radio-card-padding" | "panneau-radio-card-bg" | "panneau-radio-card-border-color" | "panneau-radio-card-border-color-hover" | "panneau-radio-card-border-color-selected" | "panneau-radio-scale-bg" | "panneau-radio-scale-border-color" | "panneau-radio-scale-selected-bg" | "panneau-radio-scale-selected-text" | "panneau-radio-card-radius" | "panneau-radio-card-label-font-weight", string>>;
34
+ 'segmented-control': Readonly<Record<"panneau-segmented-control-radius" | "panneau-segmented-control-padding" | "panneau-segmented-control-bg" | "panneau-segmented-control-border-color" | "panneau-segmented-control-segment-padding-x" | "panneau-segmented-control-segment-font-weight" | "panneau-segmented-control-segment-color" | "panneau-segmented-control-segment-color-hover" | "panneau-segmented-control-segment-bg-hover" | "panneau-segmented-control-segment-color-selected" | "panneau-segmented-control-segment-bg-selected" | "panneau-segmented-control-segment-shadow-selected", string>>;
35
+ selected: Readonly<Record<"panneau-selected-text" | "panneau-selected-subtle" | "panneau-selected-bg", string>>;
36
+ skeleton: Readonly<Record<"panneau-skeleton-color" | "panneau-skeleton-radius" | "panneau-skeleton-duration", string>>;
37
+ sparkline: Readonly<Record<"panneau-sparkline-height" | "panneau-sparkline-line-width" | "panneau-sparkline-dot-size" | "panneau-sparkline-area-opacity", string>>;
26
38
  spinner: Readonly<Record<"panneau-spinner-border-width", string>>;
27
39
  stack: Readonly<Record<"panneau-stack-gap", string>>;
28
- switch: Readonly<Record<"panneau-switch-height" | "panneau-switch-width" | "panneau-switch-radius" | "panneau-switch-checked-bg" | "panneau-switch-track-bg" | "panneau-switch-thumb-size" | "panneau-switch-thumb-bg" | "panneau-switch-checked-thumb-bg", string>>;
40
+ stat: Readonly<Record<"panneau-stat-gap" | "panneau-stat-label-font-size" | "panneau-stat-value-font-family" | "panneau-stat-value-font-size" | "panneau-stat-value-font-weight" | "panneau-stat-help-font-size", string>>;
41
+ switch: Readonly<Record<"panneau-switch-height" | "panneau-switch-width" | "panneau-switch-radius" | "panneau-switch-checked-bg" | "panneau-switch-track-bg" | "panneau-switch-track-border-color" | "panneau-switch-thumb-size" | "panneau-switch-thumb-bg" | "panneau-switch-checked-thumb-bg", string>>;
29
42
  tabs: Readonly<Record<"panneau-tabs-gap" | "panneau-tabs-border-color" | "panneau-tabs-tab-padding-x" | "panneau-tabs-tab-font-weight" | "panneau-tabs-tab-color" | "panneau-tabs-indicator-height" | "panneau-tabs-tab-color-selected" | "panneau-tabs-indicator-color", string>>;
30
43
  text: Readonly<Record<"panneau-text-muted-color", string>>;
31
- toast: Readonly<Record<"panneau-toast-width" | "panneau-toast-radius" | "panneau-toast-bg" | "panneau-toast-border-color" | "panneau-toast-shadow" | "panneau-toast-tone-width", string>>;
32
- tooltip: Readonly<Record<"panneau-tooltip-color" | "panneau-tooltip-radius" | "panneau-tooltip-padding-y" | "panneau-tooltip-padding-x" | "panneau-tooltip-font-size" | "panneau-tooltip-bg", string>>;
44
+ toast: Readonly<Record<"panneau-toast-width" | "panneau-toast-radius" | "panneau-toast-bg" | "panneau-toast-shadow" | "panneau-toast-border-color" | "panneau-toast-tone-width", string>>;
45
+ tooltip: Readonly<Record<"panneau-tooltip-color" | "panneau-tooltip-radius" | "panneau-tooltip-padding-y" | "panneau-tooltip-padding-x" | "panneau-tooltip-bg" | "panneau-tooltip-font-size", string>>;
33
46
  }>;
34
47
  /** The name of a component token of `@panneau/ui`, without the leading `--`. */
35
48
  export type ComponentTokenName = {
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/theme/components.ts"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B1B,CAAC;AAEH,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;KAC5B,SAAS,IAAI,MAAM,OAAO,eAAe,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC,SAAS,CAAC;CACzF,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/theme/components.ts"],"names":[],"mappings":"AAyCA;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyC1B,CAAC;AAEH,gFAAgF;AAChF,MAAM,MAAM,kBAAkB,GAAG;KAC5B,SAAS,IAAI,MAAM,OAAO,eAAe,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC,SAAS,CAAC;CACzF,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC"}