@micha.bigler/ui-core-micha 3.14.3 → 4.0.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 (367) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +7 -0
  3. package/dist/auth/UserMenu.js +1 -1
  4. package/dist/auth/apiClient.js +7 -6
  5. package/dist/chat/ChatList.js +1 -1
  6. package/dist/chat/ChatThread.js +2 -1
  7. package/dist/chat/ChatWorkspace.js +1 -1
  8. package/dist/chat/ModelPicker.js +2 -5
  9. package/dist/chat/kitSxRegistry.js +9 -0
  10. package/dist/chat/useChatSocket.js +1 -1
  11. package/dist/components/LoginForm.js +1 -1
  12. package/dist/components/SecurityComponent.js +1 -1
  13. package/dist/components/UserListComponent.js +2 -8
  14. package/dist/components/charts/ChartFrame.js +1 -1
  15. package/dist/components/charts/ScatterChart.js +2 -1
  16. package/dist/components/charts/kitSxRegistry.js +6 -0
  17. package/dist/entries/charts.js +6 -0
  18. package/dist/entries/chat.js +8 -0
  19. package/dist/entries/markdown.js +1 -0
  20. package/dist/index.js +0 -14
  21. package/dist/layout/SectionNav.js +1 -1
  22. package/dist/messaging/AttachmentList.js +2 -2
  23. package/dist/messaging/Composer.js +2 -1
  24. package/dist/messaging/ConversationLaunchers.js +1 -4
  25. package/dist/messaging/ConversationList.js +1 -1
  26. package/dist/messaging/DirectMessageLauncher.js +1 -1
  27. package/dist/messaging/MessagingProvider.js +0 -0
  28. package/dist/messaging/PollCard.js +7 -5
  29. package/dist/messaging/ReadTicks.js +2 -2
  30. package/dist/messaging/Thread.js +5 -3
  31. package/dist/notifications/NotificationBell.js +4 -7
  32. package/dist/notifications/NotificationSettings.js +1 -1
  33. package/dist/onboarding/OnboardingProvider.js +3 -6
  34. package/dist/pages/AccountPage.js +1 -2
  35. package/dist/pages/LoginPage.js +2 -3
  36. package/dist/pages/PasswordChangePage.js +2 -3
  37. package/dist/pages/PasswordInvitePage.js +2 -3
  38. package/dist/pages/PasswordResetRequestPage.js +2 -3
  39. package/dist/pages/SignUpPage.js +2 -3
  40. package/dist/pages/SignupConfirmPage.js +2 -3
  41. package/dist/theme/createAppTheme.js +5 -4
  42. package/dist/theme/kitSxEntry.js +11 -0
  43. package/dist/theme/kitSxRegistry.js +2 -15
  44. package/dist/theme/themeCompleteness.js +3 -12
  45. package/dist/utils/auth-errors.js +4 -3
  46. package/package.json +41 -16
  47. package/.github/workflows/publish.yml +0 -126
  48. package/DESIGN.md +0 -60
  49. package/WORK_ORDERS.md +0 -148
  50. package/dev/entries.jsx +0 -721
  51. package/dev/fixtures.js +0 -26
  52. package/dev/main.jsx +0 -75
  53. package/dev/mockTransport.jsx +0 -128
  54. package/docs/CHART-LAYOUT.md +0 -157
  55. package/docs/DARK-TOKENS.md +0 -140
  56. package/docs/TYPE-SCALE.md +0 -111
  57. package/docs/messaging-deviations.md +0 -118
  58. package/index.html +0 -12
  59. package/renovate.json +0 -10
  60. package/scripts/chart-api-census.mjs +0 -415
  61. package/src/auth/AuthContext.jsx +0 -158
  62. package/src/auth/ReauthModal.jsx +0 -82
  63. package/src/auth/UserMenu.jsx +0 -121
  64. package/src/auth/apiClient.jsx +0 -232
  65. package/src/auth/authApi.jsx +0 -539
  66. package/src/auth/authConfig.jsx +0 -34
  67. package/src/auth/reauth.js +0 -47
  68. package/src/chat/ChatComposer.jsx +0 -36
  69. package/src/chat/ChatList.jsx +0 -87
  70. package/src/chat/ChatThread.jsx +0 -128
  71. package/src/chat/ChatWorkspace.jsx +0 -244
  72. package/src/chat/MarkdownReply.jsx +0 -22
  73. package/src/chat/ModelPicker.jsx +0 -85
  74. package/src/chat/api.js +0 -18
  75. package/src/chat/useChatSocket.js +0 -32
  76. package/src/chat/wire.js +0 -7
  77. package/src/components/AccessCodeManager.jsx +0 -288
  78. package/src/components/AccessCodeSingleUseToggle.jsx +0 -92
  79. package/src/components/AllowedEmailDomainsManager.jsx +0 -92
  80. package/src/components/AuthFactorRequirementCard.jsx +0 -95
  81. package/src/components/BulkInviteCsvTab.jsx +0 -198
  82. package/src/components/EmptyState.jsx +0 -38
  83. package/src/components/LoginForm.jsx +0 -159
  84. package/src/components/MFAComponent.jsx +0 -350
  85. package/src/components/MfaLoginComponent.jsx +0 -252
  86. package/src/components/MobileBottomNav.jsx +0 -82
  87. package/src/components/PasskeysComponent.jsx +0 -252
  88. package/src/components/PasswordChangeForm.jsx +0 -87
  89. package/src/components/PasswordResetRequestForm.jsx +0 -43
  90. package/src/components/PasswordSetForm.jsx +0 -97
  91. package/src/components/ProfileComponent.jsx +0 -348
  92. package/src/components/QrSignupManager.jsx +0 -404
  93. package/src/components/QrSignupValidityManager.jsx +0 -106
  94. package/src/components/RegistrationMethodsManager.jsx +0 -150
  95. package/src/components/SecurityComponent.jsx +0 -141
  96. package/src/components/SocialLoginButtons.jsx +0 -83
  97. package/src/components/SoftChip.jsx +0 -93
  98. package/src/components/StatTile.jsx +0 -39
  99. package/src/components/SupportRecoveryRequestsTab.jsx +0 -482
  100. package/src/components/TurnstileWidget.jsx +0 -99
  101. package/src/components/UserInviteComponent.jsx +0 -76
  102. package/src/components/UserListComponent.jsx +0 -618
  103. package/src/components/charts/BarChart.jsx +0 -102
  104. package/src/components/charts/ChartFrame.jsx +0 -214
  105. package/src/components/charts/LineChart.jsx +0 -126
  106. package/src/components/charts/ScatterChart.jsx +0 -299
  107. package/src/components/charts/TimeSeriesChart.jsx +0 -300
  108. package/src/components/charts/chartDefaults.js +0 -644
  109. package/src/components/charts/chartLabels.js +0 -36
  110. package/src/components/charts/exportChart.js +0 -258
  111. package/src/components/charts/formatters.js +0 -39
  112. package/src/components/charts/palette.js +0 -33
  113. package/src/components/charts/yearTickInterval.js +0 -7
  114. package/src/i18n/authTranslations.ts +0 -2651
  115. package/src/i18n/chartsTranslations.ts +0 -91
  116. package/src/i18n/chatTranslations.ts +0 -55
  117. package/src/i18n/messagingTranslations.ts +0 -120
  118. package/src/i18n/notificationsTranslations.ts +0 -32
  119. package/src/i18n/onboardingTranslations.ts +0 -29
  120. package/src/i18n/sectionNavTranslations.ts +0 -20
  121. package/src/i18n/uiCoreTranslations.js +0 -29
  122. package/src/i18n/userMenuTranslations.ts +0 -5
  123. package/src/index.js +0 -158
  124. package/src/layout/PageLayout.jsx +0 -36
  125. package/src/layout/SectionNav.jsx +0 -320
  126. package/src/messaging/AttachmentList.jsx +0 -145
  127. package/src/messaging/Composer.jsx +0 -197
  128. package/src/messaging/ConversationLaunchers.jsx +0 -51
  129. package/src/messaging/ConversationList.jsx +0 -109
  130. package/src/messaging/DirectMessageLauncher.jsx +0 -112
  131. package/src/messaging/MessageBubble.jsx +0 -183
  132. package/src/messaging/MessagingProvider.jsx +0 -0
  133. package/src/messaging/MessagingScopeConfig.jsx +0 -24
  134. package/src/messaging/PollCard.jsx +0 -163
  135. package/src/messaging/ReactionBar.jsx +0 -43
  136. package/src/messaging/ReadTicks.jsx +0 -82
  137. package/src/messaging/Thread.jsx +0 -195
  138. package/src/messaging/api.js +0 -48
  139. package/src/messaging/composerImageCompression.js +0 -35
  140. package/src/messaging/linkifyText.jsx +0 -37
  141. package/src/notifications/NotificationBell.jsx +0 -84
  142. package/src/notifications/NotificationSettings.jsx +0 -330
  143. package/src/notifications/NotificationsProvider.jsx +0 -224
  144. package/src/notifications/PopupSurface.jsx +0 -105
  145. package/src/notifications/api.js +0 -55
  146. package/src/notifications/feedApi.js +0 -18
  147. package/src/notifications/realtime.jsx +0 -138
  148. package/src/notifications/serviceWorker/sw.js +0 -50
  149. package/src/onboarding/OnboardingProvider.jsx +0 -326
  150. package/src/onboarding/OnboardingWizard.jsx +0 -61
  151. package/src/onboarding/WizardDialogShell.jsx +0 -51
  152. package/src/onboarding/api.js +0 -13
  153. package/src/onboarding/stepSelection.js +0 -16
  154. package/src/onboarding/steps/BrowserPushStep.jsx +0 -121
  155. package/src/onboarding/steps/CompleteNameStep.jsx +0 -46
  156. package/src/onboarding/steps/CookieConsentStep.jsx +0 -133
  157. package/src/onboarding/steps/PwaInstallStep.jsx +0 -47
  158. package/src/pages/AccountPage.jsx +0 -394
  159. package/src/pages/LoginPage.jsx +0 -343
  160. package/src/pages/PasswordChangePage.jsx +0 -62
  161. package/src/pages/PasswordInvitePage.jsx +0 -177
  162. package/src/pages/PasswordResetRequestPage.jsx +0 -68
  163. package/src/pages/SignUpPage.jsx +0 -268
  164. package/src/pages/SignupConfirmPage.jsx +0 -155
  165. package/src/testing/checkKitIntegration.js +0 -233
  166. package/src/theme/createAppTheme.js +0 -423
  167. package/src/theme/fonts.js +0 -3
  168. package/src/theme/index.js +0 -21
  169. package/src/theme/kitSxRegistry.js +0 -285
  170. package/src/theme/themeCompleteness.js +0 -1045
  171. package/src/theme/tokens.js +0 -478
  172. package/src/utils/auth-errors.js +0 -76
  173. package/src/utils/authService.js +0 -223
  174. package/src/utils/resolveErrorText.js +0 -28
  175. package/src/utils/webauthn.js +0 -51
  176. package/tests/AccountPage.profileStatements.test.jsx +0 -162
  177. package/tests/AccountPage.test.jsx +0 -200
  178. package/tests/AuthContext.test.jsx +0 -129
  179. package/tests/BarChart.test.jsx +0 -112
  180. package/tests/BrowserPushStep.test.jsx +0 -110
  181. package/tests/ChartFrame.test.jsx +0 -336
  182. package/tests/ConversationList.test.jsx +0 -144
  183. package/tests/CookieConsentStep.test.jsx +0 -69
  184. package/tests/EmptyState.test.jsx +0 -62
  185. package/tests/LineChart.test.jsx +0 -80
  186. package/tests/MessagingProvider.test.jsx +0 -50
  187. package/tests/MobileBottomNav.test.jsx +0 -319
  188. package/tests/NotificationBell.test.jsx +0 -60
  189. package/tests/NotificationSettings.test.jsx +0 -276
  190. package/tests/NotificationsProvider.test.jsx +0 -240
  191. package/tests/OnboardingProvider.test.jsx +0 -294
  192. package/tests/OnboardingWizard.test.jsx +0 -143
  193. package/tests/PasswordChangeForm.test.jsx +0 -70
  194. package/tests/PasswordInvitePage.test.jsx +0 -142
  195. package/tests/PasswordSetForm.test.jsx +0 -70
  196. package/tests/PopupSurface.test.jsx +0 -142
  197. package/tests/ProfileComponent.refresh.test.jsx +0 -194
  198. package/tests/QrSignupManager.registrationContext.test.jsx +0 -106
  199. package/tests/QrSignupManagerInfoBox.test.jsx +0 -49
  200. package/tests/ScatterChart.test.jsx +0 -270
  201. package/tests/SectionNav.test.jsx +0 -363
  202. package/tests/SignUpPage.test.jsx +0 -208
  203. package/tests/SoftChip.test.jsx +0 -105
  204. package/tests/StatTile.test.jsx +0 -57
  205. package/tests/Thread.test.jsx +0 -151
  206. package/tests/TimeSeriesChart.test.jsx +0 -367
  207. package/tests/UserListComponent.test.jsx +0 -192
  208. package/tests/UserMenu.test.jsx +0 -171
  209. package/tests/apiClientLanguage.test.js +0 -33
  210. package/tests/apiClientPublicPaths.test.js +0 -178
  211. package/tests/authApiLogin.test.js +0 -42
  212. package/tests/authApiRegistration.test.js +0 -31
  213. package/tests/authErrorCodeRendering.test.jsx +0 -77
  214. package/tests/authErrors.test.js +0 -74
  215. package/tests/authTranslations.test.js +0 -74
  216. package/tests/chart-api-census.test.js +0 -366
  217. package/tests/chartAxisTickBand.test.jsx +0 -95
  218. package/tests/chartDefaults.test.js +0 -902
  219. package/tests/chartLabels.test.js +0 -50
  220. package/tests/chartsPalette.test.js +0 -99
  221. package/tests/chatApi.test.js +0 -48
  222. package/tests/chatDriverNames.test.jsx +0 -71
  223. package/tests/chatExports.test.js +0 -3
  224. package/tests/chatList.test.jsx +0 -84
  225. package/tests/chatPicker.test.jsx +0 -82
  226. package/tests/chatSocket.test.jsx +0 -26
  227. package/tests/chatThread.test.jsx +0 -116
  228. package/tests/chatTranslations.test.js +0 -47
  229. package/tests/chatWorkspace.test.jsx +0 -234
  230. package/tests/checkKitIntegration.test.jsx +0 -219
  231. package/tests/createAppTheme.test.js +0 -132
  232. package/tests/createAppThemeDark.test.js +0 -127
  233. package/tests/createAppThemeLightGuard.test.js +0 -40
  234. package/tests/createAppThemePageContrast.test.js +0 -108
  235. package/tests/createAppThemeTypography.test.js +0 -53
  236. package/tests/errorCallSiteGuard.test.js +0 -32
  237. package/tests/exportChart.test.js +0 -313
  238. package/tests/feedApi.test.js +0 -46
  239. package/tests/fixtures/light-theme-baseline.json +0 -2234
  240. package/tests/i18nAggregate.test.js +0 -120
  241. package/tests/i18nGermanVariant.test.js +0 -65
  242. package/tests/loginPageErrorResolution.test.jsx +0 -102
  243. package/tests/messagingApi.test.js +0 -32
  244. package/tests/messagingChunk6.test.jsx +0 -116
  245. package/tests/messagingCompactBubble.test.jsx +0 -64
  246. package/tests/messagingComposer.test.jsx +0 -136
  247. package/tests/messagingComposerChunk5.test.jsx +0 -113
  248. package/tests/messagingContractConformance.test.js +0 -69
  249. package/tests/messagingDirectMessageLauncher.test.jsx +0 -151
  250. package/tests/messagingExports.test.js +0 -21
  251. package/tests/messagingInteractions.test.jsx +0 -136
  252. package/tests/messagingLastMessagePreview.test.jsx +0 -93
  253. package/tests/messagingLinkify.test.jsx +0 -51
  254. package/tests/messagingMessageActions.test.jsx +0 -163
  255. package/tests/messagingMsg6.test.jsx +0 -105
  256. package/tests/messagingMsg6f.test.jsx +0 -155
  257. package/tests/messagingMsg6g.test.jsx +0 -166
  258. package/tests/messagingMsg6h.test.jsx +0 -136
  259. package/tests/messagingMsg6i.test.jsx +0 -129
  260. package/tests/messagingPollRendering.test.jsx +0 -142
  261. package/tests/messagingReactionMerge.test.jsx +0 -77
  262. package/tests/messagingReadTicksTooltip.test.jsx +0 -36
  263. package/tests/messagingThreadReceipts.test.jsx +0 -178
  264. package/tests/messagingThreadingQuoting.test.jsx +0 -87
  265. package/tests/messagingUnreadLifecycle.test.jsx +0 -78
  266. package/tests/notificationsApi.test.js +0 -41
  267. package/tests/notificationsExports.test.js +0 -34
  268. package/tests/onboardingDescriptors.test.js +0 -132
  269. package/tests/packageTreeShaking.test.js +0 -126
  270. package/tests/realtime.test.jsx +0 -219
  271. package/tests/resolveErrorText.test.js +0 -72
  272. package/tests/stepSelection.test.js +0 -53
  273. package/tests/themeCompleteness.test.js +0 -626
  274. package/tests/timeSeriesLegend.test.js +0 -99
  275. package/tests/userScreenTranslations.test.jsx +0 -218
  276. package/tsconfig.build.json +0 -18
  277. package/vite.config.mjs +0 -6
  278. package/work-orders/AUTH-1.md +0 -74
  279. package/work-orders/AUTH-2.md +0 -74
  280. package/work-orders/AUTH-4.md +0 -183
  281. package/work-orders/AUTH-5.md +0 -154
  282. package/work-orders/AUTH-7.md +0 -181
  283. package/work-orders/AUTH-8.md +0 -184
  284. package/work-orders/CHART-1.md +0 -285
  285. package/work-orders/CHART-2.md +0 -222
  286. package/work-orders/CHART-3.md +0 -163
  287. package/work-orders/CHART-4.md +0 -203
  288. package/work-orders/CHART-5.md +0 -226
  289. package/work-orders/CHART-6.md +0 -428
  290. package/work-orders/CHART-7.md +0 -175
  291. package/work-orders/DX-1.md +0 -169
  292. package/work-orders/DX-2.md +0 -188
  293. package/work-orders/DX-3.md +0 -195
  294. package/work-orders/I18N-1.md +0 -254
  295. package/work-orders/I18N-3.md +0 -207
  296. package/work-orders/MSG-3.md +0 -375
  297. package/work-orders/MSG-3b.md +0 -1002
  298. package/work-orders/MSG-3c.md +0 -378
  299. package/work-orders/MSG-3d.md +0 -268
  300. package/work-orders/MSG-3e.md +0 -164
  301. package/work-orders/MSG-3f.md +0 -391
  302. package/work-orders/MSG-6e.md +0 -308
  303. package/work-orders/MSG-6f.md +0 -214
  304. package/work-orders/MSG-6g.md +0 -244
  305. package/work-orders/MSG-6h.md +0 -238
  306. package/work-orders/MSG-6i.md +0 -271
  307. package/work-orders/MSG-6j.md +0 -117
  308. package/work-orders/NOTIF-12.md +0 -214
  309. package/work-orders/NOTIF-13.md +0 -142
  310. package/work-orders/NOTIF-14.md +0 -151
  311. package/work-orders/PRIM-1.md +0 -177
  312. package/work-orders/SHELL-1.md +0 -255
  313. package/work-orders/SHELL-2.md +0 -197
  314. package/work-orders/SHELL-3.md +0 -359
  315. package/work-orders/SHELL-4.md +0 -351
  316. package/work-orders/SHELL-5.md +0 -345
  317. package/work-orders/SHELL-6.md +0 -210
  318. package/work-orders/THEME-1.md +0 -587
  319. package/work-orders/THEME-10.md +0 -303
  320. package/work-orders/THEME-11.md +0 -208
  321. package/work-orders/THEME-2.md +0 -339
  322. package/work-orders/THEME-3.md +0 -210
  323. package/work-orders/THEME-4.md +0 -271
  324. package/work-orders/THEME-5.md +0 -341
  325. package/work-orders/THEME-6.md +0 -247
  326. package/work-orders/THEME-7.md +0 -82
  327. package/work-orders/THEME-8.md +0 -211
  328. package/work-orders/THEME-9.md +0 -194
  329. package/work-orders/UCM-AUTH-10.md +0 -490
  330. package/work-orders/UCM-AUTH-11.md +0 -185
  331. package/work-orders/UCM-AUTH-12.md +0 -98
  332. package/work-orders/UCM-AUTH-13.md +0 -47
  333. package/work-orders/UCM-AUTH-9.md +0 -207
  334. package/work-orders/UCM-CHART-10.md +0 -150
  335. package/work-orders/UCM-CHART-11.md +0 -132
  336. package/work-orders/UCM-CHART-12.md +0 -348
  337. package/work-orders/UCM-CHART-13.md +0 -122
  338. package/work-orders/UCM-CHART-14.md +0 -198
  339. package/work-orders/UCM-CHART-15.md +0 -187
  340. package/work-orders/UCM-CHART-16.md +0 -169
  341. package/work-orders/UCM-CHART-17.md +0 -195
  342. package/work-orders/UCM-CHART-18.md +0 -200
  343. package/work-orders/UCM-CHART-8.md +0 -147
  344. package/work-orders/UCM-CHART-9.md +0 -265
  345. package/work-orders/UCM-CHAT-1.md +0 -190
  346. package/work-orders/UCM-CHAT-2.md +0 -75
  347. package/work-orders/UCM-DEP-1.md +0 -63
  348. package/work-orders/UCM-I18N-4.md +0 -226
  349. package/work-orders/UCM-I18N-5.md +0 -211
  350. package/work-orders/UCM-MSG-20.md +0 -192
  351. package/work-orders/UCM-PRIM-2.md +0 -114
  352. package/work-orders/UCM-SHELL-7.md +0 -134
  353. package/work-orders/UCM-SHELL-8.md +0 -125
  354. package/work-orders/UCM-TEST-1.md +0 -304
  355. package/work-orders/UCM-THEME-13.md +0 -69
  356. package/work-orders/UCM-THEME-14.md +0 -312
  357. package/work-orders/UCM-THEME-15.md +0 -356
  358. package/work-orders/UCM-THEME-16.md +0 -80
  359. package/work-orders/UCM-THEME-17.md +0 -111
  360. package/work-orders/UCM-THEME-18.md +0 -184
  361. package/work-orders/assets/AUTH-4-user-list-card.html +0 -407
  362. package/work-orders/assets/PRIM-1-dashboard-primitives.html +0 -624
  363. package/work-orders/assets/SHELL-2-account-navigation.html +0 -1159
  364. package/work-orders/assets/THEME-1-baseline-reference-sheet.html +0 -1352
  365. package/work-orders/assets/UCM-CHAT-1-ai-chat.html +0 -447
  366. package/work-orders/assets/UCM-THEME-13-dark-prototype.html +0 -390
  367. package/work-orders/assets/UCM-THEME-17-type-scale.html +0 -391
