@celestia-island/hikari 0.55.459 → 0.55.461

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/types/components/HkLoginFlow.d.ts +42 -6
  2. package/dist/types/components/HkMarkdownEditor.d.ts +123 -0
  3. package/dist/types/components/HkSignInCard.d.ts +31 -2
  4. package/dist/types/index.d.ts +2 -0
  5. package/dist/types/mermaid/wasmEngine.d.ts +1 -1
  6. package/package.json +1 -1
  7. package/src/components/HkLoginFlow.test.tsx +225 -14
  8. package/src/components/HkLoginFlow.tsx +149 -97
  9. package/src/components/HkMarkdownEditor.barrel.test.ts +42 -0
  10. package/src/components/HkMarkdownEditor.scss +190 -0
  11. package/src/components/HkMarkdownEditor.test.tsx +404 -0
  12. package/src/components/HkMarkdownEditor.tsx +357 -0
  13. package/src/components/HkSignInCard.test.ts +43 -0
  14. package/src/components/HkSignInCard.tsx +96 -54
  15. package/src/i18n/locales/ar/components.json +14 -1
  16. package/src/i18n/locales/de/components.json +14 -1
  17. package/src/i18n/locales/en/components.json +14 -1
  18. package/src/i18n/locales/es/components.json +14 -1
  19. package/src/i18n/locales/fr/components.json +14 -1
  20. package/src/i18n/locales/ja/components.json +14 -1
  21. package/src/i18n/locales/ko/components.json +14 -1
  22. package/src/i18n/locales/pt/components.json +14 -1
  23. package/src/i18n/locales/ru/components.json +14 -1
  24. package/src/i18n/locales/zh-Hans/components.json +14 -1
  25. package/src/i18n/locales/zh-Hant/components.json +14 -1
  26. package/src/index.ts +2 -0
  27. package/src/mermaid/wasmEngine.ts +1 -1
  28. package/src/scene3d/wasmFleetSpec.ts +1 -1
  29. package/src/styles/admin-tokens.scss +15 -0
  30. package/src/utils/qr/qrEncoder.ts +6 -1
  31. package/src/wasm/highlight/hikari_wasm_highlight.d.ts +3 -2
  32. package/src/wasm/highlight/hikari_wasm_highlight.js +486 -160
  33. package/src/wasm/highlight/interfaces/celestia-hikari-highlight-types.d.ts +4 -0
  34. package/src/wasm/highlight/interfaces/wasi-cli-exit.d.ts +1 -0
  35. package/src/wasm/highlight/interfaces/wasi-clocks-monotonic-clock.d.ts +2 -0
  36. package/src/wasm/highlight/interfaces/wasi-clocks-wall-clock.d.ts +6 -0
  37. package/src/wasm/mermaid/hikari_wasm_mermaid.d.ts +3 -2
  38. package/src/wasm/mermaid/hikari_wasm_mermaid.js +487 -161
  39. package/src/wasm/mermaid/interfaces/celestia-hikari-mermaid-types.d.ts +4 -0
  40. package/src/wasm/mermaid/interfaces/wasi-cli-exit.d.ts +1 -0
  41. package/src/wasm/mermaid/interfaces/wasi-clocks-monotonic-clock.d.ts +2 -0
  42. package/src/wasm/mermaid/interfaces/wasi-clocks-wall-clock.d.ts +6 -0
  43. package/src/wasm/qr/hikari_wasm_qr.d.ts +4 -3
  44. package/src/wasm/qr/hikari_wasm_qr.js +475 -155
  45. package/src/wasm/qr/interfaces/{hikari-qr-types.d.ts → celestia-hikari-qr-types.d.ts} +1 -2
  46. package/src/wasm/qr/interfaces/wasi-cli-exit.d.ts +1 -0
  47. package/src/wasm/qr/interfaces/wasi-clocks-monotonic-clock.d.ts +2 -0
  48. package/src/wasm/qr/interfaces/wasi-clocks-wall-clock.d.ts +6 -0
  49. package/src/wasm/scene3d/hikari_wasm_scene3d.d.ts +4 -3
  50. package/src/wasm/scene3d/hikari_wasm_scene3d.js +482 -161
  51. package/src/wasm/scene3d/interfaces/{hikari-scene3d-types.d.ts → celestia-hikari-scene3d-types.d.ts} +1 -1
  52. package/src/wasm/scene3d/interfaces/wasi-cli-exit.d.ts +1 -0
  53. package/src/wasm/scene3d/interfaces/wasi-clocks-monotonic-clock.d.ts +2 -0
  54. package/src/wasm/scene3d/interfaces/wasi-clocks-wall-clock.d.ts +6 -0
  55. package/src/wasm/highlight/interfaces/hikari-highlight-types.d.ts +0 -4
  56. package/src/wasm/mermaid/interfaces/hikari-mermaid-types.d.ts +0 -4
