@monkey-mini-app/panel 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.
@@ -0,0 +1,528 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // src/themes.ts
6
+ var PALETTES = [
7
+ { id: "default", label: "\u9ED8\u8BA4", swatch: "#2563eb" },
8
+ { id: "tokyo", label: "\u4E1C\u4EAC\u591C", swatch: "#7aa2f7" },
9
+ { id: "forest", label: "\u82D4\u539F", swatch: "#a7c080" },
10
+ { id: "matcha", label: "\u8349\u8393\u62B9\u8336", swatch: "#ee9aa6" },
11
+ { id: "yellow", label: "\u836F\u4E38\u9EC4", swatch: "#facc15" },
12
+ { id: "zoro", label: "\u4E09\u5200\u6D41", swatch: "#4ade80" },
13
+ { id: "hokage", label: "\u706B\u5F71\u9ECE\u660E", swatch: "#f59e0b" },
14
+ { id: "slate", label: "\u77F3\u58A8", swatch: "#3f3f46" }
15
+ ];
16
+ var TOKENS = {
17
+ default: {
18
+ light: {
19
+ bg: "#f7f7f8",
20
+ fg: "#111111",
21
+ surface: "#ffffff",
22
+ surfaceFg: "#111111",
23
+ border: "#e5e7eb",
24
+ muted: "#f3f4f6",
25
+ mutedFg: "#6b7280",
26
+ primary: "#2563eb",
27
+ primaryFg: "#ffffff",
28
+ secondary: "#f3f4f6",
29
+ secondaryFg: "#111111",
30
+ accent: "#eff6ff",
31
+ accentFg: "#1e3a8a",
32
+ destructive: "#dc2626",
33
+ destructiveFg: "#ffffff",
34
+ ring: "#2563eb",
35
+ input: "#e5e7eb",
36
+ radius: "10px",
37
+ shadow: "rgba(15, 23, 42, 0.08)"
38
+ },
39
+ dark: {
40
+ bg: "#0b0b0c",
41
+ fg: "#f4f4f5",
42
+ surface: "#171717",
43
+ surfaceFg: "#f4f4f5",
44
+ border: "#2a2a2c",
45
+ muted: "#27272a",
46
+ mutedFg: "#a1a1aa",
47
+ primary: "#3b82f6",
48
+ primaryFg: "#ffffff",
49
+ secondary: "#27272a",
50
+ secondaryFg: "#f4f4f5",
51
+ accent: "#172554",
52
+ accentFg: "#bfdbfe",
53
+ destructive: "#ef4444",
54
+ destructiveFg: "#ffffff",
55
+ ring: "#3b82f6",
56
+ input: "#2a2a2c",
57
+ radius: "10px",
58
+ shadow: "rgba(0, 0, 0, 0.45)"
59
+ }
60
+ },
61
+ tokyo: {
62
+ light: {
63
+ bg: "#d5d6db",
64
+ fg: "#343b59",
65
+ surface: "#f2f3f8",
66
+ surfaceFg: "#343b59",
67
+ border: "#c9ccd9",
68
+ muted: "#e9eaf2",
69
+ mutedFg: "#7c82a4",
70
+ primary: "#2e7de9",
71
+ primaryFg: "#ffffff",
72
+ secondary: "#e3e5ef",
73
+ secondaryFg: "#343b59",
74
+ accent: "#dfe6f6",
75
+ accentFg: "#274a94",
76
+ destructive: "#db4b4b",
77
+ destructiveFg: "#ffffff",
78
+ ring: "#2e7de9",
79
+ input: "#e8eaf2",
80
+ radius: "10px",
81
+ shadow: "rgba(30, 40, 90, 0.12)"
82
+ },
83
+ dark: {
84
+ bg: "#1a1b26",
85
+ fg: "#a9b1d6",
86
+ surface: "#16161e",
87
+ surfaceFg: "#a9b1d6",
88
+ border: "#2b2e3d",
89
+ muted: "#1f2230",
90
+ mutedFg: "#787c99",
91
+ primary: "#7aa2f7",
92
+ primaryFg: "#1a1b26",
93
+ secondary: "#202330",
94
+ secondaryFg: "#a9b1d6",
95
+ accent: "#33467c",
96
+ accentFg: "#c0caf5",
97
+ destructive: "#f7768e",
98
+ destructiveFg: "#1a1b26",
99
+ ring: "#7aa2f7",
100
+ input: "#14141b",
101
+ radius: "10px",
102
+ shadow: "rgba(0, 0, 0, 0.5)"
103
+ }
104
+ },
105
+ forest: {
106
+ light: {
107
+ bg: "#fdf6e3",
108
+ fg: "#5c6a72",
109
+ surface: "#fefaf0",
110
+ surfaceFg: "#5c6a72",
111
+ border: "#e3ddc9",
112
+ muted: "#f2ecdb",
113
+ mutedFg: "#859289",
114
+ primary: "#93b259",
115
+ primaryFg: "#fdf6e3",
116
+ secondary: "#eae4d2",
117
+ secondaryFg: "#5c6a72",
118
+ accent: "#e0e6c8",
119
+ accentFg: "#4d6a3d",
120
+ destructive: "#e67e80",
121
+ destructiveFg: "#fdf6e3",
122
+ ring: "#93b259",
123
+ input: "#f7f1e0",
124
+ radius: "12px",
125
+ shadow: "rgba(70, 90, 60, 0.12)"
126
+ },
127
+ dark: {
128
+ bg: "#2d353b",
129
+ fg: "#d3c6aa",
130
+ surface: "#333c43",
131
+ surfaceFg: "#d3c6aa",
132
+ border: "#414c52",
133
+ muted: "#3d484d",
134
+ mutedFg: "#859289",
135
+ primary: "#a7c080",
136
+ primaryFg: "#2d353b",
137
+ secondary: "#3d484d",
138
+ secondaryFg: "#d3c6aa",
139
+ accent: "#475258",
140
+ accentFg: "#d3c6aa",
141
+ destructive: "#e67e80",
142
+ destructiveFg: "#2d353b",
143
+ ring: "#a7c080",
144
+ input: "#272e33",
145
+ radius: "12px",
146
+ shadow: "rgba(0, 0, 0, 0.4)"
147
+ }
148
+ },
149
+ matcha: {
150
+ light: {
151
+ bg: "#faf5f3",
152
+ fg: "#4c4147",
153
+ surface: "#ffffff",
154
+ surfaceFg: "#4c4147",
155
+ border: "#eadcd8",
156
+ muted: "#f3eae6",
157
+ mutedFg: "#98857f",
158
+ primary: "#e08a9c",
159
+ primaryFg: "#ffffff",
160
+ secondary: "#f0e4df",
161
+ secondaryFg: "#4c4147",
162
+ accent: "#e8f0da",
163
+ accentFg: "#5a7a3f",
164
+ destructive: "#d95f7f",
165
+ destructiveFg: "#ffffff",
166
+ ring: "#e08a9c",
167
+ input: "#f8f1ee",
168
+ radius: "14px",
169
+ shadow: "rgba(180, 90, 110, 0.12)"
170
+ },
171
+ dark: {
172
+ bg: "#28242b",
173
+ fg: "#e9d8d2",
174
+ surface: "#302b33",
175
+ surfaceFg: "#e9d8d2",
176
+ border: "#443a44",
177
+ muted: "#38313a",
178
+ mutedFg: "#b3a09f",
179
+ primary: "#ee9aa6",
180
+ primaryFg: "#28242b",
181
+ secondary: "#38313a",
182
+ secondaryFg: "#e9d8d2",
183
+ accent: "#3f4a38",
184
+ accentFg: "#c8e3b2",
185
+ destructive: "#e06c8a",
186
+ destructiveFg: "#28242b",
187
+ ring: "#ee9aa6",
188
+ input: "#231f26",
189
+ radius: "14px",
190
+ shadow: "rgba(0, 0, 0, 0.45)"
191
+ }
192
+ },
193
+ yellow: {
194
+ light: {
195
+ bg: "#faf6ef",
196
+ fg: "#3d3326",
197
+ surface: "#ffffff",
198
+ surfaceFg: "#3d3326",
199
+ border: "#e8dfcd",
200
+ muted: "#f2ecdf",
201
+ mutedFg: "#9a8a6f",
202
+ primary: "#a37b16",
203
+ primaryFg: "#ffffff",
204
+ secondary: "#ede5d3",
205
+ secondaryFg: "#3d3326",
206
+ accent: "#f7edcb",
207
+ accentFg: "#6b4e0a",
208
+ destructive: "#dc2626",
209
+ destructiveFg: "#ffffff",
210
+ ring: "#a37b16",
211
+ input: "#f7f1e4",
212
+ radius: "12px",
213
+ shadow: "rgba(140, 110, 40, 0.12)"
214
+ },
215
+ dark: {
216
+ bg: "#1c1917",
217
+ fg: "#f5f0e6",
218
+ surface: "#242019",
219
+ surfaceFg: "#f5f0e6",
220
+ border: "#3a332a",
221
+ muted: "#2a2520",
222
+ mutedFg: "#b3a68f",
223
+ primary: "#facc15",
224
+ primaryFg: "#1c1917",
225
+ secondary: "#2a2520",
226
+ secondaryFg: "#f5f0e6",
227
+ accent: "#3f3518",
228
+ accentFg: "#fde68a",
229
+ destructive: "#f87171",
230
+ destructiveFg: "#1c1917",
231
+ ring: "#facc15",
232
+ input: "#211d18",
233
+ radius: "12px",
234
+ shadow: "rgba(0, 0, 0, 0.5)"
235
+ }
236
+ },
237
+ zoro: {
238
+ light: {
239
+ bg: "#f2f6f0",
240
+ fg: "#24302a",
241
+ surface: "#ffffff",
242
+ surfaceFg: "#24302a",
243
+ border: "#d8e4d6",
244
+ muted: "#e9efe6",
245
+ mutedFg: "#7d907e",
246
+ primary: "#15803d",
247
+ primaryFg: "#ffffff",
248
+ secondary: "#e3ecdf",
249
+ secondaryFg: "#24302a",
250
+ accent: "#dcf2e2",
251
+ accentFg: "#166534",
252
+ destructive: "#dc2626",
253
+ destructiveFg: "#ffffff",
254
+ ring: "#15803d",
255
+ input: "#f4f8f2",
256
+ radius: "12px",
257
+ shadow: "rgba(30, 80, 50, 0.1)"
258
+ },
259
+ dark: {
260
+ bg: "#101512",
261
+ fg: "#d8e0d4",
262
+ surface: "#18211b",
263
+ surfaceFg: "#d8e0d4",
264
+ border: "#2c3a30",
265
+ muted: "#1d2720",
266
+ mutedFg: "#93a393",
267
+ primary: "#4ade80",
268
+ primaryFg: "#101512",
269
+ secondary: "#1d2720",
270
+ secondaryFg: "#d8e0d4",
271
+ accent: "#14532d",
272
+ accentFg: "#bbf7d0",
273
+ destructive: "#f87171",
274
+ destructiveFg: "#101512",
275
+ ring: "#4ade80",
276
+ input: "#141b16",
277
+ radius: "12px",
278
+ shadow: "rgba(0, 0, 0, 0.5)"
279
+ }
280
+ },
281
+ hokage: {
282
+ light: {
283
+ bg: "#faf3ea",
284
+ fg: "#4a3a2c",
285
+ surface: "#ffffff",
286
+ surfaceFg: "#4a3a2c",
287
+ border: "#eadcc8",
288
+ muted: "#f3e9db",
289
+ mutedFg: "#a0886a",
290
+ primary: "#c2660f",
291
+ primaryFg: "#ffffff",
292
+ secondary: "#efe2d0",
293
+ secondaryFg: "#4a3a2c",
294
+ accent: "#fbe6c8",
295
+ accentFg: "#7c4a10",
296
+ destructive: "#dc2626",
297
+ destructiveFg: "#ffffff",
298
+ ring: "#c2660f",
299
+ input: "#f8f0e4",
300
+ radius: "12px",
301
+ shadow: "rgba(150, 90, 30, 0.12)"
302
+ },
303
+ dark: {
304
+ bg: "#241a17",
305
+ fg: "#f0e3d8",
306
+ surface: "#2e211c",
307
+ surfaceFg: "#f0e3d8",
308
+ border: "#45372e",
309
+ muted: "#33251f",
310
+ mutedFg: "#b59f8c",
311
+ primary: "#f59e0b",
312
+ primaryFg: "#241a17",
313
+ secondary: "#33251f",
314
+ secondaryFg: "#f0e3d8",
315
+ accent: "#4a3024",
316
+ accentFg: "#fcd9b6",
317
+ destructive: "#ef4444",
318
+ destructiveFg: "#241a17",
319
+ ring: "#f59e0b",
320
+ input: "#201612",
321
+ radius: "12px",
322
+ shadow: "rgba(0, 0, 0, 0.5)"
323
+ }
324
+ },
325
+ slate: {
326
+ light: {
327
+ bg: "#ececee",
328
+ fg: "#09090b",
329
+ surface: "#ffffff",
330
+ surfaceFg: "#09090b",
331
+ border: "#c8c8ce",
332
+ muted: "#e0e0e5",
333
+ mutedFg: "#52525b",
334
+ primary: "#27272a",
335
+ primaryFg: "#fafafa",
336
+ secondary: "#e0e0e5",
337
+ secondaryFg: "#09090b",
338
+ accent: "#d4d4d8",
339
+ accentFg: "#18181b",
340
+ destructive: "#dc2626",
341
+ destructiveFg: "#ffffff",
342
+ ring: "#27272a",
343
+ input: "#c8c8ce",
344
+ radius: "8px",
345
+ shadow: "rgba(24, 24, 27, 0.12)"
346
+ },
347
+ dark: {
348
+ bg: "#050506",
349
+ fg: "#fafafa",
350
+ surface: "#141416",
351
+ surfaceFg: "#fafafa",
352
+ border: "#3f3f46",
353
+ muted: "#1f1f23",
354
+ mutedFg: "#a1a1aa",
355
+ primary: "#e4e4e7",
356
+ primaryFg: "#09090b",
357
+ secondary: "#1f1f23",
358
+ secondaryFg: "#fafafa",
359
+ accent: "#27272a",
360
+ accentFg: "#f4f4f5",
361
+ destructive: "#f87171",
362
+ destructiveFg: "#09090b",
363
+ ring: "#e4e4e7",
364
+ input: "#3f3f46",
365
+ radius: "8px",
366
+ shadow: "rgba(0, 0, 0, 0.6)"
367
+ }
368
+ }
369
+ };
370
+ var THEME_VAR_KEYS = [
371
+ "bg",
372
+ "fg",
373
+ "surface",
374
+ "surface-fg",
375
+ "border",
376
+ "muted",
377
+ "muted-fg",
378
+ "primary",
379
+ "primary-fg",
380
+ "secondary",
381
+ "secondary-fg",
382
+ "accent",
383
+ "accent-fg",
384
+ "destructive",
385
+ "destructive-fg",
386
+ "ring",
387
+ "input",
388
+ "radius",
389
+ "shadow"
390
+ ];
391
+ function kebabToCamel(k) {
392
+ return k.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
393
+ }
394
+ function parseThemeCss(css, _id) {
395
+ const out = {};
396
+ const blockRe = /:root\[data-mode="(light|dark)"\]\s*\{([^}]*)\}/g;
397
+ let m;
398
+ while (m = blockRe.exec(String(css || ""))) {
399
+ const mode = m[1];
400
+ const vars = {};
401
+ for (const key of THEME_VAR_KEYS) {
402
+ const vm = new RegExp(`--${key}\\s*:\\s*([^;\\n]+)`).exec(m[2]);
403
+ if (vm) vars[kebabToCamel(key)] = vm[1].trim();
404
+ }
405
+ if (vars.bg && vars.fg && vars.primary) out[mode] = vars;
406
+ }
407
+ if (!out.light || !out.dark) return null;
408
+ const base = {
409
+ surfaceFg: out.light.fg,
410
+ secondary: out.light.muted,
411
+ secondaryFg: out.light.fg,
412
+ destructiveFg: "#ffffff",
413
+ radius: "12px",
414
+ shadow: "rgba(15, 23, 42, 0.1)"
415
+ };
416
+ const fill = (v) => Object.assign({}, base, v);
417
+ return { light: fill(out.light), dark: fill(out.dark) };
418
+ }
419
+ function themeLabelFromCss(css, fallback) {
420
+ const m = /\/\*\s*name\s*:\s*([^*]+)\*\//.exec(String(css || ""));
421
+ return m && m[1].trim() || fallback;
422
+ }
423
+ function clampPalette(value) {
424
+ if (value === "tokyo" || value === "forest" || value === "matcha" || value === "yellow" || value === "zoro" || value === "hokage" || value === "slate" || value === "default") {
425
+ return value;
426
+ }
427
+ if (value === "ocean" || value === "mist") return "tokyo";
428
+ if (value === "violet" || value === "ink") return "matcha";
429
+ if (value === "paper" || value === "noir") return "slate";
430
+ return "default";
431
+ }
432
+ function clampMode(value) {
433
+ return value === "dark" ? "dark" : "light";
434
+ }
435
+ function tokensOf(palette, mode) {
436
+ return TOKENS[clampPalette(palette)][clampMode(mode)];
437
+ }
438
+ function cssVars(t) {
439
+ return [
440
+ `--background:${t.bg}`,
441
+ `--foreground:${t.fg}`,
442
+ `--card:${t.surface}`,
443
+ `--card-foreground:${t.surfaceFg}`,
444
+ `--primary:${t.primary}`,
445
+ `--primary-foreground:${t.primaryFg}`,
446
+ `--secondary:${t.secondary}`,
447
+ `--secondary-foreground:${t.secondaryFg}`,
448
+ `--muted:${t.muted}`,
449
+ `--muted-foreground:${t.mutedFg}`,
450
+ `--accent:${t.accent}`,
451
+ `--accent-foreground:${t.accentFg}`,
452
+ `--destructive:${t.destructive}`,
453
+ `--destructive-foreground:${t.destructiveFg}`,
454
+ `--border:${t.border}`,
455
+ `--input:${t.input}`,
456
+ `--ring:${t.ring}`,
457
+ `--radius:${t.radius}`,
458
+ `--shadow:${t.shadow}`,
459
+ `--color-background:var(--background)`,
460
+ `--color-surface:var(--card)`,
461
+ `--color-foreground:var(--foreground)`,
462
+ `--color-primary:var(--primary)`,
463
+ `--color-primary-foreground:var(--primary-foreground)`,
464
+ `--color-muted:var(--muted)`,
465
+ `--color-muted-foreground:var(--muted-foreground)`,
466
+ `--color-border:var(--border)`,
467
+ `--radius-md:var(--radius)`,
468
+ `--space-4:16px`,
469
+ `--font-sans:ui-sans-serif,system-ui,-apple-system,sans-serif`
470
+ ].join(";");
471
+ }
472
+ function runnerThemeCss() {
473
+ const blocks = [
474
+ `:root,html[data-theme="light"]:not([data-palette]),html[data-theme="light"][data-palette="default"]{${cssVars(TOKENS.default.light)}}`,
475
+ `html[data-theme="dark"]:not([data-palette]),html[data-theme="dark"][data-palette="default"]{${cssVars(TOKENS.default.dark)}}`
476
+ ];
477
+ ["tokyo", "forest", "matcha", "yellow", "zoro", "hokage", "slate"].forEach((id) => {
478
+ blocks.push(`html[data-theme="light"][data-palette="${id}"]{${cssVars(TOKENS[id].light)}}`);
479
+ blocks.push(`html[data-theme="dark"][data-palette="${id}"]{${cssVars(TOKENS[id].dark)}}`);
480
+ });
481
+ blocks.push(`html[data-theme="dark"] input[type="date"],html[data-theme="dark"] input[type="time"],html[data-theme="dark"] input[type="datetime-local"],html[data-theme="dark"] input[type="month"],html[data-theme="dark"] input[type="week"]{color-scheme:dark}`);
482
+ blocks.push(`html[data-theme="light"] input[type="date"],html[data-theme="light"] input[type="time"],html[data-theme="light"] input[type="datetime-local"],html[data-theme="light"] input[type="month"],html[data-theme="light"] input[type="week"]{color-scheme:light}`);
483
+ return blocks.join("\n ");
484
+ }
485
+ function applyThemeTo(el, theme, palette, custom) {
486
+ const mode = clampMode(theme);
487
+ const c = custom && palette ? custom[String(palette)] : void 0;
488
+ const pal = c ? String(palette) : clampPalette(palette);
489
+ const t = c && c.tokens && c.tokens[mode] || tokensOf(pal, mode);
490
+ el.setAttribute("data-theme", mode);
491
+ el.setAttribute("data-palette", pal);
492
+ const map = {
493
+ "--dsw-alias-bg": t.bg,
494
+ "--dsw-alias-fg": t.fg,
495
+ "--dsw-alias-surface": t.surface,
496
+ "--dsw-alias-border": t.border,
497
+ "--dsw-alias-muted": t.muted,
498
+ "--dsw-alias-primary": t.primary,
499
+ "--dsw-alias-primary-fg": t.primaryFg,
500
+ "--dsw-alias-accent": t.accent,
501
+ "--dsw-alias-shadow": t.shadow,
502
+ "--background": t.bg,
503
+ "--foreground": t.fg,
504
+ "--card": t.surface,
505
+ "--card-foreground": t.surfaceFg,
506
+ "--primary": t.primary,
507
+ "--primary-foreground": t.primaryFg,
508
+ "--secondary": t.secondary,
509
+ "--secondary-foreground": t.secondaryFg,
510
+ "--muted": t.muted,
511
+ "--muted-foreground": t.mutedFg,
512
+ "--accent": t.accent,
513
+ "--accent-foreground": t.accentFg,
514
+ "--border": t.border,
515
+ "--input": t.input,
516
+ "--ring": t.ring,
517
+ "--destructive": t.destructive,
518
+ "--destructive-foreground": t.destructiveFg,
519
+ "--radius": t.radius,
520
+ "--shadow": t.shadow
521
+ };
522
+ for (const k of Object.keys(map)) el.style.setProperty(k, map[k]);
523
+ el.style.background = t.bg;
524
+ el.style.color = t.fg;
525
+ return { theme: mode, palette: pal };
526
+ }
527
+
528
+ export { PALETTES, __publicField, applyThemeTo, clampMode, clampPalette, cssVars, parseThemeCss, runnerThemeCss, themeLabelFromCss, tokensOf };