@jogak/ui 0.1.0-alpha.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/dist/index.mjs ADDED
@@ -0,0 +1,1217 @@
1
+ import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
+ import { useState as x, useEffect as v, useRef as V, useMemo as w, useCallback as R } from "react";
3
+ import { defaultActionChannel as z, ComponentRegistry as U, defaultRegistry as F } from "@jogak/core";
4
+ import { useRegistryMeta as _, useEntry as G, reactAdapter as j, JogakProvider as T, useRegistry as q } from "@jogak/react";
5
+ import { themes as L, Highlight as Q } from "prism-react-renderer";
6
+ function Y({
7
+ selectedEntryId: e,
8
+ selectedJogakName: t,
9
+ onSelect: o
10
+ }) {
11
+ const [i, d] = x(""), { metaTree: r, searchMeta: s } = _(), l = i.trim().length > 0 ? s(i) : null;
12
+ return /* @__PURE__ */ c(
13
+ "aside",
14
+ {
15
+ "data-testid": "sidebar",
16
+ style: {
17
+ borderRight: "1px solid #e5e7eb",
18
+ height: "100%",
19
+ overflow: "auto",
20
+ display: "flex",
21
+ flexDirection: "column"
22
+ },
23
+ children: [
24
+ /* @__PURE__ */ n("div", { style: { padding: "12px", borderBottom: "1px solid #e5e7eb" }, children: /* @__PURE__ */ n(
25
+ "input",
26
+ {
27
+ type: "search",
28
+ placeholder: "Search components...",
29
+ value: i,
30
+ onChange: (a) => {
31
+ d(a.target.value);
32
+ },
33
+ style: {
34
+ width: "100%",
35
+ padding: "6px 8px",
36
+ border: "1px solid #d1d5db",
37
+ borderRadius: 4
38
+ },
39
+ "aria-label": "Search components"
40
+ }
41
+ ) }),
42
+ /* @__PURE__ */ n("nav", { style: { flex: 1, overflow: "auto", padding: "8px 0" }, children: l !== null ? /* @__PURE__ */ n(
43
+ X,
44
+ {
45
+ metas: l,
46
+ selectedEntryId: e,
47
+ selectedJogakName: t,
48
+ onSelect: o
49
+ }
50
+ ) : /* @__PURE__ */ n(
51
+ H,
52
+ {
53
+ node: r,
54
+ selectedEntryId: e,
55
+ selectedJogakName: t,
56
+ onSelect: o
57
+ }
58
+ ) })
59
+ ]
60
+ }
61
+ );
62
+ }
63
+ function X({
64
+ metas: e,
65
+ selectedEntryId: t,
66
+ selectedJogakName: o,
67
+ onSelect: i
68
+ }) {
69
+ return e.length === 0 ? /* @__PURE__ */ n("p", { style: { padding: "0 12px", color: "#9ca3af", fontSize: 13 }, children: "No results" }) : /* @__PURE__ */ n("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: e.map((d) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
70
+ D,
71
+ {
72
+ meta: d,
73
+ selectedEntryId: t,
74
+ selectedJogakName: o,
75
+ onSelect: i,
76
+ indent: 0
77
+ }
78
+ ) }, d.id)) });
79
+ }
80
+ function H({
81
+ node: e,
82
+ selectedEntryId: t,
83
+ selectedJogakName: o,
84
+ onSelect: i,
85
+ depth: d = 0
86
+ }) {
87
+ return /* @__PURE__ */ n(
88
+ "ul",
89
+ {
90
+ style: {
91
+ listStyle: "none",
92
+ margin: 0,
93
+ padding: `0 0 0 ${d * 12}px`
94
+ },
95
+ children: Object.entries(e).map(([r, s]) => /* @__PURE__ */ n("li", { children: "id" in s ? /* @__PURE__ */ n(
96
+ D,
97
+ {
98
+ meta: s,
99
+ selectedEntryId: t,
100
+ selectedJogakName: o,
101
+ onSelect: i,
102
+ indent: 0
103
+ }
104
+ ) : /* @__PURE__ */ n(
105
+ Z,
106
+ {
107
+ label: r,
108
+ node: s,
109
+ selectedEntryId: t,
110
+ selectedJogakName: o,
111
+ onSelect: i,
112
+ depth: d + 1
113
+ }
114
+ ) }, r))
115
+ }
116
+ );
117
+ }
118
+ function Z({
119
+ label: e,
120
+ node: t,
121
+ selectedEntryId: o,
122
+ selectedJogakName: i,
123
+ onSelect: d,
124
+ depth: r
125
+ }) {
126
+ const [s, l] = x(!0);
127
+ return /* @__PURE__ */ c("div", { children: [
128
+ /* @__PURE__ */ c(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ onClick: () => {
133
+ l((a) => !a);
134
+ },
135
+ style: {
136
+ display: "flex",
137
+ alignItems: "center",
138
+ gap: 4,
139
+ width: "100%",
140
+ padding: "4px 12px",
141
+ background: "none",
142
+ border: "none",
143
+ cursor: "pointer",
144
+ fontSize: 12,
145
+ fontWeight: 600,
146
+ color: "#6b7280",
147
+ textTransform: "uppercase",
148
+ letterSpacing: "0.05em"
149
+ },
150
+ "aria-expanded": s,
151
+ children: [
152
+ /* @__PURE__ */ n("span", { children: s ? "▾" : "▸" }),
153
+ e
154
+ ]
155
+ }
156
+ ),
157
+ s && /* @__PURE__ */ n(
158
+ H,
159
+ {
160
+ node: t,
161
+ selectedEntryId: o,
162
+ selectedJogakName: i,
163
+ onSelect: d,
164
+ depth: r
165
+ }
166
+ )
167
+ ] });
168
+ }
169
+ function D({
170
+ meta: e,
171
+ selectedEntryId: t,
172
+ selectedJogakName: o,
173
+ onSelect: i,
174
+ indent: d
175
+ }) {
176
+ const r = e.id === t, [s, l] = x(r);
177
+ v(() => {
178
+ r && l(!0);
179
+ }, [r]);
180
+ const a = e.title.split("/").pop() ?? e.title, m = 16 + d * 12;
181
+ return /* @__PURE__ */ c("div", { children: [
182
+ /* @__PURE__ */ c(
183
+ "button",
184
+ {
185
+ type: "button",
186
+ onClick: () => {
187
+ if (r)
188
+ l((p) => !p);
189
+ else {
190
+ l(!0);
191
+ const p = e.jogakNames[0];
192
+ p !== void 0 && i(e.id, p);
193
+ }
194
+ },
195
+ style: {
196
+ display: "flex",
197
+ alignItems: "center",
198
+ gap: 6,
199
+ width: "100%",
200
+ padding: `5px 12px 5px ${m}px`,
201
+ background: r ? "#eff6ff" : "none",
202
+ border: "none",
203
+ cursor: "pointer",
204
+ fontSize: 13,
205
+ color: r ? "#2563eb" : "#374151",
206
+ fontWeight: r ? 500 : 400,
207
+ textAlign: "left"
208
+ },
209
+ "aria-expanded": s,
210
+ children: [
211
+ /* @__PURE__ */ n("span", { style: { fontSize: 10, flexShrink: 0, lineHeight: 1 }, children: s ? "▾" : "▸" }),
212
+ a
213
+ ]
214
+ }
215
+ ),
216
+ s && /* @__PURE__ */ n("ul", { style: { listStyle: "none", margin: 0, padding: 0 }, children: e.jogakNames.map((p) => {
217
+ const h = r && p === o;
218
+ return /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
219
+ "button",
220
+ {
221
+ type: "button",
222
+ onClick: () => {
223
+ i(e.id, p);
224
+ },
225
+ style: {
226
+ display: "block",
227
+ width: "100%",
228
+ textAlign: "left",
229
+ padding: `4px 12px 4px ${m + 18}px`,
230
+ background: h ? "#dbeafe" : "none",
231
+ border: "none",
232
+ cursor: "pointer",
233
+ fontSize: 12,
234
+ color: h ? "#1d4ed8" : "#6b7280",
235
+ fontWeight: h ? 500 : 400
236
+ },
237
+ "aria-current": h ? "true" : void 0,
238
+ children: p
239
+ }
240
+ ) }, p);
241
+ }) })
242
+ ] });
243
+ }
244
+ function K(e, t) {
245
+ const o = t == null ? void 0 : t.control, i = (t == null ? void 0 : t.action) !== void 0 && t.action !== !1, d = (t == null ? void 0 : t.type) === "function" || typeof e == "function";
246
+ return i || d ? "action" : o === "boolean" || typeof e == "boolean" ? "boolean" : o === "number" || o === "range" || typeof e == "number" ? "number" : o === "select" || o === "radio" || (t == null ? void 0 : t.options) !== void 0 && t.options.length > 0 ? "select" : o === "text" || o === "color" || typeof e == "string" ? "text" : "json";
247
+ }
248
+ function ee({ argKey: e, value: t, argType: o, onArgChange: i }) {
249
+ switch (K(t, o)) {
250
+ case "boolean":
251
+ return /* @__PURE__ */ n(
252
+ "input",
253
+ {
254
+ type: "checkbox",
255
+ checked: t === !0,
256
+ onChange: (r) => {
257
+ i(e, r.target.checked);
258
+ },
259
+ style: { cursor: "pointer", width: 16, height: 16, accentColor: "#2563eb" }
260
+ }
261
+ );
262
+ case "number":
263
+ return /* @__PURE__ */ n(
264
+ "input",
265
+ {
266
+ type: "number",
267
+ value: typeof t == "number" ? t : "",
268
+ onChange: (r) => {
269
+ i(e, r.target.valueAsNumber);
270
+ },
271
+ style: W
272
+ }
273
+ );
274
+ case "select": {
275
+ const r = (o == null ? void 0 : o.options) ?? [];
276
+ return /* @__PURE__ */ n(
277
+ "select",
278
+ {
279
+ value: String(t ?? ""),
280
+ onChange: (s) => {
281
+ i(e, s.target.value);
282
+ },
283
+ style: W,
284
+ children: r.map((s) => /* @__PURE__ */ n("option", { value: String(s), children: String(s) }, String(s)))
285
+ }
286
+ );
287
+ }
288
+ case "text":
289
+ return /* @__PURE__ */ n(
290
+ "input",
291
+ {
292
+ type: "text",
293
+ value: typeof t == "string" ? t : String(t ?? ""),
294
+ onChange: (r) => {
295
+ i(e, r.target.value);
296
+ },
297
+ style: W
298
+ }
299
+ );
300
+ case "action":
301
+ return /* @__PURE__ */ n(
302
+ "span",
303
+ {
304
+ style: {
305
+ display: "inline-block",
306
+ padding: "2px 8px",
307
+ fontSize: 11,
308
+ fontWeight: 600,
309
+ color: "#7c3aed",
310
+ background: "#f5f3ff",
311
+ border: "1px solid #ddd6fe",
312
+ borderRadius: 4,
313
+ fontFamily: "monospace"
314
+ },
315
+ children: "(action)"
316
+ }
317
+ );
318
+ case "json":
319
+ return /* @__PURE__ */ n("code", { style: { fontSize: 12, color: "#6b7280", fontFamily: "monospace" }, children: JSON.stringify(t) });
320
+ }
321
+ }
322
+ const W = {
323
+ padding: "4px 8px",
324
+ border: "1px solid #d1d5db",
325
+ borderRadius: 4,
326
+ fontSize: 13,
327
+ width: "100%",
328
+ maxWidth: 280
329
+ }, A = {
330
+ padding: "6px 20px",
331
+ textAlign: "left",
332
+ color: "#6b7280",
333
+ fontWeight: 500,
334
+ fontSize: 12,
335
+ borderBottom: "1px solid #e5e7eb"
336
+ }, B = {
337
+ padding: "8px 20px",
338
+ verticalAlign: "middle",
339
+ borderBottom: "1px solid #f3f4f6"
340
+ };
341
+ function te({ args: e, argTypes: t, onArgChange: o }) {
342
+ const d = Array.from(/* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)])).map((r) => [r, e[r]]);
343
+ return /* @__PURE__ */ c("div", { style: { borderTop: "2px solid #e5e7eb" }, children: [
344
+ /* @__PURE__ */ n(
345
+ "div",
346
+ {
347
+ style: {
348
+ padding: "6px 20px",
349
+ fontSize: 11,
350
+ fontWeight: 700,
351
+ color: "#9ca3af",
352
+ textTransform: "uppercase",
353
+ letterSpacing: "0.08em",
354
+ borderBottom: "1px solid #e5e7eb",
355
+ background: "#f9fafb"
356
+ },
357
+ children: "Controls"
358
+ }
359
+ ),
360
+ d.length === 0 ? /* @__PURE__ */ n("div", { style: { padding: "12px 20px", color: "#9ca3af", fontSize: 13 }, children: "No args defined" }) : /* @__PURE__ */ c("table", { style: { width: "100%", borderCollapse: "collapse", fontSize: 13 }, children: [
361
+ /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ c("tr", { children: [
362
+ /* @__PURE__ */ n("th", { style: A, children: "Name" }),
363
+ /* @__PURE__ */ n("th", { style: A, children: "Control" }),
364
+ /* @__PURE__ */ n("th", { style: A, children: "Description" })
365
+ ] }) }),
366
+ /* @__PURE__ */ n("tbody", { children: d.map(([r, s]) => {
367
+ const l = t[r];
368
+ return /* @__PURE__ */ c("tr", { children: [
369
+ /* @__PURE__ */ n(
370
+ "td",
371
+ {
372
+ style: {
373
+ ...B,
374
+ fontFamily: "monospace",
375
+ fontSize: 12,
376
+ color: "#374151",
377
+ whiteSpace: "nowrap"
378
+ },
379
+ children: r
380
+ }
381
+ ),
382
+ /* @__PURE__ */ n("td", { style: B, children: /* @__PURE__ */ n(
383
+ ee,
384
+ {
385
+ argKey: r,
386
+ value: s,
387
+ argType: l,
388
+ onArgChange: o
389
+ }
390
+ ) }),
391
+ /* @__PURE__ */ n("td", { style: { ...B, color: "#9ca3af" }, children: (l == null ? void 0 : l.description) ?? "" })
392
+ ] }, r);
393
+ }) })
394
+ ] })
395
+ ] });
396
+ }
397
+ function ne(e) {
398
+ if (e.length === 0) return "()";
399
+ try {
400
+ return e.map((t) => {
401
+ var o;
402
+ if (t === null) return "null";
403
+ if (t === void 0) return "undefined";
404
+ if (typeof t == "function") return "[Function]";
405
+ if (typeof t == "object") {
406
+ const i = ((o = t.constructor) == null ? void 0 : o.name) ?? "Object";
407
+ return i !== "Object" && i !== "Array" ? `[${i}]` : JSON.stringify(t);
408
+ }
409
+ return JSON.stringify(t);
410
+ }).join(", ");
411
+ } catch {
412
+ return "[unserializable]";
413
+ }
414
+ }
415
+ function oe(e) {
416
+ const t = new Date(e), o = t.getHours().toString().padStart(2, "0"), i = t.getMinutes().toString().padStart(2, "0"), d = t.getSeconds().toString().padStart(2, "0"), r = t.getMilliseconds().toString().padStart(3, "0");
417
+ return `${o}:${i}:${d}.${r}`;
418
+ }
419
+ function re() {
420
+ const [e, t] = x(() => z.getLogs());
421
+ return v(() => z.subscribe(t), []), /* @__PURE__ */ c("div", { style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
422
+ /* @__PURE__ */ c(
423
+ "div",
424
+ {
425
+ style: {
426
+ padding: "6px 20px",
427
+ fontSize: 11,
428
+ fontWeight: 700,
429
+ color: "#9ca3af",
430
+ textTransform: "uppercase",
431
+ letterSpacing: "0.08em",
432
+ borderBottom: "1px solid #e5e7eb",
433
+ background: "#f9fafb",
434
+ display: "flex",
435
+ alignItems: "center",
436
+ justifyContent: "space-between",
437
+ flexShrink: 0
438
+ },
439
+ children: [
440
+ /* @__PURE__ */ c("span", { children: [
441
+ "Actions ",
442
+ e.length > 0 && `(${e.length.toString()})`
443
+ ] }),
444
+ /* @__PURE__ */ n(
445
+ "button",
446
+ {
447
+ type: "button",
448
+ onClick: () => {
449
+ z.clear();
450
+ },
451
+ disabled: e.length === 0,
452
+ style: {
453
+ fontSize: 10,
454
+ fontWeight: 600,
455
+ padding: "2px 8px",
456
+ border: "1px solid #d1d5db",
457
+ borderRadius: 3,
458
+ background: "#fff",
459
+ color: e.length === 0 ? "#9ca3af" : "#374151",
460
+ cursor: e.length === 0 ? "default" : "pointer",
461
+ textTransform: "none",
462
+ letterSpacing: 0
463
+ },
464
+ children: "Clear"
465
+ }
466
+ )
467
+ ]
468
+ }
469
+ ),
470
+ /* @__PURE__ */ n("div", { style: { flex: 1, overflow: "auto" }, children: e.length === 0 ? /* @__PURE__ */ n(
471
+ "div",
472
+ {
473
+ style: {
474
+ padding: "12px 20px",
475
+ color: "#9ca3af",
476
+ fontSize: 13
477
+ },
478
+ children: "함수 prop이 호출되면 여기에 기록됩니다"
479
+ }
480
+ ) : /* @__PURE__ */ n("ul", { style: { listStyle: "none", margin: 0, padding: 0, fontFamily: "monospace", fontSize: 12 }, children: e.map((o) => /* @__PURE__ */ c(
481
+ "li",
482
+ {
483
+ style: {
484
+ display: "flex",
485
+ alignItems: "baseline",
486
+ gap: 10,
487
+ padding: "6px 20px",
488
+ borderBottom: "1px solid #f3f4f6"
489
+ },
490
+ children: [
491
+ /* @__PURE__ */ n("span", { style: { color: "#9ca3af", fontSize: 11, minWidth: 92 }, children: oe(o.timestamp) }),
492
+ /* @__PURE__ */ n("span", { style: { color: "#7c3aed", fontWeight: 600 }, children: o.name }),
493
+ /* @__PURE__ */ c("span", { style: { color: "#374151", wordBreak: "break-all", flex: 1 }, children: [
494
+ "(",
495
+ ne(o.args),
496
+ ")"
497
+ ] })
498
+ ]
499
+ },
500
+ o.id
501
+ )) }) })
502
+ ] });
503
+ }
504
+ const N = {
505
+ mobile: 375,
506
+ tablet: 768,
507
+ desktop: "none"
508
+ }, ie = {
509
+ mobile: "Mobile",
510
+ tablet: "Tablet",
511
+ desktop: "Desktop"
512
+ }, M = {
513
+ white: { background: "#ffffff" },
514
+ dark: { background: "#1f2937" },
515
+ transparent: {
516
+ backgroundImage: [
517
+ "linear-gradient(45deg, #e2e8f0 25%, transparent 25%)",
518
+ "linear-gradient(-45deg, #e2e8f0 25%, transparent 25%)",
519
+ "linear-gradient(45deg, transparent 75%, #e2e8f0 75%)",
520
+ "linear-gradient(-45deg, transparent 75%, #e2e8f0 75%)"
521
+ ].join(", "),
522
+ backgroundSize: "16px 16px",
523
+ backgroundPosition: "0 0, 0 8px, 8px -8px, -8px 0px",
524
+ backgroundColor: "#ffffff"
525
+ }
526
+ }, I = 320;
527
+ function de(e) {
528
+ return L[e] ?? L.vsDark;
529
+ }
530
+ function le({
531
+ entryId: e,
532
+ jogakName: t,
533
+ overrideArgs: o,
534
+ onArgChange: i,
535
+ onReset: d,
536
+ codeTheme: r,
537
+ onResolveJogak: s
538
+ }) {
539
+ const l = G(e), [a, m] = x("desktop"), [p, h] = x("white"), [S, b] = x("controls"), y = de(r);
540
+ return l.status === "unknown" ? /* @__PURE__ */ c("div", { "data-testid": "preview-not-found", style: { padding: 24, color: "#ef4444" }, children: [
541
+ "Entry not found: ",
542
+ e
543
+ ] }) : l.status === "error" ? /* @__PURE__ */ c(
544
+ "div",
545
+ {
546
+ "data-testid": "preview-error",
547
+ style: {
548
+ padding: 24,
549
+ color: "#b91c1c",
550
+ background: "#fef2f2",
551
+ height: "100%",
552
+ display: "flex",
553
+ flexDirection: "column",
554
+ gap: 12,
555
+ alignItems: "flex-start"
556
+ },
557
+ children: [
558
+ /* @__PURE__ */ c("div", { style: { fontWeight: 600 }, children: [
559
+ "Failed to load entry: ",
560
+ e
561
+ ] }),
562
+ /* @__PURE__ */ n(
563
+ "pre",
564
+ {
565
+ style: {
566
+ margin: 0,
567
+ padding: 12,
568
+ background: "#fff",
569
+ border: "1px solid #fecaca",
570
+ borderRadius: 6,
571
+ fontSize: 12,
572
+ whiteSpace: "pre-wrap",
573
+ maxWidth: "100%"
574
+ },
575
+ children: l.error.message
576
+ }
577
+ )
578
+ ]
579
+ }
580
+ ) : l.status === "loading" ? /* @__PURE__ */ n(
581
+ se,
582
+ {
583
+ meta: l.meta,
584
+ jogakName: t,
585
+ viewport: a,
586
+ bgMode: p,
587
+ onViewportChange: m,
588
+ onBgModeChange: h
589
+ }
590
+ ) : /* @__PURE__ */ n(
591
+ ae,
592
+ {
593
+ entry: l.entry,
594
+ jogakName: t,
595
+ overrideArgs: o,
596
+ onArgChange: i,
597
+ onReset: d,
598
+ onResolveJogak: s,
599
+ viewport: a,
600
+ bgMode: p,
601
+ bottomTab: S,
602
+ onViewportChange: m,
603
+ onBgModeChange: h,
604
+ onBottomTabChange: b,
605
+ prismTheme: y
606
+ }
607
+ );
608
+ }
609
+ function se({
610
+ meta: e,
611
+ jogakName: t,
612
+ viewport: o,
613
+ bgMode: i,
614
+ onViewportChange: d,
615
+ onBgModeChange: r
616
+ }) {
617
+ const s = t ?? e.jogakNames[0] ?? "...", l = N[o];
618
+ return /* @__PURE__ */ c(
619
+ "div",
620
+ {
621
+ "data-testid": "preview-loading",
622
+ style: { display: "flex", flexDirection: "column", height: "100%" },
623
+ children: [
624
+ /* @__PURE__ */ n(
625
+ J,
626
+ {
627
+ title: e.title,
628
+ jogakName: s,
629
+ viewport: o,
630
+ bgMode: i,
631
+ onViewportChange: d,
632
+ onBgModeChange: r,
633
+ showReset: !1,
634
+ onReset: () => {
635
+ }
636
+ }
637
+ ),
638
+ /* @__PURE__ */ n(
639
+ "div",
640
+ {
641
+ style: {
642
+ flex: 1,
643
+ minHeight: I,
644
+ overflow: "auto",
645
+ ...M[i]
646
+ },
647
+ children: /* @__PURE__ */ n(
648
+ "div",
649
+ {
650
+ style: {
651
+ maxWidth: l === "none" ? "100%" : l,
652
+ margin: "0 auto",
653
+ padding: 24
654
+ },
655
+ children: /* @__PURE__ */ c(
656
+ "div",
657
+ {
658
+ style: {
659
+ border: "1px dashed #e5e7eb",
660
+ borderRadius: 8,
661
+ padding: 16,
662
+ minHeight: I - 64,
663
+ display: "flex",
664
+ alignItems: "center",
665
+ justifyContent: "center",
666
+ color: "#9ca3af",
667
+ fontSize: 13,
668
+ background: "linear-gradient(90deg, rgba(229,231,235,0) 0%, rgba(229,231,235,0.45) 50%, rgba(229,231,235,0) 100%)",
669
+ backgroundSize: "200% 100%",
670
+ animation: "jogakSkeleton 1.4s ease-in-out infinite"
671
+ },
672
+ children: [
673
+ "Loading ",
674
+ e.title,
675
+ "…"
676
+ ]
677
+ }
678
+ )
679
+ }
680
+ )
681
+ }
682
+ ),
683
+ /* @__PURE__ */ n("style", { children: "@keyframes jogakSkeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }" })
684
+ ]
685
+ }
686
+ );
687
+ }
688
+ function ae({
689
+ entry: e,
690
+ jogakName: t,
691
+ overrideArgs: o,
692
+ onArgChange: i,
693
+ onReset: d,
694
+ onResolveJogak: r,
695
+ viewport: s,
696
+ bgMode: l,
697
+ bottomTab: a,
698
+ onViewportChange: m,
699
+ onBgModeChange: p,
700
+ onBottomTabChange: h,
701
+ prismTheme: S
702
+ }) {
703
+ var $;
704
+ const b = t ?? (($ = e.jogaks[0]) == null ? void 0 : $.name) ?? null;
705
+ if (v(() => {
706
+ t === null && b !== null && r !== void 0 && r(e.id, b);
707
+ }, [t, b, e.id, r]), b === null)
708
+ return /* @__PURE__ */ c("div", { style: { padding: 24, color: "#ef4444" }, children: [
709
+ "Entry has no jogaks: ",
710
+ e.id
711
+ ] });
712
+ const y = e.jogaks.find((k) => k.name === b);
713
+ if (y === void 0)
714
+ return /* @__PURE__ */ c("div", { style: { padding: 24, color: "#ef4444" }, children: [
715
+ "Jogak not found: ",
716
+ b
717
+ ] });
718
+ const u = { ...y.args ?? {}, ...o }, g = {
719
+ ...e.meta.argTypes ?? {},
720
+ ...y.argTypes ?? {}
721
+ }, P = Object.keys(o).length > 0, O = N[s];
722
+ return /* @__PURE__ */ c("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
723
+ /* @__PURE__ */ n(
724
+ J,
725
+ {
726
+ title: e.title,
727
+ jogakName: y.name,
728
+ viewport: s,
729
+ bgMode: l,
730
+ onViewportChange: m,
731
+ onBgModeChange: p,
732
+ showReset: P,
733
+ onReset: d
734
+ }
735
+ ),
736
+ /* @__PURE__ */ n(
737
+ "div",
738
+ {
739
+ style: {
740
+ flex: 1,
741
+ minHeight: I,
742
+ overflow: "auto",
743
+ ...M[l]
744
+ },
745
+ children: /* @__PURE__ */ n(
746
+ "div",
747
+ {
748
+ style: {
749
+ maxWidth: O === "none" ? "100%" : O,
750
+ margin: "0 auto",
751
+ padding: 24
752
+ },
753
+ children: /* @__PURE__ */ n(
754
+ ce,
755
+ {
756
+ entry: e,
757
+ args: u,
758
+ source: e.source,
759
+ theme: S
760
+ },
761
+ `${e.id}/${y.name}`
762
+ )
763
+ }
764
+ )
765
+ }
766
+ ),
767
+ /* @__PURE__ */ c(
768
+ "div",
769
+ {
770
+ style: {
771
+ height: 260,
772
+ flexShrink: 0,
773
+ display: "flex",
774
+ flexDirection: "column",
775
+ borderTop: "2px solid #e5e7eb"
776
+ },
777
+ children: [
778
+ /* @__PURE__ */ n(
779
+ "div",
780
+ {
781
+ role: "tablist",
782
+ style: {
783
+ display: "flex",
784
+ gap: 4,
785
+ padding: "4px 12px 0",
786
+ background: "#fff",
787
+ borderBottom: "1px solid #e5e7eb",
788
+ flexShrink: 0
789
+ },
790
+ children: ["controls", "actions"].map((k) => {
791
+ const C = a === k;
792
+ return /* @__PURE__ */ n(
793
+ "button",
794
+ {
795
+ type: "button",
796
+ role: "tab",
797
+ "aria-selected": C,
798
+ onClick: () => {
799
+ h(k);
800
+ },
801
+ style: {
802
+ padding: "6px 14px",
803
+ fontSize: 12,
804
+ fontWeight: C ? 600 : 500,
805
+ color: C ? "#111827" : "#6b7280",
806
+ background: "transparent",
807
+ border: "none",
808
+ borderBottom: C ? "2px solid #2563eb" : "2px solid transparent",
809
+ marginBottom: -1,
810
+ cursor: "pointer",
811
+ textTransform: "capitalize"
812
+ },
813
+ children: k
814
+ },
815
+ k
816
+ );
817
+ })
818
+ }
819
+ ),
820
+ /* @__PURE__ */ n("div", { style: { flex: 1, minHeight: 0, overflow: "auto" }, children: a === "controls" ? /* @__PURE__ */ n(
821
+ te,
822
+ {
823
+ args: u,
824
+ argTypes: g,
825
+ onArgChange: i
826
+ }
827
+ ) : /* @__PURE__ */ n(re, {}) })
828
+ ]
829
+ }
830
+ )
831
+ ] });
832
+ }
833
+ function J({
834
+ title: e,
835
+ jogakName: t,
836
+ viewport: o,
837
+ bgMode: i,
838
+ onViewportChange: d,
839
+ onBgModeChange: r,
840
+ showReset: s,
841
+ onReset: l
842
+ }) {
843
+ return /* @__PURE__ */ c(
844
+ "div",
845
+ {
846
+ style: {
847
+ display: "flex",
848
+ alignItems: "center",
849
+ gap: 10,
850
+ padding: "7px 14px",
851
+ borderBottom: "1px solid #e5e7eb",
852
+ background: "#fff",
853
+ flexShrink: 0
854
+ },
855
+ children: [
856
+ /* @__PURE__ */ c("div", { style: { flex: 1, fontSize: 13 }, children: [
857
+ /* @__PURE__ */ n("span", { style: { color: "#9ca3af" }, children: e }),
858
+ /* @__PURE__ */ n("span", { style: { color: "#d1d5db", margin: "0 6px" }, children: "/" }),
859
+ /* @__PURE__ */ n("span", { style: { color: "#111827", fontWeight: 600 }, children: t })
860
+ ] }),
861
+ /* @__PURE__ */ n(
862
+ "div",
863
+ {
864
+ style: {
865
+ display: "flex",
866
+ gap: 2,
867
+ background: "#f3f4f6",
868
+ borderRadius: 6,
869
+ padding: 2
870
+ },
871
+ children: ["mobile", "tablet", "desktop"].map((a) => /* @__PURE__ */ n(
872
+ "button",
873
+ {
874
+ type: "button",
875
+ onClick: () => {
876
+ d(a);
877
+ },
878
+ "aria-pressed": o === a,
879
+ style: {
880
+ padding: "3px 9px",
881
+ fontSize: 12,
882
+ border: "none",
883
+ borderRadius: 4,
884
+ cursor: "pointer",
885
+ background: o === a ? "#fff" : "transparent",
886
+ color: o === a ? "#111827" : "#6b7280",
887
+ fontWeight: o === a ? 600 : 400,
888
+ boxShadow: o === a ? "0 1px 2px rgba(0,0,0,0.08)" : "none",
889
+ transition: "all 0.1s"
890
+ },
891
+ children: ie[a]
892
+ },
893
+ a
894
+ ))
895
+ }
896
+ ),
897
+ /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, alignItems: "center" }, children: ["white", "dark", "transparent"].map((a) => /* @__PURE__ */ n(
898
+ "button",
899
+ {
900
+ type: "button",
901
+ onClick: () => {
902
+ r(a);
903
+ },
904
+ "aria-pressed": i === a,
905
+ "aria-label": `${a} background`,
906
+ style: {
907
+ width: 20,
908
+ height: 20,
909
+ borderRadius: 4,
910
+ border: i === a ? "2px solid #2563eb" : "2px solid #d1d5db",
911
+ cursor: "pointer",
912
+ padding: 0,
913
+ flexShrink: 0,
914
+ ...M[a]
915
+ }
916
+ },
917
+ a
918
+ )) }),
919
+ s && /* @__PURE__ */ n(
920
+ "button",
921
+ {
922
+ type: "button",
923
+ onClick: l,
924
+ style: {
925
+ padding: "3px 10px",
926
+ fontSize: 12,
927
+ border: "1px solid #d1d5db",
928
+ borderRadius: 4,
929
+ background: "#fff",
930
+ cursor: "pointer",
931
+ color: "#374151"
932
+ },
933
+ children: "Reset"
934
+ }
935
+ )
936
+ ]
937
+ }
938
+ );
939
+ }
940
+ function ce({ entry: e, args: t, source: o, theme: i }) {
941
+ const d = V(null), [r, s] = x(!1);
942
+ return v(() => {
943
+ const l = d.current;
944
+ if (l !== null)
945
+ return j.render(e, t, l), () => {
946
+ j.unmount(l);
947
+ };
948
+ }, [e]), v(() => {
949
+ const l = d.current;
950
+ l !== null && j.render(e, t, l);
951
+ }, [e, t]), /* @__PURE__ */ c("div", { children: [
952
+ /* @__PURE__ */ c("div", { style: { position: "relative" }, children: [
953
+ /* @__PURE__ */ n(
954
+ "div",
955
+ {
956
+ ref: d,
957
+ "data-testid": "preview-content",
958
+ style: {
959
+ border: "1px dashed #e5e7eb",
960
+ borderRadius: 8,
961
+ padding: 16,
962
+ paddingBottom: 36
963
+ }
964
+ }
965
+ ),
966
+ /* @__PURE__ */ n(
967
+ "button",
968
+ {
969
+ type: "button",
970
+ onClick: () => {
971
+ s((l) => !l);
972
+ },
973
+ "aria-pressed": r,
974
+ "aria-label": r ? "Hide source code" : "Show source code",
975
+ style: {
976
+ position: "absolute",
977
+ bottom: 8,
978
+ right: 8,
979
+ padding: "4px 9px",
980
+ fontSize: 11,
981
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
982
+ fontWeight: 600,
983
+ letterSpacing: "0.02em",
984
+ background: r ? "#2563eb" : "#1e293b",
985
+ color: "#fff",
986
+ border: "none",
987
+ borderRadius: 5,
988
+ cursor: "pointer",
989
+ boxShadow: "0 1px 4px rgba(0,0,0,0.2)",
990
+ transition: "background 0.15s"
991
+ },
992
+ children: "</>"
993
+ }
994
+ )
995
+ ] }),
996
+ r && /* @__PURE__ */ n(
997
+ "div",
998
+ {
999
+ style: {
1000
+ marginTop: 8,
1001
+ borderRadius: 8,
1002
+ overflow: "hidden",
1003
+ height: 320,
1004
+ boxShadow: "0 0 0 1px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.12)"
1005
+ },
1006
+ children: /* @__PURE__ */ n(pe, { source: o, theme: i })
1007
+ }
1008
+ )
1009
+ ] });
1010
+ }
1011
+ function pe({ source: e, theme: t }) {
1012
+ const [o, i] = x(!1), d = t.plain.backgroundColor ?? "#1e293b";
1013
+ return e === void 0 ? /* @__PURE__ */ n(
1014
+ "div",
1015
+ {
1016
+ style: {
1017
+ height: "100%",
1018
+ display: "flex",
1019
+ alignItems: "center",
1020
+ justifyContent: "center",
1021
+ background: d,
1022
+ color: "#94a3b8",
1023
+ fontSize: 13
1024
+ },
1025
+ children: "Source not available"
1026
+ }
1027
+ ) : /* @__PURE__ */ c("div", { style: { position: "relative", height: "100%" }, children: [
1028
+ /* @__PURE__ */ n(
1029
+ "button",
1030
+ {
1031
+ type: "button",
1032
+ onClick: () => {
1033
+ navigator.clipboard.writeText(e).then(() => {
1034
+ i(!0), setTimeout(() => {
1035
+ i(!1);
1036
+ }, 2e3);
1037
+ });
1038
+ },
1039
+ style: {
1040
+ position: "absolute",
1041
+ top: 10,
1042
+ right: 12,
1043
+ zIndex: 1,
1044
+ padding: "3px 9px",
1045
+ fontSize: 11,
1046
+ background: "rgba(255,255,255,0.1)",
1047
+ color: "#e2e8f0",
1048
+ border: "1px solid rgba(255,255,255,0.18)",
1049
+ borderRadius: 4,
1050
+ cursor: "pointer"
1051
+ },
1052
+ children: o ? "✓ Copied" : "Copy"
1053
+ }
1054
+ ),
1055
+ /* @__PURE__ */ n(Q, { code: e.trim(), language: "tsx", theme: t, children: ({ style: s, tokens: l, getLineProps: a, getTokenProps: m }) => /* @__PURE__ */ n(
1056
+ "pre",
1057
+ {
1058
+ style: {
1059
+ ...s,
1060
+ margin: 0,
1061
+ padding: "12px 0",
1062
+ fontSize: 12.5,
1063
+ lineHeight: 1.7,
1064
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
1065
+ height: "100%",
1066
+ boxSizing: "border-box",
1067
+ overflow: "auto"
1068
+ },
1069
+ children: l.map((p, h) => /* @__PURE__ */ c(
1070
+ "div",
1071
+ {
1072
+ ...a({ line: p }),
1073
+ style: {
1074
+ ...a({ line: p }).style,
1075
+ display: "flex",
1076
+ paddingRight: 24
1077
+ },
1078
+ children: [
1079
+ /* @__PURE__ */ n(
1080
+ "span",
1081
+ {
1082
+ style: {
1083
+ userSelect: "none",
1084
+ minWidth: 40,
1085
+ paddingLeft: 14,
1086
+ paddingRight: 14,
1087
+ textAlign: "right",
1088
+ color: "rgba(148,163,184,0.45)",
1089
+ flexShrink: 0
1090
+ },
1091
+ children: h + 1
1092
+ }
1093
+ ),
1094
+ /* @__PURE__ */ n("span", { children: p.map((S, b) => /* @__PURE__ */ n("span", { ...m({ token: S }) }, b)) })
1095
+ ]
1096
+ },
1097
+ h
1098
+ ))
1099
+ }
1100
+ ) })
1101
+ ] });
1102
+ }
1103
+ function E() {
1104
+ if (typeof window > "u") return null;
1105
+ const e = new URLSearchParams(window.location.search), t = e.get("entry");
1106
+ if (t === null) return null;
1107
+ const o = e.get("jogak");
1108
+ return { entryId: t, jogakName: o };
1109
+ }
1110
+ function fe(e, t) {
1111
+ const o = new URLSearchParams();
1112
+ o.set("entry", e), o.set("jogak", t), window.history.pushState({}, "", `?${o.toString()}`);
1113
+ }
1114
+ function me({
1115
+ entries: e,
1116
+ metas: t,
1117
+ codeTheme: o = "vsDark"
1118
+ } = {}) {
1119
+ const i = w(() => {
1120
+ if (e !== void 0) {
1121
+ t !== void 0 && console.warn(
1122
+ "[jogak] JogakApp received both `entries` and `metas` — `entries` (eager) takes precedence."
1123
+ );
1124
+ const f = new U();
1125
+ for (const u of e) f.register(u);
1126
+ return f;
1127
+ }
1128
+ if (t !== void 0)
1129
+ for (const f of t) F.registerMeta(f);
1130
+ return F;
1131
+ }, [e, t]), d = w(() => E(), []), [r, s] = x(
1132
+ (d == null ? void 0 : d.entryId) ?? null
1133
+ ), [l, a] = x(
1134
+ (d == null ? void 0 : d.jogakName) ?? null
1135
+ ), [m, p] = x({});
1136
+ v(() => {
1137
+ const f = () => {
1138
+ const u = E();
1139
+ u !== null ? (s(u.entryId), a(u.jogakName), p({})) : (s(null), a(null));
1140
+ };
1141
+ return window.addEventListener("popstate", f), () => {
1142
+ window.removeEventListener("popstate", f);
1143
+ };
1144
+ }, []);
1145
+ const h = R((f, u) => {
1146
+ s(f), a(u), p({}), fe(f, u);
1147
+ }, []), S = R((f, u) => {
1148
+ if (s((g) => g === f ? f : g), a((g) => g ?? u), typeof window < "u") {
1149
+ const g = new URLSearchParams(window.location.search);
1150
+ g.get("entry") === f && g.get("jogak") === null && (g.set("jogak", u), window.history.replaceState({}, "", `?${g.toString()}`));
1151
+ }
1152
+ }, []), b = R((f, u) => {
1153
+ p((g) => ({ ...g, [f]: u }));
1154
+ }, []), y = R(() => {
1155
+ p({});
1156
+ }, []);
1157
+ return /* @__PURE__ */ n(T, { registry: i, children: /* @__PURE__ */ c(
1158
+ "div",
1159
+ {
1160
+ style: {
1161
+ display: "grid",
1162
+ gridTemplateColumns: "260px 1fr",
1163
+ height: "100dvh",
1164
+ overflow: "hidden"
1165
+ },
1166
+ children: [
1167
+ /* @__PURE__ */ n(
1168
+ Y,
1169
+ {
1170
+ selectedEntryId: r,
1171
+ selectedJogakName: l,
1172
+ onSelect: h
1173
+ }
1174
+ ),
1175
+ /* @__PURE__ */ n("main", { style: { overflow: "hidden", minHeight: 0 }, children: r !== null ? /* @__PURE__ */ n(
1176
+ le,
1177
+ {
1178
+ entryId: r,
1179
+ jogakName: l,
1180
+ overrideArgs: m,
1181
+ onArgChange: b,
1182
+ onReset: y,
1183
+ codeTheme: o,
1184
+ onResolveJogak: S
1185
+ }
1186
+ ) : /* @__PURE__ */ n(
1187
+ "div",
1188
+ {
1189
+ style: {
1190
+ display: "flex",
1191
+ alignItems: "center",
1192
+ justifyContent: "center",
1193
+ height: "100%",
1194
+ color: "#9ca3af"
1195
+ },
1196
+ children: "Select a component from the sidebar"
1197
+ }
1198
+ ) })
1199
+ ]
1200
+ }
1201
+ ) });
1202
+ }
1203
+ function ye() {
1204
+ const e = q(), t = w(() => e.getAll(), [e]), o = w(() => e.getTree(), [e]), i = w(
1205
+ () => (d) => e.search(d),
1206
+ [e]
1207
+ );
1208
+ return { entries: t, tree: o, search: i };
1209
+ }
1210
+ export {
1211
+ re as Actions,
1212
+ te as Controls,
1213
+ me as JogakApp,
1214
+ le as Preview,
1215
+ Y as Sidebar,
1216
+ ye as useRegistry
1217
+ };