@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.
- package/CHANGELOG.md +31 -0
- package/README.md +7 -0
- package/dist/auth/UserMenu.js +1 -1
- package/dist/auth/apiClient.js +7 -6
- package/dist/chat/ChatList.js +1 -1
- package/dist/chat/ChatThread.js +2 -1
- package/dist/chat/ChatWorkspace.js +1 -1
- package/dist/chat/ModelPicker.js +2 -5
- package/dist/chat/kitSxRegistry.js +9 -0
- package/dist/chat/useChatSocket.js +1 -1
- package/dist/components/LoginForm.js +1 -1
- package/dist/components/SecurityComponent.js +1 -1
- package/dist/components/UserListComponent.js +2 -8
- package/dist/components/charts/ChartFrame.js +1 -1
- package/dist/components/charts/ScatterChart.js +2 -1
- package/dist/components/charts/kitSxRegistry.js +6 -0
- package/dist/entries/charts.js +6 -0
- package/dist/entries/chat.js +8 -0
- package/dist/entries/markdown.js +1 -0
- package/dist/index.js +0 -14
- package/dist/layout/SectionNav.js +1 -1
- package/dist/messaging/AttachmentList.js +2 -2
- package/dist/messaging/Composer.js +2 -1
- package/dist/messaging/ConversationLaunchers.js +1 -4
- package/dist/messaging/ConversationList.js +1 -1
- package/dist/messaging/DirectMessageLauncher.js +1 -1
- package/dist/messaging/MessagingProvider.js +0 -0
- package/dist/messaging/PollCard.js +7 -5
- package/dist/messaging/ReadTicks.js +2 -2
- package/dist/messaging/Thread.js +5 -3
- package/dist/notifications/NotificationBell.js +4 -7
- package/dist/notifications/NotificationSettings.js +1 -1
- package/dist/onboarding/OnboardingProvider.js +3 -6
- package/dist/pages/AccountPage.js +1 -2
- package/dist/pages/LoginPage.js +2 -3
- package/dist/pages/PasswordChangePage.js +2 -3
- package/dist/pages/PasswordInvitePage.js +2 -3
- package/dist/pages/PasswordResetRequestPage.js +2 -3
- package/dist/pages/SignUpPage.js +2 -3
- package/dist/pages/SignupConfirmPage.js +2 -3
- package/dist/theme/createAppTheme.js +5 -4
- package/dist/theme/kitSxEntry.js +11 -0
- package/dist/theme/kitSxRegistry.js +2 -15
- package/dist/theme/themeCompleteness.js +3 -12
- package/dist/utils/auth-errors.js +4 -3
- package/package.json +41 -16
- package/.github/workflows/publish.yml +0 -126
- package/DESIGN.md +0 -60
- package/WORK_ORDERS.md +0 -148
- package/dev/entries.jsx +0 -721
- package/dev/fixtures.js +0 -26
- package/dev/main.jsx +0 -75
- package/dev/mockTransport.jsx +0 -128
- package/docs/CHART-LAYOUT.md +0 -157
- package/docs/DARK-TOKENS.md +0 -140
- package/docs/TYPE-SCALE.md +0 -111
- package/docs/messaging-deviations.md +0 -118
- package/index.html +0 -12
- package/renovate.json +0 -10
- package/scripts/chart-api-census.mjs +0 -415
- package/src/auth/AuthContext.jsx +0 -158
- package/src/auth/ReauthModal.jsx +0 -82
- package/src/auth/UserMenu.jsx +0 -121
- package/src/auth/apiClient.jsx +0 -232
- package/src/auth/authApi.jsx +0 -539
- package/src/auth/authConfig.jsx +0 -34
- package/src/auth/reauth.js +0 -47
- package/src/chat/ChatComposer.jsx +0 -36
- package/src/chat/ChatList.jsx +0 -87
- package/src/chat/ChatThread.jsx +0 -128
- package/src/chat/ChatWorkspace.jsx +0 -244
- package/src/chat/MarkdownReply.jsx +0 -22
- package/src/chat/ModelPicker.jsx +0 -85
- package/src/chat/api.js +0 -18
- package/src/chat/useChatSocket.js +0 -32
- package/src/chat/wire.js +0 -7
- package/src/components/AccessCodeManager.jsx +0 -288
- package/src/components/AccessCodeSingleUseToggle.jsx +0 -92
- package/src/components/AllowedEmailDomainsManager.jsx +0 -92
- package/src/components/AuthFactorRequirementCard.jsx +0 -95
- package/src/components/BulkInviteCsvTab.jsx +0 -198
- package/src/components/EmptyState.jsx +0 -38
- package/src/components/LoginForm.jsx +0 -159
- package/src/components/MFAComponent.jsx +0 -350
- package/src/components/MfaLoginComponent.jsx +0 -252
- package/src/components/MobileBottomNav.jsx +0 -82
- package/src/components/PasskeysComponent.jsx +0 -252
- package/src/components/PasswordChangeForm.jsx +0 -87
- package/src/components/PasswordResetRequestForm.jsx +0 -43
- package/src/components/PasswordSetForm.jsx +0 -97
- package/src/components/ProfileComponent.jsx +0 -348
- package/src/components/QrSignupManager.jsx +0 -404
- package/src/components/QrSignupValidityManager.jsx +0 -106
- package/src/components/RegistrationMethodsManager.jsx +0 -150
- package/src/components/SecurityComponent.jsx +0 -141
- package/src/components/SocialLoginButtons.jsx +0 -83
- package/src/components/SoftChip.jsx +0 -93
- package/src/components/StatTile.jsx +0 -39
- package/src/components/SupportRecoveryRequestsTab.jsx +0 -482
- package/src/components/TurnstileWidget.jsx +0 -99
- package/src/components/UserInviteComponent.jsx +0 -76
- package/src/components/UserListComponent.jsx +0 -618
- package/src/components/charts/BarChart.jsx +0 -102
- package/src/components/charts/ChartFrame.jsx +0 -214
- package/src/components/charts/LineChart.jsx +0 -126
- package/src/components/charts/ScatterChart.jsx +0 -299
- package/src/components/charts/TimeSeriesChart.jsx +0 -300
- package/src/components/charts/chartDefaults.js +0 -644
- package/src/components/charts/chartLabels.js +0 -36
- package/src/components/charts/exportChart.js +0 -258
- package/src/components/charts/formatters.js +0 -39
- package/src/components/charts/palette.js +0 -33
- package/src/components/charts/yearTickInterval.js +0 -7
- package/src/i18n/authTranslations.ts +0 -2651
- package/src/i18n/chartsTranslations.ts +0 -91
- package/src/i18n/chatTranslations.ts +0 -55
- package/src/i18n/messagingTranslations.ts +0 -120
- package/src/i18n/notificationsTranslations.ts +0 -32
- package/src/i18n/onboardingTranslations.ts +0 -29
- package/src/i18n/sectionNavTranslations.ts +0 -20
- package/src/i18n/uiCoreTranslations.js +0 -29
- package/src/i18n/userMenuTranslations.ts +0 -5
- package/src/index.js +0 -158
- package/src/layout/PageLayout.jsx +0 -36
- package/src/layout/SectionNav.jsx +0 -320
- package/src/messaging/AttachmentList.jsx +0 -145
- package/src/messaging/Composer.jsx +0 -197
- package/src/messaging/ConversationLaunchers.jsx +0 -51
- package/src/messaging/ConversationList.jsx +0 -109
- package/src/messaging/DirectMessageLauncher.jsx +0 -112
- package/src/messaging/MessageBubble.jsx +0 -183
- package/src/messaging/MessagingProvider.jsx +0 -0
- package/src/messaging/MessagingScopeConfig.jsx +0 -24
- package/src/messaging/PollCard.jsx +0 -163
- package/src/messaging/ReactionBar.jsx +0 -43
- package/src/messaging/ReadTicks.jsx +0 -82
- package/src/messaging/Thread.jsx +0 -195
- package/src/messaging/api.js +0 -48
- package/src/messaging/composerImageCompression.js +0 -35
- package/src/messaging/linkifyText.jsx +0 -37
- package/src/notifications/NotificationBell.jsx +0 -84
- package/src/notifications/NotificationSettings.jsx +0 -330
- package/src/notifications/NotificationsProvider.jsx +0 -224
- package/src/notifications/PopupSurface.jsx +0 -105
- package/src/notifications/api.js +0 -55
- package/src/notifications/feedApi.js +0 -18
- package/src/notifications/realtime.jsx +0 -138
- package/src/notifications/serviceWorker/sw.js +0 -50
- package/src/onboarding/OnboardingProvider.jsx +0 -326
- package/src/onboarding/OnboardingWizard.jsx +0 -61
- package/src/onboarding/WizardDialogShell.jsx +0 -51
- package/src/onboarding/api.js +0 -13
- package/src/onboarding/stepSelection.js +0 -16
- package/src/onboarding/steps/BrowserPushStep.jsx +0 -121
- package/src/onboarding/steps/CompleteNameStep.jsx +0 -46
- package/src/onboarding/steps/CookieConsentStep.jsx +0 -133
- package/src/onboarding/steps/PwaInstallStep.jsx +0 -47
- package/src/pages/AccountPage.jsx +0 -394
- package/src/pages/LoginPage.jsx +0 -343
- package/src/pages/PasswordChangePage.jsx +0 -62
- package/src/pages/PasswordInvitePage.jsx +0 -177
- package/src/pages/PasswordResetRequestPage.jsx +0 -68
- package/src/pages/SignUpPage.jsx +0 -268
- package/src/pages/SignupConfirmPage.jsx +0 -155
- package/src/testing/checkKitIntegration.js +0 -233
- package/src/theme/createAppTheme.js +0 -423
- package/src/theme/fonts.js +0 -3
- package/src/theme/index.js +0 -21
- package/src/theme/kitSxRegistry.js +0 -285
- package/src/theme/themeCompleteness.js +0 -1045
- package/src/theme/tokens.js +0 -478
- package/src/utils/auth-errors.js +0 -76
- package/src/utils/authService.js +0 -223
- package/src/utils/resolveErrorText.js +0 -28
- package/src/utils/webauthn.js +0 -51
- package/tests/AccountPage.profileStatements.test.jsx +0 -162
- package/tests/AccountPage.test.jsx +0 -200
- package/tests/AuthContext.test.jsx +0 -129
- package/tests/BarChart.test.jsx +0 -112
- package/tests/BrowserPushStep.test.jsx +0 -110
- package/tests/ChartFrame.test.jsx +0 -336
- package/tests/ConversationList.test.jsx +0 -144
- package/tests/CookieConsentStep.test.jsx +0 -69
- package/tests/EmptyState.test.jsx +0 -62
- package/tests/LineChart.test.jsx +0 -80
- package/tests/MessagingProvider.test.jsx +0 -50
- package/tests/MobileBottomNav.test.jsx +0 -319
- package/tests/NotificationBell.test.jsx +0 -60
- package/tests/NotificationSettings.test.jsx +0 -276
- package/tests/NotificationsProvider.test.jsx +0 -240
- package/tests/OnboardingProvider.test.jsx +0 -294
- package/tests/OnboardingWizard.test.jsx +0 -143
- package/tests/PasswordChangeForm.test.jsx +0 -70
- package/tests/PasswordInvitePage.test.jsx +0 -142
- package/tests/PasswordSetForm.test.jsx +0 -70
- package/tests/PopupSurface.test.jsx +0 -142
- package/tests/ProfileComponent.refresh.test.jsx +0 -194
- package/tests/QrSignupManager.registrationContext.test.jsx +0 -106
- package/tests/QrSignupManagerInfoBox.test.jsx +0 -49
- package/tests/ScatterChart.test.jsx +0 -270
- package/tests/SectionNav.test.jsx +0 -363
- package/tests/SignUpPage.test.jsx +0 -208
- package/tests/SoftChip.test.jsx +0 -105
- package/tests/StatTile.test.jsx +0 -57
- package/tests/Thread.test.jsx +0 -151
- package/tests/TimeSeriesChart.test.jsx +0 -367
- package/tests/UserListComponent.test.jsx +0 -192
- package/tests/UserMenu.test.jsx +0 -171
- package/tests/apiClientLanguage.test.js +0 -33
- package/tests/apiClientPublicPaths.test.js +0 -178
- package/tests/authApiLogin.test.js +0 -42
- package/tests/authApiRegistration.test.js +0 -31
- package/tests/authErrorCodeRendering.test.jsx +0 -77
- package/tests/authErrors.test.js +0 -74
- package/tests/authTranslations.test.js +0 -74
- package/tests/chart-api-census.test.js +0 -366
- package/tests/chartAxisTickBand.test.jsx +0 -95
- package/tests/chartDefaults.test.js +0 -902
- package/tests/chartLabels.test.js +0 -50
- package/tests/chartsPalette.test.js +0 -99
- package/tests/chatApi.test.js +0 -48
- package/tests/chatDriverNames.test.jsx +0 -71
- package/tests/chatExports.test.js +0 -3
- package/tests/chatList.test.jsx +0 -84
- package/tests/chatPicker.test.jsx +0 -82
- package/tests/chatSocket.test.jsx +0 -26
- package/tests/chatThread.test.jsx +0 -116
- package/tests/chatTranslations.test.js +0 -47
- package/tests/chatWorkspace.test.jsx +0 -234
- package/tests/checkKitIntegration.test.jsx +0 -219
- package/tests/createAppTheme.test.js +0 -132
- package/tests/createAppThemeDark.test.js +0 -127
- package/tests/createAppThemeLightGuard.test.js +0 -40
- package/tests/createAppThemePageContrast.test.js +0 -108
- package/tests/createAppThemeTypography.test.js +0 -53
- package/tests/errorCallSiteGuard.test.js +0 -32
- package/tests/exportChart.test.js +0 -313
- package/tests/feedApi.test.js +0 -46
- package/tests/fixtures/light-theme-baseline.json +0 -2234
- package/tests/i18nAggregate.test.js +0 -120
- package/tests/i18nGermanVariant.test.js +0 -65
- package/tests/loginPageErrorResolution.test.jsx +0 -102
- package/tests/messagingApi.test.js +0 -32
- package/tests/messagingChunk6.test.jsx +0 -116
- package/tests/messagingCompactBubble.test.jsx +0 -64
- package/tests/messagingComposer.test.jsx +0 -136
- package/tests/messagingComposerChunk5.test.jsx +0 -113
- package/tests/messagingContractConformance.test.js +0 -69
- package/tests/messagingDirectMessageLauncher.test.jsx +0 -151
- package/tests/messagingExports.test.js +0 -21
- package/tests/messagingInteractions.test.jsx +0 -136
- package/tests/messagingLastMessagePreview.test.jsx +0 -93
- package/tests/messagingLinkify.test.jsx +0 -51
- package/tests/messagingMessageActions.test.jsx +0 -163
- package/tests/messagingMsg6.test.jsx +0 -105
- package/tests/messagingMsg6f.test.jsx +0 -155
- package/tests/messagingMsg6g.test.jsx +0 -166
- package/tests/messagingMsg6h.test.jsx +0 -136
- package/tests/messagingMsg6i.test.jsx +0 -129
- package/tests/messagingPollRendering.test.jsx +0 -142
- package/tests/messagingReactionMerge.test.jsx +0 -77
- package/tests/messagingReadTicksTooltip.test.jsx +0 -36
- package/tests/messagingThreadReceipts.test.jsx +0 -178
- package/tests/messagingThreadingQuoting.test.jsx +0 -87
- package/tests/messagingUnreadLifecycle.test.jsx +0 -78
- package/tests/notificationsApi.test.js +0 -41
- package/tests/notificationsExports.test.js +0 -34
- package/tests/onboardingDescriptors.test.js +0 -132
- package/tests/packageTreeShaking.test.js +0 -126
- package/tests/realtime.test.jsx +0 -219
- package/tests/resolveErrorText.test.js +0 -72
- package/tests/stepSelection.test.js +0 -53
- package/tests/themeCompleteness.test.js +0 -626
- package/tests/timeSeriesLegend.test.js +0 -99
- package/tests/userScreenTranslations.test.jsx +0 -218
- package/tsconfig.build.json +0 -18
- package/vite.config.mjs +0 -6
- package/work-orders/AUTH-1.md +0 -74
- package/work-orders/AUTH-2.md +0 -74
- package/work-orders/AUTH-4.md +0 -183
- package/work-orders/AUTH-5.md +0 -154
- package/work-orders/AUTH-7.md +0 -181
- package/work-orders/AUTH-8.md +0 -184
- package/work-orders/CHART-1.md +0 -285
- package/work-orders/CHART-2.md +0 -222
- package/work-orders/CHART-3.md +0 -163
- package/work-orders/CHART-4.md +0 -203
- package/work-orders/CHART-5.md +0 -226
- package/work-orders/CHART-6.md +0 -428
- package/work-orders/CHART-7.md +0 -175
- package/work-orders/DX-1.md +0 -169
- package/work-orders/DX-2.md +0 -188
- package/work-orders/DX-3.md +0 -195
- package/work-orders/I18N-1.md +0 -254
- package/work-orders/I18N-3.md +0 -207
- package/work-orders/MSG-3.md +0 -375
- package/work-orders/MSG-3b.md +0 -1002
- package/work-orders/MSG-3c.md +0 -378
- package/work-orders/MSG-3d.md +0 -268
- package/work-orders/MSG-3e.md +0 -164
- package/work-orders/MSG-3f.md +0 -391
- package/work-orders/MSG-6e.md +0 -308
- package/work-orders/MSG-6f.md +0 -214
- package/work-orders/MSG-6g.md +0 -244
- package/work-orders/MSG-6h.md +0 -238
- package/work-orders/MSG-6i.md +0 -271
- package/work-orders/MSG-6j.md +0 -117
- package/work-orders/NOTIF-12.md +0 -214
- package/work-orders/NOTIF-13.md +0 -142
- package/work-orders/NOTIF-14.md +0 -151
- package/work-orders/PRIM-1.md +0 -177
- package/work-orders/SHELL-1.md +0 -255
- package/work-orders/SHELL-2.md +0 -197
- package/work-orders/SHELL-3.md +0 -359
- package/work-orders/SHELL-4.md +0 -351
- package/work-orders/SHELL-5.md +0 -345
- package/work-orders/SHELL-6.md +0 -210
- package/work-orders/THEME-1.md +0 -587
- package/work-orders/THEME-10.md +0 -303
- package/work-orders/THEME-11.md +0 -208
- package/work-orders/THEME-2.md +0 -339
- package/work-orders/THEME-3.md +0 -210
- package/work-orders/THEME-4.md +0 -271
- package/work-orders/THEME-5.md +0 -341
- package/work-orders/THEME-6.md +0 -247
- package/work-orders/THEME-7.md +0 -82
- package/work-orders/THEME-8.md +0 -211
- package/work-orders/THEME-9.md +0 -194
- package/work-orders/UCM-AUTH-10.md +0 -490
- package/work-orders/UCM-AUTH-11.md +0 -185
- package/work-orders/UCM-AUTH-12.md +0 -98
- package/work-orders/UCM-AUTH-13.md +0 -47
- package/work-orders/UCM-AUTH-9.md +0 -207
- package/work-orders/UCM-CHART-10.md +0 -150
- package/work-orders/UCM-CHART-11.md +0 -132
- package/work-orders/UCM-CHART-12.md +0 -348
- package/work-orders/UCM-CHART-13.md +0 -122
- package/work-orders/UCM-CHART-14.md +0 -198
- package/work-orders/UCM-CHART-15.md +0 -187
- package/work-orders/UCM-CHART-16.md +0 -169
- package/work-orders/UCM-CHART-17.md +0 -195
- package/work-orders/UCM-CHART-18.md +0 -200
- package/work-orders/UCM-CHART-8.md +0 -147
- package/work-orders/UCM-CHART-9.md +0 -265
- package/work-orders/UCM-CHAT-1.md +0 -190
- package/work-orders/UCM-CHAT-2.md +0 -75
- package/work-orders/UCM-DEP-1.md +0 -63
- package/work-orders/UCM-I18N-4.md +0 -226
- package/work-orders/UCM-I18N-5.md +0 -211
- package/work-orders/UCM-MSG-20.md +0 -192
- package/work-orders/UCM-PRIM-2.md +0 -114
- package/work-orders/UCM-SHELL-7.md +0 -134
- package/work-orders/UCM-SHELL-8.md +0 -125
- package/work-orders/UCM-TEST-1.md +0 -304
- package/work-orders/UCM-THEME-13.md +0 -69
- package/work-orders/UCM-THEME-14.md +0 -312
- package/work-orders/UCM-THEME-15.md +0 -356
- package/work-orders/UCM-THEME-16.md +0 -80
- package/work-orders/UCM-THEME-17.md +0 -111
- package/work-orders/UCM-THEME-18.md +0 -184
- package/work-orders/assets/AUTH-4-user-list-card.html +0 -407
- package/work-orders/assets/PRIM-1-dashboard-primitives.html +0 -624
- package/work-orders/assets/SHELL-2-account-navigation.html +0 -1159
- package/work-orders/assets/THEME-1-baseline-reference-sheet.html +0 -1352
- package/work-orders/assets/UCM-CHAT-1-ai-chat.html +0 -447
- package/work-orders/assets/UCM-THEME-13-dark-prototype.html +0 -390
- 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
|
-
}
|