@felix-hz/seamount 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +150 -2
- package/THIRD_PARTY_NOTICES.md +37 -0
- package/dist/css/base.css +75 -0
- package/dist/css/components.css +1107 -0
- package/dist/css/fonts.css +136 -0
- package/dist/css/seamount.css +1483 -0
- package/dist/css/tailwind.css +64 -0
- package/dist/css/tokens.css +159 -0
- package/dist/fonts/DepartureMono-OFL.txt +93 -0
- package/dist/fonts/InstrumentSans-OFL.txt +93 -0
- package/dist/fonts/JetBrainsMono-OFL.txt +93 -0
- package/dist/fonts/Newsreader-OFL.txt +93 -0
- package/dist/fonts/departure-mono.woff2 +0 -0
- package/dist/fonts/instrument-sans.woff2 +0 -0
- package/dist/fonts/jetbrains-mono.woff2 +0 -0
- package/dist/fonts/newsreader-display.woff2 +0 -0
- package/dist/fonts/newsreader-italic.woff2 +0 -0
- package/dist/fonts/newsreader-semibold.woff2 +0 -0
- package/dist/fonts/newsreader.woff2 +0 -0
- package/dist/lib/format.d.ts +23 -0
- package/dist/lib/format.js +88 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/theme.d.ts +20 -0
- package/dist/lib/theme.js +53 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/react/button.d.ts +12 -0
- package/dist/react/button.js +19 -0
- package/dist/react/button.js.map +1 -0
- package/dist/react/cn.d.ts +4 -0
- package/dist/react/cn.js +10 -0
- package/dist/react/cn.js.map +1 -0
- package/dist/react/controls.d.ts +23 -0
- package/dist/react/controls.js +50 -0
- package/dist/react/controls.js.map +1 -0
- package/dist/react/dialog.d.ts +40 -0
- package/dist/react/dialog.js +102 -0
- package/dist/react/dialog.js.map +1 -0
- package/dist/react/feedback.d.ts +31 -0
- package/dist/react/feedback.js +86 -0
- package/dist/react/feedback.js.map +1 -0
- package/dist/react/field.d.ts +38 -0
- package/dist/react/field.js +81 -0
- package/dist/react/field.js.map +1 -0
- package/dist/react/hooks.d.ts +24 -0
- package/dist/react/hooks.js +58 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +19 -0
- package/dist/react/label.d.ts +28 -0
- package/dist/react/label.js +91 -0
- package/dist/react/label.js.map +1 -0
- package/dist/react/menu.d.ts +21 -0
- package/dist/react/menu.js +72 -0
- package/dist/react/menu.js.map +1 -0
- package/dist/react/overlay.d.ts +19 -0
- package/dist/react/overlay.js +47 -0
- package/dist/react/overlay.js.map +1 -0
- package/dist/react/row.d.ts +14 -0
- package/dist/react/row.js +35 -0
- package/dist/react/row.js.map +1 -0
- package/dist/react/section.d.ts +20 -0
- package/dist/react/section.js +72 -0
- package/dist/react/section.js.map +1 -0
- package/dist/react/select.d.ts +11 -0
- package/dist/react/select.js +59 -0
- package/dist/react/select.js.map +1 -0
- package/dist/react/spec.d.ts +10 -0
- package/dist/react/spec.js +25 -0
- package/dist/react/spec.js.map +1 -0
- package/dist/react/stat.d.ts +37 -0
- package/dist/react/stat.js +115 -0
- package/dist/react/stat.js.map +1 -0
- package/dist/react/tabs.d.ts +7 -0
- package/dist/react/tabs.js +30 -0
- package/dist/react/tabs.js.map +1 -0
- package/dist/react/toast.d.ts +51 -0
- package/dist/react/toast.js +122 -0
- package/dist/react/toast.js.map +1 -0
- package/package.json +100 -4
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
|
|
2
|
+
// src/lib/format.ts
|
|
3
|
+
const MISSING = "–";
|
|
4
|
+
const isMissing = (value) => value === null || value === void 0 || Number.isNaN(value);
|
|
5
|
+
/** `4812` → `4,812`; `null` → `–`. */
|
|
6
|
+
function formatNumber(value, options = {}, locale = "en-NZ") {
|
|
7
|
+
if (isMissing(value)) return "–";
|
|
8
|
+
return new Intl.NumberFormat(locale, {
|
|
9
|
+
maximumFractionDigits: 2,
|
|
10
|
+
...options
|
|
11
|
+
}).format(value);
|
|
12
|
+
}
|
|
13
|
+
/** `88.4, "°C"` → `88.4 °C`; `60, "%"` → `60%`. A non-breaking space keeps the unit with its figure. */
|
|
14
|
+
function formatUnit(value, unit, options = {}, locale = "en-NZ") {
|
|
15
|
+
if (isMissing(value)) return "–";
|
|
16
|
+
const figure = formatNumber(value, options, locale);
|
|
17
|
+
return unit === "%" ? `${figure}%` : `${figure} ${unit}`;
|
|
18
|
+
}
|
|
19
|
+
/** Money with an explicit sign, so state never rests on colour: `−42.10`, `+4,230.00`. */
|
|
20
|
+
function formatSigned(value, options = {}, locale = "en-NZ") {
|
|
21
|
+
if (isMissing(value)) return "–";
|
|
22
|
+
const figure = new Intl.NumberFormat(locale, {
|
|
23
|
+
minimumFractionDigits: 2,
|
|
24
|
+
maximumFractionDigits: 2,
|
|
25
|
+
...options,
|
|
26
|
+
signDisplay: "never"
|
|
27
|
+
}).format(value);
|
|
28
|
+
if (value === 0) return figure;
|
|
29
|
+
return `${value < 0 ? "−" : "+"}${figure}`;
|
|
30
|
+
}
|
|
31
|
+
/** Currency amount; pass `signed` to show the sign before the symbol: `−$42.10`. */
|
|
32
|
+
function formatMoney(value, currency, { signed = false, locale = "en-NZ" } = {}) {
|
|
33
|
+
if (isMissing(value)) return "–";
|
|
34
|
+
const figure = new Intl.NumberFormat(locale, {
|
|
35
|
+
style: "currency",
|
|
36
|
+
currency,
|
|
37
|
+
currencyDisplay: "narrowSymbol",
|
|
38
|
+
signDisplay: "never"
|
|
39
|
+
}).format(value);
|
|
40
|
+
if (!signed || value === 0) return value < 0 ? `−${figure}` : figure;
|
|
41
|
+
return `${value < 0 ? "−" : "+"}${figure}`;
|
|
42
|
+
}
|
|
43
|
+
const MINUTE = 6e4;
|
|
44
|
+
const HOUR = 60 * MINUTE;
|
|
45
|
+
/** Inside the last hour: `just now`, `4 min ago`. Beyond it: `Fri 20 Nov, 21:40`, with the year when it differs. */
|
|
46
|
+
function formatWhen(date, now = /* @__PURE__ */ new Date(), locale = "en-NZ") {
|
|
47
|
+
if (date === null || date === void 0) return "–";
|
|
48
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
49
|
+
if (Number.isNaN(d.getTime())) return "–";
|
|
50
|
+
const diff = now.getTime() - d.getTime();
|
|
51
|
+
if (diff >= 0 && diff < HOUR) {
|
|
52
|
+
const minutes = Math.floor(diff / MINUTE);
|
|
53
|
+
return minutes < 1 ? "just now" : `${minutes} min ago`;
|
|
54
|
+
}
|
|
55
|
+
return formatDay(d, now, locale, true);
|
|
56
|
+
}
|
|
57
|
+
/** `Fri 20 Nov`, or `Fri 20 Nov 2025` outside the current year; `withTime` adds `, 21:40`. */
|
|
58
|
+
function formatDay(date, now = /* @__PURE__ */ new Date(), locale = "en-NZ", withTime = false) {
|
|
59
|
+
if (date === null || date === void 0) return "–";
|
|
60
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
61
|
+
if (Number.isNaN(d.getTime())) return "–";
|
|
62
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
63
|
+
weekday: "short",
|
|
64
|
+
day: "numeric",
|
|
65
|
+
month: "short",
|
|
66
|
+
year: d.getFullYear() === now.getFullYear() ? void 0 : "numeric"
|
|
67
|
+
}).formatToParts(d);
|
|
68
|
+
const get = (type) => parts.find((p) => p.type === type)?.value ?? "";
|
|
69
|
+
const year = get("year");
|
|
70
|
+
const day = `${get("weekday")} ${get("day")} ${get("month")}${year ? ` ${year}` : ""}`;
|
|
71
|
+
if (!withTime) return day;
|
|
72
|
+
return `${day}, ${new Intl.DateTimeFormat(locale, {
|
|
73
|
+
hour: "2-digit",
|
|
74
|
+
minute: "2-digit",
|
|
75
|
+
hourCycle: "h23"
|
|
76
|
+
}).format(d)}`;
|
|
77
|
+
}
|
|
78
|
+
/** `6, 21` → `6 of 21`, the counter for a position in a set. */
|
|
79
|
+
function formatCounter(position, total) {
|
|
80
|
+
return `${position} of ${total}`;
|
|
81
|
+
}
|
|
82
|
+
/** `0` → `01`: section and plate numbers. */
|
|
83
|
+
function pad2(n) {
|
|
84
|
+
return String(n).padStart(2, "0");
|
|
85
|
+
}
|
|
86
|
+
export { MISSING, formatCounter, formatDay, formatMoney, formatNumber, formatSigned, formatUnit, formatWhen, pad2 };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","names":[],"sources":["../../src/lib/format.ts"],"sourcesContent":["// Seamount's rules for numbers and time: a space before units except %, thousands separators, an en dash\n// for a missing value, relative time inside the last hour and the day with the time beyond it. Pure\n// functions with no React, so they also run on a server and in vanilla pages.\n\nexport const MISSING = \"–\";\n\ntype Maybe<T> = T | null | undefined;\n\nconst isMissing = (value: Maybe<number>): value is null | undefined =>\n value === null || value === undefined || Number.isNaN(value);\n\n/** `4812` → `4,812`; `null` → `–`. */\nexport function formatNumber(value: Maybe<number>, options: Intl.NumberFormatOptions = {}, locale = \"en-NZ\"): string {\n if (isMissing(value)) return MISSING;\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 2, ...options }).format(value);\n}\n\n/** `88.4, \"°C\"` → `88.4 °C`; `60, \"%\"` → `60%`. A non-breaking space keeps the unit with its figure. */\nexport function formatUnit(\n value: Maybe<number>,\n unit: string,\n options: Intl.NumberFormatOptions = {},\n locale = \"en-NZ\",\n): string {\n if (isMissing(value)) return MISSING;\n const figure = formatNumber(value, options, locale);\n return unit === \"%\" ? `${figure}%` : `${figure} ${unit}`;\n}\n\n/** Money with an explicit sign, so state never rests on colour: `−42.10`, `+4,230.00`. */\nexport function formatSigned(value: Maybe<number>, options: Intl.NumberFormatOptions = {}, locale = \"en-NZ\"): string {\n if (isMissing(value)) return MISSING;\n const figure = new Intl.NumberFormat(locale, {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n ...options,\n signDisplay: \"never\",\n }).format(value);\n if (value === 0) return figure;\n return `${value < 0 ? \"−\" : \"+\"}${figure}`;\n}\n\n/** Currency amount; pass `signed` to show the sign before the symbol: `−$42.10`. */\nexport function formatMoney(\n value: Maybe<number>,\n currency: string,\n { signed = false, locale = \"en-NZ\" }: { signed?: boolean; locale?: string } = {},\n): string {\n if (isMissing(value)) return MISSING;\n const figure = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n currencyDisplay: \"narrowSymbol\",\n signDisplay: \"never\",\n }).format(value);\n if (!signed || value === 0) return value < 0 ? `−${figure}` : figure;\n return `${value < 0 ? \"−\" : \"+\"}${figure}`;\n}\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\n\n/** Inside the last hour: `just now`, `4 min ago`. Beyond it: `Fri 20 Nov, 21:40`, with the year when it differs. */\nexport function formatWhen(date: Maybe<Date | number | string>, now: Date = new Date(), locale = \"en-NZ\"): string {\n if (date === null || date === undefined) return MISSING;\n const d = date instanceof Date ? date : new Date(date);\n if (Number.isNaN(d.getTime())) return MISSING;\n const diff = now.getTime() - d.getTime();\n if (diff >= 0 && diff < HOUR) {\n const minutes = Math.floor(diff / MINUTE);\n return minutes < 1 ? \"just now\" : `${minutes} min ago`;\n }\n return formatDay(d, now, locale, true);\n}\n\n/** `Fri 20 Nov`, or `Fri 20 Nov 2025` outside the current year; `withTime` adds `, 21:40`. */\nexport function formatDay(\n date: Maybe<Date | number | string>,\n now: Date = new Date(),\n locale = \"en-NZ\",\n withTime = false,\n): string {\n if (date === null || date === undefined) return MISSING;\n const d = date instanceof Date ? date : new Date(date);\n if (Number.isNaN(d.getTime())) return MISSING;\n const parts = new Intl.DateTimeFormat(locale, {\n weekday: \"short\",\n day: \"numeric\",\n month: \"short\",\n year: d.getFullYear() === now.getFullYear() ? undefined : \"numeric\",\n }).formatToParts(d);\n const get = (type: Intl.DateTimeFormatPartTypes): string => parts.find((p) => p.type === type)?.value ?? \"\";\n const year = get(\"year\");\n const day = `${get(\"weekday\")} ${get(\"day\")} ${get(\"month\")}${year ? ` ${year}` : \"\"}`;\n if (!withTime) return day;\n const time = new Intl.DateTimeFormat(locale, { hour: \"2-digit\", minute: \"2-digit\", hourCycle: \"h23\" }).format(d);\n return `${day}, ${time}`;\n}\n\n/** `6, 21` → `6 of 21`, the counter for a position in a set. */\nexport function formatCounter(position: number, total: number): string {\n return `${position} of ${total}`;\n}\n\n/** `0` → `01`: section and plate numbers. */\nexport function pad2(n: number): string {\n return String(n).padStart(2, \"0\");\n}\n"],"mappings":";;AAIA,MAAa,UAAU;AAIvB,MAAM,aAAa,UACjB,UAAU,QAAQ,UAAU,KAAA,KAAa,OAAO,MAAM,KAAK;;AAG7D,SAAgB,aAAa,OAAsB,UAAoC,CAAC,GAAG,SAAS,SAAiB;CACnH,IAAI,UAAU,KAAK,GAAG,OAAA;CACtB,OAAO,IAAI,KAAK,aAAa,QAAQ;EAAE,uBAAuB;EAAG,GAAG;CAAQ,CAAC,CAAC,CAAC,OAAO,KAAK;AAC7F;;AAGA,SAAgB,WACd,OACA,MACA,UAAoC,CAAC,GACrC,SAAS,SACD;CACR,IAAI,UAAU,KAAK,GAAG,OAAA;CACtB,MAAM,SAAS,aAAa,OAAO,SAAS,MAAM;CAClD,OAAO,SAAS,MAAM,GAAG,OAAO,KAAK,GAAG,OAAO,GAAG;AACpD;;AAGA,SAAgB,aAAa,OAAsB,UAAoC,CAAC,GAAG,SAAS,SAAiB;CACnH,IAAI,UAAU,KAAK,GAAG,OAAA;CACtB,MAAM,SAAS,IAAI,KAAK,aAAa,QAAQ;EAC3C,uBAAuB;EACvB,uBAAuB;EACvB,GAAG;EACH,aAAa;CACf,CAAC,CAAC,CAAC,OAAO,KAAK;CACf,IAAI,UAAU,GAAG,OAAO;CACxB,OAAO,GAAG,QAAQ,IAAI,MAAM,MAAM;AACpC;;AAGA,SAAgB,YACd,OACA,UACA,EAAE,SAAS,OAAO,SAAS,YAAmD,CAAC,GACvE;CACR,IAAI,UAAU,KAAK,GAAG,OAAA;CACtB,MAAM,SAAS,IAAI,KAAK,aAAa,QAAQ;EAC3C,OAAO;EACP;EACA,iBAAiB;EACjB,aAAa;CACf,CAAC,CAAC,CAAC,OAAO,KAAK;CACf,IAAI,CAAC,UAAU,UAAU,GAAG,OAAO,QAAQ,IAAI,IAAI,WAAW;CAC9D,OAAO,GAAG,QAAQ,IAAI,MAAM,MAAM;AACpC;AAEA,MAAM,SAAS;AACf,MAAM,OAAO,KAAK;;AAGlB,SAAgB,WAAW,MAAqC,sBAAY,IAAI,KAAK,GAAG,SAAS,SAAiB;CAChH,IAAI,SAAS,QAAQ,SAAS,KAAA,GAAW,OAAA;CACzC,MAAM,IAAI,gBAAgB,OAAO,OAAO,IAAI,KAAK,IAAI;CACrD,IAAI,OAAO,MAAM,EAAE,QAAQ,CAAC,GAAG,OAAA;CAC/B,MAAM,OAAO,IAAI,QAAQ,IAAI,EAAE,QAAQ;CACvC,IAAI,QAAQ,KAAK,OAAO,MAAM;EAC5B,MAAM,UAAU,KAAK,MAAM,OAAO,MAAM;EACxC,OAAO,UAAU,IAAI,aAAa,GAAG,QAAQ;CAC/C;CACA,OAAO,UAAU,GAAG,KAAK,QAAQ,IAAI;AACvC;;AAGA,SAAgB,UACd,MACA,sBAAY,IAAI,KAAK,GACrB,SAAS,SACT,WAAW,OACH;CACR,IAAI,SAAS,QAAQ,SAAS,KAAA,GAAW,OAAA;CACzC,MAAM,IAAI,gBAAgB,OAAO,OAAO,IAAI,KAAK,IAAI;CACrD,IAAI,OAAO,MAAM,EAAE,QAAQ,CAAC,GAAG,OAAA;CAC/B,MAAM,QAAQ,IAAI,KAAK,eAAe,QAAQ;EAC5C,SAAS;EACT,KAAK;EACL,OAAO;EACP,MAAM,EAAE,YAAY,MAAM,IAAI,YAAY,IAAI,KAAA,IAAY;CAC5D,CAAC,CAAC,CAAC,cAAc,CAAC;CAClB,MAAM,OAAO,SAA+C,MAAM,MAAM,MAAM,EAAE,SAAS,IAAI,CAAC,EAAE,SAAS;CACzG,MAAM,OAAO,IAAI,MAAM;CACvB,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,OAAO,IAAI,OAAO,IAAI,SAAS;CAClF,IAAI,CAAC,UAAU,OAAO;CAEtB,OAAO,GAAG,IAAI,IADD,IAAI,KAAK,eAAe,QAAQ;EAAE,MAAM;EAAW,QAAQ;EAAW,WAAW;CAAM,CAAC,CAAC,CAAC,OAAO,CACzF;AACvB;;AAGA,SAAgB,cAAc,UAAkB,OAAuB;CACrE,OAAO,GAAG,SAAS,MAAM;AAC3B;;AAGA,SAAgB,KAAK,GAAmB;CACtC,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AAClC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export type ThemeChoice = "system" | "light" | "dark";
|
|
3
|
+
export type ResolvedTheme = "light" | "dark";
|
|
4
|
+
export declare const THEME_STORAGE_KEY = "seamount.theme";
|
|
5
|
+
/** The stored choice; storage can be absent or throw (private windows), which reads as System. */
|
|
6
|
+
export declare function readThemeChoice(key?: string): ThemeChoice;
|
|
7
|
+
export declare function resolveTheme(choice: ThemeChoice): ResolvedTheme;
|
|
8
|
+
/** Writes the resolved theme to the root element. `classes` also toggles .dark and .light. */
|
|
9
|
+
export declare function applyTheme(choice: ThemeChoice, { root, classes }?: {
|
|
10
|
+
root?: HTMLElement;
|
|
11
|
+
classes?: boolean;
|
|
12
|
+
}): ResolvedTheme;
|
|
13
|
+
export declare function storeThemeChoice(choice: ThemeChoice, key?: string): void;
|
|
14
|
+
/** Re-applies on OS changes while the choice is System. Returns the unsubscribe. */
|
|
15
|
+
export declare function watchSystemTheme(onChange: (resolved: ResolvedTheme) => void): () => void;
|
|
16
|
+
/**
|
|
17
|
+
* Inline this in <head> before any stylesheet so the first paint is in the right theme:
|
|
18
|
+
* `<script>{themeScript()}<\/script>`, or dangerouslySetInnerHTML in React.
|
|
19
|
+
*/
|
|
20
|
+
export declare function themeScript(key?: string, classes?: boolean): string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
// src/lib/theme.ts
|
|
3
|
+
const THEME_STORAGE_KEY = "seamount.theme";
|
|
4
|
+
const isChoice = (value) => value === "system" || value === "light" || value === "dark";
|
|
5
|
+
const media = () => typeof window === "undefined" ? void 0 : window.matchMedia("(prefers-color-scheme: dark)");
|
|
6
|
+
/** The stored choice; storage can be absent or throw (private windows), which reads as System. */
|
|
7
|
+
function readThemeChoice(key = THEME_STORAGE_KEY) {
|
|
8
|
+
try {
|
|
9
|
+
const value = localStorage.getItem(key);
|
|
10
|
+
return isChoice(value) ? value : "system";
|
|
11
|
+
} catch {
|
|
12
|
+
return "system";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function resolveTheme(choice) {
|
|
16
|
+
if (choice !== "system") return choice;
|
|
17
|
+
return media()?.matches ? "dark" : "light";
|
|
18
|
+
}
|
|
19
|
+
/** Writes the resolved theme to the root element. `classes` also toggles .dark and .light. */
|
|
20
|
+
function applyTheme(choice, { root = document.documentElement, classes = false } = {}) {
|
|
21
|
+
const resolved = resolveTheme(choice);
|
|
22
|
+
root.dataset.theme = resolved;
|
|
23
|
+
root.style.colorScheme = resolved;
|
|
24
|
+
if (classes) {
|
|
25
|
+
root.classList.toggle("dark", resolved === "dark");
|
|
26
|
+
root.classList.toggle("light", resolved === "light");
|
|
27
|
+
}
|
|
28
|
+
return resolved;
|
|
29
|
+
}
|
|
30
|
+
function storeThemeChoice(choice, key = THEME_STORAGE_KEY) {
|
|
31
|
+
try {
|
|
32
|
+
if (choice === "system") localStorage.removeItem(key);
|
|
33
|
+
else localStorage.setItem(key, choice);
|
|
34
|
+
} catch {}
|
|
35
|
+
}
|
|
36
|
+
/** Re-applies on OS changes while the choice is System. Returns the unsubscribe. */
|
|
37
|
+
function watchSystemTheme(onChange) {
|
|
38
|
+
const mq = media();
|
|
39
|
+
if (!mq) return () => {};
|
|
40
|
+
const listener = () => onChange(mq.matches ? "dark" : "light");
|
|
41
|
+
mq.addEventListener("change", listener);
|
|
42
|
+
return () => mq.removeEventListener("change", listener);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Inline this in <head> before any stylesheet so the first paint is in the right theme:
|
|
46
|
+
* `<script>{themeScript()}<\/script>`, or dangerouslySetInnerHTML in React.
|
|
47
|
+
*/
|
|
48
|
+
function themeScript(key = THEME_STORAGE_KEY, classes = false) {
|
|
49
|
+
return `(function(){try{var c=localStorage.getItem(${JSON.stringify(key)});}catch(e){}var d=c==="dark"||(c!=="light"&&matchMedia("(prefers-color-scheme: dark)").matches);var r=document.documentElement;r.dataset.theme=d?"dark":"light";r.style.colorScheme=d?"dark":"light";${classes ? "r.classList.toggle(\"dark\",d);r.classList.toggle(\"light\",!d);" : ""}})();`;
|
|
50
|
+
}
|
|
51
|
+
export { THEME_STORAGE_KEY, applyTheme, readThemeChoice, resolveTheme, storeThemeChoice, themeScript, watchSystemTheme };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../src/lib/theme.ts"],"sourcesContent":["// Theme choice: System, Light or Dark, persisted. The resolved theme is written to <html data-theme>, so CSS\n// and Tailwind's dark: variant see one attribute; in System it follows the OS live. Without JavaScript the\n// tokens' prefers-color-scheme rule gives the same result.\n\nexport type ThemeChoice = \"system\" | \"light\" | \"dark\";\nexport type ResolvedTheme = \"light\" | \"dark\";\n\nexport const THEME_STORAGE_KEY = \"seamount.theme\";\n\nconst isChoice = (value: unknown): value is ThemeChoice => value === \"system\" || value === \"light\" || value === \"dark\";\n\nconst media = (): MediaQueryList | undefined =>\n typeof window === \"undefined\" ? undefined : window.matchMedia(\"(prefers-color-scheme: dark)\");\n\n/** The stored choice; storage can be absent or throw (private windows), which reads as System. */\nexport function readThemeChoice(key: string = THEME_STORAGE_KEY): ThemeChoice {\n try {\n const value = localStorage.getItem(key);\n return isChoice(value) ? value : \"system\";\n } catch {\n return \"system\";\n }\n}\n\nexport function resolveTheme(choice: ThemeChoice): ResolvedTheme {\n if (choice !== \"system\") return choice;\n return media()?.matches ? \"dark\" : \"light\";\n}\n\n/** Writes the resolved theme to the root element. `classes` also toggles .dark and .light. */\nexport function applyTheme(\n choice: ThemeChoice,\n { root = document.documentElement, classes = false }: { root?: HTMLElement; classes?: boolean } = {},\n): ResolvedTheme {\n const resolved = resolveTheme(choice);\n root.dataset.theme = resolved;\n root.style.colorScheme = resolved;\n if (classes) {\n root.classList.toggle(\"dark\", resolved === \"dark\");\n root.classList.toggle(\"light\", resolved === \"light\");\n }\n return resolved;\n}\n\nexport function storeThemeChoice(choice: ThemeChoice, key: string = THEME_STORAGE_KEY): void {\n try {\n if (choice === \"system\") localStorage.removeItem(key);\n else localStorage.setItem(key, choice);\n } catch {\n // Storage blocked: the choice lasts for this page only\n }\n}\n\n/** Re-applies on OS changes while the choice is System. Returns the unsubscribe. */\nexport function watchSystemTheme(onChange: (resolved: ResolvedTheme) => void): () => void {\n const mq = media();\n if (!mq) return () => {};\n const listener = (): void => onChange(mq.matches ? \"dark\" : \"light\");\n mq.addEventListener(\"change\", listener);\n return () => mq.removeEventListener(\"change\", listener);\n}\n\n/**\n * Inline this in <head> before any stylesheet so the first paint is in the right theme:\n * `<script>{themeScript()}</script>`, or dangerouslySetInnerHTML in React.\n */\nexport function themeScript(key: string = THEME_STORAGE_KEY, classes = false): string {\n return `(function(){try{var c=localStorage.getItem(${JSON.stringify(key)});}catch(e){}var d=c===\"dark\"||(c!==\"light\"&&matchMedia(\"(prefers-color-scheme: dark)\").matches);var r=document.documentElement;r.dataset.theme=d?\"dark\":\"light\";r.style.colorScheme=d?\"dark\":\"light\";${\n classes ? 'r.classList.toggle(\"dark\",d);r.classList.toggle(\"light\",!d);' : \"\"\n }})();`;\n}\n"],"mappings":";;AAOA,MAAa,oBAAoB;AAEjC,MAAM,YAAY,UAAyC,UAAU,YAAY,UAAU,WAAW,UAAU;AAEhH,MAAM,cACJ,OAAO,WAAW,cAAc,KAAA,IAAY,OAAO,WAAW,8BAA8B;;AAG9F,SAAgB,gBAAgB,MAAc,mBAAgC;CAC5E,IAAI;EACF,MAAM,QAAQ,aAAa,QAAQ,GAAG;EACtC,OAAO,SAAS,KAAK,IAAI,QAAQ;CACnC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAgB,aAAa,QAAoC;CAC/D,IAAI,WAAW,UAAU,OAAO;CAChC,OAAO,MAAM,CAAC,EAAE,UAAU,SAAS;AACrC;;AAGA,SAAgB,WACd,QACA,EAAE,OAAO,SAAS,iBAAiB,UAAU,UAAqD,CAAC,GACpF;CACf,MAAM,WAAW,aAAa,MAAM;CACpC,KAAK,QAAQ,QAAQ;CACrB,KAAK,MAAM,cAAc;CACzB,IAAI,SAAS;EACX,KAAK,UAAU,OAAO,QAAQ,aAAa,MAAM;EACjD,KAAK,UAAU,OAAO,SAAS,aAAa,OAAO;CACrD;CACA,OAAO;AACT;AAEA,SAAgB,iBAAiB,QAAqB,MAAc,mBAAyB;CAC3F,IAAI;EACF,IAAI,WAAW,UAAU,aAAa,WAAW,GAAG;OAC/C,aAAa,QAAQ,KAAK,MAAM;CACvC,QAAQ,CAER;AACF;;AAGA,SAAgB,iBAAiB,UAAyD;CACxF,MAAM,KAAK,MAAM;CACjB,IAAI,CAAC,IAAI,aAAa,CAAC;CACvB,MAAM,iBAAuB,SAAS,GAAG,UAAU,SAAS,OAAO;CACnE,GAAG,iBAAiB,UAAU,QAAQ;CACtC,aAAa,GAAG,oBAAoB,UAAU,QAAQ;AACxD;;;;;AAMA,SAAgB,YAAY,MAAc,mBAAmB,UAAU,OAAe;CACpF,OAAO,8CAA8C,KAAK,UAAU,GAAG,EAAE,wMACvE,UAAU,qEAAiE,GAC5E;AACH"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type ButtonVariant = "default" | "primary" | "ghost" | "destructive" | "link";
|
|
4
|
+
export type ButtonSize = "md" | "sm" | "icon" | "icon-sm";
|
|
5
|
+
export type ButtonProps = React.ComponentProps<"button"> & {
|
|
6
|
+
/** One primary per view. Destructive is Ember and always says what it destroys ("Delete account"). */
|
|
7
|
+
variant?: ButtonVariant;
|
|
8
|
+
size?: ButtonSize;
|
|
9
|
+
/** Renders the child element (a link, say) with the button's styling. */
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function Button({ className, variant, size, asChild, type, ...props }: ButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Slot } from "radix-ui";
|
|
3
|
+
import { cn } from "./cn.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/react/button.tsx
|
|
6
|
+
function Button({ className, variant = "default", size = "md", asChild = false, type, ...props }) {
|
|
7
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
8
|
+
return /* @__PURE__ */ jsx(Comp, {
|
|
9
|
+
"data-slot": "button",
|
|
10
|
+
"data-variant": variant,
|
|
11
|
+
"data-size": size,
|
|
12
|
+
className: cn("sm-button", className),
|
|
13
|
+
type: asChild ? type : type ?? "button",
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { Button };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../src/react/button.tsx"],"sourcesContent":["import { Slot } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { cn } from \"./cn\";\n\nexport type ButtonVariant = \"default\" | \"primary\" | \"ghost\" | \"destructive\" | \"link\";\nexport type ButtonSize = \"md\" | \"sm\" | \"icon\" | \"icon-sm\";\n\nexport type ButtonProps = React.ComponentProps<\"button\"> & {\n /** One primary per view. Destructive is Ember and always says what it destroys (\"Delete account\"). */\n variant?: ButtonVariant;\n size?: ButtonSize;\n /** Renders the child element (a link, say) with the button's styling. */\n asChild?: boolean;\n};\n\nexport function Button({\n className,\n variant = \"default\",\n size = \"md\",\n asChild = false,\n type,\n ...props\n}: ButtonProps): React.JSX.Element {\n const Comp = asChild ? Slot.Root : \"button\";\n return (\n <Comp\n data-slot=\"button\"\n data-variant={variant}\n data-size={size}\n className={cn(\"sm-button\", className)}\n // A bare <button> inside a form submits; default to \"button\" so only an explicit submit does\n type={asChild ? type : (type ?? \"button\")}\n {...props}\n />\n );\n}\n"],"mappings":";;;;;AAeA,SAAgB,OAAO,EACrB,WACA,UAAU,WACV,OAAO,MACP,UAAU,OACV,MACA,GAAG,SAC8B;CACjC,MAAM,OAAO,UAAU,KAAK,OAAO;CACnC,OACE,oBAAC,MAAD;EACE,aAAU;EACV,gBAAc;EACd,aAAW;EACX,WAAW,GAAG,aAAa,SAAS;EAEpC,MAAM,UAAU,OAAQ,QAAQ;EAChC,GAAI;CACL,CAAA;AAEL"}
|
package/dist/react/cn.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
// src/react/cn.ts
|
|
4
|
+
/** Joins class names; the components need no Tailwind merge because their styles live in classes, not utilities. */
|
|
5
|
+
function cn(...values) {
|
|
6
|
+
return clsx(values);
|
|
7
|
+
}
|
|
8
|
+
export { cn };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=cn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cn.js","names":[],"sources":["../../src/react/cn.ts"],"sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\n\n/** Joins class names; the components need no Tailwind merge because their styles live in classes, not utilities. */\nexport function cn(...values: ClassValue[]): string {\n return clsx(values);\n}\n"],"mappings":";;;;AAGA,SAAgB,GAAG,GAAG,QAA8B;CAClD,OAAO,KAAK,MAAM;AACpB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { Checkbox as Checkbox$1, Switch as Switch$1 } from "radix-ui";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/** Only for a true on and off; anything with more states is a segmented control. */
|
|
5
|
+
export declare function Switch({ className, ...props }: React.ComponentProps<typeof Switch$1.Root>): React.JSX.Element;
|
|
6
|
+
export declare function Checkbox({ className, ...props }: React.ComponentProps<typeof Checkbox$1.Root>): React.JSX.Element;
|
|
7
|
+
export type SegmentedOption<T extends string> = {
|
|
8
|
+
value: T;
|
|
9
|
+
label: React.ReactNode;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type SegmentedControlProps<T extends string> = {
|
|
13
|
+
value: T;
|
|
14
|
+
onValueChange: (value: T) => void;
|
|
15
|
+
/** Up to four; more becomes a Select. */
|
|
16
|
+
options: ReadonlyArray<SegmentedOption<T>>;
|
|
17
|
+
"aria-label"?: string;
|
|
18
|
+
"aria-labelledby"?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** One of up to four choices, always one selected: clicking the current choice keeps it. */
|
|
23
|
+
export declare function SegmentedControl<T extends string>({ value, onValueChange, options, className, disabled, ...aria }: SegmentedControlProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Checkbox as Checkbox$1, Switch as Switch$1, ToggleGroup } from "radix-ui";
|
|
3
|
+
import { cn } from "./cn.js";
|
|
4
|
+
import { useFieldControlProps } from "./field.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// src/react/controls.tsx
|
|
7
|
+
/** Only for a true on and off; anything with more states is a segmented control. */
|
|
8
|
+
function Switch({ className, ...props }) {
|
|
9
|
+
const wired = useFieldControlProps(props);
|
|
10
|
+
return /* @__PURE__ */ jsx(Switch$1.Root, {
|
|
11
|
+
"data-slot": "switch",
|
|
12
|
+
className: cn("sm-switch", className),
|
|
13
|
+
...props,
|
|
14
|
+
...wired,
|
|
15
|
+
children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: "sm-switch-thumb" })
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function Checkbox({ className, ...props }) {
|
|
19
|
+
const wired = useFieldControlProps(props);
|
|
20
|
+
return /* @__PURE__ */ jsx(Checkbox$1.Root, {
|
|
21
|
+
"data-slot": "checkbox",
|
|
22
|
+
className: cn("sm-checkbox", className),
|
|
23
|
+
...props,
|
|
24
|
+
...wired,
|
|
25
|
+
children: /* @__PURE__ */ jsx(Checkbox$1.Indicator, { className: "sm-checkbox-indicator" })
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** One of up to four choices, always one selected: clicking the current choice keeps it. */
|
|
29
|
+
function SegmentedControl({ value, onValueChange, options, className, disabled, ...aria }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(ToggleGroup.Root, {
|
|
31
|
+
type: "single",
|
|
32
|
+
"data-slot": "segmented",
|
|
33
|
+
className: cn("sm-segmented", className),
|
|
34
|
+
value,
|
|
35
|
+
disabled,
|
|
36
|
+
onValueChange: (next) => {
|
|
37
|
+
if (next) onValueChange(next);
|
|
38
|
+
},
|
|
39
|
+
...aria,
|
|
40
|
+
children: options.map((option) => /* @__PURE__ */ jsx(ToggleGroup.Item, {
|
|
41
|
+
value: option.value,
|
|
42
|
+
disabled: option.disabled,
|
|
43
|
+
className: "sm-segmented-item",
|
|
44
|
+
children: option.label
|
|
45
|
+
}, option.value))
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export { Checkbox, SegmentedControl, Switch };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controls.js","names":["SwitchPrimitive","CheckboxPrimitive"],"sources":["../../src/react/controls.tsx"],"sourcesContent":["import { Checkbox as CheckboxPrimitive, Switch as SwitchPrimitive, ToggleGroup } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { cn } from \"./cn\";\nimport { useFieldControlProps } from \"./field\";\n\n/** Only for a true on and off; anything with more states is a segmented control. */\nexport function Switch({ className, ...props }: React.ComponentProps<typeof SwitchPrimitive.Root>): React.JSX.Element {\n const wired = useFieldControlProps(props);\n return (\n <SwitchPrimitive.Root data-slot=\"switch\" className={cn(\"sm-switch\", className)} {...props} {...wired}>\n <SwitchPrimitive.Thumb className=\"sm-switch-thumb\" />\n </SwitchPrimitive.Root>\n );\n}\n\nexport function Checkbox({\n className,\n ...props\n}: React.ComponentProps<typeof CheckboxPrimitive.Root>): React.JSX.Element {\n const wired = useFieldControlProps(props);\n return (\n <CheckboxPrimitive.Root data-slot=\"checkbox\" className={cn(\"sm-checkbox\", className)} {...props} {...wired}>\n <CheckboxPrimitive.Indicator className=\"sm-checkbox-indicator\" />\n </CheckboxPrimitive.Root>\n );\n}\n\nexport type SegmentedOption<T extends string> = {\n value: T;\n label: React.ReactNode;\n disabled?: boolean;\n};\n\nexport type SegmentedControlProps<T extends string> = {\n value: T;\n onValueChange: (value: T) => void;\n /** Up to four; more becomes a Select. */\n options: ReadonlyArray<SegmentedOption<T>>;\n \"aria-label\"?: string;\n \"aria-labelledby\"?: string;\n className?: string;\n disabled?: boolean;\n};\n\n/** One of up to four choices, always one selected: clicking the current choice keeps it. */\nexport function SegmentedControl<T extends string>({\n value,\n onValueChange,\n options,\n className,\n disabled,\n ...aria\n}: SegmentedControlProps<T>): React.JSX.Element {\n return (\n <ToggleGroup.Root\n type=\"single\"\n data-slot=\"segmented\"\n className={cn(\"sm-segmented\", className)}\n value={value}\n disabled={disabled}\n onValueChange={(next) => {\n // Radix clears a single group when the pressed item is pressed again\n if (next) onValueChange(next as T);\n }}\n {...aria}\n >\n {options.map((option) => (\n <ToggleGroup.Item\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n className=\"sm-segmented-item\"\n >\n {option.label}\n </ToggleGroup.Item>\n ))}\n </ToggleGroup.Root>\n );\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,OAAO,EAAE,WAAW,GAAG,SAA+E;CACpH,MAAM,QAAQ,qBAAqB,KAAK;CACxC,OACE,oBAACA,SAAgB,MAAjB;EAAsB,aAAU;EAAS,WAAW,GAAG,aAAa,SAAS;EAAG,GAAI;EAAO,GAAI;EAC7F,UAAA,oBAACA,SAAgB,OAAjB,EAAuB,WAAU,kBAAmB,CAAA;CAChC,CAAA;AAE1B;AAEA,SAAgB,SAAS,EACvB,WACA,GAAG,SACsE;CACzE,MAAM,QAAQ,qBAAqB,KAAK;CACxC,OACE,oBAACC,WAAkB,MAAnB;EAAwB,aAAU;EAAW,WAAW,GAAG,eAAe,SAAS;EAAG,GAAI;EAAO,GAAI;EACnG,UAAA,oBAACA,WAAkB,WAAnB,EAA6B,WAAU,wBAAyB,CAAA;CAC1C,CAAA;AAE5B;;AAoBA,SAAgB,iBAAmC,EACjD,OACA,eACA,SACA,WACA,UACA,GAAG,QAC2C;CAC9C,OACE,oBAAC,YAAY,MAAb;EACE,MAAK;EACL,aAAU;EACV,WAAW,GAAG,gBAAgB,SAAS;EAChC;EACG;EACV,gBAAgB,SAAS;GAEvB,IAAI,MAAM,cAAc,IAAS;EACnC;EACA,GAAI;EAEH,UAAA,QAAQ,KAAK,WACZ,oBAAC,YAAY,MAAb;GAEE,OAAO,OAAO;GACd,UAAU,OAAO;GACjB,WAAU;GAET,UAAA,OAAO;EACQ,GANX,OAAO,KAMI,CACnB;CACe,CAAA;AAEtB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
|
|
2
|
+
import { Dialog as Dialog$1 } from "radix-ui";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export declare const Dialog: typeof Dialog$1.Root;
|
|
5
|
+
export declare const DialogTrigger: typeof Dialog$1.Trigger;
|
|
6
|
+
export declare const DialogClose: typeof Dialog$1.Close;
|
|
7
|
+
export type DialogContentProps = React.ComponentProps<typeof Dialog$1.Content> & {
|
|
8
|
+
size?: "md" | "lg";
|
|
9
|
+
/** On narrow screens, rise from the bottom as a sheet. */
|
|
10
|
+
sheet?: boolean;
|
|
11
|
+
/** Show an Esc close control in the corner. The Esc key works either way. */
|
|
12
|
+
closeButton?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function DialogContent({ className, children, size, sheet, closeButton, ...props }: DialogContentProps): React.JSX.Element;
|
|
15
|
+
export declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof Dialog$1.Title>): React.JSX.Element;
|
|
16
|
+
export declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof Dialog$1.Description>): React.JSX.Element;
|
|
17
|
+
export declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
18
|
+
export type ConfirmDialogProps = {
|
|
19
|
+
open?: boolean;
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/** The element that opens it; focus returns here on close. */
|
|
23
|
+
trigger?: React.ReactNode;
|
|
24
|
+
/** The action as a question: "Delete this account?" */
|
|
25
|
+
title: React.ReactNode;
|
|
26
|
+
/** What happens, as a short list. */
|
|
27
|
+
consequences?: ReadonlyArray<React.ReactNode>;
|
|
28
|
+
description?: React.ReactNode;
|
|
29
|
+
/** A verb: "Delete", "Uninstall". */
|
|
30
|
+
actionLabel: string;
|
|
31
|
+
cancelLabel?: string;
|
|
32
|
+
/** Ember, for an action that destroys something. */
|
|
33
|
+
destructive?: boolean;
|
|
34
|
+
onConfirm: () => void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Only for what cannot be undone; anything reversible applies at once with Undo. Focus starts on Cancel
|
|
38
|
+
* and returns to the trigger on close (Radix AlertDialog).
|
|
39
|
+
*/
|
|
40
|
+
export declare function ConfirmDialog({ open, defaultOpen, onOpenChange, trigger, title, consequences, description, actionLabel, cancelLabel, destructive, onConfirm }: ConfirmDialogProps): React.JSX.Element;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AlertDialog, Dialog as Dialog$1 } from "radix-ui";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/react/dialog.tsx
|
|
7
|
+
const Dialog = Dialog$1.Root;
|
|
8
|
+
const DialogTrigger = Dialog$1.Trigger;
|
|
9
|
+
const DialogClose = Dialog$1.Close;
|
|
10
|
+
function DialogContent({ className, children, size = "md", sheet = false, closeButton = true, ...props }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(Dialog$1.Portal, { children: [/* @__PURE__ */ jsx(Dialog$1.Overlay, { className: "sm-overlay" }), /* @__PURE__ */ jsxs(Dialog$1.Content, {
|
|
12
|
+
"data-slot": "dialog",
|
|
13
|
+
"data-size": size,
|
|
14
|
+
"data-sheet": sheet || void 0,
|
|
15
|
+
className: cn("sm-dialog", className),
|
|
16
|
+
...props,
|
|
17
|
+
children: [children, closeButton && /* @__PURE__ */ jsx(Dialog$1.Close, {
|
|
18
|
+
asChild: true,
|
|
19
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
20
|
+
variant: "ghost",
|
|
21
|
+
size: "sm",
|
|
22
|
+
className: "sm-dialog-close",
|
|
23
|
+
"aria-label": "Close",
|
|
24
|
+
children: "Esc"
|
|
25
|
+
})
|
|
26
|
+
})]
|
|
27
|
+
})] });
|
|
28
|
+
}
|
|
29
|
+
function DialogTitle({ className, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Dialog$1.Title, {
|
|
31
|
+
className: cn("sm-dialog-title", className),
|
|
32
|
+
...props
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function DialogDescription({ className, ...props }) {
|
|
36
|
+
return /* @__PURE__ */ jsx(Dialog$1.Description, {
|
|
37
|
+
className: cn("sm-dialog-description", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function DialogFooter({ className, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx("div", {
|
|
43
|
+
"data-slot": "dialog-footer",
|
|
44
|
+
className: cn("sm-dialog-footer", className),
|
|
45
|
+
...props
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Only for what cannot be undone; anything reversible applies at once with Undo. Focus starts on Cancel
|
|
50
|
+
* and returns to the trigger on close (Radix AlertDialog).
|
|
51
|
+
*/
|
|
52
|
+
function ConfirmDialog({ open, defaultOpen, onOpenChange, trigger, title, consequences, description, actionLabel, cancelLabel = "Cancel", destructive = false, onConfirm }) {
|
|
53
|
+
const hasList = Boolean(consequences?.length);
|
|
54
|
+
return /* @__PURE__ */ jsxs(AlertDialog.Root, {
|
|
55
|
+
open,
|
|
56
|
+
defaultOpen,
|
|
57
|
+
onOpenChange,
|
|
58
|
+
children: [trigger && /* @__PURE__ */ jsx(AlertDialog.Trigger, {
|
|
59
|
+
asChild: true,
|
|
60
|
+
children: trigger
|
|
61
|
+
}), /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [/* @__PURE__ */ jsx(AlertDialog.Overlay, { className: "sm-overlay" }), /* @__PURE__ */ jsxs(AlertDialog.Content, {
|
|
62
|
+
"data-slot": "confirm-dialog",
|
|
63
|
+
className: "sm-dialog",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ jsx(AlertDialog.Title, {
|
|
66
|
+
className: "sm-dialog-title",
|
|
67
|
+
children: title
|
|
68
|
+
}),
|
|
69
|
+
/* @__PURE__ */ jsx(AlertDialog.Description, {
|
|
70
|
+
asChild: true,
|
|
71
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
72
|
+
className: "sm-dialog-description",
|
|
73
|
+
children: [description && /* @__PURE__ */ jsx("p", {
|
|
74
|
+
style: { margin: hasList ? "0 0 0.5rem" : 0 },
|
|
75
|
+
children: description
|
|
76
|
+
}), hasList && /* @__PURE__ */ jsx("ul", {
|
|
77
|
+
className: "sm-list",
|
|
78
|
+
children: consequences?.map((item, i) => /* @__PURE__ */ jsx("li", { children: item }, i))
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ jsxs("div", {
|
|
83
|
+
className: "sm-dialog-footer",
|
|
84
|
+
children: [/* @__PURE__ */ jsx(AlertDialog.Cancel, {
|
|
85
|
+
asChild: true,
|
|
86
|
+
children: /* @__PURE__ */ jsx(Button, { children: cancelLabel })
|
|
87
|
+
}), /* @__PURE__ */ jsx(AlertDialog.Action, {
|
|
88
|
+
asChild: true,
|
|
89
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
90
|
+
variant: destructive ? "destructive" : "primary",
|
|
91
|
+
onClick: onConfirm,
|
|
92
|
+
children: actionLabel
|
|
93
|
+
})
|
|
94
|
+
})]
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})] })]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export { ConfirmDialog, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogTitle, DialogTrigger };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","names":["DialogPrimitive","AlertDialogPrimitive"],"sources":["../../src/react/dialog.tsx"],"sourcesContent":["import { AlertDialog as AlertDialogPrimitive, Dialog as DialogPrimitive } from \"radix-ui\";\nimport type * as React from \"react\";\nimport { Button } from \"./button\";\nimport { cn } from \"./cn\";\n\nexport const Dialog: typeof DialogPrimitive.Root = DialogPrimitive.Root;\nexport const DialogTrigger: typeof DialogPrimitive.Trigger = DialogPrimitive.Trigger;\nexport const DialogClose: typeof DialogPrimitive.Close = DialogPrimitive.Close;\n\nexport type DialogContentProps = React.ComponentProps<typeof DialogPrimitive.Content> & {\n size?: \"md\" | \"lg\";\n /** On narrow screens, rise from the bottom as a sheet. */\n sheet?: boolean;\n /** Show an Esc close control in the corner. The Esc key works either way. */\n closeButton?: boolean;\n};\n\nexport function DialogContent({\n className,\n children,\n size = \"md\",\n sheet = false,\n closeButton = true,\n ...props\n}: DialogContentProps): React.JSX.Element {\n return (\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className=\"sm-overlay\" />\n <DialogPrimitive.Content\n data-slot=\"dialog\"\n data-size={size}\n data-sheet={sheet || undefined}\n className={cn(\"sm-dialog\", className)}\n {...props}\n >\n {children}\n {closeButton && (\n <DialogPrimitive.Close asChild>\n <Button variant=\"ghost\" size=\"sm\" className=\"sm-dialog-close\" aria-label=\"Close\">\n Esc\n </Button>\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n );\n}\n\nexport function DialogTitle({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Title>): React.JSX.Element {\n return <DialogPrimitive.Title className={cn(\"sm-dialog-title\", className)} {...props} />;\n}\n\nexport function DialogDescription({\n className,\n ...props\n}: React.ComponentProps<typeof DialogPrimitive.Description>): React.JSX.Element {\n return <DialogPrimitive.Description className={cn(\"sm-dialog-description\", className)} {...props} />;\n}\n\nexport function DialogFooter({ className, ...props }: React.ComponentProps<\"div\">): React.JSX.Element {\n return <div data-slot=\"dialog-footer\" className={cn(\"sm-dialog-footer\", className)} {...props} />;\n}\n\nexport type ConfirmDialogProps = {\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** The element that opens it; focus returns here on close. */\n trigger?: React.ReactNode;\n /** The action as a question: \"Delete this account?\" */\n title: React.ReactNode;\n /** What happens, as a short list. */\n consequences?: ReadonlyArray<React.ReactNode>;\n description?: React.ReactNode;\n /** A verb: \"Delete\", \"Uninstall\". */\n actionLabel: string;\n cancelLabel?: string;\n /** Ember, for an action that destroys something. */\n destructive?: boolean;\n onConfirm: () => void;\n};\n\n/**\n * Only for what cannot be undone; anything reversible applies at once with Undo. Focus starts on Cancel\n * and returns to the trigger on close (Radix AlertDialog).\n */\nexport function ConfirmDialog({\n open,\n defaultOpen,\n onOpenChange,\n trigger,\n title,\n consequences,\n description,\n actionLabel,\n cancelLabel = \"Cancel\",\n destructive = false,\n onConfirm,\n}: ConfirmDialogProps): React.JSX.Element {\n const hasList = Boolean(consequences?.length);\n return (\n <AlertDialogPrimitive.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>\n {trigger && <AlertDialogPrimitive.Trigger asChild>{trigger}</AlertDialogPrimitive.Trigger>}\n <AlertDialogPrimitive.Portal>\n <AlertDialogPrimitive.Overlay className=\"sm-overlay\" />\n <AlertDialogPrimitive.Content data-slot=\"confirm-dialog\" className=\"sm-dialog\">\n <AlertDialogPrimitive.Title className=\"sm-dialog-title\">{title}</AlertDialogPrimitive.Title>\n <AlertDialogPrimitive.Description asChild>\n <div className=\"sm-dialog-description\">\n {description && <p style={{ margin: hasList ? \"0 0 0.5rem\" : 0 }}>{description}</p>}\n {hasList && (\n <ul className=\"sm-list\">\n {consequences?.map((item, i) => (\n // biome-ignore lint/suspicious/noArrayIndexKey: a fixed list rendered once\n <li key={i}>{item}</li>\n ))}\n </ul>\n )}\n </div>\n </AlertDialogPrimitive.Description>\n <div className=\"sm-dialog-footer\">\n <AlertDialogPrimitive.Cancel asChild>\n <Button>{cancelLabel}</Button>\n </AlertDialogPrimitive.Cancel>\n <AlertDialogPrimitive.Action asChild>\n <Button variant={destructive ? \"destructive\" : \"primary\"} onClick={onConfirm}>\n {actionLabel}\n </Button>\n </AlertDialogPrimitive.Action>\n </div>\n </AlertDialogPrimitive.Content>\n </AlertDialogPrimitive.Portal>\n </AlertDialogPrimitive.Root>\n );\n}\n"],"mappings":";;;;;;AAKA,MAAa,SAAsCA,SAAgB;AACnE,MAAa,gBAAgDA,SAAgB;AAC7E,MAAa,cAA4CA,SAAgB;AAUzE,SAAgB,cAAc,EAC5B,WACA,UACA,OAAO,MACP,QAAQ,OACR,cAAc,MACd,GAAG,SACqC;CACxC,OACE,qBAACA,SAAgB,QAAjB,EAAA,UAAA,CACE,oBAACA,SAAgB,SAAjB,EAAyB,WAAU,aAAc,CAAA,GACjD,qBAACA,SAAgB,SAAjB;EACE,aAAU;EACV,aAAW;EACX,cAAY,SAAS,KAAA;EACrB,WAAW,GAAG,aAAa,SAAS;EACpC,GAAI;EALN,UAAA,CAOG,UACA,eACC,oBAACA,SAAgB,OAAjB;GAAuB,SAAA;GACrB,UAAA,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,MAAK;IAAK,WAAU;IAAkB,cAAW;IAAQ,UAAA;GAEzE,CAAA;EACa,CAAA,CAEF;CACH,CAAA,CAAA,EAAA,CAAA;AAE5B;AAEA,SAAgB,YAAY,EAC1B,WACA,GAAG,SACqE;CACxE,OAAO,oBAACA,SAAgB,OAAjB;EAAuB,WAAW,GAAG,mBAAmB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACzF;AAEA,SAAgB,kBAAkB,EAChC,WACA,GAAG,SAC2E;CAC9E,OAAO,oBAACA,SAAgB,aAAjB;EAA6B,WAAW,GAAG,yBAAyB,SAAS;EAAG,GAAI;CAAQ,CAAA;AACrG;AAEA,SAAgB,aAAa,EAAE,WAAW,GAAG,SAAyD;CACpG,OAAO,oBAAC,OAAD;EAAK,aAAU;EAAgB,WAAW,GAAG,oBAAoB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAClG;;;;;AAyBA,SAAgB,cAAc,EAC5B,MACA,aACA,cACA,SACA,OACA,cACA,aACA,aACA,cAAc,UACd,cAAc,OACd,aACwC;CACxC,MAAM,UAAU,QAAQ,cAAc,MAAM;CAC5C,OACE,qBAACC,YAAqB,MAAtB;EAAiC;EAAmB;EAA2B;EAA/E,UAAA,CACG,WAAW,oBAACA,YAAqB,SAAtB;GAA8B,SAAA;GAAS,UAAA;EAAsC,CAAA,GACzF,qBAACA,YAAqB,QAAtB,EAAA,UAAA,CACE,oBAACA,YAAqB,SAAtB,EAA8B,WAAU,aAAc,CAAA,GACtD,qBAACA,YAAqB,SAAtB;GAA8B,aAAU;GAAiB,WAAU;GAAnE,UAAA;IACE,oBAACA,YAAqB,OAAtB;KAA4B,WAAU;KAAmB,UAAA;IAAkC,CAAA;IAC3F,oBAACA,YAAqB,aAAtB;KAAkC,SAAA;KAChC,UAAA,qBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACG,eAAe,oBAAC,KAAD;OAAG,OAAO,EAAE,QAAQ,UAAU,eAAe,EAAE;OAAI,UAAA;MAAe,CAAA,GACjF,WACC,oBAAC,MAAD;OAAI,WAAU;OACX,UAAA,cAAc,KAAK,MAAM,MAExB,oBAAC,MAAD,EAAA,UAAa,KAAS,GAAb,CAAa,CACvB;MACC,CAAA,CAEH;;IAC2B,CAAA;IAClC,qBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,oBAACA,YAAqB,QAAtB;MAA6B,SAAA;MAC3B,UAAA,oBAAC,QAAD,EAAA,UAAS,YAAoB,CAAA;KACF,CAAA,GAC7B,oBAACA,YAAqB,QAAtB;MAA6B,SAAA;MAC3B,UAAA,oBAAC,QAAD;OAAQ,SAAS,cAAc,gBAAgB;OAAW,SAAS;OAChE,UAAA;MACK,CAAA;KACmB,CAAA,CAC1B;;GACuB;EACH,CAAA,CAAA,EAAA,CAAA,CACJ;;AAE/B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type BannerProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
4
|
+
/** One sentence naming the condition. */
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
/** One action, e.g. "Close MSI Center". */
|
|
7
|
+
action?: React.ReactNode;
|
|
8
|
+
/** Shows a Dismiss control; the app remembers the dismissal. */
|
|
9
|
+
onDismiss?: () => void;
|
|
10
|
+
tone?: "accent" | "ember";
|
|
11
|
+
};
|
|
12
|
+
/** A lasting condition, across the top of the content. */
|
|
13
|
+
export declare function Banner({ children, action, onDismiss, tone, className, ...props }: BannerProps): React.JSX.Element;
|
|
14
|
+
export type EmptyStateProps = Omit<React.ComponentProps<"div">, "title" | "children"> & {
|
|
15
|
+
title: React.ReactNode;
|
|
16
|
+
/** Why it is empty and when it fills. */
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
/** One action. */
|
|
19
|
+
action?: React.ReactNode;
|
|
20
|
+
};
|
|
21
|
+
export declare function EmptyState({ title, children, action, className, ...props }: EmptyStateProps): React.JSX.Element;
|
|
22
|
+
export declare function Skeleton({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
23
|
+
export type LoadingStateProps = Omit<React.ComponentProps<"p">, "children"> & {
|
|
24
|
+
/** Inline mono state: "Reading…", or a count past 2 s: "Reading 3 of 7 days". */
|
|
25
|
+
children?: React.ReactNode;
|
|
26
|
+
/** Nothing renders before this many milliseconds, so fast loads never flash. */
|
|
27
|
+
delay?: number;
|
|
28
|
+
};
|
|
29
|
+
/** Shows nothing under 300 ms, then an inline state line. Never a spinner without words. */
|
|
30
|
+
export declare function LoadingState({ children, delay, className, ...props }: LoadingStateProps): React.JSX.Element | null;
|
|
31
|
+
export declare function Table({ className, ...props }: React.ComponentProps<"table">): React.JSX.Element;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Button } from "./button.js";
|
|
4
|
+
import { cn } from "./cn.js";
|
|
5
|
+
import { Square } from "./label.js";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/react/feedback.tsx
|
|
8
|
+
/** A lasting condition, across the top of the content. */
|
|
9
|
+
function Banner({ children, action, onDismiss, tone = "accent", className, ...props }) {
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
"data-slot": "banner",
|
|
12
|
+
"data-tone": tone,
|
|
13
|
+
role: "status",
|
|
14
|
+
className: cn("sm-banner", className),
|
|
15
|
+
...props,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(Square, { tone: tone === "ember" ? "ember" : void 0 }),
|
|
18
|
+
/* @__PURE__ */ jsx("p", {
|
|
19
|
+
className: "sm-banner-text",
|
|
20
|
+
style: { margin: 0 },
|
|
21
|
+
children
|
|
22
|
+
}),
|
|
23
|
+
action,
|
|
24
|
+
onDismiss && /* @__PURE__ */ jsx(Button, {
|
|
25
|
+
variant: "ghost",
|
|
26
|
+
size: "sm",
|
|
27
|
+
onClick: onDismiss,
|
|
28
|
+
children: "Dismiss"
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function EmptyState({ title, children, action, className, ...props }) {
|
|
34
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
35
|
+
"data-slot": "empty",
|
|
36
|
+
className: cn("sm-empty", className),
|
|
37
|
+
...props,
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("p", {
|
|
40
|
+
className: "sm-empty-title",
|
|
41
|
+
children: title
|
|
42
|
+
}),
|
|
43
|
+
children && /* @__PURE__ */ jsx("p", {
|
|
44
|
+
className: "sm-empty-text",
|
|
45
|
+
children
|
|
46
|
+
}),
|
|
47
|
+
action
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function Skeleton({ className, ...props }) {
|
|
52
|
+
return /* @__PURE__ */ jsx("span", {
|
|
53
|
+
"data-slot": "skeleton",
|
|
54
|
+
"aria-hidden": "true",
|
|
55
|
+
className: cn("sm-skeleton", className),
|
|
56
|
+
...props
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Shows nothing under 300 ms, then an inline state line. Never a spinner without words. */
|
|
60
|
+
function LoadingState({ children = "Loading…", delay = 300, className, ...props }) {
|
|
61
|
+
const [visible, setVisible] = React.useState(delay <= 0);
|
|
62
|
+
React.useEffect(() => {
|
|
63
|
+
if (delay <= 0) return;
|
|
64
|
+
const timer = setTimeout(() => setVisible(true), delay);
|
|
65
|
+
return () => clearTimeout(timer);
|
|
66
|
+
}, [delay]);
|
|
67
|
+
if (!visible) return null;
|
|
68
|
+
return /* @__PURE__ */ jsx("p", {
|
|
69
|
+
"data-slot": "loading",
|
|
70
|
+
role: "status",
|
|
71
|
+
className: cn("sm-state", className),
|
|
72
|
+
style: { margin: 0 },
|
|
73
|
+
...props,
|
|
74
|
+
children
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function Table({ className, ...props }) {
|
|
78
|
+
return /* @__PURE__ */ jsx("table", {
|
|
79
|
+
"data-slot": "table",
|
|
80
|
+
className: cn("sm-table", className),
|
|
81
|
+
...props
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
export { Banner, EmptyState, LoadingState, Skeleton, Table };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=feedback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feedback.js","names":[],"sources":["../../src/react/feedback.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { Button } from \"./button\";\nimport { cn } from \"./cn\";\nimport { Square } from \"./label\";\n\nexport type BannerProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** One sentence naming the condition. */\n children: React.ReactNode;\n /** One action, e.g. \"Close MSI Center\". */\n action?: React.ReactNode;\n /** Shows a Dismiss control; the app remembers the dismissal. */\n onDismiss?: () => void;\n tone?: \"accent\" | \"ember\";\n};\n\n/** A lasting condition, across the top of the content. */\nexport function Banner({\n children,\n action,\n onDismiss,\n tone = \"accent\",\n className,\n ...props\n}: BannerProps): React.JSX.Element {\n return (\n <div data-slot=\"banner\" data-tone={tone} role=\"status\" className={cn(\"sm-banner\", className)} {...props}>\n <Square tone={tone === \"ember\" ? \"ember\" : undefined} />\n <p className=\"sm-banner-text\" style={{ margin: 0 }}>\n {children}\n </p>\n {action}\n {onDismiss && (\n <Button variant=\"ghost\" size=\"sm\" onClick={onDismiss}>\n Dismiss\n </Button>\n )}\n </div>\n );\n}\n\nexport type EmptyStateProps = Omit<React.ComponentProps<\"div\">, \"title\" | \"children\"> & {\n title: React.ReactNode;\n /** Why it is empty and when it fills. */\n children?: React.ReactNode;\n /** One action. */\n action?: React.ReactNode;\n};\n\nexport function EmptyState({ title, children, action, className, ...props }: EmptyStateProps): React.JSX.Element {\n return (\n <div data-slot=\"empty\" className={cn(\"sm-empty\", className)} {...props}>\n <p className=\"sm-empty-title\">{title}</p>\n {children && <p className=\"sm-empty-text\">{children}</p>}\n {action}\n </div>\n );\n}\n\nexport function Skeleton({ className, ...props }: React.ComponentProps<\"span\">): React.JSX.Element {\n return <span data-slot=\"skeleton\" aria-hidden=\"true\" className={cn(\"sm-skeleton\", className)} {...props} />;\n}\n\nexport type LoadingStateProps = Omit<React.ComponentProps<\"p\">, \"children\"> & {\n /** Inline mono state: \"Reading…\", or a count past 2 s: \"Reading 3 of 7 days\". */\n children?: React.ReactNode;\n /** Nothing renders before this many milliseconds, so fast loads never flash. */\n delay?: number;\n};\n\n/** Shows nothing under 300 ms, then an inline state line. Never a spinner without words. */\nexport function LoadingState({\n children = \"Loading…\",\n delay = 300,\n className,\n ...props\n}: LoadingStateProps): React.JSX.Element | null {\n const [visible, setVisible] = React.useState(delay <= 0);\n React.useEffect(() => {\n if (delay <= 0) return;\n const timer = setTimeout(() => setVisible(true), delay);\n return () => clearTimeout(timer);\n }, [delay]);\n if (!visible) return null;\n return (\n <p data-slot=\"loading\" role=\"status\" className={cn(\"sm-state\", className)} style={{ margin: 0 }} {...props}>\n {children}\n </p>\n );\n}\n\nexport function Table({ className, ...props }: React.ComponentProps<\"table\">): React.JSX.Element {\n return <table data-slot=\"table\" className={cn(\"sm-table\", className)} {...props} />;\n}\n"],"mappings":";;;;;;;;AAgBA,SAAgB,OAAO,EACrB,UACA,QACA,WACA,OAAO,UACP,WACA,GAAG,SAC8B;CACjC,OACE,qBAAC,OAAD;EAAK,aAAU;EAAS,aAAW;EAAM,MAAK;EAAS,WAAW,GAAG,aAAa,SAAS;EAAG,GAAI;EAAlG,UAAA;GACE,oBAAC,QAAD,EAAQ,MAAM,SAAS,UAAU,UAAU,KAAA,EAAY,CAAA;GACvD,oBAAC,KAAD;IAAG,WAAU;IAAiB,OAAO,EAAE,QAAQ,EAAE;IAC9C;GACA,CAAA;GACF;GACA,aACC,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,MAAK;IAAK,SAAS;IAAW,UAAA;GAE9C,CAAA;EAEP;;AAET;AAUA,SAAgB,WAAW,EAAE,OAAO,UAAU,QAAQ,WAAW,GAAG,SAA6C;CAC/G,OACE,qBAAC,OAAD;EAAK,aAAU;EAAQ,WAAW,GAAG,YAAY,SAAS;EAAG,GAAI;EAAjE,UAAA;GACE,oBAAC,KAAD;IAAG,WAAU;IAAkB,UAAA;GAAS,CAAA;GACvC,YAAY,oBAAC,KAAD;IAAG,WAAU;IAAiB;GAAY,CAAA;GACtD;EACE;;AAET;AAEA,SAAgB,SAAS,EAAE,WAAW,GAAG,SAA0D;CACjG,OAAO,oBAAC,QAAD;EAAM,aAAU;EAAW,eAAY;EAAO,WAAW,GAAG,eAAe,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC5G;;AAUA,SAAgB,aAAa,EAC3B,WAAW,YACX,QAAQ,KACR,WACA,GAAG,SAC2C;CAC9C,MAAM,CAAC,SAAS,cAAc,MAAM,SAAS,SAAS,CAAC;CACvD,MAAM,gBAAgB;EACpB,IAAI,SAAS,GAAG;EAChB,MAAM,QAAQ,iBAAiB,WAAW,IAAI,GAAG,KAAK;EACtD,aAAa,aAAa,KAAK;CACjC,GAAG,CAAC,KAAK,CAAC;CACV,IAAI,CAAC,SAAS,OAAO;CACrB,OACE,oBAAC,KAAD;EAAG,aAAU;EAAU,MAAK;EAAS,WAAW,GAAG,YAAY,SAAS;EAAG,OAAO,EAAE,QAAQ,EAAE;EAAG,GAAI;EAClG;CACA,CAAA;AAEP;AAEA,SAAgB,MAAM,EAAE,WAAW,GAAG,SAA2D;CAC/F,OAAO,oBAAC,SAAD;EAAO,aAAU;EAAQ,WAAW,GAAG,YAAY,SAAS;EAAG,GAAI;CAAQ,CAAA;AACpF"}
|