@@ -69,10 +69,12 @@ export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
69
69
  * This is the business-level composition above the auth kit (extracted
70
70
  * from shittim-chest's LoginView, 2026-11 user direction: the login
71
71
  * screen had drifted into per-app reimplementations). It owns EVERYTHING
72
- * visual — the pill segment group (hidden when a deployment offers a
73
- * single channel; a lone dead segment reads as a broken switch), the
74
- * height-morphing channel swap, the direction-aware account→verify
75
- * slide, the methods rows, the MFA card — while staying a CONTROLLED
72
+ * visual — ONE stable shell card (logo, header, the pill segment group
73
+ * hidden when a deployment offers a single channel; a lone dead segment
74
+ * reads as a broken switch) whose body below the tabs crossfades and
75
+ * height-morphs per channel through `HkTransitionContainer`, with the
76
+ * account→verify step as the same fade+height morph between the shell
77
+ * and the MFA card — while staying a CONTROLLED
76
78
  * component: no endpoint, no URL building, no factor ladder policy.
77
79
  * Each host (the chest migration plus the erp and arona login surfaces,
78
80
  * landing as their own PRs) keeps its own auth client and drives the
@@ -138,11 +140,27 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
138
140
  type: BooleanConstructor;
139
141
  default: boolean;
140
142
  };
141
- /** Logo image URL forwarded to the active card's header. */
143
+ /** Logo image URL forwarded to the shell card's header. */
142
144
  logoSrc: {
143
145
  type: StringConstructor;
144
146
  default: undefined;
145
147
  };
148
+ /** The SHELL card's header title — one stable header across every
149
+ * channel (2026-11-24 user direction: a channel switch must morph
150
+ * only the content below the tabs, never dissolve the card). Falls
151
+ * back to the ACTIVE channel's `title` (then the conventional
152
+ * sign-in copy) for hosts that still brand per channel; distinct
153
+ * per-channel fallbacks then swap as instant text, so multi-channel
154
+ * hosts should pass this once. */
155
+ title: {
156
+ type: StringConstructor;
157
+ default: undefined;
158
+ };
159
+ /** The SHELL card's subtitle — same stability contract as `title`. */
160
+ subtitle: {
161
+ type: StringConstructor;
162
+ default: undefined;
163
+ };
146
164
  /** Seed for the credentials card's username field — survives the
147
165
  * verify round-trip (see HkSignInCard.initialUsername). */
148
166
  initialUsername: {
@@ -204,11 +222,27 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
204
222
  type: BooleanConstructor;
205
223
  default: boolean;
206
224
  };
207
- /** Logo image URL forwarded to the active card's header. */
225
+ /** Logo image URL forwarded to the shell card's header. */
208
226
  logoSrc: {
209
227
  type: StringConstructor;
210
228
  default: undefined;
211
229
  };
230
+ /** The SHELL card's header title — one stable header across every
231
+ * channel (2026-11-24 user direction: a channel switch must morph
232
+ * only the content below the tabs, never dissolve the card). Falls
233
+ * back to the ACTIVE channel's `title` (then the conventional
234
+ * sign-in copy) for hosts that still brand per channel; distinct
235
+ * per-channel fallbacks then swap as instant text, so multi-channel
236
+ * hosts should pass this once. */
237
+ title: {
238
+ type: StringConstructor;
239
+ default: undefined;
240
+ };
241
+ /** The SHELL card's subtitle — same stability contract as `title`. */
242
+ subtitle: {
243
+ type: StringConstructor;
244
+ default: undefined;
245
+ };
212
246
  /** Seed for the credentials card's username field — survives the
213
247
  * verify round-trip (see HkSignInCard.initialUsername). */
