@heyramzi/ui 2.23.0 → 2.24.0

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.
Files changed (123) hide show
  1. package/COMPONENTS.md +3 -6
  2. package/dist/ai/confirmation/index.js +3 -6
  3. package/dist/ai/index.js +1 -5
  4. package/dist/charts/dashboard/index.js +1 -3
  5. package/dist/charts/primitives/chart-utils.js +14 -0
  6. package/dist/components/chip/index.js +1 -0
  7. package/dist/components/language-flag/flags.js +5 -0
  8. package/dist/components/language-flag/index.js +1 -0
  9. package/dist/components/list-page/index.js +1 -3
  10. package/dist/components/work-parts/index.js +1 -1
  11. package/dist/editor/doc-blocks.js +2 -1
  12. package/dist/effects/animated-beam/path-calculator.svelte.js +13 -6
  13. package/dist/lib/dates.js +41 -0
  14. package/dist/lib/panel.js +2 -2
  15. package/dist/lib/tone.js +13 -0
  16. package/dist/record/format.js +2 -18
  17. package/dist/record/logic.js +3 -6
  18. package/dist/status/index.js +1 -1
  19. package/dist/work/dates.js +2 -3
  20. package/dist/work/detail/detail-types.js +0 -8
  21. package/dist/work/docs/edited.js +8 -7
  22. package/dist/work/inbox/inbox-logic.js +5 -20
  23. package/dist/work/index.js +0 -2
  24. package/dist/work/time/duration.js +2 -3
  25. package/package.json +1 -21
  26. package/src/ai/confirmation/Confirmation.svelte +2 -2
  27. package/src/ai/confirmation/{ConfirmationRequest.svelte → ConfirmationState.svelte} +6 -3
  28. package/src/ai/confirmation/confirmation-context.svelte.ts +2 -2
  29. package/src/ai/confirmation/confirmation-parts.test.svelte +17 -0
  30. package/src/ai/confirmation/confirmation-parts.test.ts +23 -0
  31. package/src/ai/confirmation/index.ts +6 -21
  32. package/src/ai/index.ts +3 -13
  33. package/src/ai/typing-dots/TypingDots.svelte +32 -12
  34. package/src/ai/typing-dots/typing-dots.test.ts +36 -0
  35. package/src/canvas/ui/canvas-ui.css +12 -0
  36. package/src/charts/README.md +2 -2
  37. package/src/charts/area-chart.svelte +3 -10
  38. package/src/charts/bar-chart.svelte +4 -12
  39. package/src/charts/dashboard/data-table.svelte +21 -21
  40. package/src/charts/dashboard/index.ts +1 -3
  41. package/src/charts/dashboard/rating-chip.svelte +9 -11
  42. package/src/charts/dashboard/stat-tile.svelte +3 -4
  43. package/src/charts/line-chart.svelte +3 -10
  44. package/src/charts/primitives/chart-utils.test.ts +17 -0
  45. package/src/charts/primitives/chart-utils.ts +16 -0
  46. package/src/charts/time-series-chart.svelte +8 -4
  47. package/src/components/chip/count-chip.svelte +35 -0
  48. package/src/components/chip/index.ts +1 -0
  49. package/src/components/data-table/data-table.ts +1 -1
  50. package/src/components/data-table/row-context-menu.svelte +3 -4
  51. package/src/components/data-table/sortable-head.svelte +45 -10
  52. package/src/components/language-flag/flags.ts +5 -0
  53. package/src/components/language-flag/index.ts +1 -0
  54. package/src/components/language-flag/language-flag.svelte +3 -11
  55. package/src/components/list-page/empty-state.svelte +90 -12
  56. package/src/components/list-page/filter-popover.svelte +2 -5
  57. package/src/components/list-page/grouped-list.svelte +2 -4
  58. package/src/components/list-page/index.ts +1 -3
  59. package/src/components/section-header/section-header.svelte +2 -6
  60. package/src/components/segmented/segment.svelte +13 -19
  61. package/src/components/segmented/segmented-filter.svelte +1 -2
  62. package/src/components/table-view/table-view.svelte +31 -45
  63. package/src/components/table-view/table-view.test.ts +6 -3
  64. package/src/components/work-parts/group-head.svelte +1 -1
  65. package/src/components/work-parts/index.ts +1 -1
  66. package/src/editor/doc-blocks.ts +2 -1
  67. package/src/effects/animated-beam/path-calculator.svelte.ts +19 -5
  68. package/src/effects/marquee/Marquee.css +6 -3
  69. package/src/effects/marquee/Marquee.svelte +6 -2
  70. package/src/inbox/thread-inbox.svelte +6 -4
  71. package/src/lib/dates.test.ts +63 -0
  72. package/src/lib/dates.ts +63 -0
  73. package/src/lib/panel.svelte +116 -0
  74. package/src/lib/panel.ts +2 -2
  75. package/src/lib/tone.ts +15 -0
  76. package/src/panel/side-panel.svelte +4 -4
  77. package/src/record/format.ts +3 -15
  78. package/src/record/logic.ts +2 -6
  79. package/src/record/record-stats.svelte +4 -3
  80. package/src/record/steps-rail.svelte +7 -4
  81. package/src/status/index.ts +1 -1
  82. package/src/status/status-pill.svelte +2 -8
  83. package/src/thread/thread.svelte +3 -6
  84. package/src/work/README.md +0 -1
  85. package/src/work/dates.ts +3 -3
  86. package/src/work/demo.svelte +9 -1
  87. package/src/work/detail/detail-demo.svelte +30 -27
  88. package/src/work/detail/detail-types.ts +1 -29
  89. package/src/work/detail/task-detail.svelte +18 -17
  90. package/src/work/docs/doc-menu.svelte +2 -1
  91. package/src/work/docs/edited.ts +4 -7
  92. package/src/work/inbox/inbox-card.svelte +4 -9
  93. package/src/work/inbox/inbox-logic.ts +4 -16
  94. package/src/work/index.ts +1 -3
  95. package/src/work/time/duration.ts +2 -3
  96. package/dist/ai/thinking-dots/index.js +0 -3
  97. package/dist/components/icon/index.js +0 -1
  98. package/dist/components/locale-switch/index.js +0 -1
  99. package/dist/icons/trades.js +0 -49
  100. package/dist/status/pill-tint.js +0 -13
  101. package/dist/work/presets/sales.js +0 -39
  102. package/src/ai/confirmation/ConfirmationAccepted.svelte +0 -23
  103. package/src/ai/confirmation/ConfirmationFailed.svelte +0 -23
  104. package/src/ai/confirmation/ConfirmationRejected.svelte +0 -23
  105. package/src/ai/thinking-dots/ThinkingDots.svelte +0 -42
  106. package/src/ai/thinking-dots/index.ts +0 -5
  107. package/src/charts/dashboard/dashboard-empty.svelte +0 -55
  108. package/src/charts/dashboard/data-panel.svelte +0 -81
  109. package/src/charts/dashboard/data-sort-head.svelte +0 -102
  110. package/src/components/icon/icon.svelte +0 -23
  111. package/src/components/icon/index.ts +0 -1
  112. package/src/components/list-page/detail-empty.svelte +0 -45
  113. package/src/components/list-page/detail-panel.svelte +0 -82
  114. package/src/components/list-page/rail-empty.svelte +0 -44
  115. package/src/components/locale-switch/index.ts +0 -1
  116. package/src/components/locale-switch/locale-switch.svelte +0 -59
  117. package/src/components/work-parts/count-chip.svelte +0 -20
  118. package/src/icons/TradeIcon.svelte +0 -16
  119. package/src/icons/trades.ts +0 -89
  120. package/src/status/pill-tint.ts +0 -16
  121. package/src/work/detail/task-property.svelte +0 -17
  122. package/src/work/detail/task-thread.svelte +0 -221
  123. package/src/work/presets/sales.ts +0 -16
