@celestia-island/hikari 0.55.80 → 0.55.81
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 +1 -1
- package/src/components/HkAdminTablePage.tsx +2 -2
- package/src/components/HkCardList.tsx +1 -1
- package/src/components/HkIconChip.tsx +1 -1
- package/src/components/HkIconPropFunction.test.tsx +48 -0
- package/src/components/HkPageHeader.tsx +1 -1
- package/src/components/HkSectionHeader.tsx +1 -1
- package/src/components/HkStatCard.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, type PropType } from "vue";
|
|
1
|
+
import { defineComponent, type Component, type PropType } from "vue";
|
|
2
2
|
import { HAlert, HCard, HEmptyState, HSpinner, HTable, useI18n } from "@celestia-island/hikari";
|
|
3
3
|
import { HkPageHeader } from "./HkPageHeader";
|
|
4
4
|
|
|
@@ -34,7 +34,7 @@ export const HkAdminTablePage = defineComponent({
|
|
|
34
34
|
/** Forwarded to the page header. */
|
|
35
35
|
subtitle: { type: String, default: undefined },
|
|
36
36
|
/** Forwarded to the page header. */
|
|
37
|
-
icon: { type: Object, default: undefined },
|
|
37
|
+
icon: { type: [Object, Function] as PropType<Component>, default: undefined },
|
|
38
38
|
/** Compact page header variant. */
|
|
39
39
|
dense: { type: Boolean, default: false },
|
|
40
40
|
loading: { type: Boolean, default: false },
|
|
@@ -70,7 +70,7 @@ export const HkListRow = defineComponent({
|
|
|
70
70
|
name: "HkListRow",
|
|
71
71
|
props: {
|
|
72
72
|
/** Leading icon — rendered through the standard HkIconChip. */
|
|
73
|
-
icon: { type: Object as PropType<Component>, default: undefined },
|
|
73
|
+
icon: { type: [Object, Function] as PropType<Component>, default: undefined },
|
|
74
74
|
iconTone: { type: String as PropType<StatTone>, default: "primary" },
|
|
75
75
|
title: { type: String, default: undefined },
|
|
76
76
|
subtitle: { type: String, default: undefined },
|
|
@@ -23,7 +23,7 @@ export const HkIconChip = defineComponent({
|
|
|
23
23
|
name: "HkIconChip",
|
|
24
24
|
props: {
|
|
25
25
|
/** Icon component (lucide-vue-next style). */
|
|
26
|
-
icon: { type: Object as PropType<Component>, required: true },
|
|
26
|
+
icon: { type: [Object, Function] as PropType<Component>, required: true },
|
|
27
27
|
/** Tone drives both the tint background and the glyph ink. */
|
|
28
28
|
tone: { type: String as PropType<StatTone>, default: "primary" },
|
|
29
29
|
/** sm = 24px box / 13px glyph, md = 28px box / 15px glyph. */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createApp, defineComponent, h } from "vue";
|
|
3
|
+
|
|
4
|
+
import { HkIconChip } from "./HkIconChip";
|
|
5
|
+
import { HkPageHeader } from "./HkPageHeader";
|
|
6
|
+
import { HkSectionHeader } from "./HkSectionHeader";
|
|
7
|
+
import { HkStatCard } from "./HkStatCard";
|
|
8
|
+
|
|
9
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
10
|
+
|
|
11
|
+
function mount(node: ReturnType<typeof h>) {
|
|
12
|
+
const container = document.createElement("div");
|
|
13
|
+
document.body.appendChild(container);
|
|
14
|
+
const app = createApp({ render: () => node });
|
|
15
|
+
app.mount(container);
|
|
16
|
+
mounts.push({ app, container });
|
|
17
|
+
return container;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
for (const { app, container } of mounts.splice(0)) {
|
|
22
|
+
app.unmount();
|
|
23
|
+
container.remove();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/** A lucide-vue-next style icon: a plain functional component. */
|
|
28
|
+
const FnIcon = (_props: { size?: number }, _ctx: unknown) =>
|
|
29
|
+
h("svg", { "data-fn-icon": "" });
|
|
30
|
+
|
|
31
|
+
const FnIconComponent = defineComponent({
|
|
32
|
+
name: "FnIcon",
|
|
33
|
+
setup: () => () => h("svg", { "data-fn-icon": "" }),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe("icon props accept functional components", () => {
|
|
37
|
+
it("renders lucide-style functional icons without the Invalid-prop warning", () => {
|
|
38
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
39
|
+
mount(h(HkIconChip, { icon: FnIconComponent as never }));
|
|
40
|
+
mount(h(HkStatCard, { variant: "chip", value: 1, label: "L", icon: FnIconComponent as never }));
|
|
41
|
+
mount(h(HkPageHeader, { title: "T", icon: FnIconComponent as never }));
|
|
42
|
+
mount(h(HkSectionHeader, { title: "T", icon: FnIconComponent as never }));
|
|
43
|
+
const invalid = warn.mock.calls.filter((c) => String(c[0]).includes("Invalid prop"));
|
|
44
|
+
expect(invalid).toEqual([]);
|
|
45
|
+
expect(document.querySelectorAll("[data-fn-icon]")).toBeTruthy();
|
|
46
|
+
warn.mockRestore();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -22,7 +22,7 @@ export const HkPageHeader = defineComponent({
|
|
|
22
22
|
title: { type: String, required: true },
|
|
23
23
|
subtitle: { type: String, default: undefined },
|
|
24
24
|
/** Leading icon component (rendered before the title text). */
|
|
25
|
-
icon: { type: Object as PropType<Component>, default: undefined },
|
|
25
|
+
icon: { type: [Object, Function] as PropType<Component>, default: undefined },
|
|
26
26
|
/** Compact variant for dense pages (smaller title, tighter spacing). */
|
|
27
27
|
dense: { type: Boolean, default: false },
|
|
28
28
|
},
|
|
@@ -34,7 +34,7 @@ export const HkSectionHeader = defineComponent({
|
|
|
34
34
|
/** One-line description rendered under the heading. */
|
|
35
35
|
description: { type: String, default: undefined },
|
|
36
36
|
/** Leading icon component. */
|
|
37
|
-
icon: { type: Object as PropType<Component>, default: undefined },
|
|
37
|
+
icon: { type: [Object, Function] as PropType<Component>, default: undefined },
|
|
38
38
|
/** Trailing count badge (e.g. "12 total") rendered beside the title. */
|
|
39
39
|
count: { type: String, default: undefined },
|
|
40
40
|
variant: { type: String as PropType<SectionHeaderVariant>, default: "default" },
|
|
@@ -77,7 +77,7 @@ export const HkStatCard = defineComponent({
|
|
|
77
77
|
/** Whole-card click (drill-through to the owning page). */
|
|
78
78
|
clickable: { type: Boolean, default: false },
|
|
79
79
|
/** chip/ring: leading icon component (lucide-vue-next style). */
|
|
80
|
-
icon: { type: Object as PropType<Component>, default: undefined },
|
|
80
|
+
icon: { type: [Object, Function] as PropType<Component>, default: undefined },
|
|
81
81
|
/** ring/bar: gauge percentage, clamped to 0–100. */
|
|
82
82
|
pct: { type: Number, default: undefined },
|
|
83
83
|
/** ring: sub-label rendered inside the ring under the value (the unit). */
|