@eifi1/ui-kit 0.34.0 → 0.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +115 -41
  2. package/dist/admin/role-select.d.ts +3 -2
  3. package/dist/admin/role-select.js +2 -0
  4. package/dist/admin/role-select.js.map +1 -1
  5. package/dist/billing/billing-banner.d.ts +5 -2
  6. package/dist/billing/billing-banner.js.map +1 -1
  7. package/dist/billing/plan-limit-notice.d.ts +5 -2
  8. package/dist/billing/plan-limit-notice.js.map +1 -1
  9. package/dist/chart.js.map +1 -1
  10. package/dist/components/amount-input.d.ts +2 -5
  11. package/dist/components/amount-input.js +2 -2
  12. package/dist/components/amount-input.js.map +1 -1
  13. package/dist/components/autocomplete.d.ts +2 -2
  14. package/dist/components/autocomplete.js +2 -1
  15. package/dist/components/autocomplete.js.map +1 -1
  16. package/dist/components/button-look.d.ts +1 -1
  17. package/dist/components/button-look.js +9 -4
  18. package/dist/components/button-look.js.map +1 -1
  19. package/dist/components/calculator.d.ts +1 -4
  20. package/dist/components/calculator.js +1 -3
  21. package/dist/components/calculator.js.map +1 -1
  22. package/dist/components/chart-zoom.d.ts +0 -37
  23. package/dist/components/chart-zoom.js +1 -28
  24. package/dist/components/chart-zoom.js.map +1 -1
  25. package/dist/components/checkbox-group.d.ts +5 -2
  26. package/dist/components/checkbox-group.js +15 -4
  27. package/dist/components/checkbox-group.js.map +1 -1
  28. package/dist/components/chip-input.d.ts +0 -4
  29. package/dist/components/chip-input.js +1 -5
  30. package/dist/components/chip-input.js.map +1 -1
  31. package/dist/components/column-mapper.d.ts +5 -3
  32. package/dist/components/column-mapper.js +2 -0
  33. package/dist/components/column-mapper.js.map +1 -1
  34. package/dist/components/combobox.d.ts +3 -3
  35. package/dist/components/combobox.js +2 -1
  36. package/dist/components/combobox.js.map +1 -1
  37. package/dist/components/copy-button.d.ts +5 -1
  38. package/dist/components/copy-button.js.map +1 -1
  39. package/dist/components/country-select.d.ts +3 -3
  40. package/dist/components/country-select.js +3 -0
  41. package/dist/components/country-select.js.map +1 -1
  42. package/dist/components/currency-option-list.d.ts +3 -8
  43. package/dist/components/currency-option-list.js +1 -29
  44. package/dist/components/currency-option-list.js.map +1 -1
  45. package/dist/components/currency-select.d.ts +3 -2
  46. package/dist/components/currency-select.js +10 -1
  47. package/dist/components/currency-select.js.map +1 -1
  48. package/dist/components/danger-confirm.d.ts +3 -3
  49. package/dist/components/danger-confirm.js.map +1 -1
  50. package/dist/components/data-table-filter-popover.d.ts +1 -1
  51. package/dist/components/data-table-filter-popover.js +1 -1
  52. package/dist/components/data-table-filter-popover.js.map +1 -1
  53. package/dist/components/data-table-labels.d.ts +1 -42
  54. package/dist/components/data-table-labels.js +2 -31
  55. package/dist/components/data-table-labels.js.map +1 -1
  56. package/dist/components/data-table-shared.d.ts +17 -1
  57. package/dist/components/data-table-shared.js +22 -0
  58. package/dist/components/data-table-shared.js.map +1 -1
  59. package/dist/components/data-table.d.ts +12 -2
  60. package/dist/components/data-table.js +18 -14
  61. package/dist/components/data-table.js.map +1 -1
  62. package/dist/components/date-field.d.ts +2 -1
  63. package/dist/components/date-field.js.map +1 -1
  64. package/dist/components/date-picker.js +3 -0
  65. package/dist/components/date-picker.js.map +1 -1
  66. package/dist/components/date-range-picker.js +3 -0
  67. package/dist/components/date-range-picker.js.map +1 -1
  68. package/dist/components/dialog-frame.d.ts +3 -1
  69. package/dist/components/dialog-frame.js.map +1 -1
  70. package/dist/components/dropdown.d.ts +18 -15
  71. package/dist/components/dropdown.js +11 -3
  72. package/dist/components/dropdown.js.map +1 -1
  73. package/dist/components/entity-combobox.d.ts +3 -3
  74. package/dist/components/entity-combobox.js +2 -1
  75. package/dist/components/entity-combobox.js.map +1 -1
  76. package/dist/components/field-base.d.ts +0 -5
  77. package/dist/components/field-base.js +0 -5
  78. package/dist/components/field-base.js.map +1 -1
  79. package/dist/components/field-parts.d.ts +69 -22
  80. package/dist/components/field-parts.js +33 -19
  81. package/dist/components/field-parts.js.map +1 -1
  82. package/dist/components/field-strip.d.ts +9 -23
  83. package/dist/components/field-strip.js +26 -23
  84. package/dist/components/field-strip.js.map +1 -1
  85. package/dist/components/field-sync.d.ts +0 -4
  86. package/dist/components/field-sync.js +0 -4
  87. package/dist/components/field-sync.js.map +1 -1
  88. package/dist/components/field.d.ts +7 -6
  89. package/dist/components/field.js +24 -15
  90. package/dist/components/field.js.map +1 -1
  91. package/dist/components/full-bleed-dialog.js +2 -2
  92. package/dist/components/full-bleed-dialog.js.map +1 -1
  93. package/dist/components/help-popover.d.ts +9 -7
  94. package/dist/components/help-popover.js.map +1 -1
  95. package/dist/components/hover-menu.d.ts +6 -13
  96. package/dist/components/hover-menu.js +3 -3
  97. package/dist/components/hover-menu.js.map +1 -1
  98. package/dist/components/icon-picker.d.ts +3 -2
  99. package/dist/components/icon-picker.js +3 -0
  100. package/dist/components/icon-picker.js.map +1 -1
  101. package/dist/components/inline-entity-combobox.d.ts +3 -3
  102. package/dist/components/inline-entity-combobox.js +2 -1
  103. package/dist/components/inline-entity-combobox.js.map +1 -1
  104. package/dist/components/input.d.ts +2 -2
  105. package/dist/components/input.js +2 -1
  106. package/dist/components/input.js.map +1 -1
  107. package/dist/components/modal.d.ts +9 -1
  108. package/dist/components/modal.js +7 -4
  109. package/dist/components/modal.js.map +1 -1
  110. package/dist/components/month-picker.d.ts +2 -1
  111. package/dist/components/month-picker.js +8 -1
  112. package/dist/components/month-picker.js.map +1 -1
  113. package/dist/components/multi-entity-combobox.d.ts +2 -2
  114. package/dist/components/multi-entity-combobox.js +2 -1
  115. package/dist/components/multi-entity-combobox.js.map +1 -1
  116. package/dist/components/multi-select.d.ts +7 -18
  117. package/dist/components/multi-select.js +8 -10
  118. package/dist/components/multi-select.js.map +1 -1
  119. package/dist/components/number-input.d.ts +2 -5
  120. package/dist/components/number-input.js +2 -4
  121. package/dist/components/number-input.js.map +1 -1
  122. package/dist/components/numeric-field.d.ts +5 -2
  123. package/dist/components/numeric-field.js +4 -1
  124. package/dist/components/numeric-field.js.map +1 -1
  125. package/dist/components/one-time-code-input.d.ts +2 -1
  126. package/dist/components/one-time-code-input.js +2 -1
  127. package/dist/components/one-time-code-input.js.map +1 -1
  128. package/dist/components/phone-input.d.ts +1 -1
  129. package/dist/components/phone-input.js +4 -0
  130. package/dist/components/phone-input.js.map +1 -1
  131. package/dist/components/popover.js +3 -3
  132. package/dist/components/popover.js.map +1 -1
  133. package/dist/components/select.d.ts +4 -3
  134. package/dist/components/select.js +2 -1
  135. package/dist/components/select.js.map +1 -1
  136. package/dist/components/series-chart.js.map +1 -1
  137. package/dist/components/server-wake.d.ts +0 -6
  138. package/dist/components/server-wake.js.map +1 -1
  139. package/dist/components/settings-fields.d.ts +4 -2
  140. package/dist/components/settings-fields.js.map +1 -1
  141. package/dist/components/slider.d.ts +3 -2
  142. package/dist/components/slider.js +7 -1
  143. package/dist/components/slider.js.map +1 -1
  144. package/dist/components/stat-tile.d.ts +8 -2
  145. package/dist/components/stat-tile.js +2 -11
  146. package/dist/components/stat-tile.js.map +1 -1
  147. package/dist/components/swatch-picker.d.ts +3 -2
  148. package/dist/components/swatch-picker.js +3 -0
  149. package/dist/components/swatch-picker.js.map +1 -1
  150. package/dist/components/swipeable-row.d.ts +2 -17
  151. package/dist/components/swipeable-row.js +11 -16
  152. package/dist/components/swipeable-row.js.map +1 -1
  153. package/dist/components/text-link.js +3 -1
  154. package/dist/components/text-link.js.map +1 -1
  155. package/dist/components/textarea.d.ts +2 -1
  156. package/dist/components/textarea.js +9 -3
  157. package/dist/components/textarea.js.map +1 -1
  158. package/dist/components/toggle-group.d.ts +2 -2
  159. package/dist/components/toggle-group.js +7 -3
  160. package/dist/components/toggle-group.js.map +1 -1
  161. package/dist/components/tooltip.d.ts +9 -1
  162. package/dist/components/tooltip.js +20 -5
  163. package/dist/components/tooltip.js.map +1 -1
  164. package/dist/components/translation-review.d.ts +10 -2
  165. package/dist/components/translation-review.js +11 -3
  166. package/dist/components/translation-review.js.map +1 -1
  167. package/dist/components/use-table-state.d.ts +31 -3
  168. package/dist/components/use-table-state.js +53 -8
  169. package/dist/components/use-table-state.js.map +1 -1
  170. package/dist/components/user-avatar.d.ts +2 -2
  171. package/dist/components/user-avatar.js.map +1 -1
  172. package/dist/components/wizard-stepper.d.ts +1 -4
  173. package/dist/components/wizard-stepper.js +2 -3
  174. package/dist/components/wizard-stepper.js.map +1 -1
  175. package/dist/currencies.d.ts +23 -0
  176. package/dist/currencies.js +38 -0
  177. package/dist/currencies.js.map +1 -0
  178. package/dist/demo/demo-banner.d.ts +7 -2
  179. package/dist/demo/demo-banner.js.map +1 -1
  180. package/dist/eslint/index.d.ts +83 -0
  181. package/dist/eslint/index.js +69 -0
  182. package/dist/eslint/index.js.map +1 -0
  183. package/dist/eslint/role-utilities.d.ts +48 -0
  184. package/dist/eslint/role-utilities.generated.d.ts +2 -0
  185. package/dist/eslint/role-utilities.generated.js +143 -0
  186. package/dist/eslint/role-utilities.generated.js.map +1 -0
  187. package/dist/eslint/role-utilities.js +43 -0
  188. package/dist/eslint/role-utilities.js.map +1 -0
  189. package/dist/feedback/feedback-menu.d.ts +2 -2
  190. package/dist/feedback/feedback-menu.js.map +1 -1
  191. package/dist/feedback/feedback-thread.d.ts +3 -8
  192. package/dist/feedback/feedback-thread.js +0 -2
  193. package/dist/feedback/feedback-thread.js.map +1 -1
  194. package/dist/hooks/use-dismiss.d.ts +16 -3
  195. package/dist/hooks/use-dismiss.js +14 -2
  196. package/dist/hooks/use-dismiss.js.map +1 -1
  197. package/dist/i18n/defaults.js +5 -1
  198. package/dist/i18n/defaults.js.map +1 -1
  199. package/dist/i18n/german.js +97 -1
  200. package/dist/i18n/german.js.map +1 -1
  201. package/dist/i18n/kit-labels.d.ts +29 -4
  202. package/dist/i18n/kit-labels.js +21 -1
  203. package/dist/i18n/kit-labels.js.map +1 -1
  204. package/dist/i18n/locales/en.js +104 -3
  205. package/dist/i18n/locales/en.js.map +3 -3
  206. package/dist/i18n/locales/es.js +95 -1
  207. package/dist/i18n/locales/es.js.map +1 -1
  208. package/dist/i18n/locales/fr.js +99 -3
  209. package/dist/i18n/locales/fr.js.map +1 -1
  210. package/dist/i18n/locales/hu.js +95 -1
  211. package/dist/i18n/locales/hu.js.map +1 -1
  212. package/dist/i18n/locales/it.js +99 -3
  213. package/dist/i18n/locales/it.js.map +1 -1
  214. package/dist/i18n/locales/zh.js +95 -1
  215. package/dist/i18n/locales/zh.js.map +1 -1
  216. package/dist/i18n/review.js +13 -0
  217. package/dist/i18n/review.js.map +1 -1
  218. package/dist/i18n/shared-labels.js +3 -1
  219. package/dist/i18n/shared-labels.js.map +1 -1
  220. package/dist/index.d.ts +23 -1
  221. package/dist/index.js +40 -2
  222. package/dist/index.js.map +1 -1
  223. package/dist/lib/device-settings.d.ts +72 -0
  224. package/dist/lib/device-settings.js +64 -0
  225. package/dist/lib/device-settings.js.map +1 -0
  226. package/dist/lib/plain-text.d.ts +11 -0
  227. package/dist/lib/plain-text.js +16 -0
  228. package/dist/lib/plain-text.js.map +1 -0
  229. package/dist/lib/refs.d.ts +13 -0
  230. package/dist/lib/refs.js +15 -0
  231. package/dist/lib/refs.js.map +1 -0
  232. package/dist/lib/safe-storage.d.ts +6 -0
  233. package/dist/lib/safe-storage.js +11 -0
  234. package/dist/lib/safe-storage.js.map +1 -1
  235. package/dist/notifications/notification-parts.d.ts +39 -0
  236. package/dist/notifications/notification-parts.js +47 -0
  237. package/dist/notifications/notification-parts.js.map +1 -0
  238. package/dist/notifications/notification-types-setting.d.ts +62 -0
  239. package/dist/notifications/notification-types-setting.js +192 -0
  240. package/dist/notifications/notification-types-setting.js.map +1 -0
  241. package/dist/notifications/notification-types.d.ts +75 -0
  242. package/dist/notifications/notification-types.js +2 -0
  243. package/dist/notifications/notification-types.js.map +1 -0
  244. package/dist/notifications/notifications-labels.d.ts +131 -0
  245. package/dist/notifications/notifications-labels.js +83 -0
  246. package/dist/notifications/notifications-labels.js.map +1 -0
  247. package/dist/notifications/push-device-setting.d.ts +37 -0
  248. package/dist/notifications/push-device-setting.js +164 -0
  249. package/dist/notifications/push-device-setting.js.map +1 -0
  250. package/dist/notifications/push-devices-setting.d.ts +44 -0
  251. package/dist/notifications/push-devices-setting.js +203 -0
  252. package/dist/notifications/push-devices-setting.js.map +1 -0
  253. package/dist/notifications/quiet-hours-setting.d.ts +47 -0
  254. package/dist/notifications/quiet-hours-setting.js +131 -0
  255. package/dist/notifications/quiet-hours-setting.js.map +1 -0
  256. package/dist/notifications/time-zone-select.d.ts +50 -0
  257. package/dist/notifications/time-zone-select.js +76 -0
  258. package/dist/notifications/time-zone-select.js.map +1 -0
  259. package/dist/notifications/unsubscribe-panel.d.ts +53 -0
  260. package/dist/notifications/unsubscribe-panel.js +139 -0
  261. package/dist/notifications/unsubscribe-panel.js.map +1 -0
  262. package/dist/notifications/use-push-device.d.ts +122 -0
  263. package/dist/notifications/use-push-device.js +230 -0
  264. package/dist/notifications/use-push-device.js.map +1 -0
  265. package/dist/rhf/fields.d.ts +36 -29
  266. package/dist/rhf/fields.js +51 -22
  267. package/dist/rhf/fields.js.map +1 -1
  268. package/dist/rhf/form-core.d.ts +5 -4
  269. package/dist/rhf/form-core.js.map +1 -1
  270. package/dist/rhf/form.d.ts +7 -36
  271. package/dist/rhf/form.js +1 -16
  272. package/dist/rhf/form.js.map +1 -1
  273. package/dist/rhf/line-items.d.ts +1 -1
  274. package/dist/rhf/line-items.js.map +1 -1
  275. package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
  276. package/dist/rhf.js.map +1 -1
  277. package/dist/settings/device-reset-setting-labels.d.ts +3 -0
  278. package/dist/settings/device-reset-setting-labels.js +15 -0
  279. package/dist/settings/device-reset-setting-labels.js.map +1 -0
  280. package/dist/settings/device-reset-setting.d.ts +58 -0
  281. package/dist/settings/device-reset-setting.js +51 -0
  282. package/dist/settings/device-reset-setting.js.map +1 -0
  283. package/dist/shell/app-shell.js +5 -0
  284. package/dist/shell/app-shell.js.map +1 -1
  285. package/dist/shell/option-switcher-menu.d.ts +5 -17
  286. package/dist/shell/option-switcher-menu.js +1 -3
  287. package/dist/shell/option-switcher-menu.js.map +1 -1
  288. package/dist/shell/role-switcher.d.ts +1 -4
  289. package/dist/shell/role-switcher.js +2 -3
  290. package/dist/shell/role-switcher.js.map +1 -1
  291. package/dist/shell/topbar-action-menu.d.ts +7 -19
  292. package/dist/shell/topbar-action-menu.js +1 -3
  293. package/dist/shell/topbar-action-menu.js.map +1 -1
  294. package/dist/shell/topbar-controls.d.ts +3 -12
  295. package/dist/shell/topbar-controls.js +6 -9
  296. package/dist/shell/topbar-controls.js.map +1 -1
  297. package/dist/testing/index.d.ts +1 -1
  298. package/dist/testing/index.js +2 -0
  299. package/dist/testing/index.js.map +1 -1
  300. package/dist/testing/viewport.d.ts +25 -2
  301. package/dist/testing/viewport.js +61 -10
  302. package/dist/testing/viewport.js.map +1 -1
  303. package/dist/theme/contrast-tokens.d.ts +42 -4
  304. package/dist/theme/contrast-tokens.js +56 -9
  305. package/dist/theme/contrast-tokens.js.map +1 -1
  306. package/dist/theme/contrast.d.ts +4 -2
  307. package/dist/theme/contrast.js +13 -0
  308. package/dist/theme/contrast.js.map +1 -1
  309. package/dist/theme/palette-derive.d.ts +15 -1
  310. package/dist/theme/palette-derive.js +37 -8
  311. package/dist/theme/palette-derive.js.map +1 -1
  312. package/dist/theme/palette-presets.d.ts +2 -8
  313. package/dist/theme/palette-presets.js +5 -284
  314. package/dist/theme/palette-presets.js.map +1 -1
  315. package/dist/theme/palette-store.js +6 -0
  316. package/dist/theme/palette-store.js.map +1 -1
  317. package/dist/theme/text-size.js +6 -0
  318. package/dist/theme/text-size.js.map +1 -1
  319. package/dist/theme/theme-store.js +6 -0
  320. package/dist/theme/theme-store.js.map +1 -1
  321. package/dist/wizard/types.d.ts +0 -5
  322. package/dist/wizard/types.js +1 -5
  323. package/dist/wizard/types.js.map +1 -1
  324. package/package.json +9 -1
  325. package/src/admin/role-select.tsx +4 -1
  326. package/src/billing/billing-banner.tsx +5 -2
  327. package/src/billing/plan-limit-notice.tsx +5 -2
  328. package/src/chart.ts +5 -3
  329. package/src/components/amount-input.tsx +4 -7
  330. package/src/components/autocomplete.tsx +5 -2
  331. package/src/components/button-look.ts +15 -5
  332. package/src/components/calculator.tsx +2 -7
  333. package/src/components/chart-zoom.tsx +4 -47
  334. package/src/components/checkbox-group.tsx +22 -4
  335. package/src/components/chip-input.tsx +0 -7
  336. package/src/components/column-mapper.tsx +6 -2
  337. package/src/components/combobox.tsx +6 -3
  338. package/src/components/copy-button.tsx +5 -1
  339. package/src/components/country-select.tsx +6 -1
  340. package/src/components/currency-option-list.tsx +8 -42
  341. package/src/components/currency-select.tsx +12 -3
  342. package/src/components/danger-confirm.tsx +3 -3
  343. package/src/components/data-table-filter-popover.tsx +2 -1
  344. package/src/components/data-table-labels.ts +2 -84
  345. package/src/components/data-table-shared.tsx +55 -2
  346. package/src/components/data-table.tsx +29 -17
  347. package/src/components/date-field.tsx +2 -2
  348. package/src/components/date-picker.tsx +3 -0
  349. package/src/components/date-range-picker.tsx +3 -0
  350. package/src/components/dialog-frame.tsx +3 -1
  351. package/src/components/dropdown.tsx +42 -18
  352. package/src/components/entity-combobox.tsx +6 -3
  353. package/src/components/field-base.tsx +0 -11
  354. package/src/components/field-parts.tsx +112 -38
  355. package/src/components/field-strip.tsx +12 -27
  356. package/src/components/field-sync.tsx +0 -7
  357. package/src/components/field.tsx +32 -19
  358. package/src/components/full-bleed-dialog.tsx +4 -3
  359. package/src/components/help-popover.tsx +9 -7
  360. package/src/components/hover-menu.tsx +12 -16
  361. package/src/components/icon-picker.tsx +8 -3
  362. package/src/components/inline-entity-combobox.tsx +6 -3
  363. package/src/components/input.tsx +4 -2
  364. package/src/components/modal.tsx +20 -4
  365. package/src/components/month-picker.tsx +10 -3
  366. package/src/components/multi-entity-combobox.tsx +5 -2
  367. package/src/components/multi-select.tsx +19 -31
  368. package/src/components/number-input.tsx +5 -10
  369. package/src/components/numeric-field.ts +10 -2
  370. package/src/components/one-time-code-input.tsx +5 -3
  371. package/src/components/phone-input.tsx +4 -0
  372. package/src/components/popover.tsx +8 -4
  373. package/src/components/select.tsx +6 -3
  374. package/src/components/series-chart.tsx +1 -1
  375. package/src/components/server-wake.tsx +0 -6
  376. package/src/components/settings-fields.tsx +4 -2
  377. package/src/components/slider.tsx +10 -3
  378. package/src/components/stat-tile.tsx +11 -20
  379. package/src/components/swatch-picker.tsx +9 -4
  380. package/src/components/swipeable-row.tsx +15 -37
  381. package/src/components/text-link.tsx +3 -1
  382. package/src/components/textarea.tsx +11 -4
  383. package/src/components/toggle-group.tsx +21 -5
  384. package/src/components/tooltip.tsx +37 -6
  385. package/src/components/translation-review.tsx +25 -7
  386. package/src/components/use-table-state.ts +91 -10
  387. package/src/components/user-avatar.tsx +2 -2
  388. package/src/components/wizard-stepper.tsx +2 -6
  389. package/src/currencies.ts +70 -0
  390. package/src/demo/demo-banner.tsx +7 -2
  391. package/src/eslint/index.ts +161 -0
  392. package/src/eslint/role-utilities.generated.ts +146 -0
  393. package/src/eslint/role-utilities.ts +99 -0
  394. package/src/feedback/feedback-menu.tsx +2 -2
  395. package/src/feedback/feedback-thread.tsx +3 -8
  396. package/src/hooks/use-dismiss.ts +39 -4
  397. package/src/i18n/defaults.ts +4 -0
  398. package/src/i18n/german.ts +113 -0
  399. package/src/i18n/kit-labels.tsx +66 -6
  400. package/src/i18n/locales/en.ts +6 -0
  401. package/src/i18n/locales/es.ts +106 -0
  402. package/src/i18n/locales/fr.ts +109 -2
  403. package/src/i18n/locales/hu.ts +104 -0
  404. package/src/i18n/locales/it.ts +108 -2
  405. package/src/i18n/locales/zh.ts +96 -0
  406. package/src/i18n/review.ts +13 -0
  407. package/src/i18n/shared-labels.ts +2 -0
  408. package/src/index.ts +53 -1
  409. package/src/lib/device-settings.ts +146 -0
  410. package/src/lib/plain-text.ts +22 -0
  411. package/src/lib/refs.ts +22 -0
  412. package/src/lib/safe-storage.ts +16 -0
  413. package/src/notifications/notification-parts.tsx +83 -0
  414. package/src/notifications/notification-types-setting.tsx +309 -0
  415. package/src/notifications/notification-types.ts +80 -0
  416. package/src/notifications/notifications-labels.ts +238 -0
  417. package/src/notifications/push-device-setting.tsx +224 -0
  418. package/src/notifications/push-devices-setting.tsx +306 -0
  419. package/src/notifications/quiet-hours-setting.tsx +185 -0
  420. package/src/notifications/time-zone-select.tsx +126 -0
  421. package/src/notifications/unsubscribe-panel.tsx +203 -0
  422. package/src/notifications/use-push-device.ts +392 -0
  423. package/src/rhf/fields.tsx +87 -39
  424. package/src/rhf/form-core.tsx +5 -4
  425. package/src/rhf/form.tsx +7 -43
  426. package/src/rhf/line-items.tsx +1 -1
  427. package/src/rhf/use-rhf-wizard-step.ts +4 -4
  428. package/src/rhf.ts +3 -2
  429. package/src/settings/device-reset-setting-labels.ts +20 -0
  430. package/src/settings/device-reset-setting.tsx +119 -0
  431. package/src/shell/app-shell.tsx +8 -0
  432. package/src/shell/option-switcher-menu.tsx +5 -22
  433. package/src/shell/role-switcher.tsx +2 -6
  434. package/src/shell/topbar-action-menu.tsx +7 -24
  435. package/src/shell/topbar-controls.tsx +6 -18
  436. package/src/testing/index.ts +3 -1
  437. package/src/testing/viewport.ts +125 -19
  438. package/src/theme/contrast-tokens.ts +106 -12
  439. package/src/theme/contrast.ts +30 -4
  440. package/src/theme/palette-derive.ts +68 -7
  441. package/src/theme/palette-presets.ts +16 -299
  442. package/src/theme/palette-store.ts +12 -0
  443. package/src/theme/text-size.ts +8 -0
  444. package/src/theme/theme-store.ts +10 -0
  445. package/src/wizard/types.ts +0 -8
  446. package/tokens.css +38 -4
