@celestia-island/hikari 0.55.526 → 0.55.528
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/HkAdminHeader.d.ts +31 -10
- package/dist/types/components/HkAlert.d.ts +35 -0
- package/dist/types/components/HkFaceShell.d.ts +16 -0
- package/dist/types/components/HkMenu.d.ts +15 -0
- package/dist/types/composables/usePageCreateAction.d.ts +42 -0
- package/dist/types/composables/usePageRefresh.d.ts +37 -0
- package/dist/types/composables/usePageSearch.d.ts +55 -0
- package/dist/types/index.d.ts +7 -1
- package/package.json +1 -1
- package/src/components/HkAdminHeader.test.tsx +142 -9
- package/src/components/HkAdminHeader.tsx +56 -11
- package/src/components/HkAdminHeader.userMenuItems.test.tsx +205 -0
- package/src/components/HkAdminShell.centre.test.tsx +12 -10
- package/src/components/HkAlert.role.test.tsx +17 -0
- package/src/components/HkAlert.tsx +22 -4
- package/src/components/HkAuthHandoff.test.tsx +10 -0
- package/src/components/HkAuthHandoff.tsx +6 -4
- package/src/components/HkFaceShell.slots.test.ts +65 -1
- package/src/components/HkFaceShell.tsx +16 -0
- package/src/components/HkMenu.test.ts +192 -2
- package/src/components/HkMenu.tsx +32 -0
- package/src/composables/usePageActions.barrel.test.ts +38 -0
- package/src/composables/usePageCreateAction.test.ts +309 -0
- package/src/composables/usePageCreateAction.ts +81 -0
- package/src/composables/usePageRefresh.test.ts +241 -0
- package/src/composables/usePageRefresh.ts +74 -0
- package/src/composables/usePageSearch.test.ts +345 -0
- package/src/composables/usePageSearch.ts +87 -0
- package/src/errorLandingStandalone/error-landing.html +1 -1
- package/src/i18n/locales/ar/components.json +2 -1
- package/src/i18n/locales/de/components.json +2 -1
- package/src/i18n/locales/en/components.json +2 -1
- package/src/i18n/locales/es/components.json +2 -1
- package/src/i18n/locales/fr/components.json +2 -1
- package/src/i18n/locales/ja/components.json +2 -1
- package/src/i18n/locales/ko/components.json +2 -1
- package/src/i18n/locales/pt/components.json +2 -1
- package/src/i18n/locales/ru/components.json +2 -1
- package/src/i18n/locales/zh-Hans/components.json +2 -1
- package/src/i18n/locales/zh-Hant/components.json +2 -1
- package/src/index.ts +10 -1
|
@@ -23,6 +23,20 @@ export interface HkAdminHeaderAvatarModalSlot {
|
|
|
23
23
|
export interface HkAdminHeaderUserMenuExtraSlot {
|
|
24
24
|
close?: () => void;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Scoped payload of the `user-menu-items` slot — host-owned account rows
|
|
28
|
+
* the header seats IMMEDIATELY ABOVE the logout row, inside the dropdown's
|
|
29
|
+
* row run (no divider): account actions belong ahead of the destructive
|
|
30
|
+
* exit. `user-menu-extra` is the TAIL band BELOW logout — a change-password
|
|
31
|
+
* entry passed there reads as an afterthought under "Log out", which is
|
|
32
|
+
* where it sat while the tail was the only host carrier. Same payload shape
|
|
33
|
+
* as `user-menu-extra`: `close` dismisses the dropdown so a navigating entry
|
|
34
|
+
* leaves no orphaned menu behind. Both slots may be supplied at once and
|
|
35
|
+
* each keeps its own position.
|
|
36
|
+
*/
|
|
37
|
+
export interface HkAdminHeaderUserMenuItemsSlot {
|
|
38
|
+
close?: () => void;
|
|
39
|
+
}
|
|
26
40
|
/**
|
|
27
41
|
* Scoped payload of the `locale-picker` slot — the host-owned locale
|
|
28
42
|
* popup. When the slot is supplied, the menu's Language row becomes a
|
|
@@ -46,8 +60,9 @@ export interface HkAdminHeaderLocalePickerSlot {
|
|
|
46
60
|
* static site logo in place of the avatar identity trigger. The mark
|
|
47
61
|
* is an identity, not a control: no href, no button semantics. On that
|
|
48
62
|
* face the account machinery does not mount at all (ZERO ACCOUNT
|
|
49
|
-
* SURFACE): `identity`, `user-menu-extra`, `
|
|
50
|
-
* `locale-picker` have no carrier — they all live
|
|
63
|
+
* SURFACE): `identity`, `user-menu-extra`, `user-menu-items`,
|
|
64
|
+
* `avatar-modal` and `locale-picker` have no carrier — they all live
|
|
65
|
+
* inside the dropdown.
|
|
51
66
|
* The drawer face never renders the mark — the avatar trigger is the
|
|
52
67
|
* drawer's only opener there, and the drawer path stays untouched.
|
|
53
68
|
* The host that swaps the identity trigger away mounts its own account
|
|
@@ -58,6 +73,11 @@ export interface HkAdminHeaderLocalePickerSlot {
|
|
|
58
73
|
* `locale-picker` (host locale popup replacing the built-in cascade) were
|
|
59
74
|
* consumed as of the L39 ruling-a revival (2026-11-20): the erp bodies
|
|
60
75
|
* that had sat invisible since 0.55.241 now render.
|
|
76
|
+
*
|
|
77
|
+
* `user-menu-items` (host account rows seated directly above the logout
|
|
78
|
+
* row, through HkMenu's `before-item` splice) is the position that slot
|
|
79
|
+
* could never offer — the tail is below logout. It coexists with
|
|
80
|
+
* `user-menu-extra`; each keeps its own position.
|
|
61
81
|
*/
|
|
62
82
|
export type HkAdminHeaderSlots = SlotsType<{
|
|
63
83
|
brand?: () => VNode[];
|
|
@@ -67,6 +87,7 @@ export type HkAdminHeaderSlots = SlotsType<{
|
|
|
67
87
|
"theme-toggle"?: () => VNode[];
|
|
68
88
|
"avatar-modal"?: (params: HkAdminHeaderAvatarModalSlot) => VNode[];
|
|
69
89
|
"user-menu-extra"?: (params: HkAdminHeaderUserMenuExtraSlot) => VNode[];
|
|
90
|
+
"user-menu-items"?: (params: HkAdminHeaderUserMenuItemsSlot) => VNode[];
|
|
70
91
|
"locale-picker"?: (params: HkAdminHeaderLocalePickerSlot) => VNode[];
|
|
71
92
|
}>;
|
|
72
93
|
export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
@@ -239,10 +260,10 @@ export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").
|
|
|
239
260
|
* Contract, four clauses:
|
|
240
261
|
* - ZERO ACCOUNT SURFACE: the branded desktop face renders no
|
|
241
262
|
* account machinery at all — the avatar trigger does not render,
|
|
242
|
-
* and the `identity` / `user-menu-extra` / `
|
|
243
|
-
* `locale-picker` slots have NO carrier on this
|
|
244
|
-
* live inside the dropdown, which is not mounted).
|
|
245
|
-
* needs an account face either does not opt into the brand
|
|
263
|
+
* and the `identity` / `user-menu-extra` / `user-menu-items` /
|
|
264
|
+
* `avatar-modal` / `locale-picker` slots have NO carrier on this
|
|
265
|
+
* face (they all live inside the dropdown, which is not mounted).
|
|
266
|
+
* A host that needs an account face either does not opt into the brand
|
|
246
267
|
* (its consumers keep today's header) or mounts its own entries
|
|
247
268
|
* in the actions wing — the house shape is a ghost HkIconButton
|
|
248
269
|
* sized on the page-chrome action ladder, NOT a second
|
|
@@ -451,10 +472,10 @@ export declare const HkAdminHeader: import("vue").DefineComponent<import("vue").
|
|
|
451
472
|
* Contract, four clauses:
|
|
452
473
|
* - ZERO ACCOUNT SURFACE: the branded desktop face renders no
|
|
453
474
|
* account machinery at all — the avatar trigger does not render,
|
|
454
|
-
* and the `identity` / `user-menu-extra` / `
|
|
455
|
-
* `locale-picker` slots have NO carrier on this
|
|
456
|
-
* live inside the dropdown, which is not mounted).
|
|
457
|
-
* needs an account face either does not opt into the brand
|
|
475
|
+
* and the `identity` / `user-menu-extra` / `user-menu-items` /
|
|
476
|
+
* `avatar-modal` / `locale-picker` slots have NO carrier on this
|
|
477
|
+
* face (they all live inside the dropdown, which is not mounted).
|
|
478
|
+
* A host that needs an account face either does not opt into the brand
|
|
458
479
|
* (its consumers keep today's header) or mounts its own entries
|
|
459
480
|
* in the actions wing — the house shape is a ghost HkIconButton
|
|
460
481
|
* sized on the page-chrome action ladder, NOT a second
|
|
@@ -34,6 +34,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
34
34
|
type: PropType<HkPad>;
|
|
35
35
|
default: undefined;
|
|
36
36
|
};
|
|
37
|
+
/** Drop this alert's OWN live region (`role` / `aria-live` stay off
|
|
38
|
+
* the root) while keeping the visuals. For an alert rendered INSIDE
|
|
39
|
+
* a container that already owns the live region — e.g. HkAuthHandoff's
|
|
40
|
+
* failed card, which carries `role="alert"` itself and flips in place
|
|
41
|
+
* on a status change. Nesting a second assertive region there makes a
|
|
42
|
+
* flip announce twice (2026-12-02 review, S2). Default true: the
|
|
43
|
+
* standalone alert keeps its semantics, which every other consumer
|
|
44
|
+
* relies on.
|
|
45
|
+
*
|
|
46
|
+
* The name is `ownsLiveRegion`, NOT `ariaLive`: a camelCase prop
|
|
47
|
+
* lowercases to `arialive`, which CONSUMES the fallthrough
|
|
48
|
+
* `aria-live` attribute — a host's `aria-live="off"` would become an
|
|
49
|
+
* interruption instead of a silence request. */
|
|
50
|
+
ownsLiveRegion: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: boolean;
|
|
53
|
+
};
|
|
37
54
|
}>, () => import("vue/jsx-runtime").JSX.Element | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
38
55
|
close: () => true;
|
|
39
56
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
@@ -67,6 +84,23 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
67
84
|
type: PropType<HkPad>;
|
|
68
85
|
default: undefined;
|
|
69
86
|
};
|
|
87
|
+
/** Drop this alert's OWN live region (`role` / `aria-live` stay off
|
|
88
|
+
* the root) while keeping the visuals. For an alert rendered INSIDE
|
|
89
|
+
* a container that already owns the live region — e.g. HkAuthHandoff's
|
|
90
|
+
* failed card, which carries `role="alert"` itself and flips in place
|
|
91
|
+
* on a status change. Nesting a second assertive region there makes a
|
|
92
|
+
* flip announce twice (2026-12-02 review, S2). Default true: the
|
|
93
|
+
* standalone alert keeps its semantics, which every other consumer
|
|
94
|
+
* relies on.
|
|
95
|
+
*
|
|
96
|
+
* The name is `ownsLiveRegion`, NOT `ariaLive`: a camelCase prop
|
|
97
|
+
* lowercases to `arialive`, which CONSUMES the fallthrough
|
|
98
|
+
* `aria-live` attribute — a host's `aria-live="off"` would become an
|
|
99
|
+
* interruption instead of a silence request. */
|
|
100
|
+
ownsLiveRegion: {
|
|
101
|
+
type: BooleanConstructor;
|
|
102
|
+
default: boolean;
|
|
103
|
+
};
|
|
70
104
|
}>> & Readonly<{
|
|
71
105
|
onClose?: (() => any) | undefined;
|
|
72
106
|
}>, {
|
|
@@ -76,5 +110,6 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
76
110
|
padding: HkPad;
|
|
77
111
|
closable: boolean;
|
|
78
112
|
banner: boolean;
|
|
113
|
+
ownsLiveRegion: boolean;
|
|
79
114
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
80
115
|
export default _default;
|
|
@@ -136,6 +136,22 @@ export interface HkFaceShellHeaderSlot {
|
|
|
136
136
|
* (or drops) its centre group repaints the header that renders it.
|
|
137
137
|
*/
|
|
138
138
|
center?: () => VNode[];
|
|
139
|
+
/**
|
|
140
|
+
* The RIGHT cluster — the page action bar: the VNodes of every action the
|
|
141
|
+
* mounted pages registered (`useActionBar().setActions`), already in slot
|
|
142
|
+
* order, for the header to render as its top-right group. `HkAdminHeader`
|
|
143
|
+
* takes this list verbatim as its `actions` prop.
|
|
144
|
+
*
|
|
145
|
+
* Supplied by the shell that PROVIDES the bar — `HkAdminShell`, which
|
|
146
|
+
* owns one and re-reads it on each of its own renders, so a page's
|
|
147
|
+
* registration repaints the header that shows it. A bare `HkFaceShell`
|
|
148
|
+
* provides no bar and leaves the field ABSENT: a face whose host owns its
|
|
149
|
+
* chrome reads its own bar instead. A consumer therefore relays it as
|
|
150
|
+
* `actions ?? []`, and the optionality is the type-level mirror of the
|
|
151
|
+
* runtime pins in HkFaceShell.test.tsx ("actions" present under
|
|
152
|
+
* HkAdminShell, absent under HkFaceShell).
|
|
153
|
+
*/
|
|
154
|
+
actions?: VNode[];
|
|
139
155
|
}
|
|
140
156
|
/**
|
|
141
157
|
* Scoped payload of the `sidebar` slot. Desktop renders it twice — expanded
|
|
@@ -39,6 +39,21 @@ import "./HkMenu.scss";
|
|
|
39
39
|
* (HkAffixPicker) put their search here so a long catalog scrolls
|
|
40
40
|
* under the field instead of taking it along (2026-11-27 user report).
|
|
41
41
|
* Cascade levels and mobile sub-sheets carry neither.
|
|
42
|
+
*
|
|
43
|
+
* One more slot seats host rows BETWEEN the built-in ones — popup
|
|
44
|
+
* variant, ROOT level, DATA-DRIVEN mode only:
|
|
45
|
+
* - `before-item` — scoped, `({ key }) => VNode[]`, invoked right
|
|
46
|
+
* before EACH root row renders with that row's `HkMenuItem.key`; its
|
|
47
|
+
* nodes splice into the level as the row's IMMEDIATE predecessors —
|
|
48
|
+
* bare (no wrapper, no divider), so the host supplies menu-row markup
|
|
49
|
+
* itself and keys the splice on the row key it wants to precede.
|
|
50
|
+
* HkAdminHeader's `user-menu-items` lands directly above the logout
|
|
51
|
+
* row this way (the `footer` band sits BELOW logout — too late for an
|
|
52
|
+
* account action). With no slot the level DOM is byte-identical.
|
|
53
|
+
* Inert everywhere else: cascade levels and mobile sub-sheets are not
|
|
54
|
+
* the root, the sidebar variant draws its rows through its own
|
|
55
|
+
* renderers and never consults the hook, and in composition mode the
|
|
56
|
+
* default slot draws its own rows (no item row to precede).
|
|
42
57
|
*/
|
|
43
58
|
export interface HkMenuItem {
|
|
44
59
|
key: string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Component, type Ref } from "vue";
|
|
2
|
+
/** What a page passes to `usePageCreateAction`. */
|
|
3
|
+
export interface UsePageCreateActionOptions {
|
|
4
|
+
/** Accessible name + tooltip — the label the in-page button printed.
|
|
5
|
+
* A FUNCTION is resolved on every header render, which is how a page
|
|
6
|
+
* whose create action changes with its sub-tab (or its locale) keeps the
|
|
7
|
+
* button labelled correctly without re-registering. */
|
|
8
|
+
label: string | (() => string);
|
|
9
|
+
/** Opens the page's own create dialog / starts the create flow. */
|
|
10
|
+
onCreate: () => unknown;
|
|
11
|
+
/** True while the action cannot run (e.g. a save is in flight). */
|
|
12
|
+
disabled?: Ref<boolean> | (() => boolean);
|
|
13
|
+
/** False hides the button entirely (evaluated on every header render). */
|
|
14
|
+
visible?: () => boolean;
|
|
15
|
+
/** Glyph override; defaults to the plus. The glyph stays 16px — the
|
|
16
|
+
* glyph size is part of the cluster's geometry, not a page's choice. */
|
|
17
|
+
icon?: Component;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The standard CREATE affordance of the page-chrome grammar
|
|
21
|
+
* (`design/page-chrome.md`, the create rule): a page's primary create
|
|
22
|
+
* action is a plus icon button in the shell header's top-right cluster —
|
|
23
|
+
* never a standalone button inside the page body.
|
|
24
|
+
*
|
|
25
|
+
* The visible label the in-page button used to carry becomes the button's
|
|
26
|
+
* accessible name (`aria-label`) and tooltip (`title`). The page keeps
|
|
27
|
+
* owning its own dialog: this composable registers the button only, and
|
|
28
|
+
* `onCreate` is what opens that dialog.
|
|
29
|
+
*
|
|
30
|
+
* Geometry is deliberately identical to `usePageRefresh`'s — an
|
|
31
|
+
* `HkIconButton` on the `useChromeActionSize` ladder with a 16px glyph — so
|
|
32
|
+
* the cluster reads as one row of chrome. The registration declares the
|
|
33
|
+
* Create slot, whose canonical rank (the rank table in `useActionBar.ts`)
|
|
34
|
+
* places the plus leftmost no matter which composable the view calls first:
|
|
35
|
+
* [create][filter?][search][refresh][window].
|
|
36
|
+
*
|
|
37
|
+
* Call once from a view's (or card's) setup; the registration dies with
|
|
38
|
+
* that scope, so leaving the page — or switching the tab that mounted the
|
|
39
|
+
* card — clears the button. Outside any action-bar provider the call is a
|
|
40
|
+
* silent no-op (`useActionBar`'s contract).
|
|
41
|
+
*/
|
|
42
|
+
export declare function usePageCreateAction(options: UsePageCreateActionOptions): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
/** What a page passes to `usePageRefresh` beside its refresh callback. */
|
|
3
|
+
export interface UsePageRefreshOptions {
|
|
4
|
+
/** True while the page's fetch is in flight — the button DISABLES, so a
|
|
5
|
+
* second click cannot stack a second fetch, and re-enables when the ref
|
|
6
|
+
* clears. */
|
|
7
|
+
loading?: Ref<boolean>;
|
|
8
|
+
/** Accessible label override; defaults to the localized "Refresh"
|
|
9
|
+
* (`hikari::pageActions.refresh`). */
|
|
10
|
+
label?: string;
|
|
11
|
+
/** False hides the button entirely (the renderer emits nothing) — for
|
|
12
|
+
* views whose refresh belongs to ONE stage/mode of a longer-lived
|
|
13
|
+
* component. Evaluated on every header render, so flipping the stage
|
|
14
|
+
* shows/hides the button reactively; the per-scope registration
|
|
15
|
+
* contract is unchanged. */
|
|
16
|
+
visible?: () => boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The standard REFRESH affordance of the page-chrome grammar
|
|
20
|
+
* (`design/page-chrome.md`): THE refresh button of a page, registered in
|
|
21
|
+
* the Refresh slot of the shell header's top-right cluster — the same slot
|
|
22
|
+
* the theme toggle lives in, and the same button geometry (an `HkIconButton`
|
|
23
|
+
* on the `useChromeActionSize` ladder with a 16px glyph). A page either
|
|
24
|
+
* has a refresh, and it is HERE, or it has none: an in-body refresh button
|
|
25
|
+
* beside it is a second source for one verb.
|
|
26
|
+
*
|
|
27
|
+
* The slot's canonical rank (the rank table in `useActionBar.ts`) seats the
|
|
28
|
+
* button right of the search and left of the window opener regardless of
|
|
29
|
+
* the order the page registered its affordances in:
|
|
30
|
+
* [create][filter?][search][refresh][window].
|
|
31
|
+
*
|
|
32
|
+
* Call once from a view's setup; the registration dies with the view's
|
|
33
|
+
* scope (`useActionBar`'s per-scope contract), so switching pages clears
|
|
34
|
+
* the button automatically. Outside any action-bar provider the call is a
|
|
35
|
+
* silent no-op.
|
|
36
|
+
*/
|
|
37
|
+
export declare function usePageRefresh(refresh: () => unknown, options?: UsePageRefreshOptions): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ComputedRef, type Ref } from "vue";
|
|
2
|
+
/** What a page passes to `usePageSearch`. */
|
|
3
|
+
export interface UsePageSearchOptions {
|
|
4
|
+
/** Accessible label / sheet title; defaults to `HkSearchTrigger`'s own
|
|
5
|
+
* localized "Search". */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Input placeholder; defaults to the localized "Search…". */
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
/** Commit debounce while typing, ms (`HkSearchTrigger`'s own default is
|
|
10
|
+
* 300; Enter commits immediately). */
|
|
11
|
+
debounce?: number;
|
|
12
|
+
/** Drafts shorter than this never commit (`HkSearchTrigger`'s own
|
|
13
|
+
* default is 1; 0 disables the floor). */
|
|
14
|
+
minLength?: number;
|
|
15
|
+
/** Initial keyword (deep-link restore); default "". */
|
|
16
|
+
initial?: string;
|
|
17
|
+
/** False hides the trigger entirely (evaluated on every header render) —
|
|
18
|
+
* for keep-mounted panes that must not show their search chrome while
|
|
19
|
+
* another pane is active. */
|
|
20
|
+
visible?: () => boolean;
|
|
21
|
+
}
|
|
22
|
+
/** What `usePageSearch` hands back: the page's keyword model. */
|
|
23
|
+
export interface UsePageSearchReturn {
|
|
24
|
+
/** The trimmed active keyword ("" = none). Reactive. */
|
|
25
|
+
search: ComputedRef<string>;
|
|
26
|
+
/** The raw keyword ref, for hosts that need to write it directly. */
|
|
27
|
+
keyword: Ref<string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The standard SEARCH affordance of the page-chrome grammar
|
|
31
|
+
* (`design/page-chrome.md`) — the search-behaviour half of a list page.
|
|
32
|
+
* One trigger (hikari's `HkSearchTrigger`, the chrome twin of the filter
|
|
33
|
+
* trigger) registered in the Search slot of the shell header's top-right
|
|
34
|
+
* cluster, one keyword namespace: the page decides WHAT the keyword
|
|
35
|
+
* matches (its fetcher maps it onto its own query params), the trigger
|
|
36
|
+
* decides HOW search behaves (draft panel, debounce, clear,
|
|
37
|
+
* commit-on-close).
|
|
38
|
+
*
|
|
39
|
+
* The cluster orders itself by slot rank, so the order this composable is
|
|
40
|
+
* called in relative to `usePageCreateAction` / `usePageRefresh` does not
|
|
41
|
+
* matter — the header reads [create][filter?][search][refresh][window].
|
|
42
|
+
*
|
|
43
|
+
* const { search } = usePageSearch();
|
|
44
|
+
* const rows = useTableFetch(fetcher, { params: () => ({ search: search.value }) });
|
|
45
|
+
*
|
|
46
|
+
* The returned `search` is the TRIMMED keyword ("" = none) — feed it into
|
|
47
|
+
* the page's query params. The model is two-way: a commit from the trigger
|
|
48
|
+
* (typed, pasted or cleared) writes `keyword`, and a host that writes
|
|
49
|
+
* `keyword` itself re-renders the trigger with the new active keyword.
|
|
50
|
+
*
|
|
51
|
+
* Call once from a view's setup; the registration dies with that scope
|
|
52
|
+
* (`useActionBar`'s per-scope contract). Outside any action-bar provider
|
|
53
|
+
* the registration is a silent no-op and the keyword model still works.
|
|
54
|
+
*/
|
|
55
|
+
export declare function usePageSearch(options?: UsePageSearchOptions): UsePageSearchReturn;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -249,6 +249,12 @@ export { provideActionBar, useActionBar, PageActionSlot, orderActionRegistration
|
|
|
249
249
|
export { useActionBarCenter } from "./composables/useActionBar";
|
|
250
250
|
export type { ActionBarRenderer, PageActionSlotValue, ActionBarRegistration } from "./composables/useActionBar";
|
|
251
251
|
export { useChromeActionSize } from "./composables/useChromeActionSize";
|
|
252
|
+
export { usePageCreateAction } from "./composables/usePageCreateAction";
|
|
253
|
+
export type { UsePageCreateActionOptions } from "./composables/usePageCreateAction";
|
|
254
|
+
export { usePageRefresh } from "./composables/usePageRefresh";
|
|
255
|
+
export type { UsePageRefreshOptions } from "./composables/usePageRefresh";
|
|
256
|
+
export { usePageSearch } from "./composables/usePageSearch";
|
|
257
|
+
export type { UsePageSearchOptions, UsePageSearchReturn } from "./composables/usePageSearch";
|
|
252
258
|
export { leadingZeroBits, sha256, solvePow, solvePowSync, verifyPow } from "./utils/pow";
|
|
253
259
|
export type { PowChallenge, PowSolution } from "./utils/pow";
|
|
254
260
|
export { HkLocalePicker as HLocalePicker } from "./components/HkLocalePicker";
|
|
@@ -478,7 +484,7 @@ export { HkAdminShell as HkAdminShell } from "./components/HkAdminShell";
|
|
|
478
484
|
export { HkFaceShell as HkFaceShell } from "./components/HkFaceShell";
|
|
479
485
|
export type { HkFaceShellHeaderSlot, HkFaceShellSidebarSlot, HkFaceShellUserPanelSlot, HkFaceShellSlots } from "./components/HkFaceShell";
|
|
480
486
|
export { HkAdminHeader as HkAdminHeader } from "./components/HkAdminHeader";
|
|
481
|
-
export type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot } from "./components/HkAdminHeader";
|
|
487
|
+
export type { HkAdminHeaderAvatarModalSlot, HkAdminHeaderLocalePickerSlot, HkAdminHeaderSlots, HkAdminHeaderUserMenuExtraSlot, HkAdminHeaderUserMenuItemsSlot } from "./components/HkAdminHeader";
|
|
482
488
|
export { HkAvatarButton as HkAvatarButton } from "./components/HkAvatarButton";
|
|
483
489
|
export { HkNavSidebar as HkNavSidebar } from "./components/HkNavSidebar";
|
|
484
490
|
export { HkThemeToggle as HkThemeToggle } from "./components/HkThemeToggle";
|
package/package.json
CHANGED
|
@@ -17,6 +17,17 @@ interface MenuItemStub {
|
|
|
17
17
|
// wiring row clicks to the select handler; the rest of hikari stays
|
|
18
18
|
// real. The select handler reaches the stub through attrs (it is not
|
|
19
19
|
// re-declared as an emit, which would strip it from props).
|
|
20
|
+
//
|
|
21
|
+
// The stub honours HkMenu's root-level `before-item` hook the same way
|
|
22
|
+
// the real menu does (its nodes land right before each ROOT row; child
|
|
23
|
+
// rows live in their own level upstream and never see it), so the
|
|
24
|
+
// header's splice WIRING is observable here (comment-gate-ok: wiring
|
|
25
|
+
// only — the real splice geometry is pinned by MUT:M1/M2/M6 in
|
|
26
|
+
// HkMenu.test.ts and by the real-menu pins in
|
|
27
|
+
// HkAdminHeader.userMenuItems.test.tsx). It mirrors the call
|
|
28
|
+
// convention only — the real splice geometry is pinned in HkMenu.test.ts
|
|
29
|
+
// and, with the real menu under this real header, in
|
|
30
|
+
// HkAdminHeader.userMenuItems.test.tsx.
|
|
20
31
|
vi.mock("./HkMenu", async () => {
|
|
21
32
|
const { defineComponent, h } = await import("vue");
|
|
22
33
|
const { asPropType } = await import("../utils/typing");
|
|
@@ -31,8 +42,12 @@ vi.mock("./HkMenu", async () => {
|
|
|
31
42
|
return () => {
|
|
32
43
|
if (!props.open) return null;
|
|
33
44
|
const rows: ReturnType<typeof h>[] = [];
|
|
34
|
-
const
|
|
35
|
-
|
|
45
|
+
const beforeItem = slots["before-item"] as
|
|
46
|
+
| ((payload: { key: string }) => ReturnType<typeof h>[])
|
|
47
|
+
| undefined;
|
|
48
|
+
const flatten = (list: MenuItemStub[], root: boolean) => {
|
|
49
|
+
for (const item of list ?? []) {
|
|
50
|
+
if (root && beforeItem) rows.push(...beforeItem({ key: item.key }));
|
|
36
51
|
rows.push(
|
|
37
52
|
h(
|
|
38
53
|
"button",
|
|
@@ -49,11 +64,18 @@ vi.mock("./HkMenu", async () => {
|
|
|
49
64
|
item.label,
|
|
50
65
|
),
|
|
51
66
|
);
|
|
52
|
-
if (item.children?.length) flatten(item.children);
|
|
67
|
+
if (item.children?.length) flatten(item.children, false);
|
|
53
68
|
}
|
|
54
69
|
};
|
|
55
|
-
flatten(props.items);
|
|
56
|
-
|
|
70
|
+
flatten(props.items, true);
|
|
71
|
+
// The slot KEYS the header handed the menu, sorted — published as an
|
|
72
|
+
// attribute so a test can pin the slot SET itself (a carrier the
|
|
73
|
+
// header must not pass unasked), not only what the slots render.
|
|
74
|
+
const slotKeys = Object.keys(slots)
|
|
75
|
+
.filter((key) => !key.startsWith("_"))
|
|
76
|
+
.sort()
|
|
77
|
+
.join(" ");
|
|
78
|
+
return h("div", { class: "menu-stub", "data-slots": slotKeys }, [
|
|
57
79
|
...(slots.header?.() ?? []),
|
|
58
80
|
...rows,
|
|
59
81
|
...(slots.footer?.() ?? []),
|
|
@@ -78,7 +100,9 @@ import { HkAdminHeader } from "./HkAdminHeader";
|
|
|
78
100
|
* - an empty identity renders the signing-in placeholder + the
|
|
79
101
|
* force-sign-out escape row;
|
|
80
102
|
* - Language children carry checked state and emit localeSelect;
|
|
81
|
-
* - the goToFrontend row sits directly above logout
|
|
103
|
+
* - the goToFrontend row sits directly above logout;
|
|
104
|
+
* - host rows from `user-menu-items` sit between the built-in rows and
|
|
105
|
+
* logout (the splice wiring), `user-menu-extra` rows stay in the tail.
|
|
82
106
|
*
|
|
83
107
|
* (Repo test convention: raw createApp + container queries, no
|
|
84
108
|
* @vue/test-utils dependency.)
|
|
@@ -424,9 +448,14 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
|
|
|
424
448
|
// The replacement clause, pinned end to end: identity props AND the
|
|
425
449
|
// account carrier slots are ALL supplied, yet the branded header
|
|
426
450
|
// exposes no account trigger, no popup, and none of the slot bodies
|
|
427
|
-
// — the dropdown (and identity / user-menu-extra /
|
|
428
|
-
// locale-picker inside it) does not mount at all
|
|
429
|
-
//
|
|
451
|
+
// — the dropdown (and identity / user-menu-extra / user-menu-items /
|
|
452
|
+
// avatar-modal / locale-picker inside it) does not mount at all
|
|
453
|
+
// (MUT:M4 — a host-supplied user-menu-items row renders, so the
|
|
454
|
+
// wiring exists; the branded face mounts no menu to carry it).
|
|
455
|
+
// This is the pin that keeps a future edit from "helpfully" wiring
|
|
456
|
+
// the menu back. comment-gate-ok: user-menu-items rides that existing
|
|
457
|
+
// pin — with no dropdown mounted there is no splice carrier, and
|
|
458
|
+
// wiring the menu back is already red on the `header button` line.
|
|
430
459
|
const c = mount(headerNode({
|
|
431
460
|
title: "Providers",
|
|
432
461
|
username: "alice",
|
|
@@ -436,6 +465,7 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
|
|
|
436
465
|
}, {
|
|
437
466
|
identity: () => h("div", { class: "host-identity" }, "host identity"),
|
|
438
467
|
"user-menu-extra": () => h("div", { class: "host-extra" }, "host extra"),
|
|
468
|
+
"user-menu-items": () => h("div", { class: "host-items" }, "host items"),
|
|
439
469
|
"avatar-modal": () => h("div", { class: "host-modal" }, "host modal"),
|
|
440
470
|
"locale-picker": () => h("div", { class: "host-locale" }, "host locale"),
|
|
441
471
|
}));
|
|
@@ -447,6 +477,7 @@ describe("HkAdminHeader brand slot (opt-in site mark)", () => {
|
|
|
447
477
|
// ...and none of the account carrier slots render their bodies.
|
|
448
478
|
expect(c.querySelector(".host-identity")).toBeNull();
|
|
449
479
|
expect(c.querySelector(".host-extra")).toBeNull();
|
|
480
|
+
expect(c.querySelector(".host-items")).toBeNull();
|
|
450
481
|
expect(c.querySelector(".host-modal")).toBeNull();
|
|
451
482
|
expect(c.querySelector(".host-locale")).toBeNull();
|
|
452
483
|
// The brand mark itself is the only thing the wing gained.
|
|
@@ -548,6 +579,108 @@ describe("HkAdminHeader host slots (L39 ruling-a revival)", () => {
|
|
|
548
579
|
expect(c.querySelector(".menu-stub")).toBeNull();
|
|
549
580
|
});
|
|
550
581
|
|
|
582
|
+
/** DOM order of the stub menu's rows = Tab order (every row is a native
|
|
583
|
+
* button): a built-in row's key, or `#label` for a host row. */
|
|
584
|
+
const rowOrder = (c: HTMLElement) =>
|
|
585
|
+
[...c.querySelectorAll<HTMLButtonElement>(".menu-stub button")].map(
|
|
586
|
+
(b) => b.dataset.key ?? `#${b.textContent}`,
|
|
587
|
+
);
|
|
588
|
+
|
|
589
|
+
const hostRow = (label: string, onClick?: () => void) =>
|
|
590
|
+
h("button", { class: "menu-stub-row host-item", type: "button", onClick }, label);
|
|
591
|
+
|
|
592
|
+
it("seats user-menu-items rows directly above logout, ahead of the user-menu-extra tail", async () => {
|
|
593
|
+
// MUT:M1 MUT:M2 MUT:M4: DOM order = Tab order = visual order — Avatar,
|
|
594
|
+
// Language, Account, <host rows>, Logout, <extra>. Host rows moved
|
|
595
|
+
// below logout (M1), repeated before every row (M2) or a dropped tail
|
|
596
|
+
// (M4) each change this list.
|
|
597
|
+
const c = mount(
|
|
598
|
+
headerNode({ localeOptions: LOCALES, goToFrontendLabel: "Account", logoutLabel: "Log out" }, {
|
|
599
|
+
"user-menu-items": ({ close }: { close?: () => void }) => [
|
|
600
|
+
hostRow("Change password", () => close?.()),
|
|
601
|
+
hostRow("Account center", () => close?.()),
|
|
602
|
+
],
|
|
603
|
+
"user-menu-extra": () => h("button", { class: "menu-stub-row extra-row", type: "button" }, "Host extra"),
|
|
604
|
+
}),
|
|
605
|
+
);
|
|
606
|
+
const menu = (await openMenu(c))!;
|
|
607
|
+
// The carrier: the menu receives `before-item` beside the two bands.
|
|
608
|
+
expect(menu.dataset.slots).toBe("before-item footer header");
|
|
609
|
+
expect(rowOrder(c)).toEqual([
|
|
610
|
+
"avatar",
|
|
611
|
+
"locale",
|
|
612
|
+
"locale:en",
|
|
613
|
+
"locale:zh-Hans",
|
|
614
|
+
"go-to-frontend",
|
|
615
|
+
"#Change password",
|
|
616
|
+
"#Account center",
|
|
617
|
+
"logout",
|
|
618
|
+
"#Host extra",
|
|
619
|
+
]);
|
|
620
|
+
// The payload's close() dismisses the dropdown on either host row — a
|
|
621
|
+
// navigating entry leaves no orphaned menu behind. MUT:M3
|
|
622
|
+
await click(c.querySelector(".host-item"));
|
|
623
|
+
expect(c.querySelector(".menu-stub")).toBeNull();
|
|
624
|
+
await openMenu(c);
|
|
625
|
+
await click(c.querySelectorAll(".host-item")[1]);
|
|
626
|
+
expect(c.querySelector(".menu-stub")).toBeNull();
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it("keeps logout the last row when only user-menu-items is supplied", async () => {
|
|
630
|
+
// MUT:M1 MUT:M2: host rows dropped below logout, or repeated before
|
|
631
|
+
// every row, both break this list.
|
|
632
|
+
const c = mount(headerNode({ logoutLabel: "Log out" }, {
|
|
633
|
+
"user-menu-items": () => hostRow("Change password"),
|
|
634
|
+
}));
|
|
635
|
+
await openMenu(c);
|
|
636
|
+
expect(rowOrder(c)).toEqual(["avatar", "#Change password", "logout"]);
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it("renders the exact previous rows when user-menu-items is not supplied", async () => {
|
|
640
|
+
// NEGATIVE CONTROL: a header without the slot hands the menu what it
|
|
641
|
+
// always did — the same row list with no node in between.
|
|
642
|
+
// MUT:M12: a stray node on the no-slot path shows up in this shape.
|
|
643
|
+
const c = mount(headerNode({ localeOptions: LOCALES, goToFrontendLabel: "Account", logoutLabel: "Log out" }));
|
|
644
|
+
const menu = (await openMenu(c))!;
|
|
645
|
+
expect(menuRows(c).map((r) => r.dataset.key)).toEqual([
|
|
646
|
+
"avatar",
|
|
647
|
+
"locale",
|
|
648
|
+
"locale:en",
|
|
649
|
+
"locale:zh-Hans",
|
|
650
|
+
"go-to-frontend",
|
|
651
|
+
"logout",
|
|
652
|
+
]);
|
|
653
|
+
expect([...menu.children].map((el) => el.className)).toEqual([
|
|
654
|
+
"s-user-header s-user-header--profile",
|
|
655
|
+
"menu-stub-row",
|
|
656
|
+
"menu-stub-row",
|
|
657
|
+
"menu-stub-row",
|
|
658
|
+
"menu-stub-row",
|
|
659
|
+
"menu-stub-row",
|
|
660
|
+
"menu-stub-row",
|
|
661
|
+
]);
|
|
662
|
+
// The slot SET is the exact previous one too: `before-item` travels
|
|
663
|
+
// only with the host slot, so a header without it adds no carrier —
|
|
664
|
+
// an always-forwarded hook renders nothing, which is why the DOM
|
|
665
|
+
// controls above cannot see it. MUT:before-item-unconditional
|
|
666
|
+
expect(menu.dataset.slots).toBe("footer header");
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
it("renders no user-menu-items rows in the pending-identity menu", async () => {
|
|
670
|
+
// The splice is keyed on the logout ROW, not on "the last row": the
|
|
671
|
+
// pending menu holds only the force-sign-out escape, and a host
|
|
672
|
+
// account row must not appear above it — account rows wait for an
|
|
673
|
+
// identity like every built-in action row. MUT:M13
|
|
674
|
+
const c = mount(
|
|
675
|
+
headerNode(
|
|
676
|
+
{ username: "", userEmail: "", signingInLabel: "Signing in…", onForceSignOut: () => {} },
|
|
677
|
+
{ "user-menu-items": () => hostRow("Change password") },
|
|
678
|
+
),
|
|
679
|
+
);
|
|
680
|
+
const menu = (await openMenu(c))!;
|
|
681
|
+
expect([...menu.querySelectorAll("button")].map((b) => b.dataset.key)).toEqual(["force-signout"]);
|
|
682
|
+
});
|
|
683
|
+
|
|
551
684
|
it("renders the locale-picker popup when the Language row is selected", async () => {
|
|
552
685
|
const c = mount(
|
|
553
686
|
headerNode(
|