@@ -23,9 +23,10 @@
23
23
  .marquee__track--reverse {
24
24
  animation-direction: reverse;
25
25
  }
26
+ /* fit-content already stops at the parent's width. No max-width here: this sheet is unlayered, so
27
+ it would beat a caller's max-w-* utility and the line would never overflow its box. */
26
28
  .marquee[data-overflow-only] {
27
29
  width: fit-content;
28
- max-width: 100%;
29
30
  padding: 0;
30
31
  }
31
32
  .marquee[data-still] .marquee__track {
@@ -49,8 +50,10 @@
49
50
  transparent
50
51
  );
51
52
  }
52
- .marquee[data-pause-hover]:hover .marquee__track {
53
- animation-play-state: paused;
53
+ @media (hover: hover) and (pointer: fine) {
54
+ .marquee[data-pause-hover]:hover .marquee__track {
55
+ animation-play-state: paused;
56
+ }
54
57
  }
55
58
  .marquee[data-paused] .marquee__track {
56
59
  animation-play-state: paused;
@@ -114,8 +114,12 @@
114
114
  const track = firstTrack.getBoundingClientRect();
115
115
  const padStart = parseFloat(vertical ? computed.paddingTop : computed.paddingLeft) || 0;
116
116
  const padEnd = parseFloat(vertical ? computed.paddingBottom : computed.paddingRight) || 0;
117
- boxSize = (vertical ? box.height : box.width) - padStart - padEnd;
118
- trackSize = vertical ? track.height : track.width;
117
+ // Rects carry an ancestor's CSS scale, padding and speed don't. Back to the box's own
118
+ // pixels, or a scaled box loops at the wrong speed.
119
+ const own = vertical ? root.offsetHeight : root.offsetWidth;
120
+ const scale = own ? (vertical ? box.height : box.width) / own : 1;
121
+ boxSize = (vertical ? box.height : box.width) / scale - padStart - padEnd;
122
+ trackSize = (vertical ? track.height : track.width) / scale;
119
123
  gapSize = parseFloat(vertical ? computed.rowGap : computed.columnGap) || 0;
120
124
  };
121
125
  measure();
@@ -15,12 +15,12 @@
15
15
  UserPlus,
16
16
  } from "phosphor-svelte";
