@celestia-island/hikari 0.55.464 → 0.55.467
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/HkMasterDetail.d.ts +6 -3
- package/package.json +1 -1
- package/src/components/HkHeaderPicker.scss +9 -1
- package/src/components/HkHeaderPicker.test.tsx +25 -0
- package/src/components/HkMasterDetail.scss +28 -6
- package/src/components/HkMasterDetail.test.tsx +108 -3
- package/src/components/HkMasterDetail.tsx +15 -5
|
@@ -58,13 +58,16 @@ export declare function resolveListWidth(width: string): string;
|
|
|
58
58
|
*
|
|
59
59
|
* The head band (`.hk-master-detail-detail-head`) carries the host's
|
|
60
60
|
* `actions` slot and the close affordance; it renders only when it has at
|
|
61
|
-
* least one of those
|
|
61
|
+
* least one of those — and the close affordance itself only while a detail
|
|
62
|
+
* is OPEN (a closed pane has nothing to dismiss). It also carries the
|
|
63
|
+
* overlay-scrollbar rail, which the
|
|
62
64
|
* component attaches to the pane over its own scroll region — native
|
|
63
65
|
* MECHANICS, the library's chrome).
|
|
64
66
|
*
|
|
65
67
|
* Emits `close` when the user dismisses the selection. The close
|
|
66
|
-
* affordance renders only when a listener is bound (`@close` /
|
|
67
|
-
*
|
|
68
|
+
* affordance renders only when a listener is bound (`@close` / `onClose`)
|
|
69
|
+
* AND a detail is open — a pane whose host cannot deselect has no button
|
|
70
|
+
* to press, and a closed pane has nothing to dismiss.
|
|
68
71
|
*
|
|
69
72
|
* ```tsx
|
|
70
73
|
* <HkMasterDetail
|
package/package.json
CHANGED
|
@@ -22,7 +22,15 @@
|
|
|
22
22
|
padding-inline: var(--space-12) var(--space-28);
|
|
23
23
|
font-size: var(--text-sm);
|
|
24
24
|
font-weight: 600;
|
|
25
|
-
|
|
25
|
+
/* The trigger hugs its label, capped so a long one cannot push the
|
|
26
|
+
* header's centre band around. The cap is a HOOK, not a constant: a
|
|
27
|
+
* host whose labels are legitimately long (a mailbox identity written
|
|
28
|
+
* "Name <address>", a document title) opts out with
|
|
29
|
+
* `--hk-header-picker-max-w: none` on the picker's own class instead of
|
|
30
|
+
* forking the component. That lifts the CAP only — a centre band with
|
|
31
|
+
* sibling groups can still squeeze (and ellipsise) the trigger, so `none`
|
|
32
|
+
* is not by itself a guarantee of full display. */
|
|
33
|
+
max-width: var(--hk-header-picker-max-w, 16rem);
|
|
26
34
|
/* Ghost chrome (2026-10-18 user direction: the top-centre dropdown
|
|
27
35
|
* must read like the bottom-centre platform pill — no field border,
|
|
28
36
|
* hover tint only). Mirrors HkButton's ghost variant. */
|
|
@@ -153,6 +153,31 @@ describe("HkHeaderPicker", () => {
|
|
|
153
153
|
expect(scss).toContain("background: var(--c-primary-light);");
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
it("lands a host class on the picker root, where the hook resolves", () => {
|
|
157
|
+
// The width hook is a custom property, so it must be settable on the
|
|
158
|
+
// element the host can reach: the picker's own ROOT. (A wrapper works
|
|
159
|
+
// too — custom properties inherit — but the root is the documented
|
|
160
|
+
// handle, and attrs fall through to it.)
|
|
161
|
+
const c = mountPicker(
|
|
162
|
+
{ modelValue: "a", options: [{ value: "a", label: "Ayane Test <someone@example.test>" }] },
|
|
163
|
+
{ class: "wide-picker" },
|
|
164
|
+
);
|
|
165
|
+
const root = c.querySelector(".hk-header-picker") as HTMLElement;
|
|
166
|
+
expect(root, "the picker root exists").toBeTruthy();
|
|
167
|
+
expect(root.classList.contains("wide-picker"), "the host class lands on it").toBe(true);
|
|
168
|
+
// …and the trigger the cap applies to lives inside it.
|
|
169
|
+
expect(root.querySelector(".hk-select-trigger.hk-header-picker-trigger")).toBeTruthy();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("keeps the trigger cap a hook so a host with long labels can opt out", () => {
|
|
173
|
+
// A "Name <address>" identity (or a document title) legitimately
|
|
174
|
+
// exceeds the band-friendly cap. The cap stays a tunable so the host
|
|
175
|
+
// widens its own picker instead of forking the component — and the
|
|
176
|
+
// family default is unchanged for everyone else.
|
|
177
|
+
const scss = readFileSync(join(here, "HkHeaderPicker.scss"), "utf-8");
|
|
178
|
+
expect(scss).toContain("max-width: var(--hk-header-picker-max-w, 16rem);");
|
|
179
|
+
});
|
|
180
|
+
|
|
156
181
|
it("disables the trigger when disabled", () => {
|
|
157
182
|
const c = mountPicker({ disabled: true }, {});
|
|
158
183
|
expect(
|
|
@@ -99,6 +99,11 @@
|
|
|
99
99
|
display: flex;
|
|
100
100
|
flex: none;
|
|
101
101
|
align-items: center;
|
|
102
|
+
// The band's contents park on the TRAILING edge: the actions slot and
|
|
103
|
+
// the close affordance are both "way out" controls, and a band holding
|
|
104
|
+
// only the ✕ must not leave it stranded at the reading text's first
|
|
105
|
+
// column (2026-11-23 field report).
|
|
106
|
+
justify-content: flex-end;
|
|
102
107
|
gap: var(--space-8, 0.5rem);
|
|
103
108
|
padding: var(--space-12, 0.75rem)
|
|
104
109
|
var(--hk-master-detail-detail-pad, var(--space-16, 1rem));
|
|
@@ -114,9 +119,9 @@
|
|
|
114
119
|
flex: none;
|
|
115
120
|
align-items: center;
|
|
116
121
|
gap: var(--space-8, 0.5rem);
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
|
|
122
|
+
// No auto margin here: the band itself parks its contents on the
|
|
123
|
+
// trailing edge, so the actions and the close affordance stay adjacent
|
|
124
|
+
// whether one of them is present or both are.
|
|
120
125
|
}
|
|
121
126
|
|
|
122
127
|
.hk-master-detail-detail-body {
|
|
@@ -130,11 +135,28 @@
|
|
|
130
135
|
padding: var(--hk-master-detail-detail-pad, var(--space-16, 1rem));
|
|
131
136
|
}
|
|
132
137
|
|
|
133
|
-
// The empty state
|
|
134
|
-
//
|
|
135
|
-
//
|
|
138
|
+
// The empty state lives in the middle of the pane, both axes (2026-11-23
|
|
139
|
+
// user direction: the pick-a-message card is the pane's own content, so it
|
|
140
|
+
// belongs at the optical centre rather than pinned to the top edge). The
|
|
141
|
+
// body already fills the scroll region (flex: 1 1 auto against the pane's
|
|
142
|
+
// definite height), so centring here is enough; the floor keeps the card
|
|
143
|
+
// from collapsing the pane to a sliver on a short box.
|
|
136
144
|
.hk-master-detail:not([data-open]) .hk-master-detail-detail-body {
|
|
137
145
|
min-height: var(--hk-master-detail-empty-min-h, 14rem);
|
|
146
|
+
align-items: center;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Vertical centring rides AUTO MARGINS on the empty state, not
|
|
150
|
+
// justify-content: a centred flex item overflowing a scroll container
|
|
151
|
+
// overflows on BOTH sides, and the top half is unreachable (a scrollport
|
|
152
|
+
// cannot scroll to a negative offset) — a pane near the floor plus a
|
|
153
|
+
// two-line description would clip the card's top edge. Auto margins centre
|
|
154
|
+
// while there is room and collapse to zero when there is not, so the
|
|
155
|
+
// overflow goes downward where the rail can reach it. Naming the part (not
|
|
156
|
+
// `> *`) keeps the rule out of the selection controls' mover table: it is
|
|
157
|
+
// the empty state being placed, not arbitrary children.
|
|
158
|
+
.hk-master-detail:not([data-open]) .hk-master-detail-detail-body > .hk-empty-state {
|
|
159
|
+
margin-block: auto;
|
|
138
160
|
}
|
|
139
161
|
|
|
140
162
|
// The narrow sheet's body shim: HkModal's body already insets; the
|
|
@@ -32,9 +32,10 @@ import { asIndexable } from "../utils/typing";
|
|
|
32
32
|
* `splitAt` and its boundary (>= is two-pane) — a hand-picked width in
|
|
33
33
|
* one test cannot see an off-by-one or a hardcoded 768;
|
|
34
34
|
* - the dismissal contract: the close affordance appears ONLY with a
|
|
35
|
-
* bound `onClose` (a declared emit is stripped from
|
|
36
|
-
* detection is the component's own vnode props
|
|
37
|
-
*
|
|
35
|
+
* bound `onClose` AND an open detail (a declared emit is stripped from
|
|
36
|
+
* $attrs, so the detection is the component's own vnode props — read
|
|
37
|
+
* per render, never through a dependency-free computed); the narrow
|
|
38
|
+
* form forwards the MODAL's close as the pane's `close` emit;
|
|
38
39
|
* - the scss contract (the flush column, the separator hairline, the
|
|
39
40
|
* scroll region's native-bar suppression) — a class-name-only test
|
|
40
41
|
* cannot see the layout rules that make the pane usable.
|
|
@@ -209,6 +210,81 @@ describe("HkMasterDetail — two-pane layout", () => {
|
|
|
209
210
|
expect(c.querySelector(".hk-master-detail-detail-head")).toBeNull();
|
|
210
211
|
});
|
|
211
212
|
|
|
213
|
+
it("hides the close affordance while nothing is selected", () => {
|
|
214
|
+
// A ✕ beside "pick a message" is a control with no subject: closed,
|
|
215
|
+
// the pane has nothing to dismiss, so the affordance and its head
|
|
216
|
+
// band stay away even though the host bound a listener.
|
|
217
|
+
setWidth(1280);
|
|
218
|
+
const closed = mount(
|
|
219
|
+
h(HkMasterDetail, { detailOpen: false, detailTitle: "Message", onClose: () => {} }, {
|
|
220
|
+
list: ROSTER,
|
|
221
|
+
detail: DETAIL,
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
expect(closed.querySelector(".hk-master-detail-close")).toBeNull();
|
|
225
|
+
expect(closed.querySelector(".hk-master-detail-detail-head")).toBeNull();
|
|
226
|
+
|
|
227
|
+
// …and it returns the moment a detail is open.
|
|
228
|
+
const open = mount(
|
|
229
|
+
h(HkMasterDetail, { detailOpen: true, detailTitle: "Message", onClose: () => {} }, {
|
|
230
|
+
list: ROSTER,
|
|
231
|
+
detail: DETAIL,
|
|
232
|
+
}),
|
|
233
|
+
);
|
|
234
|
+
expect(open.querySelector(".hk-master-detail-close")).toBeTruthy();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("keeps the actions band while closed (the affordance is not the whole band)", () => {
|
|
238
|
+
setWidth(1280);
|
|
239
|
+
const c = mount(
|
|
240
|
+
h(HkMasterDetail, { detailOpen: false, detailTitle: "Message", onClose: () => {} }, {
|
|
241
|
+
list: ROSTER,
|
|
242
|
+
detail: DETAIL,
|
|
243
|
+
actions: () => h("button", { class: "detail-action" }, "Refresh"),
|
|
244
|
+
}),
|
|
245
|
+
);
|
|
246
|
+
expect(c.querySelector(".hk-master-detail-detail-head .detail-action")).toBeTruthy();
|
|
247
|
+
expect(c.querySelector(".hk-master-detail-close")).toBeNull();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("follows a close channel bound AFTER mount for the wide affordance", async () => {
|
|
251
|
+
// Same untracked-read trap as the form selectors: a computed `&&`
|
|
252
|
+
// over the vnode props latches — and with no listener at first render
|
|
253
|
+
// it has no dependency at all, so even a detailOpen flip cannot
|
|
254
|
+
// re-run it. The ✕ must appear when the host binds later.
|
|
255
|
+
setWidth(1280);
|
|
256
|
+
const bound = ref(false);
|
|
257
|
+
const Wrapper = defineComponent({
|
|
258
|
+
setup() {
|
|
259
|
+
return () =>
|
|
260
|
+
h(
|
|
261
|
+
HkMasterDetail,
|
|
262
|
+
{
|
|
263
|
+
detailOpen: true,
|
|
264
|
+
detailTitle: "Message",
|
|
265
|
+
...(bound.value ? { onClose: () => {} } : {}),
|
|
266
|
+
},
|
|
267
|
+
{ list: ROSTER, detail: DETAIL },
|
|
268
|
+
);
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
const c = mount(h(Wrapper));
|
|
272
|
+
await nextTick();
|
|
273
|
+
expect(c.querySelector(".hk-master-detail-close")).toBeNull();
|
|
274
|
+
|
|
275
|
+
bound.value = true;
|
|
276
|
+
await nextTick();
|
|
277
|
+
await nextTick();
|
|
278
|
+
expect(c.querySelector(".hk-master-detail-close"), "the ✕ appears").toBeTruthy();
|
|
279
|
+
|
|
280
|
+
// …and disappears again when the host unbinds while the detail stays
|
|
281
|
+
// open (otherwise it is a button emitting into nobody).
|
|
282
|
+
bound.value = false;
|
|
283
|
+
await nextTick();
|
|
284
|
+
await nextTick();
|
|
285
|
+
expect(c.querySelector(".hk-master-detail-close"), "the ✕ leaves").toBeNull();
|
|
286
|
+
});
|
|
287
|
+
|
|
212
288
|
it("renders the actions slot ahead of the close affordance", async () => {
|
|
213
289
|
setWidth(1280);
|
|
214
290
|
const c = mount(
|
|
@@ -673,10 +749,39 @@ describe("HkMasterDetail — stylesheet contract", () => {
|
|
|
673
749
|
);
|
|
674
750
|
});
|
|
675
751
|
|
|
752
|
+
it("centres the empty state on both axes while nothing is selected", () => {
|
|
753
|
+
const emptyBody = ruleBody(css, ".hk-master-detail:not([data-open]) .hk-master-detail-detail-body");
|
|
754
|
+
expect(emptyBody).toContain("align-items: center");
|
|
755
|
+
expect(emptyBody).toContain("min-height: var(--hk-master-detail-empty-min-h, 14rem)");
|
|
756
|
+
// Vertical centring rides the child's auto margins — NOT
|
|
757
|
+
// justify-content: center, whose overflow splits above the scrollport
|
|
758
|
+
// where no scroll offset can reach it (the card's top would clip).
|
|
759
|
+
expect(emptyBody).not.toContain("justify-content: center");
|
|
760
|
+
expect(
|
|
761
|
+
ruleBody(
|
|
762
|
+
css,
|
|
763
|
+
".hk-master-detail:not([data-open]) .hk-master-detail-detail-body > .hk-empty-state",
|
|
764
|
+
),
|
|
765
|
+
).toContain("margin-block: auto");
|
|
766
|
+
// Centring needs the body to fill the scroll region, which is the base
|
|
767
|
+
// rule's job — a dropped flex there would leave the card at the top.
|
|
768
|
+
expect(ruleBody(css, ".hk-master-detail-detail-body")).toContain("flex: 1 1 auto");
|
|
769
|
+
});
|
|
770
|
+
|
|
676
771
|
it("gives the narrow in-flow column the whole width", () => {
|
|
677
772
|
expect(ruleBody(css, ".hk-master-detail-detail--column")).toContain("flex: 1");
|
|
678
773
|
});
|
|
679
774
|
|
|
775
|
+
it("parks the head band's contents on the trailing edge", () => {
|
|
776
|
+
// A band holding only the close affordance left the ✕ at the reading
|
|
777
|
+
// text's first column; both it and the actions slot belong on the way
|
|
778
|
+
// out edge.
|
|
779
|
+
const head = ruleBody(css, ".hk-master-detail-detail-head");
|
|
780
|
+
expect(head).toContain("justify-content: flex-end");
|
|
781
|
+
const actions = ruleBody(css, ".hk-master-detail-detail-actions");
|
|
782
|
+
expect(actions).not.toContain("margin-inline-start: auto");
|
|
783
|
+
});
|
|
784
|
+
|
|
680
785
|
it("keeps the head band pinned inside the pane's scroll", () => {
|
|
681
786
|
const head = ruleBody(css, ".hk-master-detail-detail-head");
|
|
682
787
|
expect(head).toContain("position: sticky");
|
|
@@ -97,13 +97,16 @@ export function resolveListWidth(width: string): string {
|
|
|
97
97
|
*
|
|
98
98
|
* The head band (`.hk-master-detail-detail-head`) carries the host's
|
|
99
99
|
* `actions` slot and the close affordance; it renders only when it has at
|
|
100
|
-
* least one of those
|
|
100
|
+
* least one of those — and the close affordance itself only while a detail
|
|
101
|
+
* is OPEN (a closed pane has nothing to dismiss). It also carries the
|
|
102
|
+
* overlay-scrollbar rail, which the
|
|
101
103
|
* component attaches to the pane over its own scroll region — native
|
|
102
104
|
* MECHANICS, the library's chrome).
|
|
103
105
|
*
|
|
104
106
|
* Emits `close` when the user dismisses the selection. The close
|
|
105
|
-
* affordance renders only when a listener is bound (`@close` /
|
|
106
|
-
*
|
|
107
|
+
* affordance renders only when a listener is bound (`@close` / `onClose`)
|
|
108
|
+
* AND a detail is open — a pane whose host cannot deselect has no button
|
|
109
|
+
* to press, and a closed pane has nothing to dismiss.
|
|
107
110
|
*
|
|
108
111
|
* ```tsx
|
|
109
112
|
* <HkMasterDetail
|
|
@@ -171,6 +174,13 @@ export const HkMasterDetail = defineComponent({
|
|
|
171
174
|
const closeLabel = computed(
|
|
172
175
|
() => props.closeLabel || t("hikari::masterDetail.close", "Close"),
|
|
173
176
|
);
|
|
177
|
+
/** The affordance exists only while a detail is open: closed, the pane
|
|
178
|
+
* shows the empty state and there is nothing to dismiss — a ✕ beside
|
|
179
|
+
* "pick a message" is a control with no subject. A plain function for
|
|
180
|
+
* the same reason the form selectors are (see above): `&&` short-
|
|
181
|
+
* circuits, so a host with no listener at first render would leave a
|
|
182
|
+
* dependency-free computed latched on `false` forever. */
|
|
183
|
+
const canClose = () => hasCloseListener() && props.detailOpen;
|
|
174
184
|
const emptyTitle = computed(
|
|
175
185
|
() => props.emptyTitle || t("hikari::masterDetail.emptyTitle", "Nothing selected"),
|
|
176
186
|
);
|
|
@@ -292,12 +302,12 @@ export const HkMasterDetail = defineComponent({
|
|
|
292
302
|
the native bar never paints — the library's scroll
|
|
293
303
|
contract (nativeScrollbar.contract.test.ts). */}
|
|
294
304
|
<div ref={scrollRef} class="hk-master-detail-detail-scroll">
|
|
295
|
-
{slots.actions ||
|
|
305
|
+
{slots.actions || canClose() ? (
|
|
296
306
|
<div class="hk-master-detail-detail-head">
|
|
297
307
|
{slots.actions ? (
|
|
298
308
|
<div class="hk-master-detail-detail-actions">{slots.actions()}</div>
|
|
299
309
|
) : null}
|
|
300
|
-
{
|
|
310
|
+
{canClose() ? (
|
|
301
311
|
<HkIconButton
|
|
302
312
|
class="hk-master-detail-close"
|
|
303
313
|
size={28}
|