214
248
  initialUsername: {
@@ -249,7 +283,9 @@ export declare const HkLoginFlow: import("vue").DefineComponent<import("vue").Ex
249
283
  "onVerify-back"?: (() => any) | undefined;
250
284
  }>, {
251
285
  step: "verify" | "account";
286
+ title: string;
252
287
  loading: boolean;
288
+ subtitle: string;
253
289
  logoSrc: string;
254
290
  initialUsername: string;
255
291
  passkeyRetryHint: string;
@@ -0,0 +1,123 @@
1
+ import "./HkMarkdownEditor.scss";
2
+ /** Editing dialect of the editor body. `markdown` runs the toolbar and the
3
+ * rendered live preview; `plain` reduces the surface to a textarea (the
4
+ * split preview degrades to pre-wrapped plain text). */
5
+ export type HkMarkdownEditorMode = "markdown" | "plain";
6
+ /** The result of one pure text transform: the rewritten source plus the
7
+ * selection the editor should restore afterwards. Selections are plain
8
+ * string indices into `text` — the same coordinates a textarea's
9
+ * selectionStart/selectionEnd speak. */
10
+ export interface MarkdownTextEdit {
11
+ text: string;
12
+ selectionStart: number;
13
+ selectionEnd: number;
14
+ }
15
+ /**
16
+ * Wrap the current selection with markers (pure). `before`/`after` default
17
+ * to the same string (`**`, `*`, `` ` ``, `~~` …). The returned selection is
18
+ * restored INSIDE the wrap: a non-empty selection stays selected around its
19
+ * wrapped text, an empty one parks the caret between the markers so the
20
+ * next keystroke lands inside the emphasis.
21
+ */
22
+ export declare function applyWrap(source: string, selectionStart: number, selectionEnd: number, before: string, after?: string): MarkdownTextEdit;
23
+ /**
24
+ * Prefix every line covered by the selection (pure). The operated range is
25
+ * the full line range containing the selection — a caret mid-line still
26
+ * prefixes that whole line, and a selection spanning lines prefixes each
27
+ * one. `prefix` is either a literal (`- `, `> `, `## `) or a per-line
28
+ * factory receiving the zero-based line index (ordered lists emit
29
+ * `1. `, `2. `, …). The returned selection covers the rewritten lines.
30
+ */
31
+ export declare function applyLinePrefix(source: string, selectionStart: number, selectionEnd: number, prefix: string | ((lineIndex: number) => string)): MarkdownTextEdit;
32
+ /**
33
+ * HkMarkdownEditor — the family's standard two-pane markdown/plain-text
34
+ * editor. Left: the textarea (every toolbar action a pure string transform
35
+ * over the current selection, refocused with a restored selection after
36
+ * each action). Right: the live preview through HkMarkdownRenderer,
37
+ * shown in split view — markdown mode renders, plain mode degrades to
38
+ * pre-wrapped plain text. Image drops/pastes are REPORTED (one
39
+ * `imageDrop` event per file) and never embedded or uploaded: the host
40
+ * owns the upload and inserts its own markdown marker.
41
+ */
42
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
43
+ modelValue: {
44
+ type: StringConstructor;
45
+ default: string;
46
+ };
47
+ mode: {
48
+ type: () => HkMarkdownEditorMode;
49
+ default: string;
50
+ };
51
+ view: {
52
+ type: () => "split" | "edit";
53
+ default: string;
54
+ };
55
+ placeholder: {
56
+ type: StringConstructor;
57
+ default: string;
58
+ };
59
+ disabled: {
60
+ type: BooleanConstructor;
61
+ default: boolean;
62
+ };
63
+ /** Toolbar actions row (markdown mode only — plain mode has no
64
+ * markdown to insert). The mode segmented control always renders. */
65
+ toolbar: {
66
+ type: BooleanConstructor;
67
+ default: boolean;
68
+ };
69
+ /** Report drag-dropped and pasted images through `imageDrop`. */
70
+ imageDrop: {
71
+ type: BooleanConstructor;
72
+ default: boolean;
73
+ };
74
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
75
+ "update:modelValue": (_value: string) => true;
76
+ "update:mode": (_mode: HkMarkdownEditorMode) => true;
77
+ imageDrop: (_file: File) => true;
78
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
79
+ modelValue: {
80
+ type: StringConstructor;
81
+ default: string;
82
+ };
83
+ mode: {
84
+ type: () => HkMarkdownEditorMode;
85
+ default: string;
86
+ };
87
+ view: {
88
+ type: () => "split" | "edit";
89
+ default: string;
90
+ };
91
+ placeholder: {
92
+ type: StringConstructor;
93
+ default: string;
94
+ };
95
+ disabled: {
96
+ type: BooleanConstructor;
97
+ default: boolean;
98
+ };
99
+ /** Toolbar actions row (markdown mode only — plain mode has no
100
+ * markdown to insert). The mode segmented control always renders. */
101
+ toolbar: {
102
+ type: BooleanConstructor;
103
+ default: boolean;
104
+ };
105
+ /** Report drag-dropped and pasted images through `imageDrop`. */
106
+ imageDrop: {
107
+ type: BooleanConstructor;
108
+ default: boolean;
109
+ };
110
+ }>> & Readonly<{
111
+ "onUpdate:modelValue"?: ((_value: string) => any) | undefined;
112
+ onImageDrop?: ((_file: File) => any) | undefined;
113
+ "onUpdate:mode"?: ((_mode: HkMarkdownEditorMode) => any) | undefined;
114
+ }>, {
115
+ view: "split" | "edit";
116
+ mode: HkMarkdownEditorMode;
117
+ toolbar: boolean;
118
+ disabled: boolean;
119
+ modelValue: string;
120
+ placeholder: string;
121
+ imageDrop: boolean;
122
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
123
+ export default _default;
@@ -32,6 +32,13 @@
32
32
  * between the form and the footer (typically `HkAuthMethodList`), so
33
33
  * alternative sign-in buttons line up with the inputs while the footer
34
34
  * rows keep their centered-group layout.
35
+ * - `bare: true` — render ONLY the credential fragment (the `<form>` plus
36
+ * the methods/footer blocks, same wrapper classes) with NO HkAuthCard
37
+ * shell: for hosts that own a stable card shell and swap this body
38
+ * inside it (HkLoginFlow's channel switch — 2026-11-24 user direction:
39
+ * the shell, its header and the channel tabs must NOT dissolve when
40
+ * only the content below the tabs changes). The `top` slot is a shell
41
+ * concern and deliberately does not exist in bare mode.
35
42
  *
36
43
  * ```tsx
37
44
  * <HSignInCard
@@ -44,9 +51,11 @@
44
51
  * ```
45
52
  */
46
53
  export declare const HkSignInCard: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
54
+ /** Card title (shell mode). Unused in `bare` mode — the host owns
55
+ * the shell — but kept in the prop shape for the standalone card. */
47
56
  title: {
48
57
  type: StringConstructor;
49
- required: true;
58
+ default: string;
50
59
  };
51
60
  subtitle: {
52
61
  type: StringConstructor;
@@ -108,14 +117,24 @@ export declare const HkSignInCard: import("vue").DefineComponent<import("vue").E
108
117
  type: StringConstructor;
109
118
  default: string;
110
119
  };
120
+ /** Render ONLY the credential fragment — no HkAuthCard shell, no
121
+ * `top` slot. For hosts that own a stable shell and transition this
122
+ * body inside it (HkLoginFlow's channel swap). Default keeps the
123
+ * full standalone card. */
124
+ bare: {
125
+ type: BooleanConstructor;
126
+ default: boolean;
127
+ };
111
128
  }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
