@celestia-island/hikari 0.55.429 → 0.55.432
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/package.json
CHANGED
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
text-overflow: ellipsis;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
/* The trigger renders NO caret (2026-11-19): a facet chip reads as the
|
|
79
|
+
* same solid-surface family as the bespoke chips beside it, and the
|
|
80
|
+
* disclosure state rides aria-expanded. Host suffixes (a direction
|
|
81
|
+
* arrow) seat through renderChipTrailing and carry their own classes. */
|
|
82
82
|
|
|
83
83
|
.hk-filter-chip-body {
|
|
84
84
|
display: flex;
|
|
@@ -133,4 +133,123 @@ describe("HkFilterChip", () => {
|
|
|
133
133
|
expect(chipButton(c).className).toContain("hk-filter-chip--on");
|
|
134
134
|
expect(chipButton(c).getAttribute("aria-label")).toContain("OpenAI");
|
|
135
135
|
});
|
|
136
|
+
|
|
137
|
+
it("renders no caret — the facet chip reads as the solid-chip family", () => {
|
|
138
|
+
const c = mount(
|
|
139
|
+
h(HkFilterChip, { label: "Providers", allLabel: "All providers", options: OPTIONS }),
|
|
140
|
+
);
|
|
141
|
+
// The 2026-11-19 default: no affordance arrow beside the label (the
|
|
142
|
+
// bespoke chips of the wowsp bar carry none either); disclosure rides
|
|
143
|
+
// aria-expanded. Host suffixes seat through renderChipTrailing.
|
|
144
|
+
expect(chipButton(c).querySelector(".hk-filter-chip-caret")).toBeNull();
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("opens the popup at the lg pad step by default — a content panel, not a menu", async () => {
|
|
148
|
+
const open = ref(false);
|
|
149
|
+
const c = mountRendered(
|
|
150
|
+
() =>
|
|
151
|
+
h(HkFilterChip, {
|
|
152
|
+
label: "Providers",
|
|
153
|
+
allLabel: "All providers",
|
|
154
|
+
options: OPTIONS,
|
|
155
|
+
open: open.value,
|
|
156
|
+
"onUpdate:open": (v: boolean) => (open.value = v),
|
|
157
|
+
}),
|
|
158
|
+
);
|
|
159
|
+
chipButton(c).dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
|
160
|
+
await Promise.resolve();
|
|
161
|
+
await Promise.resolve();
|
|
162
|
+
// The shared container-pad token lands inline on the teleported panel
|
|
163
|
+
// at the lg step (16px) — the glass chrome's 4px menu-voice inset read
|
|
164
|
+
// cramped against the pill group.
|
|
165
|
+
const panel = document.body.querySelector<HTMLElement>(".hk-popover-panel")!;
|
|
166
|
+
expect(panel).toBeTruthy();
|
|
167
|
+
expect(panel.style.getPropertyValue("--hk-pad")).toBe("var(--space-16, 1rem)");
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it("chipText overrides the selection mirror on the trigger and in the aria name", () => {
|
|
171
|
+
// A range corridor is not a picked-label list: the host names it.
|
|
172
|
+
const c = mount(
|
|
173
|
+
h(HkFilterChip, {
|
|
174
|
+
label: "Tier",
|
|
175
|
+
allLabel: "All tiers",
|
|
176
|
+
chipText: "VI – ★",
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
expect(chipButton(c).querySelector(".hk-filter-chip-text")!.textContent).toBe("VI – ★");
|
|
180
|
+
// The override differs from the all-label: the state stays audible.
|
|
181
|
+
expect(chipButton(c).getAttribute("aria-label")).toBe("Tier: VI – ★");
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("seats the host's chip suffix (renderChipTrailing) after the text", () => {
|
|
185
|
+
const c = mount(
|
|
186
|
+
h(HkFilterChip, {
|
|
187
|
+
label: "Providers",
|
|
188
|
+
allLabel: "All providers",
|
|
189
|
+
options: OPTIONS,
|
|
190
|
+
renderChipTrailing: () => h("span", { class: "chip-arrow" }, "↑"),
|
|
191
|
+
}),
|
|
192
|
+
);
|
|
193
|
+
const arrow = chipButton(c).querySelector(".chip-arrow");
|
|
194
|
+
expect(arrow).toBeTruthy();
|
|
195
|
+
// After the text span: the suffix is the LAST element child.
|
|
196
|
+
expect(chipButton(c).lastElementChild).toBe(arrow);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("forwards renderPillTrailing to the pill group; null scopes the all-pill", async () => {
|
|
200
|
+
const scopes: Array<string | null> = [];
|
|
201
|
+
const c = mountRendered(
|
|
202
|
+
() =>
|
|
203
|
+
h(HkFilterChip, {
|
|
204
|
+
label: "Providers",
|
|
205
|
+
allLabel: "All providers",
|
|
206
|
+
options: OPTIONS,
|
|
207
|
+
selected: new Set(["openai"]),
|
|
208
|
+
open: true,
|
|
209
|
+
renderPillTrailing: (value) => {
|
|
210
|
+
scopes.push(value);
|
|
211
|
+
return h("span", { class: value === null ? "arrow-all" : "arrow-opt" }, "↑");
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
);
|
|
215
|
+
expect(document.body.querySelector(".hk-pill-group")).toBeTruthy();
|
|
216
|
+
// One call per rendered pill: the all-pill (null) plus each option.
|
|
217
|
+
expect(scopes).toEqual([null, "deepseek", "openai", "anthropic", "gemini"]);
|
|
218
|
+
// The all-pill arrow and exactly the option arrows rendered.
|
|
219
|
+
expect(document.body.querySelector(".arrow-all")).toBeTruthy();
|
|
220
|
+
const optArrows = document.body.querySelectorAll(".arrow-opt");
|
|
221
|
+
expect(optArrows.length).toBe(OPTIONS.length);
|
|
222
|
+
optArrows.forEach((arrow) => {
|
|
223
|
+
const pill = arrow.closest(".hk-pill-group-pill")!;
|
|
224
|
+
// The arrow seats after the label (the pill's last text node ends it).
|
|
225
|
+
expect(pill.textContent).toContain("↑");
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it("the default slot replaces the pill group; the hint still appends", async () => {
|
|
230
|
+
const open = ref(true);
|
|
231
|
+
mountRendered(
|
|
232
|
+
() =>
|
|
233
|
+
h(
|
|
234
|
+
HkFilterChip,
|
|
235
|
+
{
|
|
236
|
+
label: "Tier",
|
|
237
|
+
allLabel: "All tiers",
|
|
238
|
+
hint: "Drag either end",
|
|
239
|
+
open: open.value,
|
|
240
|
+
"onUpdate:open": (v: boolean) => (open.value = v),
|
|
241
|
+
},
|
|
242
|
+
{ default: () => h("div", { class: "custom-body" }, "slider lives here") },
|
|
243
|
+
),
|
|
244
|
+
);
|
|
245
|
+
await Promise.resolve();
|
|
246
|
+
await Promise.resolve();
|
|
247
|
+
// The host's body mounts in the slot's place — a range slider is not
|
|
248
|
+
// an option set — and the hint line still appends below it.
|
|
249
|
+
expect(document.body.querySelector(".custom-body")?.textContent).toBe("slider lives here");
|
|
250
|
+
expect(document.body.querySelector(".hk-pill-group")).toBeNull();
|
|
251
|
+
expect(document.body.querySelector(".hk-filter-chip-hint")?.textContent).toBe(
|
|
252
|
+
"Drag either end",
|
|
253
|
+
);
|
|
254
|
+
});
|
|
136
255
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { computed, defineComponent, ref, type PropType } from "vue";
|
|
2
|
-
import { ChevronDown } from "lucide-vue-next";
|
|
1
|
+
import { computed, defineComponent, ref, useAttrs, type PropType, type VNode } from "vue";
|
|
3
2
|
|
|
4
3
|
import HkPopover, { type PopupPlacement } from "./HkPopover";
|
|
5
4
|
import HkPillToggleGroup, { type HkPillToggleGroupOption } from "./HkPillToggleGroup";
|
|
5
|
+
import { hkPadStyle, type HkPad } from "../runtime/containerPad";
|
|
6
6
|
import "./HkFilterChip.scss";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -20,9 +20,40 @@ import "./HkFilterChip.scss";
|
|
|
20
20
|
* the selection: the all-label when nothing is picked, otherwise the
|
|
21
21
|
* picked labels in canonical option order (capped at three plus a +N
|
|
22
22
|
* tail, so a wide facet cannot blow up the chip strip's width).
|
|
23
|
+
*
|
|
24
|
+
* Customization (2026-11-19, the wowsp bar's full migration — every
|
|
25
|
+
* filter category of that strip now rides this one component):
|
|
26
|
+
*
|
|
27
|
+
* - The trigger drops the caret glyph. A facet chip reads as the same
|
|
28
|
+
* solid-surface family as every bespoke chip beside it (those carry
|
|
29
|
+
* no affordance arrow either — their arrows mark an ENGAGED sort);
|
|
30
|
+
* the disclosure state rides aria-expanded. Attrs fall through to
|
|
31
|
+
* the trigger (HkButton's contract), so hosts state-mark it with
|
|
32
|
+
* their own classes (wowsp's intermediate sort tint).
|
|
33
|
+
* - `padding` defaults to "lg": the popup is a CONTENT panel (pills,
|
|
34
|
+
* sliders, custom bodies), so it rides the shared container-pad
|
|
35
|
+
* token at the content step instead of the glass chrome's 4px
|
|
36
|
+
* menu-voice inset that left the pills breathing against the edge.
|
|
37
|
+
* - `chipText` overrides the selection mirror for hosts whose chip
|
|
38
|
+
* text is not a picked-label list (a range corridor reads "VI – ★").
|
|
39
|
+
* - `renderChipTrailing` / `renderPillTrailing` seat the host's
|
|
40
|
+
* direction arrows: inside the trigger, and after each popup pill
|
|
41
|
+
* (null scopes the all-pill) — re-evaluated every render, so the
|
|
42
|
+
* arrows track the host's shared direction flag.
|
|
43
|
+
* - The default slot replaces the pill group for bodies that are not
|
|
44
|
+
* an option set (a dual-thumb corridor slider); the hint line still
|
|
45
|
+
* appends below when provided. `closeOnBackdrop` passes through for
|
|
46
|
+
* hosts that run a bar-level outside close with chip re-click
|
|
47
|
+
* switching on desktop.
|
|
23
48
|
*/
|
|
24
49
|
export default defineComponent({
|
|
25
50
|
name: "HkFilterChip",
|
|
51
|
+
/** Attrs land on the TRIGGER button (HkButton's fallthrough contract):
|
|
52
|
+
* the trigger is the chrome hosts style and state-mark, while the
|
|
53
|
+
* anchor span stays a bare layout wrapper. class/style are re-merged
|
|
54
|
+
* explicitly below — a bare spread would let attrs.class win the
|
|
55
|
+
* whole class list instead of compounding onto the chrome. */
|
|
56
|
+
inheritAttrs: false,
|
|
26
57
|
props: {
|
|
27
58
|
/** Popup title + the trigger's accessible name (the category). */
|
|
28
59
|
label: { type: String, required: true },
|
|
@@ -42,19 +73,44 @@ export default defineComponent({
|
|
|
42
73
|
* the facet's semantics (multi-select? radio? clears what?) are the
|
|
43
74
|
* host's story to tell. */
|
|
44
75
|
hint: { type: String, default: undefined },
|
|
76
|
+
/** Chip-label override — for hosts whose chip text is not the picked
|
|
77
|
+
* label list (a range corridor). Undefined keeps the mirror. */
|
|
78
|
+
chipText: { type: String, default: undefined },
|
|
79
|
+
/** The popup's content inset — the shared container-pad token
|
|
80
|
+
* (runtime/containerPad). Defaults to the lg content step: this panel
|
|
81
|
+
* hosts pills and sliders, not menu voices. */
|
|
82
|
+
padding: { type: String as PropType<HkPad>, default: "lg" },
|
|
83
|
+
/** HkPopover outside-close passthrough. Hosts that own a bar-level
|
|
84
|
+
* outside close (with chip re-click switching) turn it off where
|
|
85
|
+
* the two closes would fight; mobile keeps its scrim either way. */
|
|
86
|
+
closeOnBackdrop: { type: Boolean, default: true },
|
|
87
|
+
/** Trigger-suffix renderer — the seat for a host's direction arrow.
|
|
88
|
+
* Re-evaluated every render; render nothing while disengaged (an
|
|
89
|
+
* undefined return seats nothing — the disengaged state is the norm). */
|
|
90
|
+
renderChipTrailing: {
|
|
91
|
+
type: Function as PropType<() => VNode | undefined>,
|
|
92
|
+
default: undefined,
|
|
93
|
+
},
|
|
94
|
+
/** Popup pill-suffix renderer, forwarded to the pill group — a null
|
|
95
|
+
* value scopes the all-pill, a value scopes that option. Ignored
|
|
96
|
+
* while the default slot replaces the pill group. */
|
|
97
|
+
renderPillTrailing: {
|
|
98
|
+
type: Function as PropType<(value: string | null) => VNode | undefined>,
|
|
99
|
+
default: undefined,
|
|
100
|
+
},
|
|
45
101
|
},
|
|
46
102
|
emits: {
|
|
47
103
|
"update:open": (_v: boolean) => true,
|
|
48
104
|
toggle: (_value: string) => true,
|
|
49
105
|
all: () => true,
|
|
50
106
|
},
|
|
51
|
-
setup(props, { emit }) {
|
|
107
|
+
setup(props, { emit, slots, attrs }) {
|
|
52
108
|
const anchorRef = ref<HTMLElement | null>(null);
|
|
53
109
|
|
|
54
110
|
/** Picked options in canonical order — the chip label's source. */
|
|
55
111
|
const picked = computed(() => props.options.filter((o) => props.selected.has(o.value)));
|
|
56
112
|
|
|
57
|
-
const
|
|
113
|
+
const mirrored = computed(() => {
|
|
58
114
|
if (picked.value.length === 0) return props.allLabel;
|
|
59
115
|
const names = picked.value.map((o) => o.label);
|
|
60
116
|
const head = names.slice(0, 3).join(", ");
|
|
@@ -62,21 +118,32 @@ export default defineComponent({
|
|
|
62
118
|
return rest > 0 ? `${head} +${rest}` : head;
|
|
63
119
|
});
|
|
64
120
|
|
|
121
|
+
const chipText = computed(() => props.chipText ?? mirrored.value);
|
|
122
|
+
|
|
123
|
+
/** The accessible name carries the SAME text the eye sees once a
|
|
124
|
+
* selection (or a corridor override) engages — a bare category
|
|
125
|
+
* aria-label would mask the chip's visible state. */
|
|
126
|
+
const ariaLabel = computed(() =>
|
|
127
|
+
picked.value.length > 0 || (props.chipText != null && props.chipText !== props.allLabel)
|
|
128
|
+
? `${props.label}: ${chipText.value}`
|
|
129
|
+
: props.label,
|
|
130
|
+
);
|
|
131
|
+
|
|
65
132
|
return () => (
|
|
66
133
|
<span ref={anchorRef} class="hk-filter-chip-anchor">
|
|
67
134
|
<button
|
|
135
|
+
{...attrs}
|
|
68
136
|
type="button"
|
|
69
|
-
class={["hk-filter-chip", props.selected.size > 0 && "hk-filter-chip--on"]}
|
|
137
|
+
class={["hk-filter-chip", props.selected.size > 0 && "hk-filter-chip--on", attrs.class]}
|
|
138
|
+
style={attrs.style || undefined}
|
|
70
139
|
aria-haspopup="dialog"
|
|
71
140
|
aria-expanded={props.open ? "true" : "false"}
|
|
72
|
-
aria-label={
|
|
73
|
-
picked.value.length > 0 ? `${props.label}: ${chipText.value}` : props.label
|
|
74
|
-
}
|
|
141
|
+
aria-label={ariaLabel.value}
|
|
75
142
|
title={props.label}
|
|
76
143
|
onClick={() => emit("update:open", !props.open)}
|
|
77
144
|
>
|
|
78
145
|
<span class="hk-filter-chip-text">{chipText.value}</span>
|
|
79
|
-
|
|
146
|
+
{props.renderChipTrailing?.()}
|
|
80
147
|
</button>
|
|
81
148
|
<HkPopover
|
|
82
149
|
modelValue={props.open}
|
|
@@ -85,17 +152,24 @@ export default defineComponent({
|
|
|
85
152
|
placement={props.placement}
|
|
86
153
|
offset={6}
|
|
87
154
|
sheetOnMobile
|
|
155
|
+
closeOnBackdrop={props.closeOnBackdrop}
|
|
156
|
+
padding={props.padding}
|
|
88
157
|
title={props.label}
|
|
89
158
|
>
|
|
90
159
|
<div class="hk-filter-chip-body">
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
160
|
+
{slots.default ? (
|
|
161
|
+
slots.default()
|
|
162
|
+
) : (
|
|
163
|
+
<HkPillToggleGroup
|
|
164
|
+
label={props.label}
|
|
165
|
+
options={props.options}
|
|
166
|
+
selected={props.selected}
|
|
167
|
+
allLabel={props.allLabel}
|
|
168
|
+
renderTrailing={props.renderPillTrailing}
|
|
169
|
+
onToggle={(v: string) => emit("toggle", v)}
|
|
170
|
+
onAll={() => emit("all")}
|
|
171
|
+
/>
|
|
172
|
+
)}
|
|
99
173
|
{props.hint && <div class="hk-filter-chip-hint">{props.hint}</div>}
|
|
100
174
|
</div>
|
|
101
175
|
</HkPopover>
|
|
@@ -75,6 +75,17 @@ export default defineComponent({
|
|
|
75
75
|
/** The leading all-pill's label; omit to hide the all-pill. The pill
|
|
76
76
|
* wears the active tint exactly when nothing is picked. */
|
|
77
77
|
allLabel: { type: String, default: undefined },
|
|
78
|
+
/** Pill-suffix renderer (2026-11-19, the filter-chip sort arrows): one
|
|
79
|
+
* call per rendered pill — a null value scopes the ALL-pill, a value
|
|
80
|
+
* scopes that option — rendered UNWRAPPED after the label so the
|
|
81
|
+
* suffix carries its own classes (a direction arrow rides its lucide
|
|
82
|
+
* class; the pill's flex gap seats it). Re-evaluated every render: the
|
|
83
|
+
* host rebuilds the returned vnode when its state moves, nothing is
|
|
84
|
+
* cached here. */
|
|
85
|
+
renderTrailing: {
|
|
86
|
+
type: Function as PropType<(value: string | null) => VNode | undefined>,
|
|
87
|
+
default: undefined,
|
|
88
|
+
},
|
|
78
89
|
},
|
|
79
90
|
emits: {
|
|
80
91
|
toggle: (_value: string) => true,
|
|
@@ -101,6 +112,7 @@ export default defineComponent({
|
|
|
101
112
|
onClick={() => emit("all")}
|
|
102
113
|
>
|
|
103
114
|
{props.allLabel}
|
|
115
|
+
{props.renderTrailing?.(null)}
|
|
104
116
|
</button>
|
|
105
117
|
)}
|
|
106
118
|
{props.options.map((o) => {
|
|
@@ -117,6 +129,7 @@ export default defineComponent({
|
|
|
117
129
|
>
|
|
118
130
|
{icon != null && <span class="hk-pill-group-icon">{icon}</span>}
|
|
119
131
|
{o.label}
|
|
132
|
+
{props.renderTrailing?.(o.value)}
|
|
120
133
|
</button>
|
|
121
134
|
);
|
|
122
135
|
})}
|