@vscode/component-explorer 0.1.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 (52) hide show
  1. package/dist/components/Explorer.d.ts +6 -0
  2. package/dist/components/Explorer.d.ts.map +1 -0
  3. package/dist/components/ExplorerModel.d.ts +50 -0
  4. package/dist/components/ExplorerModel.d.ts.map +1 -0
  5. package/dist/components/FixturePreviewItem.d.ts +8 -0
  6. package/dist/components/FixturePreviewItem.d.ts.map +1 -0
  7. package/dist/components/LeftSidebar.d.ts +5 -0
  8. package/dist/components/LeftSidebar.d.ts.map +1 -0
  9. package/dist/components/PreviewArea.d.ts +6 -0
  10. package/dist/components/PreviewArea.d.ts.map +1 -0
  11. package/dist/components/RightSidebar.d.ts +6 -0
  12. package/dist/components/RightSidebar.d.ts.map +1 -0
  13. package/dist/components/TitleBar.d.ts +5 -0
  14. package/dist/components/TitleBar.d.ts.map +1 -0
  15. package/dist/components/TitleBarButton.d.ts +9 -0
  16. package/dist/components/TitleBarButton.d.ts.map +1 -0
  17. package/dist/components/TreeView.d.ts +14 -0
  18. package/dist/components/TreeView.d.ts.map +1 -0
  19. package/dist/components/icons.d.ts +18 -0
  20. package/dist/components/icons.d.ts.map +1 -0
  21. package/dist/components/index.d.ts +15 -0
  22. package/dist/components/index.d.ts.map +1 -0
  23. package/dist/components/styles.d.ts +192 -0
  24. package/dist/components/styles.d.ts.map +1 -0
  25. package/dist/components/types.d.ts +18 -0
  26. package/dist/components/types.d.ts.map +1 -0
  27. package/dist/core/ComponentDefinition.d.ts +70 -0
  28. package/dist/core/ComponentDefinition.d.ts.map +1 -0
  29. package/dist/core/DisplayMode.d.ts +65 -0
  30. package/dist/core/DisplayMode.d.ts.map +1 -0
  31. package/dist/core/FixtureNode.d.ts +31 -0
  32. package/dist/core/FixtureNode.d.ts.map +1 -0
  33. package/dist/core/FixtureRegistry.d.ts +37 -0
  34. package/dist/core/FixtureRegistry.d.ts.map +1 -0
  35. package/dist/core/PropertySchema.d.ts +40 -0
  36. package/dist/core/PropertySchema.d.ts.map +1 -0
  37. package/dist/core/defineFixture.d.ts +109 -0
  38. package/dist/core/defineFixture.d.ts.map +1 -0
  39. package/dist/core/index.d.ts +12 -0
  40. package/dist/core/index.d.ts.map +1 -0
  41. package/dist/index.css +1 -0
  42. package/dist/index.d.ts +31 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +1386 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/lib/fixtureSizeCache.d.ts +12 -0
  47. package/dist/lib/fixtureSizeCache.d.ts.map +1 -0
  48. package/dist/lib/localStorageObservable.d.ts +16 -0
  49. package/dist/lib/localStorageObservable.d.ts.map +1 -0
  50. package/dist/lib/utils.d.ts +6 -0
  51. package/dist/lib/utils.d.ts.map +1 -0
  52. package/package.json +59 -0