@@ -1,36 +0,0 @@
1
- // Short, granularity-aware x-axis tick labels.
2
- //
3
- // Not a style choice -- MUI X-Charts has a known, unfixed bug (mui-x#18768,
4
- // duplicate of #18399): when the measured space for a tick label gets
5
- // tight, its ellipsize() logic doesn't truncate the text, it collapses it
6
- // to an empty string (the <tspan> stays in the DOM with no content). It
7
- // only reproduces with long label text ("08/05, 10:00 AM"-style, ~16
8
- // characters) combined with this app's actual font metrics (DM Sans) --
9
- // short labels like "05.08." or "10:00" leave enough margin that the bug
10
- // never triggers. Same fix already proven in jg-ferien's ActivitySection.
11
-
12
- // `locale` defaults to "de-CH" only as a fallback for callers that don't
13
- // pass the app's active i18n language (found in review: an earlier version
14
- // hardcoded "de-CH" always, showing German month names to en/fr users).
15
-
16
- export function formatShortTime(date, locale = 'de-CH') {
17
- // hour12 forced false regardless of locale -- an English 12-hour label
18
- // ("10:00 AM") is exactly the longer style that triggered the original
19
- // collapse bug; staying short is the point, not locale fidelity here.
20
- return date.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', hour12: false });
21
- }
22
-
23
- export function formatShortDate(date, locale = 'de-CH') {
24
- return date.toLocaleDateString(locale, { day: '2-digit', month: '2-digit' });
25
- }
26
-
27
- export function formatShortMonth(date, locale = 'de-CH') {
28
- return date.toLocaleDateString(locale, { month: 'short', year: '2-digit' });
29
- }
30
-
31
- // "All" spans years -- day/month labels repeat (e.g. every "01.04." shows up
32
- // once per year) and read as meaningless noise; a bare year number is the
33
- // only granularity dense multi-year history can show cleanly.
34
- export function formatShortYear(date, locale = 'de-CH') {
35
- return date.toLocaleDateString(locale, { year: 'numeric' });
36
- }
@@ -1,258 +0,0 @@
1
- // UCM-CHART-17: the two exports promise two different things and now keep them.
2
- //
3
- // SVG stays a true, portable vector: only the chart's own MUI x-charts surface, but with the
4
- // computed styles that render it correctly (font, colour, stroke) written inline, since nothing
5
- // downstream of a cloned+serialised node carries the page's emotion CSS classes. PNG rasterises
6
- // the whole container -- chart, hand-built legend, size key, footnotes -- because that is what
7
- // the screen actually shows (`AccessGapScatterPanel` and its siblings render the legend/size key
8
- // as HTML/SVG siblings of the chart since `HRAM-RES-39`/`HRAM-VIS-2`, outside the chart's own SVG).
9
- //
10
- // Both paths route DOM through an SVG (`<foreignObject>` for the PNG's arbitrary HTML+SVG mix,
11
- // direct serialisation for the chart-only SVG) into an `Image`, then a `<canvas>` -- the platform's
12
- // own APIs, no rasteriser dependency added (this package's only runtime dependency stays
13
- // `@fontsource/dm-sans`). A library was seriously considered, not just skipped: the naive version
14
- // of this technique (an `Image` loaded from a `blob:` URL) taints the canvas on `toBlob` in Chrome
15
- // the moment the SVG contains a `<foreignObject>`, unconditionally -- see `rasterize`'s own comment
16
- // for how that was confirmed live and worked around with a `data:` URI instead, which is what
17
- // makes the platform-only approach actually viable rather than merely attempted.
18
- //
19
- // Font embedding: NOT done. Inlined `font-family` records the real value (e.g. `"DM Sans", ...`
20
- // with its documented fallback stack) instead of nothing at all, which is already a correctness
21
- // improvement over the pre-fix export (unstyled, arbitrary browser default). A machine without DM
22
- // Sans installed falls back through that stack -- an honest, visible degradation, not a silent one,
23
- // and embedding the font file was judged not worth the added complexity/weight for this WO.
24
-
25
- const SVG_NS = 'http://www.w3.org/2000/svg';
26
- const XHTML_NS = 'http://www.w3.org/1999/xhtml';
27
-
28
- // Typography and SVG paint -- what actually makes a chart LOOK like the theme instead of bare SVG
29
- // defaults (tick fonts and sizes, axis/grid colours, text fill). Deliberately curated, not a full
30
- // `getComputedStyle` dump: every extra property is bytes in a file a human may open in Illustrator
31
- // or Inkscape.
32
- // UCM-CHART-18: `transform`/`transform-origin` added -- a rotated element (e.g. a legend swatch
33
- // rotated into a diamond) previously exported unrotated, since nothing wrote the resolved CSS
34
- // transform onto the clone. `getComputedStyle` returns the FINAL, resolved matrix -- already
35
- // incorporating an SVG element's own `transform` PRESENTATION ATTRIBUTE, which `cloneNode` also
36
- // keeps -- and an inline `style` declaration always wins over a presentation attribute (SVG2:
37
- // presentation attributes carry the lowest possible specificity), so writing the computed value
38
- // inline overrides rather than composes with it. Verified live against a rotated legend swatch and
39
- // against `xLabels="angled"` tick labels: neither double-rotates or double-displaces.
40
- const CHART_STYLE_PROPERTIES = [
41
- 'font-family', 'font-size', 'font-weight', 'font-style', 'line-height', 'letter-spacing',
42
- 'fill', 'stroke', 'stroke-width', 'stroke-dasharray', 'stroke-linecap', 'stroke-linejoin',
43
- 'opacity', 'fill-opacity', 'stroke-opacity', 'text-anchor', 'dominant-baseline', 'color',
44
- 'transform', 'transform-origin',
45
- ];
46
-
47
- // Box layout/appearance for the HTML legend and size key a panel renders beside the chart --
48
- // only needed for the PNG's whole-container rasterisation, where a hand-built legend is plain
49
- // HTML with no chart-specific paint properties of its own. `overflow` and the grid properties
50
- // (reviewer finding) cover MUI's own composed layouts too, not only a hand-built flex legend --
51
- // `ChartsSurface` itself sits in a `grid-area`, so a container that lets MUI position multiple
52
- // parts via CSS Grid needs those to reposition correctly once cloned out of the page.
53
- const CONTAINER_LAYOUT_STYLE_PROPERTIES = [
54
- 'background-color', 'border-color', 'border-width', 'border-style', 'border-radius',
55
- 'display', 'flex-direction', 'flex-wrap', 'flex', 'align-items', 'justify-content',
56
- 'justify-items', 'align-content', 'gap', 'overflow',
57
- 'grid-template-columns', 'grid-template-rows', 'grid-template-areas', 'grid-area',
58
- 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
59
- 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
60
- 'width', 'height', 'box-sizing', 'text-align', 'white-space',
61
- ];
62
-
63
- // Deliberate, not positional (UCM-CHART-17 scope item 3): MUI x-charts' own root `<svg>` always
64
- // carries `MuiChartsSurface-root` (`@mui/x-charts/ChartsSurface`) -- a stable selector, unlike "the
65
- // first svg in the container", which silently exported a size-key SVG once one existed ahead of
66
- // the chart. Falls back to the first SVG for a bespoke (non-MUI) SVG child, which `ChartFrame`'s
67
- // own docblock explicitly allows.
68
- function findChartSvg(chartContainer) {
69
- const svg = chartContainer?.querySelector('svg.MuiChartsSurface-root') || chartContainer?.querySelector('svg');
70
- if (!svg) throw new Error('Chart container does not contain an SVG element.');
71
- return svg;
72
- }
73
-
74
- // UCM-CHART-18: an exported image shows what the chart COMMUNICATES, not what can be clicked --
75
- // a panel's own controls (an info `IconButton`, a drill-down `Button`, ...) live in `children`
76
- // alongside the chart (`ChartFrame`'s `chartRef` wraps `children` only, not `toolbar`/`controls`/
77
- // `meta`), so the whole-container PNG picked them up once it started rasterising `chartRef` in
78
- // full (`UCM-CHART-17`). `[role="button"]` catches MUI's own non-native button-like elements (e.g.
79
- // an `IconButton` can render as a `<span>`/`<div>` with that role) that a tag-name selector alone
80
- // would miss; `a[href]`/`[role="link"]` (reviewer finding) cover a drill-down built as a link
81
- // rather than a `<button>`.
82
- const INTERACTIVE_CONTROL_SELECTOR = 'button, input, select, textarea, [role="button"], a[href], [role="link"]';
83
-
84
- // ui_reviewer + reviewer finding, independently: MUI's OWN chart legend can be interactive
85
- // (`onItemClick`/`toggleVisibilityOnClick`) and, when it is, X-Charts renders each legend item as
86
- // `<button role="button" class="...MuiChartsLegend-series...">`, WRAPPING the series swatch and
87
- // label -- that markup IS the legend's explanatory content, not chrome, and the WO's own risk
88
- // section says exactly this: "if it vanishes, that is a finding that changes the approach, not a
89
- // detail to paper over." A blanket `.remove()` would delete the swatch+label along with the click
90
- // handler. Unwrapped instead: replace the interactive element with a plain, non-interactive one
91
- // carrying the SAME class/style/children, so the legend keeps every pixel of content while losing
92
- // only its clickability (irrelevant anyway -- a rasterised PNG has no click handlers regardless).
93
- const MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR = '.MuiChartsLegend-series';
94
-
95
- function stripInteractiveControls(clone) {
96
- clone.querySelectorAll(INTERACTIVE_CONTROL_SELECTOR).forEach((node) => {
97
- if (node.matches(MUI_INTERACTIVE_LEGEND_ITEM_SELECTOR)) {
98
- const unwrapped = document.createElement('span');
99
- unwrapped.className = node.className;
100
- const style = node.getAttribute('style');
101
- if (style) unwrapped.setAttribute('style', style);
102
- while (node.firstChild) unwrapped.appendChild(node.firstChild);
103
- node.replaceWith(unwrapped);
104
- return;
105
- }
106
- node.remove();
107
- });
108
- }
109
-
110
- // Walks `sourceRoot` and `cloneRoot` in lockstep (both traversed in the same, deterministic
111
- // document order, since `cloneRoot` is a structural copy of `sourceRoot`) and writes each node's
112
- // RESOLVED style for `properties` onto the clone as an inline `style` attribute. This is what
113
- // carries the page's emotion CSS classes (which the clone keeps by name but not by rule) into a
114
- // standalone file that has no access to that stylesheet.
115
- function inlineComputedStyles(sourceRoot, cloneRoot, properties) {
116
- const sourceNodes = [sourceRoot, ...sourceRoot.querySelectorAll('*')];
117
- const cloneNodes = [cloneRoot, ...cloneRoot.querySelectorAll('*')];
118
- sourceNodes.forEach((sourceNode, index) => {
119
- const cloneNode = cloneNodes[index];
120
- if (!cloneNode || cloneNode.nodeType !== Node.ELEMENT_NODE) return;
121
- const computed = window.getComputedStyle(sourceNode);
122
- const declarations = properties
123
- .map((property) => `${property}: ${computed.getPropertyValue(property)}`)
124
- .join('; ');
125
- const existing = cloneNode.getAttribute('style');
126
- cloneNode.setAttribute('style', existing ? `${existing}; ${declarations}` : declarations);
127
- });
128
- }
129
-
130
- function svgToBlob(svg) {
131
- return new Blob([new XMLSerializer().serializeToString(svg)], { type: 'image/svg+xml;charset=utf-8' });
132
- }
133
-
134
- function download(blob, filename) {
135
- const url = URL.createObjectURL(blob);
136
- const anchor = document.createElement('a');
137
- anchor.href = url;
138
- anchor.download = filename;
139
- document.body.appendChild(anchor);
140
- anchor.click();
141
- anchor.remove();
142
- URL.revokeObjectURL(url);
143
- }
144
-
145
- // The chart's own surface, faithfully styled -- true vector, chart only. Does not gain the
146
- // legend/size key rendered beside it; that is correct for what this format is for (Part A).
147
- function chartSvgBlob(chartContainer) {
148
- const svg = findChartSvg(chartContainer);
149
- const clone = svg.cloneNode(true);
150
- inlineComputedStyles(svg, clone, CHART_STYLE_PROPERTIES);
151
- // reviewer finding: MUI's ChartsSurface only ever gives the root <svg> a `viewBox` -- its actual
152
- // pixel size comes from CSS (`width: 100%; height: 100%` against the page's own layout), which
153
- // has nothing to resolve against once cloned out to a standalone file. Without an explicit
154
- // width/height a standalone viewer falls back to the SVG UA default (typically 300x150).
155
- const rect = svg.getBoundingClientRect();
156
- clone.setAttribute('width', Math.ceil(rect.width) || svg.clientWidth || 1);
157
- clone.setAttribute('height', Math.ceil(rect.height) || svg.clientHeight || 1);
158
- clone.setAttribute('xmlns', SVG_NS);
159
- return svgToBlob(clone);
160
- }
161
-
162
- // The whole container, as seen -- chart plus everything the panel renders beside it, via an SVG
163
- // `<foreignObject>` wrapping a styled clone of the container's actual DOM. Standard platform
164
- // technique for DOM rasterisation without a library: the intermediate SVG is never downloaded, only
165
- // decoded into an `Image` and drawn onto a `<canvas>`.
166
- function containerSvgBlob(chartContainer) {
167
- const rect = chartContainer.getBoundingClientRect();
168
- const width = Math.ceil(rect.width) || chartContainer.scrollWidth || 1;
169
- const height = Math.ceil(rect.height) || chartContainer.scrollHeight || 1;
170
-
171
- const clone = chartContainer.cloneNode(true);
172
- inlineComputedStyles(chartContainer, clone, [...CHART_STYLE_PROPERTIES, ...CONTAINER_LAYOUT_STYLE_PROPERTIES]);
173
- // UCM-CHART-18 scope item 2, deliberately AFTER inlineComputedStyles, never before:
174
- // inlineComputedStyles walks `chartContainer` and `clone` IN LOCKSTEP BY INDEX
175
- // (`sourceNodes[i]` <-> `cloneNodes[i]`, both from `querySelectorAll('*')`). Removing nodes from
176
- // the clone first would shift every subsequent index out of alignment with the still-intact
177
- // source tree, so elements downstream of the first removal would silently receive a DIFFERENT
178
- // element's computed style -- wrong, but not obviously wrong, since the result still looks like a
179
- // styled export.
180
- stripInteractiveControls(clone);
181
- clone.setAttribute('xmlns', XHTML_NS);
182
-
183
- const svg = document.createElementNS(SVG_NS, 'svg');
184
- svg.setAttribute('xmlns', SVG_NS);
185
- svg.setAttribute('width', width);
186
- svg.setAttribute('height', height);
187
- svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
188
- const foreignObject = document.createElementNS(SVG_NS, 'foreignObject');
189
- foreignObject.setAttribute('width', '100%');
190
- foreignObject.setAttribute('height', '100%');
191
- foreignObject.appendChild(clone);
192
- svg.appendChild(foreignObject);
193
-
194
- return { svg, width, height };
195
- }
196
-
197
- // UCM-CHART-17 risk section, confirmed live (not assumed): an SVG containing a `<foreignObject>`
198
- // taints the canvas on `toBlob` in Chrome -- unconditionally, even with zero external references
199
- // (verified: a foreignObject holding nothing but plain styled text already triggers
200
- // `SecurityError: Tainted canvases may not be exported`) -- but ONLY when the image is loaded via
201
- // a `blob:` object URL. The identical SVG loaded via a `data:` URI does not taint the canvas at
202
- // all. This is why the SVG-only export (`chartSvgBlob`, no foreignObject) can keep using
203
- // `URL.createObjectURL` for its own download, while the PNG path's `Image` source specifically
204
- // must be a `data:` URI. No rasteriser dependency needed once this is accounted for.
205
- async function svgToDataUri(svg) {
206
- const svgString = await svgToBlob(svg).text();
207
- return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svgString)}`;
208
- }
209
-
210
- async function rasterize(svg, width, height, backgroundColour) {
211
- const dataUri = await svgToDataUri(svg);
212
- return new Promise((resolve, reject) => {
213
- const image = new Image();
214
-
215
- image.onload = () => {
216
- try {
217
- const canvas = document.createElement('canvas');
218
- canvas.width = width * 2;
219
- canvas.height = height * 2;
220
- const context = canvas.getContext('2d');
221
- context.fillStyle = backgroundColour;
222
- context.fillRect(0, 0, canvas.width, canvas.height);
223
- context.drawImage(image, 0, 0, canvas.width, canvas.height);
224
- canvas.toBlob((blob) => {
225
- if (!blob) {
226
- reject(new Error('Unable to create PNG export.'));
227
- return;
228
- }
229
- resolve(blob);
230
- }, 'image/png');
231
- } catch (error) {
232
- reject(error);
233
- }
234
- };
235
- image.onerror = () => {
236
- reject(new Error('Unable to rasterize chart container for PNG export.'));
237
- };
238
- image.src = dataUri;
239
- });
240
- }
241
-
242
- /** Serializes the chart's own SVG surface, styles inlined, and downloads it. */
243
- export function exportChartSvg(chartContainer, filename = 'chart.svg') {
244
- const blob = chartSvgBlob(chartContainer);
245
- download(blob, filename);
246
- return blob;
247
- }
248
-
249
- /**
250
- * Rasterizes the whole chart container -- chart, legend, size key, footnotes, everything the panel
251
- * renders beside the chart -- at two-times scale and downloads it.
252
- */
253
- export async function exportChartPng(chartContainer, filename = 'chart.png', backgroundColour) {
254
- const { svg, width, height } = containerSvgBlob(chartContainer);
255
- const blob = await rasterize(svg, width, height, backgroundColour);
256
- download(blob, filename);
257
- return blob;
258
- }
@@ -1,39 +0,0 @@
1
- import { useTranslation } from 'react-i18next';
2
-
3
- export function formatPercentage(value, locale, options = {}) {
4
- return new Intl.NumberFormat(locale, {
5
- style: 'percent',
6
- maximumFractionDigits: 1,
7
- ...options,
8
- }).format(value);
9
- }
10
-
11
- export function formatCompact(value, locale, options = {}) {
12
- return new Intl.NumberFormat(locale, {
13
- notation: 'compact',
14
- maximumFractionDigits: 1,
15
- ...options,
16
- }).format(value);
17
- }
18
-
19
- export function formatRatio(value, locale, options = {}) {
20
- return new Intl.NumberFormat(locale, {
21
- maximumFractionDigits: 2,
22
- ...options,
23
- }).format(value);
24
- }
25
-
26
- /** Creates locale-aware formatter functions for use in chart axes and tooltips. */
27
- export function createChartFormatters(locale) {
28
- return {
29
- percentage: (value, options) => formatPercentage(value, locale, options),
30
- compact: (value, options) => formatCompact(value, locale, options),
31
- ratio: (value, options) => formatRatio(value, locale, options),
32
- };
33
- }
34
-
35
- /** Resolves formatter locale from the active react-i18next instance. */
36
- export function useChartFormatters() {
37
- const { i18n } = useTranslation();
38
- return createChartFormatters(i18n.language);
39
- }
@@ -1,33 +0,0 @@
1
- import { useTheme } from '@mui/material/styles';
2
-
3
- /**
4
- * Returns neutral chart colours derived only from the active MUI theme.
5
- * Consumers may replace either array with their own domain palette.
6
- */
7
- export function getNeutralChartPalette(theme) {
8
- const palette = theme.palette;
9
- const isDark = palette.mode === 'dark';
10
- const dataSeries = palette.dataSeries?.categorical;
11
-
12
- return {
13
- categorical: Array.isArray(dataSeries) && dataSeries.length > 0
14
- ? [...dataSeries]
15
- : isDark
16
- ? [palette.primary.light, palette.secondary.light, palette.info.light, palette.success.light, palette.warning.light]
17
- : [palette.primary.main, palette.secondary.main, palette.info.main, palette.success.main, palette.warning.main],
18
- sequential: isDark
19
- ? [palette.action.disabled, palette.text.secondary, palette.primary.light, palette.primary.main, palette.primary.dark]
20
- : [palette.action.disabled, palette.divider, palette.text.secondary, palette.primary.light, palette.primary.main],
21
- // THEME-10: an undifferentiated mass (e.g. a scatter cloud with no colour
22
- // dimension encoded) is ink-neutral, not a series hue -- a KPI identity
23
- // colour there implies a meaning the cloud does not carry. `text.secondary`
24
- // reads as neutral ink in both palette modes without competing with an
25
- // actual categorical/sequential encoding drawn on top of it.
26
- neutral: palette.text.secondary,
27
- };
28
- }
29
-
30
- /** Resolves the kit's neutral palette from the nearest MUI ThemeProvider. */
31
- export function useNeutralChartPalette() {
32
- return getNeutralChartPalette(useTheme());
33
- }
@@ -1,7 +0,0 @@
1
- /** Return one January tick for every calendar year represented in dates. */
2
- export function yearTickInterval(dates) {
3
- const years = new Set(dates.map((date) => date.getFullYear()));
4
- return [...years]
5
- .sort((first, second) => first - second)
6
- .map((year) => new Date(year, 0, 1));
7
- }