@celestia-island/hikari 0.55.402 → 0.55.403

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.402",
3
+ "version": "0.55.403",
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",
@@ -10,8 +10,9 @@ import { setLocale } from "../i18n/context";
10
10
  * COMPONENT contract: the segment order follows the ACTIVE hikari
11
11
  * locale (year first for zh-Hans, year LAST for en) with that locale's
12
12
  * own separators, the order re-derives live when the host flips the
13
- * locale, `time` appends the muted trailing segment, and unparseable
14
- * input renders the empty pill shell.
13
+ * locale, `time` appends the muted trailing segment, `seconds` widens
14
+ * that segment to hour:minute:second (only under `time`), and
15
+ * unparseable input renders the empty pill shell.
15
16
  */
16
17
 
17
18
  const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
@@ -20,7 +21,11 @@ const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement
20
21
  // every CI time zone; the pill renders local calendar segments.
21
22
  const SHIP_DATE = new Date(2024, 9, 6, 14, 30);
22
23
 
23
- function mountTag(props: { value: string | number | Date; time?: boolean }): HTMLElement {
24
+ function mountTag(props: {
25
+ value: string | number | Date;
26
+ time?: boolean;
27
+ seconds?: boolean;
28
+ }): HTMLElement {
24
29
  const container = document.createElement("div");
25
30
  document.body.appendChild(container);
26
31
  const app = createApp({ render: () => h(HkDateTag, props) });
@@ -123,6 +128,44 @@ describe("HkDateTag time segment", () => {
123
128
  });
124
129
  });
125
130
 
131
+ describe("HkDateTag seconds segment", () => {
132
+ // A nonzero second is the point: the widened segment must show the
133
+ // record's exact tick, not a padded zero.
134
+ const TICK = new Date(2024, 9, 6, 14, 30, 5);
135
+
136
+ it("widens the time segment to hour:minute:second when asked", async () => {
137
+ await setLocale("zh-Hans");
138
+ const container = mountTag({ value: TICK, time: true, seconds: true });
139
+ const segs = segsOf(container);
140
+ // Same segment count and element role as the plain time pill — the
141
+ // widening refines the segment in place.
142
+ expect(segs).toHaveLength(4);
143
+ expect(segs[3].classList.contains("hk-date-tag__seg--time")).toBe(true);
144
+ expect(segs[3].textContent).toBe("14:30:05");
145
+ expect(textOf(container)).toBe("2024/10/06 14:30:05");
146
+ });
147
+
148
+ it("formats the seconds form for the active locale", async () => {
149
+ await setLocale("en");
150
+ const container = mountTag({ value: TICK, time: true, seconds: true });
151
+ const segs = segsOf(container);
152
+ expect(segs).toHaveLength(4);
153
+ expect(segs[3]!.textContent).toBe("02:30:05 PM");
154
+ expect(textOf(container)).toBe("10/06/2024 02:30:05 PM");
155
+ });
156
+
157
+ it("does nothing without the time flag", async () => {
158
+ await setLocale("zh-Hans");
159
+ const container = mountTag({ value: TICK, seconds: true });
160
+ const segs = segsOf(container);
161
+ expect(segs).toHaveLength(3);
162
+ expect(segs.some((s) => s.classList.contains("hk-date-tag__seg--time"))).toBe(false);
163
+ // No time segment also means NO separator — the pill's text is the
164
+ // bare date, byte-identical to the no-flags render.
165
+ expect(textOf(container)).toBe("2024/10/06");
166
+ });
167
+ });
168
+
126
169
  describe("HkDateTag value normalization", () => {
127
170
  it("accepts epoch milliseconds and date strings like the Date form", async () => {
128
171
  await setLocale("en");
@@ -10,7 +10,8 @@ import "./HkDateTag.scss";
10
10
  * dates (zh: 2024/10/06 — year first; en: 10/06/2024 — the year LAST;
11
11
  * de: 06.10.2024 — day first), joined by that locale's own literal
12
12
  * separators. With the `time` flag a fourth, muted segment carries the
13
- * locale time (hour + minute, 2-digit) after a blank separator.
13
+ * locale time (hour + minute, 2-digit — widened to hour:minute:second
14
+ * under `seconds`) after a blank separator.
14
15
  *
15
16
  * Generic business part (peer of HkTemplateText / HkMarkdownRenderer,
16
17
  * NOT of the HkInput family): hosts render compact per-row dates in
@@ -32,6 +33,11 @@ import "./HkDateTag.scss";
32
33
  * `setLocale` re-orders the line live.
33
34
  * - `time` (default false) appends the muted time segment
34
35
  * (`hk-date-tag__seg--time`) after a blank separator.
36
+ * - `seconds` (default false) widens the time segment to
37
+ * hour:minute:second — it refines the `time` segment in place (same
38
+ * element, same muted role) and does nothing when `time` is false.
39
+ * Trace/log surfaces that need second precision (a 176ms tool call
40
+ * landing between two :30 ticks) opt in; tables stay at HH:mm.
35
41
  */
36
42
  export const HkDateTag = defineComponent({
37
43
  name: "HkDateTag",
@@ -44,6 +50,8 @@ export const HkDateTag = defineComponent({
44
50
  },
45
51
  /** Append the muted locale time segment (hour + minute, 2-digit). */
46
52
  time: { type: Boolean, default: false },
53
+ /** Widen the time segment to hour:minute:second (needs `time`). */
54
+ seconds: { type: Boolean, default: false },
47
55
  },
48
56
  setup(props) {
49
57
  const date = computed<Date | null>(() => {
@@ -70,12 +78,18 @@ export const HkDateTag = defineComponent({
70
78
  }).formatToParts(d);
71
79
  });
72
80
 
73
- /** The locale time (hour + minute, 2-digit) when the pill opts
74
- * in — null without `time` or for an invalid date. */
81
+ /** The locale time (hour + minute, or hour:minute:second under
82
+ * `seconds`) when the pill opts in — null without `time` or for an
83
+ * invalid date. */
75
84
  const timeText = computed<string | null>(() => {
76
85
  const d = date.value;
77
86
  if (!props.time || d === null) return null;
78
- return new Intl.DateTimeFormat(locale.value, { hour: "2-digit", minute: "2-digit" }).format(d);
87
+ return new Intl.DateTimeFormat(
88
+ locale.value,
89
+ props.seconds
90
+ ? { hour: "2-digit", minute: "2-digit", second: "2-digit" }
91
+ : { hour: "2-digit", minute: "2-digit" },
92
+ ).format(d);
79
93
  });
80
94
 
81
95
  return () => (