@celestia-island/hikari 0.55.464 → 0.55.465

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.
@@ -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 (plus the overlay-scrollbar rail, which the
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
- * `onClose`) — a pane whose host cannot deselect has no button to press.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.464",
3
+ "version": "0.55.465",
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",
@@ -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
- max-width: 16rem;
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(
@@ -130,11 +130,28 @@
130
130
  padding: var(--hk-master-detail-detail-pad, var(--space-16, 1rem));
131
131
  }
132
132
 
133
- // The empty state must not collapse the pane to a sliver: a floor only
134
- // while nothing is selected (a real detail keeps its own height).
135
- // Gallery-hall geometry, not a layout rule for content.
133
+ // The empty state lives in the middle of the pane, both axes (2026-11-23
134
+ // user direction: the pick-a-message card is the pane's own content, so it
135
+ // belongs at the optical centre rather than pinned to the top edge). The
136
+ // body already fills the scroll region (flex: 1 1 auto against the pane's
137
+ // definite height), so centring here is enough; the floor keeps the card
138
+ // from collapsing the pane to a sliver on a short box.
136
139
  .hk-master-detail:not([data-open]) .hk-master-detail-detail-body {
137
140
  min-height: var(--hk-master-detail-empty-min-h, 14rem);
141
+ align-items: center;
142
+ }
143
+
144
+ // Vertical centring rides AUTO MARGINS on the empty state, not
145
+ // justify-content: a centred flex item overflowing a scroll container
146
+ // overflows on BOTH sides, and the top half is unreachable (a scrollport
147
+ // cannot scroll to a negative offset) — a pane near the floor plus a
148
+ // two-line description would clip the card's top edge. Auto margins centre
149
+ // while there is room and collapse to zero when there is not, so the
150
+ // overflow goes downward where the rail can reach it. Naming the part (not
151
+ // `> *`) keeps the rule out of the selection controls' mover table: it is
152
+ // the empty state being placed, not arbitrary children.
153
+ .hk-master-detail:not([data-open]) .hk-master-detail-detail-body > .hk-empty-state {
154
+ margin-block: auto;
138
155
  }
139
156
 
140
157
  // 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 $attrs, so the
36
- * detection is the component's own vnode props); the narrow form
37
- * forwards the MODAL's close as the pane's `close` emit;
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,6 +749,25 @@ 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
  });
@@ -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 (plus the overlay-scrollbar rail, which the
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
- * `onClose`) — a pane whose host cannot deselect has no button to press.
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 || hasCloseListener() ? (
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
- {hasCloseListener() ? (
310
+ {canClose() ? (
301
311
  <HkIconButton
302
312
  class="hk-master-detail-close"
303
313
  size={28}