@@ -1,6 +1,16 @@
1
1
  "use client";
2
- import { contrast, oklchToRgb, parseHex, rgbToOklch, toHex } from "./color.js";
3
- const CONTRAST_STEPPED_VARS = ["--text-secondary", "--text-muted", "--text-placeholder", "--border"];
2
+ import { contrast, hexToOklch, luminance, oklchToHex, oklchToRgb, parseHex, rgbToOklch, solveLightness, toHex } from "./color.js";
3
+ const CONTRAST_STEPPED_VARS = [
4
+ "--text-secondary",
5
+ "--text-muted",
6
+ "--text-placeholder",
7
+ "--border",
8
+ "--bg-surface-2",
9
+ "--money-income",
10
+ "--money-expense",
11
+ "--money-net",
12
+ "--money-neutral"
13
+ ];
4
14
  function toLab(hex) {
5
15
  const rgb = parseHex(hex);
6
16
  if (!rgb) return null;
@@ -23,6 +33,37 @@ const HOVER_INK = 0.055;
23
33
  function hoverFill(t) {
24
34
  return mix(t.textPrimary, t.bgSurface, HOVER_INK);
25
35
  }
36
+ const WELL_INK_MORE = 0.1;
37
+ const WELL_STEP_MIN = 1.17;
38
+ function isLightSet(t) {
39
+ const ink = parseHex(t.textPrimary);
40
+ const card = parseHex(t.bgSurface);
41
+ if (!ink || !card) return null;
42
+ return luminance(ink) < luminance(card);
43
+ }
44
+ const MONEY_TARGET = 4.5;
45
+ function moneyOn(color, well) {
46
+ if (contrast(color, well) >= MONEY_TARGET) return color;
47
+ const lch = hexToOklch(color);
48
+ const bg = parseHex(well);
49
+ if (!lch || !bg) return color;
50
+ const l = solveLightness(MONEY_TARGET, bg, lch.h, lch.c, "darker");
51
+ return oklchToHex({ l, c: lch.c, h: lch.h });
52
+ }
53
+ function steppedWellFill(t) {
54
+ return isLightSet(t) ? mix(t.textPrimary, t.bgSurface, WELL_INK_MORE) : null;
55
+ }
56
+ function wellStep(t) {
57
+ const well = steppedWellFill(t);
58
+ if (!well) return null;
59
+ return {
60
+ bgSurface2: well,
61
+ moneyIncome: moneyOn(t.moneyIncome, well),
62
+ moneyExpense: moneyOn(t.moneyExpense, well),
63
+ moneyNet: moneyOn(t.moneyNet, well),
64
+ moneyNeutral: moneyOn(t.moneyNeutral, well)
65
+ };
66
+ }
26
67
  const BRAND_MUTED_SHARE = 0.62;
27
68
  const BRAND_BG_SHARE = 0.14;
28
69
  const BRAND_BG_HOVER_SHARE = 0.24;
@@ -35,26 +76,29 @@ function brandSoft(t) {
35
76
  }
36
77
  const BORDER_TARGET = 3;
37
78
  const BORDER_STRONG_SHARE = 0.45;
38
- function worstContrast(color, t) {
39
- return Math.min(contrast(color, t.bgPage), contrast(color, t.bgSurface), contrast(color, t.bgSurface2));
79
+ function worstContrast(color, t, well) {
80
+ return Math.min(contrast(color, t.bgPage), contrast(color, t.bgSurface), contrast(color, well));
40
81
  }
41
- function steppedBorder(t) {
82
+ function steppedBorder(t, well) {
83
+ const surface2 = well?.bgSurface2 ?? t.bgSurface2;
42
84
  let lo = BORDER_STRONG_SHARE;
43
- if (worstContrast(mix(t.border, t.textPrimary, 1 - lo), t) >= BORDER_TARGET) return mix(t.border, t.textPrimary, 1 - lo);
85
+ if (worstContrast(mix(t.border, t.textPrimary, 1 - lo), t, surface2) >= BORDER_TARGET) return mix(t.border, t.textPrimary, 1 - lo);
44
86
  let hi = 1;
45
87
  for (let i = 0; i < 16; i++) {
46
88
  const mid = (lo + hi) / 2;
47
- if (worstContrast(mix(t.border, t.textPrimary, 1 - mid), t) >= BORDER_TARGET) hi = mid;
89
+ if (worstContrast(mix(t.border, t.textPrimary, 1 - mid), t, surface2) >= BORDER_TARGET) hi = mid;
48
90
  else lo = mid;
49
91
  }
50
92
  return mix(t.border, t.textPrimary, 1 - hi);
51
93
  }
52
94
  function contrastStep(t) {
95
+ const well = wellStep(t);
53
96
  return {
54
97
  textSecondary: mix(t.textSecondary, t.textPrimary, 0.5),
55
98
  textMuted: t.textSecondary,
56
99
  textPlaceholder: t.textMuted,
57
- border: steppedBorder(t)
100
+ border: steppedBorder(t, well),
101
+ well
58
102
  };
59
103
  }
60
104
  const lastWritten = /* @__PURE__ */ new WeakMap();
@@ -70,11 +114,14 @@ export {
70
114
  BRAND_MUTED_SHARE,
71
115
  CONTRAST_STEPPED_VARS,
72
116
  HOVER_INK,
117
+ WELL_INK_MORE,
118
+ WELL_STEP_MIN,
73
119
  brandSoft,
74
120
  contrastStep,
75
121
  hoverFill,
76
122
  mix,
77
123
  rememberTokenSet,
78
- rememberedTokenSet
124
+ rememberedTokenSet,
125
+ steppedWellFill
79
126
  };
80
127
  //# sourceMappingURL=contrast-tokens.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/contrast-tokens.ts"],"sourcesContent":["import { contrast, oklchToRgb, parseHex, rgbToOklch, toHex } from \"./color\";\nimport type { TokenSet } from \"./palette-presets\";\n\n/**\n * The \"More contrast\" step on a token set (docs/text-size-harmonization.md §5, §10.5).\n * INTERNAL — `applyTokenSet` and the contrast layer share it; it is not re-exported.\n *\n * The step happens HERE, in JS, because the tokens it changes are written inline on\n * `<html>` by `applyTokenSet`: an inline value beats any `[data-contrast=more]` rule and\n * any `@media (prefers-contrast: more)` block, so a stylesheet cannot do it (§10.5, the\n * keksdose review). `--text-placeholder` is a CSS-derived token, and it is written inline\n * here too rather than redefined per attribute in tokens.css.\n *\n * What moves (§5):\n * - `--text-muted` becomes the set's `--text-secondary`;\n * - `--text-secondary` moves halfway to `--text-primary`;\n * - `--text-placeholder` becomes the set's `--text-muted` (4.6–5.5:1 on every shipped\n * preset, where the CSS formula gives 2.4–2.8:1) — the order primary > secondary >\n * muted > placeholder survives the step;\n * - `--border` moves toward `--text-primary` until it clears 3:1 against the worst of the\n * three surfaces (WCAG 1.4.11, a field's boundary), and never less far than\n * `--border-strong`'s 45 % — so every border is at least as strong as a \"strong\" one was.\n * `--border-strong` stays derived in tokens.css and grows with it.\n */\n\n/** The custom properties a contrast step writes. */\nexport const CONTRAST_STEPPED_VARS = [\"--text-secondary\", \"--text-muted\", \"--text-placeholder\", \"--border\"] as const;\n\nexport interface ContrastStep {\n textSecondary: string;\n textMuted: string;\n textPlaceholder: string;\n border: string;\n}\n\ninterface Lab {\n l: number;\n a: number;\n b: number;\n}\n\nfunction toLab(hex: string): Lab | null {\n const rgb = parseHex(hex);\n if (!rgb) return null;\n const { l, c, h } = rgbToOklch(rgb);\n const rad = (h * Math.PI) / 180;\n return { l, a: c * Math.cos(rad), b: c * Math.sin(rad) };\n}\n\n/** `color-mix(in oklab, a p, b)` as a hex — the same formula tokens.css's derived roles\n * use, so a stepped value sits where the stylesheet would have put it. A colour that is\n * not hex (a consumer's own token set) comes back unmixed. The deriver mixes with it\n * too (`--bg-hover`, `--brand-muted`, `--brand-bg`, `--brand-bg-hover`). */\nexport function mix(a: string, b: string, p: number): string {\n const A = toLab(a);\n const B = toLab(b);\n if (!A || !B) return a;\n const l = A.l * p + B.l * (1 - p);\n const x = A.a * p + B.a * (1 - p);\n const y = A.b * p + B.b * (1 - p);\n const c = Math.hypot(x, y);\n const h = c < 1e-6 ? 0 : ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360;\n return toHex(oklchToRgb({ l, c, h }));\n}\n\n/**\n * `--bg-hover` in tokens.css: this share of `--text-primary` mixed into `--bg-surface`.\n *\n * 5.5 %, down from 7 % in 0.33 (docs/colour-roles-harmonization.md §12.10): a hovered row\n * on a card is the darkest fill (in dark, the lightest) that text sits on, and at 7 % the\n * light status colours, the money colours and Ink/Moss/Plum's muted text fell to\n * 4.25–4.49:1 on it. The status literals are fixed, the same in every preset, so the\n * hover moved instead: text wins over the hover's step. At 5.5 % the step from the card\n * is still 1.09–1.13:1, above the 1.08:1 the kit's hover rule asks (§12.2). The deriver\n * solves the money colours against this fill, and tokens-css-audit.test.ts measures\n * every text role on it in every shipped preset, so the two cannot part.\n */\nexport const HOVER_INK = 0.055;\n\n/** The card's hover fill (`--bg-hover`) for `t`, as tokens.css mixes it. */\nexport function hoverFill(t: Pick<TokenSet, \"textPrimary\" | \"bgSurface\">): string {\n return mix(t.textPrimary, t.bgSurface, HOVER_INK);\n}\n\n/**\n * `--brand-muted` in tokens.css: this share of `--brand` mixed into `--text-primary`.\n *\n * 62 %, down from 70 % in 0.33 (docs/colour-roles-harmonization.md §12.11): the brand as\n * text sits on its soft chip HOVERED too (`--brand-bg-hover` — ButtonGroupLink's current\n * page, a selected day), and at 70 % it read 4.08–4.42:1 there in Default and Moss light\n * and in Ink, Moss, Plum and Contrast dark. The brand could not move instead: the dark\n * brands would have flipped their white label to the dark ink. Nor could the chip's hover\n * lighten: by the time the text cleared 4.5:1 the hover sat 1.00:1 from the chip it\n * hovers. So the text moves toward the ink, as `--bg-hover` moved for its text.\n */\nexport const BRAND_MUTED_SHARE = 0.62;\n/** `--brand-bg` and `--brand-bg-hover` in tokens.css: these shares of `--brand` mixed\n * into `--bg-surface`. */\nexport const BRAND_BG_SHARE = 0.14;\nexport const BRAND_BG_HOVER_SHARE = 0.24;\n\n/** `--brand-muted`, `--brand-bg` and `--brand-bg-hover` for `t`, as tokens.css mixes them.\n * tokens-css-audit.test.ts holds the three shares equal to the stylesheet's. */\nexport function brandSoft(t: Pick<TokenSet, \"brand\" | \"textPrimary\" | \"bgSurface\">): {\n brandMuted: string;\n brandBg: string;\n brandBgHover: string;\n} {\n return {\n brandMuted: mix(t.brand, t.textPrimary, BRAND_MUTED_SHARE),\n brandBg: mix(t.brand, t.bgSurface, BRAND_BG_SHARE),\n brandBgHover: mix(t.brand, t.bgSurface, BRAND_BG_HOVER_SHARE),\n };\n}\n\n/** WCAG 1.4.11 for a component's boundary. */\nconst BORDER_TARGET = 3;\n/** `--border-strong` in tokens.css: 55 % border, 45 % text. */\nconst BORDER_STRONG_SHARE = 0.45;\n\nfunction worstContrast(color: string, t: TokenSet): number {\n return Math.min(contrast(color, t.bgPage), contrast(color, t.bgSurface), contrast(color, t.bgSurface2));\n}\n\nfunction steppedBorder(t: TokenSet): string {\n // The share of `--text-primary` in the border: at least --border-strong's, more until\n // 3:1. Monotonic in the share (the mix walks from the border to the text, away from\n // every surface), so a bisection finds the least that clears it.\n let lo = BORDER_STRONG_SHARE;\n if (worstContrast(mix(t.border, t.textPrimary, 1 - lo), t) >= BORDER_TARGET) return mix(t.border, t.textPrimary, 1 - lo);\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) / 2;\n if (worstContrast(mix(t.border, t.textPrimary, 1 - mid), t) >= BORDER_TARGET) hi = mid;\n else lo = mid;\n }\n return mix(t.border, t.textPrimary, 1 - hi);\n}\n\n/** The four stepped values for `t`. Pure. */\nexport function contrastStep(t: TokenSet): ContrastStep {\n return {\n textSecondary: mix(t.textSecondary, t.textPrimary, 0.5),\n textMuted: t.textSecondary,\n textPlaceholder: t.textMuted,\n border: steppedBorder(t),\n };\n}\n\n/* ── The token set last written to an element ───────────────────────────── */\n\nconst lastWritten = new WeakMap<HTMLElement, TokenSet>();\n\n/** Remember the set `applyTokenSet` wrote, so a contrast change can re-apply it. */\nexport function rememberTokenSet(el: HTMLElement, t: TokenSet): void {\n lastWritten.set(el, t);\n}\n\n/** The set `applyTokenSet` last wrote to `el`, or undefined when nothing did — an app\n * without the palette layer, whose base tokens come from tokens.css. */\nexport function rememberedTokenSet(el: HTMLElement): TokenSet | undefined {\n return lastWritten.get(el);\n}\n"],"mappings":";AAAA,SAAS,UAAU,YAAY,UAAU,YAAY,aAAa;AA0B3D,MAAM,wBAAwB,CAAC,oBAAoB,gBAAgB,sBAAsB,UAAU;AAe1G,SAAS,MAAM,KAAyB;AACtC,QAAM,MAAM,SAAS,GAAG;AACxB,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,EAAE,GAAG,GAAG,EAAE,IAAI,WAAW,GAAG;AAClC,QAAM,MAAO,IAAI,KAAK,KAAM;AAC5B,SAAO,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,GAAG,GAAG,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE;AACzD;AAMO,SAAS,IAAI,GAAW,GAAW,GAAmB;AAC3D,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,IAAI,MAAM,CAAC;AACjB,MAAI,CAAC,KAAK,CAAC,EAAG,QAAO;AACrB,QAAM,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,IAAI;AAC/B,QAAM,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,IAAI;AAC/B,QAAM,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,IAAI;AAC/B,QAAM,IA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GAA2B;AACtD,SAAO;AAAA,IACL,eAAe,IAAI,EAAE,eAAe,EAAE,aAAa,GAAG;AAAA,IACtD,WAAW,EAAE;AAAA,IACb,iBAAiB,EAAE;AAAA,IACnB,QAAQ,cAAc,CAAC;AAAA,EACzB;AACF;AAIA,MAAM,cAAc,oBAAI,QAA+B;AAGhD,SAAS,iBAAiB,IAAiB,GAAmB;AACnE,cAAY,IAAI,IAAI,CAAC;AACvB;AAIO,SAAS,mBAAmB,IAAuC;AACxE,SAAO,YAAY,IAAI,EAAE;AAC3B;","names":[]}
1
+ {"version":3,"sources":["../../src/theme/contrast-tokens.ts"],"sourcesContent":["import { contrast, hexToOklch, luminance, oklchToHex, oklchToRgb, parseHex, rgbToOklch, solveLightness, toHex } from \"./color\";\nimport type { TokenSet } from \"./palette-presets\";\n\n/**\n * The \"More contrast\" step on a token set (docs/text-size-harmonization.md §5, §10.5).\n * INTERNAL — `applyTokenSet` and the contrast layer share it; it is not re-exported.\n *\n * The step happens HERE, in JS, because the tokens it changes are written inline on\n * `<html>` by `applyTokenSet`: an inline value beats any `[data-contrast=more]` rule and\n * any `@media (prefers-contrast: more)` block, so a stylesheet cannot do it (§10.5, the\n * keksdose review). `--text-placeholder` is a CSS-derived token, and it is written inline\n * here too rather than redefined per attribute in tokens.css.\n *\n * What moves (§5):\n * - `--text-muted` becomes the set's `--text-secondary`;\n * - `--text-secondary` moves halfway to `--text-primary`;\n * - `--text-placeholder` becomes the set's `--text-muted` (4.6–5.5:1 on every shipped\n * preset, where the CSS formula gives 2.4–2.8:1) — the order primary > secondary >\n * muted > placeholder survives the step;\n * - `--border` moves toward `--text-primary` until it clears 3:1 against the worst of the\n * three surfaces (WCAG 1.4.11, a field's boundary), and never less far than\n * `--border-strong`'s 45 % — so every border is at least as strong as a \"strong\" one was.\n * `--border-strong` stays derived in tokens.css and grows with it;\n * - in a LIGHT set only (0.36, docs/colour-roles-harmonization.md §13): the well\n * (`--bg-surface-2`) becomes {@link WELL_INK_MORE} of `--text-primary` mixed into the\n * card, and each of the four money colours that falls under 4.5:1 on that well is\n * solved darker at its own hue and chroma. The border above is solved against the\n * stepped well. A dark set's well stands 1.11–1.13:1 from its card already, and its\n * money has no room: nothing of it steps.\n *\n * What does NOT move here, because it is not inline: the light status, hue and field-sync\n * literals and `--bg-active` step in tokens.css's `:root[data-contrast=\"more\"]:not(.dark)`\n * block, solved over these stepped wells.\n */\n\n/** The custom properties a contrast step writes. The last five only for a light set. */\nexport const CONTRAST_STEPPED_VARS = [\n \"--text-secondary\",\n \"--text-muted\",\n \"--text-placeholder\",\n \"--border\",\n \"--bg-surface-2\",\n \"--money-income\",\n \"--money-expense\",\n \"--money-net\",\n \"--money-neutral\",\n] as const;\n\n/** The light well under More contrast and the money that reads on it (§13.4). */\nexport interface WellStep {\n bgSurface2: string;\n moneyIncome: string;\n moneyExpense: string;\n moneyNet: string;\n moneyNeutral: string;\n}\n\nexport interface ContrastStep {\n textSecondary: string;\n textMuted: string;\n textPlaceholder: string;\n border: string;\n /** The stepped well and money, or null for a dark set (which does not step them). */\n well: WellStep | null;\n}\n\ninterface Lab {\n l: number;\n a: number;\n b: number;\n}\n\nfunction toLab(hex: string): Lab | null {\n const rgb = parseHex(hex);\n if (!rgb) return null;\n const { l, c, h } = rgbToOklch(rgb);\n const rad = (h * Math.PI) / 180;\n return { l, a: c * Math.cos(rad), b: c * Math.sin(rad) };\n}\n\n/** `color-mix(in oklab, a p, b)` as a hex — the same formula tokens.css's derived roles\n * use, so a stepped value sits where the stylesheet would have put it. A colour that is\n * not hex (a consumer's own token set) comes back unmixed. The deriver mixes with it\n * too (`--bg-hover`, `--brand-muted`, `--brand-bg`, `--brand-bg-hover`). */\nexport function mix(a: string, b: string, p: number): string {\n const A = toLab(a);\n const B = toLab(b);\n if (!A || !B) return a;\n const l = A.l * p + B.l * (1 - p);\n const x = A.a * p + B.a * (1 - p);\n const y = A.b * p + B.b * (1 - p);\n const c = Math.hypot(x, y);\n const h = c < 1e-6 ? 0 : ((Math.atan2(y, x) * 180) / Math.PI + 360) % 360;\n return toHex(oklchToRgb({ l, c, h }));\n}\n\n/**\n * `--bg-hover` in tokens.css: this share of `--text-primary` mixed into `--bg-surface`.\n *\n * 5.5 %, down from 7 % in 0.33 (docs/colour-roles-harmonization.md §12.10): a hovered row\n * on a card is the darkest fill (in dark, the lightest) that text sits on, and at 7 % the\n * light status colours, the money colours and Ink/Moss/Plum's muted text fell to\n * 4.25–4.49:1 on it. The status literals are fixed, the same in every preset, so the\n * hover moved instead: text wins over the hover's step. At 5.5 % the step from the card\n * is still 1.09–1.13:1, above the 1.08:1 the kit's hover rule asks (§12.2). The deriver\n * solves the money colours against this fill, and tokens-css-audit.test.ts measures\n * every text role on it in every shipped preset, so the two cannot part.\n */\nexport const HOVER_INK = 0.055;\n\n/** The card's hover fill (`--bg-hover`) for `t`, as tokens.css mixes it. */\nexport function hoverFill(t: Pick<TokenSet, \"textPrimary\" | \"bgSurface\">): string {\n return mix(t.textPrimary, t.bgSurface, HOVER_INK);\n}\n\n/**\n * The light well under More contrast: this share of `--text-primary` mixed into the card,\n * `--bg-hover`'s formula at a larger share (0.36, docs/colour-roles-harmonization.md §13).\n *\n * In light the well is the page (§5.3), 1.09–1.11:1 from the card. At 10 % it stands\n * 1.19–1.24:1 from it, about twice that. The rule it is held to: **the stepped well stands\n * at least 1.17:1 from the card**, two of the hover rule's 1.08 steps; 9 % is the least\n * that clears it in every shipped preset, with no room. The step cannot ship alone: on a\n * 10 % well money, status and two hues read 4.07–4.28:1, so the money is solved with it\n * here and the status and hue literals in tokens.css.\n */\nexport const WELL_INK_MORE = 0.1;\n\n/** The least the stepped light well stands from the card (§13.3, decision 2). */\nexport const WELL_STEP_MIN = 1.17;\n\n/** True when `t` is a light set: its body ink darker than its card. */\nfunction isLightSet(t: Pick<TokenSet, \"textPrimary\" | \"bgSurface\">): boolean | null {\n const ink = parseHex(t.textPrimary);\n const card = parseHex(t.bgSurface);\n if (!ink || !card) return null;\n return luminance(ink) < luminance(card);\n}\n\n/** Money as text: WCAG 1.4.3 AA. */\nconst MONEY_TARGET = 4.5;\n\n/** `color` as it is when it clears 4.5:1 on `well`, else solved darker at its own hue and\n * chroma until it does — measured on the hex (`solveLightness`). */\nfunction moneyOn(color: string, well: string): string {\n if (contrast(color, well) >= MONEY_TARGET) return color;\n const lch = hexToOklch(color);\n const bg = parseHex(well);\n if (!lch || !bg) return color;\n const l = solveLightness(MONEY_TARGET, bg, lch.h, lch.c, \"darker\");\n return oklchToHex({ l, c: lch.c, h: lch.h });\n}\n\n/** The light well under More contrast for `t`, or null for a dark set (or one whose ink or\n * card is not hex, which cannot be mixed). The deriver solves the brand against it. */\nexport function steppedWellFill(t: Pick<TokenSet, \"textPrimary\" | \"bgSurface\">): string | null {\n return isLightSet(t) ? mix(t.textPrimary, t.bgSurface, WELL_INK_MORE) : null;\n}\n\n/** The stepped well and money of a light set, or null (see {@link steppedWellFill}). */\nfunction wellStep(t: TokenSet): WellStep | null {\n const well = steppedWellFill(t);\n if (!well) return null;\n return {\n bgSurface2: well,\n moneyIncome: moneyOn(t.moneyIncome, well),\n moneyExpense: moneyOn(t.moneyExpense, well),\n moneyNet: moneyOn(t.moneyNet, well),\n moneyNeutral: moneyOn(t.moneyNeutral, well),\n };\n}\n\n/**\n * `--brand-muted` in tokens.css: this share of `--brand` mixed into `--text-primary`.\n *\n * 62 %, down from 70 % in 0.33 (docs/colour-roles-harmonization.md §12.11): the brand as\n * text sits on its soft chip HOVERED too (`--brand-bg-hover` — ButtonGroupLink's current\n * page, a selected day), and at 70 % it read 4.08–4.42:1 there in Default and Moss light\n * and in Ink, Moss, Plum and Contrast dark. The brand could not move instead: the dark\n * brands would have flipped their white label to the dark ink. Nor could the chip's hover\n * lighten: by the time the text cleared 4.5:1 the hover sat 1.00:1 from the chip it\n * hovers. So the text moves toward the ink, as `--bg-hover` moved for its text.\n */\nexport const BRAND_MUTED_SHARE = 0.62;\n/** `--brand-bg` and `--brand-bg-hover` in tokens.css: these shares of `--brand` mixed\n * into `--bg-surface`. */\nexport const BRAND_BG_SHARE = 0.14;\nexport const BRAND_BG_HOVER_SHARE = 0.24;\n\n/** `--brand-muted`, `--brand-bg` and `--brand-bg-hover` for `t`, as tokens.css mixes them.\n * tokens-css-audit.test.ts holds the three shares equal to the stylesheet's. */\nexport function brandSoft(t: Pick<TokenSet, \"brand\" | \"textPrimary\" | \"bgSurface\">): {\n brandMuted: string;\n brandBg: string;\n brandBgHover: string;\n} {\n return {\n brandMuted: mix(t.brand, t.textPrimary, BRAND_MUTED_SHARE),\n brandBg: mix(t.brand, t.bgSurface, BRAND_BG_SHARE),\n brandBgHover: mix(t.brand, t.bgSurface, BRAND_BG_HOVER_SHARE),\n };\n}\n\n/** WCAG 1.4.11 for a component's boundary. */\nconst BORDER_TARGET = 3;\n/** `--border-strong` in tokens.css: 55 % border, 45 % text. */\nconst BORDER_STRONG_SHARE = 0.45;\n\n/** The worst of the three surfaces; `well`, when the step has one, in place of the set's. */\nfunction worstContrast(color: string, t: TokenSet, well: string): number {\n return Math.min(contrast(color, t.bgPage), contrast(color, t.bgSurface), contrast(color, well));\n}\n\nfunction steppedBorder(t: TokenSet, well: WellStep | null): string {\n // The share of `--text-primary` in the border: at least --border-strong's, more until\n // 3:1. Monotonic in the share (the mix walks from the border to the text, away from\n // every surface), so a bisection finds the least that clears it. Against the stepped\n // light well (§13.4), which is the darkest surface under More contrast.\n const surface2 = well?.bgSurface2 ?? t.bgSurface2;\n let lo = BORDER_STRONG_SHARE;\n if (worstContrast(mix(t.border, t.textPrimary, 1 - lo), t, surface2) >= BORDER_TARGET) return mix(t.border, t.textPrimary, 1 - lo);\n let hi = 1;\n for (let i = 0; i < 16; i++) {\n const mid = (lo + hi) / 2;\n if (worstContrast(mix(t.border, t.textPrimary, 1 - mid), t, surface2) >= BORDER_TARGET) hi = mid;\n else lo = mid;\n }\n return mix(t.border, t.textPrimary, 1 - hi);\n}\n\n/** The stepped values for `t`: the four text and line tokens, and for a light set the\n * well and money (`well`, null in dark). Pure. */\nexport function contrastStep(t: TokenSet): ContrastStep {\n const well = wellStep(t);\n return {\n textSecondary: mix(t.textSecondary, t.textPrimary, 0.5),\n textMuted: t.textSecondary,\n textPlaceholder: t.textMuted,\n border: steppedBorder(t, well),\n well,\n };\n}\n\n/* ── The token set last written to an element ───────────────────────────── */\n\nconst lastWritten = new WeakMap<HTMLElement, TokenSet>();\n\n/** Remember the set `applyTokenSet` wrote, so a contrast change can re-apply it. */\nexport function rememberTokenSet(el: HTMLElement, t: TokenSet): void {\n lastWritten.set(el, t);\n}\n\n/** The set `applyTokenSet` last wrote to `el`, or undefined when nothing did — an app\n * without the palette layer, whose base tokens come from tokens.css. */\nexport function rememberedTokenSet(el: HTMLElement): TokenSet | undefined {\n return lastWritten.get(el);\n}\n"],"mappings":";AAAA,SAAS,UAAU,YAAY,WAAW,YAAY,YAAY,UAAU,YAAY,gBAAgB,aAAa;AAoC9G,MAAM,wBAAwB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA0BA,SAAS,MAAM,KAAyB;AACtC,QAAM,MAAM,SAAS,GAAG;AACxB,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,EAAE,GAAG,GAAG,EAAE,IAAI,WAAW,GAAG;AAClC,QAAM,MAAO,IAAI,KAAK,KAAM;AAC5B,SAAO,EAAE,GAAG,GAAG,IAAI,KAAK,IAAI,GAAG,GAAG,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE;AACzD;AAMO,SAAS,IAAI,GAAW,GAAW,GAAmB;AAC3D,QAAM,IAAI,MAAM,CAAC;AACjB,QAAM,IAAI,MAAM,CAAC;AACjB,MAAI,CAAC,KAAK,CAAC,EAAG,QAAO;AACrB,QAAM,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,IAAI;AAC/B,QAAM,IAAI,EAAE,IAAI,IAAI,EAAE,KAAK,IAAI;A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AA,IACtD,WAAW,EAAE;AAAA,IACb,iBAAiB,EAAE;AAAA,IACnB,QAAQ,cAAc,GAAG,IAAI;AAAA,IAC7B;AAAA,EACF;AACF;AAIA,MAAM,cAAc,oBAAI,QAA+B;AAGhD,SAAS,iBAAiB,IAAiB,GAAmB;AACnE,cAAY,IAAI,IAAI,CAAC;AACvB;AAIO,SAAS,mBAAmB,IAAuC;AACxE,SAAO,YAAY,IAAI,EAAE;AAC3B;","names":[]}
@@ -7,8 +7,10 @@ import type { PersistedAppearanceOptions } from "./text-size.js";
7
7
  * In force it is `<html data-contrast="more">` (else `"standard"`), which does two things:
8
8
  * - the inline colour tokens are re-written one step stronger (`applyTokenSet`'s
9
9
  * contrast flag — see contrast-tokens.ts for what moves and why it is JS);
10
- * - tokens.css raises `--focus-ring-width` from 2 to 3 px and turns on the `contrast:`
11
- * variant for anything else a component wants to change.
10
+ * - tokens.css raises `--focus-ring-width` from 2 to 3 px, in light deepens the status,
11
+ * hue and field-sync literals and `--bg-active` to read on the stepped well (0.36,
12
+ * colour-roles §13), and turns on the `contrast:` variant for anything else a
13
+ * component wants to change.
12
14
  *
13
15
  * The names below are frozen like the text size's: server-kit's `CONTRAST_MODES`, the
14
16
  * stored format, the attribute.
@@ -4,6 +4,7 @@ import { create } from "zustand";
4
4
  import { persist } from "zustand/middleware";
5
5
  import { logger } from "../lib/logger.js";
6
6
  import { readStored } from "../lib/safe-storage.js";
7
+ import { registerDeviceSetting } from "../lib/device-settings.js";
7
8
  import { useMediaQuery } from "../hooks/use-media-query.js";
8
9
  import { CONTRAST_STEPPED_VARS, contrastStep, rememberedTokenSet } from "./contrast-tokens.js";
9
10
  import { applyTokenSet, DEFAULT_PRESET } from "./palette-presets.js";
@@ -45,6 +46,13 @@ function reapplyContrastTokens(el) {
45
46
  el.style.setProperty("--text-muted", step.textMuted);
46
47
  el.style.setProperty("--text-placeholder", step.textPlaceholder);
47
48
  el.style.setProperty("--border", step.border);
49
+ if (step.well) {
50
+ el.style.setProperty("--bg-surface-2", step.well.bgSurface2);
51
+ el.style.setProperty("--money-income", step.well.moneyIncome);
52
+ el.style.setProperty("--money-expense", step.well.moneyExpense);
53
+ el.style.setProperty("--money-net", step.well.moneyNet);
54
+ el.style.setProperty("--money-neutral", step.well.moneyNeutral);
55
+ }
48
56
  }
49
57
  function applyContrast(level) {
50
58
  if (typeof document === "undefined") return;
@@ -93,6 +101,11 @@ function createContrastStore(storageKey) {
93
101
  "contrast"
94
102
  )
95
103
  );
104
+ registerDeviceSetting({
105
+ key: storageKey,
106
+ kind: "appearance",
107
+ reset: () => useContrastStore.getState().setContrast(null)
108
+ });
96
109
  function useApplyContrast({ account } = {}) {
97
110
  const device = useContrastStore((s) => s.contrast);
98
111
  const prefersMore = useMediaQuery(PREFERS_MORE_QUERY, false);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport { persist } from \"zustand/middleware\";\nimport { logger } from \"../lib/logger\";\nimport { readStored } from \"../lib/safe-storage\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { CONTRAST_STEPPED_VARS, contrastStep, rememberedTokenSet } from \"./contrast-tokens\";\nimport { applyTokenSet, DEFAULT_PRESET } from \"./palette-presets\";\nimport type { PersistedAppearanceOptions } from \"./text-size\";\n\n/**\n * \"More contrast\" (docs/text-size-harmonization.md §2.4, §5, §10.5, §10.6): a switch\n * beside the text size, on by choice or — on \"System\" — when the device asks for more\n * contrast (`prefers-contrast: more`). Any text size.\n *\n * In force it is `<html data-contrast=\"more\">` (else `\"standard\"`), which does two things:\n * - the inline colour tokens are re-written one step stronger (`applyTokenSet`'s\n * contrast flag — see contrast-tokens.ts for what moves and why it is JS);\n * - tokens.css raises `--focus-ring-width` from 2 to 3 px and turns on the `contrast:`\n * variant for anything else a component wants to change.\n *\n * The names below are frozen like the text size's: server-kit's `CONTRAST_MODES`, the\n * stored format, the attribute.\n */\n\n/** The stored choices (§10.6): server-kit's `CONTRAST_MODES`. \"system\" IS a stored value\n * — the PATCH rule refuses an explicit null, so null means only \"never chosen\". */\nexport const CONTRAST_MODES = [\"system\", \"standard\", \"more\"] as const;\n\nexport type ContrastMode = (typeof CONTRAST_MODES)[number];\n\n/** What is in force on `<html data-contrast>`: a mode with \"system\" resolved. */\nexport type ContrastLevel = \"standard\" | \"more\";\n\nconst CONTRAST_ATTRIBUTE = \"data-contrast\";\nconst PREFERS_MORE_QUERY = \"(prefers-contrast: more)\";\n\nexport function isContrastMode(value: unknown): value is ContrastMode {\n return value === \"system\" || value === \"standard\" || value === \"more\";\n}\n\n/** The mode in force: **this device's own choice → the account's → \"system\"** (§2.6).\n * The one order the pre-paint call, the apply hook and `useAccountAppearance` share. */\nexport function resolveContrastMode(device: unknown, account?: unknown): ContrastMode {\n if (isContrastMode(device)) return device;\n if (isContrastMode(account)) return account;\n return \"system\";\n}\n\n/** Whether the device asks for more contrast now. False without `matchMedia`. */\nexport function prefersMoreContrast(): boolean {\n try {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(PREFERS_MORE_QUERY).matches\n : false;\n } catch {\n return false;\n }\n}\n\n/** A mode to the level it puts on `<html>`; \"system\" asks the device (or takes\n * `prefersMore`, when the caller already knows). */\nexport function contrastLevel(mode: ContrastMode, prefersMore: boolean = prefersMoreContrast()): ContrastLevel {\n return mode === \"more\" || (mode === \"system\" && prefersMore) ? \"more\" : \"standard\";\n}\n\n/** The level `<html>` carries now; \"standard\" without one. */\nexport function readContrastLevel(): ContrastLevel {\n if (typeof document === \"undefined\") return \"standard\";\n return document.documentElement.getAttribute(CONTRAST_ATTRIBUTE) === \"more\" ? \"more\" : \"standard\";\n}\n\n/**\n * Re-write the contrast-dependent tokens on `el` for its current `data-contrast`.\n *\n * With a palette layer (`applyTokenSet` has written a set here), that set is applied\n * again and steps itself. Without one — an app whose base tokens come from tokens.css,\n * like Kurvenschmiede's — the four stepped tokens are written over the stylesheet for\n * the default preset in the current light/dark, or removed again.\n */\nfunction reapplyContrastTokens(el: HTMLElement): void {\n const written = rememberedTokenSet(el);\n if (written) {\n applyTokenSet(el, written);\n return;\n }\n for (const name of CONTRAST_STEPPED_VARS) el.style.removeProperty(name);\n if (el.getAttribute(CONTRAST_ATTRIBUTE) !== \"more\") return;\n const step = contrastStep(DEFAULT_PRESET[el.classList.contains(\"dark\") ? \"dark\" : \"light\"]);\n el.style.setProperty(\"--text-secondary\", step.textSecondary);\n el.style.setProperty(\"--text-muted\", step.textMuted);\n el.style.setProperty(\"--text-placeholder\", step.textPlaceholder);\n el.style.setProperty(\"--border\", step.border);\n}\n\n/** Put `level` on `<html>` and re-write the colour tokens for it. */\nexport function applyContrast(level: ContrastLevel): void {\n if (typeof document === \"undefined\") return;\n const root = document.documentElement;\n root.setAttribute(CONTRAST_ATTRIBUTE, level);\n reapplyContrastTokens(root);\n}\n\n/* ── Storage: the frozen format, the pre-paint call ─────────────────────── */\n\n/**\n * What a contrast store persists under its key — FROZEN, like the text size's:\n *\n * {\"state\":{\"contrast\":\"more\"},\"version\":1}\n *\n * `contrast` is one of {@link CONTRAST_MODES}, or `null` / absent when this device never\n * chose.\n */\nexport interface PersistedContrast {\n state?: { contrast?: ContrastMode | null };\n version?: number;\n}\n\n/** This device's own choice under `storageKey`, or `null` when it never chose. */\nexport function readPersistedContrast(storageKey: string): ContrastMode | null {\n try {\n const blob = JSON.parse(readStored(storageKey) ?? \"null\") as PersistedContrast | null;\n const mode = blob?.state?.contrast;\n return isContrastMode(mode) ? mode : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Pre-paint (§10.3, §10.5): this device's choice under `storageKey` — else the account's\n * last known value, else \"system\" — resolved against `prefers-contrast` and applied\n * BEFORE `createRoot`. Call it next to `applyPersistedPalette`, in EITHER order — the\n * palette steps itself when `data-contrast` is already set, and this re-applies the\n * palette's set when it is not; no app has to put one first (0.32.1, keksdose's 0.32\n * report asked which). Returns the level applied.\n */\nexport function applyPersistedContrast(storageKey: string, options: PersistedAppearanceOptions = {}): ContrastLevel {\n let account: unknown;\n try {\n account = options.account?.();\n } catch {\n account = undefined;\n }\n const level = contrastLevel(resolveContrastMode(readPersistedContrast(storageKey), account));\n applyContrast(level);\n return level;\n}\n\n/* ── The store ──────────────────────────────────────────────────────────── */\n\nexport interface ContrastState {\n /** This device's own choice (persisted), or `null` when it never chose — then the\n * account's value applies, else \"system\". */\n contrast: ContrastMode | null;\n /** Store this device's choice; `null` forgets it. */\n setContrast: (contrast: ContrastMode | null) => void;\n}\n\nexport interface ApplyContrastOptions {\n /** The account's value (`/auth/me`'s `contrast`): it applies while this device has no\n * choice of its own. */\n account?: string | null;\n}\n\n/**\n * Build a contrast store bound to a consumer-supplied localStorage key, shaped like\n * `createThemeStore` and {@link createTextSizeStore} (§6). It holds the DEVICE's choice;\n * the account's value comes in through `useApplyContrast({ account })`.\n *\n * `useApplyContrast` — mount it once near the root, beside `useApplyPalette`:\n * - puts the level on `<html>` and steps the tokens;\n * - on \"System\", follows `prefers-contrast: more` live (§10.5);\n * - without a palette layer, re-writes the stepped tokens when the light/dark class\n * changes, since they differ per theme.\n *\n * The persisted format is {@link PersistedContrast}, and frozen.\n */\nexport function createContrastStore(storageKey: string) {\n const useContrastStore = create<ContrastState>()(\n logger(\n persist(\n (set) => ({\n contrast: null,\n setContrast: (contrast) => set({ contrast: isContrastMode(contrast) ? contrast : null }),\n }),\n {\n name: storageKey,\n version: 1,\n partialize: (s) => ({ contrast: s.contrast }),\n merge: (persisted, current) => {\n const value = (persisted as { contrast?: unknown } | null)?.contrast;\n return { ...current, contrast: isContrastMode(value) ? value : null };\n },\n },\n ),\n \"contrast\",\n ),\n );\n\n function useApplyContrast({ account }: ApplyContrastOptions = {}): ContrastLevel {\n const device = useContrastStore((s) => s.contrast);\n // Subscribed whatever the mode (hooks cannot be skipped); only \"system\" reads it.\n const prefersMore = useMediaQuery(PREFERS_MORE_QUERY, false);\n const level = contrastLevel(resolveContrastMode(device, account), prefersMore);\n useEffect(() => {\n applyContrast(level);\n }, [level]);\n // Without a palette layer the stepped tokens are per theme: follow `.dark`.\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\") return;\n const root = document.documentElement;\n const observer = new MutationObserver(() => {\n if (!rememberedTokenSet(root)) reapplyContrastTokens(root);\n });\n observer.observe(root, { attributes: true, attributeFilter: [\"class\"] });\n return () => observer.disconnect();\n }, []);\n return level;\n }\n\n return { useContrastStore, useApplyContrast };\n}\n\nexport type ContrastStore = ReturnType<typeof createContrastStore>;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,cAAc,0BAA0B;AACxE,SAAS,eAAe,sBAAsB;AAoBvC,MAAM,iBAAiB,CAAC,UAAU,YAAY,MAAM;AAO3D,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAEpB,SAAS,eAAe,OAAuC;AACpE,SAAO,UAAU,YAAY,UAAU,cAAc,UAAU;AACjE;AAIO,SAAS,oBAAoB,QAAiB,SAAiC;AACpF,MAAI,eAAe,MAAM,EAAG,QAAO;AACnC,MAAI,eAAe,OAAO,EAAG,QAAO;AACpC,SAAO;AACT;AAGO,SAAS,sBAA+B;AAC7C,MAAI;AACF,WAAO,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,aACjE,OAAO,WAAW,kBAAkB,EAAE,UACtC;AAAA,EACN,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIO,SAAS,cAAc,MAAoB,cAAuB,oBAAoB,GAAkB;AAC7G,SAAO,SAAS,UAAW,SAAS,YAAY,cAAe,SAAS;AAC1E;AAGO,SAAS,oBAAmC;AACjD,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,SAAS,gBAAgB,aAAa,kBAAkB,MAAM,SAAS,SAAS;AACzF;AAUA,SAAS,sBAAsB,IAAuB;A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W,KAAK,CAAC;AAAA,QACzF;AAAA,QACA;AAAA,UACE,MAAM;AAAA,UACN,SAAS;AAAA,UACT,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS;AAAA,UAC3C,OAAO,CAAC,WAAW,YAAY;AAC7B,kBAAM,QAAS,WAA6C;AAC5D,mBAAO,EAAE,GAAG,SAAS,UAAU,eAAe,KAAK,IAAI,QAAQ,KAAK;AAAA,UACtE;AAAA,QACF;AAAA,MACF;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,WAAS,iBAAiB,EAAE,QAAQ,IAA0B,CAAC,GAAkB;AAC/E,UAAM,SAAS,iBAAiB,CAAC,MAAM,EAAE,QAAQ;AAEjD,UAAM,cAAc,cAAc,oBAAoB,KAAK;AAC3D,UAAM,QAAQ,cAAc,oBAAoB,QAAQ,OAAO,GAAG,WAAW;AAC7E,cAAU,MAAM;AACd,oBAAc,KAAK;AAAA,IACrB,GAAG,CAAC,KAAK,CAAC;AAEV,cAAU,MAAM;AACd,UAAI,OAAO,qBAAqB,YAAa;AAC7C,YAAM,OAAO,SAAS;AACtB,YAAM,WAAW,IAAI,iBAAiB,MAAM;AAC1C,YAAI,CAAC,mBAAmB,IAAI,EAAG,uBAAsB,IAAI;AAAA,MAC3D,CAAC;AACD,eAAS,QAAQ,MAAM,EAAE,YAAY,MAAM,iBAAiB,CAAC,OAAO,EAAE,CAAC;AACvE,aAAO,MAAM,SAAS,WAAW;AAAA,IACnC,GAAG,CAAC,CAAC;AACL,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,kBAAkB,iBAAiB;AAC9C;","names":[]}
1
+ {"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { create } from \"zustand\";\nimport { persist } from \"zustand/middleware\";\nimport { logger } from \"../lib/logger\";\nimport { readStored } from \"../lib/safe-storage\";\nimport { registerDeviceSetting } from \"../lib/device-settings\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { CONTRAST_STEPPED_VARS, contrastStep, rememberedTokenSet } from \"./contrast-tokens\";\nimport { applyTokenSet, DEFAULT_PRESET } from \"./palette-presets\";\nimport type { PersistedAppearanceOptions } from \"./text-size\";\n\n/**\n * \"More contrast\" (docs/text-size-harmonization.md §2.4, §5, §10.5, §10.6): a switch\n * beside the text size, on by choice or — on \"System\" — when the device asks for more\n * contrast (`prefers-contrast: more`). Any text size.\n *\n * In force it is `<html data-contrast=\"more\">` (else `\"standard\"`), which does two things:\n * - the inline colour tokens are re-written one step stronger (`applyTokenSet`'s\n * contrast flag — see contrast-tokens.ts for what moves and why it is JS);\n * - tokens.css raises `--focus-ring-width` from 2 to 3 px, in light deepens the status,\n * hue and field-sync literals and `--bg-active` to read on the stepped well (0.36,\n * colour-roles §13), and turns on the `contrast:` variant for anything else a\n * component wants to change.\n *\n * The names below are frozen like the text size's: server-kit's `CONTRAST_MODES`, the\n * stored format, the attribute.\n */\n\n/** The stored choices (§10.6): server-kit's `CONTRAST_MODES`. \"system\" IS a stored value\n * — the PATCH rule refuses an explicit null, so null means only \"never chosen\". */\nexport const CONTRAST_MODES = [\"system\", \"standard\", \"more\"] as const;\n\nexport type ContrastMode = (typeof CONTRAST_MODES)[number];\n\n/** What is in force on `<html data-contrast>`: a mode with \"system\" resolved. */\nexport type ContrastLevel = \"standard\" | \"more\";\n\nconst CONTRAST_ATTRIBUTE = \"data-contrast\";\nconst PREFERS_MORE_QUERY = \"(prefers-contrast: more)\";\n\nexport function isContrastMode(value: unknown): value is ContrastMode {\n return value === \"system\" || value === \"standard\" || value === \"more\";\n}\n\n/** The mode in force: **this device's own choice → the account's → \"system\"** (§2.6).\n * The one order the pre-paint call, the apply hook and `useAccountAppearance` share. */\nexport function resolveContrastMode(device: unknown, account?: unknown): ContrastMode {\n if (isContrastMode(device)) return device;\n if (isContrastMode(account)) return account;\n return \"system\";\n}\n\n/** Whether the device asks for more contrast now. False without `matchMedia`. */\nexport function prefersMoreContrast(): boolean {\n try {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\"\n ? window.matchMedia(PREFERS_MORE_QUERY).matches\n : false;\n } catch {\n return false;\n }\n}\n\n/** A mode to the level it puts on `<html>`; \"system\" asks the device (or takes\n * `prefersMore`, when the caller already knows). */\nexport function contrastLevel(mode: ContrastMode, prefersMore: boolean = prefersMoreContrast()): ContrastLevel {\n return mode === \"more\" || (mode === \"system\" && prefersMore) ? \"more\" : \"standard\";\n}\n\n/** The level `<html>` carries now; \"standard\" without one. */\nexport function readContrastLevel(): ContrastLevel {\n if (typeof document === \"undefined\") return \"standard\";\n return document.documentElement.getAttribute(CONTRAST_ATTRIBUTE) === \"more\" ? \"more\" : \"standard\";\n}\n\n/**\n * Re-write the contrast-dependent tokens on `el` for its current `data-contrast`.\n *\n * With a palette layer (`applyTokenSet` has written a set here), that set is applied\n * again and steps itself. Without one — an app whose base tokens come from tokens.css,\n * like Kurvenschmiede's — the stepped tokens are written over the stylesheet for the\n * default preset in the current light/dark, or removed again: the four text and line\n * tokens in both modes, and in light the well and the four money colours too (0.36,\n * docs/colour-roles-harmonization.md §13.3 decision 10). In dark those five stay removed,\n * so the stylesheet's dark well and money paint.\n *\n * It never calls `applyTokenSet` here: that would remember a token set on `<html>`, and\n * this app would then take the palette branch above, which a theme switch does not re-run\n * (the class observer in `useApplyContrast` re-writes only while nothing is remembered).\n */\nfunction reapplyContrastTokens(el: HTMLElement): void {\n const written = rememberedTokenSet(el);\n if (written) {\n applyTokenSet(el, written);\n return;\n }\n for (const name of CONTRAST_STEPPED_VARS) el.style.removeProperty(name);\n if (el.getAttribute(CONTRAST_ATTRIBUTE) !== \"more\") return;\n const step = contrastStep(DEFAULT_PRESET[el.classList.contains(\"dark\") ? \"dark\" : \"light\"]);\n el.style.setProperty(\"--text-secondary\", step.textSecondary);\n el.style.setProperty(\"--text-muted\", step.textMuted);\n el.style.setProperty(\"--text-placeholder\", step.textPlaceholder);\n el.style.setProperty(\"--border\", step.border);\n // One line per variable, not a loop: the step's fields are not the variables' names.\n if (step.well) {\n el.style.setProperty(\"--bg-surface-2\", step.well.bgSurface2);\n el.style.setProperty(\"--money-income\", step.well.moneyIncome);\n el.style.setProperty(\"--money-expense\", step.well.moneyExpense);\n el.style.setProperty(\"--money-net\", step.well.moneyNet);\n el.style.setProperty(\"--money-neutral\", step.well.moneyNeutral);\n }\n}\n\n/** Put `level` on `<html>` and re-write the colour tokens for it. */\nexport function applyContrast(level: ContrastLevel): void {\n if (typeof document === \"undefined\") return;\n const root = document.documentElement;\n root.setAttribute(CONTRAST_ATTRIBUTE, level);\n reapplyContrastTokens(root);\n}\n\n/* ── Storage: the frozen format, the pre-paint call ─────────────────────── */\n\n/**\n * What a contrast store persists under its key — FROZEN, like the text size's:\n *\n * {\"state\":{\"contrast\":\"more\"},\"version\":1}\n *\n * `contrast` is one of {@link CONTRAST_MODES}, or `null` / absent when this device never\n * chose.\n */\nexport interface PersistedContrast {\n state?: { contrast?: ContrastMode | null };\n version?: number;\n}\n\n/** This device's own choice under `storageKey`, or `null` when it never chose. */\nexport function readPersistedContrast(storageKey: string): ContrastMode | null {\n try {\n const blob = JSON.parse(readStored(storageKey) ?? \"null\") as PersistedContrast | null;\n const mode = blob?.state?.contrast;\n return isContrastMode(mode) ? mode : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Pre-paint (§10.3, §10.5): this device's choice under `storageKey` — else the account's\n * last known value, else \"system\" — resolved against `prefers-contrast` and applied\n * BEFORE `createRoot`. Call it next to `applyPersistedPalette`, in EITHER order — the\n * palette steps itself when `data-contrast` is already set, and this re-applies the\n * palette's set when it is not; no app has to put one first (0.32.1, keksdose's 0.32\n * report asked which). Returns the level applied.\n */\nexport function applyPersistedContrast(storageKey: string, options: PersistedAppearanceOptions = {}): ContrastLevel {\n let account: unknown;\n try {\n account = options.account?.();\n } catch {\n account = undefined;\n }\n const level = contrastLevel(resolveContrastMode(readPersistedContrast(storageKey), account));\n applyContrast(level);\n return level;\n}\n\n/* ── The store ──────────────────────────────────────────────────────────── */\n\nexport interface ContrastState {\n /** This device's own choice (persisted), or `null` when it never chose — then the\n * account's value applies, else \"system\". */\n contrast: ContrastMode | null;\n /** Store this device's choice; `null` forgets it. */\n setContrast: (contrast: ContrastMode | null) => void;\n}\n\nexport interface ApplyContrastOptions {\n /** The account's value (`/auth/me`'s `contrast`): it applies while this device has no\n * choice of its own. */\n account?: string | null;\n}\n\n/**\n * Build a contrast store bound to a consumer-supplied localStorage key, shaped like\n * `createThemeStore` and {@link createTextSizeStore} (§6). It holds the DEVICE's choice;\n * the account's value comes in through `useApplyContrast({ account })`.\n *\n * `useApplyContrast` — mount it once near the root, beside `useApplyPalette`:\n * - puts the level on `<html>` and steps the tokens;\n * - on \"System\", follows `prefers-contrast: more` live (§10.5);\n * - without a palette layer, re-writes the stepped tokens when the light/dark class\n * changes, since they differ per theme.\n *\n * The persisted format is {@link PersistedContrast}, and frozen.\n */\nexport function createContrastStore(storageKey: string) {\n const useContrastStore = create<ContrastState>()(\n logger(\n persist(\n (set) => ({\n contrast: null,\n setContrast: (contrast) => set({ contrast: isContrastMode(contrast) ? contrast : null }),\n }),\n {\n name: storageKey,\n version: 1,\n partialize: (s) => ({ contrast: s.contrast }),\n merge: (persisted, current) => {\n const value = (persisted as { contrast?: unknown } | null)?.contrast;\n return { ...current, contrast: isContrastMode(value) ? value : null };\n },\n },\n ),\n \"contrast\",\n ),\n );\n // Reset this device's settings (docs/settings-harmonization.md §11.4): no choice on\n // this device, so `useApplyContrast` re-resolves to the account's mode, else \"system\",\n // and re-steps the tokens.\n registerDeviceSetting({\n key: storageKey,\n kind: \"appearance\",\n reset: () => useContrastStore.getState().setContrast(null),\n });\n\n function useApplyContrast({ account }: ApplyContrastOptions = {}): ContrastLevel {\n const device = useContrastStore((s) => s.contrast);\n // Subscribed whatever the mode (hooks cannot be skipped); only \"system\" reads it.\n const prefersMore = useMediaQuery(PREFERS_MORE_QUERY, false);\n const level = contrastLevel(resolveContrastMode(device, account), prefersMore);\n useEffect(() => {\n applyContrast(level);\n }, [level]);\n // Without a palette layer the stepped tokens are per theme: follow `.dark`.\n useEffect(() => {\n if (typeof MutationObserver === \"undefined\") return;\n const root = document.documentElement;\n const observer = new MutationObserver(() => {\n if (!rememberedTokenSet(root)) reapplyContrastTokens(root);\n });\n observer.observe(root, { attributes: true, attributeFilter: [\"class\"] });\n return () => observer.disconnect();\n }, []);\n return level;\n }\n\n return { useContrastStore, useApplyContrast };\n}\n\nexport type ContrastStore = ReturnType<typeof createContrastStore>;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB,cAAc,0BAA0B;AACxE,SAAS,eAAe,sBAAsB;AAsBvC,MAAM,iBAAiB,CAAC,UAAU,YAAY,MAAM;AAO3D,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAEpB,SAAS,eAAe,OAAuC;AACpE,SAAO,UAAU,YAAY,UAAU,cAAc,UAAU;AACjE;AAIO,SAAS,oBAAoB,QAAiB,SAAiC;AACpF,MAAI,eAAe,MAAM,EAAG,QAAO;AACnC,MAAI,eAAe,OAAO,EAAG,QAAO;AACpC,SAAO;AACT;AAGO,SAAS,sBAA+B;AAC7C,MAAI;AACF,WAAO,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,aACjE,OAAO,WAAW,kBAAkB,EAAE,UACtC;AAAA,EACN,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIO,SAAS,cAAc,MAAoB,cAAuB,oBAAoB,GAAkB;AAC7G,SAAO,SAAS,UAAW,SAAS,YAAY,cAAe,SAAS;AAC1E;AAGO,SAAS,oBAAmC;AACjD,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,SAAO,SAAS,gBAAgB,aAAa,kBAAkB,MAAM,SAAS,SAAS;AACzF;AAiBA,SAAS,sBAAsB,IAAuB;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E,YAAY,MAAM,iBAAiB,CAAC,OAAO,EAAE,CAAC;AACvE,aAAO,MAAM,SAAS,WAAW;AAAA,IACnC,GAAG,CAAC,CAAC;AACL,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,kBAAkB,iBAAiB;AAC9C;","names":[]}
@@ -1,6 +1,7 @@
1
1
  import type { ThemeMode } from "./theme-store.js";
2
2
  import type { TokenSet } from "./palette-presets.js";
3
3
  import type { CvdType, Oklch } from "./color.js";
4
+ import type { ContrastLevel } from "./contrast.js";
4
5
  /**
5
6
  * Build a whole palette from one brand colour, plus any number of colours pinned by
6
7
  * hand, with every contrast ratio SOLVED rather than chosen and then hoped for.
@@ -85,6 +86,8 @@ export interface ContrastReport {
85
86
  export interface DerivedPalette {
86
87
  tokens: TokenSet;
87
88
  semantic: SemanticTokens;
89
+ /** {@link auditPalette} at both contrast levels: the More-contrast checks carry a
90
+ * " (More contrast)" suffix (0.36). */
88
91
  audit: ContrastReport;
89
92
  /** Compromises the deriver had to make, in plain words. Never silent. */
90
93
  warnings: string[];
@@ -96,8 +99,19 @@ export declare function derivePalette({ anchors, mode, surfaceTint, textContrast
96
99
  * This is the part the shipped presets were missing. `derivePalette` runs it on the way
97
100
  * out, and the preset test runs it over everything the package ships, so a palette that
98
101
  * does not hold up cannot be merged with a comment claiming that it does.
102
+ *
103
+ * **`level: "more"`** (0.36, docs/colour-roles-harmonization.md §13.5) measures the set as
104
+ * More contrast paints it: the stepped secondary, muted and border, and in a light set the
105
+ * stepped well (as `bgSurface2`) and money — the same pairs, named with a " (More
106
+ * contrast)" suffix. Two things change with the level: the border is a field's boundary
107
+ * there, held to WCAG 1.4.11's 3:1 rather than the hairline's 1.1, and a light set's well
108
+ * must stand {@link WELL_STEP_MIN}:1 from the card. Pass `semantic` with tokens.css's More
109
+ * literals for a light set (the status colours step there); the status text is then
110
+ * measured on the stepped well too.
99
111
  */
100
- export declare function auditPalette(t: TokenSet, semantic?: SemanticTokens): ContrastReport;
112
+ export declare function auditPalette(set: TokenSet, semantic?: SemanticTokens, options?: {
113
+ level?: ContrastLevel;
114
+ }): ContrastReport;
101
115
  export interface ChartRampReport {
102
116
  colors: string[];
103
117
  /** Series pairs that are too close under normal vision or any simulated CVD. */
@@ -10,7 +10,7 @@ import {
10
10
  simulateCvd,
11
11
  solveLightness
12
12
  } from "./color.js";
13
- import { brandSoft, hoverFill } from "./contrast-tokens.js";
13
+ import { brandSoft, contrastStep, hoverFill, steppedWellFill, WELL_STEP_MIN } from "./contrast-tokens.js";
14
14
  const HUE_HOME = {
15
15
  danger: { hue: 27, slack: 14 },
16
16
  warning: { hue: 75, slack: 16 },
@@ -119,9 +119,11 @@ function derivePalette({
119
119
  const worstText = [worstSurface, hover].reduce(
120
120
  (a, b) => contrast(a, mode === "light" ? "#000000" : "#ffffff") < contrast(b, mode === "light" ? "#000000" : "#ffffff") ? a : b
121
121
  );
122
+ const moreWell = steppedWellFill({ textPrimary, bgSurface: surfaces.bgSurface });
123
+ const brandGround = moreWell ? [worstSurface, moreWell].reduce((a, b) => contrast(a, "#000000") < contrast(b, "#000000") ? a : b) : worstSurface;
122
124
  const brandChroma = Math.max(brand.c, 0.06);
123
- const brandRatio = contrast(anchors.brand, worstSurface);
124
- let brandHex = brandRatio >= 3 ? toHex(parseHex(anchors.brand)) : solveAgainst(brand.h, brandChroma, 3, worstSurface, mode);
125
+ const brandRatio = contrast(anchors.brand, brandGround);
126
+ let brandHex = brandRatio >= 3 ? toHex(parseHex(anchors.brand)) : solveAgainst(brand.h, brandChroma, 3, brandGround, mode);
125
127
  if (brandRatio < 3) {
126
128
  warnings.push(
127
129
  `brand ${anchors.brand} sits at ${brandRatio.toFixed(2)}:1 against the ${mode} surfaces, below the 3:1 WCAG 1.4.11 asks of a control boundary. Lightness was adjusted to ${brandHex}; hue and chroma are unchanged.`
@@ -132,7 +134,9 @@ function derivePalette({
132
134
  return Math.min(
133
135
  contrast(soft.brandMuted, worstText),
134
136
  contrast(soft.brandMuted, soft.brandBg),
135
- contrast(soft.brandMuted, soft.brandBgHover)
137
+ contrast(soft.brandMuted, soft.brandBgHover),
138
+ // …and on More contrast's light well, where a link button reads it (§13.3).
139
+ moreWell ? contrast(soft.brandMuted, moreWell) : Infinity
136
140
  );
137
141
  };
138
142
  for (let i = 0; i < 40 && brandMutedWorst(brandHex) < 4.5; i++) {
@@ -291,7 +295,11 @@ function derivePalette({
291
295
  chart: [],
292
296
  heat: deriveHeat(moneyIncome, moneyExpense, surfaces, mode)
293
297
  };
294
- return { tokens, semantic, audit: auditPalette(tokens, semantic), warnings };
298
+ const standard = auditPalette(tokens, semantic);
299
+ const more = auditPalette(tokens, void 0, { level: "more" });
300
+ const checks = [...standard.checks, ...more.checks];
301
+ const failures = checks.filter((c) => !c.passes);
302
+ return { tokens, semantic, audit: { checks, failures, passes: failures.length === 0 }, warnings };
295
303
  }
296
304
  function deriveHeat(income, expense, surfaces, mode) {
297
305
  const exp = hexToOklch(expense);
@@ -304,7 +312,23 @@ function deriveHeat(income, expense, surfaces, mode) {
304
312
  empty: mode === "light" ? "rgba(120,110,95,0.14)" : "rgba(160,170,190,0.10)"
305
313
  };
306
314
  }
307
- function auditPalette(t, semantic) {
315
+ function auditPalette(set, semantic, options = {}) {
316
+ const more = options.level === "more";
317
+ const step = more ? contrastStep(set) : null;
318
+ const t = step ? {
319
+ ...set,
320
+ textSecondary: step.textSecondary,
321
+ textMuted: step.textMuted,
322
+ border: step.border,
323
+ ...step.well && {
324
+ bgSurface2: step.well.bgSurface2,
325
+ moneyIncome: step.well.moneyIncome,
326
+ moneyExpense: step.well.moneyExpense,
327
+ moneyNet: step.well.moneyNet,
328
+ moneyNeutral: step.well.moneyNeutral
329
+ }
330
+ } : set;
331
+ const suffix = more ? " (More contrast)" : "";
308
332
  const checks = [];
309
333
  const surfaces = [
310
334
  ["bgPage", t.bgPage],
@@ -318,11 +342,15 @@ function auditPalette(t, semantic) {
318
342
  const add = (pair, fg, bg, required, rule) => {
319
343
  const ratio = contrast(fg, bg);
320
344
  const slack = MIXED.test(pair) ? 0.05 : 0;
321
- checks.push({ pair, ratio, required, rule, passes: ratio >= required - slack });
345
+ checks.push({ pair: pair + suffix, ratio, required, rule, passes: ratio >= required - slack });
322
346
  };
323
347
  for (const [name, bg] of surfaces) {
324
348
  add(`brand on ${name}`, t.brand, bg, 3, "WCAG 1.4.11 graphical object");
325
- add(`border on ${name}`, t.border, bg, 1.1, "house rule: a hairline must be findable");
349
+ if (more) add(`border on ${name}`, t.border, bg, 3, "WCAG 1.4.11 \u2014 under More contrast a border bounds a field");
350
+ else add(`border on ${name}`, t.border, bg, 1.1, "house rule: a hairline must be findable");
351
+ }
352
+ if (step?.well) {
353
+ add("bgSurface2 on bgSurface", t.bgSurface2, t.bgSurface, WELL_STEP_MIN, "house rule: the well stands two hover steps from the card");
326
354
  }
327
355
  for (const [name, bg] of textGrounds) {
328
356
  add(`textPrimary on ${name}`, t.textPrimary, bg, 7, "WCAG 1.4.6 AAA body text");
@@ -353,6 +381,7 @@ function auditPalette(t, semantic) {
353
381
  ]) {
354
382
  add(`${name} on bgSurface`, fg, t.bgSurface, 4.5, "WCAG 1.4.3 \u2014 rendered as text");
355
383
  add(`${name} on bgHover`, fg, hover, 4.5, "WCAG 1.4.3 \u2014 rendered as text, on a hovered row");
384
+ if (step?.well) add(`${name} on bgSurface2`, fg, t.bgSurface2, 4.5, "WCAG 1.4.3 \u2014 rendered as text, on the well");
356
385
  }
357
386
  add("danger on dangerBg", semantic.danger, semantic.dangerBg, 4.5, "WCAG 1.4.3 \u2014 badge text");
358
387
  add("warning on warningBg", semantic.warning, semantic.warningBg, 4.5, "WCAG 1.4.3 \u2014 badge text");