nish-ui 2.2.0 → 3.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.
Files changed (99) hide show
  1. package/README.md +10 -6
  2. package/dist/chart.d.ts +8 -3
  3. package/dist/chart.js +2 -417
  4. package/dist/elements-all.js +81 -80
  5. package/dist/elements-charts.d.ts +7 -1
  6. package/dist/elements-charts.js +16 -16
  7. package/dist/elements-data.d.ts +7 -1
  8. package/dist/elements-data.js +5 -5
  9. package/dist/elements-forms.d.ts +7 -1
  10. package/dist/elements-forms.js +18 -17
  11. package/dist/elements.d.ts +7 -1
  12. package/dist/elements.js +4 -4
  13. package/dist/esm/components/accordion.js +3 -2
  14. package/dist/esm/components/app-shell.js +3 -2
  15. package/dist/esm/components/avatar.js +6 -5
  16. package/dist/esm/components/breadcrumbs.js +3 -2
  17. package/dist/esm/components/calendar-base.js +4 -3
  18. package/dist/esm/components/canvas/legend.js +7 -6
  19. package/dist/esm/components/canvas/node.js +3 -2
  20. package/dist/esm/components/canvas/system-canvas.js +27 -3
  21. package/dist/esm/components/carousel.js +24 -5
  22. package/dist/esm/components/charts.js +29 -20
  23. package/dist/esm/components/combobox.js +4 -3
  24. package/dist/esm/components/command.js +4 -3
  25. package/dist/esm/components/context-menu.js +3 -2
  26. package/dist/esm/components/data-classes.js +5 -4
  27. package/dist/esm/components/data.js +5 -8
  28. package/dist/esm/components/date-picker.js +5 -3
  29. package/dist/esm/components/date-range-picker.js +5 -3
  30. package/dist/esm/components/display.js +10 -9
  31. package/dist/esm/components/drawer.js +3 -2
  32. package/dist/esm/components/error-boundary.js +4 -2
  33. package/dist/esm/components/feedback.js +7 -6
  34. package/dist/esm/components/file-dropzone.js +24 -3
  35. package/dist/esm/components/filters.js +7 -4
  36. package/dist/esm/components/flow.js +17 -15
  37. package/dist/esm/components/forms.js +37 -10
  38. package/dist/esm/components/hooks.js +22 -19
  39. package/dist/esm/components/hover-card.js +2 -2
  40. package/dist/esm/components/inbox.js +12 -8
  41. package/dist/esm/components/layout-vars.js +10 -7
  42. package/dist/esm/components/layout.js +5 -4
  43. package/dist/esm/components/media.js +3 -2
  44. package/dist/esm/components/menu.js +12 -8
  45. package/dist/esm/components/modal.js +4 -3
  46. package/dist/esm/components/more-sheet.js +3 -2
  47. package/dist/esm/components/multi-select.js +10 -6
  48. package/dist/esm/components/nav-items.js +4 -3
  49. package/dist/esm/components/nav.js +5 -4
  50. package/dist/esm/components/overlay-core.js +31 -10
  51. package/dist/esm/components/overlay-dialog.js +20 -4
  52. package/dist/esm/components/pagination.js +7 -3
  53. package/dist/esm/components/popover.js +17 -11
  54. package/dist/esm/components/portal.js +2 -2
  55. package/dist/esm/components/primitives.js +1 -1
  56. package/dist/esm/components/progress.js +5 -2
  57. package/dist/esm/components/provider.js +34 -5
  58. package/dist/esm/components/range-calendar.js +4 -3
  59. package/dist/esm/components/resource-classes.js +34 -16
  60. package/dist/esm/components/resource.js +5 -4
  61. package/dist/esm/components/service-tokens.js +4 -3
  62. package/dist/esm/components/settings.js +8 -5
  63. package/dist/esm/components/slider.js +4 -2
  64. package/dist/esm/components/split.js +4 -3
  65. package/dist/esm/components/strings.js +182 -65
  66. package/dist/esm/components/tag-input.js +18 -9
  67. package/dist/esm/components/theme-toggle.js +3 -2
  68. package/dist/esm/components/time-field-classes.js +5 -2
  69. package/dist/esm/components/time-field.js +19 -10
  70. package/dist/esm/components/toast-card.js +155 -0
  71. package/dist/esm/components/toast-store.js +136 -0
  72. package/dist/esm/components/toast.js +38 -241
  73. package/dist/esm/components/tooltip.js +3 -3
  74. package/dist/esm/components/url-state.js +1 -0
  75. package/dist/esm/components/virtual-table.js +11 -4
  76. package/dist/esm/components/virtual.js +16 -2
  77. package/dist/esm/format.js +17 -14
  78. package/dist/esm/index.js +0 -20
  79. package/dist/esm/runtime.js +1 -1
  80. package/dist/esm/server/inbox/client.js +1 -1
  81. package/dist/esm/system-canvas.js +4 -0
  82. package/dist/esm/theme.js +73 -13
  83. package/dist/format.js +18 -15
  84. package/dist/inbox-client.js +1 -1
  85. package/dist/index.d.ts +43 -21
  86. package/dist/nish-components.css +41 -1
  87. package/dist/nish-components.min.css +1 -1
  88. package/dist/node/th-check.js +12 -3
  89. package/dist/server/hono.d.ts +1 -1
  90. package/dist/server/hono.js +20 -1
  91. package/dist/server/index.d.ts +2 -2
  92. package/dist/server/index.js +19 -5
  93. package/dist/{spa-BLlMc0eI.d.ts → spa-7myD4xvA.d.ts} +3 -2
  94. package/dist/system-canvas.d.ts +179 -2
  95. package/dist/theme.d.ts +23 -5
  96. package/dist/theme.global.js +87 -151
  97. package/dist/theme.js +87 -151
  98. package/package.json +1 -1
  99. package/dist/system-canvas-BLuWd69H.d.ts +0 -183
