@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,423 +0,0 @@
|
|
|
1
|
-
import './fonts';
|
|
2
|
-
|
|
3
|
-
import { createTheme, darken, decomposeColor, getContrastRatio, lighten } from '@mui/material/styles';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS,
|
|
7
|
-
BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS_DARK,
|
|
8
|
-
BASELINE_PALETTE,
|
|
9
|
-
BASELINE_PALETTE_DARK,
|
|
10
|
-
BASELINE_STATIC,
|
|
11
|
-
BREAKPOINT_SM,
|
|
12
|
-
DARK_OVERLAY_SHADOW,
|
|
13
|
-
DARK_OVERLAY_SURFACE,
|
|
14
|
-
DARK_SCRIM,
|
|
15
|
-
MOTION,
|
|
16
|
-
breakpointDownQuery,
|
|
17
|
-
withMainShades,
|
|
18
|
-
} from './tokens';
|
|
19
|
-
import { calculateContrastRatio } from './themeCompleteness';
|
|
20
|
-
|
|
21
|
-
function findFunction(value, path) {
|
|
22
|
-
if (typeof value === 'function') return path;
|
|
23
|
-
if (!value || typeof value !== 'object') return null;
|
|
24
|
-
|
|
25
|
-
for (const [key, child] of Object.entries(value)) {
|
|
26
|
-
const found = findFunction(child, `${path}.${key}`);
|
|
27
|
-
if (found) return found;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function validateStyleOverrides(components = {}) {
|
|
33
|
-
for (const [componentName, component] of Object.entries(components)) {
|
|
34
|
-
if (!component?.styleOverrides) continue;
|
|
35
|
-
const slot = findFunction(
|
|
36
|
-
component.styleOverrides,
|
|
37
|
-
`components.${componentName}.styleOverrides`,
|
|
38
|
-
);
|
|
39
|
-
if (slot) {
|
|
40
|
-
throw new TypeError(
|
|
41
|
-
`createAppTheme: ${slot} must be an object, not a function. ` +
|
|
42
|
-
'Use object styleOverrides and MUI variants for prop- or state-dependent styles.',
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function clearsContrast(colour, surfaces) {
|
|
49
|
-
return surfaces.every((surface) => getContrastRatio(colour, surface) >= 3);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function normalizeColour(colour) {
|
|
53
|
-
const match = colour.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/);
|
|
54
|
-
if (!match) return colour;
|
|
55
|
-
return `#${match.slice(1).map((channel) => Number(channel).toString(16).padStart(2, '0')).join('').toUpperCase()}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function lightenColour(colour, coefficient) {
|
|
59
|
-
const normalized = normalizeColour(colour);
|
|
60
|
-
const match = normalized.match(/^#([\da-f]{6})$/i);
|
|
61
|
-
if (!match) return normalizeColour(lighten(colour, coefficient));
|
|
62
|
-
const channels = [0, 2, 4].map((offset) => parseInt(match[1].slice(offset, offset + 2), 16));
|
|
63
|
-
return `#${channels.map((channel) => Math.round(channel + (255 - channel) * coefficient)
|
|
64
|
-
.toString(16).padStart(2, '0')).join('').toUpperCase()}`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Darkened until it clears 3:1 against BOTH '#FFFFFF' and background.default
|
|
68
|
-
// -- the exact two surfaces assertThemeComplete's contrastFindings checks --
|
|
69
|
-
// so deriving against background.paper alone (which need not be white for an
|
|
70
|
-
// app that overrides it) could pass here and still fail there.
|
|
71
|
-
function deriveFocusColour(primary, surfaces) {
|
|
72
|
-
let focus = primary;
|
|
73
|
-
for (let coefficient = 0.05; !clearsContrast(focus, surfaces); coefficient += 0.05) {
|
|
74
|
-
focus = darken(primary, Math.min(coefficient, 0.9));
|
|
75
|
-
if (coefficient >= 0.9) break;
|
|
76
|
-
}
|
|
77
|
-
return focus;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function deriveLightenedColour(original, surfaces) {
|
|
81
|
-
if (clearsContrast(original, surfaces)) return original;
|
|
82
|
-
let colour = original;
|
|
83
|
-
for (let coefficient = 0.05; !clearsContrast(colour, surfaces); coefficient += 0.05) {
|
|
84
|
-
colour = lightenColour(original, Math.min(coefficient, 0.9));
|
|
85
|
-
if (coefficient >= 0.9) break;
|
|
86
|
-
}
|
|
87
|
-
return colour;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function clearsPageContrast(colour, surfaces, threshold) {
|
|
91
|
-
return surfaces.every((surface) => {
|
|
92
|
-
const ratio = calculateContrastRatio(colour, surface);
|
|
93
|
-
return Number.isFinite(ratio) && ratio >= threshold;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function deriveDarkenedPageColour(original, surfaces, threshold) {
|
|
98
|
-
if (clearsPageContrast(original, surfaces, threshold)) return original;
|
|
99
|
-
|
|
100
|
-
let colour = original;
|
|
101
|
-
for (let coefficient = 0.05; !clearsPageContrast(colour, surfaces, threshold); coefficient += 0.05) {
|
|
102
|
-
colour = darken(original, Math.min(coefficient, 0.9));
|
|
103
|
-
if (coefficient >= 0.9) break;
|
|
104
|
-
}
|
|
105
|
-
return colour;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function deriveLightenedPageColour(original, surfaces, threshold) {
|
|
109
|
-
if (clearsPageContrast(original, surfaces, threshold)) return original;
|
|
110
|
-
|
|
111
|
-
let colour = original;
|
|
112
|
-
for (let coefficient = 0.05; !clearsPageContrast(colour, surfaces, threshold); coefficient += 0.05) {
|
|
113
|
-
colour = lightenColour(original, Math.min(coefficient, 0.9));
|
|
114
|
-
if (coefficient >= 0.9) break;
|
|
115
|
-
}
|
|
116
|
-
return colour;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ink.primary may be supplied as hex or rgb(); decomposeColor normalises both.
|
|
120
|
-
function inkChannels(ink) {
|
|
121
|
-
return decomposeColor(ink).values.slice(0, 3).map((value) => Math.round(value));
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 0.02 steps: the frozen sheet value (0.38) is the first even step that clears
|
|
125
|
-
// 3:1; a 0.01 search would land on 0.37 and drift from the frozen baseline.
|
|
126
|
-
function deriveDarkAlphaColour(ink, surfaces) {
|
|
127
|
-
const [red, green, blue] = inkChannels(ink);
|
|
128
|
-
let alpha = 0;
|
|
129
|
-
while (alpha <= 1) {
|
|
130
|
-
const colour = `rgba(${red},${green},${blue},${alpha.toFixed(2)})`;
|
|
131
|
-
if (clearsPageContrast(colour, surfaces, 3)) return colour;
|
|
132
|
-
alpha = Number((alpha + 0.02).toFixed(2));
|
|
133
|
-
}
|
|
134
|
-
return `rgba(${red},${green},${blue},1)`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const RGBA_PATTERN = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*\.?\d+)\s*\)$/;
|
|
138
|
-
|
|
139
|
-
function deriveAlphaPageColour(original, surfaces, threshold) {
|
|
140
|
-
if (clearsPageContrast(original, surfaces, threshold)) return original;
|
|
141
|
-
|
|
142
|
-
const match = original.match(RGBA_PATTERN);
|
|
143
|
-
if (!match) return original;
|
|
144
|
-
|
|
145
|
-
const [, red, green, blue, alphaText] = match;
|
|
146
|
-
let alpha = Number(alphaText);
|
|
147
|
-
let colour = original;
|
|
148
|
-
while (alpha < 1) {
|
|
149
|
-
alpha = Math.min(1, Number((alpha + 0.05).toFixed(2)));
|
|
150
|
-
colour = `rgba(${red}, ${green}, ${blue}, ${alpha})`;
|
|
151
|
-
if (clearsPageContrast(colour, surfaces, threshold)) return colour;
|
|
152
|
-
}
|
|
153
|
-
return colour;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function createPaletteAwareComponents(palette, isDark) {
|
|
157
|
-
const stateTransition = `border-color ${MOTION.duration.fast}ms ${MOTION.easing.state}, color ${MOTION.duration.fast}ms ${MOTION.easing.state}, background-color ${MOTION.duration.fast}ms ${MOTION.easing.state}`;
|
|
158
|
-
const autofill = {
|
|
159
|
-
'&:-webkit-autofill': {
|
|
160
|
-
WebkitBoxShadow: `0 0 0 100px ${palette.background.paper} inset`,
|
|
161
|
-
WebkitTextFillColor: palette.ink.primary,
|
|
162
|
-
caretColor: palette.ink.primary,
|
|
163
|
-
},
|
|
164
|
-
'&:autofill': {
|
|
165
|
-
boxShadow: `0 0 0 100px ${palette.background.paper} inset`,
|
|
166
|
-
WebkitTextFillColor: palette.ink.primary,
|
|
167
|
-
caretColor: palette.ink.primary,
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
const alertStyles = Object.fromEntries(
|
|
171
|
-
['success', 'warning', 'error', 'info'].map((status) => [
|
|
172
|
-
`standard${status[0].toUpperCase()}${status.slice(1)}`,
|
|
173
|
-
{
|
|
174
|
-
color: palette[status].text,
|
|
175
|
-
backgroundColor: palette[status].bg,
|
|
176
|
-
'& .MuiAlert-icon': { color: palette[status].text },
|
|
177
|
-
},
|
|
178
|
-
]),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const components = {
|
|
182
|
-
MuiButton: {
|
|
183
|
-
styleOverrides: {
|
|
184
|
-
root: { transition: stateTransition },
|
|
185
|
-
outlined: {
|
|
186
|
-
borderColor: palette.controlBorder.main,
|
|
187
|
-
'&:hover': { borderColor: palette.controlBorder.hover },
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
MuiDivider: {
|
|
192
|
-
styleOverrides: { root: { borderColor: palette.divider } },
|
|
193
|
-
},
|
|
194
|
-
MuiCheckbox: {
|
|
195
|
-
styleOverrides: {
|
|
196
|
-
root: {
|
|
197
|
-
color: palette.controlBorder.main,
|
|
198
|
-
transition: stateTransition,
|
|
199
|
-
'&:hover': { color: palette.controlBorder.hover },
|
|
200
|
-
'&.Mui-checked': { color: palette.primary.main },
|
|
201
|
-
'&.MuiCheckbox-indeterminate': { color: palette.primary.main },
|
|
202
|
-
'&.Mui-error': { color: palette.controlBorder.error },
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
MuiPaper: {
|
|
207
|
-
styleOverrides: { root: { borderColor: palette.divider } },
|
|
208
|
-
},
|
|
209
|
-
MuiCard: {
|
|
210
|
-
styleOverrides: { root: { borderColor: palette.divider } },
|
|
211
|
-
},
|
|
212
|
-
MuiChip: {
|
|
213
|
-
styleOverrides: {
|
|
214
|
-
outlined: { borderColor: palette.controlBorder.main },
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
MuiBottomNavigation: {
|
|
218
|
-
styleOverrides: {
|
|
219
|
-
root: {
|
|
220
|
-
backgroundColor: palette.background.paper,
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
},
|
|
224
|
-
MuiBottomNavigationAction: {
|
|
225
|
-
styleOverrides: {
|
|
226
|
-
root: {
|
|
227
|
-
color: palette.text.secondary,
|
|
228
|
-
'&.Mui-selected': { color: palette.primary.main },
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
MuiOutlinedInput: {
|
|
233
|
-
styleOverrides: {
|
|
234
|
-
root: {
|
|
235
|
-
transition: stateTransition,
|
|
236
|
-
'& .MuiOutlinedInput-notchedOutline': {
|
|
237
|
-
borderColor: palette.controlBorder.main,
|
|
238
|
-
},
|
|
239
|
-
'&:hover .MuiOutlinedInput-notchedOutline': {
|
|
240
|
-
borderColor: palette.controlBorder.hover,
|
|
241
|
-
},
|
|
242
|
-
'&.Mui-focused .MuiOutlinedInput-notchedOutline': {
|
|
243
|
-
borderColor: palette.controlBorder.focus,
|
|
244
|
-
borderWidth: 2,
|
|
245
|
-
},
|
|
246
|
-
'&.Mui-error .MuiOutlinedInput-notchedOutline': {
|
|
247
|
-
borderColor: palette.controlBorder.error,
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
input: autofill,
|
|
251
|
-
},
|
|
252
|
-
},
|
|
253
|
-
MuiFilledInput: {
|
|
254
|
-
styleOverrides: { input: autofill },
|
|
255
|
-
},
|
|
256
|
-
MuiInput: {
|
|
257
|
-
styleOverrides: { input: autofill },
|
|
258
|
-
},
|
|
259
|
-
MuiAlert: {
|
|
260
|
-
styleOverrides: alertStyles,
|
|
261
|
-
},
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
if (isDark) {
|
|
265
|
-
for (const component of ['MuiDialog', 'MuiMenu', 'MuiPopover', 'MuiDrawer']) {
|
|
266
|
-
components[component] = {
|
|
267
|
-
styleOverrides: {
|
|
268
|
-
paper: {
|
|
269
|
-
backgroundColor: DARK_OVERLAY_SURFACE,
|
|
270
|
-
boxShadow: DARK_OVERLAY_SHADOW,
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
components.MuiBackdrop = { styleOverrides: { root: { backgroundColor: DARK_SCRIM } } };
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return components;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Builds the shared application theme while leaving app identity in primary
|
|
283
|
-
* and fontFamily. Palette resolution happens before palette-aware component
|
|
284
|
-
* objects are created, so runtime app/site overrides cannot leave stale values.
|
|
285
|
-
*/
|
|
286
|
-
export function createAppTheme(appConfig = {}) {
|
|
287
|
-
if (!appConfig?.palette?.primary) {
|
|
288
|
-
throw new TypeError('createAppTheme: appConfig.palette.primary is required.');
|
|
289
|
-
}
|
|
290
|
-
validateStyleOverrides(appConfig.components);
|
|
291
|
-
|
|
292
|
-
const isDark = appConfig.palette.mode === 'dark';
|
|
293
|
-
const baselinePalette = isDark ? BASELINE_PALETTE_DARK : BASELINE_PALETTE;
|
|
294
|
-
|
|
295
|
-
const paletteTheme = createTheme(
|
|
296
|
-
{ palette: appConfig.palette },
|
|
297
|
-
{ palette: baselinePalette },
|
|
298
|
-
{ palette: appConfig.palette },
|
|
299
|
-
);
|
|
300
|
-
const finalPalette = paletteTheme.palette;
|
|
301
|
-
const contrastSurfaces = isDark
|
|
302
|
-
? [finalPalette.background.default, finalPalette.background.paper]
|
|
303
|
-
: ['#FFFFFF', finalPalette.background.default];
|
|
304
|
-
const derivedStatusEntries = {};
|
|
305
|
-
for (const status of ['success', 'warning', 'error', 'info']) {
|
|
306
|
-
if (appConfig.palette?.[status]?.main !== undefined) continue;
|
|
307
|
-
|
|
308
|
-
const current = finalPalette[status];
|
|
309
|
-
const statusSurfaces = isDark
|
|
310
|
-
? [finalPalette.background.default, current.bg]
|
|
311
|
-
: contrastSurfaces;
|
|
312
|
-
const main = isDark
|
|
313
|
-
? deriveLightenedPageColour(current.main, statusSurfaces, 4.5)
|
|
314
|
-
: deriveDarkenedPageColour(current.main, statusSurfaces, 4.5);
|
|
315
|
-
if (main !== current.main) {
|
|
316
|
-
derivedStatusEntries[status] = {
|
|
317
|
-
...current,
|
|
318
|
-
...withMainShades(main, current.contrastText),
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const derivedControlBorderEntries = {};
|
|
324
|
-
for (const state of ['main', 'hover', 'error']) {
|
|
325
|
-
if (appConfig.palette?.controlBorder?.[state] !== undefined) continue;
|
|
326
|
-
|
|
327
|
-
const current = finalPalette.controlBorder[state];
|
|
328
|
-
const derived = isDark
|
|
329
|
-
? state === 'error'
|
|
330
|
-
? deriveLightenedPageColour(current, [finalPalette.background.default, finalPalette.error.bg], 3)
|
|
331
|
-
: deriveDarkAlphaColour(finalPalette.ink.primary, contrastSurfaces)
|
|
332
|
-
: state === 'error'
|
|
333
|
-
? deriveDarkenedPageColour(current, contrastSurfaces, 3)
|
|
334
|
-
: deriveAlphaPageColour(current, contrastSurfaces, 3);
|
|
335
|
-
if (derived !== current) derivedControlBorderEntries[state] = derived;
|
|
336
|
-
}
|
|
337
|
-
if (isDark && appConfig.palette?.controlBorder?.hover === undefined) {
|
|
338
|
-
const main = derivedControlBorderEntries.main || finalPalette.controlBorder.main;
|
|
339
|
-
const alpha = Number(main.match(/,([\d.]+)\)$/)?.[1] || 0);
|
|
340
|
-
const hoverAlpha = Math.min(1, Number((alpha + 0.15).toFixed(2)));
|
|
341
|
-
const [red, green, blue] = inkChannels(finalPalette.ink.primary);
|
|
342
|
-
derivedControlBorderEntries.hover = `rgba(${red},${green},${blue},${hoverAlpha.toFixed(2)})`;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const primaryMain = isDark
|
|
346
|
-
? deriveLightenedPageColour(finalPalette.primary.main, [finalPalette.background.default], 4.5)
|
|
347
|
-
: finalPalette.primary.main;
|
|
348
|
-
const primaryContrastText = isDark
|
|
349
|
-
? (getContrastRatio('#FFFFFF', primaryMain) >= getContrastRatio(finalPalette.background.default, primaryMain)
|
|
350
|
-
? '#FFFFFF'
|
|
351
|
-
: finalPalette.background.default)
|
|
352
|
-
: finalPalette.primary.contrastText;
|
|
353
|
-
const derivedSeries = isDark && appConfig.palette?.dataSeries?.categorical === undefined
|
|
354
|
-
? finalPalette.dataSeries.categorical.map((colour) => (
|
|
355
|
-
deriveLightenedPageColour(colour, [finalPalette.background.paper], 3)
|
|
356
|
-
))
|
|
357
|
-
: finalPalette.dataSeries.categorical;
|
|
358
|
-
|
|
359
|
-
const computedPalette = {
|
|
360
|
-
...derivedStatusEntries,
|
|
361
|
-
controlBorder: {
|
|
362
|
-
...finalPalette.controlBorder,
|
|
363
|
-
...derivedControlBorderEntries,
|
|
364
|
-
focus: isDark
|
|
365
|
-
? (appConfig.palette?.controlBorder?.focus
|
|
366
|
-
?? deriveLightenedColour(primaryMain, contrastSurfaces))
|
|
367
|
-
: deriveFocusColour(finalPalette.primary.main, contrastSurfaces),
|
|
368
|
-
},
|
|
369
|
-
primary: {
|
|
370
|
-
...finalPalette.primary,
|
|
371
|
-
// A lightened main needs its own light/dark shades, or hover states keep
|
|
372
|
-
// the shades of the colour that was replaced.
|
|
373
|
-
...(isDark && primaryMain !== finalPalette.primary.main
|
|
374
|
-
? withMainShades(primaryMain, primaryContrastText)
|
|
375
|
-
: { main: primaryMain }),
|
|
376
|
-
contrastText: primaryContrastText,
|
|
377
|
-
},
|
|
378
|
-
dataSeries: { categorical: derivedSeries },
|
|
379
|
-
};
|
|
380
|
-
const resolvedPalette = { ...finalPalette, ...computedPalette };
|
|
381
|
-
const fontFamily = appConfig.typography?.fontFamily || BASELINE_STATIC.typography.fontFamily;
|
|
382
|
-
// The h4 step below `sm` follows the app's own `sm` if it overrides the breakpoint,
|
|
383
|
-
// so the step always ends where theme.breakpoints.down('sm') ends.
|
|
384
|
-
const { [breakpointDownQuery(BREAKPOINT_SM)]: h4Mobile, ...h4Base } = BASELINE_STATIC.typography.h4;
|
|
385
|
-
const smValue = appConfig.breakpoints?.values?.sm ?? BREAKPOINT_SM;
|
|
386
|
-
|
|
387
|
-
return createTheme(
|
|
388
|
-
{
|
|
389
|
-
...BASELINE_STATIC,
|
|
390
|
-
typography: {
|
|
391
|
-
...BASELINE_STATIC.typography,
|
|
392
|
-
fontFamily,
|
|
393
|
-
h4: { ...h4Base, [breakpointDownQuery(smValue)]: h4Mobile },
|
|
394
|
-
},
|
|
395
|
-
fontLoading: {
|
|
396
|
-
...BASELINE_STATIC.fontLoading,
|
|
397
|
-
weights: [...BASELINE_STATIC.fontLoading.weights],
|
|
398
|
-
},
|
|
399
|
-
shadow: isDark ? { ...BASELINE_STATIC.shadow, overlay: DARK_OVERLAY_SHADOW } : BASELINE_STATIC.shadow,
|
|
400
|
-
palette: resolvedPalette,
|
|
401
|
-
themeCompleteness: {
|
|
402
|
-
baseline: true,
|
|
403
|
-
exemptions: (isDark
|
|
404
|
-
? BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS_DARK
|
|
405
|
-
: BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS).map((exemption) => ({
|
|
406
|
-
...exemption,
|
|
407
|
-
})),
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
{
|
|
411
|
-
components: createPaletteAwareComponents(resolvedPalette, isDark),
|
|
412
|
-
},
|
|
413
|
-
appConfig,
|
|
414
|
-
{
|
|
415
|
-
palette: {
|
|
416
|
-
...(isDark ? computedPalette : {}),
|
|
417
|
-
dataSeries: {
|
|
418
|
-
categorical: [...resolvedPalette.dataSeries.categorical],
|
|
419
|
-
},
|
|
420
|
-
},
|
|
421
|
-
},
|
|
422
|
-
);
|
|
423
|
-
}
|
package/src/theme/fonts.js
DELETED
package/src/theme/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import './fonts';
|
|
2
|
-
|
|
3
|
-
export { createAppTheme } from './createAppTheme';
|
|
4
|
-
export {
|
|
5
|
-
assertThemeComplete,
|
|
6
|
-
assertKitSxDisjoint,
|
|
7
|
-
calculateContrastRatio,
|
|
8
|
-
reportOffPaletteColours,
|
|
9
|
-
reportKitSxBypasses,
|
|
10
|
-
reportRedundantThemeValues,
|
|
11
|
-
reportThemeAdoption,
|
|
12
|
-
THEME_COMPLETENESS_SURFACES,
|
|
13
|
-
} from './themeCompleteness';
|
|
14
|
-
export { KIT_COMPONENT_SX_REGISTRY } from './kitSxRegistry';
|
|
15
|
-
export {
|
|
16
|
-
formatShortTime,
|
|
17
|
-
formatShortDate,
|
|
18
|
-
formatShortMonth,
|
|
19
|
-
formatShortYear,
|
|
20
|
-
} from '../components/charts/chartLabels';
|
|
21
|
-
export { yearTickInterval } from '../components/charts/yearTickInterval';
|