112
129
  /** Fired on explicit click or Enter; never with an empty username (or
113
130
  * an empty password while `passwordField` is on) or while busy. */
114
131
  submit: (_username: string, _password: string) => true;
115
132
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
133
+ /** Card title (shell mode). Unused in `bare` mode — the host owns
134
+ * the shell — but kept in the prop shape for the standalone card. */
116
135
  title: {
117
136
  type: StringConstructor;
118
- required: true;
137
+ default: string;
119
138
  };
120
139
  subtitle: {
121
140
  type: StringConstructor;
@@ -177,9 +196,18 @@ export declare const HkSignInCard: import("vue").DefineComponent<import("vue").E
177
196
  type: StringConstructor;
178
197
  default: string;
179
198
  };
199
+ /** Render ONLY the credential fragment — no HkAuthCard shell, no
200
+ * `top` slot. For hosts that own a stable shell and transition this
201
+ * body inside it (HkLoginFlow's channel swap). Default keeps the
202
+ * full standalone card. */
203
+ bare: {
204
+ type: BooleanConstructor;
205
+ default: boolean;
206
+ };
180
207
  }>> & Readonly<{
181
208
  onSubmit?: ((_username: string, _password: string) => any) | undefined;
182
209
  }>, {
210
+ title: string;
183
211
  loading: boolean;
184
212
  disabled: boolean;
185
213
  subtitle: string;
@@ -191,4 +219,5 @@ export declare const HkSignInCard: import("vue").DefineComponent<import("vue").E
191
219
  usernamePlaceholder: string;
192
220
  passwordField: boolean;
193
221
  initialUsername: string;
222
+ bare: boolean;
194
223
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -347,6 +347,8 @@ export { default as HkLabel } from "./components/HkLabel";
347
347
  export { default as HkListTransition } from "./components/HkListTransition";
348
348
  export { default as HkLoadMore } from "./components/HkLoadMore";
349
349
  export { default as HkMarkdownRenderer } from "./components/HkMarkdownRenderer";
350
+ export { default as HkMarkdownEditor, applyLinePrefix, applyWrap } from "./components/HkMarkdownEditor";
351
+ export type { HkMarkdownEditorMode, MarkdownTextEdit } from "./components/HkMarkdownEditor";
350
352
  export { default as HkMermaidDiagram } from "./components/HkMermaidDiagram";
351
353
  export { default as HkTerminal } from "./components/HkTerminal";
352
354
  export { default as HkModal } from "./components/HkModal";
@@ -1,6 +1,6 @@
1
1
  import { HostClientError } from "@celestia-island/tairitsu-host-client";
2
2
  import type { MermaidParserEngine } from "./engine";
3
- /** The component's `hikari:mermaid/types` `parse-result` record. */
3
+ /** The component's `celestia:hikari-mermaid/types` `parse-result` record. */
4
4
  export interface MermaidParseResult {
5
5
  /** JSON-serialized MermaidDiagram; absent when unrecognized. */
6
6
  json?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.459",
3
+ "version": "0.55.461",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -1,3 +1,7 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
1
5
  import { afterEach, describe, expect, it, vi } from "vitest";
2
6
  import { createApp, defineComponent, h, nextTick, ref } from "vue";
3
7
 
@@ -334,7 +338,7 @@ describe("HkLoginFlow — verify step", () => {
334
338
  expect(c.querySelector(".hk-tabs")).toBeNull();
335
339
  });
336
340
 
337
- it("slides account → verify → back when the host flips the step prop reactively", async () => {
341
+ it("morphs account → verify → back when the host flips the step prop reactively", async () => {
338
342
  // The host mirrors every real consumer: reactive state read INSIDE
339
343
  // the render function, so each change re-evaluates the props. (A
340
344
  // one-shot `h()` snapshot VNode never updates — re-mounting such a
@@ -364,21 +368,228 @@ describe("HkLoginFlow — verify step", () => {
364
368
 
365
369
  step.value = "account";
366
370
  for (let i = 0; i < 12; i++) await nextTick();
367
- // The account card comes back as a FRESH body: jsdom fires no
368
- // transitionend, so the leaving verify body lingers with its OTP
369
- // cells — asserting a bare username-input count would pass even if
370
- // the flip-back never happened (the leaving account input from the
371
- // entry leg also lingers). Pin the body that is NOT on its way
372
- // out: the username input inside a body without the leave class.
373
- const settledInput = c.querySelector(
374
- '.hk-stepflow-body:not(.hk-stepflow-leave-to) input[name="signin-username"]',
371
+ // The account shell comes back. Scope the assertion to the OUTER
372
+ // tier's DIRECT stage items (`.hk-login-flow > .hk-tc > …`) — the
373
+ // union of every crossfade item in the subtree is unfalsifiable
374
+ // (the inner items ride inside the settled account item, so a
375
+ // stuck-outer mutation can never turn this red; the forward leg's
376
+ // OTP-presence check carries the teeth for that mutation).
377
+ // MUT:r1487-outer-key-channel (R7 M1: keying the outer container on
378
+ // the channel makes `dataset.crossfadeKey` read "account:cloud" here
379
+ // and this assertion goes red).
380
+ const outerSettled = Array.from(
381
+ c.querySelectorAll(
382
+ ".hk-login-flow > .hk-tc > .hk-tc-stage > .hk-crossfade > .hk-crossfade-item"
383
+ + ":not(.hk-crossfade-leave-active):not(.hk-crossfade-leave-to)",
384
+ ),
385
+ );
386
+ expect(outerSettled.length).toBe(1);
387
+ expect((outerSettled[0] as HTMLElement).dataset.crossfadeKey).toBe("account");
388
+ expect(outerSettled[0]!.querySelector('input[name="signin-username"]')).not.toBeNull();
389
+ expect(outerSettled[0]!.querySelector(".hk-otp-cell")).toBeNull();
390
+ });
391
+ });
392
+
393
+ describe("HkLoginFlow — stable shell channel swap (2026-11-24 user direction)", () => { // "Switching the top segment group only crossfades the content below
394
+ // it and morphs the height — use the library's existing component, do
395
+ // not destroy the whole card." The pins below are ELEMENT-IDENTITY
396
+ // assertions: if the shell (or the tabs, or the header) remounts on a
397
+ // channel switch, the captured element nodes go stale and the test
398
+ // fails — the exact regression the direction forbids.
399
+
400
+ function mountTwoChannel(channel: "cloud" | "org") {
401
+ const active = ref<"cloud" | "org">(channel);
402
+ const Host = defineComponent({
403
+ setup: () => () =>
404
+ h(HkLoginFlow, {
405
+ channels: [cloudChannel, orgChannel],
406
+ modelValue: active.value,
407
+ title: "Sign in",
408
+ subtitle: "Console",
409
+ "onUpdate:modelValue": (key: string) => {
410
+ active.value = key as "cloud" | "org";
411
+ },
412
+ }),
413
+ });
414
+ return { container: mount(h(Host)), active };
415
+ }
416
+
417
+ it("keeps the shell, header and tabs mounted while only the body swaps", async () => {
418
+ const { container, active } = mountTwoChannel("cloud");
419
+ const tabsBefore = container.querySelector(".hk-tabs");
420
+ const titleBefore = container.querySelector(".s-auth-title");
421
+ const logoSlotBefore = container.querySelector(".s-auth-header");
422
+ expect(tabsBefore).not.toBeNull();
423
+ expect(titleBefore?.textContent).toBe("Sign in");
424
+ // Exactly ONE card — the shell. A silently-ignored `bare` mode
425
+ // (HkSignInCard wrapping its own card inside the shell) shows up
426
+ // as a second .s-auth-card / .s-auth-form here.
427
+ // MUT:r1487-bare-ignored (deleting HkSignInCard's bare return
428
+ // makes this count 2 and the nested selector non-null).
429
+ expect(container.querySelectorAll(".s-auth-card")).toHaveLength(1);
430
+ expect(container.querySelector(".s-auth-card .s-auth-card")).toBeNull();
431
+ expect(container.querySelectorAll(".s-auth-form")).toHaveLength(1);
432
+ // The shell opts OUT of HkAuthCard's own smooth-height wrapper: the
433
+ // inner container owns the height choreography, and a second
434
+ // measuring wrapper would chain its 300ms transition after the
435
+ // container's (a telescoping double-morph). smoothHeight={false}
436
+ // leaves the wrapper unmeasured — no inline height, no observer
437
+ // (a measured wrapper pins an inline height and tracks the card).
438
+ // MUT:r1487-shell-double-morph (dropping the prop installs the
439
+ // observer and writes an inline height — this goes red).
440
+ const heightWrapper = container.querySelector(
441
+ ".s-auth-card-height",
442
+ ) as HTMLElement;
443
+ expect(heightWrapper).not.toBeNull();
444
+ expect(heightWrapper.style.height).toBe("");
445
+
446
+ active.value = "org";
447
+ for (let i = 0; i < 12; i++) await nextTick();
448
+
449
+ // SAME DOM NODES — the shell never dissolved.
450
+ expect(container.querySelector(".hk-tabs")).toBe(tabsBefore);
451
+ expect(container.querySelector(".s-auth-title")).toBe(titleBefore);
452
+ expect(container.querySelector(".s-auth-header")).toBe(logoSlotBefore);
453
+ // The tabs sit ABOVE the swapped region — outside the inner
454
+ // container's own class (a tabs-inside-the-body shape would
455
+ // dissolve the switch itself; the tabs are necessarily inside the
456
+ // OUTER tier, so the inner tier's class is the discriminator).
457
+ // MUT:r1487-tabs-inside-body (moving tabsEl() into the inner
458
+ // container gives the tabs a .hk-login-flow-body ancestor — this
459
+ // fails).
460
+ expect(tabsBefore!.closest(".hk-login-flow-body")).toBeNull();
461
+ // The swapped region carries the org body (the sso row list), and
462
+ // it lives BELOW the tabs inside the shell card.
463
+ const shellCard = container.querySelector(".s-auth-card")!;
464
+ const ssoBlock = container.querySelector(".hk-login-flow-sso");
465
+ expect(ssoBlock).not.toBeNull();
466
+ expect(shellCard.contains(ssoBlock!)).toBe(true);
467
+ // The inner crossfade is keyed on the CHANNEL; the outer tier stayed
468
+ // on the account generation (the shell item's key never changed).
469
+ // MUT:r1487-inner-key-fixed (R7 M6: pinning the inner swapKey to a
470
+ // constant leaves no item carrying data-crossfade-key="org" and
471
+ // this assertion goes red).
472
+ const innerItems = container.querySelectorAll(
473
+ ".hk-tc .hk-tc .hk-crossfade-item",
375
474
  );
376
- expect(settledInput).not.toBeNull();
377
- // And the OTP cells of the returning stage live only in a leaving
378
- // body — the settled stage carries none.
475
+ expect(innerItems.length).toBeGreaterThan(0);
379
476
  expect(
380
- c.querySelectorAll('.hk-stepflow-body:not(.hk-stepflow-leave-to) .hk-otp-cell').length,
381
- ).toBe(0);
477
+ Array.from(innerItems).some(
478
+ (el) => (el as HTMLElement).dataset.crossfadeKey === "org",
479
+ ),
480
+ ).toBe(true);
481
+ });
482
+
483
+ it("swaps the credentials body back without losing the typed tab state", async () => {
484
+ const { container, active } = mountTwoChannel("org");
485
+ active.value = "cloud";
486
+ for (let i = 0; i < 12; i++) await nextTick();
487
+ // The INNER container's settled item is the cloud body (the outer
488
+ // account item contains the leaving inner org item too — scope the
489
+ // assertion to the inner tier, the only thing that swapped).
490
+ const innerSettled = Array.from(
491
+ container.querySelectorAll(
492
+ ".hk-tc .hk-tc .hk-crossfade-item:not(.hk-crossfade-leave-active):not(.hk-crossfade-leave-to)",
493
+ ),
494
+ );
495
+ expect(innerSettled.length).toBe(1);
496
+ expect((innerSettled[0] as HTMLElement).dataset.crossfadeKey).toBe("cloud");
497
+ expect(innerSettled[0]!.querySelector('input[name="signin-username"]')).not.toBeNull();
498
+ expect(innerSettled[0]!.querySelector(".hk-login-flow-sso")).toBeNull();
499
+ });
500
+
501
+ it("blurs a field focused inside the leaving body on a channel switch", async () => {
502
+ // The anti-strobe cover HkStepFlow's dropFlowFocus used to provide
503
+ // (chest round-22 field report: a focused field re-anchors the
504
+ // Android autofill panel on every layout beat). The TAB button
505
+ // keeps its focus — the blur scope is the swapped body only.
506
+ const { container, active } = mountTwoChannel("cloud");
507
+ const input = container.querySelector<HTMLInputElement>(
508
+ 'input[name="signin-username"]',
509
+ )!;
510
+ input.focus();
511
+ expect(document.activeElement).toBe(input);
512
+ active.value = "org";
513
+ await nextTick();
514
+ // MUT:r1487-focus-strobe (dropping the blur watch leaves the
515
+ // dissolved field focused — the autofill strobe regression).
516
+ expect(document.activeElement).not.toBe(input);
517
+
518
+ // The exempt half: an activated TAB TRIGGER keeps focus across the
519
+ // switch (keyboard a11y — the blur scope must not fold to the whole
520
+ // flow).
521
+ // MUT:r1487-blur-scope-fold (widening the scope to .hk-login-flow
522
+ // blurs the trigger here and this goes red).
523
+ active.value = "cloud";
524
+ await nextTick();
525
+ await new Promise((r) => setTimeout(r, 30));
526
+ const trigger = container.querySelectorAll<HTMLButtonElement>(
527
+ ".hk-tabs-trigger",
528
+ )[0]!;
529
+ trigger.focus();
530
+ expect(document.activeElement).toBe(trigger);
531
+ active.value = "org";
532
+ await nextTick();
533
+ expect(document.activeElement).toBe(trigger);
534
+ });
535
+
536
+ it("extends the :has rhythm collapse to the bare fragment's descendant blocks (styles pin)", () => {
537
+ // The stable shell's bare fragment renders the methods/footer
538
+ // blocks as DESCENDANTS of the shell's .s-auth-form — the sibling
539
+ // `:has(+ …)` rules cannot see them, so the descendant variants
540
+ // carry the same collapsed bottom padding (without them the form's
541
+ // full 24px bottom padding stacks onto the footer's top margin).
542
+ // MUT:r1487-rhythm-descendant (reverting to sibling-only rules
543
+ // makes this match empty).
544
+ const here = dirname(fileURLToPath(import.meta.url));
545
+ const scss = readFileSync(join(here, "../styles/admin-tokens.scss"), "utf-8");
546
+ const methods = scss.match(/\.s-auth-form:has\(\.s-auth-methods\)\s*,\s*\.s-auth-form:has\(\.s-auth-footer\)\s*{[^}]*}/)?.[0] ?? "";
547
+ expect(methods, "descendant :has collapse rule must exist").toBeTruthy();
548
+ expect(methods).toContain("padding-bottom: var(--space-8, 0.5rem)");
549
+ });
550
+
551
+ it("renders no footer band when the host passed no footer slot (flow-level dead-space guard)", () => {
552
+ // The flow's own footer-slot existence guard (mirroring the card's
553
+ // methods/footer rules): an unconditional lambda would make the
554
+ // bare fragment render an empty padded .s-auth-footer band under
555
+ // every channel body.
556
+ // MUT:r1487-flow-footer-dead-space (forwarding the footer lambda
557
+ // unconditionally renders the empty band here).
558
+ const c = mount(h(HkLoginFlow, {
559
+ channels: [cloudChannel],
560
+ modelValue: "cloud",
561
+ }));
562
+ expect(c.querySelector(".s-auth-footer")).toBeNull();
563
+ // The default username icon lane survives the bare fragment (the
564
+ // fallback <User> mark rides the field unless a channel overrides).
565
+ // MUT:r1487-icon-fallback-drop (dropping the else branch leaves
566
+ // the field icon-less).
567
+ expect(c.querySelector(".s-auth-card-field-icon")).not.toBeNull();
568
+ });
569
+
570
+ it("flows the per-channel fallback title through the stable shell header", async () => {
571
+ // Without a flow-level title the ACTIVE channel's title supplies
572
+ // the header copy (single-channel hosts unchanged); switching then
573
+ // updates the text in place — the header node itself stays mounted.
574
+ const active = ref<"cloud" | "org">("cloud");
575
+ const Host = defineComponent({
576
+ setup: () => () =>
577
+ h(HkLoginFlow, {
578
+ channels: [
579
+ cloudChannel,
580
+ { key: "org", mode: "sso", icon: h("svg"), title: "Organization access" },
581
+ ],
582
+ modelValue: active.value,
583
+ "onUpdate:modelValue": () => {},
584
+ }),
585
+ });
586
+ const container = mount(h(Host));
587
+ const titleEl = container.querySelector(".s-auth-title")!;
588
+ expect(titleEl.textContent).toContain("Sign in");
589
+ active.value = "org";
590
+ for (let i = 0; i < 12; i++) await nextTick();
591
+ expect(container.querySelector(".s-auth-title")).toBe(titleEl);
592
+ expect(titleEl.textContent).toContain("Organization access");
382
593
  });
383
594
  });
384
595