package/README.md CHANGED
@@ -156,16 +156,16 @@ elements for pages that have no React: `<nish-theme-toggle>`, `<nish-sheet>`,
156
156
  and Claude artifacts. They use the same `nish-*` classes as above, so link the stylesheets too.
157
157
 
158
158
  ```html
159
- <script src="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/theme-init.js"></script>
160
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/nish.css">
161
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/nish-components.css">
162
- <script type="module" src="https://cdn.jsdelivr.net/npm/nish-ui@2/dist/elements.js"></script>
159
+ <script src="https://cdn.jsdelivr.net/npm/nish-ui@3/dist/theme-init.js"></script>
160
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@3/dist/nish.css">
161
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/nish-ui@3/dist/nish-components.css">
162
+ <script type="module" src="https://cdn.jsdelivr.net/npm/nish-ui@3/dist/elements.js"></script>
163
163
 
164
164
  <nish-theme-toggle pill></nish-theme-toggle>
165
165
  ```
166
166
 
167
167
  With a bundler: `import 'nish-ui/elements';` and `import { toast } from 'nish-ui/elements';`.
168
- Pin an exact version (`nish-ui@2.0.0`) in production.
168
+ Pin an exact version (`nish-ui@3.0.0`) in production.
169
169
 
170
170
  Each entry file is self-contained, so load only the ones whose tags the page uses:
171
171
 
@@ -302,6 +302,8 @@ Entry points:
302
302
  | `nish-ui/vite` | The theme-init Vite plugin |
303
303
  | `nish-ui/eslint` | Lint rules for theme classes |
304
304
 
