@celestia-island/hikari 0.55.470 → 0.55.471
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
|
@@ -225,6 +225,40 @@ describe("HkHeaderPicker", () => {
|
|
|
225
225
|
expect(row.querySelector(".hk-header-picker-option-group .hk-tag")).toBeTruthy();
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
it("mirrors the option's tags on the trigger", () => {
|
|
229
|
+
// A picker whose rows are chips but whose trigger is plain text reads
|
|
230
|
+
// as two different controls: the closed state must show the SAME two
|
|
231
|
+
// tags the row does.
|
|
232
|
+
const c = mountPicker(
|
|
233
|
+
{
|
|
234
|
+
modelValue: "a@example.test",
|
|
235
|
+
options: [
|
|
236
|
+
{
|
|
237
|
+
value: "a@example.test",
|
|
238
|
+
label: "a@example.test",
|
|
239
|
+
labelTag: true,
|
|
240
|
+
badge: "personal",
|
|
241
|
+
badgeVariant: "primary",
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
{},
|
|
246
|
+
);
|
|
247
|
+
const value = c.querySelector(".hk-header-picker-trigger .hk-select-value")!;
|
|
248
|
+
const tags = Array.from(value.querySelectorAll(".hk-tag"));
|
|
249
|
+
expect(tags.length, "label tag plus badge, in the trigger").toBe(2);
|
|
250
|
+
expect(tags[0].textContent?.trim()).toBe("a@example.test");
|
|
251
|
+
expect(tags[1].textContent?.trim()).toBe("personal");
|
|
252
|
+
expect(tags[1].className).toContain("hk-tag-primary");
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it("keeps the trigger plain when the option asks for no tags", () => {
|
|
256
|
+
const c = mountPicker({}, {});
|
|
257
|
+
const value = c.querySelector(".hk-header-picker-trigger .hk-select-value")!;
|
|
258
|
+
expect(value.querySelector(".hk-tag")).toBeNull();
|
|
259
|
+
expect(value.textContent?.trim()).toBe("Hub One");
|
|
260
|
+
});
|
|
261
|
+
|
|
228
262
|
it("disables the trigger when disabled", () => {
|
|
229
263
|
const c = mountPicker({ disabled: true }, {});
|
|
230
264
|
expect(
|
|
@@ -120,6 +120,11 @@ export default defineComponent({
|
|
|
120
120
|
|
|
121
121
|
const options = computed(() => props.options ?? []);
|
|
122
122
|
|
|
123
|
+
/** The chosen option, whose tag flags the trigger mirrors. */
|
|
124
|
+
const selected = computed(() =>
|
|
125
|
+
options.value.find((o) => o.value === props.modelValue),
|
|
126
|
+
);
|
|
127
|
+
|
|
123
128
|
const displayLabel = computed(() => {
|
|
124
129
|
if (!props.modelValue) return props.placeholder || "";
|
|
125
130
|
return (
|
|
@@ -318,7 +323,18 @@ export default defineComponent({
|
|
|
318
323
|
onClick={toggle}
|
|
319
324
|
onKeydown={onTriggerKeydown}
|
|
320
325
|
>
|
|
321
|
-
<span class="hk-select-value">
|
|
326
|
+
<span class="hk-select-value">
|
|
327
|
+
{selected.value?.labelTag && displayLabel.value ? (
|
|
328
|
+
<HkTag size="sm">{displayLabel.value}</HkTag>
|
|
329
|
+
) : (
|
|
330
|
+
displayLabel.value || props.placeholder
|
|
331
|
+
)}
|
|
332
|
+
{selected.value?.badge ? (
|
|
333
|
+
<HkTag size="sm" variant={selected.value.badgeVariant ?? "default"}>
|
|
334
|
+
{selected.value.badge}
|
|
335
|
+
</HkTag>
|
|
336
|
+
) : null}
|
|
337
|
+
</span>
|
|
322
338
|
<ChevronDown size={16} class="hk-select-arrow" />
|
|
323
339
|
</button>
|
|
324
340
|
<HkSelectPanel
|