@micha.bigler/ui-core-micha 3.10.0 → 3.11.1

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.
@@ -22,6 +22,9 @@ import { UserListComponent } from '../src/components/UserListComponent';
22
22
  const germanResources = Object.fromEntries(
23
23
  Object.entries(authTranslations).map(([key, value]) => [key, value.de]),
24
24
  );
25
+ const englishResources = Object.fromEntries(
26
+ Object.entries(authTranslations).map(([key, value]) => [key, value.en]),
27
+ );
25
28
  const i18n = i18next.createInstance();
26
29
  i18n.init({
27
30
  lng: 'de',
@@ -31,12 +34,22 @@ i18n.init({
31
34
  nsSeparator: false,
32
35
  interpolation: { escapeValue: false },
33
36
  });
37
+ const englishI18n = i18next.createInstance();
38
+ englishI18n.init({
39
+ lng: 'en',
40
+ fallbackLng: 'en',
41
+ resources: { en: { translation: englishResources } },
42
+ keySeparator: false,
43
+ nsSeparator: false,
44
+ interpolation: { escapeValue: false },
45
+ });
34
46
 
35
47
  const ENGLISH_DEFAULTS = [
36
48
  'All Users',
37
49
  'Search',
38
50
  'Search users...',
39
51
  'Rows per page:',
52
+ 'of 1',
40
53
  'Successful Login',
41
54
  'Are you sure you want to delete this user?',
42
55
  'Invite a new user',
@@ -51,6 +64,10 @@ function withGermanI18n(children) {
51
64
  return <I18nextProvider i18n={i18n}>{children}</I18nextProvider>;
52
65
  }
53
66
 
67
+ function withEnglishI18n(children) {
68
+ return <I18nextProvider i18n={englishI18n}>{children}</I18nextProvider>;
69
+ }
70
+
54
71
  function expectNoEnglishDefaults() {
55
72
  const text = document.body.textContent;
56
73
  for (const english of ENGLISH_DEFAULTS) {
@@ -112,6 +129,7 @@ describe('German user and invite screen translations', () => {
112
129
  await waitFor(() => expect(screen.getByText('Alle Benutzer')).toBeTruthy());
113
130
  expect(screen.getByLabelText('Suche')).toBeTruthy();
114
131
  expect(screen.getByPlaceholderText('Benutzer suchen...')).toBeTruthy();
132
+ expect(screen.getByText('1–1 von 1')).toBeTruthy();
115
133
  for (const german of ['Neu', 'Erfolgreiche Anmeldung', 'Rolle', 'Aktionen', 'Zeilen pro Seite:', 'Löschen']) {
116
134
  expect(screen.getByText(german)).toBeTruthy();
117
135
  }
@@ -124,6 +142,41 @@ describe('German user and invite screen translations', () => {
124
142
  expectNoEnglishDefaults();
125
143
  });
126
144
 
145
+ it('renders the pagination range in English when the locale is English', async () => {
146
+ render(withEnglishI18n(<UserListComponent currentUser={{ id: 99, is_superuser: true, role: 'admin' }} />));
147
+
148
+ await waitFor(() => expect(screen.getByText('1–1 of 1')).toBeTruthy());
149
+ });
150
+
151
+ it('actually goes through the translation key, not a coincidental match with MUI\'s own default', async () => {
152
+ // The real English wording is deliberately identical to MUI's own hardcoded default text
153
+ // (both "{from}-{to} of {count}"), so the assertion above would still pass even if
154
+ // labelDisplayedRows were reverted to unset entirely. Swap in a distinctive marker for just
155
+ // this one key to prove the render genuinely resolves it through i18next, not MUI's fallback
156
+ // (UCM-I18N-5 review, tests lens).
157
+ const markerI18n = i18next.createInstance();
158
+ markerI18n.init({
159
+ lng: 'en',
160
+ fallbackLng: 'en',
161
+ resources: {
162
+ en: {
163
+ translation: { ...englishResources, 'UserList.DISPLAYED_ROWS': '__MARKER__ {{from}}-{{to}}/{{count}}' },
164
+ },
165
+ },
166
+ keySeparator: false,
167
+ nsSeparator: false,
168
+ interpolation: { escapeValue: false },
169
+ });
170
+
171
+ render(
172
+ <I18nextProvider i18n={markerI18n}>
173
+ <UserListComponent currentUser={{ id: 99, is_superuser: true, role: 'admin' }} />
174
+ </I18nextProvider>,
175
+ );
176
+
177
+ await waitFor(() => expect(screen.getByText('__MARKER__ 1-1/1')).toBeTruthy());
178
+ });
179
+
127
180
  it('renders UserInviteComponent in German and translates the success message', async () => {
128
181
  render(withGermanI18n(<UserInviteComponent />));
129
182
 
@@ -0,0 +1,211 @@
1
+ # UCM-I18N-5 — User-list pagination range text is hard-coded English
2
+
3
+ # A. Envelope — authored by the Expertenchat
4
+
5
+ ## Goal & expected outcome
6
+
7
+ - Goal: the user list's pagination reads in the user's language.
8
+ - Expected outcome: `UserListComponent`'s `TablePagination` renders its "1–4 of 4" text through a
9
+ translation key (de/en/fr and every locale the bundles carry), the way `labelRowsPerPage`
10
+ already does.
11
+
12
+ ## Context — measured 2026-10-01 in jg-ferien's local browser (ucm 3.7.0 installed there)
13
+
14
+ - `/account?tab=users` in German: "Zeilen pro Seite: 25 ▾ · **1–4 of 4**". `UserListComponent.jsx`
15
+ (~l.589-600) sets `labelRowsPerPage={t('UserList.ROWS_PER_PAGE', …)}` but no
16
+ `labelDisplayedRows`, so MUI's English default renders. It is the only `TablePagination` in ucm.
17
+ - Follows `UCM-I18N-4` (hard-coded English in the user list).
18
+
19
+ ## Scope + non-goals
20
+
21
+ - In scope: `labelDisplayedRows` via a key with count interpolation; tests; release.
22
+ - Explicit non-goals / do-not-touch: no other change to the user list.
23
+
24
+ ## Tier · gates
25
+
26
+ - **Tier 3** — change inside shared-core (small).
27
+ - Done means released AND jg-ferien's pin bumped.
28
+
29
+ ## Risks
30
+
31
+ - The "more than" form (`count === -1`) must have a wording too, or it renders "of -1".
32
+
33
+ ## Required tests to WRITE (you write them and run YOUR OWN new ones; the orchestrator's run is the gate)
34
+
35
+ 1. In `de`, the pagination shows the German range text; in `en` the English one.
36
+ 2. Key-parity: every locale bundle has the new key.
37
+
38
+ ---
39
+
40
+ # B. Implementation map — filled by the Orchestrator — ADDRESSED TO THE IMPLEMENTER
41
+
42
+ ## Context package
43
+
44
+ ### The call site
45
+
46
+ `src/components/UserListComponent.jsx:589-601`:
47
+ ```jsx
48
+ <TablePagination
49
+ component="div"
50
+ count={sortedUsers.length}
51
+ page={page}
52
+ onPageChange={(_, newPage) => setPage(newPage)}
53
+ rowsPerPage={pageSize}
54
+ onRowsPerPageChange={(event) => {
55
+ setPageSize(Number(event.target.value));
56
+ setPage(0);
57
+ }}
58
+ labelRowsPerPage={t('UserList.ROWS_PER_PAGE', 'Rows per page:')}
59
+ rowsPerPageOptions={[10, 25, 50, 100]}
60
+ />
61
+ ```
62
+ `t`/`i18n` come from `useTranslation()` (`react-i18next`), already in scope at l.53.
63
+
64
+ ### MUI's `labelDisplayedRows` contract
65
+
66
+ MUI's own default (`node_modules/@mui/material/TablePagination/TablePagination.js:119-124`,
67
+ for reference only — do not import it):
68
+ ```js
69
+ function defaultLabelDisplayedRows({ from, to, count }) {
70
+ return `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`;
71
+ }
72
+ ```
73
+ The prop signature is `({ from, to, count, page }) => ReactNode`. `count` is `-1` when the total
74
+ is unknown/unbounded — this component always passes a real `sortedUsers.length`, but the prop
75
+ contract still has to handle `-1` defensively (the Risk note): MUI itself would call the function
76
+ with `-1` only if `count={-1}` were passed, which this component doesn't do — handle it anyway
77
+ since the function must satisfy the full contract, not just this component's current call site.
78
+
79
+ ### The translation bundle has FOUR locales, not three
80
+
81
+ `src/i18n/authTranslations.ts` (flat `export const authTranslations = { "Key.NAME": { de, fr, en,
82
+ sw }, ... }`) carries `de`/`fr`/`en`/`sw` for every existing key, confirmed by grepping all locale
83
+ codes in the file — **sw (Swahili) is real and already translated throughout, not a stub**. "every
84
+ locale the bundles carry" in the Envelope means these four, not jg-ferien's usual three. Add the
85
+ new key(s) in the same shape, next to `UserList.ROWS_PER_PAGE` (~l.2050-2055) for locality.
86
+
87
+ Proposed keys (interpolated, i18next `{{var}}` syntax — do not reserialize the whole file through
88
+ `JSON.parse`/`JSON.stringify`, this is a `.ts` module, not JSON; a plain text insert keeps every
89
+ other entry byte-identical):
90
+ ```ts
91
+ "UserList.DISPLAYED_ROWS": {
92
+ "de": "{{from}}–{{to}} von {{count}}",
93
+ "fr": "{{from}}–{{to}} sur {{count}}",
94
+ "en": "{{from}}–{{to}} of {{count}}",
95
+ "sw": "{{from}}–{{to}} ya {{count}}"
96
+ },
97
+ "UserList.DISPLAYED_ROWS_MORE_THAN": {
98
+ "de": "{{from}}–{{to}} von mehr als {{to}}",
99
+ "fr": "{{from}}–{{to}} sur plus de {{to}}",
100
+ "en": "{{from}}–{{to}} of more than {{to}}",
101
+ "sw": "{{from}}–{{to}} ya zaidi ya {{to}}"
102
+ }
103
+ ```
104
+ The `sw` wording reuses "ya" for "of"/possessive, already used this way elsewhere in the same file
105
+ (e.g. l.57 `"ruhusa ya kutuma mialiko"`, l.114 `"barua pepe ya kuweka upya"`) and "zaidi ya" ("more
106
+ than") as a plain compositional phrase — a reasonable best-effort construction, NOT a
107
+ native-speaker-verified translation; say so plainly in your own report rather than presenting it as
108
+ settled, same as you would for any other claim you can't independently verify.
109
+
110
+ Call site becomes:
111
+ ```jsx
112
+ labelDisplayedRows={({ from, to, count }) =>
113
+ count === -1
114
+ ? t('UserList.DISPLAYED_ROWS_MORE_THAN', '{{from}}–{{to}} of more than {{to}}', { from, to })
115
+ : t('UserList.DISPLAYED_ROWS', '{{from}}–{{to}} of {{count}}', { from, to, count })
116
+ }
117
+ ```
118
+
119
+ ### Existing test harness to extend, not duplicate
120
+
121
+ `tests/userScreenTranslations.test.jsx` already renders `UserListComponent` through a REAL
122
+ `i18next` instance pinned to German (`withGermanI18n`, ~l.22-30, built from
123
+ `authTranslations.*.de`) and asserts rendered German strings plus `expectNoEnglishDefaults()`
124
+ (~l.34-39, checks `document.body.textContent` against an `ENGLISH_DEFAULTS` list, ~l.33-46). The
125
+ test `'renders UserListComponent in German, including pagination and action feedback'` (~l.97-125)
126
+ already fetches exactly 1 user, so the pagination currently renders English "1–1 of 1" — add that
127
+ literal string (or your chosen German text) to the existing `for (const german of [...])` loop
128
+ (~l.115) to assert the real rendered pagination text, and add the English range phrasing (e.g.
129
+ `'of 1'` or similar, whatever actually changes) to `ENGLISH_DEFAULTS` so `expectNoEnglishDefaults()`
130
+ (already called at line 124) starts actually catching a regression here — today it does NOT, since
131
+ no "of N" string is in that list, which is why this bug shipped unnoticed.
132
+
133
+ Required test 1 (German vs English) is naturally satisfied by extending this file: German via the
134
+ existing `withGermanI18n` harness, English via a parallel small i18next instance (or reuse the
135
+ `en` resources the same way `germanResources` is built from `.de`) rendering the same component and
136
+ asserting the English range text.
137
+
138
+ Required test 2 (key-parity across all four locales) — check whether a generic "every key has
139
+ every locale" structural test already exists in this repo (grep `authTranslations` test files for
140
+ something like `Object.values(...).every(...)` or a locale-set check) before writing a new one;
141
+ extend it if so, add a small standalone one for just these two new keys if not.
142
+
143
+ ## Target repo working directory (absolute)
144
+
145
+ `C:\Users\biglmi\Documents\webapps\ui-core-micha` (branch `main`)
146
+
147
+ ## Preamble — a REQUIRED block IN this file, not something appended at invocation
148
+
149
+ > The text above is the COMPLETE spec — the committed WO file's content, not a plan to refine; there
150
+ > is no separate plan file. Read the nearest `AGENTS.md`, the relevant `.codex/skills/<role>/SKILL.md`, and the
151
+ > app `MEMORY.md` ONLY for conventions. Stay in scope; do not touch auth/permissions/deps/schema/CI
152
+ > unless the spec says so; do not update `MEMORY.md`. **Do NOT edit `WORK_ORDERS.md` — the register
153
+ > row and the review verdicts are the orchestrator's alone.** **Your tools are for editing source
154
+ > and test files and for running the tests you wrote — nothing else.** Do NOT install dependencies,
155
+ > touch a lockfile, run a package manager, or tidy up stray files; if something in the repo state
156
+ > blocks you, stop and report it as `RESULT: BLOCKED <reason>` instead of fixing it. Do NOT
157
+ > `git add`/`commit`/`push` — leave every
158
+ > change uncommitted in the working tree for the orchestrator's independent review. WRITE the tests
159
+ > the `Required tests` section calls for AND **RUN the tests you just wrote** to confirm they execute
160
+ > and pass — that is the ONLY test run you do (NOT the app's affected/full suite, NOT any review).
161
+ > The orchestrator re-runs the authoritative set + does the independent review after you finish —
162
+ > those are the gate; your own run does not count as the gate.
163
+ >
164
+ > Narrate continuously: a `PLAN: <step1> | <step2> | …` line up front, then a single-line
165
+ > `PROGRESS: [<n>/<total>] <present-tense action>` before every relevant action (and `… done` on
166
+ > completion), spaced so no gap exceeds ~2 min, stdout unbuffered, plus exactly one final
167
+ > `RESULT: DONE|BLOCKED <reason>`.
168
+
169
+ ---
170
+
171
+ # C. Orchestrator only — NOT ADDRESSED TO THE IMPLEMENTER
172
+
173
+ > **If you are the implementer reading this work order as your own specification: STOP at this line.
174
+ > Everything below describes what the Orchestrator does AFTER you finish. You do none of it — no
175
+ > reviewers, no verification run, no register edit, no commit.**
176
+
177
+ **Execution directive:** dispatch via `codex exec --skip-git-repo-check
178
+ --dangerously-bypass-approvals-and-sandbox -m gpt-5.6-luna - < work-orders/UCM-I18N-5.md` (today,
179
+ 2026-10-02, already recorded `available` in `webapps/.claude/codex-status.md`), cwd =
180
+ `C:\Users\biglmi\Documents\webapps\ui-core-micha`. Monitor for `RESULT: DONE|BLOCKED`.
181
+
182
+ **Review routing:** Tier 3 (shared-core) — full `reviewer` lens set (`envelope`, `regression`,
183
+ `duplication`, `tests`, codex/gpt-5.6-luna, one concurrent batch, diff inline) PLUS `ui_reviewer`
184
+ (frontend-adjacent: a rendered component's i18n text). `duplication` should specifically check
185
+ whether any OTHER app already patched around this same MUI default locally (a local workaround that
186
+ this shared-core fix should make redundant, worth naming even if out of this WO's scope to remove).
187
+
188
+ **Tests:** the Orchestrator re-runs `tests/userScreenTranslations.test.jsx` (and any new/renamed
189
+ key-parity test file) as the gate — not ucm's full suite (Tier 3 but a small, local-only change;
190
+ no cross-app ripple to justify a full run per `AGENTS.md` → Test scope).
191
+
192
+ **Release:** patch bump (3.11.0 → 3.11.1) — this extends `UCM-I18N-4`'s existing i18n-gap category
193
+ in the same component, not a new capability area, per the project convention (version bump reflects
194
+ scope, not mere newness). Update `package.json` + `CHANGELOG.md`, then the repo's normal publish
195
+ path (check `.github/workflows/` or `package.json` scripts for how a previous release like
196
+ `UCM-THEME-14`/3.11.0 or `UCM-AUTH-11`/3.9.1 actually published, don't assume `npm publish` by
197
+ hand — follow the established mechanism).
198
+
199
+ **jg-ferien pin bump:** after the release is live, bump `ui-core-micha`'s pin in
200
+ `jg-ferien/frontend/package.json`, install, run jg-ferien's own affected tests (anything touching
201
+ `UserListComponent` consumption, if jg-ferien renders it at all — check first; if jg-ferien doesn't
202
+ use `UserListComponent`, the pin bump itself plus jg-ferien's existing suite staying green is the
203
+ evidence), commit + push to jg-ferien's `develop`.
204
+
205
+ **Register:** `done` only once BOTH halves land — the release AND the jg-ferien pin bump (the WO's
206
+ own Tier line: "Done means released AND jg-ferien's pin bumped"). Row here (ui-core-micha's
207
+ `WORK_ORDERS.md`) AND a row in jg-ferien's own `WORK_ORDERS.md` noting the pin bump, per the
208
+ Envelope's own closing instruction.
209
+
210
+ **Commit:** ui-core-micha lands on `main` (no `develop` branch here, confirmed in `AGENTS.md`'s
211
+ branch table). jg-ferien's pin bump lands on `develop` as usual.
@@ -14,9 +14,38 @@ both of its themes through the factory.
14
14
 
15
15
  ## Value source
16
16
 
17
- **`docs/DARK-TOKENS.md`, frozen by the operator in `UCM-THEME-13`.** Every dark value in code comes
18
- from that sheet. A value the implementation needs that the sheet does not carry is a stop-and-report.
19
- Do not improvise it.
17
+ **`docs/DARK-TOKENS.md`, frozen by the operator in `UCM-THEME-13` (2026-10-02, `7330f91`).** Every dark
18
+ value in code comes from that sheet. A value the implementation needs that the sheet does not carry is a
19
+ stop-and-report. Do not improvise it.
20
+
21
+ ## Decided rules (operator, 2026-10-01 and 2026-10-02; amended into this order 2026-10-02)
22
+
23
+ 1. **Complete baseline.** Every mode-dependent token class has its dark value from the sheet, including
24
+ `ink.*`, `text.*`, `background.default/paper/subtle`, `divider`, `controlBorder.*`, all five status keys
25
+ (`main/light/dark/contrastText` via `withMainShades`, plus `text/fill/fillText/bg`), `dataSeries` and
26
+ `shadow.*`.
27
+ 2. **Outlined first, as in light.** Resting surfaces keep `shadow.rest: none`. **Overlays get their own,
28
+ lighter surface in dark**: the sheet's overlay surface (`#232A31`) is the paper of `MuiDialog`,
29
+ `MuiMenu`, `MuiPopover` and `MuiDrawer` in dark, with the sheet's overlay shadow; the modal backdrop
30
+ (`MuiBackdrop`) uses the sheet's scrim. Light has no such surface and does not change.
31
+ 3. **Primary in dark: derived only when it fails.** An app always passes `palette.primary` (the factory
32
+ requires it). In dark, that value is kept if it clears 4.5:1 on the dark page, and otherwise lightened in
33
+ 0.05 steps until it does. Its `contrastText` is whichever of `#FFFFFF` and the dark page colour
34
+ contrasts more. This is how "derived unless the app sets its own" is expressed in an API where every
35
+ app sets one: an app that wants a particular dark primary passes one that already clears the floor
36
+ (webshop-guenter `#D49040`, 7.35:1, stays). Worked examples are in the sheet.
37
+ 4. **Status safety net, the dark counterpart of `UCM-THEME-15`.** On a dark page other than the baseline
38
+ page, a **baseline-supplied** status `main` (and `controlBorder.error`) that would fail against the page or
39
+ its own `bg` is lightened until it passes. App-supplied values are never altered (`UCM-THEME-15` rule 3,
40
+ read per key off `appConfig.palette`). Never throws; capped like the darkening.
41
+ 5. **Data series follow a rule, not only a list.** In dark, each light series colour is lightened until it
42
+ clears 3:1 on the theme's own `background.paper`. On the baseline paper that yields exactly the sheet's
43
+ list; on an app's own paper (webshop-guenter `#171209`) it adapts.
44
+ 6. **Contrast surfaces are the theme's own.** In dark, every derivation and `contrastFindings` judge against
45
+ the theme's page and paper, never a fixed `#FFFFFF`. Light keeps today's pair.
46
+ 7. **Autofill needs no new code path.** The palette-aware block (`src/theme/createAppTheme.js:97-108`)
47
+ already resolves from `background.paper` and `ink.primary` and wins over the static light block in
48
+ `tokens.js`. It is correct in dark once the dark palette is in place; confirm it in a test.
20
49
 
21
50
  ## Context the operator established
22
51
 
@@ -32,7 +61,10 @@ Do not improvise it.
32
61
  - `BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS` includes `palette.background.paper` with the reason "The
33
62
  canonical surface is deliberately MUI white". That reason is false for a dark theme.
34
63
  - The palette-aware slots use palette values (for example the autofill inset uses `background.paper`),
35
- so they follow the resolved palette once it is right.
64
+ so they follow the resolved palette once it is right. `tokens.js` also carries a static light `autofill`
65
+ block (`#FFFFFF`, `#212529`); it is shadowed by the palette-aware one (measured 2026-10-02).
66
+ - `UCM-THEME-15` (3.8.0) added `deriveDarkenedPageColour`/`deriveAlphaPageColour` next to
67
+ `deriveFocusColour`; the dark branch extends those, it does not add a parallel set.
36
68
  - The kit has components registered against the baseline (`src/theme/kitSxRegistry.js`, `THEME-4`/
37
69
  `THEME-5`). A kit component that hard-codes a light value would show that value only in dark mode.
38
70
 
@@ -42,7 +74,9 @@ In scope:
42
74
  1. `tokens.js`: a dark baseline palette with the sheet's values, and whatever exemption entries a
43
75
  dark theme needs, each with a true reason.
44
76
  2. `createAppTheme`: select the baseline palette by `palette.mode`. Make the focus derivation work in
45
- both directions against the mode's surfaces.
77
+ both directions against the mode's surfaces. Rules 2 to 6 above: the overlay surface, scrim and overlay
78
+ shadow on the four overlay components in dark; the primary derivation; the status safety net; the
79
+ series rule.
46
80
  3. `themeCompleteness.js`: contrast checks against the theme's own surfaces, not a fixed white. Mode-
47
81
  specific exemptions.
48
82
  4. Kit components that resolve a hard-coded light value instead of a token: **list** every one.
@@ -76,6 +110,11 @@ Non-goals:
76
110
  derived by darkening, both fail on dark.
77
111
  - **The `background.paper` exemption reason is currently mode-blind.** Leaving it would record a false
78
112
  statement as the reason in every dark theme.
113
+ - **Rule 3 cannot keep a dark primary that fails the floor.** An app that deliberately wants one gets it
114
+ lightened. That is intended (an accessibility floor), not a defect.
115
+ - **Two sheet values sit close to their threshold** (`controlBorder.main` 3.14:1 on paper, series slot 1
116
+ 3.07:1). Build them from the rules, not as literals, so a later paper change re-derives instead of
117
+ silently failing.
79
118
 
80
119
  ## Required tests to WRITE (you write them and run YOUR OWN new ones; the Orchestrator's run is the gate)
81
120
 
@@ -91,6 +130,18 @@ Kit test suite, narrow, next to the existing theme tests:
91
130
  3. **Focus contrast.** `controlBorder.focus` clears 3:1 against both page surfaces in each mode.
92
131
  4. **Status family on dark.** Each status key resolves `main/light/dark/contrastText` from the dark
93
132
  baseline, not MUI's defaults.
133
+ 5. **Primary in dark (rule 3).** On the baseline dark page: `#468AB2` stays, `#2F4F96` resolves to
134
+ `#6D84B6`, `#432CA1` to `#8576C2`, each with `#14181B` as `contrastText`; `#D49040` stays.
135
+ 6. **Status net (rule 4).** On webshop-guenter's page `#0E0B08` no baseline status colour moves; on a
136
+ page chosen so that one fails, that one is lightened and passes; an app-supplied status `main` that
137
+ fails stays exactly as supplied.
138
+ 7. **Overlay surface (rule 2).** In dark, the paper of `MuiDialog`, `MuiMenu`, `MuiPopover` and `MuiDrawer`
139
+ resolves to the sheet's overlay surface and `MuiBackdrop` to its scrim; the light theme's values for
140
+ the same slots are unchanged (covered by test 1).
141
+ 8. **Series rule (rule 5).** On the baseline paper the dark series equal the sheet's list; on
142
+ `#171209` every slot clears 3:1.
143
+ 9. **Autofill (rule 7).** In dark, the resolved autofill inset is the dark paper and the text is
144
+ `ink.primary`.
94
145
 
95
146
  Run, do not write: the kit's existing theme and `kitSxRegistry` tests.
96
147
 
@@ -103,9 +154,128 @@ branch.
103
154
 
104
155
  # B. Implementation map, filled by the Orchestrator and ADDRESSED TO THE IMPLEMENTER
105
156
 
106
- *Placeholder. The Orchestrator fills the context package, the absolute working directory, the
107
- progress contract and the preamble block on `git pull`, per `AGENTS.md` -> "Work Order". Do not
108
- dispatch while this placeholder stands, and not before `UCM-THEME-13` is frozen.*
157
+ Work from this package; do not explore broadly from scratch; open only the named files to verify. If
158
+ you must dig deeper, delegate to a read-only Explore sub-agent.
159
+
160
+ ## Target working directory (absolute)
161
+
162
+ `C:\Users\biglmi\Documents\webapps\ui-core-micha` (branch `main`). Never the workspace root.
163
+
164
+ ## Context package
165
+
166
+ Value source for every dark value: `docs/DARK-TOKENS.md` (read it fully first). Do not invent a value;
167
+ one the sheet lacks is `RESULT: BLOCKED <value>`.
168
+
169
+ **`src/theme/tokens.js`**
170
+ - `BASELINE_PALETTE` (l.~52-123) is the light baseline. Add `BASELINE_PALETTE_DARK` next to it with the
171
+ same shape, every key from the sheet: `ink`, `text`, `background`, `divider`, `controlBorder`
172
+ (`main`/`hover`/`error`), the five status keys (use `withMainShades(main, '#14181B')` for
173
+ success/warning/error/info, plus `text`/`fill`/`fillText`/`bg`; `stale` has no `main`, as in light),
174
+ `dataSeries.categorical`. Do NOT hardcode series slots 1 and 5, `controlBorder.main/hover`, or the
175
+ primary as literals: those are rule-derived (see below); the sheet's numbers are the expected OUTPUT.
176
+ The dark `dataSeries` base is the light `SERIES_COLOURS`, lightened by the factory.
177
+ - Export a dark overlay surface (`#232A31`), a dark overlay shadow (`0 8px 28px rgba(0,0,0,.45)`) and the
178
+ scrim (`rgba(0,0,0,.55)`) as named constants.
179
+ - `BASELINE_STATIC.shadow` (~l.200) carries `rest`/`overlay`; the dark theme needs the dark overlay value
180
+ there. `BASELINE_STATIC.components` has static `MuiDialog.paper`/`MuiDrawer.paper`/`MuiMenu.paper`
181
+ boxShadow `OVERLAY_SHADOW` (~l.340-355): in dark these are overridden, never edited for light.
182
+ - The static light `autofill` block (~l.147) is shadowed by the palette-aware one; leave it, confirm by test.
183
+ - `BASELINE_INTENTIONAL_DEFAULT_EXEMPTIONS` (end of file): the `palette.background.paper` entry says "MUI
184
+ white". Provide the list by mode: in dark, drop that entry (the dark paper differs from MUI's default, so
185
+ no exemption is needed), keep the others. The light list stays byte-identical.
186
+
187
+ **`src/theme/createAppTheme.js`**
188
+ - `createAppTheme` (l.~176): the three-layer `createTheme(app, BASELINE_PALETTE, app)` resolution. Read
189
+ `appConfig.palette.mode`; `'dark'` selects `BASELINE_PALETTE_DARK` and passes `mode: 'dark'` through to the
190
+ theme; anything else is the unchanged light path. Do not read `prefers-color-scheme`.
191
+ - `contrastSurfaces = ['#FFFFFF', background.default]` (l.~186): in dark this must be the theme's own
192
+ `[background.default, background.paper]`; light stays exactly `['#FFFFFF', default]`.
193
+ - `deriveFocusColour`/`clearsContrast` (l.~48-60) only darken and use MUI `getContrastRatio`. In dark add a
194
+ lightening counterpart (lighten in 0.05 steps, same 0.9 cap) alongside, not a rewrite. Same for
195
+ `deriveDarkenedPageColour`: add a lightened sibling next to it. For dark `controlBorder.main/hover`:
196
+ `rgba(230, 235, 239, a)` from `ink.primary`, `a` = the smallest alpha (0.01 steps) that clears 3:1 on
197
+ page and paper, hover = main + 0.15; the sheet's 0.38 / 0.53 are the expected result.
198
+ - Rule 3 (primary), rule 4 (status net: baseline-supplied status `main` and `controlBorder.error`, judged
199
+ against page AND its own `bg`, lightened; per-key check off `appConfig.palette` exactly as the existing
200
+ light loops do), rule 5 (series: each baseline light series colour lightened in 0.05 steps until it clears
201
+ 3:1 on the theme's own `background.paper`; app-supplied series untouched, the final merge argument already
202
+ lets them win), rule 6 (own surfaces) are all computed here, dark branch only. Primary `contrastText` =
203
+ whichever of `#FFFFFF` / `background.default` contrasts more. The app may pass `primary` as `{ main }`.
204
+ - `createPaletteAwareComponents(palette)` (l.~84): add dark-only overlay slots: `MuiDialog`, `MuiMenu`,
205
+ `MuiPopover`, `MuiDrawer` `paper` -> background colour = overlay surface `#232A31`, `boxShadow` = dark
206
+ overlay shadow; `MuiBackdrop.root` -> scrim. Keep the overlay surface a local constant unless a palette
207
+ key is clearly cleaner and trips no completeness check. Emitted only when mode is dark, so the light
208
+ component tree is untouched.
209
+ - Preserve the final merge order (BASELINE_STATIC, palette-aware components, `appConfig`, the dataSeries
210
+ re-merge). The dark theme's `shadow.overlay` = the dark value.
211
+
212
+ **`src/theme/themeCompleteness.js`**
213
+ - `contrastFindings` (l.~268-345): `backgrounds = { white: '#FFFFFF', page: default }` (~l.298). In dark use
214
+ the theme's own page and paper instead of a fixed white. Light keeps the exact same keys
215
+ (`...-on-white`, `...-on-page`) and values; existing tests assert those surface names. For dark name them
216
+ `...-on-paper` / `...-on-page`.
217
+ - `assertThemeComplete` (~l.620): `MUI_DEFAULT_THEME` is the light MUI default. Verify a dark theme neither
218
+ produces a false "still MUI default" finding nor a false pass; fix only what is wrong.
219
+
220
+ **Kit components with hard-coded light values:** `src/components/QrSignupManager.jsx` has an inline CSS
221
+ block (l.~225-274: `#f5f7fb`, `#122033`, `#d9e2f2`, `#ffffff`, `#e8f0ff`, `#23408e`, `#f8faff`) and
222
+ `bgcolor: '#ffffff'` at l.361. **The l.361 white is a QR quiet zone and stays.** List every hard-coded
223
+ light colour under `src/` outside `src/theme/` and tests in your final report. Switching one to an existing
224
+ palette token is in scope (check its consumers and `tests/QrSignupManager.registrationContext.test.jsx`
225
+ first); a spot that would need a new token is reported, not built. `src/auth/UserMenu.jsx:44` and
226
+ `src/components/charts/chartLabels.js` only mention colours in comments.
227
+
228
+ **Docs / release:** `DESIGN.md` gets a concise dark-mode section (how to opt in, primary rule, status net,
229
+ overlay surface, series rule, what an app owns in dark). `CHANGELOG.md` entry. `package.json` version
230
+ `3.10.0` -> `3.11.0` (and `package-lock.json` where the version appears for this package).
231
+
232
+ **Existing tests to follow** (style, imports): `tests/createAppTheme.test.js`,
233
+ `tests/createAppThemePageContrast.test.js` (imports `assertThemeComplete`, `createAppTheme` from
234
+ `../src/theme`), `tests/themeCompleteness.test.js`. New dark tests go in `tests/createAppThemeDark.test.js`,
235
+ the light guard in `tests/createAppThemeLightGuard.test.js`.
236
+
237
+ **Light regression guard (required test 1):** BEFORE editing any source, capture the output of
238
+ `createAppTheme({ palette: { primary: { main: '#0F62FE' } } })` and of one overriding app config (fontFamily,
239
+ a custom page background, an app-supplied status main) as a JSON fixture
240
+ (`tests/fixtures/light-theme-baseline.json`, stable serialization, functions as strings), from the
241
+ unmodified code, and assert equality afterwards. Prove it can fail: one test mutates a light value in a
242
+ clone of the snapshot and asserts the comparison reports a difference.
243
+
244
+ **Invariants / pitfalls**
245
+ - Light output byte-identical: no key-order change that alters serialization, no new keys on the light theme.
246
+ - Only the first `createTheme` argument is augmented (comment at the top of `tokens.js`): every status
247
+ entry needs explicit `main/light/dark/contrastText`.
248
+ - MUI `getContrastRatio` vs the kit's alpha-aware `calculateContrastRatio`: use the kit's for anything with
249
+ alpha, as THEME-15 did.
250
+ - Build `controlBorder.main/hover`, the series and the primary from the rules, not literals; the tests
251
+ assert the rules reproduce the sheet's values.
252
+ - Do not touch auth, CI, dependencies, `WORK_ORDERS.md`, or `docs/DARK-TOKENS.md` (read-only here).
253
+
254
+ ## Required tests, restated
255
+
256
+ The nine tests of Part A, in the new files named above. Run only the tests you wrote.
257
+
258
+ ## Preamble
259
+
260
+ The text above is the COMPLETE spec: the committed WO file's content, not a plan to refine; there is no
261
+ separate plan file. Read the nearest `AGENTS.md`, the relevant `.codex/skills/<role>/SKILL.md`, and the app
262
+ `MEMORY.md` ONLY for conventions. Stay in scope; do not touch auth/permissions/deps/schema/CI unless the
263
+ spec says so; do not update `MEMORY.md`. **Do NOT edit `WORK_ORDERS.md`: the register row and the review
264
+ verdicts are the orchestrator's alone.** **Your tools are for editing source and test files and for running
265
+ the tests you wrote, nothing else.** Do NOT install dependencies, touch a lockfile (the version line in
266
+ `package-lock.json` is the one exception, a plain text edit), run a package manager, or tidy up stray
267
+ files; if something in the repo state blocks you, stop and report it as `RESULT: BLOCKED <reason>` instead
268
+ of fixing it. Do NOT `git add`/`commit`/`push`: leave every change uncommitted in the working tree for the
269
+ orchestrator's independent review. WRITE the tests the `Required tests` section calls for AND **RUN the
270
+ tests you just wrote** to confirm they execute and pass: that is the ONLY test run you do (NOT the
271
+ affected/full suite, NOT any review). Run them with `npx vitest run <your test files>`. The orchestrator
272
+ re-runs the authoritative set and does the independent review after you finish; those are the gate.
273
+
274
+ Narrate continuously: a `PLAN: <step1> | <step2> | ...` line up front, then a single-line
275
+ `PROGRESS: [<n>/<total>] <present-tense action>` before every relevant action (and `... done` on
276
+ completion), spaced so no gap exceeds ~2 min, stdout unbuffered, plus exactly one final
277
+ `RESULT: DONE|BLOCKED <reason>`. Your final report must also list every hard-coded light colour found under
278
+ `src/` outside the theme folder.
109
279
 
110
280
  ---
111
281