@celestia-island/hikari 0.55.473 → 0.55.475
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/dist/types/components/HkAuthChannelList.d.ts +8 -1
- package/dist/types/components/HkAuthHandoff.d.ts +132 -0
- package/dist/types/components/HkLoginFlow.d.ts +5 -0
- package/dist/types/components/HkStatusBar.d.ts +1 -1
- package/dist/types/components/loginDiscovery.d.ts +91 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +7 -4
- package/src/components/HkAuthChannelList.scss +4 -2
- package/src/components/HkAuthChannelList.test.tsx +64 -0
- package/src/components/HkAuthChannelList.tsx +51 -19
- package/src/components/HkAuthHandoff.scss +79 -0
- package/src/components/HkAuthHandoff.test.tsx +208 -0
- package/src/components/HkAuthHandoff.tsx +222 -0
- package/src/components/HkLoginFlow.test.tsx +21 -0
- package/src/components/HkLoginFlow.tsx +6 -0
- package/src/components/loginDiscovery.test.ts +200 -0
- package/src/components/loginDiscovery.ts +172 -0
- package/src/composables/useHighlight.hostSurface.test.ts +11 -1
- package/src/i18n/locales/ar/components.json +7 -0
- package/src/i18n/locales/de/components.json +7 -0
- package/src/i18n/locales/en/components.json +7 -0
- package/src/i18n/locales/es/components.json +7 -0
- package/src/i18n/locales/fr/components.json +7 -0
- package/src/i18n/locales/ja/components.json +7 -0
- package/src/i18n/locales/ko/components.json +7 -0
- package/src/i18n/locales/pt/components.json +7 -0
- package/src/i18n/locales/ru/components.json +7 -0
- package/src/i18n/locales/zh-Hans/components.json +7 -0
- package/src/i18n/locales/zh-Hant/components.json +7 -0
- package/src/index.ts +18 -0
- package/src/scene3d/scene3dHostSurface.test.ts +16 -4
- package/src/utils/qr/qrHostSurface.test.ts +20 -6
- package/src/wasm/highlight/hikari_wasm_highlight.js +1 -1
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +1 -1
- package/src/wasm/qr/hikari_wasm_qr.js +1 -1
- package/src/wasm/scene3d/hikari_wasm_scene3d.js +1 -1
|
@@ -11,6 +11,12 @@ export interface HkAuthChannelListEntry {
|
|
|
11
11
|
* (the label carries the row). */
|
|
12
12
|
icon?: unknown;
|
|
13
13
|
disabled?: boolean;
|
|
14
|
+
/** Navigation target. When set the row is a real link (`<a href>`), so
|
|
15
|
+
* middle-click, ctrl-click and crawlers work; `select(key)` STILL fires
|
|
16
|
+
* first (the host arms state) and the default navigation is NOT
|
|
17
|
+
* prevented. Default undefined — the row stays a `<button type="button">`
|
|
18
|
+
* and the host navigates itself, as before. */
|
|
19
|
+
href?: string;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
22
|
* HkAuthChannelList — the standard sign-in destination list (2026-11-22
|
|
@@ -24,7 +30,8 @@ export interface HkAuthChannelListEntry {
|
|
|
24
30
|
* dark-mode automatic) — no square framing, no hover reveal.
|
|
25
31
|
*
|
|
26
32
|
* Control contract: the list never talks to a backend; the host injects
|
|
27
|
-
* `methods` and handles `select(key)
|
|
33
|
+
* `methods` and handles `select(key)`, or gives a row a `href` so the row
|
|
34
|
+
* itself navigates.
|
|
28
35
|
*
|
|
29
36
|
* ```tsx
|
|
30
37
|
* <HkAuthChannelList
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { type PropType } from "vue";
|
|
2
|
+
import "./HkAuthHandoff.scss";
|
|
3
|
+
/** The five states a hand-off screen can be in:
|
|
4
|
+
* `redirecting` (about to leave for the sign-in entry), `completing`
|
|
5
|
+
* (the callback is being exchanged), `success`, `failed` and `expired`. */
|
|
6
|
+
export type HkAuthHandoffStatus = "redirecting" | "completing" | "success" | "failed" | "expired";
|
|
7
|
+
/** The built-in actions: `retry` restarts the hand-off, `back` returns to
|
|
8
|
+
* the sign-in page. */
|
|
9
|
+
export type HkAuthHandoffAction = "retry" | "back";
|
|
10
|
+
/**
|
|
11
|
+
* HkAuthHandoff — the sign-in screens that are NOT a form: the relay-mode
|
|
12
|
+
* splash before the browser leaves for the central login, the "completing"
|
|
13
|
+
* state while a callback is exchanged, and the terminal success / failed /
|
|
14
|
+
* expired states.
|
|
15
|
+
*
|
|
16
|
+
* Built on `HkAuthScreen` (header strip, centred stage, footer) with the
|
|
17
|
+
* auth card's grammar (logo, title, description). A CONTROLLED component:
|
|
18
|
+
* it builds no URLs and reads no token — the host passes `href` (or
|
|
19
|
+
* navigates itself on `redirect`) and decides what `retry` / `back` mean.
|
|
20
|
+
*
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <HkAuthHandoff
|
|
23
|
+
* status="redirecting"
|
|
24
|
+
* href={hkRelayEntryHref(policy, route.query.return) ?? undefined}
|
|
25
|
+
* delayMs={800}
|
|
26
|
+
* onBack={() => router.push("/login")}
|
|
27
|
+
* />
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const HkAuthHandoff: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
31
|
+
status: {
|
|
32
|
+
type: PropType<HkAuthHandoffStatus>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
/** Overrides the status title. Default undefined — the title is the
|
|
36
|
+
* status copy from `hikari::authHandoff.*`. */
|
|
37
|
+
title: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
/** A line under the title. Default undefined — no description is
|
|
42
|
+
* rendered (the status copy alone is the title). */
|
|
43
|
+
description: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: undefined;
|
|
46
|
+
};
|
|
47
|
+
/** Logo above the title. Default undefined — no logo. */
|
|
48
|
+
logoSrc: {
|
|
49
|
+
type: StringConstructor;
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
52
|
+
/** `redirecting` only: the navigation target. When undefined the
|
|
53
|
+
* component navigates nothing and the host handles `redirect`. */
|
|
54
|
+
href: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
/** `redirecting` only: how long the splash shows before navigating.
|
|
59
|
+
* Default 0 — navigate as soon as the screen mounts. */
|
|
60
|
+
delayMs: {
|
|
61
|
+
type: NumberConstructor;
|
|
62
|
+
default: number;
|
|
63
|
+
};
|
|
64
|
+
/** Built-in buttons in render order. Default undefined — `["back"]` for
|
|
65
|
+
* `failed` / `expired`, none for the other states. */
|
|
66
|
+
actions: {
|
|
67
|
+
type: PropType<readonly HkAuthHandoffAction[]>;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
71
|
+
/** The redirect fired: `href` is the target (an empty string when the
|
|
72
|
+
* `href` prop was not given). Return `false` from the handler to
|
|
73
|
+
* cancel the navigation (the handler is invoked directly so its
|
|
74
|
+
* return value can be read). */
|
|
75
|
+
redirect: (_href: string) => true;
|
|
76
|
+
/** The `retry` action was activated. */
|
|
77
|
+
retry: () => true;
|
|
78
|
+
/** The `back` action was activated. */
|
|
79
|
+
back: () => true;
|
|
80
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
81
|
+
status: {
|
|
82
|
+
type: PropType<HkAuthHandoffStatus>;
|
|
83
|
+
required: true;
|
|
84
|
+
};
|
|
85
|
+
/** Overrides the status title. Default undefined — the title is the
|
|
86
|
+
* status copy from `hikari::authHandoff.*`. */
|
|
87
|
+
title: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
default: undefined;
|
|
90
|
+
};
|
|
91
|
+
/** A line under the title. Default undefined — no description is
|
|
92
|
+
* rendered (the status copy alone is the title). */
|
|
93
|
+
description: {
|
|
94
|
+
type: StringConstructor;
|
|
95
|
+
default: undefined;
|
|
96
|
+
};
|
|
97
|
+
/** Logo above the title. Default undefined — no logo. */
|
|
98
|
+
logoSrc: {
|
|
99
|
+
type: StringConstructor;
|
|
100
|
+
default: undefined;
|
|
101
|
+
};
|
|
102
|
+
/** `redirecting` only: the navigation target. When undefined the
|
|
103
|
+
* component navigates nothing and the host handles `redirect`. */
|
|
104
|
+
href: {
|
|
105
|
+
type: StringConstructor;
|
|
106
|
+
default: undefined;
|
|
107
|
+
};
|
|
108
|
+
/** `redirecting` only: how long the splash shows before navigating.
|
|
109
|
+
* Default 0 — navigate as soon as the screen mounts. */
|
|
110
|
+
delayMs: {
|
|
111
|
+
type: NumberConstructor;
|
|
112
|
+
default: number;
|
|
113
|
+
};
|
|
114
|
+
/** Built-in buttons in render order. Default undefined — `["back"]` for
|
|
115
|
+
* `failed` / `expired`, none for the other states. */
|
|
116
|
+
actions: {
|
|
117
|
+
type: PropType<readonly HkAuthHandoffAction[]>;
|
|
118
|
+
default: undefined;
|
|
119
|
+
};
|
|
120
|
+
}>> & Readonly<{
|
|
121
|
+
onBack?: (() => any) | undefined;
|
|
122
|
+
onRetry?: (() => any) | undefined;
|
|
123
|
+
onRedirect?: ((_href: string) => any) | undefined;
|
|
124
|
+
}>, {
|
|
125
|
+
description: string;
|
|
126
|
+
title: string;
|
|
127
|
+
href: string;
|
|
128
|
+
actions: readonly HkAuthHandoffAction[];
|
|
129
|
+
logoSrc: string;
|
|
130
|
+
delayMs: number;
|
|
131
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
132
|
+
export default HkAuthHandoff;
|
|
@@ -66,6 +66,11 @@ export interface HkLoginSsoChannel {
|
|
|
66
66
|
* label. */
|
|
67
67
|
buttonLabel?: string;
|
|
68
68
|
disabled?: boolean;
|
|
69
|
+
/** Navigation target forwarded to the channel row: the row becomes a
|
|
70
|
+
* real link (`sso-click` still fires first, navigation is not
|
|
71
|
+
* prevented). Default undefined — the row is a button and the host
|
|
72
|
+
* navigates on `sso-click`, as before. */
|
|
73
|
+
href?: string;
|
|
69
74
|
}
|
|
70
75
|
export type HkLoginChannel = HkLoginCredentialsChannel | HkLoginSsoChannel;
|
|
71
76
|
/**
|
|
@@ -186,13 +186,13 @@ export declare const HkStatusBar: import("vue").DefineComponent<import("vue").Ex
|
|
|
186
186
|
version: string;
|
|
187
187
|
compact: boolean;
|
|
188
188
|
latencyMs: number;
|
|
189
|
+
onRetry: () => void;
|
|
189
190
|
engineVersion: string | null;
|
|
190
191
|
panelBuildHash: string | undefined;
|
|
191
192
|
engineBuildHash: string | undefined;
|
|
192
193
|
connectionStatus: "idle" | "connected" | "disconnected" | "connecting" | "reconnecting";
|
|
193
194
|
connectionInfo: HkConnectionInfo | null;
|
|
194
195
|
standalone: boolean;
|
|
195
|
-
onRetry: () => void;
|
|
196
196
|
transportTier: string;
|
|
197
197
|
attemptNumber: number;
|
|
198
198
|
countdown: number;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { HkLoginChannel } from "./HkLoginFlow";
|
|
2
|
+
/**
|
|
3
|
+
* Pure discovery adapter — turns the server's login-policy document into
|
|
4
|
+
* `HkLoginFlow` channels (or into "mount no flow at all"). No Vue
|
|
5
|
+
* reactivity, no endpoint, no URL building: hosts fetch the document and
|
|
6
|
+
* call `hkLoginPlanFromDiscovery`.
|
|
7
|
+
*
|
|
8
|
+
* The structural types mirror the wire document field-for-field. hikari
|
|
9
|
+
* never validates it and never throws on a foreign document — unknown
|
|
10
|
+
* methods are ignored; the SERVER stays the authority.
|
|
11
|
+
*/
|
|
12
|
+
/** Where the password form (if any) and the provider rows live. */
|
|
13
|
+
export type HkLoginMode = "local" | "federated" | "relay";
|
|
14
|
+
/** One non-password entrance announced by the server. */
|
|
15
|
+
export type HkLoginMethod = {
|
|
16
|
+
kind: "oauth";
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
href: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: "passkey";
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
href: string;
|
|
27
|
+
icon?: string;
|
|
28
|
+
} | {
|
|
29
|
+
kind: "custom";
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
href: string;
|
|
33
|
+
icon?: string;
|
|
34
|
+
};
|
|
35
|
+
/** The login-policy wire document (see `kirino::auth::mode::LoginPolicy`). */
|
|
36
|
+
export interface HkLoginDiscovery {
|
|
37
|
+
version: number;
|
|
38
|
+
mode: HkLoginMode;
|
|
39
|
+
password: boolean;
|
|
40
|
+
methods: readonly HkLoginMethod[];
|
|
41
|
+
/** Present in `relay` mode: the central sign-in entry and the query
|
|
42
|
+
* parameter it reads the return address from. */
|
|
43
|
+
relay?: {
|
|
44
|
+
entry: string;
|
|
45
|
+
return_param: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** What a host mounts for the discovered policy. */
|
|
49
|
+
export interface HkLoginPlan {
|
|
50
|
+
mode: HkLoginMode;
|
|
51
|
+
/** `HkLoginFlow` channels. EMPTY in relay mode — the host must not mount
|
|
52
|
+
* the flow; it shows the hand-off screen (`HkAuthHandoff`) instead. */
|
|
53
|
+
channels: HkLoginChannel[];
|
|
54
|
+
/** Seed for the flow's `v-model`; `null` in relay mode. */
|
|
55
|
+
defaultChannel: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** Host-owned copy. Everything is optional; the credentials channel is
|
|
58
|
+
* consumer-localised on purpose, as every auth label is. */
|
|
59
|
+
export interface HkLoginPlanCopy {
|
|
60
|
+
/** Channel key of the credentials channel; default `"cloud"`. */
|
|
61
|
+
credentialsKey?: string;
|
|
62
|
+
/** Optional segment label for the credentials channel. */
|
|
63
|
+
credentialsLabel?: string;
|
|
64
|
+
/** Divider text above the provider rows. Omitted when not given (the
|
|
65
|
+
* list renders no divider) — the consumer-localised rule is kept. */
|
|
66
|
+
divider?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Map a discovery document to a `HkLoginPlan`.
|
|
70
|
+
*
|
|
71
|
+
* - `relay` → `channels: []`, `defaultChannel: null` (hand-off screen).
|
|
72
|
+
* - `local` → ONE credentials channel whose rows are the non-provider
|
|
73
|
+
* entrances (`passkey`, `custom`); `defaultChannel` is its key.
|
|
74
|
+
* - `federated` + `password: true` → the credentials channel with EVERY
|
|
75
|
+
* method as a row, wire order preserved.
|
|
76
|
+
* - `federated` + `password: false` → no credentials channel; every method
|
|
77
|
+
* becomes its own `sso` channel. `defaultChannel` = the first one's key.
|
|
78
|
+
*/
|
|
79
|
+
export declare function hkLoginPlanFromDiscovery(d: HkLoginDiscovery, copy?: HkLoginPlanCopy): HkLoginPlan;
|
|
80
|
+
/** True for a path hikari may forward as a return address: absolute,
|
|
81
|
+
* same-origin by construction (`/x`), not a protocol-relative URL
|
|
82
|
+
* (`//evil.example`), not the bare root, and free of backslashes, control
|
|
83
|
+
* and format characters (see `UNSAFE_IN_A_LOCATION`). */
|
|
84
|
+
export declare function hkIsSameOriginPath(raw: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* The navigation target of a relay entry, or `null` when the document is
|
|
87
|
+
* not in relay mode (or has no entry). The return address is appended only
|
|
88
|
+
* when it is a same-origin path — a foreign URL is never forwarded. An
|
|
89
|
+
* entry that already carries a query string is joined with `&`.
|
|
90
|
+
*/
|
|
91
|
+
export declare function hkRelayEntryHref(d: HkLoginDiscovery, returnTo?: string): string | null;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -240,6 +240,7 @@ export { default as HAuthMethodList } from "./components/HkAuthMethodList";
|
|
|
240
240
|
export { HkSignInCard as HSignInCard } from "./components/HkSignInCard";
|
|
241
241
|
export { HkThirdPartySignInCard as HThirdPartySignInCard } from "./components/HkThirdPartySignInCard";
|
|
242
242
|
export { default as HAuthSubmitButton } from "./components/HkAuthSubmitButton";
|
|
243
|
+
export { HkAuthHandoff as HAuthHandoff } from "./components/HkAuthHandoff";
|
|
243
244
|
export { HkMfaVerifyCard as HMfaVerifyCard, hkIsMfaFactor as isMfaFactor, hkPreferredMfaFactor as preferredMfaFactor, hkMfaVerifyTitle as mfaVerifyTitle, hkMfaVerifySubtitle as mfaVerifySubtitle, type HkMfaFactor as MfaFactor, } from "./components/HkMfaVerifyCard";
|
|
244
245
|
export { usePageTitle, useRouteTitle } from "./composables/usePageTitle";
|
|
245
246
|
export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistrations } from "./composables/useActionBar";
|
|
@@ -498,6 +499,9 @@ export { type HkLoginSsoChannel as HkLoginSsoChannel } from "./components/HkLogi
|
|
|
498
499
|
export { HkAuthSsoButton as HkAuthSsoButton } from "./components/HkAuthSsoButton";
|
|
499
500
|
export { HkAuthChannelList as HkAuthChannelList } from "./components/HkAuthChannelList";
|
|
500
501
|
export { type HkAuthChannelListEntry as HkAuthChannelListEntry } from "./components/HkAuthChannelList";
|
|
502
|
+
export { HkAuthHandoff as HkAuthHandoff } from "./components/HkAuthHandoff";
|
|
503
|
+
export { type HkAuthHandoffAction as HkAuthHandoffAction, type HkAuthHandoffStatus as HkAuthHandoffStatus, } from "./components/HkAuthHandoff";
|
|
504
|
+
export { hkIsSameOriginPath as hkIsSameOriginPath, hkLoginPlanFromDiscovery as hkLoginPlanFromDiscovery, hkRelayEntryHref as hkRelayEntryHref, type HkLoginDiscovery as HkLoginDiscovery, type HkLoginMethod as HkLoginMethod, type HkLoginMode as HkLoginMode, type HkLoginPlan as HkLoginPlan, type HkLoginPlanCopy as HkLoginPlanCopy, } from "./components/loginDiscovery";
|
|
501
505
|
export { HkLocalePicker as HkLocalePicker } from "./components/HkLocalePicker";
|
|
502
506
|
export { HkAdminTablePage as HkAdminTablePage } from "./components/HkAdminTablePage";
|
|
503
507
|
export { HkMasterDetail as HkMasterDetail } from "./components/HkMasterDetail";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celestia-island/hikari",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.475",
|
|
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",
|
|
@@ -63,13 +63,16 @@
|
|
|
63
63
|
],
|
|
64
64
|
"scripts": {
|
|
65
65
|
"dev": "vite",
|
|
66
|
+
"pretest": "python3 ../wasm/ensure_bindings.py",
|
|
67
|
+
"test": "vitest run",
|
|
68
|
+
"test:watch": "vitest",
|
|
69
|
+
"prebuild": "python3 ../wasm/ensure_bindings.py",
|
|
66
70
|
"build": "vue-tsc --noEmit",
|
|
67
71
|
"build:docs": "vite build",
|
|
72
|
+
"prelint": "python3 ../wasm/ensure_bindings.py",
|
|
68
73
|
"lint": "vue-tsc --noEmit",
|
|
69
|
-
"test": "vitest run",
|
|
70
|
-
"test:watch": "vitest",
|
|
71
74
|
"gen:boot-landing-css": "node scripts/gen-boot-landing-css.js",
|
|
72
|
-
"prepublishOnly": "npm run build:types",
|
|
75
|
+
"prepublishOnly": "python3 ../wasm/check_npm_pack.py && npm run build:types",
|
|
73
76
|
"build:types": "vue-tsc --project tsconfig.build.json"
|
|
74
77
|
},
|
|
75
78
|
"peerDependencies": {
|
|
@@ -42,11 +42,12 @@
|
|
|
42
42
|
color: rgb(var(--color-text, 25 30 40));
|
|
43
43
|
font-size: 0.875rem;
|
|
44
44
|
cursor: pointer;
|
|
45
|
+
text-decoration: none;
|
|
45
46
|
transition:
|
|
46
47
|
border-color 0.15s ease,
|
|
47
48
|
background-color 0.15s ease;
|
|
48
49
|
|
|
49
|
-
&:hover:not(:disabled) {
|
|
50
|
+
&:hover:not(:disabled):not([aria-disabled="true"]) {
|
|
50
51
|
border-color: color-mix(in srgb, rgb(var(--color-primary, 122 162 247)) 55%, transparent);
|
|
51
52
|
background: color-mix(in srgb, rgb(var(--color-surface, 255 255 255)) 100%, transparent);
|
|
52
53
|
}
|
|
@@ -56,7 +57,8 @@
|
|
|
56
57
|
outline-offset: 2px;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
&:disabled
|
|
60
|
+
&:disabled,
|
|
61
|
+
&[aria-disabled="true"] {
|
|
60
62
|
opacity: 0.55;
|
|
61
63
|
cursor: not-allowed;
|
|
62
64
|
}
|
|
@@ -71,4 +71,68 @@ describe("HkAuthChannelList", () => {
|
|
|
71
71
|
const c = mount(h(HkAuthChannelList, { divider: "或", methods }));
|
|
72
72
|
expect(c.querySelector(".hk-auth-channel-divider")?.textContent).toContain("或");
|
|
73
73
|
});
|
|
74
|
+
|
|
75
|
+
it("renders a real link for a row with href, and a button without", () => {
|
|
76
|
+
const c = mount(
|
|
77
|
+
h(HkAuthChannelList, {
|
|
78
|
+
methods: [{ key: "celestial", label: "Celestia", href: "/auth/relay/begin" }, ...methods],
|
|
79
|
+
}),
|
|
80
|
+
);
|
|
81
|
+
const rows = c.querySelectorAll<HTMLElement>(".hk-auth-channel-row");
|
|
82
|
+
expect(rows[0]!.tagName).toBe("A");
|
|
83
|
+
// MUT:row-href-dropped (dropping `href` from the anchor leaves a link
|
|
84
|
+
// that goes nowhere — middle-click and crawlers see no target).
|
|
85
|
+
expect(rows[0]!.getAttribute("href")).toBe("/auth/relay/begin");
|
|
86
|
+
expect(rows[0]!.getAttribute("type")).toBeNull();
|
|
87
|
+
// The old default is untouched: no href → a plain button.
|
|
88
|
+
expect(rows[1]!.tagName).toBe("BUTTON");
|
|
89
|
+
expect(rows[1]!.getAttribute("type")).toBe("button");
|
|
90
|
+
expect(rows[1]!.getAttribute("href")).toBeNull();
|
|
91
|
+
// Same classes and inner grammar on both forms.
|
|
92
|
+
expect(rows[0]!.querySelector(".hk-auth-channel-name")?.textContent).toBe("Celestia");
|
|
93
|
+
expect(rows[0]!.getAttribute("aria-label")).toBe("Celestia");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("emits select BEFORE following the link and never prevents the navigation", async () => {
|
|
97
|
+
const onSelect = vi.fn();
|
|
98
|
+
const c = mount(
|
|
99
|
+
h(HkAuthChannelList, {
|
|
100
|
+
methods: [{ key: "celestial", label: "Celestia", href: "/auth/relay/begin" }],
|
|
101
|
+
onSelect,
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
const row = c.querySelector<HTMLAnchorElement>("a.hk-auth-channel-row")!;
|
|
105
|
+
const seen: Array<{ called: boolean; prevented: boolean }> = [];
|
|
106
|
+
row.addEventListener("click", (event) => {
|
|
107
|
+
// Runs AFTER the component's own handler (registered first).
|
|
108
|
+
seen.push({ called: onSelect.mock.calls.length > 0, prevented: event.defaultPrevented });
|
|
109
|
+
});
|
|
110
|
+
row.click();
|
|
111
|
+
await nextTick();
|
|
112
|
+
expect(onSelect).toHaveBeenCalledWith("celestial");
|
|
113
|
+
// MUT:row-select-after-nav (deferring the emit, e.g. into a promise,
|
|
114
|
+
// has the browser leave before the host armed its state).
|
|
115
|
+
expect(seen[0]).toEqual({ called: true, prevented: false });
|
|
116
|
+
// MUT:row-href-prevent-default (cancelling the click turns the link
|
|
117
|
+
// into a button again — no new tab, no crawler target).
|
|
118
|
+
expect(seen[0]!.prevented).toBe(false);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("a disabled link renders without href and announces aria-disabled", () => {
|
|
122
|
+
const onSelect = vi.fn();
|
|
123
|
+
const c = mount(
|
|
124
|
+
h(HkAuthChannelList, {
|
|
125
|
+
methods: [{ key: "off", label: "Off", href: "/x", disabled: true }],
|
|
126
|
+
onSelect,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
const row = c.querySelector<HTMLAnchorElement>("a.hk-auth-channel-row")!;
|
|
130
|
+
expect(row.tagName).toBe("A");
|
|
131
|
+
// MUT:row-disabled-href-kept (leaving the href on a disabled link keeps
|
|
132
|
+
// it navigable by keyboard and by middle-click).
|
|
133
|
+
expect(row.hasAttribute("href")).toBe(false);
|
|
134
|
+
// MUT:row-disabled-aria-dropped (without aria-disabled the row looks
|
|
135
|
+
// enabled to assistive tech).
|
|
136
|
+
expect(row.getAttribute("aria-disabled")).toBe("true");
|
|
137
|
+
});
|
|
74
138
|
});
|
|
@@ -14,6 +14,12 @@ export interface HkAuthChannelListEntry {
|
|
|
14
14
|
* (the label carries the row). */
|
|
15
15
|
icon?: unknown;
|
|
16
16
|
disabled?: boolean;
|
|
17
|
+
/** Navigation target. When set the row is a real link (`<a href>`), so
|
|
18
|
+
* middle-click, ctrl-click and crawlers work; `select(key)` STILL fires
|
|
19
|
+
* first (the host arms state) and the default navigation is NOT
|
|
20
|
+
* prevented. Default undefined — the row stays a `<button type="button">`
|
|
21
|
+
* and the host navigates itself, as before. */
|
|
22
|
+
href?: string;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
/**
|
|
@@ -28,7 +34,8 @@ export interface HkAuthChannelListEntry {
|
|
|
28
34
|
* dark-mode automatic) — no square framing, no hover reveal.
|
|
29
35
|
*
|
|
30
36
|
* Control contract: the list never talks to a backend; the host injects
|
|
31
|
-
* `methods` and handles `select(key)
|
|
37
|
+
* `methods` and handles `select(key)`, or gives a row a `href` so the row
|
|
38
|
+
* itself navigates.
|
|
32
39
|
*
|
|
33
40
|
* ```tsx
|
|
34
41
|
* <HkAuthChannelList
|
|
@@ -61,24 +68,49 @@ export const HkAuthChannelList = defineComponent({
|
|
|
61
68
|
</div>
|
|
62
69
|
)}
|
|
63
70
|
<div class="hk-auth-channel-rows">
|
|
64
|
-
{props.methods.map((method) =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
{props.methods.map((method) => {
|
|
72
|
+
// A disabled link carries no `href` at all (an anchor cannot be
|
|
73
|
+
// natively disabled); `aria-disabled` keeps the state announced.
|
|
74
|
+
const isLink = Boolean(method.href);
|
|
75
|
+
const active = !method.disabled;
|
|
76
|
+
const body = (
|
|
77
|
+
<>
|
|
78
|
+
<span class="hk-auth-channel-icon" aria-hidden="true">
|
|
79
|
+
{method.icon ?? null}
|
|
80
|
+
</span>
|
|
81
|
+
<span class="hk-auth-channel-name">{method.label}</span>
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
const onClick = () => {
|
|
85
|
+
// Synchronous, BEFORE the browser follows the link.
|
|
86
|
+
if (active) emit("select", method.key);
|
|
87
|
+
};
|
|
88
|
+
return isLink ? (
|
|
89
|
+
<a
|
|
90
|
+
key={method.key}
|
|
91
|
+
class="hk-auth-channel-row"
|
|
92
|
+
data-key={method.key}
|
|
93
|
+
href={active ? method.href : undefined}
|
|
94
|
+
aria-disabled={active ? undefined : "true"}
|
|
95
|
+
aria-label={method.label}
|
|
96
|
+
onClick={onClick}
|
|
97
|
+
>
|
|
98
|
+
{body}
|
|
99
|
+
</a>
|
|
100
|
+
) : (
|
|
101
|
+
<button
|
|
102
|
+
key={method.key}
|
|
103
|
+
type="button"
|
|
104
|
+
class="hk-auth-channel-row"
|
|
105
|
+
data-key={method.key}
|
|
106
|
+
disabled={method.disabled}
|
|
107
|
+
aria-label={method.label}
|
|
108
|
+
onClick={onClick}
|
|
109
|
+
>
|
|
110
|
+
{body}
|
|
111
|
+
</button>
|
|
112
|
+
);
|
|
113
|
+
})}
|
|
82
114
|
</div>
|
|
83
115
|
</div>
|
|
84
116
|
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// AI-generated: developed with the DeepSeek Harness agent (model GLM-5.4), directed and
|
|
2
|
+
// reviewed by the lead agent — SySL-1.0 §2.3 disclosure.
|
|
3
|
+
|
|
4
|
+
// HkAuthHandoff — the no-form sign-in screens (relay splash, completing,
|
|
5
|
+
// success / failed / expired). The shell is HkAuthScreen and the frame is
|
|
6
|
+
// the shared `.s-auth-card` grammar from admin-tokens.scss (vendored); this
|
|
7
|
+
// sheet only adds what the card never had: a logo, a centred body with a
|
|
8
|
+
// spinner or a status line, and an action row.
|
|
9
|
+
|
|
10
|
+
.hk-auth-handoff {
|
|
11
|
+
width: 100%;
|
|
12
|
+
max-width: var(--hk-auth-card-max-width, 28rem);
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.hk-auth-handoff-card {
|
|
17
|
+
overflow-wrap: anywhere;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.hk-auth-handoff-header {
|
|
21
|
+
gap: var(--space-12, 0.75rem);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hk-auth-handoff-logo {
|
|
25
|
+
display: block;
|
|
26
|
+
width: 3.5rem;
|
|
27
|
+
height: 3.5rem;
|
|
28
|
+
object-fit: contain;
|
|
29
|
+
border-radius: var(--hi-radius-lg, 12px);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.hk-auth-handoff-title {
|
|
33
|
+
margin: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.hk-auth-handoff-description {
|
|
37
|
+
max-width: 36ch;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.hk-auth-handoff-body {
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
align-items: center;
|
|
44
|
+
gap: var(--space-24, 1.5rem);
|
|
45
|
+
padding: var(--space-24, 1.5rem) var(--space-24, 1.5rem) var(--space-32, 2rem);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.hk-auth-handoff-state {
|
|
49
|
+
display: flex;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.hk-auth-handoff-actions {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
gap: var(--space-12, 0.75rem);
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A body with nothing to show (no actions, no spinner) keeps no padding.
|
|
62
|
+
.hk-auth-handoff-body:empty {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (max-width: 360px) {
|
|
67
|
+
.hk-auth-handoff-header {
|
|
68
|
+
padding: var(--space-24, 1.5rem) var(--space-16, 1rem) 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.hk-auth-handoff-body {
|
|
72
|
+
padding: var(--space-16, 1rem) var(--space-16, 1rem) var(--space-24, 1.5rem);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.hk-auth-handoff-logo {
|
|
76
|
+
width: 2.5rem;
|
|
77
|
+
height: 2.5rem;
|
|
78
|
+
}
|
|
79
|
+
}
|