17
17
  import DetailHeader from "../components/list-page/detail-header.svelte";
18
- import DetailPanel from "../components/list-page/detail-panel.svelte";
18
+ import DetailPanel from "../lib/panel.svelte";
19
19
  import FilterItem from "../components/list-page/filter-item.svelte";
20
20
  import FilterPopover from "../components/list-page/filter-popover.svelte";
21
21
  import MasterDetail from "../components/list-page/master-detail.svelte";
22
22
  import RailBody from "../components/list-page/rail-body.svelte";
23
- import RailEmpty from "../components/list-page/rail-empty.svelte";
23
+ import EmptyState from "../components/list-page/empty-state.svelte";
24
24
  import RailHead from "../components/list-page/rail-head.svelte";
25
25
  import RailRow from "../components/list-page/rail-row.svelte";
26
26
  import { filterSectionClass } from "../components/list-page/filter-section.js";
@@ -427,7 +427,9 @@
427
427
  </li>
428
428
  {:else}
429
429
  <li class="flex h-full flex-col items-center">
430
- <RailEmpty
430
+ <EmptyState
431
+ size="sm"
432
+ class="h-full"
431
433
  title={filtered
432
434
  ? filter.needsYou
433
435
  ? labels.emptyNeedsYou
@@ -531,7 +533,7 @@
531
533
  </DetailPanel>
532
534
  {/if}
533
535
  {:else}
534
- <RailEmpty title={labels.selectThread} />
536
+ <EmptyState size="sm" class="h-full" title={labels.selectThread} />
535
537
  {/if}
536
538
  {/snippet}
537
539
  </MasterDetail>
@@ -0,0 +1,63 @@
1
+ import { describe, expect, it } from "vite-plus/test";
2
+ import { formatAge } from "../record/format.js";
3
+ import { localDay as recordDay } from "../record/logic.js";
4
+ import { whenOf } from "../work/inbox/inbox-logic.js";
5
+ import { editStamp, editedLabel, shortDate as editedDate } from "../work/docs/edited.js";
6
+ import { todayIso } from "../work/dates.js";
7
+ import { localDay as timeDay } from "../work/time/duration.js";
8
+
9
+ // The modules that kept their own date names, pinned so the shared helpers can't change a string.
10
+ // 10:00 UTC is the same calendar day from Hawaii to Auckland, so whenOf's date holds in any zone.
11
+ const NOW = Date.parse("2026-10-23T10:00:00Z");
12
+ const ago = (seconds: number) => new Date(NOW - seconds * 1000).toISOString();
13
+
14
+ describe("relative time", () => {
15
+ it("formatAge says it in long words", () => {
16
+ expect(formatAge(ago(20), NOW)).toBe("now");
17
+ expect(formatAge(ago(3 * 86_400), NOW)).toBe("3 days ago");
18
+ expect(formatAge(ago(-14 * 86_400), NOW)).toBe("in 2 weeks");
19
+ expect(formatAge(ago(70 * 86_400), NOW)).toBe("2 months ago");
20
+ expect(formatAge(ago(400 * 86_400), NOW)).toBe("last year");
21
+ });
22
+
23
+ it("whenOf says it short, then turns to a date at four weeks", () => {
24
+ expect(whenOf(ago(3 * 3_600), NOW)).toBe("3 hr ago");
25
+ expect(whenOf(ago(86_400), NOW)).toBe("yesterday");
26
+ expect(whenOf(ago(40 * 86_400), NOW)).toBe("13 Sept");
27
+ expect(whenOf(ago(40 * 86_400), NOW, "en-US")).toBe("Sep 13");
28
+ expect(whenOf("Tuesday", NOW)).toBe("Tuesday");
29
+ expect(whenOf("2026-13-45T00:00:00Z", NOW)).toBe("");
30
+ });
31
+ });
32
+
33
+ describe("short date", () => {
34
+ const options = { now: new Date(NOW), timeZone: "UTC" };
35
+
36
+ it("adds the year only when it isn't this one", () => {
37
+ expect(editedDate("2026-10-23T08:00:00Z", options)).toBe("Oct 23");
38
+ expect(editedDate("2025-10-23T08:00:00Z", options)).toBe("Oct 23, 2025");
39
+ expect(editedDate("not a date", options)).toBe("");
40
+ });
41
+
42
+ it("builds the edited chip and stamp on it", () => {
43
+ expect(editStamp("2026-10-23T14:44:00Z", options)).toBe("Oct 23, 14:44");
44
+ expect(editedLabel("2026-10-23T14:44:00Z", "Edited", options)).toBe("Edited Oct 23");
45
+ expect(editedLabel(null, "Edited", options)).toBe("Edited");
46
+ });
47
+ });
48
+
49
+ describe("local day", () => {
50
+ it("reads a timestamp's day in the given zone", () => {
51
+ expect(recordDay("2026-10-23T23:30:00Z", "Europe/Paris")).toBe("2026-10-24");
52
+ expect(recordDay("2026-10-23T23:30:00Z", "UTC")).toBe("2026-10-23");
53
+ });
54
+
55
+ it("reads a date's day in the viewer's zone", () => {
56
+ expect(timeDay(new Date(2026, 0, 5, 23, 59))).toBe("2026-01-05");
57
+ expect(recordDay(new Date(2026, 0, 5, 0, 1).toISOString())).toBe("2026-01-05");
58
+ });
59
+
60
+ it("today matches across the modules", () => {
61
+ expect(todayIso()).toBe(timeDay());
62
+ });
63
+ });
@@ -0,0 +1,63 @@
1
+ // The date strings the library shows, through Intl so a locale and a zone are all a caller passes.
2
+
3
+ type At = Date | string | number;
4
+
5
+ export type ShortDateOptions = {
6
+ locale?: string;
7
+ timeZone?: string;
8
+ /** Adds the year: "Oct 23, 2025". */
9
+ year?: boolean;
10
+ };
11
+
12
+ /** "Oct 23" in the caller's locale. */
13
+ export function shortDate(at: At, { locale, timeZone, year }: ShortDateOptions = {}): string {
14
+ return new Intl.DateTimeFormat(locale, {
15
+ month: "short",
16
+ day: "numeric",
17
+ year: year ? "numeric" : undefined,
18
+ timeZone,
19
+ }).format(new Date(at));
20
+ }
21
+
22
+ const UNITS: [number, Intl.RelativeTimeFormatUnit][] = [
23
+ [31_536_000, "year"],
24
+ [2_592_000, "month"],
25
+ [604_800, "week"],
26
+ [86_400, "day"],
27
+ [3_600, "hour"],
28
+ [60, "minute"],
29
+ ];
30
+
31
+ export type RelativeTimeOptions = {
32
+ locale?: string;
33
+ /** `long` says "3 hours ago", `short` "3 hr ago". */
34
+ style?: Intl.RelativeTimeFormatStyle;
35
+ };
36
+
37
+ /** "3 days ago", "in 2 weeks", "now": the largest whole unit between `at` and `now`. */
38
+ export function relativeTime(
39
+ at: At,
40
+ now: At = Date.now(),
41
+ { locale, style = "long" }: RelativeTimeOptions = {},
42
+ ): string {
43
+ const seconds = Math.round((new Date(at).getTime() - new Date(now).getTime()) / 1000);
44
+ const age = Math.abs(seconds);
45
+ const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto", style });
46
+ for (const [size, unit] of UNITS) {
47
+ if (age >= size) return rtf.format(Math.round(seconds / size), unit);
48
+ }
49
+ return rtf.format(0, "second");
50
+ }
51
+
52
+ /** The calendar day of a moment as `YYYY-MM-DD`, in the given zone or the viewer's own. Today by default. */
53
+ export function localDay(at: At = new Date(), timeZone?: string): string {
54
+ const parts = new Intl.DateTimeFormat("en-US", {
55
+ year: "numeric",
56
+ month: "2-digit",
57
+ day: "2-digit",
58
+ timeZone,
59
+ }).formatToParts(new Date(at));
60
+ const part = (type: Intl.DateTimeFormatPartTypes) =>
61
+ parts.find((p) => p.type === type)?.value ?? "";
62
+ return `${part("year")}-${part("month")}-${part("day")}`;
63
+ }
@@ -0,0 +1,116 @@
1
+ <script lang="ts">
2
+ /*
3
+ * The one titled panel, exported as `DataPanel` from the dashboard and `DetailPanel`
4
+ * from list-page. Both drew the same box from `panel.ts` with different props.
5
+ */
6
+
7
+ // =========================
8
+ // IMPORTS
9
+ // =========================
10
+ import type { Snippet } from "svelte";
11
+ import SectionLabel from "../components/section-header/section-label.svelte";
12
+ import { cn } from "./utils.js";
13
+ import { panelHeaderClass, panelShellClass } from "./panel.js";
14
+ import type { PhosphorIcon } from "./icon-types.js";
15
+
16
+ // =========================
17
+ // TYPES
18
+ // =========================
19
+ interface Props {
20
+ /** What this panel is, drawn as the app's one panel label. No label, no actions: no header. */
21
+ label?: string;
22
+ labelIcon?: PhosphorIcon;
23
+ /** A mark the icon set lacks (a platform logo), drawn ahead of the label at the same size. */
24
+ labelLead?: Snippet;
25
+ /** A line under the label, for the scope a number was measured over. */
26
+ sublabel?: string;
27
+ /**
28
+ * A row count, total or freshness stamp. A prop, not an action, because
29
+ * hand-placed hints ended up at three type sizes on one screen.
30
+ */
31
+ hint?: string;
32
+ /** Controls that act on this panel. Pinned right, after the hint. */
33
+ actions?: Snippet;
34
+ /** Off for a body that supplies its own padding: a table, a media grid, a full-bleed list. */
35
+ pad?: boolean;
36
+ /** The body scrolls sideways rather than squeezing, for a table wider than the window. */
37
+ scroll?: boolean;
38
+ /** Takes the height the panels above it left, inside a `fill` stack. One per stack. */
39
+ grow?: boolean;
40
+ children: Snippet;
41
+ class?: string;
42
+ bodyClass?: string;
43
+ }
44
+
45
+ // =========================
46
+ // PROPS
47
+ // =========================
48
+ let {
49
+ label,
50
+ labelIcon,
51
+ labelLead,
52
+ sublabel,
53
+ hint,
54
+ actions,
55
+ pad = true,
56
+ scroll = false,
57
+ grow = false,
58
+ children,
59
+ class: className,
60
+ bodyClass,
61
+ }: Props = $props();
62
+
63
+ // =========================
64
+ // DERIVED
65
+ // =========================
66
+ let titled = $derived(Boolean(label || labelLead || sublabel));
67
+ let hasHeader = $derived(titled || Boolean(hint || actions));
68
+ </script>
69
+
70
+ <!-- =========================== -->
71
+ <!-- MARKUP -->
72
+ <!-- =========================== -->
73
+ <section class={cn(panelShellClass, grow && "flex min-h-0 flex-1 flex-col", className)}>
74
+ {#if hasHeader}
75
+ <div class={panelHeaderClass}>
76
+ {#if titled}
77
+ <div class="flex min-w-0 flex-col gap-0.5">
78
+ {#if label || labelLead}
79
+ <SectionLabel icon={labelIcon}>
80
+ {@render labelLead?.()}
81
+ {label}
82
+ </SectionLabel>
83
+ {/if}
84
+ {#if sublabel}
85
+ <span class="truncate text-xs text-muted-foreground">{sublabel}</span>
86
+ {/if}
87
+ </div>
88
+ {:else}
89
+ <!-- Holds the left slot so the actions stay pinned right. -->
90
+ <span></span>
91
+ {/if}
92
+ {#if hint || actions}
93
+ <div class="flex min-w-0 items-center gap-3">
94
+ {#if hint}
95
+ <span class="text-xs tabular-nums text-muted-foreground">{hint}</span>
96
+ {/if}
97
+ {#if actions}
98
+ <div class="flex min-w-0 flex-wrap items-center justify-end gap-2">
99
+ {@render actions()}
100
+ </div>
101
+ {/if}
102
+ </div>
103
+ {/if}
104
+ </div>
105
+ {/if}
106
+ <div
107
+ class={cn(
108
+ pad && "p-4",
109
+ scroll && "overflow-x-auto",
110
+ grow && "flex min-h-0 flex-1 flex-col",
111
+ bodyClass,
112
+ )}
113
+ >
114
+ {@render children()}
115
+ </div>
116
+ </section>
package/src/lib/panel.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** The one panel shell: a titled box holding a table, a chart or a stack. */
2
2
 
3
- // WHY tokens, not markup: `DetailPanel` and `DataPanel` draw the same box with
4
- // different props, and their edges drifted because the classes were typed twice.
3
+ // Tokens beside `panel.svelte`, because skeletons and hand-built cards draw this
4
+ // same edge without the panel's header.
5
5
 
6
6
  // Dashboards used `Card`, so /ads had a ring and a shadow where /social had a
7
7
  // hairline. Flat, one hairline, `rounded-xl`.
package/src/lib/tone.ts CHANGED
@@ -15,6 +15,21 @@ export const TONE_CLASS: Record<Tone, string> = {
15
15
  destructive: "border-destructive/30 bg-destructive/10 text-destructive-ink",
16
16
  };
17
17
 
18
+ /**
19
+ * The scale as a quiet tint with no border: the icon and the text carry the tone, the fill only
20
+ * groups them. Neutral reads off the foreground, not `bg-muted`, because muted sits 0.005 L from
21
+ * the canvas and vanishes there (tokens board, "what fights the new scale").
22
+ */
23
+ export const TONE_TINT: Record<Tone, string> = {
24
+ neutral: "bg-foreground/6 text-muted-foreground",
25
+ accent:
26
+ "bg-[color-mix(in_oklab,var(--tone-accent,var(--color-primary))_12%,transparent)] text-[color:var(--tone-accent,var(--color-primary))]",
27
+ info: "bg-info/12 text-info-800 dark:text-info-400",
28
+ success: "bg-success/12 text-success-800 dark:text-success-400",
29
+ warning: "bg-warning/14 text-warning-800 dark:text-warning-400",
30
+ destructive: "bg-destructive/10 text-destructive-ink",
31
+ };
32
+
18
33
  /** The same scale as text, for a verdict inside a line of muted facts. */
19
34
  export const TONE_TEXT: Record<Tone, string> = {
20
35
  neutral: "text-muted-foreground",
@@ -11,7 +11,7 @@
11
11
  import * as Sheet from "../shadcn/sheet/index.js";
12
12
  import { OpenIn, type OpenInTool } from "../components/open-in/index.js";
13
13
  import { CopyButton } from "../components/copy/index.js";
14
- import type { Tone } from "../lib/tone.js";
14
+ import { TONE_TEXT, type Tone } from "../lib/tone.js";
15
15
  import { cn } from "../lib/utils.js";
16
16
  import StatusBadge from "../status/status-badge.svelte";
17
17
  import PopValue from "../charts/pop-value.svelte";
@@ -75,9 +75,9 @@
75
75
  let hasRow = $derived(badges.length > 0 || openIn.length > 0 || Boolean(handoff || actions));
76
76
  const STAT_TONE = {
77
77
  default: "",
78
- muted: "text-muted-foreground",
79
- good: "text-success",
80
- bad: "text-destructive",
78
+ muted: TONE_TEXT.neutral,
79
+ good: TONE_TEXT.success,
80
+ bad: TONE_TEXT.destructive,
81
81
  } as const;
82
82
  const WIDTH: Record<SidePanelWidth, string> = {
83
83
  sm: "sm:max-w-sm",
@@ -1,6 +1,8 @@
1
1
  // Display formatting through Intl, so a locale string is all a host passes.
2
2
  // A date-only value ("2026-10-26") is a calendar day, read in UTC so no zone shifts it.
3
3
 
4
+ import { relativeTime } from "../lib/dates.js";
5
+
4
6
  const DAY_ONLY = /^\d{4}-\d{2}-\d{2}$/;
5
7
 
6
8
  function parse(iso: string): { date: Date; timeZone?: string } {
@@ -61,21 +63,7 @@ export function formatTime(iso: string, locale = "en-GB", timeZone?: string): st
61
63
 
62
64
  /** "3 days ago", "in 2 weeks", "now". */
63
65
  export function formatAge(iso: string, now: Date | number = Date.now(), locale = "en-GB"): string {
64
- const seconds = Math.round((new Date(iso).getTime() - new Date(now).getTime()) / 1000);
65
- const abs = Math.abs(seconds);
66
- const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto", style: "long" });
67
- const units: [number, Intl.RelativeTimeFormatUnit][] = [
68
- [31_536_000, "year"],
69
- [2_592_000, "month"],
70
- [604_800, "week"],
71
- [86_400, "day"],
72
- [3_600, "hour"],
73
- [60, "minute"],
74
- ];
75
- for (const [size, unit] of units) {
76
- if (abs >= size) return rtf.format(Math.round(seconds / size), unit);
77
- }
78
- return rtf.format(0, "second");
66
+ return relativeTime(iso, now, { locale });
79
67
  }
80
68
 
81
69
  /** "€12,000". `compact` gives "€12K". */
@@ -1,4 +1,5 @@
1
1
  // The record's pure logic: grouping, merging, picking. No DOM, no clock of its own.
2
+ import { localDay as dayOf } from "../lib/dates.js";
2
3
  import type {
3
4
  RecordEvent,
4
5
  RecordFilterDef,
@@ -16,12 +17,7 @@ import type {
16
17
 
17
18
  /** The calendar day of a timestamp as `YYYY-MM-DD`, in the given zone or the viewer's own. */
18
19
  export function localDay(iso: string, timeZone?: string): string {
19
- return new Intl.DateTimeFormat("en-CA", {
20
- year: "numeric",
21
- month: "2-digit",
22
- day: "2-digit",
23
- timeZone,
24
- }).format(new Date(iso));
20
+ return dayOf(iso, timeZone);
25
21
  }
26
22
 
27
23
  export type DayGroup = { day: string; events: RecordEvent[] };
@@ -2,6 +2,7 @@
2
2
  // =========================
3
3
  // IMPORTS
4
4
  // =========================
5
+ import { TONE_TEXT } from "../lib/tone.js";
5
6
  import { cn } from "../lib/utils.js";
6
7
  import PopValue from "../charts/pop-value.svelte";
7
8
  import type { PanelStat } from "../panel/side-panel-types.js";
@@ -23,9 +24,9 @@
23
24
  // =========================
24
25
  const TONE = {
25
26
  default: "",
26
- muted: "text-muted-foreground",
27
- good: "text-success",
28
- bad: "text-destructive",
27
+ muted: TONE_TEXT.neutral,
28
+ good: TONE_TEXT.success,
29
+ bad: TONE_TEXT.destructive,
29
30
  } as const;
30
31
  </script>
31
32
 
@@ -14,6 +14,7 @@
14
14
  } from "phosphor-svelte";
15
15
  import { cn } from "../lib/utils.js";
16
16
  import { Button } from "../shadcn/button/index.js";
17
+ import CountChip from "../components/chip/count-chip.svelte";
17
18
  import { Input } from "../shadcn/input/index.js";
18
19
  import { Skeleton } from "../shadcn/skeleton/index.js";
19
20
  import * as Popover from "../shadcn/popover/index.js";
@@ -279,10 +280,12 @@
279
280
  >
280
281
  <DotsThreeVertical class="size-4" weight="bold" />
281
282
  {#if hiddenCount > 0}
282
- <span
283
- class="absolute -top-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-muted px-1 text-xs font-medium tabular-nums"
284
- >{hiddenCount.toLocaleString()}</span
285
- >
283
+ <!-- Opaque, since it sits over the icon's corner. -->
284
+ <CountChip
285
+ count={hiddenCount}
286
+ size="sm"
287
+ class="absolute -top-0.5 -right-0.5 bg-muted"
288
+ />
286
289
  {/if}
287
290
  </Button>
288
291
  {/snippet}
@@ -10,4 +10,4 @@ export type {
10
10
  Statuses,
11
11
  } from "./status-types.js";
12
12
  export { default as StatusPill } from "./status-pill.svelte";
13
- export { PILL_TINT } from "./pill-tint.js";
13
+ export { TONE_TINT as PILL_TINT } from "../lib/tone.js";
@@ -1,13 +1,7 @@
1
- <script lang="ts" module>
2
- import type { Tone } from "../lib/tone.js";
3
- import { PILL_TINT } from "./pill-tint.js";
4
-
5
- export { PILL_TINT };
6
- </script>
7
-
8
1
  <script lang="ts">
9
2
  import type { Snippet } from "svelte";
10
3
  import type { HTMLAttributes } from "svelte/elements";
4
+ import { TONE_TINT, type Tone } from "../lib/tone.js";
11
5
  import { cn } from "../lib/utils.js";
12
6
 
13
7
  interface Props extends Omit<HTMLAttributes<HTMLSpanElement>, "class" | "children"> {
@@ -30,7 +24,7 @@
30
24
  "transition-[background-color,color] duration-quick ease-smooth-out motion-reduce:transition-none",
31
25
  "[&>svg]:size-3 [&>svg]:shrink-0",
32
26
  icon && "pl-1.5",
33
- PILL_TINT[tone],
27
+ TONE_TINT[tone],
34
28
  className,
35
29
  )}
36
30
  {...restProps}
@@ -2,6 +2,7 @@
2
2
  import type { Snippet } from "svelte";
3
3
  import { ArrowBendDownRight, Check, MapPin, PencilSimple, Trash } from "phosphor-svelte";
4
4
  import { cn } from "../lib/utils.js";
5
+ import { shortDate } from "../lib/dates.js";
5
6
  import { initial } from "../lib/initials.js";
6
7
  import { AgentAvatar } from "../agents/index.js";
7
8
  import RichRenderer from "../editor/renderer.svelte";
@@ -64,8 +65,8 @@
64
65
  avatar,
65
66
  attachments,
66
67
  anchorChip,
67
- when = (comment) => shortDate(comment.createdAt),
68
- whenEvent = (event) => shortDate(event.at),
68
+ when = (comment) => shortDate(comment.createdAt, { locale }),
69
+ whenEvent = (event) => shortDate(event.at, { locale }),
69
70
  onPost,
70
71
  onEdit,
71
72
  onDelete,
@@ -84,10 +85,6 @@
84
85
  let shown = $derived(showResolved ? nodes : nodes.filter((node) => !node.comment.resolved));
85
86
  let items = $derived(interleave(shown, events));
86
87
 
87
- function shortDate(at: string): string {
88
- return new Intl.DateTimeFormat(locale, { month: "short", day: "numeric" }).format(new Date(at));
89
- }
90
-
91
88
  let draft = $state("");
92
89
  let replyTo = $state<string | null>(null);
93
90
  let replyDraft = $state("");
@@ -286,7 +286,6 @@ exported helpers.
286
286
  A badge also takes its text as children, for a caller that already has the word.
287
287
  - `defineStatuses`: builds a status registry from a plain map.
288
288
  - `SidePanel`: a sheet for one record, above.
289
- - `salesStatuses`: an example pipeline map.
290
289
 
291
290
  ## Styling
292
291
 
package/src/work/dates.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  // Dates are plain "YYYY-MM-DD" strings, counted as whole UTC days. A timeline
2
2
  // only needs days, and day numbers dodge every timezone and DST edge.
3
+ import { localDay } from "../lib/dates.js";
4
+
3
5
  const DAY_MS = 86_400_000;
4
6
 
5
7
  /** Days since 1970-01-01 for an ISO date. Anything after the date part is ignored. */
@@ -20,9 +22,7 @@ export function addDays(iso: string, days: number): string {
20
22
 
21
23
  /** Today in the viewer's own timezone, as an ISO date. */
22
24
  export function todayIso(): string {
23
- const now = new Date();
24
- const local = new Date(now.getTime() - now.getTimezoneOffset() * 60_000);
25
- return local.toISOString().slice(0, 10);
25
+ return localDay();
26
26
  }
27
27
 
28
28
  /** 0 is Sunday, as in `Date.getUTCDay`. */
@@ -20,7 +20,6 @@
20
20
  import StatusDot from "../status/status-dot.svelte";
21
21
  import { defineStatuses } from "../status/define-statuses.js";
22
22
  import { addDays, dayNumber, todayIso } from "./dates.js";
23
- import { salesStatuses } from "./presets/sales.js";
24
23
  import type { KanbanMove } from "./kanban-types.js";
25
24
  import type { GanttChange } from "./task-types.js";
26
25
  import TimeTracker from "./time/time-tracker.svelte";
@@ -48,6 +47,15 @@
48
47
  done: { label: "Done", tone: "success", variant: "completed" },
49
48
  });
50
49
 
50
+ const salesStatuses = defineStatuses({
51
+ new: { label: "New", tone: "accent", variant: "open" },
52
+ contacted: { label: "Contacted", tone: "info", variant: "open" },
53
+ proposal: { label: "Proposal", tone: "accent", variant: "progress", progress: 0.25 },
54
+ negotiation: { label: "Negotiation", tone: "warning", variant: "progress", progress: 0.75 },
55
+ won: { label: "Won", tone: "success", variant: "completed" },
56
+ lost: { label: "Lost", tone: "destructive", variant: "lost" },
57
+ });
58
+
51
59
  const columns = [
52
60
  { id: "todo", label: "To do", hue: "var(--color-muted-foreground)" },
53
61
  { id: "doing", label: "In progress", hue: "var(--color-info)" },