305
+ Moving from 2.x: [the 3.0 guide](https://design.nish.software/#/migrating).
306
+
305
307
  Also `nish-ui/theme-init.js` and `theme-init.sha256`, `nish-ui/theme.global.js`,
306
308
  `nish-ui/fonts/*`, `nish-ui/tsconfig/*` (strict presets), the `nish-th-check` CLI, and
307
309
  `nish-ui/server`, `nish-ui/server/hono` and `nish-ui/inbox-client` (a login, session and inbox
@@ -313,7 +315,8 @@ Details: [Vite plugin and lint](https://design.nish.software/#/components/vite-p
313
315
  `Inbox`, `ServiceTokensSection`, `useServiceTokens`, `SystemCanvas` and the server kit
314
316
  (`nish-ui/server`, `nish-ui/server/hono`, `nish-ui/inbox-client`) are built for the nish.software apps. They
315
317
  can change in a minor release; patches only fix. Import them from their own entry points
316
- (`nish-ui/inbox`, `nish-ui/service-tokens`, `nish-ui/system-canvas`); the root entry keeps them through 2.x.
318
+ (`nish-ui/inbox`, `nish-ui/service-tokens`, `nish-ui/system-canvas`). Since 3.0 the root entry
319
+ does not export them.
317
320
  Everything else follows semver.
318
321
 
319
322
  ## Bundle size
@@ -325,6 +328,7 @@ Measured with esbuild (minified, React external) from `dist/esm` on every pull r
325
328
  |---|---|
326
329
  | `cn` | under 10 KB |
327
330
  | `Button` | under 11 KB |
331
+ | `AppShell` | under 34 KB |
328
332
  | `useMediaQuery` | under 1.5 KB |
329
333
  | `nish-ui/theme` | under 12 KB |
330
334
  | `nish-ui/format` | under 4 KB |
package/dist/chart.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { CSSProperties } from 'react';
2
-
3
1
  /** The categorical series color for index i (0-based), cycling through chart-1…chart-8. */
4
2
  declare function seriesColor(i: number): string;
5
3
  /** Chart chrome as var() strings: gridlines, axis lines, the zero line and tick text. */
@@ -10,7 +8,14 @@ declare const CHART: {
10
8
  readonly text: "var(--nish-hi3)";
11
9
  };
12
10
  /** Inline style for a chart tooltip box (Recharts contentStyle and similar). */
13
- declare const tooltipStyle: CSSProperties;
11
+ declare const tooltipStyle: {
12
+ background: string;
13
+ border: string;
14
+ borderRadius: string;
15
+ boxShadow: string;
16
+ color: string;
17
+ fontSize: number;
18
+ };
14
19
  /** Resolved chart colors for canvas libraries, which cannot read var(). */
15
20
  interface ChartTheme {
16
21
  /** Gridlines. */
package/dist/chart.js CHANGED
@@ -1,405 +1,8 @@
1
- // src/tokens.mjs
2
- var HUE_ROLES = ["emerald", "indigo", "amber", "lime", "rose", "sky", "violet", "teal"];
3
- var SOFT_ROLES = ["accent", "ok", "loss", "warn", "info", ...HUE_ROLES];
4
- var DARK_HUES = {
5
- emerald: "#34d399",
6
- indigo: "#8b93ff",
7
- amber: "#fbbf24",
8
- lime: "#a3e635",
9
- rose: "#fb7185",
10
- sky: "#38bdf8",
11
- violet: "#c084fc",
12
- teal: "#2dd4bf"
13
- };
14
- var LIGHT_HUES = {
15
- emerald: "#046d4f",
16
- indigo: "#4e45e3",
17
- amber: "#9b4708",
18
- lime: "#41690d",
19
- rose: "#b8113a",
20
- sky: "#036499",
21
- violet: "#7e22ce",
22
- teal: "#0e6b64"
23
- };
24
- var DARK_CHART = ["#8b93ff", "#34d399", "#fbbf24", "#fb7185", "#38bdf8", "#c084fc", "#fb923c", "#a3e635"];
25
- var LIGHT_CHART = ["#6366f1", "#059669", "#c96d06", "#f43f5e", "#0284c7", "#a855f7", "#ea580c", "#5a910c"];
26
- var chart = (list) => Object.fromEntries(list.map((c, i) => [`chart-${i + 1}`, c]));
27
- var RAW_THEMES = {
28
- dark: {
29
- label: "Dark",
30
- scheme: "dark",
31
- colors: {
32
- bg: "#0a0b0f",
33
- surface: "#111218",
34
- elevated: "#191b23",
35
- overlay: "#22252f",
36
- line: "#262935",
37
- "line-strong": "#3a3e4d",
38
- "line-control": "#666975",
39
- hi: "#ececf1",
40
- hi2: "#a8aab7",
41
- hi3: "#8a8d9b",
42
- ghost: "#6b6e7c",
43
- accent: "#8b93ff",
44
- accent2: "#c084fc",
45
- "on-accent": "#0a0b0f",
46
- ok: "#34d399",
47
- loss: "#f87171",
48
- warn: "#fbbf24",
49
- info: "#38bdf8",
50
- scrim: "#000000",
51
- "invert-bg": "#ececf1",
52
- "invert-text": "#111218",
53
- ...chart(DARK_CHART),
54
- ...DARK_HUES
55
- }
56
- },
57
- light: {
58
- label: "Light",
59
- scheme: "light",
60
- colors: {
61
- bg: "#f7f6f3",
62
- surface: "#ffffff",
63
- elevated: "#f1f0ec",
64
- overlay: "#e6e4de",
65
- line: "#e2e0da",
66
- "line-strong": "#c9c6bd",
67
- "line-control": "#8a8881",
68
- hi: "#17171c",
69
- hi2: "#4f515c",
70
- hi3: "#626470",
71
- ghost: "#8a8c98",
72
- accent: "#4338ca",
73
- accent2: "#7e22ce",
74
- "on-accent": "#ffffff",
75
- // Light fills are mid-tones: white only clears 4.5:1 on loss and accent2.
76
- "on-accent2": "#ffffff",
77
- "on-ok": "#0a0a0c",
78
- "on-loss": "#ffffff",
79
- "on-warn": "#0a0a0c",
80
- "on-info": "#0a0a0c",
81
- ok: "#065f46",
82
- "ok-fill": "#059669",
83
- "loss-fill": "#dc2626",
84
- "warn-fill": "#c96d06",
85
- "info-fill": "#0284c7",
86
- loss: "#a91b1b",
87
- warn: "#92400e",
88
- info: "#075985",
89
- scrim: "#17171c",
90
- "invert-bg": "#17171c",
91
- "invert-text": "#f7f6f3",
92
- ...chart(LIGHT_CHART),
93
- ...LIGHT_HUES
94
- }
95
- },
96
- slate: {
97
- label: "Slate",
98
- scheme: "dark",
99
- colors: {
100
- bg: "#18181b",
101
- surface: "#202024",
102
- elevated: "#2c2c32",
103
- overlay: "#36363d",
104
- line: "#3a3a42",
105
- "line-strong": "#52525b",
106
- "line-control": "#77777e",
107
- hi: "#f4f4f5",
108
- hi2: "#b8b8c0",
109
- hi3: "#a0a0a8",
110
- ghost: "#71717a",
111
- accent: "#a5b4fc",
112
- accent2: "#c084fc",
113
- "on-accent": "#18181b",
114
- ok: "#4ade80",
115
- loss: "#fda4af",
116
- warn: "#facc15",
117
- info: "#38bdf8",
118
- scrim: "#000000",
119
- "invert-bg": "#f4f4f5",
120
- "invert-text": "#202024",
121
- ...chart(["#818cf8", "#4ade80", "#facc15", "#fb7185", "#38bdf8", "#c084fc", "#fb923c", "#a3e635"]),
122
- ...DARK_HUES,
123
- // Lifted so tinted chips stay readable on this theme's lighter cards.
124
- indigo: "#9aa1ff",
125
- rose: "#fc8395",
126
- violet: "#c792fc"
127
- }
128
- },
129
- terminal: {
130
- label: "Terminal",
131
- scheme: "dark",
132
- colors: {
133
- bg: "#050807",
134
- surface: "#0c110e",
135
- elevated: "#141c17",
136
- overlay: "#1c2820",
137
- line: "#233028",
138
- "line-strong": "#34483b",
139
- "line-control": "#5c6c61",
140
- hi: "#d1fae5",
141
- hi2: "#8fc4a8",
142
- hi3: "#74a68b",
143
- ghost: "#4f7a62",
144
- accent: "#34d399",
145
- accent2: "#2dd4bf",
146
- "on-accent": "#050807",
147
- ok: "#4ade80",
148
- loss: "#f87171",
149
- warn: "#fbbf24",
150
- info: "#67e8f9",
151
- scrim: "#000000",
152
- "invert-bg": "#d1fae5",
153
- "invert-text": "#0c110e",
154
- ...chart(["#34d399", "#67e8f9", "#fbbf24", "#f87171", "#a3e635", "#c084fc", "#fb923c", "#2dd4bf"]),
155
- ...DARK_HUES
156
- }
157
- },
158
- mocha: {
159
- label: "Mocha",
160
- scheme: "dark",
161
- colors: {
162
- bg: "#1c1917",
163
- surface: "#292524",
164
- elevated: "#393432",
165
- overlay: "#44403c",
166
- line: "#44403c",
167
- "line-strong": "#57534e",
168
- "line-control": "#83807c",
169
- hi: "#f5f0eb",
170
- hi2: "#c6c0bb",
171
- hi3: "#b2ada8",
172
- ghost: "#78716c",
173
- accent: "#fdba74",
174
- accent2: "#f472b6",
175
- "on-accent": "#1c1917",
176
- ok: "#4ade80",
177
- loss: "#fca5a5",
178
- warn: "#facc15",
179
- info: "#7dd3fc",
180
- scrim: "#000000",
181
- "invert-bg": "#f5f0eb",
182
- "invert-text": "#292524",
183
- ...chart(["#fb923c", "#4ade80", "#facc15", "#f472b6", "#7dd3fc", "#c4b5fd", "#f87171", "#bef264"]),
184
- ...DARK_HUES,
185
- // Lifted so tinted chips stay readable on this theme's lighter cards.
186
- indigo: "#a9afff",
187
- rose: "#fc99a7",
188
- sky: "#3ebff8",
189
- violet: "#cfa2fd"
190
- }
191
- },
192
- ocean: {
193
- label: "Ocean",
194
- scheme: "dark",
195
- colors: {
196
- bg: "#020c18",
197
- surface: "#061528",
198
- elevated: "#0a243e",
199
- overlay: "#103658",
200
- line: "#123050",
201
- "line-strong": "#1f4a72",
202
- "line-control": "#507291",
203
- hi: "#e0f2fe",
204
- hi2: "#9ccde6",
205
- hi3: "#6fa9c6",
206
- ghost: "#3f7392",
207
- accent: "#38bdf8",
208
- accent2: "#a78bfa",
209
- "on-accent": "#020c18",
210
- ok: "#34d399",
211
- loss: "#fb7185",
212
- warn: "#fbbf24",
213
- info: "#7dd3fc",
214
- scrim: "#000000",
215
- "invert-bg": "#38bdf8",
216
- "invert-text": "#020c18",
217
- ...chart(["#38bdf8", "#34d399", "#fbbf24", "#fb7185", "#a78bfa", "#2dd4bf", "#fb923c", "#a3e635"]),
218
- ...DARK_HUES
219
- }
220
- },
221
- contrast: {
222
- label: "High contrast",
223
- scheme: "dark",
224
- colors: {
225
- bg: "#000000",
226
- surface: "#080808",
227
- elevated: "#141414",
228
- overlay: "#222222",
229
- line: "#4a4a4a",
230
- "line-strong": "#8a8a8a",
231
- "line-control": "#8a8a8a",
232
- hi: "#ffffff",
233
- hi2: "#d4d4d4",
234
- hi3: "#bdbdbd",
235
- ghost: "#8f8f8f",
236
- accent: "#ffd60a",
237
- accent2: "#7dd3fc",
238
- "on-accent": "#000000",
239
- ok: "#4ade80",
240
- loss: "#ff6b6b",
241
- warn: "#ffd60a",
242
- info: "#7dd3fc",
243
- scrim: "#000000",
244
- "invert-bg": "#ffffff",
245
- "invert-text": "#000000",
246
- ...chart(["#ffd60a", "#4ade80", "#7dd3fc", "#ff6b6b", "#c4b5fd", "#fb923c", "#f9a8d4", "#bef264"]),
247
- ...DARK_HUES
248
- }
249
- }
250
- };
251
- var withFills = (t) => {
252
- const c = t.colors;
253
- const fills = Object.fromEntries(
254
- ["ok", "loss", "warn", "info"].flatMap((r) => [
255
- [`${r}-fill`, c[`${r}-fill`] ?? c[r]],
256
- [`on-${r}`, c[`on-${r}`] ?? c["on-accent"]]
257
- ])
258
- );
259
- return { ...t, colors: { ...c, ...fills, "on-accent2": c["on-accent2"] ?? c["on-accent"] } };
260
- };
261
- var THEMES = /* @__PURE__ */ Object.fromEntries(
262
- Object.entries(RAW_THEMES).map(([name, t]) => [name, withFills(t)])
263
- );
264
- var DEFAULT_THEME = "dark";
265
-
266
- // src/runtime.ts
267
- var version = true ? "2.2.0" : "dev";
268
- var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
269
- function runtime() {
270
- const g = globalThis;
271
- return g[KEY] ??= { versions: /* @__PURE__ */ new Set(), slots: {} };
272
- }
273
- function register(rt) {
274
- rt.versions.add(version);
275
- if (rt.versions.size > 1 && !rt.warned && globalThis.process?.env?.NODE_ENV !== "production") {
276
- rt.warned = true;
277
- console.warn(
278
- `nish-ui: two versions are loaded on this page (${[...rt.versions].join(", ")}). Overlays, toasts and theme state are shared, but mixing versions is unsupported.`
279
- );
280
- }
281
- }
282
- var registered = false;
283
- function shared(key, init) {
284
- const rt = runtime();
285
- if (!registered) {
286
- registered = true;
287
- register(rt);
288
- }
289
- if (!(key in rt.slots)) rt.slots[key] = init();
290
- return rt.slots[key];
291
- }
292
-
293
1
  // src/theme.ts
294
- var DEFAULT_KEY = "nish-theme";
295
2
  var ONE_YEAR = 60 * 60 * 24 * 365;
296
- var state = () => shared("theme", () => ({ extra: {}, listeners: /* @__PURE__ */ new Set(), watching: false, switchId: 0 }));
297
- function storageKey() {
298
- if (typeof document === "undefined") return DEFAULT_KEY;
299
- const k = document.documentElement.getAttribute("data-nish-storage-key");
300
- return k && /^[A-Za-z0-9_-]+$/.test(k) ? k : DEFAULT_KEY;
301
- }
302
- var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
303
- function isThemeName(v) {
304
- return typeof v === "string" && (has(THEMES, v) || has(state().extra, v));
305
- }
306
- function readCookie() {
307
- if (typeof document === "undefined") return null;
308
- try {
309
- const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)`));
310
- return m ? m[1] : null;
311
- } catch {
312
- return null;
313
- }
314
- }
315
- function getThemeChoice() {
316
- let v = null;
317
- try {
318
- v = readCookie() ?? localStorage.getItem(storageKey());
319
- } catch {
320
- }
321
- return v === "system" || isThemeName(v) ? v : "system";
322
- }
323
- function systemTheme() {
324
- const light = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: light)").matches;
325
- return light ? "light" : DEFAULT_THEME;
326
- }
327
- function allowedThemes() {
328
- const attr = document.documentElement.getAttribute("data-nish-themes");
329
- return attr ? attr.split(/\s+/).filter(isThemeName) : null;
330
- }
331
- function resolveTheme(choice = getThemeChoice()) {
332
- let theme = choice === "system" ? systemTheme() : choice;
333
- const allowed = typeof document === "undefined" ? null : allowedThemes();
334
- if (allowed && !allowed.includes(theme)) theme = schemeOf(theme);
335
- return theme;
336
- }
337
- function schemeOf(theme) {
338
- const { extra } = state();
339
- return has(THEMES, theme) ? THEMES[theme].scheme : has(extra, theme) ? extra[theme] : "dark";
340
- }
341
- function applyTheme(choice = getThemeChoice()) {
342
- const theme = resolveTheme(choice);
343
- const root = document.documentElement;
344
- const previous = root.getAttribute("data-theme");
345
- if (previous && previous !== theme) suspendTransitions(root);
346
- root.setAttribute("data-theme", theme);
347
- root.setAttribute("data-scheme", schemeOf(theme));
348
- root.setAttribute("data-theme-choice", choice);
349
- root.style.colorScheme = schemeOf(theme);
350
- syncChromeColor();
351
- state().listeners.forEach((fn) => fn(choice, theme));
352
- return theme;
353
- }
354
- function suspendTransitions(root) {
355
- const st = state();
356
- const id = ++st.switchId;
357
- root.setAttribute("data-nish-theme-switching", "");
358
- const done = () => {
359
- if (st.switchId === id) root.removeAttribute("data-nish-theme-switching");
360
- };
361
- if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => requestAnimationFrame(done));
362
- else setTimeout(done, 32);
363
- }
364
3
  function readToken(name) {
365
4
  return getComputedStyle(document.documentElement).getPropertyValue(`--nish-${name}`).trim();
366
5
  }
367
- function syncChromeColor() {
368
- const bg = readToken("bg");
369
- if (!bg) return;
370
- let meta = document.querySelector('meta[name="theme-color"][data-nish]') ?? document.querySelector('meta[name="theme-color"]:not([media]):not([data-nish-keep])');
371
- if (!meta) {
372
- meta = document.createElement("meta");
373
- meta.name = "theme-color";
374
- (document.head || document.documentElement).appendChild(meta);
375
- }
376
- meta.setAttribute("data-nish", "");
377
- meta.content = bg;
378
- }
379
- function watch() {
380
- const st = state();
381
- if (st.watching || typeof window === "undefined") return;
382
- st.watching = true;
383
- const reapply = () => {
384
- const choice = getThemeChoice();
385
- if (choice !== document.documentElement.getAttribute("data-theme-choice") || choice === "system") applyTheme(choice);
386
- };
387
- if (typeof matchMedia === "function") matchMedia("(prefers-color-scheme: light)").addEventListener("change", reapply);
388
- window.addEventListener("storage", (e) => {
389
- if (e.key === storageKey()) reapply();
390
- });
391
- document.addEventListener("visibilitychange", () => {
392
- if (document.visibilityState === "visible") reapply();
393
- });
394
- }
395
- function onThemeChange(fn) {
396
- watch();
397
- const { listeners } = state();
398
- listeners.add(fn);
399
- return () => {
400
- listeners.delete(fn);
401
- };
402
- }
403
6
 
404
7
  // src/chart-values.ts
405
8
  function seriesColor(i) {
@@ -451,29 +54,11 @@ var EMPTY_CHART_THEME = {
451
54
  info: "",
452
55
  accent: ""
453
56
  };
454
-
455
- // src/components/chart-hooks.ts
456
- import { useState } from "react";
457
-
458
- // src/components/client.ts
459
- import { useLayoutEffect, useEffect, useSyncExternalStore } from "react";
460
- var useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
461
-
462
- // src/components/chart-hooks.ts
463
- function useChartTheme() {
464
- const [theme, setTheme] = useState(EMPTY_CHART_THEME);
465
- useIsoLayoutEffect(() => {
466
- const update = () => setTheme(chartTheme());
467
- update();
468
- return onThemeChange(update);
469
- }, []);
470
- return theme;
471
- }
472
57
  export {
473
58
  CHART,
59
+ EMPTY_CHART_THEME,
474
60
  chartTheme,
475
61
  seriesColor,
476
- tooltipStyle,
477
- useChartTheme
62
+ tooltipStyle
478
63
  };
479
64
  //# sourceMappingURL=chart.js.map