package/dist/index.js ADDED
@@ -0,0 +1,1386 @@
1
+ var Q = Object.defineProperty;
2
+ var ee = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var l = (r, e, t) => ee(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { observableValue as b, derived as R } from "@vscode/observables";
5
+ import te from "react-dom";
6
+ import { createElement as re } from "react";
7
+ import { jsx as i, jsxs as p, Fragment as B } from "react/jsx-runtime";
8
+ import { ViewModel as S, prop as a, viewWithModel as w, view as x } from "@vscode/observables-react";
9
+ const oe = {
10
+ mobile: { width: 390, height: 844 },
11
+ tablet: { width: 768, height: 1024 },
12
+ desktop: { width: 1440, height: 900 }
13
+ };
14
+ function ie(r) {
15
+ return typeof r == "string" ? { name: r, ...oe[r] } : r;
16
+ }
17
+ function et(r) {
18
+ const e = {};
19
+ for (const t of r)
20
+ e[t.name] = t.defaultValue;
21
+ return e;
22
+ }
23
+ function tt(r) {
24
+ return typeof r == "object" && r !== null && "render" in r && typeof r.render == "function" && "id" in r && "name" in r;
25
+ }
26
+ const F = Symbol("singleFixture"), D = Symbol("fixtureGroup"), P = Symbol("fixtureVariants");
27
+ function ne(r) {
28
+ return typeof r == "object" && r !== null && F in r;
29
+ }
30
+ function se(r) {
31
+ return typeof r == "object" && r !== null && D in r;
32
+ }
33
+ function de(r) {
34
+ return typeof r == "object" && r !== null && P in r;
35
+ }
36
+ function le(r, e, t) {
37
+ return {
38
+ id: e,
39
+ name: t,
40
+ description: r.description,
41
+ isolation: r.isolation ?? "shadow-dom",
42
+ displayMode: r.displayMode ?? { type: "component" },
43
+ styles: r.styles,
44
+ background: r.background ?? "light",
45
+ properties: r.properties ?? [],
46
+ render: r.render
47
+ };
48
+ }
49
+ function I(r) {
50
+ return {
51
+ [F]: !0,
52
+ _options: r,
53
+ _createDefinition: (e, t) => le(r, e, t)
54
+ };
55
+ }
56
+ function rt(r) {
57
+ return {
58
+ [D]: !0,
59
+ _entries: r
60
+ };
61
+ }
62
+ function ot(r) {
63
+ return {
64
+ [P]: !0,
65
+ _variants: r
66
+ };
67
+ }
68
+ function E(r) {
69
+ const e = {
70
+ id: "",
71
+ name: "Components",
72
+ type: "folder",
73
+ children: []
74
+ };
75
+ for (const [t, o] of r) {
76
+ const n = ce(t);
77
+ j(e, [n], o);
78
+ }
79
+ return e;
80
+ }
81
+ function ce(r) {
82
+ return (r.split("/").pop() ?? r).replace(/\.fixture\.(tsx?|jsx?)$/, "");
83
+ }
84
+ function j(r, e, t) {
85
+ var o;
86
+ if (ne(t)) {
87
+ const n = e.join("/"), s = e[e.length - 1], d = {
88
+ id: n,
89
+ name: s,
90
+ type: "component",
91
+ component: t._createDefinition(n, s)
92
+ };
93
+ r.children || (r.children = []), r.children.push(d);
94
+ } else if (se(t)) {
95
+ const n = e[e.length - 1], s = e.join("/");
96
+ let d = (o = r.children) == null ? void 0 : o.find(
97
+ (h) => h.type === "folder" && h.name === n
98
+ );
99
+ d || (d = {
100
+ id: s,
101
+ name: n,
102
+ type: "folder",
103
+ children: []
104
+ }, r.children || (r.children = []), r.children.push(d));
105
+ for (const [h, u] of Object.entries(t._entries))
106
+ j(d, [...e, h], u);
107
+ } else if (de(t)) {
108
+ const n = e[e.length - 1], d = {
109
+ id: e.join("/"),
110
+ name: n,
111
+ type: "variants",
112
+ children: []
113
+ };
114
+ r.children || (r.children = []), r.children.push(d);
115
+ for (const [h, u] of Object.entries(t._variants)) {
116
+ const g = [...e, h].join("/"), H = {
117
+ id: g,
118
+ name: h,
119
+ type: "component",
120
+ component: u._createDefinition(g, h)
121
+ };
122
+ d.children.push(H);
123
+ }
124
+ }
125
+ }
126
+ function V(r, e) {
127
+ if (e.length === 0)
128
+ return r;
129
+ let t = r;
130
+ for (const o of e) {
131
+ if (!t || !t.children)
132
+ return;
133
+ t = t.children.find((n) => n.name === o);
134
+ }
135
+ return t;
136
+ }
137
+ function ae(r) {
138
+ if (r.type === "component" && r.component)
139
+ return [r.component];
140
+ const e = [];
141
+ for (const t of r.children ?? [])
142
+ e.push(...ae(t));
143
+ return e;
144
+ }
145
+ class A {
146
+ constructor() {
147
+ l(this, "_fixtures", b(this, /* @__PURE__ */ new Map()));
148
+ /** Observable root of the fixture tree */
149
+ l(this, "root", R(this, (e) => {
150
+ const t = this._fixtures.read(e);
151
+ return E(t);
152
+ }));
153
+ }
154
+ /**
155
+ * Registers a fixture file.
156
+ * @param path The file path (e.g., 'components/Button.fixture.tsx')
157
+ * @param fixtureExport The exported fixture object
158
+ */
159
+ register(e, t) {
160
+ const o = new Map(this._fixtures.get());
161
+ o.set(e, t), this._fixtures.set(o, void 0);
162
+ }
163
+ /**
164
+ * Unregisters a fixture file.
165
+ * @param path The file path to remove
166
+ */
167
+ unregister(e) {
168
+ const t = new Map(this._fixtures.get());
169
+ t.delete(e) && this._fixtures.set(t, void 0);
170
+ }
171
+ /**
172
+ * Clears all registered fixtures.
173
+ */
174
+ clear() {
175
+ this._fixtures.set(/* @__PURE__ */ new Map(), void 0);
176
+ }
177
+ /**
178
+ * Gets a node by path.
179
+ */
180
+ getNode(e, t) {
181
+ const o = this.root.read(e);
182
+ return V(o, t);
183
+ }
184
+ /**
185
+ * Gets a component by path (non-reactive, for use in preview iframe).
186
+ * @param path Array of path segments (e.g., ['Button', 'Primary'])
187
+ */
188
+ getComponentByPath(e) {
189
+ const t = this._fixtures.get(), o = E(t), n = V(o, e);
190
+ return n == null ? void 0 : n.component;
191
+ }
192
+ }
193
+ var y = {}, L;
194
+ function he() {
195
+ if (L) return y;
196
+ L = 1;
197
+ var r = te;
198
+ if (process.env.NODE_ENV === "production")
199
+ y.createRoot = r.createRoot, y.hydrateRoot = r.hydrateRoot;
200
+ else {
201
+ var e = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
202
+ y.createRoot = function(t, o) {
203
+ e.usingClientEntryPoint = !0;
204
+ try {
205
+ return r.createRoot(t, o);
206
+ } finally {
207
+ e.usingClientEntryPoint = !1;
208
+ }
209
+ }, y.hydrateRoot = function(t, o, n) {
210
+ e.usingClientEntryPoint = !0;
211
+ try {
212
+ return r.hydrateRoot(t, o, n);
213
+ } finally {
214
+ e.usingClientEntryPoint = !1;
215
+ }
216
+ };
217
+ }
218
+ return y;
219
+ }
220
+ var pe = he();
221
+ function $(r) {
222
+ var e;
223
+ return {
224
+ id: r.id,
225
+ name: r.name,
226
+ type: r.type,
227
+ children: (e = r.children) == null ? void 0 : e.map($),
228
+ component: r.component
229
+ };
230
+ }
231
+ function k(r, e) {
232
+ const {
233
+ storageKey: t,
234
+ defaultValue: o,
235
+ serialize: n = JSON.stringify,
236
+ deserialize: s = JSON.parse
237
+ } = e;
238
+ let d = o;
239
+ try {
240
+ const f = localStorage.getItem(t);
241
+ f !== null && (d = s(f));
242
+ } catch {
243
+ }
244
+ const h = b(r, d), u = h.set.bind(h);
245
+ return h.set = (f, g) => {
246
+ try {
247
+ localStorage.setItem(t, n(f));
248
+ } catch {
249
+ }
250
+ u(f, g);
251
+ }, h;
252
+ }
253
+ class ue extends S({
254
+ registry: a.const()
255
+ }) {
256
+ constructor() {
257
+ super(...arguments);
258
+ l(this, "leftSidebarVisible", k(this, {
259
+ storageKey: "component-explorer:leftSidebarVisible",
260
+ defaultValue: !0
261
+ }));
262
+ l(this, "rightSidebarVisible", k(this, {
263
+ storageKey: "component-explorer:rightSidebarVisible",
264
+ defaultValue: !0
265
+ }));
266
+ l(this, "isDarkTheme", k(this, {
267
+ storageKey: "component-explorer:isDarkTheme",
268
+ defaultValue: !0
269
+ }));
270
+ l(this, "selectedNodeId", k(this, {
271
+ storageKey: "component-explorer:selectedNodeId",
272
+ defaultValue: void 0
273
+ }));
274
+ l(this, "expandedNodeIds", b(this, /* @__PURE__ */ new Set()));
275
+ /** The explorer's tree derived from the registry */
276
+ l(this, "tree", R(this, (t) => {
277
+ const o = this.props.registry.root.read(t);
278
+ return $(o);
279
+ }));
280
+ l(this, "selectedNode", R(this, (t) => {
281
+ const o = this.selectedNodeId.read(t);
282
+ if (!o) return;
283
+ const n = this.tree.read(t);
284
+ return this._findNode(n.children ?? [], o);
285
+ }));
286
+ /** List of preview rows to render based on current selection */
287
+ l(this, "selectedFixtures", R(this, (t) => {
288
+ const o = this.selectedNode.read(t);
289
+ return o ? this._collectPreviewRows(o, o.name) : [];
290
+ }));
291
+ l(this, "toggleLeftSidebar", () => {
292
+ this.leftSidebarVisible.set(!this.leftSidebarVisible.get(), void 0);
293
+ });
294
+ l(this, "toggleRightSidebar", () => {
295
+ this.rightSidebarVisible.set(!this.rightSidebarVisible.get(), void 0);
296
+ });
297
+ l(this, "toggleTheme", () => {
298
+ this.isDarkTheme.set(!this.isDarkTheme.get(), void 0);
299
+ });
300
+ l(this, "selectNode", (t) => {
301
+ this.selectedNodeId.set(t, void 0);
302
+ });
303
+ l(this, "toggleNodeExpanded", (t) => {
304
+ const o = this.expandedNodeIds.get(), n = new Set(o);
305
+ n.has(t) ? n.delete(t) : n.add(t), this.expandedNodeIds.set(n, void 0);
306
+ });
307
+ }
308
+ isNodeExpanded(t, o) {
309
+ return this.expandedNodeIds.read(o).has(t);
310
+ }
311
+ _findNode(t, o) {
312
+ for (const n of t) {
313
+ if (n.id === o) return n;
314
+ if (n.children) {
315
+ const s = this._findNode(n.children, o);
316
+ if (s) return s;
317
+ }
318
+ }
319
+ }
320
+ _collectPreviewRows(t, o) {
321
+ if (t.type === "component" && t.component)
322
+ return [{
323
+ type: "single",
324
+ fixture: {
325
+ id: t.id,
326
+ name: t.name,
327
+ path: o,
328
+ component: t.component
329
+ }
330
+ }];
331
+ if (t.type === "variants") {
332
+ const s = [];
333
+ for (const d of t.children ?? [])
334
+ d.type === "component" && d.component && s.push({
335
+ id: d.id,
336
+ name: d.name,
337
+ path: `${o} / ${d.name}`,
338
+ component: d.component
339
+ });
340
+ return s.length > 0 ? [{
341
+ type: "variants",
342
+ id: t.id,
343
+ name: t.name,
344
+ path: o,
345
+ fixtures: s
346
+ }] : [];
347
+ }
348
+ const n = [];
349
+ for (const s of t.children ?? []) {
350
+ const d = o ? `${o} / ${s.name}` : s.name;
351
+ n.push(...this._collectPreviewRows(s, d));
352
+ }
353
+ return n;
354
+ }
355
+ }
356
+ const c = {
357
+ container: {
358
+ display: "flex",
359
+ flexDirection: "row",
360
+ height: "100%",
361
+ width: "100%",
362
+ fontFamily: "var(--vscode-font-family)",
363
+ fontSize: "var(--vscode-font-size)",
364
+ color: "var(--vscode-foreground)",
365
+ backgroundColor: "var(--vscode-editor-background)"
366
+ },
367
+ centerArea: {
368
+ display: "flex",
369
+ flexDirection: "column",
370
+ flex: 1,
371
+ overflow: "hidden"
372
+ },
373
+ titleBar: {
374
+ display: "flex",
375
+ alignItems: "center",
376
+ justifyContent: "space-between",
377
+ height: "35px",
378
+ minHeight: "35px",
379
+ padding: "0 10px",
380
+ backgroundColor: "var(--vscode-titleBar-activeBackground)",
381
+ color: "var(--vscode-titleBar-activeForeground)",
382
+ borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
383
+ },
384
+ titleBarSection: {
385
+ display: "flex",
386
+ alignItems: "center",
387
+ gap: "2px"
388
+ },
389
+ titleBarCenter: {
390
+ display: "flex",
391
+ alignItems: "center",
392
+ gap: "4px",
393
+ fontSize: "13px",
394
+ fontWeight: 400
395
+ },
396
+ titleBarButton: {
397
+ display: "flex",
398
+ alignItems: "center",
399
+ justifyContent: "center",
400
+ width: "28px",
401
+ height: "28px",
402
+ border: "none",
403
+ background: "transparent",
404
+ color: "var(--vscode-titleBar-activeForeground)",
405
+ cursor: "pointer",
406
+ borderRadius: "4px"
407
+ },
408
+ titleBarButtonHover: {
409
+ backgroundColor: "var(--vscode-toolbar-hoverBackground)"
410
+ },
411
+ titleBarButtonActive: {
412
+ backgroundColor: "var(--vscode-toolbar-activeBackground)",
413
+ color: "var(--vscode-focusBorder)"
414
+ },
415
+ sidebar: {
416
+ display: "flex",
417
+ flexDirection: "column",
418
+ width: "260px",
419
+ minWidth: "200px",
420
+ backgroundColor: "var(--vscode-sideBar-background)",
421
+ borderRight: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
422
+ },
423
+ sidebarRight: {
424
+ borderRight: "none",
425
+ borderLeft: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
426
+ },
427
+ sidebarHeader: {
428
+ display: "flex",
429
+ alignItems: "center",
430
+ height: "35px",
431
+ minHeight: "35px",
432
+ padding: "0 12px",
433
+ fontSize: "11px",
434
+ fontWeight: 700,
435
+ textTransform: "uppercase",
436
+ letterSpacing: "0.04em",
437
+ color: "var(--vscode-titleBar-activeForeground)",
438
+ backgroundColor: "var(--vscode-titleBar-activeBackground)",
439
+ borderBottom: "1px solid var(--vscode-titleBar-border, var(--vscode-panel-border))"
440
+ },
441
+ sidebarContent: {
442
+ flex: 1,
443
+ overflow: "auto",
444
+ padding: "4px 0"
445
+ },
446
+ treeItem: {
447
+ display: "flex",
448
+ alignItems: "center",
449
+ height: "22px",
450
+ paddingRight: "8px",
451
+ cursor: "pointer",
452
+ userSelect: "none"
453
+ },
454
+ treeItemSelected: {
455
+ backgroundColor: "var(--vscode-list-activeSelectionBackground)",
456
+ color: "var(--vscode-list-activeSelectionForeground)"
457
+ },
458
+ treeItemHover: {
459
+ backgroundColor: "var(--vscode-list-hoverBackground)"
460
+ },
461
+ treeItemChevron: {
462
+ display: "flex",
463
+ alignItems: "center",
464
+ justifyContent: "center",
465
+ width: "16px",
466
+ height: "16px",
467
+ color: "var(--vscode-foreground)",
468
+ opacity: 0.8,
469
+ cursor: "pointer"
470
+ },
471
+ treeItemChevronPlaceholder: {
472
+ width: "16px"
473
+ },
474
+ treeItemIcon: {
475
+ display: "flex",
476
+ alignItems: "center",
477
+ justifyContent: "center",
478
+ width: "16px",
479
+ height: "16px",
480
+ marginRight: "4px"
481
+ },
482
+ treeItemLabel: {
483
+ flex: 1,
484
+ overflow: "hidden",
485
+ textOverflow: "ellipsis",
486
+ whiteSpace: "nowrap",
487
+ fontSize: "13px"
488
+ },
489
+ treeItemCount: {
490
+ marginLeft: "8px",
491
+ fontSize: "11px",
492
+ color: "var(--vscode-descriptionForeground)"
493
+ },
494
+ mainContent: {
495
+ flex: 1,
496
+ display: "flex",
497
+ alignItems: "center",
498
+ justifyContent: "center",
499
+ backgroundColor: "var(--vscode-editor-background)",
500
+ color: "var(--vscode-descriptionForeground)",
501
+ fontSize: "14px"
502
+ },
503
+ propertiesPanel: {
504
+ padding: "12px"
505
+ },
506
+ propertyRow: {
507
+ marginBottom: "12px"
508
+ },
509
+ propertyLabel: {
510
+ fontSize: "12px",
511
+ color: "var(--vscode-foreground)",
512
+ marginBottom: "4px"
513
+ },
514
+ propertyDescription: {
515
+ fontSize: "11px",
516
+ color: "var(--vscode-descriptionForeground)",
517
+ marginTop: "2px"
518
+ },
519
+ propertyInput: {
520
+ width: "100%",
521
+ height: "26px",
522
+ padding: "0 8px",
523
+ fontSize: "13px",
524
+ color: "var(--vscode-input-foreground)",
525
+ backgroundColor: "var(--vscode-input-background)",
526
+ border: "1px solid var(--vscode-input-border, transparent)",
527
+ borderRadius: "2px",
528
+ outline: "none",
529
+ boxSizing: "border-box"
530
+ },
531
+ propertySelect: {
532
+ width: "100%",
533
+ height: "26px",
534
+ padding: "0 8px",
535
+ fontSize: "13px",
536
+ color: "var(--vscode-dropdown-foreground)",
537
+ backgroundColor: "var(--vscode-dropdown-background)",
538
+ border: "1px solid var(--vscode-dropdown-border)",
539
+ borderRadius: "2px",
540
+ outline: "none",
541
+ boxSizing: "border-box",
542
+ cursor: "pointer"
543
+ }
544
+ };
545
+ function T(...r) {
546
+ return Object.assign({}, ...r.filter(Boolean));
547
+ }
548
+ class fe extends S({
549
+ active: a()
550
+ }) {
551
+ constructor() {
552
+ super(...arguments);
553
+ l(this, "isHovered", b(this, !1));
554
+ l(this, "setHovered", (t) => {
555
+ this.isHovered.set(t, void 0);
556
+ });
557
+ }
558
+ get active() {
559
+ return this.props.active;
560
+ }
561
+ }
562
+ const z = w(
563
+ fe,
564
+ {
565
+ onClick: a.const(),
566
+ title: a.const(),
567
+ children: a.const()
568
+ },
569
+ (r, e, t) => {
570
+ const o = e.isHovered.read(r), n = e.active.read(r), s = T(
571
+ c.titleBarButton,
572
+ o && !n && c.titleBarButtonHover,
573
+ n && c.titleBarButtonActive
574
+ );
575
+ return /* @__PURE__ */ i(
576
+ "button",
577
+ {
578
+ style: s,
579
+ onClick: t.onClick,
580
+ title: t.title,
581
+ onMouseEnter: () => e.setHovered(!0),
582
+ onMouseLeave: () => e.setHovered(!1),
583
+ children: t.children
584
+ }
585
+ );
586
+ }
587
+ ), ve = ({ style: r }) => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ i("path", { d: "M5.7 13.7L5 13l4.6-4.6L5 3.7l.7-.7 5.3 5.4-5.3 5.3z" }) }), ge = ({ style: r }) => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ i("path", { d: "M11 5.5L6 10.5L5.3 9.8L9.6 5.5L5.3 1.2L6 0.5L11 5.5z", transform: "rotate(90 8 5.5)" }) }), me = ({ style: r }) => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ i("path", { d: "M14.5 2H9l-.35.15-.65.64-.65-.64L7 2H1.5l-.5.5v10l.5.5H7l.35-.15.65-.64.65.64.35.15h5.5l.5-.5v-10l-.5-.5zm-7 10H2V3h5v.86L5.85 5l1.15 1.14V10l-1.15-1.14L7 7.72V12zm6 0H8V7.72l1.15 1.14L8 10V6.14L9.15 5 8 3.86V3h5v9z" }) }), be = ({ style: r }) => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", style: r, children: /* @__PURE__ */ i("path", { d: "M14.5 3H7.71l-.85-.85L6.5 2h-5l-.5.5v11l.5.5h13l.5-.5v-10l-.5-.5zm-.5 10H2V6h12v7zm0-8H2V3h4.29l.85.85.36.15H14v1z" }) }), xe = () => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ i("path", { d: "M2 2v12h12V2H2zm11 11H6V3h7v10zM3 3h2v10H3V3z" }) }), ye = () => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ i("path", { d: "M2 2v12h12V2H2zm6 11V3h5v10H8zM3 3h4v10H3V3z" }) }), _e = () => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ i("path", { d: "M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6zm0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13zm8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5zM3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8zm10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0zm-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0zm9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707zM4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708z" }) }), Ce = () => /* @__PURE__ */ i("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ i("path", { d: "M6 .278a.768.768 0 0 1 .08.858 7.208 7.208 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277.527 0 1.04-.055 1.533-.16a.787.787 0 0 1 .81.316.733.733 0 0 1-.031.893A8.349 8.349 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.752.752 0 0 1 6 .278z" }) }), Se = x(
588
+ {
589
+ model: a.const()
590
+ },
591
+ (r, e) => {
592
+ const t = e.model, o = t.leftSidebarVisible.read(r), n = t.rightSidebarVisible.read(r), s = t.isDarkTheme.read(r), d = t.selectedNode.read(r);
593
+ return /* @__PURE__ */ p("div", { style: c.titleBar, children: [
594
+ /* @__PURE__ */ i("div", { style: c.titleBarSection, children: /* @__PURE__ */ i(
595
+ z,
596
+ {
597
+ active: o,
598
+ onClick: t.toggleLeftSidebar,
599
+ title: "Toggle left sidebar",
600
+ children: /* @__PURE__ */ i(xe, {})
601
+ }
602
+ ) }),
603
+ /* @__PURE__ */ i("div", { style: c.titleBarCenter, children: d ? /* @__PURE__ */ p(B, { children: [
604
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "<" }),
605
+ /* @__PURE__ */ i("span", { children: d.name }),
606
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-textLink-foreground)" }, children: "/>" })
607
+ ] }) : /* @__PURE__ */ i("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: "No component selected" }) }),
608
+ /* @__PURE__ */ p("div", { style: c.titleBarSection, children: [
609
+ /* @__PURE__ */ i(
610
+ z,
611
+ {
612
+ active: !1,
613
+ onClick: t.toggleTheme,
614
+ title: s ? "Switch to light theme" : "Switch to dark theme",
615
+ children: s ? /* @__PURE__ */ i(_e, {}) : /* @__PURE__ */ i(Ce, {})
616
+ }
617
+ ),
618
+ /* @__PURE__ */ i(
619
+ z,
620
+ {
621
+ active: n,
622
+ onClick: t.toggleRightSidebar,
623
+ title: "Toggle right sidebar",
624
+ children: /* @__PURE__ */ i(ye, {})
625
+ }
626
+ )
627
+ ] })
628
+ ] });
629
+ }
630
+ ), W = x(
631
+ {
632
+ model: a.const(),
633
+ nodes: a.const(),
634
+ depth: a.const()
635
+ },
636
+ (r, e) => /* @__PURE__ */ i(B, { children: e.nodes.map((t) => /* @__PURE__ */ i(Ie, { model: e.model, node: t, depth: e.depth }, t.id)) })
637
+ );
638
+ class we extends S({
639
+ model: a.const(),
640
+ node: a.const(),
641
+ depth: a.const()
642
+ }) {
643
+ constructor() {
644
+ super(...arguments);
645
+ l(this, "isHovered", b(this, !1));
646
+ l(this, "setHovered", (t) => {
647
+ this.isHovered.set(t, void 0);
648
+ });
649
+ l(this, "handleClick", () => {
650
+ this.props.model.selectNode(this.props.node.id);
651
+ });
652
+ l(this, "handleDoubleClick", () => {
653
+ this._hasChildren && this.props.model.toggleNodeExpanded(this.props.node.id);
654
+ });
655
+ l(this, "handleChevronClick", (t) => {
656
+ t.stopPropagation(), this.props.model.toggleNodeExpanded(this.props.node.id);
657
+ });
658
+ }
659
+ // Expose props for render function
660
+ get explorerModel() {
661
+ return this.props.model;
662
+ }
663
+ get treeNode() {
664
+ return this.props.node;
665
+ }
666
+ get treeDepth() {
667
+ return this.props.depth;
668
+ }
669
+ get _hasChildren() {
670
+ return !!(this.props.node.children && this.props.node.children.length > 0);
671
+ }
672
+ }
673
+ const Ie = w(we, {}, (r, e) => {
674
+ const t = e.explorerModel, o = e.treeNode, n = e.treeDepth, s = !!(o.children && o.children.length > 0), d = s ? t.isNodeExpanded(o.id, r) : !1, u = t.selectedNodeId.read(r) === o.id, f = e.isHovered.read(r), g = T(
675
+ c.treeItem,
676
+ { paddingLeft: `${8 + n * 12}px` },
677
+ u && c.treeItemSelected,
678
+ !u && f && c.treeItemHover
679
+ );
680
+ return /* @__PURE__ */ p(B, { children: [
681
+ /* @__PURE__ */ p(
682
+ "div",
683
+ {
684
+ style: g,
685
+ onClick: e.handleClick,
686
+ onDoubleClick: e.handleDoubleClick,
687
+ onMouseEnter: () => e.setHovered(!0),
688
+ onMouseLeave: () => e.setHovered(!1),
689
+ children: [
690
+ s ? /* @__PURE__ */ i("div", { style: c.treeItemChevron, onClick: e.handleChevronClick, children: d ? /* @__PURE__ */ i(ge, {}) : /* @__PURE__ */ i(ve, {}) }) : /* @__PURE__ */ i("div", { style: c.treeItemChevronPlaceholder }),
691
+ /* @__PURE__ */ i("div", { style: c.treeItemIcon, children: o.type === "folder" ? /* @__PURE__ */ i(be, { style: { color: "var(--vscode-symbolIcon-folderForeground)" } }) : /* @__PURE__ */ i(me, { style: { color: "#deb45b" } }) }),
692
+ /* @__PURE__ */ i("span", { style: c.treeItemLabel, children: o.name }),
693
+ s && /* @__PURE__ */ i("span", { style: c.treeItemCount, children: o.children.length })
694
+ ]
695
+ }
696
+ ),
697
+ s && d && /* @__PURE__ */ i(W, { model: t, nodes: o.children, depth: n + 1 })
698
+ ] });
699
+ }), ke = x(
700
+ {
701
+ model: a.const()
702
+ },
703
+ (r, e) => {
704
+ const t = e.model.tree.read(r);
705
+ return /* @__PURE__ */ p("div", { style: c.sidebar, children: [
706
+ /* @__PURE__ */ i("div", { style: c.sidebarHeader, children: "Explorer" }),
707
+ /* @__PURE__ */ i("div", { style: c.sidebarContent, children: /* @__PURE__ */ i(W, { model: e.model, nodes: t.children ?? [], depth: 0 }) })
708
+ ] });
709
+ }
710
+ );
711
+ class Re extends S({}) {
712
+ constructor() {
713
+ super(...arguments);
714
+ l(this, "checked", b(this, !1));
715
+ l(this, "toggle", () => {
716
+ this.checked.set(!this.checked.get(), void 0);
717
+ });
718
+ }
719
+ }
720
+ const He = w(Re, {}, (r, e) => {
721
+ const t = e.checked.read(r), o = {
722
+ position: "relative",
723
+ width: "36px",
724
+ height: "18px",
725
+ backgroundColor: t ? "var(--vscode-button-background)" : "var(--vscode-input-background)",
726
+ borderRadius: "9px",
727
+ cursor: "pointer",
728
+ transition: "background-color 0.2s",
729
+ border: "1px solid var(--vscode-input-border, transparent)"
730
+ }, n = {
731
+ position: "absolute",
732
+ top: "2px",
733
+ left: t ? "18px" : "2px",
734
+ width: "12px",
735
+ height: "12px",
736
+ backgroundColor: "var(--vscode-foreground)",
737
+ borderRadius: "50%",
738
+ transition: "left 0.2s"
739
+ };
740
+ return /* @__PURE__ */ i("div", { style: o, onClick: e.toggle, children: /* @__PURE__ */ i("div", { style: n }) });
741
+ }), ze = x(
742
+ {
743
+ node: a.const()
744
+ },
745
+ (r, e) => e.node.type !== "component" ? /* @__PURE__ */ i("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component (not a folder) to view its properties" }) : /* @__PURE__ */ p("div", { style: c.propertiesPanel, children: [
746
+ /* @__PURE__ */ p("div", { style: c.propertyRow, children: [
747
+ /* @__PURE__ */ p("div", { style: c.propertyLabel, children: [
748
+ "children",
749
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : string" })
750
+ ] }),
751
+ /* @__PURE__ */ i(
752
+ "input",
753
+ {
754
+ type: "text",
755
+ style: c.propertyInput,
756
+ defaultValue: "Click me",
757
+ placeholder: "Enter text..."
758
+ }
759
+ ),
760
+ /* @__PURE__ */ i("div", { style: c.propertyDescription, children: "Button text content" })
761
+ ] }),
762
+ /* @__PURE__ */ p("div", { style: c.propertyRow, children: [
763
+ /* @__PURE__ */ p("div", { style: c.propertyLabel, children: [
764
+ "variant",
765
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
766
+ ] }),
767
+ /* @__PURE__ */ p("select", { style: c.propertySelect, defaultValue: "default", children: [
768
+ /* @__PURE__ */ i("option", { value: "default", children: "default" }),
769
+ /* @__PURE__ */ i("option", { value: "primary", children: "primary" }),
770
+ /* @__PURE__ */ i("option", { value: "secondary", children: "secondary" }),
771
+ /* @__PURE__ */ i("option", { value: "destructive", children: "destructive" })
772
+ ] }),
773
+ /* @__PURE__ */ i("div", { style: c.propertyDescription, children: "Visual style variant" })
774
+ ] }),
775
+ /* @__PURE__ */ p("div", { style: c.propertyRow, children: [
776
+ /* @__PURE__ */ p("div", { style: c.propertyLabel, children: [
777
+ "size",
778
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : select" })
779
+ ] }),
780
+ /* @__PURE__ */ p("select", { style: c.propertySelect, defaultValue: "default", children: [
781
+ /* @__PURE__ */ i("option", { value: "sm", children: "sm" }),
782
+ /* @__PURE__ */ i("option", { value: "default", children: "default" }),
783
+ /* @__PURE__ */ i("option", { value: "lg", children: "lg" })
784
+ ] }),
785
+ /* @__PURE__ */ i("div", { style: c.propertyDescription, children: "Button size" })
786
+ ] }),
787
+ /* @__PURE__ */ p("div", { style: c.propertyRow, children: [
788
+ /* @__PURE__ */ p("div", { style: c.propertyLabel, children: [
789
+ "disabled",
790
+ /* @__PURE__ */ i("span", { style: { color: "var(--vscode-descriptionForeground)" }, children: " : boolean" })
791
+ ] }),
792
+ /* @__PURE__ */ i(He, {}),
793
+ /* @__PURE__ */ i("div", { style: c.propertyDescription, children: "Disable the button" })
794
+ ] })
795
+ ] })
796
+ ), Be = x(
797
+ {
798
+ selectedNode: a.const()
799
+ },
800
+ (r, e) => /* @__PURE__ */ p("div", { style: T(c.sidebar, c.sidebarRight), children: [
801
+ /* @__PURE__ */ p("div", { style: c.sidebarHeader, children: [
802
+ /* @__PURE__ */ i("span", { style: { marginRight: "6px", color: "var(--vscode-textLink-foreground)" }, children: "</>" }),
803
+ "Props"
804
+ ] }),
805
+ /* @__PURE__ */ i("div", { style: c.sidebarContent, children: e.selectedNode ? /* @__PURE__ */ i(ze, { node: e.selectedNode }) : /* @__PURE__ */ i("div", { style: { padding: "12px", color: "var(--vscode-descriptionForeground)", fontSize: "12px" }, children: "Select a component to view its properties" }) })
806
+ ] })
807
+ );
808
+ class Te extends S({
809
+ fixture: a.const(),
810
+ onSizeChange: a.const(),
811
+ compact: a.const()
812
+ }) {
813
+ constructor() {
814
+ super(...arguments);
815
+ l(this, "_containerRef", null);
816
+ l(this, "_shadowRoot", null);
817
+ l(this, "_renderContainer", null);
818
+ l(this, "_disposable", null);
819
+ l(this, "_resizeObserver", null);
820
+ l(this, "measuredWidth", b(this, void 0));
821
+ l(this, "measuredHeight", b(this, void 0));
822
+ l(this, "setContainerRef", (t) => {
823
+ if (t === this._containerRef || (this._cleanup(), this._containerRef = t, !t)) return;
824
+ const o = this.fixture.component;
825
+ o.isolation === "shadow-dom" ? this._renderInShadowDom(t, o) : this._renderDirect(t, o);
826
+ const n = this._renderContainer ?? t;
827
+ this._resizeObserver = new ResizeObserver((s) => {
828
+ for (const d of s) {
829
+ const { width: h, height: u } = d.contentRect;
830
+ if (u > 0) {
831
+ const f = Math.round(h), g = Math.round(u);
832
+ this.measuredWidth.set(f, void 0), this.measuredHeight.set(g, void 0), this.onSizeChange(this.fixture.id, f, g);
833
+ }
834
+ }
835
+ }), this._resizeObserver.observe(n);
836
+ });
837
+ }
838
+ get fixture() {
839
+ return this.props.fixture;
840
+ }
841
+ get onSizeChange() {
842
+ return this.props.onSizeChange;
843
+ }
844
+ get compact() {
845
+ return this.props.compact ?? !1;
846
+ }
847
+ _renderInShadowDom(t, o) {
848
+ if (t.shadowRoot) {
849
+ for (this._shadowRoot = t.shadowRoot; this._shadowRoot.firstChild; )
850
+ this._shadowRoot.removeChild(this._shadowRoot.firstChild);
851
+ this._shadowRoot.adoptedStyleSheets = [];
852
+ } else
853
+ this._shadowRoot = t.attachShadow({ mode: "open" });
854
+ if (o.styles)
855
+ for (const d of o.styles)
856
+ if (d.type === "css") {
857
+ const h = document.createElement("style");
858
+ h.textContent = d.content, this._shadowRoot.appendChild(h);
859
+ } else if (d.type === "url") {
860
+ const h = document.createElement("link");
861
+ h.rel = "stylesheet", h.href = d.href, this._shadowRoot.appendChild(h);
862
+ } else d.type === "adopted" && (this._shadowRoot.adoptedStyleSheets = [
863
+ ...this._shadowRoot.adoptedStyleSheets,
864
+ d.sheet
865
+ ]);
866
+ const n = document.createElement("div");
867
+ n.style.display = "inline-block", this._renderContainer = n, this._shadowRoot.appendChild(n);
868
+ const s = this._getDefaultProps(o);
869
+ this._disposable = o.render(n, s);
870
+ }
871
+ _renderDirect(t, o) {
872
+ this._renderContainer = t;
873
+ const n = this._getDefaultProps(o);
874
+ this._disposable = o.render(t, n);
875
+ }
876
+ _getDefaultProps(t) {
877
+ const o = {};
878
+ for (const n of t.properties)
879
+ o[n.name] = n.defaultValue;
880
+ return o;
881
+ }
882
+ _cleanup() {
883
+ var t;
884
+ this._disposable && (typeof this._disposable == "function" ? this._disposable() : typeof this._disposable.dispose == "function" && this._disposable.dispose()), this._disposable = null, (t = this._resizeObserver) == null || t.disconnect(), this._resizeObserver = null, this._shadowRoot = null, this._renderContainer = null;
885
+ }
886
+ dispose() {
887
+ this._cleanup();
888
+ }
889
+ }
890
+ const K = w(
891
+ Te,
892
+ {},
893
+ (r, e) => {
894
+ const t = e.fixture, o = t.component, n = o.displayMode, s = e.measuredWidth.read(r), d = e.measuredHeight.read(r), h = e.compact;
895
+ let u;
896
+ if (n.type === "page") {
897
+ const Z = n.viewports[0], N = ie(Z);
898
+ u = {
899
+ width: N.width,
900
+ height: N.height,
901
+ overflow: "auto"
902
+ };
903
+ } else
904
+ u = {
905
+ display: "inline-block"
906
+ };
907
+ const f = s && d ? `${s} × ${d}` : "", g = h ? C.wrapperCompact : C.wrapper, H = h ? C.nameCompact : C.name;
908
+ return /* @__PURE__ */ p("div", { style: g, children: [
909
+ /* @__PURE__ */ p("div", { style: C.labelRow, children: [
910
+ /* @__PURE__ */ i("span", { style: H, children: t.name }),
911
+ !h && f && /* @__PURE__ */ i("span", { style: C.dimensions, children: f })
912
+ ] }),
913
+ /* @__PURE__ */ i("div", { style: Le(o.background), children: /* @__PURE__ */ i("div", { ref: e.setContainerRef, style: u }) })
914
+ ] });
915
+ }
916
+ ), _ = 8;
917
+ function G(r, e) {
918
+ return `
919
+ linear-gradient(45deg, ${e} 25%, transparent 25%),
920
+ linear-gradient(-45deg, ${e} 25%, transparent 25%),
921
+ linear-gradient(45deg, transparent 75%, ${e} 75%),
922
+ linear-gradient(-45deg, transparent 75%, ${e} 75%)
923
+ `;
924
+ }
925
+ const Ne = {
926
+ backgroundColor: "#ffffff",
927
+ backgroundImage: G("#ffffff", "#e5e5e5")
928
+ }, Ee = {
929
+ backgroundColor: "#1e1e1e",
930
+ backgroundImage: G("#1e1e1e", "#2d2d2d")
931
+ }, Ve = {
932
+ display: "inline-block",
933
+ padding: "12px",
934
+ borderRadius: "4px",
935
+ backgroundSize: `${_ * 2}px ${_ * 2}px`,
936
+ backgroundPosition: `0 0, 0 ${_}px, ${_}px -${_}px, -${_}px 0`,
937
+ boxShadow: "0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08)"
938
+ };
939
+ function Le(r) {
940
+ const e = r === "dark" ? Ee : Ne;
941
+ return {
942
+ ...Ve,
943
+ backgroundColor: e.backgroundColor,
944
+ backgroundImage: e.backgroundImage
945
+ };
946
+ }
947
+ const C = {
948
+ wrapper: {
949
+ marginBottom: "32px"
950
+ },
951
+ wrapperCompact: {
952
+ marginBottom: "0"
953
+ },
954
+ labelRow: {
955
+ display: "flex",
956
+ alignItems: "baseline",
957
+ gap: "8px",
958
+ marginBottom: "8px"
959
+ },
960
+ name: {
961
+ fontSize: "12px",
962
+ fontWeight: 500,
963
+ color: "var(--vscode-foreground)"
964
+ },
965
+ nameCompact: {
966
+ fontSize: "11px",
967
+ fontWeight: 500,
968
+ color: "var(--vscode-descriptionForeground)"
969
+ },
970
+ dimensions: {
971
+ fontSize: "11px",
972
+ color: "var(--vscode-descriptionForeground)",
973
+ fontFamily: "var(--vscode-editor-font-family, monospace)"
974
+ }
975
+ }, J = "component-explorer:fixtureSizes", O = 500;
976
+ let m = null;
977
+ function q() {
978
+ if (m !== null) return m;
979
+ try {
980
+ const r = localStorage.getItem(J);
981
+ if (r)
982
+ return m = JSON.parse(r), m;
983
+ } catch {
984
+ }
985
+ return m = {}, m;
986
+ }
987
+ function Oe() {
988
+ if (m !== null)
989
+ try {
990
+ const r = Object.entries(m);
991
+ r.length > O && (m = Object.fromEntries(r.slice(-O))), localStorage.setItem(J, JSON.stringify(m));
992
+ } catch {
993
+ }
994
+ }
995
+ function Me(r, e, t) {
996
+ const o = q();
997
+ o[r] = { width: e, height: t }, Oe();
998
+ }
999
+ function Fe() {
1000
+ const r = q(), e = /* @__PURE__ */ new Map();
1001
+ for (const [t, o] of Object.entries(r))
1002
+ e.set(t, o.height);
1003
+ return e;
1004
+ }
1005
+ const De = 280, Y = "component-explorer:scrollPositions", M = 100;
1006
+ function U() {
1007
+ try {
1008
+ const r = localStorage.getItem(Y);
1009
+ if (r) return JSON.parse(r);
1010
+ } catch {
1011
+ }
1012
+ return {};
1013
+ }
1014
+ function Pe(r, e) {
1015
+ try {
1016
+ const t = U();
1017
+ t[r] = e;
1018
+ const o = Object.entries(t), n = o.length > M ? Object.fromEntries(o.slice(-M)) : t;
1019
+ localStorage.setItem(Y, JSON.stringify(n));
1020
+ } catch {
1021
+ }
1022
+ }
1023
+ function je(r) {
1024
+ return U()[r] ?? 0;
1025
+ }
1026
+ class Ae extends S({
1027
+ model: a.const()
1028
+ }) {
1029
+ constructor() {
1030
+ super(...arguments);
1031
+ l(this, "_visibleIds", b(this, /* @__PURE__ */ new Set()));
1032
+ // Pre-load cached heights from localStorage for accurate initial render
1033
+ l(this, "_itemHeights", b(this, Fe()));
1034
+ l(this, "_intersectionObserver", null);
1035
+ l(this, "_scrollContainerRef", null);
1036
+ l(this, "_pendingObservations", /* @__PURE__ */ new Map());
1037
+ l(this, "_currentNodeId");
1038
+ l(this, "_scrollSaveTimeout", null);
1039
+ l(this, "setScrollContainerRef", (t) => {
1040
+ this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), this._scrollContainerRef = t, this._setupIntersectionObserver(), t && (t.addEventListener("scroll", this._handleScroll, { passive: !0 }), this._restoreScrollPosition());
1041
+ });
1042
+ l(this, "_handleScroll", () => {
1043
+ !this._scrollContainerRef || !this._currentNodeId || (this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout), this._scrollSaveTimeout = setTimeout(() => {
1044
+ this._scrollContainerRef && this._currentNodeId && Pe(this._currentNodeId, this._scrollContainerRef.scrollTop);
1045
+ }, 150));
1046
+ });
1047
+ l(this, "observeElement", (t, o) => {
1048
+ t && (this._intersectionObserver ? (t.setAttribute("data-fixture-id", o), this._intersectionObserver.observe(t)) : this._pendingObservations.set(t, o));
1049
+ });
1050
+ l(this, "handleSizeChange", (t, o, n) => {
1051
+ const s = this._itemHeights.get();
1052
+ if (s.get(t) !== n) {
1053
+ const d = new Map(s);
1054
+ d.set(t, n), this._itemHeights.set(d, void 0);
1055
+ }
1056
+ Me(t, o, n);
1057
+ });
1058
+ l(this, "getItemHeight", (t) => this._itemHeights.get().get(t) ?? De);
1059
+ }
1060
+ get explorerModel() {
1061
+ return this.props.model;
1062
+ }
1063
+ get visibleIds() {
1064
+ return this._visibleIds;
1065
+ }
1066
+ get itemHeights() {
1067
+ return this._itemHeights;
1068
+ }
1069
+ /** Called when selection changes to restore/reset scroll position */
1070
+ updateForSelection(t) {
1071
+ this._currentNodeId !== t && (this._currentNodeId = t, this._restoreScrollPosition());
1072
+ }
1073
+ _restoreScrollPosition() {
1074
+ if (!this._scrollContainerRef || !this._currentNodeId) return;
1075
+ const t = je(this._currentNodeId);
1076
+ requestAnimationFrame(() => {
1077
+ this._scrollContainerRef && (this._scrollContainerRef.scrollTop = t);
1078
+ });
1079
+ }
1080
+ _setupIntersectionObserver() {
1081
+ var t;
1082
+ if ((t = this._intersectionObserver) == null || t.disconnect(), !!this._scrollContainerRef) {
1083
+ this._intersectionObserver = new IntersectionObserver(
1084
+ (o) => {
1085
+ const n = new Set(this._visibleIds.get());
1086
+ for (const s of o) {
1087
+ const d = s.target.getAttribute("data-fixture-id");
1088
+ d && (s.isIntersecting ? n.add(d) : n.delete(d));
1089
+ }
1090
+ this._visibleIds.set(n, void 0);
1091
+ },
1092
+ {
1093
+ root: this._scrollContainerRef,
1094
+ rootMargin: "200px 0px",
1095
+ // Pre-render items 200px before they come into view
1096
+ threshold: 0
1097
+ }
1098
+ );
1099
+ for (const [o, n] of this._pendingObservations)
1100
+ o.setAttribute("data-fixture-id", n), this._intersectionObserver.observe(o);
1101
+ this._pendingObservations.clear();
1102
+ }
1103
+ }
1104
+ dispose() {
1105
+ var t;
1106
+ (t = this._intersectionObserver) == null || t.disconnect(), this._scrollContainerRef && this._scrollContainerRef.removeEventListener("scroll", this._handleScroll), this._scrollSaveTimeout && clearTimeout(this._scrollSaveTimeout);
1107
+ }
1108
+ }
1109
+ const $e = w(
1110
+ Ae,
1111
+ {},
1112
+ (r, e) => {
1113
+ const t = e.explorerModel.selectedFixtures.read(r), o = e.visibleIds.read(r), n = e.explorerModel.selectedNodeId.read(r);
1114
+ return e.updateForSelection(n), t.length === 0 ? /* @__PURE__ */ i("div", { style: v.emptyState, children: /* @__PURE__ */ i("span", { style: v.emptyText, children: "Select a component or folder to preview" }) }) : /* @__PURE__ */ i("div", { ref: e.setScrollContainerRef, style: v.scrollContainer, children: /* @__PURE__ */ i("div", { style: v.content, children: t.map((s) => s.type === "single" ? /* @__PURE__ */ i(
1115
+ We,
1116
+ {
1117
+ fixture: s.fixture,
1118
+ isVisible: o.has(s.fixture.id),
1119
+ estimatedHeight: e.getItemHeight(s.fixture.id),
1120
+ onSizeChange: e.handleSizeChange,
1121
+ observeElement: (d) => e.observeElement(d, s.fixture.id)
1122
+ },
1123
+ s.fixture.id
1124
+ ) : /* @__PURE__ */ i(
1125
+ Ke,
1126
+ {
1127
+ row: s,
1128
+ visibleIds: o,
1129
+ getItemHeight: e.getItemHeight,
1130
+ onSizeChange: e.handleSizeChange,
1131
+ observeElement: e.observeElement
1132
+ },
1133
+ s.id
1134
+ )) }) });
1135
+ }
1136
+ ), We = x(
1137
+ {
1138
+ fixture: a.const(),
1139
+ isVisible: a(),
1140
+ estimatedHeight: a(),
1141
+ onSizeChange: a.const(),
1142
+ observeElement: a.const()
1143
+ },
1144
+ (r, e) => {
1145
+ const t = e.isVisible.read(r), o = e.estimatedHeight.read(r);
1146
+ return /* @__PURE__ */ i("div", { ref: e.observeElement, style: { minHeight: t ? void 0 : o }, children: t ? /* @__PURE__ */ i(
1147
+ K,
1148
+ {
1149
+ fixture: e.fixture,
1150
+ onSizeChange: e.onSizeChange,
1151
+ compact: !1
1152
+ }
1153
+ ) : /* @__PURE__ */ i("div", { style: { ...v.placeholder, height: o }, children: /* @__PURE__ */ i("span", { style: v.placeholderText, children: e.fixture.name }) }) });
1154
+ }
1155
+ ), Ke = x(
1156
+ {
1157
+ row: a.const(),
1158
+ visibleIds: a(),
1159
+ getItemHeight: a.const(),
1160
+ onSizeChange: a.const(),
1161
+ observeElement: a.const()
1162
+ },
1163
+ (r, e) => {
1164
+ const t = e.visibleIds.read(r), o = e.row;
1165
+ return /* @__PURE__ */ p("div", { style: v.variantsContainer, children: [
1166
+ /* @__PURE__ */ i("div", { style: v.variantsHeader, children: /* @__PURE__ */ i("span", { style: v.variantsTitle, children: o.path }) }),
1167
+ /* @__PURE__ */ i("div", { style: v.variantsContent, children: o.fixtures.map((n) => /* @__PURE__ */ i(
1168
+ Ge,
1169
+ {
1170
+ fixture: n,
1171
+ isVisible: t.has(n.id),
1172
+ estimatedHeight: e.getItemHeight(n.id),
1173
+ onSizeChange: e.onSizeChange,
1174
+ observeElement: (s) => e.observeElement(s, n.id)
1175
+ },
1176
+ n.id
1177
+ )) })
1178
+ ] });
1179
+ }
1180
+ ), Ge = x(
1181
+ {
1182
+ fixture: a.const(),
1183
+ isVisible: a(),
1184
+ estimatedHeight: a(),
1185
+ onSizeChange: a.const(),
1186
+ observeElement: a.const()
1187
+ },
1188
+ (r, e) => {
1189
+ const t = e.isVisible.read(r), o = e.estimatedHeight.read(r);
1190
+ return /* @__PURE__ */ i("div", { ref: e.observeElement, style: v.variantItem, children: t ? /* @__PURE__ */ i(
1191
+ K,
1192
+ {
1193
+ fixture: e.fixture,
1194
+ onSizeChange: e.onSizeChange,
1195
+ compact: !0
1196
+ }
1197
+ ) : /* @__PURE__ */ i("div", { style: { ...v.variantPlaceholder, height: o }, children: /* @__PURE__ */ i("span", { style: v.placeholderText, children: e.fixture.name }) }) });
1198
+ }
1199
+ ), v = {
1200
+ scrollContainer: {
1201
+ flex: 1,
1202
+ overflow: "auto",
1203
+ backgroundColor: "var(--vscode-editor-background)"
1204
+ },
1205
+ content: {
1206
+ padding: "32px"
1207
+ },
1208
+ emptyState: {
1209
+ flex: 1,
1210
+ display: "flex",
1211
+ alignItems: "center",
1212
+ justifyContent: "center",
1213
+ backgroundColor: "var(--vscode-editor-background)"
1214
+ },
1215
+ emptyText: {
1216
+ color: "var(--vscode-descriptionForeground)",
1217
+ fontSize: "14px"
1218
+ },
1219
+ placeholder: {
1220
+ display: "flex",
1221
+ alignItems: "center",
1222
+ justifyContent: "center",
1223
+ backgroundColor: "var(--vscode-editor-inactiveSelectionBackground)",
1224
+ borderRadius: "4px",
1225
+ marginBottom: "32px",
1226
+ opacity: 0.5
1227
+ },
1228
+ placeholderText: {
1229
+ color: "var(--vscode-descriptionForeground)",
1230
+ fontSize: "11px"
1231
+ },
1232
+ variantsContainer: {
1233
+ marginBottom: "32px"
1234
+ },
1235
+ variantsHeader: {
1236
+ marginBottom: "12px"
1237
+ },
1238
+ variantsTitle: {
1239
+ fontSize: "13px",
1240
+ fontWeight: 500,
1241
+ color: "var(--vscode-foreground)"
1242
+ },
1243
+ variantsContent: {
1244
+ display: "flex",
1245
+ flexDirection: "row",
1246
+ flexWrap: "wrap",
1247
+ gap: "16px"
1248
+ },
1249
+ variantItem: {
1250
+ flex: "0 0 auto"
1251
+ },
1252
+ variantPlaceholder: {
1253
+ display: "flex",
1254
+ alignItems: "center",
1255
+ justifyContent: "center",
1256
+ backgroundColor: "var(--vscode-editor-inactiveSelectionBackground)",
1257
+ borderRadius: "4px",
1258
+ opacity: 0.5,
1259
+ minWidth: "150px"
1260
+ }
1261
+ }, X = w(
1262
+ ue,
1263
+ {},
1264
+ (r, e) => {
1265
+ const t = e.leftSidebarVisible.read(r), o = e.rightSidebarVisible.read(r), n = e.isDarkTheme.read(r), s = e.selectedNode.read(r);
1266
+ return /* @__PURE__ */ p("div", { className: n ? "vscode-theme default-dark-plus" : "vscode-theme default-light-plus", style: c.container, children: [
1267
+ t && /* @__PURE__ */ i(ke, { model: e }),
1268
+ /* @__PURE__ */ p("div", { style: c.centerArea, children: [
1269
+ /* @__PURE__ */ i(Se, { model: e }),
1270
+ /* @__PURE__ */ i($e, { model: e })
1271
+ ] }),
1272
+ o && /* @__PURE__ */ i(Be, { selectedNode: s })
1273
+ ] });
1274
+ }
1275
+ );
1276
+ function Je() {
1277
+ const r = new A();
1278
+ return r.register("components/Button.fixture.tsx", I({
1279
+ Primary: {
1280
+ render: (e) => (e.innerHTML = "<button>Primary Button</button>", { dispose: () => {
1281
+ e.innerHTML = "";
1282
+ } })
1283
+ },
1284
+ Icon: {
1285
+ render: (e) => (e.innerHTML = "<button>🔔 Icon Button</button>", { dispose: () => {
1286
+ e.innerHTML = "";
1287
+ } })
1288
+ }
1289
+ })), r.register("components/Input.fixture.tsx", I({
1290
+ Text: {
1291
+ render: (e) => (e.innerHTML = '<input type="text" placeholder="Text Input" />', { dispose: () => {
1292
+ e.innerHTML = "";
1293
+ } })
1294
+ },
1295
+ Search: {
1296
+ render: (e) => (e.innerHTML = '<input type="search" placeholder="Search..." />', { dispose: () => {
1297
+ e.innerHTML = "";
1298
+ } })
1299
+ }
1300
+ })), r.register("components/Card.fixture.tsx", I({
1301
+ Basic: {
1302
+ render: (e) => (e.innerHTML = '<div style="border: 1px solid #ccc; padding: 16px;">Basic Card</div>', { dispose: () => {
1303
+ e.innerHTML = "";
1304
+ } })
1305
+ }
1306
+ })), r.register("components/Feedback.fixture.tsx", I({
1307
+ Badge: {
1308
+ render: (e) => (e.innerHTML = '<span style="background: blue; color: white; padding: 2px 8px; border-radius: 4px;">Badge</span>', { dispose: () => {
1309
+ e.innerHTML = "";
1310
+ } })
1311
+ },
1312
+ Alert: {
1313
+ render: (e) => (e.innerHTML = '<div style="background: #ffffcc; padding: 8px; border: 1px solid #cc0;">Alert message</div>', { dispose: () => {
1314
+ e.innerHTML = "";
1315
+ } })
1316
+ }
1317
+ })), r;
1318
+ }
1319
+ function it() {
1320
+ const r = Je();
1321
+ return /* @__PURE__ */ i(X, { registry: r });
1322
+ }
1323
+ class nt {
1324
+ constructor(e, t) {
1325
+ l(this, "_root");
1326
+ l(this, "_registry", new A());
1327
+ this._populateRegistry(t), this._root = pe.createRoot(e), this._root.render(re(X, { registry: this._registry }));
1328
+ }
1329
+ _populateRegistry(e) {
1330
+ this._registry.clear();
1331
+ for (const [t, o] of Object.entries(e)) {
1332
+ const n = o.default;
1333
+ n && typeof n == "object" && this._registry.register(t, n);
1334
+ }
1335
+ }
1336
+ /**
1337
+ * Updates the fixtures. The UI will update automatically since the registry is observable.
1338
+ */
1339
+ updateFixtures(e) {
1340
+ this._populateRegistry(e);
1341
+ }
1342
+ /**
1343
+ * Unmounts the explorer and cleans up resources.
1344
+ */
1345
+ dispose() {
1346
+ this._root.unmount();
1347
+ }
1348
+ }
1349
+ export {
1350
+ ge as ChevronDownIcon,
1351
+ ve as ChevronRightIcon,
1352
+ me as ComponentIcon,
1353
+ X as Explorer,
1354
+ nt as ExplorerApp,
1355
+ ue as ExplorerModel,
1356
+ it as ExplorerWithDefaults,
1357
+ A as FixtureRegistry,
1358
+ be as FolderIcon,
1359
+ ke as LeftSidebar,
1360
+ Ce as MoonIcon,
1361
+ xe as PanelLeftIcon,
1362
+ ye as PanelRightIcon,
1363
+ Be as RightSidebar,
1364
+ _e as SunIcon,
1365
+ Se as TitleBar,
1366
+ z as TitleBarButton,
1367
+ Ie as TreeItem,
1368
+ W as TreeView,
1369
+ oe as VIEWPORT_SIZES,
1370
+ ae as collectComponents,
1371
+ E as createFixtureTree,
1372
+ I as defineFixture,
1373
+ rt as defineFixtureGroup,
1374
+ ot as defineFixtureVariants,
1375
+ V as findNodeByPath,
1376
+ et as getDefaultPropertyValues,
1377
+ tt as isComponentDefinition,
1378
+ se as isFixtureGroup,
1379
+ de as isFixtureVariants,
1380
+ ne as isSingleFixture,
1381
+ T as mergeStyles,
1382
+ ie as resolveViewport,
1383
+ c as styles,
1384
+ $ as toExplorerTree
1385
+ };
1386
+ //# sourceMappingURL=index.js.map