@ramme-io/ui 5.3.0 → 5.4.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/README.md +1 -1
- package/dist/components/data-display/DataTable.d.ts +5 -0
- package/dist/components/data-display/DataTable.js +31 -29
- package/dist/components/data-display/_DataTableCards.js +31 -31
- package/dist/components/forms/SegmentedControl.js +14 -9
- package/dist/components/layout/AppShell.js +32 -32
- package/dist/components/layout/AppShell.print.test.d.ts +1 -0
- package/dist/components/ui/Avatar.d.ts +35 -6
- package/dist/components/ui/Avatar.js +54 -20
- package/dist/components/ui/Badge.d.ts +1 -1
- package/dist/components/ui/Icon.js +21 -11
- package/dist/contexts/ThemeContext.d.ts +6 -0
- package/dist/contexts/ThemeContext.js +90 -73
- package/dist/index.css +1 -1
- package/dist/index.js +83 -82
- package/dist/lib/hooks/useChartTheme.d.ts +21 -0
- package/dist/lib/hooks/useChartTheme.js +39 -22
- package/dist/lib/theme/themeUtils.d.ts +7 -1
- package/dist/lib/theme/themeUtils.js +50 -27
- package/dist/print-palette.test.d.ts +1 -0
- package/dist/wizardManifest.js +39 -7
- package/package.json +2 -2
- package/src/wizardManifest.ts +39 -7
- package/tailwind.preset.js +1 -0
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
-
import { memo as
|
|
2
|
+
import { memo as l, useState as u, useEffect as f } from "react";
|
|
3
3
|
import I from "lucide-react/dynamicIconImports";
|
|
4
|
-
const
|
|
5
|
-
const [n,
|
|
6
|
-
|
|
7
|
-
let
|
|
4
|
+
const a = ({ name: o, className: t, ...e }) => {
|
|
5
|
+
const [n, d] = u(null);
|
|
6
|
+
if (f(() => {
|
|
7
|
+
let i = !0;
|
|
8
8
|
return (async () => {
|
|
9
9
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const s = await I[o]();
|
|
11
|
+
i && d(() => s.default);
|
|
12
12
|
} catch {
|
|
13
13
|
console.error(`Icon not found: ${o}`);
|
|
14
14
|
}
|
|
15
15
|
})(), () => {
|
|
16
|
-
|
|
16
|
+
i = !1;
|
|
17
17
|
};
|
|
18
|
-
}, [o]), n
|
|
19
|
-
|
|
18
|
+
}, [o]), n)
|
|
19
|
+
return /* @__PURE__ */ c(n, { className: t, ...e });
|
|
20
|
+
const m = !e.size && /(^|\s)(h|w|size)-/.test(t ?? ""), r = e.size || 24;
|
|
21
|
+
return /* @__PURE__ */ c(
|
|
22
|
+
"span",
|
|
23
|
+
{
|
|
24
|
+
"aria-hidden": "true",
|
|
25
|
+
className: ["inline-block shrink-0", t].filter(Boolean).join(" "),
|
|
26
|
+
style: m ? void 0 : { height: r, width: r }
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}, w = l(a);
|
|
20
30
|
export {
|
|
21
|
-
|
|
31
|
+
w as Icon
|
|
22
32
|
};
|
|
@@ -47,6 +47,12 @@ interface ThemeContextType {
|
|
|
47
47
|
setFontSize: (size: string) => void;
|
|
48
48
|
customTheme: ThemeConfig | null;
|
|
49
49
|
setCustomTheme: (config: ThemeConfig | null) => void;
|
|
50
|
+
/**
|
|
51
|
+
* True while the browser is printing. <html> carries `data-ramme-print`
|
|
52
|
+
* meanwhile, which index.css answers with the light palette; anything that
|
|
53
|
+
* reads tokens in JavaScript (useChartTheme) re-reads on this.
|
|
54
|
+
*/
|
|
55
|
+
isPrinting: boolean;
|
|
50
56
|
}
|
|
51
57
|
export interface ThemeProviderProps {
|
|
52
58
|
children: React.ReactNode;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
|
|
1
|
+
import { jsx as Z } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useEffect as $, useCallback as S, useMemo as ee, createContext as oe, useContext as re } from "react";
|
|
3
|
+
import { flushSync as te } from "react-dom";
|
|
4
|
+
import { DERIVED_THEME_VARS as ae } from "../lib/theme/themeUtils.js";
|
|
5
|
+
const M = [
|
|
4
6
|
"light",
|
|
5
7
|
"dark",
|
|
6
8
|
"system",
|
|
@@ -8,7 +10,7 @@ const E = [
|
|
|
8
10
|
"midnight",
|
|
9
11
|
"blueprint",
|
|
10
12
|
"markets"
|
|
11
|
-
], p = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
|
|
13
|
+
], p = 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace', q = {
|
|
12
14
|
light: {
|
|
13
15
|
sans: '"Inter", system-ui, sans-serif',
|
|
14
16
|
serif: "Georgia, serif",
|
|
@@ -46,7 +48,7 @@ const E = [
|
|
|
46
48
|
serif: "Georgia, serif",
|
|
47
49
|
mono: `"Menlo", ${p}`
|
|
48
50
|
}
|
|
49
|
-
},
|
|
51
|
+
}, se = 550, ne = 100, J = {
|
|
50
52
|
name: "TAY Dreamboat",
|
|
51
53
|
borderRadius: "0.5rem",
|
|
52
54
|
fonts: {
|
|
@@ -102,37 +104,37 @@ const E = [
|
|
|
102
104
|
danger: "239 68 68",
|
|
103
105
|
dangerForeground: "255 255 255"
|
|
104
106
|
}
|
|
105
|
-
},
|
|
106
|
-
[
|
|
107
|
-
},
|
|
108
|
-
children:
|
|
107
|
+
}, j = oe(void 0), U = {
|
|
108
|
+
[J.name]: J
|
|
109
|
+
}, pe = ({
|
|
110
|
+
children: w,
|
|
109
111
|
defaultTheme: l,
|
|
110
|
-
defaultCustomTheme:
|
|
112
|
+
defaultCustomTheme: d,
|
|
111
113
|
appId: L,
|
|
112
114
|
instanceConfig: c
|
|
113
115
|
}) => {
|
|
114
|
-
var
|
|
115
|
-
const
|
|
116
|
+
var G, H, V;
|
|
117
|
+
const E = (G = c == null ? void 0 : c.fonts) == null ? void 0 : G.sans, F = (H = c == null ? void 0 : c.fonts) == null ? void 0 : H.serif, R = (V = c == null ? void 0 : c.fonts) == null ? void 0 : V.mono, t = L ? `ramme:theme:${L}` : "ramme:theme:global", [b, v] = f(() => {
|
|
116
118
|
if (typeof window < "u") {
|
|
117
119
|
const o = localStorage.getItem(`${t}:mode`);
|
|
118
|
-
return
|
|
120
|
+
return d && !o ? l || "system" : o && M.includes(o) ? o : l || "system";
|
|
119
121
|
}
|
|
120
122
|
return l || "system";
|
|
121
|
-
}), [x, _] =
|
|
123
|
+
}), [x, _] = f("light"), [u, I] = f("0.5rem"), [T, k] = f("1rem"), [a, y] = f(() => {
|
|
122
124
|
if (typeof window < "u") {
|
|
123
125
|
const o = localStorage.getItem(`${t}:custom`);
|
|
124
126
|
if (o)
|
|
125
127
|
try {
|
|
126
128
|
const e = JSON.parse(o);
|
|
127
|
-
return e != null && e.name &&
|
|
129
|
+
return e != null && e.name && U[e.name] ? U[e.name] : e;
|
|
128
130
|
} catch {
|
|
129
131
|
}
|
|
130
|
-
if (
|
|
131
|
-
return
|
|
132
|
+
if (d && !o)
|
|
133
|
+
return d;
|
|
132
134
|
}
|
|
133
|
-
return
|
|
135
|
+
return d || null;
|
|
134
136
|
});
|
|
135
|
-
|
|
137
|
+
$(() => {
|
|
136
138
|
if (typeof window < "u") {
|
|
137
139
|
const o = window.matchMedia("(prefers-color-scheme: dark)");
|
|
138
140
|
_(o.matches ? "dark" : "light");
|
|
@@ -140,34 +142,34 @@ const E = [
|
|
|
140
142
|
_(g.matches ? "dark" : "light");
|
|
141
143
|
};
|
|
142
144
|
o.addEventListener("change", e);
|
|
143
|
-
const
|
|
144
|
-
return
|
|
145
|
+
const i = localStorage.getItem(`${t}:borderRadius`), A = localStorage.getItem(`${t}:fontSize`);
|
|
146
|
+
return i && I(i), A && k(A), () => o.removeEventListener("change", e);
|
|
145
147
|
}
|
|
146
|
-
}, [
|
|
147
|
-
const
|
|
148
|
-
localStorage.removeItem(`${t}:mode`), localStorage.removeItem(`${t}:custom`), localStorage.removeItem(`${t}:borderRadius`), localStorage.removeItem(`${t}:fontSize`),
|
|
149
|
-
}, [l,
|
|
150
|
-
|
|
148
|
+
}, [d, t]);
|
|
149
|
+
const D = S(() => {
|
|
150
|
+
localStorage.removeItem(`${t}:mode`), localStorage.removeItem(`${t}:custom`), localStorage.removeItem(`${t}:borderRadius`), localStorage.removeItem(`${t}:fontSize`), I("0.5rem"), k("1rem"), d ? (v("system"), y(d)) : l ? (v(l), y(null)) : (v("system"), y(null));
|
|
151
|
+
}, [l, d, t]), P = S((o) => {
|
|
152
|
+
v(o), localStorage.setItem(`${t}:mode`, o), ["light", "dark", "system"].includes(o) || (y(null), localStorage.removeItem(`${t}:custom`));
|
|
153
|
+
}, [t]), B = S((o) => {
|
|
154
|
+
y(o), o ? localStorage.setItem(`${t}:custom`, JSON.stringify(o)) : localStorage.removeItem(`${t}:custom`);
|
|
155
|
+
}, [t]), N = S((o) => {
|
|
156
|
+
I(o), localStorage.setItem(`${t}:borderRadius`, o);
|
|
151
157
|
}, [t]), Y = S((o) => {
|
|
152
|
-
|
|
153
|
-
}, [t]), D = S((o) => {
|
|
154
|
-
k(o), localStorage.setItem(`${t}:borderRadius`, o);
|
|
155
|
-
}, [t]), P = S((o) => {
|
|
156
|
-
I(o), localStorage.setItem(`${t}:fontSize`, o);
|
|
158
|
+
k(o), localStorage.setItem(`${t}:fontSize`, o);
|
|
157
159
|
}, [t]);
|
|
158
|
-
|
|
160
|
+
$(() => {
|
|
159
161
|
const o = document.documentElement;
|
|
160
162
|
let e;
|
|
161
|
-
const
|
|
162
|
-
e = window.setTimeout(() => o.setAttribute("data-theme-ready", ""),
|
|
163
|
+
const i = requestAnimationFrame(() => {
|
|
164
|
+
e = window.setTimeout(() => o.setAttribute("data-theme-ready", ""), ne);
|
|
163
165
|
});
|
|
164
166
|
return () => {
|
|
165
|
-
cancelAnimationFrame(
|
|
167
|
+
cancelAnimationFrame(i), e !== void 0 && window.clearTimeout(e), o.removeAttribute("data-theme-ready");
|
|
166
168
|
};
|
|
167
|
-
}, []),
|
|
169
|
+
}, []), $(() => {
|
|
168
170
|
const o = document.documentElement;
|
|
169
|
-
|
|
170
|
-
const e = (s, n) => o.style.setProperty(s, n),
|
|
171
|
+
M.forEach((s) => o.classList.remove(s)), o.classList.remove("custom-theme");
|
|
172
|
+
const e = (s, n) => o.style.setProperty(s, n), i = (s) => o.style.removeProperty(s), A = [
|
|
171
173
|
"system-ui",
|
|
172
174
|
"Inter",
|
|
173
175
|
"Georgia",
|
|
@@ -191,12 +193,12 @@ const E = [
|
|
|
191
193
|
if (Array.from(
|
|
192
194
|
document.querySelectorAll('link[rel="stylesheet"]')
|
|
193
195
|
).some((m) => new RegExp(`family=${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?=[:&]|$)`).test(m.href.toLowerCase()))) return;
|
|
194
|
-
const
|
|
195
|
-
if (!document.getElementById(
|
|
196
|
+
const K = `google-font-${n.replace(/\s+/g, "-")}`;
|
|
197
|
+
if (!document.getElementById(K)) {
|
|
196
198
|
const m = document.createElement("link");
|
|
197
|
-
m.id =
|
|
199
|
+
m.id = K, m.rel = "stylesheet", m.href = `https://fonts.googleapis.com/css2?family=${n.replace(/\s+/g, "+")}:wght@400;500;600;700&display=swap`, document.head.appendChild(m);
|
|
198
200
|
}
|
|
199
|
-
},
|
|
201
|
+
}, W = [
|
|
200
202
|
"--app-primary-color",
|
|
201
203
|
"--app-primary-foreground-color",
|
|
202
204
|
"--app-secondary-color",
|
|
@@ -226,56 +228,71 @@ const E = [
|
|
|
226
228
|
"--app-font-size-base",
|
|
227
229
|
"--app-border-radius-sm",
|
|
228
230
|
"--app-border-radius-md",
|
|
229
|
-
"--app-border-radius-lg"
|
|
230
|
-
|
|
231
|
+
"--app-border-radius-lg",
|
|
232
|
+
// ThemeLab paints through applyThemeToDom, which also writes these.
|
|
233
|
+
"--app-surface-hover",
|
|
234
|
+
...ae
|
|
235
|
+
], h = b === "system" ? x : b;
|
|
231
236
|
if (a) {
|
|
232
237
|
o.classList.add("custom-theme");
|
|
233
|
-
const s =
|
|
238
|
+
const s = h === "dark" || h === "midnight" || h === "markets";
|
|
234
239
|
s && o.classList.add("dark");
|
|
235
240
|
const n = a.colors, r = s ? a.darkColors || n : a.lightColors || n;
|
|
236
241
|
if (!r) {
|
|
237
242
|
console.error("ThemeEngine: Invalid customTheme payload", a);
|
|
238
243
|
return;
|
|
239
244
|
}
|
|
240
|
-
e("--app-primary-color", r.primary), e("--app-primary-foreground-color", r.primaryForeground), e("--app-secondary-color", r.secondary), e("--app-secondary-foreground-color", r.secondaryForeground), e("--app-accent-color", r.accent), e("--app-accent-foreground-color", r.accentForeground), e("--app-danger-color", r.danger), e("--app-danger-foreground-color", r.dangerForeground), r.success ? e("--app-success-color", r.success) :
|
|
245
|
+
e("--app-primary-color", r.primary), e("--app-primary-foreground-color", r.primaryForeground), e("--app-secondary-color", r.secondary), e("--app-secondary-foreground-color", r.secondaryForeground), e("--app-accent-color", r.accent), e("--app-accent-foreground-color", r.accentForeground), e("--app-danger-color", r.danger), e("--app-danger-foreground-color", r.dangerForeground), r.success ? e("--app-success-color", r.success) : i("--app-success-color"), r.warning ? e("--app-warning-color", r.warning) : i("--app-warning-color"), e("--app-bg-color", r.background), e("--app-card-bg-color", r.card), e("--app-text-color", r.text), e("--app-border-color", r.border), e("--app-muted-bg", r.muted), e("--app-muted-text", r.mutedForeground), e("--app-input-bg-color", r.input), e("--app-input-border-color", r.inputBorder), e("--app-input-focus-ring-color", r.ring), e("--app-table-header-bg", r.muted), e("--app-table-header-text", r.text), e("--app-table-row-hover-bg", r.muted), e("--app-table-grid-line-color", r.border), a.fonts && (g(a.fonts.sans), a.fonts.serif && g(a.fonts.serif), e("--app-font-serif", a.fonts.serif), e("--app-font-sans", a.fonts.sans), e("--app-font-mono", a.fonts.mono)), document.body.style.backgroundColor = `rgb(${r.background})`, document.body.style.color = `rgb(${r.text})`, e("--app-border-radius-md", a.borderRadius), e("--app-border-radius-sm", `calc(${a.borderRadius} - 0.25rem)`), e("--app-border-radius-lg", `calc(${a.borderRadius} + 0.25rem)`);
|
|
241
246
|
} else {
|
|
242
|
-
o.classList.add(
|
|
243
|
-
const s =
|
|
244
|
-
|
|
247
|
+
o.classList.add(h), W.forEach(i);
|
|
248
|
+
const s = q[h] || q.light, n = E || s.sans, r = F || s.serif, C = R || s.mono;
|
|
249
|
+
E || g(n), F || g(r), e("--app-font-sans", n), e("--app-font-serif", r), e("--app-font-mono", C), document.body.style.backgroundColor = "", document.body.style.color = "", e("--app-border-radius-md", u), e("--app-border-radius-sm", `calc(${u} - 0.25rem)`), e("--app-border-radius-lg", `calc(${u} + 0.25rem)`);
|
|
245
250
|
}
|
|
246
|
-
if (e("--app-font-size-base",
|
|
251
|
+
if (e("--app-font-size-base", T), !o.hasAttribute("data-theme-ready")) return;
|
|
247
252
|
o.setAttribute("data-theme-morphing", "");
|
|
248
|
-
const
|
|
253
|
+
const X = window.setTimeout(
|
|
249
254
|
() => o.removeAttribute("data-theme-morphing"),
|
|
250
|
-
|
|
255
|
+
se
|
|
251
256
|
);
|
|
252
|
-
return () => window.clearTimeout(
|
|
253
|
-
}, [
|
|
254
|
-
const
|
|
257
|
+
return () => window.clearTimeout(X);
|
|
258
|
+
}, [b, x, a, u, T, E, F, R]);
|
|
259
|
+
const [O, z] = f(!1);
|
|
260
|
+
$(() => {
|
|
261
|
+
const o = document.documentElement, e = () => {
|
|
262
|
+
o.setAttribute("data-ramme-print", ""), te(() => z(!0));
|
|
263
|
+
}, i = () => {
|
|
264
|
+
o.removeAttribute("data-ramme-print"), z(!1);
|
|
265
|
+
};
|
|
266
|
+
return window.addEventListener("beforeprint", e), window.addEventListener("afterprint", i), () => {
|
|
267
|
+
window.removeEventListener("beforeprint", e), window.removeEventListener("afterprint", i), o.removeAttribute("data-ramme-print");
|
|
268
|
+
};
|
|
269
|
+
}, []);
|
|
270
|
+
const Q = ee(
|
|
255
271
|
() => ({
|
|
256
|
-
theme:
|
|
257
|
-
availableThemes:
|
|
258
|
-
setTheme:
|
|
259
|
-
resetTheme:
|
|
272
|
+
theme: b,
|
|
273
|
+
availableThemes: M,
|
|
274
|
+
setTheme: P,
|
|
275
|
+
resetTheme: D,
|
|
260
276
|
borderRadius: u,
|
|
261
|
-
setBorderRadius:
|
|
262
|
-
fontSize:
|
|
263
|
-
setFontSize:
|
|
277
|
+
setBorderRadius: N,
|
|
278
|
+
fontSize: T,
|
|
279
|
+
setFontSize: Y,
|
|
264
280
|
customTheme: a,
|
|
265
|
-
setCustomTheme:
|
|
281
|
+
setCustomTheme: B,
|
|
282
|
+
isPrinting: O
|
|
266
283
|
}),
|
|
267
|
-
[
|
|
284
|
+
[b, P, D, u, N, T, Y, a, B, O]
|
|
268
285
|
);
|
|
269
|
-
return /* @__PURE__ */
|
|
270
|
-
},
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
286
|
+
return /* @__PURE__ */ Z(j.Provider, { value: Q, children: w });
|
|
287
|
+
}, le = () => {
|
|
288
|
+
const w = re(j);
|
|
289
|
+
if (w === void 0)
|
|
273
290
|
throw new Error("useTheme must be used within a ThemeProvider");
|
|
274
|
-
return
|
|
291
|
+
return w;
|
|
275
292
|
};
|
|
276
293
|
export {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
294
|
+
J as TAY_DREAMBOAT_THEME,
|
|
295
|
+
pe as ThemeProvider,
|
|
296
|
+
M as availableThemes,
|
|
297
|
+
le as useTheme
|
|
281
298
|
};
|