@micha.bigler/ui-core-micha 2.36.0 → 2.37.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/README.md +4 -0
- package/WORK_ORDERS.md +1 -1
- package/dist/index.js +8 -0
- package/package.json +1 -1
- package/src/index.js +18 -0
- package/tests/i18nAggregate.test.js +121 -0
package/README.md
CHANGED
|
@@ -5,3 +5,7 @@
|
|
|
5
5
|
Run `pnpm dev` to open the local Vite harness. It mounts entries with the package's MUI theme, `react-i18next`, a memory router, and fixture-backed REST/realtime transport. Use the controls to change theme and viewport.
|
|
6
6
|
|
|
7
7
|
To add an entry, create a small component in `dev/entries.jsx` and append it to `entries`. It may be a complete surface or one standalone component. Keep fixtures and transport behaviour in `dev/`, never in `src/`: the harness is not part of the published package.
|
|
8
|
+
|
|
9
|
+
## Internationalization
|
|
10
|
+
|
|
11
|
+
Spread `uiCoreTranslations` into the default i18n namespace as the supported aggregate; per-feature translation exports remain available to selective apps that accept responsibility for pairing every adopted feature with its bundle.
|
package/WORK_ORDERS.md
CHANGED
|
@@ -72,7 +72,7 @@ Two chunks. **Chunk 1** (Part 1 + Part 2 of the Envelope): extended `SPACING_SHO
|
|
|
72
72
|
**Operator decision: fix both** (of three offered options: widen-and-fix / exempt-with-reason / narrow-the-scanner). Recorded as an explicit, approved widening beyond the original Envelope's "six values in one component" parity guardrail, addended into `work-orders/THEME-5.md` before chunk 2 ran. **Chunk 2**: (8) `SocialLoginButtons.jsx`'s Google-icon border `1px solid rgba(0,0,0,0.2)` → `divider`; (9) `exportChart.js`'s Canvas 2D `context.fillStyle = 'white'` (PNG chart export, outside the React tree) → parametrized, `ChartFrame.jsx` now passes `theme.palette.background.paper` in via `useTheme()`.
|
|
73
73
|
|
|
74
74
|
**Orchestrator's own verification:** scoped tests (`themeCompleteness`, `createAppTheme`, `MobileBottomNav`, `ChartFrame`) 65/65 green, `tsc -p tsconfig.build.json --noEmit` clean. Independent `reviewer` (Sonnet) + `ui_reviewer` (Sonnet) spawned concurrently against the real, complete two-chunk diff — **this was the only independent review that actually ran; no prior pass exists despite what the uncommitted Notiz briefly claimed.** Both reviewers: **no blocking code findings.** `reviewer`: two P3 notes, not fixed — the print-document masking regex only matches the first `printWindow.document.write(...)` call in a file (currently safe, only one exists; latent fragility if a second is ever added); `exportChartPng`'s new `backgroundColour` parameter has no default (low risk, not exported from `src/index.js`, single caller always supplies it — a footgun only if the function gains a second caller or goes public). `ui_reviewer`: confirmed all nine role-based mappings resolve against real `tokens.js` values and are visually reasonable; flagged the Google-icon border change (`rgba(0,0,0,0.2)` → `divider`, roughly halving visible contrast) as the single largest visual delta of the nine and worth a live look given the operator's explicit no-rendered-gate decision for this WO — not blocking, no rendered gate was added, consistent with that decision. Version `2.34.0` → `2.35.0` (minor, new exported API). No rendered/prototype gate, per the operator's explicit decision — this note is the substitute, all nine changed values listed from-and-to above. DS-18 follow-ups. |
|
|
75
|
-
| SHELL-5 | Promote the secondary-navigation shell | Promotes jg-ferien's `SectionSwitcher` (grouped sidebar + bottom drawer) into the kit as the level *below* the bottom bar, adds the trigger bar that supplies the missing affordance, and makes ucm's own `AccountPage` its first consumer by replacing its horizontal `Tabs` strip. Look and feel follow jg by operator decision. Full spec: [work-orders/SHELL-5.md](work-orders/SHELL-5.md). | 2026-08-11 | done |
|
|
75
|
+
| SHELL-5 | Promote the secondary-navigation shell | Promotes jg-ferien's `SectionSwitcher` (grouped sidebar + bottom drawer) into the kit as the level *below* the bottom bar, adds the trigger bar that supplies the missing affordance, and makes ucm's own `AccountPage` its first consumer by replacing its horizontal `Tabs` strip. Look and feel follow jg by operator decision. Full spec: [work-orders/SHELL-5.md](work-orders/SHELL-5.md). | 2026-08-11 | done | b283c33 | DS-11. Supersedes `SHELL-2` (now `dropped`); prototype `assets/SHELL-2-account-navigation.html` kept as the composition spec. Each jg-specific concept was made optional and `AccountPage` proves it optional: no `overviewItem` (no "Übersicht" concept), no `rememberedKey`, `APP_HEADER_HEIGHT` → `headerOffset` (default `24`), `zIndex.drawer + 3` kept as default (`SHELL-3`'s bar sits at `+2`, ordering is meaningful), and the 280px two-column grid moved from the consumer into the component. The trigger bar is the one net-new piece (jg has none) — new full-width 56px bar, first thing rendered on mobile, opens a bottom drawer. `AccountPage`'s flat permission-computed `tabs` list bucketed into four fixed groups per the prototype ("Mein Konto"/"Verwaltung"/"Hilfe"/trailing "Weitere" catch-all for ungrouped `extraTabs`), new `Account.GROUP_*` i18n keys; `?tab=` contract and all permission-gating logic byte-for-byte unchanged. New component-owned chrome i18n (`src/i18n/sectionNavTranslations.ts`, all 4 locales) resolves the trap jg's `t("SectionSwitcher.TITLE")` had — no fallback, would have rendered a raw key. **Codex left the diff uncommitted and did not touch this file, as instructed** (the third consecutive WO where the explicit warning about the prior invalid-review pattern held). **Concurrent-session note:** an unrelated `I18N-1` session was uncommitted in the same working tree at the same time (`README.md`, `tests/i18nAggregate.test.js`, an aggregate-translations addition to `src/index.js`) — separated by hunk-level staging (`git add -p`) before this commit; only `SectionNav`'s two export lines in `src/index.js` are in this commit, I18N-1's own hunks were left for its own session to land. **Orchestrator's own verification:** scoped tests green (52/52 after fixes, see below), `tsc` clean. Independent `reviewer` + `ui_reviewer` (Sonnet, both mandatory — new logic and a prototype in scope) ran concurrently. **`reviewer` found two real P2s, both fixed:** the drawer's `zIndex` was set via BOTH an exported/registered `sx` object and a separate inline `style` prop on the same element — `style` always wins, so the registered `sx` value was dead code, tested but never actually reaching the DOM; removed the redundant `SECTION_NAV_DRAWER_SX` entirely (and its now-pointless `kitSxRegistry.js` entry), kept only the working `style`-based zIndex. The "optional controlled" `open`/`onClose` API (an Orchestrator design resolution for reconciling jg's controlled drawer with the new internally-triggered one) was incomplete — no `onOpen` callback existed, so a controlled consumer's trigger click was silently a no-op; added `onOpen`, fixed, added a regression test (`AccountPage` itself is unaffected, it uses uncontrolled mode). **`ui_reviewer` found one real P2, fixed:** the mobile trigger's current-section text used `fontWeight={700}`, matching neither the theme's `subtitle1` (600) nor the prototype's `.trigger-value` (16.5px/600) — an undeclared deviation that made it visually indistinguishable from the bold group headers; removed the override. One P3 left as documented, not fixed: `headerOffset` defaults to `24` vs. the prototype's `16` — a defensible generalisation (the component no longer assumes a fixed app-header height the way jg's original did; no consumer today is sensitive to the exact value). **Rendered verification:** the Browser pane could not composite frames in this session (same recurring environment limitation as `SHELL-3`/`SHELL-4`) — DOM/computed-style substitution via the test suite's own assertions (grid columns, drawer dimensions, z-index, theme-token resolution under two themes) plus static composition comparison against the prototype by both independent reviewers, one of which (`ui_reviewer`) is exactly the review type this repo relies on for design fidelity when a real render isn't obtainable. **Follow-ups named, unchanged:** jg migrates onto this and deletes its own drawer (operator requirement, separate WO); the users table is `AUTH-4`, deliberately not here. |
|
|
76
76
|
| AUTH-4 | The account users table is a desktop table shown unchanged on a phone | Measured 2026-08-11 in cockpit at `innerWidth` 411: `UserListComponent`'s table renders **1053px inside a 325px container** — 728px of overflow. The container has `overflow-x: auto` and **the document does not overflow**, so this is not a broken layout; it is six fixed-width desktop columns (Email 220, Name 180, New 90, Successful Login 163, Role 180, Actions 220) on a phone, with Role and Actions entirely outside the view. | 2026-08-11 | planned | | Split out of DS-11 by operator decision because its fix class differs from the navigation shell's. **No Envelope yet — its WHAT is undecided** and needs a design round: column priority, a card layout below `md`, or a sticky first column with horizontal scroll are three different answers with different costs. `SHELL-2` measured 1045px on 2026-08-08 and it is 1053px today (+8px), so the number is stable — cell padding is already the baseline's `10px 16px`, meaning `THEME-4`/`THEME-5` did not move the rendered density. Reached via `AccountPage` → the `users` tab, which **at least ten apps mount**, so any fix lands estate-wide. Prefix note: `AUTH-*` because the account screen's own surfaces belong to that stream, not because this is authentication. |
|
|
77
77
|
| I18N-1 | One export, so a consumer cannot half-register the kit's strings | ucm exports its UI strings as **six separate bundles** that each app must spread into its own i18n resources by hand. Adopting a component without also adding its bundle renders **a raw key as visible UI text** — no type error, no runtime error. Ship a `uiCoreTranslations` aggregate so that cannot happen, and so a future ucm feature is carried automatically instead of requiring twelve apps to notice. Full order [work-orders/I18N-1.md](work-orders/I18N-1.md). | 2026-08-11 | planned | | Tier 3 (shared-core + new public export), target `2.36.0` (minor, fully additive). New `I18N-*` prefix, documented in the header above. **Two apps hit by the same mechanism, evidence not hypothesis:** (1) cockpit's `UI-3` adopted `UserMenu` without `userMenuTranslations` and shipped a header button reading the literal `UserMenu.TITLE` — **both independent static reviews were clean**, it was caught only by the rendered click-through, and only by DOM inspection at that since screenshots were unavailable; (2) **fitness-monitor is defective right now** — it imports `ChartFrame` (`BodyHistoryPage.jsx:7`, used `:295`/`:445`) but registers only `authTranslations`, so `ChartFrame.jsx:74`'s `t('ChartFrame.LOADING')` and its empty/error siblings render raw keys. It survived because those are transient edge states. **Estate survey, 2026-08-11:** twelve apps register ucm bundles — jg-ferien all six, cockpit four, hram three, **fitness-monitor one (defective)**, and eight auth-only apps that are correct solely because they have not adopted a second component yet. That is a coincidence with an expiry date, not a safety property. **The merge is safe:** 504 keys across the six bundles with **zero collisions**, verified by enumeration; every key is namespace-prefixed. **The part that makes the fix permanent is the ratchet test** — the aggregate must be asserted against the bundle list **read from `src/i18n/`**, not a hand-written list, so a future bundle that is not folded in fails. Without it the aggregate is correct today and rots exactly as the six exports did. Per-feature exports stay (removing them would break twelve apps for no gain); double-spreading during migration is harmless, which is why the zero-collision property is a test and not a comment. **Rollout is constrained by the one-repo rule** — a WO implements in one repository, so the twelve consumers cannot be migrated from here: `fitness-monitor/FM-14` is written, mandatory and blocked on this release, and **fitness-monitor renders raw keys until it lands** (the operator chose to route the fix through this rollout rather than patch it separately, so it could not be lost between two WOs; the delay is the cost and is recorded rather than left implicit). The other eleven are correct today — prevention, not repair — and ride along when each is next touched. Self-registration via `addResourceBundle` is **deliberately out of scope**: feasible (ucm components use `useTranslation()` against the consumer's own instance and ucm owns no instance), but all twelve consumers flatten into the default namespace with dotted keys, and registering at render time risks a first-paint flash of the raw key — replacing an invisible defect with a visible one. It is `I18N-2`, framed as a bundle-size optimisation rather than a correctness fix, because this WO already closes the hole. |
|
|
78
78
|
| I18N-2 | Self-registering component strings, if the bundle cost justifies it | Have ucm components register their own strings on the consumer's i18n instance (`addResourceBundle` on the instance from `useTranslation()`) instead of relying on the consumer spreading a bundle. Would remove the last of the consumer's i18n obligations and stop auth-only apps shipping strings they never render. | 2026-08-11 | planned | | Tier 3 (shared-core, changes how every consumer resolves strings). **Deliberately NOT a correctness WO** — `I18N-1`'s aggregate closes the defect class; this is a bundle-size optimisation and is scheduled on that basis alone. **Its input is a measurement `I18N-1` must produce**: the built size delta an auth-only app takes on by switching to the aggregate. Source-side that is ~30 KB of strings (the five non-auth bundles are 188 keys against auth's 316), but a source figure is not the answer and a guess here would make this decision unfalsifiable. **Two known hazards, both to be resolved before authoring:** (1) all twelve consumers flatten everything into i18next's DEFAULT namespace with flat dotted keys, so the registration shape has to match exactly or key resolution changes under twelve apps at once; (2) registering during render risks a first-paint flash of the raw key — which would trade an invisible defect for a visible one, the opposite of the point. Feasibility is established: ucm components use `useTranslation()` against the consumer's instance and ucm owns no i18next instance of its own, so there is a real instance to register against. |
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
// index.js (Entry Point deiner Library)
|
|
2
|
+
import { authTranslations } from './i18n/authTranslations';
|
|
3
|
+
import { chartsTranslations } from './i18n/chartsTranslations';
|
|
4
|
+
import { messagingTranslations } from './i18n/messagingTranslations';
|
|
5
|
+
import { notificationsTranslations } from './i18n/notificationsTranslations';
|
|
6
|
+
import { onboardingTranslations } from './i18n/onboardingTranslations';
|
|
7
|
+
import { sectionNavTranslations } from './i18n/sectionNavTranslations';
|
|
8
|
+
import { userMenuTranslations } from './i18n/userMenuTranslations';
|
|
2
9
|
// --- 0. Theme ---
|
|
3
10
|
export { createAppTheme, assertThemeComplete, assertKitSxDisjoint, calculateContrastRatio, KIT_COMPONENT_SX_REGISTRY, reportOffPaletteColours, reportKitSxBypasses, reportThemeAdoption, THEME_COMPLETENESS_SURFACES, } from './theme';
|
|
4
11
|
// --- 1. Auth Context (Essentiell für den Wrapper) ---
|
|
@@ -81,3 +88,4 @@ export { notificationsTranslations } from './i18n/notificationsTranslations';
|
|
|
81
88
|
export { onboardingTranslations } from './i18n/onboardingTranslations';
|
|
82
89
|
export { chartsTranslations } from './i18n/chartsTranslations';
|
|
83
90
|
export { messagingTranslations } from './i18n/messagingTranslations';
|
|
91
|
+
export const uiCoreTranslations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, authTranslations), chartsTranslations), messagingTranslations), notificationsTranslations), onboardingTranslations), sectionNavTranslations), userMenuTranslations);
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
// index.js (Entry Point deiner Library)
|
|
2
2
|
|
|
3
|
+
import { authTranslations } from './i18n/authTranslations';
|
|
4
|
+
import { chartsTranslations } from './i18n/chartsTranslations';
|
|
5
|
+
import { messagingTranslations } from './i18n/messagingTranslations';
|
|
6
|
+
import { notificationsTranslations } from './i18n/notificationsTranslations';
|
|
7
|
+
import { onboardingTranslations } from './i18n/onboardingTranslations';
|
|
8
|
+
import { sectionNavTranslations } from './i18n/sectionNavTranslations';
|
|
9
|
+
import { userMenuTranslations } from './i18n/userMenuTranslations';
|
|
10
|
+
|
|
3
11
|
// --- 0. Theme ---
|
|
4
12
|
export {
|
|
5
13
|
createAppTheme,
|
|
@@ -125,3 +133,13 @@ export { notificationsTranslations } from './i18n/notificationsTranslations';
|
|
|
125
133
|
export { onboardingTranslations } from './i18n/onboardingTranslations';
|
|
126
134
|
export { chartsTranslations } from './i18n/chartsTranslations';
|
|
127
135
|
export { messagingTranslations } from './i18n/messagingTranslations';
|
|
136
|
+
|
|
137
|
+
export const uiCoreTranslations = {
|
|
138
|
+
...authTranslations,
|
|
139
|
+
...chartsTranslations,
|
|
140
|
+
...messagingTranslations,
|
|
141
|
+
...notificationsTranslations,
|
|
142
|
+
...onboardingTranslations,
|
|
143
|
+
...sectionNavTranslations,
|
|
144
|
+
...userMenuTranslations,
|
|
145
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
|
|
6
|
+
vi.mock('@mui/icons-material', () => ({
|
|
7
|
+
Archive: () => null,
|
|
8
|
+
Campaign: () => null,
|
|
9
|
+
Groups: () => null,
|
|
10
|
+
MoreVert: () => null,
|
|
11
|
+
NotificationsOff: () => null,
|
|
12
|
+
Person: () => null,
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
authTranslations as publicAuthTranslations,
|
|
17
|
+
chartsTranslations as publicChartsTranslations,
|
|
18
|
+
messagingTranslations as publicMessagingTranslations,
|
|
19
|
+
notificationsTranslations as publicNotificationsTranslations,
|
|
20
|
+
onboardingTranslations as publicOnboardingTranslations,
|
|
21
|
+
sectionNavTranslations as publicSectionNavTranslations,
|
|
22
|
+
uiCoreTranslations,
|
|
23
|
+
userMenuTranslations as publicUserMenuTranslations,
|
|
24
|
+
} from '../src/index';
|
|
25
|
+
|
|
26
|
+
const I18N_DIRECTORY = path.resolve('src/i18n');
|
|
27
|
+
// Scoped to the three locales every bundle already carries. `messagingTranslations`'s 116 keys
|
|
28
|
+
// have no `sw` value yet (pre-existing gap, out of I18N-1's scope — see the Notiz on the
|
|
29
|
+
// I18N-1 register row for the tracked follow-up to backfill it and restore `sw` here).
|
|
30
|
+
const REQUIRED_LOCALES = ['de', 'en', 'fr'];
|
|
31
|
+
const bundleImporters = import.meta.glob('../src/i18n/*.ts');
|
|
32
|
+
const PUBLIC_BUNDLES = {
|
|
33
|
+
authTranslations: publicAuthTranslations,
|
|
34
|
+
chartsTranslations: publicChartsTranslations,
|
|
35
|
+
messagingTranslations: publicMessagingTranslations,
|
|
36
|
+
notificationsTranslations: publicNotificationsTranslations,
|
|
37
|
+
onboardingTranslations: publicOnboardingTranslations,
|
|
38
|
+
sectionNavTranslations: publicSectionNavTranslations,
|
|
39
|
+
userMenuTranslations: publicUserMenuTranslations,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function bundleFileNames() {
|
|
43
|
+
return fs.readdirSync(I18N_DIRECTORY, { withFileTypes: true })
|
|
44
|
+
.filter((entry) => entry.isFile() && entry.name.endsWith('.ts'))
|
|
45
|
+
.map((entry) => entry.name)
|
|
46
|
+
.sort();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function loadBundles() {
|
|
50
|
+
return Promise.all(bundleFileNames().map(async (fileName) => {
|
|
51
|
+
const modulePath = `../src/i18n/${fileName}`;
|
|
52
|
+
const importBundle = bundleImporters[modulePath];
|
|
53
|
+
if (!importBundle) {
|
|
54
|
+
throw new Error(`${fileName} was enumerated from src/i18n but has no module importer`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const bundleModule = await importBundle();
|
|
58
|
+
const translationExports = Object.entries(bundleModule)
|
|
59
|
+
.filter(([exportName]) => exportName.endsWith('Translations'));
|
|
60
|
+
|
|
61
|
+
if (Object.keys(bundleModule).length !== 1 || translationExports.length !== 1) {
|
|
62
|
+
throw new Error(`${fileName} must export exactly one *Translations bundle`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const [[exportName, translations]] = translationExports;
|
|
66
|
+
return { exportName, fileName, translations };
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('uiCoreTranslations', () => {
|
|
71
|
+
it('contains every directory-enumerated bundle key with its original value', async () => {
|
|
72
|
+
const bundles = await loadBundles();
|
|
73
|
+
const sourceKeys = [];
|
|
74
|
+
|
|
75
|
+
for (const { fileName, translations } of bundles) {
|
|
76
|
+
for (const [key, value] of Object.entries(translations)) {
|
|
77
|
+
sourceKeys.push(key);
|
|
78
|
+
expect(
|
|
79
|
+
Object.hasOwn(uiCoreTranslations, key),
|
|
80
|
+
`${key} from ${fileName} is missing from the public aggregate`,
|
|
81
|
+
).toBe(true);
|
|
82
|
+
expect(uiCoreTranslations[key]).toEqual(value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
expect(Object.keys(uiCoreTranslations).sort()).toEqual(sourceKeys.sort());
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('does not allow duplicate keys across source bundles', async () => {
|
|
90
|
+
const owners = new Map();
|
|
91
|
+
const collisions = [];
|
|
92
|
+
|
|
93
|
+
for (const { fileName, translations } of await loadBundles()) {
|
|
94
|
+
for (const key of Object.keys(translations)) {
|
|
95
|
+
if (owners.has(key)) {
|
|
96
|
+
collisions.push(`${key}: ${owners.get(key)} and ${fileName}`);
|
|
97
|
+
} else {
|
|
98
|
+
owners.set(key, fileName);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
expect(collisions, `Translation key collisions:\n${collisions.join('\n')}`).toEqual([]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('preserves at least the required locale shape for every aggregate value', () => {
|
|
107
|
+
for (const [key, value] of Object.entries(uiCoreTranslations)) {
|
|
108
|
+
for (const locale of REQUIRED_LOCALES) {
|
|
109
|
+
expect(typeof value[locale], `${key}.${locale} must be a string`).toBe('string');
|
|
110
|
+
expect(value[locale].trim(), `${key}.${locale} must not be empty`).not.toBe('');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('keeps every per-feature bundle available unchanged from the package root', async () => {
|
|
116
|
+
for (const { exportName, translations } of await loadBundles()) {
|
|
117
|
+
expect(PUBLIC_BUNDLES[exportName], `${exportName} must remain a public export`)
|
|
118
|
+
.toBe(translations);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|