@celestia-island/hikari 0.55.461 → 0.55.463

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 (31) hide show
  1. package/dist/types/components/HkAdminShell.d.ts +8 -0
  2. package/dist/types/components/HkFaceShell.d.ts +13 -0
  3. package/dist/types/components/HkMasterDetail.d.ts +201 -0
  4. package/dist/types/composables/useActionBar.d.ts +21 -0
  5. package/dist/types/index.d.ts +3 -0
  6. package/package.json +1 -1
  7. package/src/animation/registerAnimations.ts +7 -0
  8. package/src/components/HkAdminShell.centre.test.tsx +175 -0
  9. package/src/components/HkAdminShell.tsx +14 -0
  10. package/src/components/HkFaceShell.test.tsx +48 -1
  11. package/src/components/HkFaceShell.tsx +28 -0
  12. package/src/components/HkMasterDetail.scss +246 -0
  13. package/src/components/HkMasterDetail.ssr.test.tsx +82 -0
  14. package/src/components/HkMasterDetail.test.tsx +603 -0
  15. package/src/components/HkMasterDetail.tsx +294 -0
  16. package/src/components/HkSignInCard.test.ts +31 -0
  17. package/src/components/HkSignInCard.tsx +4 -1
  18. package/src/composables/useActionBar.ts +26 -0
  19. package/src/i18n/locales/ar/components.json +3 -1
  20. package/src/i18n/locales/de/components.json +3 -1
  21. package/src/i18n/locales/en/components.json +3 -1
  22. package/src/i18n/locales/es/components.json +3 -1
  23. package/src/i18n/locales/fr/components.json +3 -1
  24. package/src/i18n/locales/ja/components.json +3 -1
  25. package/src/i18n/locales/ko/components.json +3 -1
  26. package/src/i18n/locales/pt/components.json +3 -1
  27. package/src/i18n/locales/ru/components.json +3 -1
  28. package/src/i18n/locales/zh-Hans/components.json +3 -1
  29. package/src/i18n/locales/zh-Hant/components.json +3 -1
  30. package/src/index.ts +10 -0
  31. package/src/styles/admin-tokens.scss +10 -1
