@adieyal/catalogue-core 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.
- package/dist/index.d.ts +1958 -0
- package/dist/index.js +1567 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1567 @@
|
|
|
1
|
+
var le = Object.defineProperty;
|
|
2
|
+
var ie = (t, e, a) => e in t ? le(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
3
|
+
var V = (t, e, a) => ie(t, typeof e != "symbol" ? e + "" : e, a);
|
|
4
|
+
import { z as l } from "zod";
|
|
5
|
+
import { marked as de } from "marked";
|
|
6
|
+
const ue = l.object({
|
|
7
|
+
/** Element tag name (e.g., 'div', 'my-component') */
|
|
8
|
+
element: l.string().min(1),
|
|
9
|
+
/** DOM attributes (set via setAttribute) */
|
|
10
|
+
attrs: l.record(l.union([l.string(), l.number(), l.boolean(), l.null()])).optional(),
|
|
11
|
+
/** DOM properties (set directly on element, for objects/arrays) */
|
|
12
|
+
props: l.record(l.unknown()).optional(),
|
|
13
|
+
/** Text content (mutually exclusive with children) */
|
|
14
|
+
text: l.string().optional()
|
|
15
|
+
}), R = ue.extend({
|
|
16
|
+
/** Named slots - content to render with slot attribute */
|
|
17
|
+
slots: l.record(l.union([
|
|
18
|
+
l.string(),
|
|
19
|
+
l.lazy(() => R),
|
|
20
|
+
l.array(l.lazy(() => R))
|
|
21
|
+
])).optional(),
|
|
22
|
+
/** Child elements */
|
|
23
|
+
children: l.array(l.lazy(() => R)).optional()
|
|
24
|
+
});
|
|
25
|
+
function ut(t) {
|
|
26
|
+
const e = R.safeParse(t);
|
|
27
|
+
return e.success ? { success: !0, data: e.data } : {
|
|
28
|
+
success: !1,
|
|
29
|
+
errors: e.error.errors.map((a) => `${a.path.join(".")}: ${a.message}`)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const pe = l.object({
|
|
33
|
+
type: l.literal("text"),
|
|
34
|
+
label: l.string().optional(),
|
|
35
|
+
defaultValue: l.string().optional(),
|
|
36
|
+
placeholder: l.string().optional()
|
|
37
|
+
}), me = l.object({
|
|
38
|
+
type: l.literal("number"),
|
|
39
|
+
label: l.string().optional(),
|
|
40
|
+
defaultValue: l.number().optional(),
|
|
41
|
+
min: l.number().optional(),
|
|
42
|
+
max: l.number().optional(),
|
|
43
|
+
step: l.number().optional()
|
|
44
|
+
}), he = l.object({
|
|
45
|
+
type: l.literal("boolean"),
|
|
46
|
+
label: l.string().optional(),
|
|
47
|
+
defaultValue: l.boolean().optional()
|
|
48
|
+
}), ge = l.object({
|
|
49
|
+
type: l.literal("select"),
|
|
50
|
+
label: l.string().optional(),
|
|
51
|
+
defaultValue: l.string().optional(),
|
|
52
|
+
options: l.array(l.union([
|
|
53
|
+
l.string(),
|
|
54
|
+
l.object({
|
|
55
|
+
label: l.string(),
|
|
56
|
+
value: l.string()
|
|
57
|
+
})
|
|
58
|
+
]))
|
|
59
|
+
}), fe = l.object({
|
|
60
|
+
type: l.literal("radio"),
|
|
61
|
+
label: l.string().optional(),
|
|
62
|
+
defaultValue: l.string().optional(),
|
|
63
|
+
options: l.array(l.union([
|
|
64
|
+
l.string(),
|
|
65
|
+
l.object({
|
|
66
|
+
label: l.string(),
|
|
67
|
+
value: l.string()
|
|
68
|
+
})
|
|
69
|
+
]))
|
|
70
|
+
}), Ce = l.object({
|
|
71
|
+
type: l.literal("color"),
|
|
72
|
+
label: l.string().optional(),
|
|
73
|
+
defaultValue: l.string().optional()
|
|
74
|
+
}), be = l.object({
|
|
75
|
+
type: l.literal("range"),
|
|
76
|
+
label: l.string().optional(),
|
|
77
|
+
defaultValue: l.number().optional(),
|
|
78
|
+
min: l.number(),
|
|
79
|
+
max: l.number(),
|
|
80
|
+
step: l.number().optional()
|
|
81
|
+
}), ve = l.object({
|
|
82
|
+
type: l.literal("json"),
|
|
83
|
+
label: l.string().optional(),
|
|
84
|
+
defaultValue: l.unknown().optional()
|
|
85
|
+
}), Z = l.discriminatedUnion("type", [
|
|
86
|
+
pe,
|
|
87
|
+
me,
|
|
88
|
+
he,
|
|
89
|
+
ge,
|
|
90
|
+
fe,
|
|
91
|
+
Ce,
|
|
92
|
+
be,
|
|
93
|
+
ve
|
|
94
|
+
]);
|
|
95
|
+
function pt(t) {
|
|
96
|
+
const e = Z.safeParse(t);
|
|
97
|
+
return e.success ? { success: !0, data: e.data } : {
|
|
98
|
+
success: !1,
|
|
99
|
+
errors: e.error.errors.map((a) => `${a.path.join(".")}: ${a.message}`)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const ye = l.enum(["stable", "beta", "deprecated"]), Ee = l.enum(["standalone", "subcomponent", "feature"]), xe = l.object({
|
|
103
|
+
/** Custom element tag name (must be kebab-case with at least one hyphen) */
|
|
104
|
+
customElement: l.string().regex(/^[a-z][a-z0-9]*-[a-z0-9-]+$/, {
|
|
105
|
+
message: 'Custom element name must be kebab-case with at least one hyphen (e.g., "my-button")'
|
|
106
|
+
}),
|
|
107
|
+
/** npm package name (optional, defaults to consumer's package) */
|
|
108
|
+
package: l.string().optional(),
|
|
109
|
+
/** Entry point path (optional, defaults to main entry) */
|
|
110
|
+
entry: l.string().optional()
|
|
111
|
+
}), we = l.object({
|
|
112
|
+
/** ID of the primary scenario to use as default in playground */
|
|
113
|
+
primaryScenarioId: l.string().min(1),
|
|
114
|
+
/** Control definitions keyed by property name */
|
|
115
|
+
controls: l.record(Z)
|
|
116
|
+
}), Ne = l.object({
|
|
117
|
+
/** Unique identifier for the component (kebab-case) */
|
|
118
|
+
id: l.string().min(1).regex(/^[a-z][a-z0-9-]*$/, {
|
|
119
|
+
message: "Component ID must be kebab-case starting with a letter"
|
|
120
|
+
}),
|
|
121
|
+
/** Human-readable title */
|
|
122
|
+
title: l.string().min(1),
|
|
123
|
+
/** Component maturity status */
|
|
124
|
+
status: ye,
|
|
125
|
+
/** Component kind */
|
|
126
|
+
kind: Ee,
|
|
127
|
+
/** Optional description */
|
|
128
|
+
description: l.string().optional(),
|
|
129
|
+
/** Tags for search and filtering */
|
|
130
|
+
tags: l.array(l.string()).optional(),
|
|
131
|
+
/** Category ID (must match a category defined in config) */
|
|
132
|
+
category: l.string().regex(/^[a-z][a-z0-9-]*$/, {
|
|
133
|
+
message: "Category must be kebab-case starting with a letter"
|
|
134
|
+
}).optional(),
|
|
135
|
+
/** Export configuration */
|
|
136
|
+
exports: xe,
|
|
137
|
+
/** Playground configuration */
|
|
138
|
+
playground: we,
|
|
139
|
+
/** Parent component ID (required when kind is 'subcomponent') */
|
|
140
|
+
parentId: l.string().optional(),
|
|
141
|
+
/** List of subcomponent IDs */
|
|
142
|
+
subcomponents: l.array(l.string()).optional()
|
|
143
|
+
}).refine(
|
|
144
|
+
(t) => !(t.kind === "subcomponent" && !t.parentId),
|
|
145
|
+
{
|
|
146
|
+
message: "Subcomponents must have a parentId",
|
|
147
|
+
path: ["parentId"]
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
function $e(t) {
|
|
151
|
+
const e = Ne.safeParse(t);
|
|
152
|
+
return e.success ? { success: !0, data: e.data } : {
|
|
153
|
+
success: !1,
|
|
154
|
+
errors: e.error.errors.map((a) => ({
|
|
155
|
+
path: a.path.join(".") || "(root)",
|
|
156
|
+
message: a.message
|
|
157
|
+
}))
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function mt(t, e) {
|
|
161
|
+
const a = e ? `${e}: ` : "";
|
|
162
|
+
return t.map((o) => `${a}${o.path}: ${o.message}`).join(`
|
|
163
|
+
`);
|
|
164
|
+
}
|
|
165
|
+
const ee = l.object({
|
|
166
|
+
/** Unique identifier for the scenario (kebab-case) */
|
|
167
|
+
id: l.string().min(1).regex(/^[a-z][a-z0-9-]*$/, {
|
|
168
|
+
message: "Scenario ID must be kebab-case starting with a letter"
|
|
169
|
+
}),
|
|
170
|
+
/** Human-readable title */
|
|
171
|
+
title: l.string().min(1),
|
|
172
|
+
/** Optional description explaining the scenario */
|
|
173
|
+
description: l.string().optional(),
|
|
174
|
+
/** Component ID this scenario belongs to */
|
|
175
|
+
componentId: l.string().min(1),
|
|
176
|
+
/** Tags for search and filtering */
|
|
177
|
+
tags: l.array(l.string()).optional(),
|
|
178
|
+
/** The RenderNode tree that defines the DOM structure */
|
|
179
|
+
render: R,
|
|
180
|
+
/** Optional viewport configuration for screenshots */
|
|
181
|
+
viewport: l.object({
|
|
182
|
+
width: l.number().positive().optional(),
|
|
183
|
+
height: l.number().positive().optional()
|
|
184
|
+
}).optional(),
|
|
185
|
+
/** Optional background color override */
|
|
186
|
+
background: l.string().optional(),
|
|
187
|
+
/** Whether this is the primary scenario (shown first) */
|
|
188
|
+
primary: l.boolean().optional()
|
|
189
|
+
}), ht = ee;
|
|
190
|
+
function te(t) {
|
|
191
|
+
const e = ee.safeParse(t);
|
|
192
|
+
return e.success ? { success: !0, data: e.data } : {
|
|
193
|
+
success: !1,
|
|
194
|
+
errors: e.error.errors.map((a) => ({
|
|
195
|
+
path: a.path.join(".") || "(root)",
|
|
196
|
+
message: a.message
|
|
197
|
+
}))
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function Se(t) {
|
|
201
|
+
return te(t);
|
|
202
|
+
}
|
|
203
|
+
function gt(t, e) {
|
|
204
|
+
const a = e ? `${e}: ` : "";
|
|
205
|
+
return t.map((o) => `${a}${o.path}: ${o.message}`).join(`
|
|
206
|
+
`);
|
|
207
|
+
}
|
|
208
|
+
function ft(t) {
|
|
209
|
+
const e = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
210
|
+
for (const { filePath: s, data: i, docs: c } of t.components) {
|
|
211
|
+
const d = $e(i);
|
|
212
|
+
if (d.success) {
|
|
213
|
+
if (d.data) {
|
|
214
|
+
const u = d.data;
|
|
215
|
+
a.set(u.id, {
|
|
216
|
+
...u,
|
|
217
|
+
filePath: s,
|
|
218
|
+
docs: c,
|
|
219
|
+
scenarios: []
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
} else for (const u of d.errors || [])
|
|
223
|
+
e.push({
|
|
224
|
+
file: s,
|
|
225
|
+
path: u.path,
|
|
226
|
+
message: u.message
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
for (const { filePath: s, data: i } of t.scenarios) {
|
|
230
|
+
const c = te(i);
|
|
231
|
+
if (c.success) {
|
|
232
|
+
if (c.data) {
|
|
233
|
+
const d = c.data, u = {
|
|
234
|
+
...d,
|
|
235
|
+
filePath: s
|
|
236
|
+
};
|
|
237
|
+
o.set(d.id, u);
|
|
238
|
+
const h = a.get(d.componentId);
|
|
239
|
+
h && h.scenarios.push(u);
|
|
240
|
+
}
|
|
241
|
+
} else for (const d of c.errors || [])
|
|
242
|
+
e.push({
|
|
243
|
+
file: s,
|
|
244
|
+
path: d.path,
|
|
245
|
+
message: d.message
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
for (const { filePath: s, data: i } of t.examples) {
|
|
249
|
+
const c = Se(i);
|
|
250
|
+
if (c.success) {
|
|
251
|
+
if (c.data) {
|
|
252
|
+
const d = c.data;
|
|
253
|
+
n.set(d.id, {
|
|
254
|
+
...d,
|
|
255
|
+
filePath: s
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
} else for (const d of c.errors || [])
|
|
259
|
+
e.push({
|
|
260
|
+
file: s,
|
|
261
|
+
path: d.path,
|
|
262
|
+
message: d.message
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
const r = t.categories ?? {
|
|
266
|
+
items: [],
|
|
267
|
+
uncategorisedLabel: "Other"
|
|
268
|
+
};
|
|
269
|
+
return {
|
|
270
|
+
registry: { components: a, scenarios: o, examples: n, categories: r },
|
|
271
|
+
errors: e
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function Ct() {
|
|
275
|
+
return {
|
|
276
|
+
components: /* @__PURE__ */ new Map(),
|
|
277
|
+
scenarios: /* @__PURE__ */ new Map(),
|
|
278
|
+
examples: /* @__PURE__ */ new Map(),
|
|
279
|
+
categories: { items: [], uncategorisedLabel: "Other" }
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function ke(t) {
|
|
283
|
+
return Array.from(t.components.values()).filter((e) => e.kind !== "subcomponent");
|
|
284
|
+
}
|
|
285
|
+
function Le(t, e) {
|
|
286
|
+
return Array.from(t.components.values()).filter((a) => a.parentId === e);
|
|
287
|
+
}
|
|
288
|
+
function Ae(t, e, a) {
|
|
289
|
+
const o = e.toLowerCase();
|
|
290
|
+
return Array.from(t.components.values()).filter((n) => {
|
|
291
|
+
var r, s, i, c, d, u;
|
|
292
|
+
if (n.kind === "subcomponent")
|
|
293
|
+
return !1;
|
|
294
|
+
if (e) {
|
|
295
|
+
const h = n.id.toLowerCase().includes(o), p = n.title.toLowerCase().includes(o), g = (r = n.tags) == null ? void 0 : r.some(
|
|
296
|
+
($) => $.toLowerCase().includes(o)
|
|
297
|
+
), N = (s = n.description) == null ? void 0 : s.toLowerCase().includes(o);
|
|
298
|
+
if (!h && !p && !g && !N)
|
|
299
|
+
return !1;
|
|
300
|
+
}
|
|
301
|
+
return !((i = a == null ? void 0 : a.status) != null && i.length && !a.status.includes(n.status) || (c = a == null ? void 0 : a.kind) != null && c.length && !a.kind.includes(n.kind) || (d = a == null ? void 0 : a.tags) != null && d.length && !((u = n.tags) == null ? void 0 : u.some(
|
|
302
|
+
(p) => a.tags.includes(p)
|
|
303
|
+
)));
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
function Y(t) {
|
|
307
|
+
const e = ke(t), a = /* @__PURE__ */ new Map(), o = [];
|
|
308
|
+
for (const r of e)
|
|
309
|
+
r.category ? (a.has(r.category) || a.set(r.category, []), a.get(r.category).push(r)) : o.push(r);
|
|
310
|
+
const n = [];
|
|
311
|
+
for (const r of t.categories.items) {
|
|
312
|
+
const s = a.get(r.id) || [];
|
|
313
|
+
s.length > 0 && n.push({ category: r, components: s });
|
|
314
|
+
}
|
|
315
|
+
return o.length > 0 && n.push({ category: null, components: o }), n;
|
|
316
|
+
}
|
|
317
|
+
function bt(t) {
|
|
318
|
+
const e = [], a = [], o = /* @__PURE__ */ new Map();
|
|
319
|
+
for (const [n, r] of t.components)
|
|
320
|
+
o.has(n) || o.set(n, []), o.get(n).push(r.filePath);
|
|
321
|
+
for (const [n, r] of t.scenarios)
|
|
322
|
+
o.has(n) || o.set(n, []), o.get(n).push(r.filePath);
|
|
323
|
+
for (const [n, r] of t.examples)
|
|
324
|
+
o.has(n) || o.set(n, []), o.get(n).push(r.filePath);
|
|
325
|
+
for (const [n, r] of o)
|
|
326
|
+
r.length > 1 && e.push({
|
|
327
|
+
file: r.join(", "),
|
|
328
|
+
path: "id",
|
|
329
|
+
message: `Duplicate ID "${n}" found in multiple files`
|
|
330
|
+
});
|
|
331
|
+
for (const [n, r] of t.components) {
|
|
332
|
+
const s = r.playground.primaryScenarioId;
|
|
333
|
+
if (r.scenarios.some((c) => c.id === s) || e.push({
|
|
334
|
+
file: r.filePath,
|
|
335
|
+
path: "playground.primaryScenarioId",
|
|
336
|
+
message: `Primary scenario "${s}" not found for component "${n}"`
|
|
337
|
+
}), r.parentId && (t.components.has(r.parentId) || e.push({
|
|
338
|
+
file: r.filePath,
|
|
339
|
+
path: "parentId",
|
|
340
|
+
message: `Parent component "${r.parentId}" not found for component "${n}"`
|
|
341
|
+
})), r.subcomponents)
|
|
342
|
+
for (const c of r.subcomponents)
|
|
343
|
+
if (!t.components.has(c))
|
|
344
|
+
e.push({
|
|
345
|
+
file: r.filePath,
|
|
346
|
+
path: "subcomponents",
|
|
347
|
+
message: `Subcomponent "${c}" not found for component "${n}"`
|
|
348
|
+
});
|
|
349
|
+
else {
|
|
350
|
+
const d = t.components.get(c);
|
|
351
|
+
d.parentId !== n && a.push({
|
|
352
|
+
file: r.filePath,
|
|
353
|
+
path: "subcomponents",
|
|
354
|
+
message: `Subcomponent "${c}" has different parentId "${d.parentId}" than expected "${n}"`
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
r.scenarios.length === 0 && e.push({
|
|
358
|
+
file: r.filePath,
|
|
359
|
+
path: "scenarios",
|
|
360
|
+
message: `Component "${n}" has no scenarios`
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
for (const [n, r] of t.scenarios)
|
|
364
|
+
t.components.has(r.componentId) || e.push({
|
|
365
|
+
file: r.filePath,
|
|
366
|
+
path: "componentId",
|
|
367
|
+
message: `Component "${r.componentId}" not found for scenario "${n}"`
|
|
368
|
+
});
|
|
369
|
+
for (const [n, r] of t.examples)
|
|
370
|
+
t.components.has(r.componentId) || e.push({
|
|
371
|
+
file: r.filePath,
|
|
372
|
+
path: "componentId",
|
|
373
|
+
message: `Component "${r.componentId}" not found for example "${n}"`
|
|
374
|
+
});
|
|
375
|
+
return {
|
|
376
|
+
valid: e.length === 0,
|
|
377
|
+
errors: e,
|
|
378
|
+
warnings: a
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function vt(t) {
|
|
382
|
+
const e = [];
|
|
383
|
+
if (t.errors.length > 0) {
|
|
384
|
+
e.push("Errors:");
|
|
385
|
+
for (const a of t.errors)
|
|
386
|
+
e.push(` ${a.file}: ${a.path}: ${a.message}`);
|
|
387
|
+
}
|
|
388
|
+
if (t.warnings.length > 0) {
|
|
389
|
+
e.push("Warnings:");
|
|
390
|
+
for (const a of t.warnings)
|
|
391
|
+
e.push(` ${a.file}: ${a.path}: ${a.message}`);
|
|
392
|
+
}
|
|
393
|
+
return e.join(`
|
|
394
|
+
`);
|
|
395
|
+
}
|
|
396
|
+
function D(t) {
|
|
397
|
+
const e = document.createElement(t.element);
|
|
398
|
+
if (t.attrs)
|
|
399
|
+
for (const [a, o] of Object.entries(t.attrs))
|
|
400
|
+
o != null && (typeof o == "boolean" ? o && e.setAttribute(a, "") : e.setAttribute(a, String(o)));
|
|
401
|
+
if (t.props)
|
|
402
|
+
for (const [a, o] of Object.entries(t.props))
|
|
403
|
+
e[a] = o;
|
|
404
|
+
if (t.text !== void 0 && (e.textContent = t.text), t.slots)
|
|
405
|
+
for (const [a, o] of Object.entries(t.slots))
|
|
406
|
+
Ie(e, a, o);
|
|
407
|
+
if (t.children)
|
|
408
|
+
for (const a of t.children) {
|
|
409
|
+
const o = D(a);
|
|
410
|
+
e.appendChild(o);
|
|
411
|
+
}
|
|
412
|
+
return e;
|
|
413
|
+
}
|
|
414
|
+
function Ie(t, e, a) {
|
|
415
|
+
if (typeof a == "string") {
|
|
416
|
+
const o = document.createElement("span");
|
|
417
|
+
e !== "default" && o.setAttribute("slot", e), o.textContent = a, t.appendChild(o);
|
|
418
|
+
} else if (Array.isArray(a))
|
|
419
|
+
for (const o of a) {
|
|
420
|
+
const n = D(o);
|
|
421
|
+
e !== "default" && n.setAttribute("slot", e), t.appendChild(n);
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
const o = D(a);
|
|
425
|
+
e !== "default" && o.setAttribute("slot", e), t.appendChild(o);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
function ne(t, e) {
|
|
429
|
+
var o;
|
|
430
|
+
const a = [];
|
|
431
|
+
e.clear && (e.container.innerHTML = "");
|
|
432
|
+
try {
|
|
433
|
+
const n = D(t);
|
|
434
|
+
return e.container.appendChild(n), { element: n, errors: a };
|
|
435
|
+
} catch (n) {
|
|
436
|
+
const r = n instanceof Error ? n : new Error(String(n));
|
|
437
|
+
a.push({ node: t, error: r }), (o = e.onError) == null || o.call(e, r, t);
|
|
438
|
+
const s = document.createElement("div");
|
|
439
|
+
return s.setAttribute("data-catalogue-error", ""), s.textContent = `Render error: ${r.message}`, s.style.cssText = "color: red; padding: 1em; border: 1px solid red; font-family: monospace;", e.container.appendChild(s), { element: s, errors: a };
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function ae(t, e, a) {
|
|
443
|
+
if (e) {
|
|
444
|
+
const o = t.getAttributeNames();
|
|
445
|
+
for (const n of o)
|
|
446
|
+
n in e || t.removeAttribute(n);
|
|
447
|
+
for (const [n, r] of Object.entries(e))
|
|
448
|
+
r == null ? t.removeAttribute(n) : typeof r == "boolean" ? r ? t.setAttribute(n, "") : t.removeAttribute(n) : t.setAttribute(n, String(r));
|
|
449
|
+
}
|
|
450
|
+
if (a)
|
|
451
|
+
for (const [o, n] of Object.entries(a))
|
|
452
|
+
t[o] = n;
|
|
453
|
+
}
|
|
454
|
+
function yt(t, e) {
|
|
455
|
+
ae(t, e.attrs, e.props), e.text !== void 0 && (t.textContent = e.text);
|
|
456
|
+
}
|
|
457
|
+
const oe = "catalogue-theme";
|
|
458
|
+
function Pe() {
|
|
459
|
+
const t = localStorage.getItem(oe);
|
|
460
|
+
return t === "dark" || t === "light" ? t : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
461
|
+
}
|
|
462
|
+
function J(t) {
|
|
463
|
+
localStorage.setItem(oe, t), document.documentElement.setAttribute("data-theme", t), document.querySelectorAll("[data-catalogue-container]").forEach((e) => {
|
|
464
|
+
e.setAttribute("data-theme", t);
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function Te() {
|
|
468
|
+
const e = (document.documentElement.getAttribute("data-theme") || "light") === "light" ? "dark" : "light";
|
|
469
|
+
return J(e), e;
|
|
470
|
+
}
|
|
471
|
+
function re() {
|
|
472
|
+
const t = Pe();
|
|
473
|
+
return J(t), t;
|
|
474
|
+
}
|
|
475
|
+
function se() {
|
|
476
|
+
const t = document.createElement("button");
|
|
477
|
+
t.className = "catalogue-theme-toggle", t.setAttribute("type", "button"), t.setAttribute("aria-label", "Toggle theme"), t.setAttribute("title", "Toggle light/dark theme");
|
|
478
|
+
const e = () => {
|
|
479
|
+
const a = document.documentElement.getAttribute("data-theme") || "light";
|
|
480
|
+
t.innerHTML = a === "light" ? '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>' : '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>';
|
|
481
|
+
};
|
|
482
|
+
return e(), t.addEventListener("click", () => {
|
|
483
|
+
Te(), e();
|
|
484
|
+
}), t;
|
|
485
|
+
}
|
|
486
|
+
const Me = [
|
|
487
|
+
{ name: "Mobile S", width: 320, height: 568 },
|
|
488
|
+
{ name: "Mobile M", width: 375, height: 667 },
|
|
489
|
+
{ name: "Mobile L", width: 425, height: 812 },
|
|
490
|
+
{ name: "Tablet", width: 768, height: 1024 },
|
|
491
|
+
{ name: "Laptop", width: 1024, height: 768 },
|
|
492
|
+
{ name: "Desktop", width: 1440, height: 900 },
|
|
493
|
+
{ name: "Full", width: 0, height: 0, fullScreen: !0 }
|
|
494
|
+
], je = "width 0.3s ease, height 0.3s ease";
|
|
495
|
+
function ze(t = {}) {
|
|
496
|
+
const {
|
|
497
|
+
initialWidth: e = "100%",
|
|
498
|
+
initialHeight: a = "auto",
|
|
499
|
+
minWidth: o = 200,
|
|
500
|
+
minHeight: n = 100,
|
|
501
|
+
maxWidth: r = 2e3,
|
|
502
|
+
maxHeight: s = 2e3,
|
|
503
|
+
onResize: i,
|
|
504
|
+
onFullScreenChange: c,
|
|
505
|
+
animatePresets: d = !0
|
|
506
|
+
} = t;
|
|
507
|
+
let u = !1;
|
|
508
|
+
const h = document.createElement("div");
|
|
509
|
+
h.className = "catalogue-resizer-wrapper";
|
|
510
|
+
const p = document.createElement("div");
|
|
511
|
+
p.className = "catalogue-resizer", p.setAttribute("data-catalogue-container", ""), p.style.width = e, p.style.height = a, p.style.minWidth = `${o}px`, p.style.minHeight = `${n}px`;
|
|
512
|
+
const g = document.createElement("div");
|
|
513
|
+
g.className = "catalogue-resizer-content", g.style.cssText = "container-type: inline-size; width: 100%; height: 100%;", p.appendChild(g);
|
|
514
|
+
const N = document.createElement("div");
|
|
515
|
+
N.className = "catalogue-resizer-handle catalogue-resizer-handle-right";
|
|
516
|
+
const $ = document.createElement("div");
|
|
517
|
+
$.className = "catalogue-resizer-handle catalogue-resizer-handle-bottom";
|
|
518
|
+
const I = document.createElement("div");
|
|
519
|
+
I.className = "catalogue-resizer-handle catalogue-resizer-handle-corner", p.appendChild(N), p.appendChild($), p.appendChild(I);
|
|
520
|
+
const b = document.createElement("div");
|
|
521
|
+
b.className = "catalogue-resizer-dimensions", p.appendChild(b);
|
|
522
|
+
const S = () => {
|
|
523
|
+
if (u)
|
|
524
|
+
b.textContent = "Full Screen";
|
|
525
|
+
else {
|
|
526
|
+
const y = p.getBoundingClientRect();
|
|
527
|
+
b.textContent = `${Math.round(y.width)} × ${Math.round(y.height)}`;
|
|
528
|
+
}
|
|
529
|
+
}, E = (y) => {
|
|
530
|
+
p.style.transition = y ? je : "none";
|
|
531
|
+
};
|
|
532
|
+
let T = !1, L = 0, m = 0, f = 0, v = 0, k = "corner";
|
|
533
|
+
const j = (y, C) => {
|
|
534
|
+
u && (u = !1, p.classList.remove("catalogue-resizer-fullscreen"), c == null || c(!1)), T = !0, k = C, L = y.clientX, m = y.clientY;
|
|
535
|
+
const x = p.getBoundingClientRect();
|
|
536
|
+
f = x.width, v = x.height, E(!1), document.body.style.cursor = C === "corner" ? "nwse-resize" : C === "right" ? "ew-resize" : "ns-resize", document.body.style.userSelect = "none", y.preventDefault();
|
|
537
|
+
}, w = (y) => {
|
|
538
|
+
if (!T) return;
|
|
539
|
+
const C = y.clientX - L, x = y.clientY - m;
|
|
540
|
+
let A = f, P = v;
|
|
541
|
+
(k === "right" || k === "corner") && (A = Math.max(o, Math.min(r, f + C))), (k === "bottom" || k === "corner") && (P = Math.max(n, Math.min(s, v + x))), p.style.width = `${A}px`, p.style.height = `${P}px`, S(), i == null || i(A, P);
|
|
542
|
+
}, M = () => {
|
|
543
|
+
T && (T = !1, document.body.style.cursor = "", document.body.style.userSelect = "");
|
|
544
|
+
};
|
|
545
|
+
return N.addEventListener("mousedown", (y) => j(y, "right")), $.addEventListener("mousedown", (y) => j(y, "bottom")), I.addEventListener("mousedown", (y) => j(y, "corner")), document.addEventListener("mousemove", w), document.addEventListener("mouseup", M), h.appendChild(p), p.addEventListener("transitionend", S), requestAnimationFrame(S), {
|
|
546
|
+
wrapper: h,
|
|
547
|
+
container: p,
|
|
548
|
+
content: g,
|
|
549
|
+
handleRight: N,
|
|
550
|
+
handleBottom: $,
|
|
551
|
+
handleCorner: I,
|
|
552
|
+
dimensionLabel: b,
|
|
553
|
+
setSize: (y, C, x = d) => {
|
|
554
|
+
const A = u;
|
|
555
|
+
y === "full" || C === "full" ? (u = !0, p.classList.add("catalogue-resizer-fullscreen"), E(x), p.style.width = "100%", p.style.height = "100%", S(), A || c == null || c(!0), requestAnimationFrame(() => {
|
|
556
|
+
const P = p.getBoundingClientRect();
|
|
557
|
+
i == null || i(P.width, P.height);
|
|
558
|
+
})) : (u = !1, p.classList.remove("catalogue-resizer-fullscreen"), E(x), p.style.width = `${y}px`, p.style.height = `${C}px`, S(), i == null || i(y, C), A && (c == null || c(!1)));
|
|
559
|
+
},
|
|
560
|
+
isFullScreen: () => u
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
function He(t, e = Me, a) {
|
|
564
|
+
const o = document.createElement("div");
|
|
565
|
+
o.className = "catalogue-breakpoint-presets";
|
|
566
|
+
let n = null;
|
|
567
|
+
for (const r of e) {
|
|
568
|
+
const s = document.createElement("button");
|
|
569
|
+
s.className = "catalogue-breakpoint-button", s.textContent = r.name, s.title = r.fullScreen ? "Fill available space" : `${r.width} × ${r.height}`, s.type = "button", s.addEventListener("click", () => {
|
|
570
|
+
n == null || n.classList.remove("active"), s.classList.add("active"), n = s, r.fullScreen ? t.setSize("full", "full", !0) : (t.setSize(r.width, r.height, !0), t.dimensionLabel.textContent = `${r.width} × ${r.height}`), a == null || a(r);
|
|
571
|
+
}), o.appendChild(s);
|
|
572
|
+
}
|
|
573
|
+
return o;
|
|
574
|
+
}
|
|
575
|
+
function Et(t, e, a, o = !0) {
|
|
576
|
+
t.setSize(e, a, o);
|
|
577
|
+
}
|
|
578
|
+
function Re(t) {
|
|
579
|
+
const {
|
|
580
|
+
code: e,
|
|
581
|
+
language: a = "html",
|
|
582
|
+
collapsible: o = !0,
|
|
583
|
+
collapsed: n = !1,
|
|
584
|
+
title: r = "Code"
|
|
585
|
+
} = t, s = document.createElement("div");
|
|
586
|
+
s.className = "catalogue-code-panel", s.setAttribute("data-language", a), n && s.setAttribute("data-collapsed", "");
|
|
587
|
+
const i = document.createElement("div");
|
|
588
|
+
i.className = "catalogue-code-panel-header";
|
|
589
|
+
const c = document.createElement("span");
|
|
590
|
+
c.className = "catalogue-code-panel-title", c.textContent = r, o && (c.style.cursor = "pointer", c.addEventListener("click", () => {
|
|
591
|
+
s.hasAttribute("data-collapsed") ? s.removeAttribute("data-collapsed") : s.setAttribute("data-collapsed", "");
|
|
592
|
+
}));
|
|
593
|
+
const d = document.createElement("button");
|
|
594
|
+
d.className = "catalogue-code-panel-copy", d.type = "button", d.textContent = "Copy", d.title = "Copy to clipboard", d.addEventListener("click", async () => {
|
|
595
|
+
try {
|
|
596
|
+
await navigator.clipboard.writeText(e), d.textContent = "Copied!", d.classList.add("copied"), setTimeout(() => {
|
|
597
|
+
d.textContent = "Copy", d.classList.remove("copied");
|
|
598
|
+
}, 2e3);
|
|
599
|
+
} catch {
|
|
600
|
+
d.textContent = "Failed", setTimeout(() => {
|
|
601
|
+
d.textContent = "Copy";
|
|
602
|
+
}, 2e3);
|
|
603
|
+
}
|
|
604
|
+
}), i.appendChild(c), i.appendChild(d);
|
|
605
|
+
const u = document.createElement("pre");
|
|
606
|
+
u.className = "catalogue-code-panel-content";
|
|
607
|
+
const h = document.createElement("code");
|
|
608
|
+
return h.className = `language-${a}`, h.textContent = e, u.appendChild(h), s.appendChild(i), s.appendChild(u), {
|
|
609
|
+
wrapper: s,
|
|
610
|
+
header: i,
|
|
611
|
+
content: u,
|
|
612
|
+
copyButton: d
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
function De(t, e) {
|
|
616
|
+
const a = t.content.querySelector("code");
|
|
617
|
+
a && (a.textContent = e);
|
|
618
|
+
const o = t.copyButton.cloneNode(!0);
|
|
619
|
+
o.addEventListener("click", async () => {
|
|
620
|
+
try {
|
|
621
|
+
await navigator.clipboard.writeText(e), o.textContent = "Copied!", o.classList.add("copied"), setTimeout(() => {
|
|
622
|
+
o.textContent = "Copy", o.classList.remove("copied");
|
|
623
|
+
}, 2e3);
|
|
624
|
+
} catch {
|
|
625
|
+
o.textContent = "Failed", setTimeout(() => {
|
|
626
|
+
o.textContent = "Copy";
|
|
627
|
+
}, 2e3);
|
|
628
|
+
}
|
|
629
|
+
}), t.copyButton.replaceWith(o), t.copyButton = o;
|
|
630
|
+
}
|
|
631
|
+
function xt(t, e = 2) {
|
|
632
|
+
const a = t.split(`
|
|
633
|
+
`);
|
|
634
|
+
let o = 0;
|
|
635
|
+
const n = " ".repeat(e);
|
|
636
|
+
return a.map((r) => {
|
|
637
|
+
const s = r.trim();
|
|
638
|
+
if (!s) return "";
|
|
639
|
+
s.startsWith("</") && (o = Math.max(0, o - 1));
|
|
640
|
+
const i = n.repeat(o) + s;
|
|
641
|
+
return s.startsWith("<") && !s.startsWith("</") && !s.endsWith("/>") && !s.includes("</") && o++, i;
|
|
642
|
+
}).filter((r) => r.length > 0).join(`
|
|
643
|
+
`);
|
|
644
|
+
}
|
|
645
|
+
class Oe {
|
|
646
|
+
constructor(e) {
|
|
647
|
+
V(this, "routes", []);
|
|
648
|
+
V(this, "options");
|
|
649
|
+
this.options = e, this.setupListeners();
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Add a route.
|
|
653
|
+
*/
|
|
654
|
+
route(e, a) {
|
|
655
|
+
const o = e.replace(/\//g, "\\/").replace(/:([a-zA-Z]+)/g, "(?<$1>[^/]+)");
|
|
656
|
+
return this.routes.push({
|
|
657
|
+
pattern: new RegExp(`^${o}$`),
|
|
658
|
+
handler: a
|
|
659
|
+
}), this;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Navigate to a path.
|
|
663
|
+
*/
|
|
664
|
+
navigate(e) {
|
|
665
|
+
window.location.hash = e;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Get current path from hash.
|
|
669
|
+
*/
|
|
670
|
+
getCurrentPath() {
|
|
671
|
+
return window.location.hash.slice(1) || "/";
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Get query parameters from current URL.
|
|
675
|
+
*/
|
|
676
|
+
getQueryParams() {
|
|
677
|
+
const e = window.location.hash.slice(1), a = e.indexOf("?");
|
|
678
|
+
return a === -1 ? new URLSearchParams() : new URLSearchParams(e.slice(a + 1));
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Resolve the current route.
|
|
682
|
+
*/
|
|
683
|
+
resolve() {
|
|
684
|
+
var r, s;
|
|
685
|
+
const e = window.location.hash.slice(1) || "/", a = e.indexOf("?"), o = a === -1 ? e : e.slice(0, a), n = this.getQueryParams();
|
|
686
|
+
for (const i of this.routes) {
|
|
687
|
+
const c = o.match(i.pattern);
|
|
688
|
+
if (c) {
|
|
689
|
+
const d = c.groups || {};
|
|
690
|
+
i.handler(d, n);
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
(s = (r = this.options).onNotFound) == null || s.call(r, o);
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Start listening for route changes.
|
|
698
|
+
*/
|
|
699
|
+
setupListeners() {
|
|
700
|
+
window.addEventListener("hashchange", () => this.resolve()), window.addEventListener("DOMContentLoaded", () => this.resolve());
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Manually trigger route resolution.
|
|
704
|
+
*/
|
|
705
|
+
start() {
|
|
706
|
+
this.resolve();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function H(t, e, a) {
|
|
710
|
+
const o = document.createElement("a");
|
|
711
|
+
return o.href = `#${t}`, o.textContent = e, a && (o.className = a), o;
|
|
712
|
+
}
|
|
713
|
+
function wt(t, e) {
|
|
714
|
+
const a = t.replace(/\//g, "\\/").replace(/:([a-zA-Z]+)/g, "(?<$1>[^/]+)"), o = new RegExp(`^${a}$`), n = e.match(o);
|
|
715
|
+
return n ? n.groups || {} : null;
|
|
716
|
+
}
|
|
717
|
+
function Be(t) {
|
|
718
|
+
const { registry: e, onNavigate: a } = t, o = document.createElement("div");
|
|
719
|
+
o.className = "catalogue-landing", o.setAttribute("data-catalogue-root", "");
|
|
720
|
+
const n = document.createElement("header");
|
|
721
|
+
n.className = "catalogue-landing-header";
|
|
722
|
+
const r = document.createElement("h1");
|
|
723
|
+
r.className = "catalogue-landing-title", r.textContent = "Component Catalogue", n.appendChild(r), o.appendChild(n);
|
|
724
|
+
const s = document.createElement("div");
|
|
725
|
+
s.className = "catalogue-landing-controls";
|
|
726
|
+
const i = document.createElement("input");
|
|
727
|
+
i.type = "search", i.className = "catalogue-search-input", i.placeholder = "Search components...", i.setAttribute("aria-label", "Search components"), s.appendChild(i);
|
|
728
|
+
const c = document.createElement("div");
|
|
729
|
+
c.className = "catalogue-filters";
|
|
730
|
+
const d = K("Status", [
|
|
731
|
+
{ value: "stable", label: "Stable" },
|
|
732
|
+
{ value: "beta", label: "Beta" },
|
|
733
|
+
{ value: "deprecated", label: "Deprecated" }
|
|
734
|
+
]);
|
|
735
|
+
c.appendChild(d.container);
|
|
736
|
+
const u = K("Kind", [
|
|
737
|
+
{ value: "standalone", label: "Standalone" },
|
|
738
|
+
{ value: "feature", label: "Feature" }
|
|
739
|
+
]);
|
|
740
|
+
c.appendChild(u.container), s.appendChild(c);
|
|
741
|
+
const h = e.categories.items.length > 0;
|
|
742
|
+
let p = null;
|
|
743
|
+
h && (p = document.createElement("button"), p.className = "catalogue-expand-toggle", p.textContent = "Collapse All", p.setAttribute("data-expanded", "true"), s.appendChild(p)), o.appendChild(s);
|
|
744
|
+
const g = document.createElement("div");
|
|
745
|
+
g.className = "catalogue-component-list", o.appendChild(g);
|
|
746
|
+
const N = d.container.querySelectorAll('input[type="checkbox"]'), $ = u.container.querySelectorAll('input[type="checkbox"]'), I = () => {
|
|
747
|
+
const b = i.value, S = Array.from(N).filter((m) => m.checked).map((m) => m.value), E = Array.from($).filter((m) => m.checked).map((m) => m.value), T = {
|
|
748
|
+
status: S.length > 0 ? S : void 0,
|
|
749
|
+
kind: E.length > 0 ? E : void 0
|
|
750
|
+
}, L = !!(b || T.status || T.kind);
|
|
751
|
+
if (g.innerHTML = "", h && !L) {
|
|
752
|
+
g.classList.remove("catalogue-component-list--flat");
|
|
753
|
+
const m = Y(e);
|
|
754
|
+
if (m.length === 0) {
|
|
755
|
+
const f = document.createElement("div");
|
|
756
|
+
f.className = "catalogue-empty-state", f.textContent = "No components found", g.appendChild(f);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
for (const f of m) {
|
|
760
|
+
const v = Fe(f, e.categories.uncategorisedLabel, a);
|
|
761
|
+
g.appendChild(v);
|
|
762
|
+
}
|
|
763
|
+
} else {
|
|
764
|
+
g.classList.add("catalogue-component-list--flat");
|
|
765
|
+
const m = L ? Ae(e, b, T) : Y(e).flatMap((f) => f.components);
|
|
766
|
+
if (m.length === 0) {
|
|
767
|
+
const f = document.createElement("div");
|
|
768
|
+
f.className = "catalogue-empty-state", f.textContent = "No components found", g.appendChild(f);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
for (const f of m) {
|
|
772
|
+
const v = ce(f, a);
|
|
773
|
+
g.appendChild(v);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
return i.addEventListener("input", () => {
|
|
778
|
+
I();
|
|
779
|
+
}), N.forEach((b) => {
|
|
780
|
+
b.addEventListener("change", I);
|
|
781
|
+
}), $.forEach((b) => {
|
|
782
|
+
b.addEventListener("change", I);
|
|
783
|
+
}), p && p.addEventListener("click", () => {
|
|
784
|
+
const b = p.getAttribute("data-expanded") === "true";
|
|
785
|
+
g.querySelectorAll(".catalogue-category-section").forEach((E) => {
|
|
786
|
+
E.open = !b;
|
|
787
|
+
}), p.setAttribute("data-expanded", String(!b)), p.textContent = b ? "Expand All" : "Collapse All";
|
|
788
|
+
}), I(), {
|
|
789
|
+
root: o,
|
|
790
|
+
searchInput: i,
|
|
791
|
+
filterContainer: c,
|
|
792
|
+
componentList: g
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
function Fe(t, e, a) {
|
|
796
|
+
var d, u;
|
|
797
|
+
const o = document.createElement("details");
|
|
798
|
+
o.className = "catalogue-category-section", o.open = !0;
|
|
799
|
+
const n = document.createElement("summary");
|
|
800
|
+
n.className = "catalogue-category-header";
|
|
801
|
+
const r = ((d = t.category) == null ? void 0 : d.label) ?? e, s = document.createElement("span");
|
|
802
|
+
s.className = "catalogue-category-label", s.textContent = r;
|
|
803
|
+
const i = document.createElement("span");
|
|
804
|
+
i.className = "catalogue-category-count", i.textContent = `(${t.components.length})`, n.appendChild(s), n.appendChild(i), (u = t.category) != null && u.description && (n.title = t.category.description), o.appendChild(n);
|
|
805
|
+
const c = document.createElement("div");
|
|
806
|
+
c.className = "catalogue-category-content";
|
|
807
|
+
for (const h of t.components) {
|
|
808
|
+
const p = ce(h, a);
|
|
809
|
+
c.appendChild(p);
|
|
810
|
+
}
|
|
811
|
+
return o.appendChild(c), o;
|
|
812
|
+
}
|
|
813
|
+
function K(t, e) {
|
|
814
|
+
const a = document.createElement("div");
|
|
815
|
+
a.className = "catalogue-filter-group";
|
|
816
|
+
const o = document.createElement("span");
|
|
817
|
+
o.className = "catalogue-filter-label", o.textContent = t, a.appendChild(o);
|
|
818
|
+
for (const n of e) {
|
|
819
|
+
const r = document.createElement("label");
|
|
820
|
+
r.className = "catalogue-filter-option";
|
|
821
|
+
const s = document.createElement("input");
|
|
822
|
+
s.type = "checkbox", s.value = n.value;
|
|
823
|
+
const i = document.createElement("span");
|
|
824
|
+
i.textContent = n.label, r.appendChild(s), r.appendChild(i), a.appendChild(r);
|
|
825
|
+
}
|
|
826
|
+
return { container: a };
|
|
827
|
+
}
|
|
828
|
+
function ce(t, e) {
|
|
829
|
+
const a = document.createElement("div");
|
|
830
|
+
a.className = "catalogue-component-card", a.setAttribute("data-status", t.status), a.setAttribute("data-kind", t.kind);
|
|
831
|
+
const o = document.createElement("div");
|
|
832
|
+
o.className = "catalogue-component-card-header";
|
|
833
|
+
const n = document.createElement("h3");
|
|
834
|
+
n.className = "catalogue-component-card-title";
|
|
835
|
+
const r = H(`/component/${t.id}`, t.title);
|
|
836
|
+
r.addEventListener("click", (c) => {
|
|
837
|
+
c.preventDefault(), e(`/component/${t.id}`);
|
|
838
|
+
}), n.appendChild(r);
|
|
839
|
+
const s = document.createElement("span");
|
|
840
|
+
if (s.className = "catalogue-status-badge", s.setAttribute("data-status", t.status), s.textContent = t.status, o.appendChild(n), o.appendChild(s), a.appendChild(o), t.description) {
|
|
841
|
+
const c = document.createElement("p");
|
|
842
|
+
c.className = "catalogue-component-card-description", c.textContent = t.description, a.appendChild(c);
|
|
843
|
+
}
|
|
844
|
+
if (t.tags && t.tags.length > 0) {
|
|
845
|
+
const c = document.createElement("div");
|
|
846
|
+
c.className = "catalogue-component-card-tags";
|
|
847
|
+
for (const d of t.tags) {
|
|
848
|
+
const u = document.createElement("span");
|
|
849
|
+
u.className = "catalogue-tag", u.textContent = d, c.appendChild(u);
|
|
850
|
+
}
|
|
851
|
+
a.appendChild(c);
|
|
852
|
+
}
|
|
853
|
+
const i = document.createElement("div");
|
|
854
|
+
return i.className = "catalogue-component-card-meta", i.textContent = `${t.scenarios.length} scenario${t.scenarios.length !== 1 ? "s" : ""}`, a.appendChild(i), a;
|
|
855
|
+
}
|
|
856
|
+
function qe(t, e) {
|
|
857
|
+
t.innerHTML = "";
|
|
858
|
+
const a = Be(e);
|
|
859
|
+
return t.appendChild(a.root), a;
|
|
860
|
+
}
|
|
861
|
+
function Ve(t) {
|
|
862
|
+
const { registry: e, componentId: a, onNavigate: o } = t, n = e.components.get(a);
|
|
863
|
+
if (!n)
|
|
864
|
+
return null;
|
|
865
|
+
const r = document.createElement("div");
|
|
866
|
+
r.className = "catalogue-component-page", r.setAttribute("data-catalogue-root", "");
|
|
867
|
+
const s = document.createElement("nav");
|
|
868
|
+
s.className = "catalogue-breadcrumb", s.setAttribute("aria-label", "Breadcrumb");
|
|
869
|
+
const i = H("/", "Components");
|
|
870
|
+
i.addEventListener("click", (m) => {
|
|
871
|
+
m.preventDefault(), o("/");
|
|
872
|
+
}), s.appendChild(i);
|
|
873
|
+
const c = document.createElement("span");
|
|
874
|
+
if (c.className = "catalogue-breadcrumb-separator", c.textContent = "/", s.appendChild(c), n.parentId) {
|
|
875
|
+
const m = e.components.get(n.parentId);
|
|
876
|
+
if (m) {
|
|
877
|
+
const f = H(`/component/${m.id}`, m.title);
|
|
878
|
+
f.addEventListener("click", (k) => {
|
|
879
|
+
k.preventDefault(), o(`/component/${m.id}`);
|
|
880
|
+
}), s.appendChild(f);
|
|
881
|
+
const v = document.createElement("span");
|
|
882
|
+
v.className = "catalogue-breadcrumb-separator", v.textContent = "/", s.appendChild(v);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
const d = document.createElement("span");
|
|
886
|
+
d.className = "catalogue-breadcrumb-current", d.textContent = n.title, s.appendChild(d), r.appendChild(s);
|
|
887
|
+
const u = document.createElement("header");
|
|
888
|
+
u.className = "catalogue-component-header";
|
|
889
|
+
const h = document.createElement("div");
|
|
890
|
+
h.className = "catalogue-component-title-row";
|
|
891
|
+
const p = document.createElement("h1");
|
|
892
|
+
p.className = "catalogue-component-title", p.textContent = n.title, h.appendChild(p);
|
|
893
|
+
const g = document.createElement("span");
|
|
894
|
+
if (g.className = "catalogue-status-badge", g.setAttribute("data-status", n.status), g.textContent = n.status, h.appendChild(g), u.appendChild(h), n.description) {
|
|
895
|
+
const m = document.createElement("p");
|
|
896
|
+
m.className = "catalogue-component-description", m.textContent = n.description, u.appendChild(m);
|
|
897
|
+
}
|
|
898
|
+
if (n.tags && n.tags.length > 0) {
|
|
899
|
+
const m = document.createElement("div");
|
|
900
|
+
m.className = "catalogue-component-tags";
|
|
901
|
+
for (const f of n.tags) {
|
|
902
|
+
const v = document.createElement("span");
|
|
903
|
+
v.className = "catalogue-tag", v.textContent = f, m.appendChild(v);
|
|
904
|
+
}
|
|
905
|
+
u.appendChild(m);
|
|
906
|
+
}
|
|
907
|
+
const N = document.createElement("div");
|
|
908
|
+
N.className = "catalogue-component-actions";
|
|
909
|
+
const $ = document.createElement("a");
|
|
910
|
+
$.href = `#/playground/${n.id}`, $.className = "catalogue-button catalogue-button-primary", $.textContent = "Open Playground", $.addEventListener("click", (m) => {
|
|
911
|
+
m.preventDefault(), o(`/playground/${n.id}`);
|
|
912
|
+
}), N.appendChild($), u.appendChild(N), r.appendChild(u);
|
|
913
|
+
const I = Le(e, a);
|
|
914
|
+
if (I.length > 0) {
|
|
915
|
+
const m = document.createElement("section");
|
|
916
|
+
m.className = "catalogue-subcomponents-section";
|
|
917
|
+
const f = document.createElement("h2");
|
|
918
|
+
f.textContent = "Subcomponents", m.appendChild(f);
|
|
919
|
+
const v = document.createElement("div");
|
|
920
|
+
v.className = "catalogue-subcomponents-list";
|
|
921
|
+
for (const k of I) {
|
|
922
|
+
const j = document.createElement("div");
|
|
923
|
+
j.className = "catalogue-subcomponent-card";
|
|
924
|
+
const w = H(`/component/${k.id}`, k.title);
|
|
925
|
+
if (w.addEventListener("click", (M) => {
|
|
926
|
+
M.preventDefault(), o(`/component/${k.id}`);
|
|
927
|
+
}), j.appendChild(w), k.description) {
|
|
928
|
+
const M = document.createElement("p");
|
|
929
|
+
M.textContent = k.description, j.appendChild(M);
|
|
930
|
+
}
|
|
931
|
+
v.appendChild(j);
|
|
932
|
+
}
|
|
933
|
+
m.appendChild(v), r.appendChild(m);
|
|
934
|
+
}
|
|
935
|
+
const b = document.createElement("section");
|
|
936
|
+
b.className = "catalogue-variants-section";
|
|
937
|
+
const S = document.createElement("h2");
|
|
938
|
+
S.textContent = "Variants", b.appendChild(S);
|
|
939
|
+
const E = document.createElement("div");
|
|
940
|
+
E.className = "catalogue-variants-grid";
|
|
941
|
+
const T = [...n.scenarios].sort((m, f) => m.id === n.playground.primaryScenarioId ? -1 : f.id === n.playground.primaryScenarioId ? 1 : 0);
|
|
942
|
+
for (const m of T) {
|
|
943
|
+
const f = We(m, n, o);
|
|
944
|
+
E.appendChild(f);
|
|
945
|
+
}
|
|
946
|
+
b.appendChild(E), r.appendChild(b);
|
|
947
|
+
let L = null;
|
|
948
|
+
if (n.docs) {
|
|
949
|
+
L = document.createElement("div"), L.className = "catalogue-docs-section";
|
|
950
|
+
const m = document.createElement("h2");
|
|
951
|
+
m.textContent = "Documentation", L.appendChild(m);
|
|
952
|
+
const f = document.createElement("div");
|
|
953
|
+
f.className = "catalogue-docs-content", f.innerHTML = de.parse(n.docs), L.appendChild(f), r.appendChild(L);
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
root: r,
|
|
957
|
+
header: u,
|
|
958
|
+
variantsGrid: E,
|
|
959
|
+
docsSection: L
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function We(t, e, a) {
|
|
963
|
+
const o = document.createElement("div");
|
|
964
|
+
o.className = "catalogue-scenario-card";
|
|
965
|
+
const n = t.id === e.playground.primaryScenarioId;
|
|
966
|
+
n && o.classList.add("catalogue-scenario-card-primary");
|
|
967
|
+
const r = document.createElement("div");
|
|
968
|
+
r.className = "catalogue-scenario-preview", r.setAttribute("data-catalogue-container", "");
|
|
969
|
+
try {
|
|
970
|
+
ne(t.render, { container: r, clear: !0 });
|
|
971
|
+
} catch (h) {
|
|
972
|
+
const p = document.createElement("div");
|
|
973
|
+
p.className = "catalogue-scenario-error", p.textContent = `Render error: ${h instanceof Error ? h.message : "Unknown error"}`, r.appendChild(p);
|
|
974
|
+
}
|
|
975
|
+
o.appendChild(r);
|
|
976
|
+
const s = document.createElement("div");
|
|
977
|
+
s.className = "catalogue-scenario-info";
|
|
978
|
+
const i = document.createElement("div");
|
|
979
|
+
i.className = "catalogue-scenario-title-row";
|
|
980
|
+
const c = document.createElement("h3");
|
|
981
|
+
if (c.className = "catalogue-scenario-title", c.textContent = t.title, i.appendChild(c), n) {
|
|
982
|
+
const h = document.createElement("span");
|
|
983
|
+
h.className = "catalogue-primary-badge", h.textContent = "Primary", i.appendChild(h);
|
|
984
|
+
}
|
|
985
|
+
if (s.appendChild(i), t.description) {
|
|
986
|
+
const h = document.createElement("p");
|
|
987
|
+
h.className = "catalogue-scenario-description", h.textContent = t.description, s.appendChild(h);
|
|
988
|
+
}
|
|
989
|
+
const d = document.createElement("div");
|
|
990
|
+
d.className = "catalogue-scenario-links";
|
|
991
|
+
const u = document.createElement("a");
|
|
992
|
+
return u.href = `#/harness/${t.id}`, u.className = "catalogue-link", u.textContent = "Harness", u.addEventListener("click", (h) => {
|
|
993
|
+
h.preventDefault(), a(`/harness/${t.id}`);
|
|
994
|
+
}), d.appendChild(u), s.appendChild(d), o.appendChild(s), o;
|
|
995
|
+
}
|
|
996
|
+
function Ue(t, e) {
|
|
997
|
+
t.innerHTML = "";
|
|
998
|
+
const a = Ve(e);
|
|
999
|
+
if (!a) {
|
|
1000
|
+
const o = document.createElement("div");
|
|
1001
|
+
return o.className = "catalogue-not-found", o.textContent = `Component "${e.componentId}" not found`, t.appendChild(o), null;
|
|
1002
|
+
}
|
|
1003
|
+
return t.appendChild(a.root), a;
|
|
1004
|
+
}
|
|
1005
|
+
function W(t, e = {}) {
|
|
1006
|
+
const { indent: a = " ", includeScript: o = !0, elementId: n } = e, r = [], s = [];
|
|
1007
|
+
if (B(t, r, s, "", a, n), o && s.length > 0) {
|
|
1008
|
+
r.push(""), r.push('<script type="module">');
|
|
1009
|
+
const i = n ? `#${n}` : t.element;
|
|
1010
|
+
r.push(`${a}const el = document.querySelector('${i}');`);
|
|
1011
|
+
for (const { key: c, value: d } of s) {
|
|
1012
|
+
const u = JSON.stringify(d);
|
|
1013
|
+
r.push(`${a}el.${c} = ${u};`);
|
|
1014
|
+
}
|
|
1015
|
+
r.push("<\/script>");
|
|
1016
|
+
}
|
|
1017
|
+
return r.join(`
|
|
1018
|
+
`);
|
|
1019
|
+
}
|
|
1020
|
+
function B(t, e, a, o, n, r) {
|
|
1021
|
+
var u, h;
|
|
1022
|
+
let s = `<${t.element}`;
|
|
1023
|
+
if (r && (s += ` id="${U(r)}"`), t.attrs)
|
|
1024
|
+
for (const [p, g] of Object.entries(t.attrs))
|
|
1025
|
+
g != null && (typeof g == "boolean" ? g && (s += ` ${p}`) : s += ` ${p}="${U(String(g))}"`);
|
|
1026
|
+
if (t.props)
|
|
1027
|
+
for (const [p, g] of Object.entries(t.props))
|
|
1028
|
+
a.push({ key: p, value: g });
|
|
1029
|
+
if (!(t.text !== void 0 || ((u = t.children) == null ? void 0 : u.length) || t.slots && Object.keys(t.slots).length > 0) && (/* @__PURE__ */ new Set([
|
|
1030
|
+
"area",
|
|
1031
|
+
"base",
|
|
1032
|
+
"br",
|
|
1033
|
+
"col",
|
|
1034
|
+
"embed",
|
|
1035
|
+
"hr",
|
|
1036
|
+
"img",
|
|
1037
|
+
"input",
|
|
1038
|
+
"link",
|
|
1039
|
+
"meta",
|
|
1040
|
+
"param",
|
|
1041
|
+
"source",
|
|
1042
|
+
"track",
|
|
1043
|
+
"wbr"
|
|
1044
|
+
])).has(t.element)) {
|
|
1045
|
+
e.push(`${o}${s} />`);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
if (s += ">", t.text !== void 0 && !((h = t.children) != null && h.length) && !t.slots) {
|
|
1049
|
+
e.push(`${o}${s}${F(t.text)}</${t.element}>`);
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
e.push(`${o}${s}`);
|
|
1053
|
+
const d = o + n;
|
|
1054
|
+
if (t.text !== void 0 && e.push(`${d}${F(t.text)}`), t.slots)
|
|
1055
|
+
for (const [p, g] of Object.entries(t.slots))
|
|
1056
|
+
Je(g, p, e, a, d, n);
|
|
1057
|
+
if (t.children)
|
|
1058
|
+
for (const p of t.children)
|
|
1059
|
+
B(p, e, a, d, n);
|
|
1060
|
+
e.push(`${o}</${t.element}>`);
|
|
1061
|
+
}
|
|
1062
|
+
function Je(t, e, a, o, n, r) {
|
|
1063
|
+
if (typeof t == "string")
|
|
1064
|
+
e === "default" ? a.push(`${n}${F(t)}`) : a.push(`${n}<span slot="${U(e)}">${F(t)}</span>`);
|
|
1065
|
+
else if (Array.isArray(t))
|
|
1066
|
+
for (const s of t) {
|
|
1067
|
+
const i = e === "default" ? s : X(s, e);
|
|
1068
|
+
B(i, a, o, n, r);
|
|
1069
|
+
}
|
|
1070
|
+
else {
|
|
1071
|
+
const s = e === "default" ? t : X(t, e);
|
|
1072
|
+
B(s, a, o, n, r);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
function X(t, e) {
|
|
1076
|
+
return {
|
|
1077
|
+
...t,
|
|
1078
|
+
attrs: {
|
|
1079
|
+
...t.attrs,
|
|
1080
|
+
slot: e
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
function F(t) {
|
|
1085
|
+
return t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1086
|
+
}
|
|
1087
|
+
function U(t) {
|
|
1088
|
+
return t.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
1089
|
+
}
|
|
1090
|
+
function Nt(t, e = {}) {
|
|
1091
|
+
return W(t, { ...e, includeScript: !1 });
|
|
1092
|
+
}
|
|
1093
|
+
function $t(t, e, a = {}) {
|
|
1094
|
+
const { indent: o = " " } = a;
|
|
1095
|
+
if (!t.props || Object.keys(t.props).length === 0)
|
|
1096
|
+
return null;
|
|
1097
|
+
const n = [];
|
|
1098
|
+
n.push(`const el = document.querySelector('${e}');`);
|
|
1099
|
+
for (const [r, s] of Object.entries(t.props)) {
|
|
1100
|
+
const i = JSON.stringify(s);
|
|
1101
|
+
n.push(`el.${r} = ${i};`);
|
|
1102
|
+
}
|
|
1103
|
+
return n.map((r) => `${o}${r}`).join(`
|
|
1104
|
+
`);
|
|
1105
|
+
}
|
|
1106
|
+
function Ye(t) {
|
|
1107
|
+
const { component: e, values: a, onChange: o } = t, n = document.createElement("div");
|
|
1108
|
+
n.className = "catalogue-controls";
|
|
1109
|
+
const r = /* @__PURE__ */ new Map();
|
|
1110
|
+
for (const [s, i] of Object.entries(e.playground.controls)) {
|
|
1111
|
+
const c = Ke(s, i, a[s], (d) => {
|
|
1112
|
+
o(s, d);
|
|
1113
|
+
});
|
|
1114
|
+
r.set(s, c.wrapper), n.appendChild(c.wrapper);
|
|
1115
|
+
}
|
|
1116
|
+
return { container: n, controls: r };
|
|
1117
|
+
}
|
|
1118
|
+
function Ke(t, e, a, o) {
|
|
1119
|
+
const n = document.createElement("div");
|
|
1120
|
+
n.className = "catalogue-control", n.setAttribute("data-control-type", e.type);
|
|
1121
|
+
const r = document.createElement("label");
|
|
1122
|
+
r.className = "catalogue-control-label", r.textContent = e.label || t, n.appendChild(r);
|
|
1123
|
+
let s;
|
|
1124
|
+
switch (e.type) {
|
|
1125
|
+
case "text":
|
|
1126
|
+
s = Xe(t, e, a, o);
|
|
1127
|
+
break;
|
|
1128
|
+
case "number":
|
|
1129
|
+
s = Ge(t, e, a, o);
|
|
1130
|
+
break;
|
|
1131
|
+
case "boolean":
|
|
1132
|
+
s = _e(t, e, a, o);
|
|
1133
|
+
break;
|
|
1134
|
+
case "select":
|
|
1135
|
+
s = Qe(t, e, a, o);
|
|
1136
|
+
break;
|
|
1137
|
+
case "radio":
|
|
1138
|
+
s = Ze(t, e, a, o);
|
|
1139
|
+
break;
|
|
1140
|
+
case "color":
|
|
1141
|
+
s = et(t, e, a, o);
|
|
1142
|
+
break;
|
|
1143
|
+
case "range":
|
|
1144
|
+
s = tt(t, e, a, o);
|
|
1145
|
+
break;
|
|
1146
|
+
case "json":
|
|
1147
|
+
s = nt(t, e, a, o);
|
|
1148
|
+
break;
|
|
1149
|
+
default:
|
|
1150
|
+
s = document.createElement("span"), s.textContent = "Unknown control type";
|
|
1151
|
+
}
|
|
1152
|
+
return n.appendChild(s), { wrapper: n, input: s };
|
|
1153
|
+
}
|
|
1154
|
+
function Xe(t, e, a, o) {
|
|
1155
|
+
const n = document.createElement("input");
|
|
1156
|
+
return n.type = "text", n.className = "catalogue-control-input", n.name = t, n.value = a ?? e.defaultValue ?? "", e.placeholder && (n.placeholder = e.placeholder), n.addEventListener("input", () => {
|
|
1157
|
+
o(n.value);
|
|
1158
|
+
}), n;
|
|
1159
|
+
}
|
|
1160
|
+
function Ge(t, e, a, o) {
|
|
1161
|
+
const n = document.createElement("input");
|
|
1162
|
+
return n.type = "number", n.className = "catalogue-control-input", n.name = t, n.value = String(a ?? e.defaultValue ?? 0), e.min !== void 0 && (n.min = String(e.min)), e.max !== void 0 && (n.max = String(e.max)), e.step !== void 0 && (n.step = String(e.step)), n.addEventListener("input", () => {
|
|
1163
|
+
o(parseFloat(n.value) || 0);
|
|
1164
|
+
}), n;
|
|
1165
|
+
}
|
|
1166
|
+
function _e(t, e, a, o) {
|
|
1167
|
+
const n = document.createElement("div");
|
|
1168
|
+
n.className = "catalogue-control-checkbox";
|
|
1169
|
+
const r = document.createElement("input");
|
|
1170
|
+
return r.type = "checkbox", r.className = "catalogue-control-checkbox-input", r.name = t, r.checked = a ?? e.defaultValue ?? !1, r.addEventListener("change", () => {
|
|
1171
|
+
o(r.checked);
|
|
1172
|
+
}), n.appendChild(r), n;
|
|
1173
|
+
}
|
|
1174
|
+
function Qe(t, e, a, o) {
|
|
1175
|
+
const n = document.createElement("select");
|
|
1176
|
+
n.className = "catalogue-control-select", n.name = t;
|
|
1177
|
+
for (const r of e.options) {
|
|
1178
|
+
const s = document.createElement("option");
|
|
1179
|
+
typeof r == "string" ? (s.value = r, s.textContent = r) : (s.value = r.value, s.textContent = r.label), n.appendChild(s);
|
|
1180
|
+
}
|
|
1181
|
+
return n.value = a ?? e.defaultValue ?? "", n.addEventListener("change", () => {
|
|
1182
|
+
o(n.value);
|
|
1183
|
+
}), n;
|
|
1184
|
+
}
|
|
1185
|
+
function Ze(t, e, a, o) {
|
|
1186
|
+
const n = document.createElement("div");
|
|
1187
|
+
n.className = "catalogue-control-radio-group";
|
|
1188
|
+
const r = a ?? e.defaultValue;
|
|
1189
|
+
for (const s of e.options) {
|
|
1190
|
+
const i = document.createElement("label");
|
|
1191
|
+
i.className = "catalogue-control-radio";
|
|
1192
|
+
const c = document.createElement("input");
|
|
1193
|
+
c.type = "radio", c.name = t;
|
|
1194
|
+
const d = typeof s == "string" ? s : s.value, u = typeof s == "string" ? s : s.label;
|
|
1195
|
+
c.value = d, c.checked = d === r, c.addEventListener("change", () => {
|
|
1196
|
+
c.checked && o(c.value);
|
|
1197
|
+
});
|
|
1198
|
+
const h = document.createElement("span");
|
|
1199
|
+
h.textContent = u, i.appendChild(c), i.appendChild(h), n.appendChild(i);
|
|
1200
|
+
}
|
|
1201
|
+
return n;
|
|
1202
|
+
}
|
|
1203
|
+
function et(t, e, a, o) {
|
|
1204
|
+
const n = document.createElement("input");
|
|
1205
|
+
return n.type = "color", n.className = "catalogue-control-color", n.name = t, n.value = a ?? e.defaultValue ?? "#000000", n.addEventListener("input", () => {
|
|
1206
|
+
o(n.value);
|
|
1207
|
+
}), n;
|
|
1208
|
+
}
|
|
1209
|
+
function tt(t, e, a, o) {
|
|
1210
|
+
const n = document.createElement("div");
|
|
1211
|
+
n.className = "catalogue-control-range-wrapper";
|
|
1212
|
+
const r = document.createElement("input");
|
|
1213
|
+
r.type = "range", r.className = "catalogue-control-range", r.name = t, r.min = String(e.min), r.max = String(e.max), e.step !== void 0 && (r.step = String(e.step)), r.value = String(a ?? e.defaultValue ?? e.min);
|
|
1214
|
+
const s = document.createElement("span");
|
|
1215
|
+
return s.className = "catalogue-control-range-value", s.textContent = r.value, r.addEventListener("input", () => {
|
|
1216
|
+
s.textContent = r.value, o(parseFloat(r.value));
|
|
1217
|
+
}), n.appendChild(r), n.appendChild(s), n;
|
|
1218
|
+
}
|
|
1219
|
+
function nt(t, e, a, o) {
|
|
1220
|
+
const n = document.createElement("textarea");
|
|
1221
|
+
n.className = "catalogue-control-json", n.name = t, n.rows = 4;
|
|
1222
|
+
const r = a ?? e.defaultValue;
|
|
1223
|
+
return n.value = r !== void 0 ? JSON.stringify(r, null, 2) : "", n.addEventListener("input", () => {
|
|
1224
|
+
try {
|
|
1225
|
+
const s = JSON.parse(n.value);
|
|
1226
|
+
n.classList.remove("invalid"), o(s);
|
|
1227
|
+
} catch {
|
|
1228
|
+
n.classList.add("invalid");
|
|
1229
|
+
}
|
|
1230
|
+
}), n;
|
|
1231
|
+
}
|
|
1232
|
+
function at(t) {
|
|
1233
|
+
const { registry: e, componentId: a, onNavigate: o } = t, n = e.components.get(a);
|
|
1234
|
+
if (!n)
|
|
1235
|
+
return null;
|
|
1236
|
+
const r = n.scenarios.find(
|
|
1237
|
+
(C) => C.id === n.playground.primaryScenarioId
|
|
1238
|
+
);
|
|
1239
|
+
if (!r)
|
|
1240
|
+
return null;
|
|
1241
|
+
re();
|
|
1242
|
+
const s = document.createElement("div");
|
|
1243
|
+
s.className = "catalogue-playground", s.setAttribute("data-catalogue-root", "");
|
|
1244
|
+
const i = document.createElement("header");
|
|
1245
|
+
i.className = "catalogue-playground-header";
|
|
1246
|
+
const c = document.createElement("nav");
|
|
1247
|
+
c.className = "catalogue-breadcrumb";
|
|
1248
|
+
const d = H("/", "Components");
|
|
1249
|
+
d.addEventListener("click", (C) => {
|
|
1250
|
+
C.preventDefault(), o("/");
|
|
1251
|
+
}), c.appendChild(d);
|
|
1252
|
+
const u = document.createElement("span");
|
|
1253
|
+
u.className = "catalogue-breadcrumb-separator", u.textContent = "/", c.appendChild(u);
|
|
1254
|
+
const h = H(`/component/${n.id}`, n.title);
|
|
1255
|
+
h.addEventListener("click", (C) => {
|
|
1256
|
+
C.preventDefault(), o(`/component/${n.id}`);
|
|
1257
|
+
}), c.appendChild(h);
|
|
1258
|
+
const p = document.createElement("span");
|
|
1259
|
+
p.className = "catalogue-breadcrumb-separator", p.textContent = "/", c.appendChild(p);
|
|
1260
|
+
const g = document.createElement("span");
|
|
1261
|
+
g.className = "catalogue-breadcrumb-current", g.textContent = "Playground", c.appendChild(g), i.appendChild(c);
|
|
1262
|
+
const N = document.createElement("div");
|
|
1263
|
+
N.className = "catalogue-playground-title-row";
|
|
1264
|
+
const $ = document.createElement("h1");
|
|
1265
|
+
$.textContent = `${n.title} Playground`, N.appendChild($);
|
|
1266
|
+
const I = se();
|
|
1267
|
+
N.appendChild(I), i.appendChild(N), s.appendChild(i);
|
|
1268
|
+
const b = document.createElement("div");
|
|
1269
|
+
b.className = "catalogue-playground-main";
|
|
1270
|
+
const S = document.createElement("div");
|
|
1271
|
+
if (S.className = "catalogue-playground-preview-section", n.scenarios.length > 1) {
|
|
1272
|
+
const C = document.createElement("div");
|
|
1273
|
+
C.className = "catalogue-scenario-selector";
|
|
1274
|
+
const x = document.createElement("label");
|
|
1275
|
+
x.textContent = "Scenario: ";
|
|
1276
|
+
const A = document.createElement("select");
|
|
1277
|
+
A.className = "catalogue-scenario-select";
|
|
1278
|
+
for (const P of n.scenarios) {
|
|
1279
|
+
const z = document.createElement("option");
|
|
1280
|
+
z.value = P.id, z.textContent = P.title, P.id === r.id && (z.selected = !0), A.appendChild(z);
|
|
1281
|
+
}
|
|
1282
|
+
x.appendChild(A), C.appendChild(x), S.appendChild(C), A.addEventListener("change", () => {
|
|
1283
|
+
const P = n.scenarios.find((z) => z.id === A.value);
|
|
1284
|
+
P && (w = structuredClone(P.render), O(), q());
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
const E = ze({
|
|
1288
|
+
initialWidth: "100%",
|
|
1289
|
+
initialHeight: "400px",
|
|
1290
|
+
onResize: (C, x) => {
|
|
1291
|
+
},
|
|
1292
|
+
onFullScreenChange: (C) => {
|
|
1293
|
+
s.classList.toggle("catalogue-playground-fullscreen", C);
|
|
1294
|
+
}
|
|
1295
|
+
}), T = He(E);
|
|
1296
|
+
S.appendChild(T), S.appendChild(E.wrapper), b.appendChild(S);
|
|
1297
|
+
const L = document.createElement("div");
|
|
1298
|
+
L.className = "catalogue-playground-sidebar";
|
|
1299
|
+
const m = document.createElement("div");
|
|
1300
|
+
m.className = "catalogue-playground-controls-section";
|
|
1301
|
+
const f = document.createElement("h2");
|
|
1302
|
+
f.textContent = "Controls", m.appendChild(f);
|
|
1303
|
+
const v = document.createElement("div");
|
|
1304
|
+
v.className = "catalogue-controls-container", m.appendChild(v), L.appendChild(m);
|
|
1305
|
+
const k = document.createElement("div");
|
|
1306
|
+
k.className = "catalogue-playground-code-section";
|
|
1307
|
+
const j = Re({
|
|
1308
|
+
code: W(r.render),
|
|
1309
|
+
title: "HTML",
|
|
1310
|
+
collapsible: !0,
|
|
1311
|
+
collapsed: !1
|
|
1312
|
+
});
|
|
1313
|
+
k.appendChild(j.wrapper), L.appendChild(k), b.appendChild(L), s.appendChild(b);
|
|
1314
|
+
let w = structuredClone(r.render), M = null;
|
|
1315
|
+
const O = () => {
|
|
1316
|
+
E.content.innerHTML = "";
|
|
1317
|
+
try {
|
|
1318
|
+
M = D(w), E.content.appendChild(M);
|
|
1319
|
+
} catch (C) {
|
|
1320
|
+
const x = document.createElement("div");
|
|
1321
|
+
x.className = "catalogue-render-error", x.textContent = `Error: ${C instanceof Error ? C.message : "Unknown error"}`, E.content.appendChild(x), M = null;
|
|
1322
|
+
}
|
|
1323
|
+
}, q = () => {
|
|
1324
|
+
const C = W(w);
|
|
1325
|
+
De(j, C);
|
|
1326
|
+
}, y = Ye({
|
|
1327
|
+
component: n,
|
|
1328
|
+
values: ot(n, w),
|
|
1329
|
+
onChange: (C, x) => {
|
|
1330
|
+
w.attrs || (w.attrs = {});
|
|
1331
|
+
const A = n.playground.controls[C];
|
|
1332
|
+
A && (A.type === "json" ? (w.props || (w.props = {}), w.props[C] = x) : A.type === "boolean" ? x ? w.attrs[C] = !0 : delete w.attrs[C] : w.attrs[C] = x), M ? ae(M, w.attrs, w.props) : O(), q();
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
return v.appendChild(y.container), O(), {
|
|
1336
|
+
root: s,
|
|
1337
|
+
preview: E.content,
|
|
1338
|
+
controls: v,
|
|
1339
|
+
codePanel: k
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
function ot(t, e) {
|
|
1343
|
+
const a = {};
|
|
1344
|
+
for (const [o, n] of Object.entries(t.playground.controls))
|
|
1345
|
+
e.attrs && o in e.attrs ? a[o] = e.attrs[o] : e.props && o in e.props ? a[o] = e.props[o] : "defaultValue" in n && (a[o] = n.defaultValue);
|
|
1346
|
+
return a;
|
|
1347
|
+
}
|
|
1348
|
+
function rt(t, e) {
|
|
1349
|
+
t.innerHTML = "";
|
|
1350
|
+
const a = at(e);
|
|
1351
|
+
if (!a) {
|
|
1352
|
+
const o = document.createElement("div");
|
|
1353
|
+
return o.className = "catalogue-not-found", o.textContent = `Component "${e.componentId}" not found or missing primary scenario`, t.appendChild(o), null;
|
|
1354
|
+
}
|
|
1355
|
+
return t.appendChild(a.root), a;
|
|
1356
|
+
}
|
|
1357
|
+
function st(t) {
|
|
1358
|
+
const { registry: e, scenarioId: a, query: o } = t, n = e.scenarios.get(a);
|
|
1359
|
+
if (!n)
|
|
1360
|
+
return null;
|
|
1361
|
+
const r = o.get("theme") || "light", s = o.get("w") ? parseInt(o.get("w"), 10) : void 0, i = o.get("h") ? parseInt(o.get("h"), 10) : void 0, c = o.get("bg") || n.background;
|
|
1362
|
+
J(r);
|
|
1363
|
+
const d = document.createElement("div");
|
|
1364
|
+
d.className = "catalogue-harness", d.setAttribute("data-catalogue-root", ""), d.setAttribute("data-theme", r);
|
|
1365
|
+
const u = document.createElement("div");
|
|
1366
|
+
u.className = "catalogue-harness-container", u.setAttribute("data-catalogue-container", ""), u.setAttribute("data-theme", r), s !== void 0 && (u.style.width = `${s}px`), i !== void 0 && (u.style.height = `${i}px`), c && (u.style.backgroundColor = c), !s && !i && n.viewport && (n.viewport.width && (u.style.width = `${n.viewport.width}px`), n.viewport.height && (u.style.height = `${n.viewport.height}px`));
|
|
1367
|
+
try {
|
|
1368
|
+
ne(n.render, { container: u, clear: !0 });
|
|
1369
|
+
} catch (h) {
|
|
1370
|
+
const p = document.createElement("div");
|
|
1371
|
+
p.setAttribute("data-catalogue-error", ""), p.style.cssText = "color: red; padding: 1em; font-family: monospace;", p.textContent = `Render error: ${h instanceof Error ? h.message : "Unknown error"}`, u.appendChild(p);
|
|
1372
|
+
}
|
|
1373
|
+
return d.appendChild(u), {
|
|
1374
|
+
root: d,
|
|
1375
|
+
container: u
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
function G(t, e) {
|
|
1379
|
+
t.innerHTML = "", document.body.classList.add("catalogue-harness-body");
|
|
1380
|
+
const a = st(e);
|
|
1381
|
+
if (!a) {
|
|
1382
|
+
const o = document.createElement("div");
|
|
1383
|
+
return o.className = "catalogue-not-found", o.setAttribute("data-catalogue-error", ""), o.textContent = `Scenario "${e.scenarioId}" not found`, t.appendChild(o), null;
|
|
1384
|
+
}
|
|
1385
|
+
return t.appendChild(a.root), a;
|
|
1386
|
+
}
|
|
1387
|
+
function _(t, e) {
|
|
1388
|
+
const a = new URLSearchParams();
|
|
1389
|
+
e != null && e.theme && a.set("theme", e.theme), (e == null ? void 0 : e.width) !== void 0 && a.set("w", String(e.width)), (e == null ? void 0 : e.height) !== void 0 && a.set("h", String(e.height)), e != null && e.background && a.set("bg", e.background);
|
|
1390
|
+
const o = a.toString();
|
|
1391
|
+
return `/harness/${t}${o ? `?${o}` : ""}`;
|
|
1392
|
+
}
|
|
1393
|
+
function St(t, e) {
|
|
1394
|
+
const a = [], o = ["light", "dark"], n = e || [
|
|
1395
|
+
{ width: 375, height: 667 },
|
|
1396
|
+
// Mobile
|
|
1397
|
+
{ width: 1024, height: 768 }
|
|
1398
|
+
// Desktop
|
|
1399
|
+
];
|
|
1400
|
+
for (const [r, s] of t.scenarios) {
|
|
1401
|
+
for (const i of o)
|
|
1402
|
+
a.push({
|
|
1403
|
+
scenarioId: r,
|
|
1404
|
+
componentId: s.componentId,
|
|
1405
|
+
url: _(r, { theme: i }),
|
|
1406
|
+
theme: i
|
|
1407
|
+
});
|
|
1408
|
+
for (const i of n)
|
|
1409
|
+
for (const c of o)
|
|
1410
|
+
a.push({
|
|
1411
|
+
scenarioId: r,
|
|
1412
|
+
componentId: s.componentId,
|
|
1413
|
+
url: _(r, {
|
|
1414
|
+
theme: c,
|
|
1415
|
+
width: i.width,
|
|
1416
|
+
height: i.height
|
|
1417
|
+
}),
|
|
1418
|
+
theme: c,
|
|
1419
|
+
width: i.width,
|
|
1420
|
+
height: i.height
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
return a;
|
|
1424
|
+
}
|
|
1425
|
+
function ct(t) {
|
|
1426
|
+
const { container: e, registry: a, basePath: o = "" } = t;
|
|
1427
|
+
re();
|
|
1428
|
+
const n = new Oe({
|
|
1429
|
+
basePath: o,
|
|
1430
|
+
root: e,
|
|
1431
|
+
onNotFound: (s) => {
|
|
1432
|
+
e.innerHTML = "";
|
|
1433
|
+
const i = document.createElement("div");
|
|
1434
|
+
i.className = "catalogue-not-found", i.innerHTML = `
|
|
1435
|
+
<h1>Page Not Found</h1>
|
|
1436
|
+
<p>The page "${s}" does not exist.</p>
|
|
1437
|
+
<a href="#/">Back to Components</a>
|
|
1438
|
+
`, e.appendChild(i);
|
|
1439
|
+
}
|
|
1440
|
+
}), r = (s) => {
|
|
1441
|
+
n.navigate(s);
|
|
1442
|
+
};
|
|
1443
|
+
return n.route("/", () => {
|
|
1444
|
+
qe(e, { registry: a, onNavigate: r }), Q(e, r);
|
|
1445
|
+
}), n.route("/component/:componentId", (s) => {
|
|
1446
|
+
Ue(e, {
|
|
1447
|
+
registry: a,
|
|
1448
|
+
componentId: s.componentId,
|
|
1449
|
+
onNavigate: r
|
|
1450
|
+
}), Q(e, r);
|
|
1451
|
+
}), n.route("/playground/:componentId", (s) => {
|
|
1452
|
+
rt(e, {
|
|
1453
|
+
registry: a,
|
|
1454
|
+
componentId: s.componentId,
|
|
1455
|
+
onNavigate: r
|
|
1456
|
+
});
|
|
1457
|
+
}), n.route("/harness/:scenarioId", (s, i) => {
|
|
1458
|
+
G(e, {
|
|
1459
|
+
registry: a,
|
|
1460
|
+
scenarioId: s.scenarioId,
|
|
1461
|
+
query: i
|
|
1462
|
+
});
|
|
1463
|
+
}), n.route("/example/:exampleId", (s, i) => {
|
|
1464
|
+
const c = a.examples.get(s.exampleId);
|
|
1465
|
+
c ? G(e, {
|
|
1466
|
+
registry: {
|
|
1467
|
+
...a,
|
|
1468
|
+
scenarios: /* @__PURE__ */ new Map([[c.id, { ...c, filePath: c.filePath }]])
|
|
1469
|
+
},
|
|
1470
|
+
scenarioId: s.exampleId,
|
|
1471
|
+
query: i
|
|
1472
|
+
}) : n.navigate("/");
|
|
1473
|
+
}), {
|
|
1474
|
+
router: n,
|
|
1475
|
+
start: () => n.start(),
|
|
1476
|
+
navigate: r,
|
|
1477
|
+
registry: a
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
function Q(t, e) {
|
|
1481
|
+
if (t.querySelector(".catalogue-global-header"))
|
|
1482
|
+
return;
|
|
1483
|
+
const o = t.querySelector("[data-catalogue-root]");
|
|
1484
|
+
if (!o)
|
|
1485
|
+
return;
|
|
1486
|
+
const n = document.createElement("div");
|
|
1487
|
+
n.className = "catalogue-global-header";
|
|
1488
|
+
const r = document.createElement("a");
|
|
1489
|
+
r.href = "#/", r.className = "catalogue-home-link", r.textContent = "Component Catalogue", r.addEventListener("click", (i) => {
|
|
1490
|
+
i.preventDefault(), e("/");
|
|
1491
|
+
}), n.appendChild(r);
|
|
1492
|
+
const s = se();
|
|
1493
|
+
n.appendChild(s), o.insertBefore(n, o.firstChild);
|
|
1494
|
+
}
|
|
1495
|
+
function kt(t, e, a) {
|
|
1496
|
+
const o = document.querySelector(t);
|
|
1497
|
+
if (!o)
|
|
1498
|
+
throw new Error(`Container element not found: ${t}`);
|
|
1499
|
+
const n = ct({
|
|
1500
|
+
container: o,
|
|
1501
|
+
registry: e,
|
|
1502
|
+
...a
|
|
1503
|
+
});
|
|
1504
|
+
return n.start(), n;
|
|
1505
|
+
}
|
|
1506
|
+
export {
|
|
1507
|
+
xe as ComponentExportsSchema,
|
|
1508
|
+
Ee as ComponentKindSchema,
|
|
1509
|
+
Ne as ComponentSchema,
|
|
1510
|
+
ye as ComponentStatusSchema,
|
|
1511
|
+
Z as ControlSpecSchema,
|
|
1512
|
+
Me as DEFAULT_BREAKPOINTS,
|
|
1513
|
+
ht as ExampleSchema,
|
|
1514
|
+
we as PlaygroundConfigSchema,
|
|
1515
|
+
R as RenderNodeSchema,
|
|
1516
|
+
Oe as Router,
|
|
1517
|
+
ee as ScenarioSchema,
|
|
1518
|
+
yt as applyNodeToElement,
|
|
1519
|
+
He as createBreakpointPresets,
|
|
1520
|
+
ct as createCatalogueApp,
|
|
1521
|
+
Re as createCodePanel,
|
|
1522
|
+
Ve as createComponentPage,
|
|
1523
|
+
Ye as createControls,
|
|
1524
|
+
Ct as createEmptyRegistry,
|
|
1525
|
+
st as createHarnessPage,
|
|
1526
|
+
Be as createLandingPage,
|
|
1527
|
+
H as createNavLink,
|
|
1528
|
+
at as createPlaygroundPage,
|
|
1529
|
+
ze as createResizer,
|
|
1530
|
+
se as createThemeToggle,
|
|
1531
|
+
mt as formatComponentErrors,
|
|
1532
|
+
xt as formatHtml,
|
|
1533
|
+
gt as formatScenarioErrors,
|
|
1534
|
+
vt as formatValidationErrors,
|
|
1535
|
+
W as generateHtml,
|
|
1536
|
+
Nt as generateHtmlOnly,
|
|
1537
|
+
$t as generatePropsScript,
|
|
1538
|
+
St as getAllHarnessUrls,
|
|
1539
|
+
Y as getComponentsByCategory,
|
|
1540
|
+
_ as getHarnessUrl,
|
|
1541
|
+
Pe as getInitialTheme,
|
|
1542
|
+
ke as getStandaloneComponents,
|
|
1543
|
+
Le as getSubcomponents,
|
|
1544
|
+
re as initTheme,
|
|
1545
|
+
ft as loadRegistry,
|
|
1546
|
+
kt as mountCatalogueApp,
|
|
1547
|
+
wt as parseRouteParams,
|
|
1548
|
+
ne as render,
|
|
1549
|
+
Ue as renderComponentPage,
|
|
1550
|
+
G as renderHarnessPage,
|
|
1551
|
+
qe as renderLandingPage,
|
|
1552
|
+
D as renderNode,
|
|
1553
|
+
rt as renderPlaygroundPage,
|
|
1554
|
+
Ae as searchComponents,
|
|
1555
|
+
Et as setResizerDimensions,
|
|
1556
|
+
J as setTheme,
|
|
1557
|
+
Te as toggleTheme,
|
|
1558
|
+
De as updateCodePanel,
|
|
1559
|
+
ae as updateElement,
|
|
1560
|
+
$e as validateComponent,
|
|
1561
|
+
pt as validateControlSpec,
|
|
1562
|
+
Se as validateExample,
|
|
1563
|
+
bt as validateRegistry,
|
|
1564
|
+
ut as validateRenderNode,
|
|
1565
|
+
te as validateScenario
|
|
1566
|
+
};
|
|
1567
|
+
//# sourceMappingURL=index.js.map
|