@@ -0,0 +1,246 @@
1
+ // HkMasterDetail — the standard two-pane roster+detail surface.
2
+ //
3
+ // One grid, two modes:
4
+ // wide (data-split="two"): [list][detail] in the tracks the props write
5
+ // narrow (data-split="single"): one full-width column; the detail pane
6
+ // becomes an overlay drawer over a scrim
7
+ //
8
+ // The surface declarations on the detail pane MIRROR HkCard's (surface
9
+ // blend + --border-subtle + --radius-lg + --shadow-elevated) rather than
10
+ // reusing its class: the pane is a column of a grid track that has to keep
11
+ // a rail-host box (position: relative) around its OWN scroll region, and
12
+ // .hk-card's single body slot cannot express that. Same chrome, one
13
+ // structure deeper, so the declarations are copied with the host hatch
14
+ // (--hk-card-blur) intact.
15
+
16
+ @use "../styles/polyfill" as *;
17
+
18
+ .hk-master-detail {
19
+ display: grid;
20
+ // The props write the two custom properties (listWidth / detailWidth);
21
+ // the fallbacks are the component's documented defaults, so a host that
22
+ // prefers pure CSS can drive the tracks through the same hooks.
23
+ grid-template-columns:
24
+ var(--hk-master-detail-list-w, minmax(360px, 1fr))
25
+ var(--hk-master-detail-detail-w, minmax(0, 1.15fr));
26
+ gap: var(--space-12, 0.75rem);
27
+ align-items: start;
28
+ min-width: 0;
29
+ }
30
+
31
+ // Below `splitAt` the component lifts the detail into its own layer; the
32
+ // roster takes the whole row. `align-items: start` keeps a short roster
33
+ // from stretching and gives the sticky pane the slack it needs to stick.
34
+ .hk-master-detail[data-split="single"] {
35
+ grid-template-columns: minmax(0, 1fr);
36
+ }
37
+
38
+ .hk-master-detail-list {
39
+ // Grid children default to min-content width: a table inside the roster
40
+ // would refuse to shrink below its widest cell. The track owns the
41
+ // width, the pane may overflow-scroll inside it.
42
+ min-width: 0;
43
+ }
44
+
45
+ .hk-master-detail-detail {
46
+ // The card, positioned: it is the overlay scrollbar RAIL's host (tracks
47
+ // are absolute children, so they must not live inside the scroller) and
48
+ // it clips its own rounded corners.
49
+ position: relative;
50
+ display: flex;
51
+ flex-direction: column;
52
+ align-self: start;
53
+ min-width: 0;
54
+ overflow: hidden;
55
+ // Opaque base first: color-mix() inside a var() fallback is VALID at
56
+ // parse time but resolves to unset (IACVT) on engines without it, so
57
+ // the tint must sit behind a feature query (the HkScrollPin lesson)
58
+ // rather than in a cascade that would keep a transparent background.
59
+ background: var(--hk-master-detail-bg, rgb(var(--color-surface) / 70%));
60
+ @include backdrop-filter(var(--hk-card-blur, blur(var(--blur-md))));
61
+ border: 1px solid var(--border-subtle);
62
+ border-radius: var(--radius-lg, 12px);
63
+ box-shadow: var(--shadow-elevated);
64
+ }
65
+
66
+ @supports (background: color-mix(in srgb, white 70%, transparent)) {
67
+ .hk-master-detail-detail {
68
+ // The SAME hook as the base rule: a host that retunes the tint keeps
69
+ // it on both sides of the feature query instead of silently reverting.
70
+ background: var(
71
+ --hk-master-detail-bg,
72
+ color-mix(in srgb, rgb(var(--color-surface)) 70%, transparent)
73
+ );
74
+ }
75
+ }
76
+
77
+ // The pane's own scroll region (native MECHANICS, the library's overlay
78
+ // chrome): a long detail never pushes the roster's column out of view. The
79
+ // native bar is suppressed here and the overlay rail is attached to the
80
+ // pane by the component (nativeScrollbar.contract.test.ts demands the
81
+ // scrollbar-width/::-webkit-scrollbar pair on every native scroll rule).
82
+ .hk-master-detail-detail-scroll {
83
+ display: flex;
84
+ flex-direction: column;
85
+ flex: 1 1 auto;
86
+ min-height: 0;
87
+ overflow: auto;
88
+ scrollbar-width: none;
89
+
90
+ &::-webkit-scrollbar {
91
+ display: none;
92
+ }
93
+ }
94
+
95
+ // Sticky is the HOST's declaration (data-sticky), the two-pane mode is
96
+ // where it applies: a fixed-position drawer is already out of the flow.
97
+ // --hk-master-detail-sticky-top lets a host with its own pinned chrome
98
+ // park the pane below it.
99
+ .hk-master-detail[data-split="two"] .hk-master-detail-detail[data-sticky] {
100
+ position: sticky;
101
+ top: var(--hk-master-detail-sticky-top, 0px);
102
+ // vh first, dvh where supported (the family's mobile-chrome rule): the
103
+ // pane must never exceed the viewport the browser shows.
104
+ max-height: var(--hk-master-detail-max-h, calc(100vh - var(--space-32, 2rem)));
105
+ max-height: var(--hk-master-detail-max-h, calc(100dvh - var(--space-32, 2rem)));
106
+ }
107
+
108
+ // The head band: title (drawer form), the host's header actions and the
109
+ // close affordance. Sticky INSIDE the pane's own scroll region, so a long
110
+ // detail never hides the way to dismiss it.
111
+ .hk-master-detail-detail-head {
112
+ position: sticky;
113
+ top: 0;
114
+ z-index: var(--hk-z-above, 1);
115
+ display: flex;
116
+ flex: none;
117
+ align-items: center;
118
+ gap: var(--space-8, 0.5rem);
119
+ padding: var(--space-12, 0.75rem)
120
+ var(--hk-master-detail-detail-pad, var(--space-16, 1rem));
121
+ border-bottom: 1px solid var(--border-faint);
122
+ // Scrolled content must never read through the band; the alpha + blur
123
+ // is HkScrollPin's floating-chrome recipe, not a solid slab.
124
+ background: rgb(var(--color-surface) / 92%);
125
+ @include backdrop-filter(blur(var(--blur-sm, 8px)));
126
+ }
127
+
128
+ .hk-master-detail-detail-title {
129
+ flex: 1 1 auto;
130
+ min-width: 0;
131
+ margin: 0;
132
+ color: rgb(var(--color-text));
133
+ font-size: var(--text-base, 0.875rem);
134
+ font-weight: 600;
135
+ white-space: nowrap;
136
+ overflow: hidden;
137
+ text-overflow: ellipsis;
138
+ }
139
+
140
+ .hk-master-detail-detail-actions {
141
+ display: flex;
142
+ flex: none;
143
+ align-items: center;
144
+ gap: var(--space-8, 0.5rem);
145
+ // Without the drawer-form title the actions still ride the band's
146
+ // trailing edge, beside the close affordance.
147
+ margin-inline-start: auto;
148
+ }
149
+
150
+ .hk-master-detail-detail-body {
151
+ display: flex;
152
+ flex-direction: column;
153
+ gap: var(--space-12, 0.75rem);
154
+ min-width: 0;
155
+ // The pane owns its inset so a detail slot needs no wrapper of its own;
156
+ // hosts that render a flush table set --hk-master-detail-detail-pad: 0.
157
+ padding: var(--hk-master-detail-detail-pad, var(--space-16, 1rem));
158
+ }
159
+
160
+ // The empty state must not collapse the pane to a title-sized sliver: a
161
+ // floor only while nothing is selected (a real detail keeps its own
162
+ // height). Gallery-hall geometry, not a layout rule for content.
163
+ .hk-master-detail:not([data-open]) .hk-master-detail-detail-body {
164
+ min-height: var(--hk-master-detail-empty-min-h, 14rem);
165
+ }
166
+
167
+ // ------
168
+ // Drawer form (single column): the SAME detail element, lifted out of the
169
+ // grid into a fixed panel on the physical right edge.
170
+ //
171
+ // HkDrawer is not reused here on purpose: its header owns the close
172
+ // affordance (closable is a single switch for both the button and
173
+ // Escape), which would put a second, hardcoded-label close beside the
174
+ // host's `closeLabel`/-detail-head close, and it teleports out of the
175
+ // page. The dismissal paths this pane needs are three small additions
176
+ // here, not a capture-semantics overlay: see the component doc.
177
+ // ------
178
+
179
+ .hk-master-detail-drawer {
180
+ position: fixed;
181
+ top: var(--hk-chrome-band-inset, 0px);
182
+ right: 0;
183
+ bottom: 0;
184
+ width: min(var(--hk-master-detail-drawer-w, 28rem), 92vw);
185
+ // Above the roster and its sticky chrome, below every teleported layer
186
+ // (--hk-z-float and up): the drawer is page chrome, not a window.
187
+ z-index: var(--hk-z-sidebar, 900);
188
+ border-radius: var(--radius-lg, 12px) 0 0 var(--radius-lg, 12px);
189
+ // Scope invalidation to the panel — the roster behind a phone drawer is
190
+ // usually streaming, and containment keeps the two from cascading.
191
+ contain: layout style;
192
+ animation: hk-master-detail-drawer-in var(--duration-normal, 0.3s)
193
+ var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
194
+ }
195
+
196
+ .hk-master-detail-scrim {
197
+ position: fixed;
198
+ top: var(--hk-chrome-band-inset, 0px);
199
+ right: 0;
200
+ bottom: 0;
201
+ left: 0;
202
+ // Same band as the panel: it paints first (DOM order), so the detail
203
+ // stays above its own veil without a second z arithmetic.
204
+ z-index: var(--hk-z-sidebar, 900);
205
+ // The drawer family's veil, so a host that retunes HkDrawer's overlay
206
+ // retunes this one too instead of inventing a second scrim colour.
207
+ background: var(
208
+ --hk-master-detail-scrim-bg,
209
+ var(--hk-drawer-overlay-bg, rgb(0 0 0 / 45%))
210
+ );
211
+ animation: hk-master-detail-scrim-in var(--duration-normal, 0.3s)
212
+ var(--ease-standard, cubic-bezier(0.4, 0, 0.2, 1));
213
+ }
214
+
215
+ @keyframes hk-master-detail-drawer-in {
216
+ from {
217
+ transform: translateX(100%);
218
+ }
219
+ to {
220
+ transform: translateX(0);
221
+ }
222
+ }
223
+
224
+ @keyframes hk-master-detail-scrim-in {
225
+ from {
226
+ opacity: 0;
227
+ }
228
+ to {
229
+ opacity: 1;
230
+ }
231
+ }
232
+
233
+ // Opt-outs: the host's global animation switch and the OS's reduced-motion
234
+ // preference both apply — an inline-less rule can carry the media query
235
+ // (the HkPaneHolder precedent), and neither may leave a panel mid-slide.
236
+ html[data-css-animations="0"] .hk-master-detail-drawer,
237
+ html[data-css-animations="0"] .hk-master-detail-scrim {
238
+ animation: none;
239
+ }
240
+
241
+ @media (prefers-reduced-motion: reduce) {
242
+ .hk-master-detail-drawer,
243
+ .hk-master-detail-scrim {
244
+ animation-duration: var(--duration-fast, 0.15s);
245
+ }
246
+ }
@@ -0,0 +1,82 @@
1
+ // @vitest-environment node
2
+ import { describe, expect, it } from "vitest";
3
+ import { createSSRApp, h } from "vue";
4
+ import { renderToString } from "@vue/server-renderer";
5
+
6
+ import { HkMasterDetail } from "./HkMasterDetail";
7
+
8
+ /**
9
+ * SSR gate for the master-detail pane.
10
+ *
11
+ * A host that server-renders its shell mounts this pane there first, and the
12
+ * node environment here means `window`, `document` and `matchMedia` do not
13
+ * exist: the assertions below cannot pass by accident.
14
+ *
15
+ * The split has no measurement on a server, so the component renders the WIDE
16
+ * layout (the same desktop assumption `useBreakpoint`'s own server fallback
17
+ * declares) instead of guessing at the drawer form and hydrating into a
18
+ * different tree. What this file pins is that the whole surface — grid, detail
19
+ * card, empty state and the overlay-scrollbar setup — is reachable without a
20
+ * DOM: a `window`/`document` read in setup or in the render function would
21
+ * throw here (the HkWallpaperBackdrop.ssr.test.ts precedent).
22
+ */
23
+ describe("HkMasterDetail on a server", () => {
24
+ it("renders the wide layout with the boxed empty state and no DOM globals", async () => {
25
+ expect(typeof globalThis.document).toBe("undefined");
26
+ expect(typeof globalThis.window).toBe("undefined");
27
+
28
+ const html = await renderToString(
29
+ createSSRApp({
30
+ render: () =>
31
+ h(
32
+ HkMasterDetail,
33
+ { detailOpen: false, detailTitle: "Message" },
34
+ {
35
+ list: () => h("div", { class: "roster" }, "ROSTER"),
36
+ detail: () => h("div", { class: "detail-payload" }, "DETAIL"),
37
+ },
38
+ ),
39
+ }),
40
+ );
41
+
42
+ expect(html).toContain('class="hk-master-detail"');
43
+ // No viewport to measure ⇒ the wide layout, never the drawer form.
44
+ // Dropping the `hasViewport` guard turns this assertion red — the
45
+ // server fallback (1024) sits below the default `splitAt` (1100)
46
+ // [MUT:hasviewport-guard-dropped].
47
+ expect(html).toContain('data-split="two"');
48
+ expect(html).not.toContain("hk-master-detail-drawer");
49
+ expect(html).not.toContain("hk-master-detail-scrim");
50
+ // Closed: the empty state stands in for the detail slot.
51
+ expect(html).toContain("hk-empty-state--boxed");
52
+ expect(html).toContain("Nothing selected");
53
+ expect(html).not.toContain("detail-payload");
54
+ expect(html).toContain("ROSTER");
55
+ // The region keeps its accessible name server-side.
56
+ expect(html).toContain('role="region"');
57
+ expect(html).toContain('aria-label="Message"');
58
+ });
59
+
60
+ it("renders a selected detail without the empty state", async () => {
61
+ const html = await renderToString(
62
+ createSSRApp({
63
+ render: () =>
64
+ h(
65
+ HkMasterDetail,
66
+ { detailOpen: true, detailTitle: "Message", onClose: () => {} },
67
+ {
68
+ list: () => h("div", { class: "roster" }, "ROSTER"),
69
+ detail: () => h("div", { class: "detail-payload" }, "DETAIL"),
70
+ },
71
+ ),
72
+ }),
73
+ );
74
+
75
+ expect(html).toContain("detail-payload");
76
+ expect(html).not.toContain("hk-empty-state");
77
+ // The close affordance renders from the bound listener even on a server
78
+ // pass (the detection reads the vnode props, not a DOM query).
79
+ expect(html).toContain("hk-master-detail-close");
80
+ expect(html).toContain('aria-label="Close"');
81
+ });
82
+ });