kss-modern 1.7.0-beta.1 → 1.7.0-beta.3

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.
@@ -3,16 +3,13 @@ import process from 'node:process';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import fs from 'fs-extra';
5
5
  import { glob } from 'tinyglobby';
6
- import { l as logger, s as sanitizeSpecialCharacters, P as PUG_ERROR_OVERLAY_TAG, r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, p as pugErrorFile, a as compileMarkup, g as getZodVersion, M as MIXIN_COMPILE_OPTIONS, b as getMixinWrapperSource, d as slugify, I as INSERT_VITE_PUG_TAG_RE, f as PUG_SRC_RE, t as themeClassList, h as ensureStartingSlash, i as sectionSanitizeId, j as stripPugErrorOverlay, k as generateId, m as replaceWrapperContent, n as formatSourceCode, o as htmlToSearchText } from '../shared/kss-modern.D1AKakeJ.mjs';
7
- export { q as createLogger } from '../shared/kss-modern.D1AKakeJ.mjs';
6
+ import { l as logger, s as sanitizeSpecialCharacters, P as PUG_ERROR_OVERLAY_TAG, r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, p as pugErrorFile, a as compileMarkup, g as getZodVersion, d as discoverMixins, M as MIXIN_COMPILE_OPTIONS, b as getMixinWrapperSource, f as slugify, I as INSERT_VITE_PUG_TAG_RE, h as PUG_SRC_RE, t as themeClassList, i as ensureStartingSlash, j as sectionSanitizeId, k as stripPugErrorOverlay, m as generateId, n as replaceWrapperContent, o as formatSourceCode, q as htmlToSearchText } from '../shared/kss-modern.tLBfjOgj.mjs';
7
+ export { u as createLogger } from '../shared/kss-modern.tLBfjOgj.mjs';
8
8
  import { existsSync, readFileSync } from 'node:fs';
9
9
  import fs$1 from 'node:fs/promises';
10
10
  import { createHash } from 'node:crypto';
11
11
  import os from 'node:os';
12
12
  import { Worker } from 'node:worker_threads';
13
- import lex from 'pug-lexer';
14
- import parse$1 from 'pug-parser';
15
- import walk from 'pug-walk';
16
13
  import htmlLang from '@shikijs/langs/html';
17
14
  import markdownLang from '@shikijs/langs/markdown';
18
15
  import scssLang from '@shikijs/langs/scss';
@@ -30,6 +27,9 @@ import 'pug';
30
27
  import 'consola';
31
28
  import 'consola/utils';
32
29
  import 'node:module';
30
+ import 'pug-walk';
31
+ import 'pug-lexer';
32
+ import 'pug-parser';
33
33
  import 'pug-load';
34
34
 
35
35
  const HEX_COLOR_RE = /^#[0-9A-F]{6}$/i;
@@ -586,42 +586,6 @@ async function logicalWriteFile(filepath, content) {
586
586
  await fs.writeFile(filepath, content);
587
587
  }
588
588
 
589
- const MIXIN_SCHEMA_RE = /\bmixinSchema\s*=/;
590
- const MIXIN_NAME_RE = /^\s*(?:var|let|const)\s+mixinName\s*=\s*(['"])([^'"\n]*)\1\s*(?:;\s*)?$/;
591
- const MIXIN_KEYWORD_RE = /^\s*mixin\s/m;
592
- function findMixinCode(block) {
593
- const found = {};
594
- walk(block, (node) => {
595
- if (node.type === "Mixin")
596
- return false;
597
- if (node.type !== "Code" || node.buffer)
598
- return;
599
- if (found.schemaSource === void 0 && MIXIN_SCHEMA_RE.test(node.val))
600
- found.schemaSource = node.val;
601
- const name = MIXIN_NAME_RE.exec(node.val)?.[2];
602
- if (found.mixinName === void 0 && name !== void 0)
603
- found.mixinName = name;
604
- });
605
- return found;
606
- }
607
- function discoverMixins(source, filename) {
608
- if (!MIXIN_KEYWORD_RE.test(source))
609
- return [];
610
- const ast = parse$1(lex(source, { filename }), { filename, src: source });
611
- const mixins = [];
612
- for (const node of ast.nodes) {
613
- if (node.type !== "Mixin" || node.call)
614
- continue;
615
- mixins.push({
616
- name: node.name,
617
- args: node.args ?? null,
618
- line: node.line,
619
- ...node.block ? findMixinCode(node.block) : {}
620
- });
621
- }
622
- return mixins;
623
- }
624
-
625
589
  const MIXIN_MANIFEST_PATH = "mixins/manifest.json";
626
590
  const MIXIN_OVERVIEW_FILE = "mixins.html";
627
591
  function getMixinExplorerHref(id) {
@@ -1846,7 +1810,7 @@ async function generateFullPageFile(data) {
1846
1810
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="${data.brandColor.dark}">
1847
1811
  ` : `<meta name="theme-color" content="${data.brandColor}">`}
1848
1812
  <script type="module" src="styleguide-assets/fullpage-aWqc0gjm.js"><\/script>
1849
- ${data.playgroundConfig ? '<script type="module" src="styleguide-assets/playground-BuO-B-Kx.js"><\/script>' : ""}
1813
+ ${data.playgroundConfig ? '<script type="module" src="styleguide-assets/playground-BhseyspT.js"><\/script>' : ""}
1850
1814
  ${computedStyleTags}
1851
1815
  ${computedThemeStyleTags}
1852
1816
  </head>
@@ -2957,7 +2921,7 @@ document.addEventListener("DOMContentLoaded", () => {
2957
2921
  //#endregion
2958
2922
  ;
2959
2923
  <\/script>
2960
- <script type="module" src="styleguide-assets/preview-C3WnTlhx.js"><\/script>
2924
+ <script type="module" src="styleguide-assets/preview-By_Bbr0k.js"><\/script>
2961
2925
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-400-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2962
2926
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-600-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
2963
2927
  <link rel="preload" href="styleguide-assets/fonts/geist-mono-latin-300-normal.woff2" as="font" type="font/woff2" crossorigin="anonymous">
@@ -1,5 +1,5 @@
1
1
  import { parentPort } from 'node:worker_threads';
2
- import { r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, a as compileMarkup, p as pugErrorFile } from '../../shared/kss-modern.D1AKakeJ.mjs';
2
+ import { r as requireZod, e as evaluateMixinSchema, c as compileMixinModule, a as compileMarkup, p as pugErrorFile } from '../../shared/kss-modern.tLBfjOgj.mjs';
3
3
  import 'node:path';
4
4
  import 'pug';
5
5
  import 'node:fs';
@@ -8,6 +8,8 @@ import 'consola';
8
8
  import 'consola/utils';
9
9
  import 'node:module';
10
10
  import 'pug-walk';
11
+ import 'pug-lexer';
12
+ import 'pug-parser';
11
13
  import 'pug-load';
12
14
 
13
15
  if (!parentPort) {
@@ -6,6 +6,8 @@ import { createConsola } from 'consola';
6
6
  import { colors } from 'consola/utils';
7
7
  import { createRequire } from 'node:module';
8
8
  import walk from 'pug-walk';
9
+ import lex from 'pug-lexer';
10
+ import parse from 'pug-parser';
9
11
  import pugLoad from 'pug-load';
10
12
 
11
13
  const sectionSanitizeId = (id2) => id2.toLowerCase().replaceAll(".", "-");
@@ -98,6 +100,72 @@ function generateId() {
98
100
  return value;
99
101
  }
100
102
 
103
+ const MIXIN_SCHEMA_RE = /\bmixinSchema\s*=/;
104
+ const MIXIN_NAME_RE = /^\s*(?:var|let|const)\s+mixinName\s*=\s*(['"])([^'"\n]*)\1\s*(?:;\s*)?$/;
105
+ const MIXIN_KEYWORD_RE = /^\s*mixin\s/m;
106
+ function findMixinCode(block) {
107
+ const found = {};
108
+ walk(block, (node) => {
109
+ if (node.type === "Mixin")
110
+ return false;
111
+ if (node.type !== "Code" || node.buffer)
112
+ return;
113
+ if (found.schemaSource === void 0 && MIXIN_SCHEMA_RE.test(node.val))
114
+ found.schemaSource = node.val;
115
+ const name = MIXIN_NAME_RE.exec(node.val)?.[2];
116
+ if (found.mixinName === void 0 && name !== void 0)
117
+ found.mixinName = name;
118
+ });
119
+ return found;
120
+ }
121
+ function discoverMixins(source, filename) {
122
+ if (!MIXIN_KEYWORD_RE.test(source))
123
+ return [];
124
+ const ast = parse(lex(source, { filename }), { filename, src: source });
125
+ const mixins = [];
126
+ for (const node of ast.nodes) {
127
+ if (node.type !== "Mixin" || node.call)
128
+ continue;
129
+ mixins.push({
130
+ name: node.name,
131
+ args: node.args ?? null,
132
+ line: node.line,
133
+ ...node.block ? findMixinCode(node.block) : {}
134
+ });
135
+ }
136
+ return mixins;
137
+ }
138
+
139
+ function getMixinMarkerName(name, mixinName) {
140
+ const segment = mixinName?.split("/").map((part) => part.trim()).filter(Boolean).at(-1) ?? name;
141
+ return segment.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/[-_\s]+/g, " ").trim().toUpperCase();
142
+ }
143
+ function createComment(val, node) {
144
+ return { type: "Comment", val, buffer: true, line: node.line, column: node.column, filename: node.filename };
145
+ }
146
+ function hasStartMarker(nodes) {
147
+ return nodes.some((node) => node.type === "Comment" && node.buffer === true && node.val?.trim().startsWith("START "));
148
+ }
149
+ const mixinMarkerPlugin = {
150
+ preCodeGen(ast) {
151
+ return walk(ast, (node) => {
152
+ if (node.type !== "Mixin" || node.call || !node.block || typeof node.name !== "string")
153
+ return;
154
+ if (hasStartMarker(node.block.nodes))
155
+ return;
156
+ const { schemaSource, mixinName } = findMixinCode(node.block);
157
+ if (schemaSource === void 0)
158
+ return;
159
+ const markerName = getMixinMarkerName(node.name, mixinName);
160
+ node.block.nodes = [
161
+ createComment(` START ${markerName}`, node),
162
+ ...node.block.nodes,
163
+ createComment(` END ${markerName}`, node)
164
+ ];
165
+ });
166
+ }
167
+ };
168
+
101
169
  const parseCache = /* @__PURE__ */ new Map();
102
170
  function signatureOf(filename) {
103
171
  try {
@@ -178,7 +246,7 @@ function compileMixinModule(file, name) {
178
246
  ...MIXIN_COMPILE_OPTIONS,
179
247
  // a sibling of the mixin's file, so its relative includes resolve exactly as in the file itself
180
248
  filename: path.join(path.dirname(absoluteFile), `__kss-mixin-${name}.pug`),
181
- plugins: [mixinPugPlugin]
249
+ plugins: [mixinPugPlugin, mixinMarkerPlugin]
182
250
  });
183
251
  return {
184
252
  code: `${body}
@@ -196,6 +264,9 @@ const ARRAY_KEYS = ["type", "items", "minItems", "maxItems", ...ANNOTATION_KEYS]
196
264
  const LITERAL_UNION_KEYS = ["anyOf", ...ANNOTATION_KEYS];
197
265
  const ROOT_KEYS = ["$schema", "type", "properties", "required", "additionalProperties", ...ANNOTATION_KEYS];
198
266
  const ENTRY_KEYS = ["type", "properties", "required", "additionalProperties", ...ANNOTATION_KEYS];
267
+ const RECORD_KEYS = ["type", "propertyNames", "additionalProperties", ...ANNOTATION_KEYS];
268
+ const RECORD_KEY_KEYS = ["type", "pattern", "minLength", "maxLength"];
269
+ const RECORD_VALUE_TYPES = ["string", "number", "integer", "boolean"];
199
270
  const CHECKED_FORMATS = ["email", "uri"];
200
271
  function isObject(value) {
201
272
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -218,6 +289,24 @@ function checkEntry(schema) {
218
289
  }
219
290
  return errors;
220
291
  }
292
+ function isRecord(schema) {
293
+ return !isObject(schema.properties) && isObject(schema.additionalProperties);
294
+ }
295
+ function checkRecord(schema) {
296
+ const errors = checkKeys(schema, RECORD_KEYS);
297
+ const keys = schema.propertyNames;
298
+ if (keys !== void 0 && (!isObject(keys) || keys.type !== "string"))
299
+ errors.push("has keys that are no strings, only z.record(z.string(), \u2026) is supported");
300
+ else if (isObject(keys))
301
+ errors.push(...checkKeys(keys, RECORD_KEY_KEYS).map((error) => `keys ${error}`));
302
+ const values = schema.additionalProperties;
303
+ const types = Array.isArray(values.type) ? values.type : [values.type];
304
+ if (Array.isArray(values.anyOf) || !types.every((type) => RECORD_VALUE_TYPES.includes(String(type))))
305
+ errors.push("has values that are no strings, numbers or booleans, which is not supported");
306
+ else if (!Array.isArray(values.type))
307
+ errors.push(...checkValue(values, "entry-field").map((error) => `values ${error}`));
308
+ return errors;
309
+ }
221
310
  function checkValue(schema, position) {
222
311
  if (Array.isArray(schema.anyOf)) {
223
312
  if (!schema.anyOf.every(isLiteral))
@@ -225,7 +314,7 @@ function checkValue(schema, position) {
225
314
  return checkKeys(schema, LITERAL_UNION_KEYS);
226
315
  }
227
316
  if (Array.isArray(schema.type))
228
- return [`can be ${schema.type.join(" or ")}; nullable props and unions of types are not supported`];
317
+ return [`can be ${schema.type.join(" or ")}; nullable props and unions of types are not supported (except as record values)`];
229
318
  switch (schema.type) {
230
319
  case "string": {
231
320
  const errors = checkKeys(schema, STRING_KEYS);
@@ -255,7 +344,9 @@ function checkValue(schema, position) {
255
344
  return checkEntry(schema);
256
345
  if (position === "entry-field")
257
346
  return ["is an object, the fields of a list entry must be scalars"];
258
- return ["is an object (or record), nested objects are not supported; use an array of objects for a list of entries"];
347
+ if (isRecord(schema))
348
+ return checkRecord(schema);
349
+ return ["is an object, nested objects are not supported; use an array of objects for a list of entries or z.record() for a map"];
259
350
  default:
260
351
  return ["has a type the playground cannot edit (e.g. z.any() or z.unknown())"];
261
352
  }
@@ -436,8 +527,9 @@ function compilePugFile(pugFilePath, mode, sectionId, extraLocals = {}) {
436
527
  // line-mapping — measurably bloating codegen and `new Function`. We surface compile errors via
437
528
  // our own overlay, so the precise pug line in a runtime stack isn't worth the cost.
438
529
  compileDebug: false,
439
- // records which mixins the section calls, see ./mixin-trace.ts
440
- plugins: [mixinTracePlugin]
530
+ // START/END comments around public mixins, see ./mixin-markers.ts; records which mixins the
531
+ // section calls, see ./mixin-trace.ts
532
+ plugins: [mixinMarkerPlugin, mixinTracePlugin]
441
533
  });
442
534
  const dependencies = [path.resolve(pugFilePath), ...pugFn.dependencies.map((dep) => path.resolve(dep))];
443
535
  const locals = { modifierClass: "{{modifier_class}}", ...extraLocals, useId: createUseId(sectionId) };
@@ -499,4 +591,4 @@ async function compileMarkup(contentDir, mode, html, sectionId) {
499
591
  return { html: result, dependencies: [...new Set(dependencies)], mixinUsage: mergeMixinUsage(mixinUsage) };
500
592
  }
501
593
 
502
- export { INSERT_VITE_PUG_TAG_RE as I, MIXIN_COMPILE_OPTIONS as M, PUG_ERROR_OVERLAY_TAG as P, compileMarkup as a, getMixinWrapperSource as b, compileMixinModule as c, slugify as d, evaluateMixinSchema as e, PUG_SRC_RE as f, getZodVersion as g, ensureStartingSlash as h, sectionSanitizeId as i, stripPugErrorOverlay as j, generateId as k, logger as l, replaceWrapperContent as m, formatSourceCode as n, htmlToSearchText as o, pugErrorFile as p, createLogger as q, requireZod as r, sanitizeSpecialCharacters as s, themeClassList as t };
594
+ export { INSERT_VITE_PUG_TAG_RE as I, MIXIN_COMPILE_OPTIONS as M, PUG_ERROR_OVERLAY_TAG as P, compileMarkup as a, getMixinWrapperSource as b, compileMixinModule as c, discoverMixins as d, evaluateMixinSchema as e, slugify as f, getZodVersion as g, PUG_SRC_RE as h, ensureStartingSlash as i, sectionSanitizeId as j, stripPugErrorOverlay as k, logger as l, generateId as m, replaceWrapperContent as n, formatSourceCode as o, pugErrorFile as p, htmlToSearchText as q, requireZod as r, sanitizeSpecialCharacters as s, themeClassList as t, createLogger as u };
@@ -21,8 +21,8 @@
21
21
  "file": "code-highlight-Fm7cxf-E.js",
22
22
  "name": "code-highlight"
23
23
  },
24
- "_controller-BduQiyRp.js": {
25
- "file": "controller-BduQiyRp.js",
24
+ "_controller-Bw_HCban.js": {
25
+ "file": "controller-Bw_HCban.js",
26
26
  "name": "controller",
27
27
  "imports": [
28
28
  "_utils-DtB-AzJa.js",
@@ -147,14 +147,14 @@
147
147
  ]
148
148
  },
149
149
  "client/lib/playground/explorer.ts": {
150
- "file": "explorer-B2UH96jd.js",
150
+ "file": "explorer-CawEz1UK.js",
151
151
  "name": "explorer",
152
152
  "src": "client/lib/playground/explorer.ts",
153
153
  "isDynamicEntry": true,
154
154
  "imports": [
155
155
  "_code-highlight-Fm7cxf-E.js",
156
156
  "_utils-DtB-AzJa.js",
157
- "_controller-BduQiyRp.js",
157
+ "_controller-Bw_HCban.js",
158
158
  "_alerts-DIQ8TeZB.js"
159
159
  ]
160
160
  },
@@ -169,13 +169,13 @@
169
169
  ]
170
170
  },
171
171
  "client/playground.ts": {
172
- "file": "playground-BuO-B-Kx.js",
172
+ "file": "playground-BhseyspT.js",
173
173
  "name": "playground",
174
174
  "src": "client/playground.ts",
175
175
  "isEntry": true,
176
176
  "imports": [
177
177
  "_shared-hGcWlnRM.js",
178
- "_controller-BduQiyRp.js"
178
+ "_controller-Bw_HCban.js"
179
179
  ]
180
180
  },
181
181
  "client/preview-inline.ts": {
@@ -185,7 +185,7 @@
185
185
  "isEntry": true
186
186
  },
187
187
  "client/preview.ts": {
188
- "file": "preview-C3WnTlhx.js",
188
+ "file": "preview-By_Bbr0k.js",
189
189
  "name": "preview",
190
190
  "src": "client/preview.ts",
191
191
  "isEntry": true,
@@ -64,6 +64,22 @@ function d(e) {
64
64
  hasDefault: "default" in r,
65
65
  hasExample: i.length > 0
66
66
  };
67
+ if (r.type === "object" && s(r.additionalProperties)) {
68
+ let e = s(r.propertyNames) ? r.propertyNames : {}, t = r.additionalProperties, n = Array.isArray(t.type) ? t.type.map((e) => ({
69
+ ...t,
70
+ type: e
71
+ })) : [t];
72
+ return {
73
+ ...a,
74
+ kind: "record",
75
+ record: {
76
+ keyPattern: typeof e.pattern == "string" ? e.pattern : void 0,
77
+ keyMinLength: c(e.minLength),
78
+ keyMaxLength: c(e.maxLength),
79
+ values: n.map(u)
80
+ }
81
+ };
82
+ }
67
83
  if (r.type === "array") {
68
84
  let e = s(r.items) ? r.items : {};
69
85
  return {
@@ -101,7 +117,7 @@ function p(e) {
101
117
  function m(e) {
102
118
  if (e.hasDefault) return e.default;
103
119
  if (e.hasExample) return e.example;
104
- if (!e.isOptional) return e.kind === "array" ? [] : f(e);
120
+ if (!e.isOptional) return e.kind === "array" ? [] : e.kind === "record" ? {} : f(e);
105
121
  }
106
122
  function h(e, t) {
107
123
  return Object.fromEntries(e.map((e) => [e.key, t ? t[e.key] : m(e)]));
@@ -113,7 +129,7 @@ function g(e, t) {
113
129
  }
114
130
  //#endregion
115
131
  //#region client/lib/playground/panel.css?inline
116
- var _ = "@layer settings{:host{--color-surface-primary:var(--styleguide-color-background-highlight,light-dark(#fff,#0a0a0a));--color-surface-sunken:var(--styleguide-color-background,light-dark(#fafafa,#050505));--color-text-primary:var(--styleguide-color-highlight,light-dark(#111827,#fafafa));--color-text-secondary:var(--styleguide-color-regular,light-dark(#666,#a3a3a3));--color-border-default:var(--styleguide-color-border,light-dark(#ebebeb,#1f1f1f));--color-border-focus:var(--styleguide-color-theme-highlight,light-dark(#2463eb,#92c2fc));--color-status-error:light-dark(#ba1c1c,#f87272);--font-mono:ui-monospace, \"Geist Mono\", sfmono-regular, menlo, monospace;--radius-default:.75em;--radius-small:.5em;--duration-fast:.15s;--ease-out:cubic-bezier(.23, 1, .32, 1)}:host([data-standalone]){--color-surface-primary:light-dark(#fff,#0a0a0a);--color-surface-sunken:light-dark(#fafafa,#050505);--color-text-primary:light-dark(#111827,#fafafa);--color-text-secondary:light-dark(#525252,#a3a3a3);--color-border-default:light-dark(#e6e6e6,#262626);--color-border-focus:light-dark(#2463eb,#92c2fc);color-scheme:light dark}:host([data-scheme=light]){color-scheme:light}:host([data-scheme=dark]){color-scheme:dark}}@layer generic{:host{display:block}.c-panel,.c-launcher{color:var(--color-text-secondary);font-size:.875rem;line-height:1.45}:host([data-standalone]) :is(.c-panel,.c-launcher){font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;font-size:13px}*,:before,:after{box-sizing:border-box}:focus-visible{outline:2px solid var(--color-border-focus);outline-offset:2px}[hidden]{display:none!important}}@layer components{.c-panel{border:1px solid var(--color-border-default);border-radius:var(--radius-default);background:var(--color-surface-primary);flex-direction:column;min-block-size:0;max-block-size:100%;display:flex;overflow:hidden}:host([data-standalone]) .c-panel{block-size:100%;box-shadow:0 0 0 1px var(--color-border-default), 0 .5em 2em #0000001f;border-width:0;border-radius:0}:host([data-flush]) .c-panel{border-width:0;border-radius:0}:host([data-flush]) .c-panel__header{display:none}.c-panel__header{border-block-end:1px solid var(--color-border-default);align-items:center;gap:.5em;padding-block:.5em;padding-inline:1em .5em;display:flex}.c-panel__title{min-inline-size:0;color:var(--color-text-primary);text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:1em;font-weight:600;line-height:2em;overflow:hidden}.c-panel__body{gap:1em;min-block-size:0;padding:1em;display:grid;overflow-y:auto}.c-panel__message{border-radius:var(--radius-small);color:var(--color-status-error);white-space:pre-wrap;overflow-wrap:anywhere;border:1px solid;margin:0;padding-block:.5em;padding-inline:.75em}.c-panel__footer{border-block-start:1px solid var(--color-border-default);background:var(--color-surface-sunken);justify-content:space-between;align-items:center;gap:.5em;padding-block:.5em;padding-inline:1em;display:flex}.c-panel__call{min-inline-size:0;font-family:var(--font-mono);color:var(--color-text-primary);text-overflow:ellipsis;white-space:nowrap;font-size:.75em;overflow:hidden}.c-field{gap:.25em;display:grid}.c-field__label{font-family:var(--font-mono);color:var(--color-text-primary);font-weight:600}.c-field__type{font-family:var(--font-mono)}.c-field__help,.c-field__error{margin:0;font-size:.75em}.c-field__error{color:var(--color-status-error)}.c-control{border:1px solid var(--color-border-default);border-radius:var(--radius-small);background:var(--color-surface-sunken);inline-size:100%;color:var(--color-text-primary);font:inherit;margin:0;padding-block:.375em;padding-inline:.625em;font-size:max(16px,1em);line-height:1.4;display:block}@media (hover:hover) and (pointer:fine){.c-control{font-size:inherit}}.c-control--select{appearance:none;cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - .9375em),calc(100% - .625em);background-repeat:no-repeat;background-size:.3125em .3125em;padding-inline-end:2em}.c-control--textarea{resize:vertical;min-block-size:5.5em;font-family:var(--font-mono);font-size:.75em}.c-control[aria-invalid=true]{border-color:var(--color-status-error)}.c-control:disabled,.c-checkbox:disabled{opacity:.5;cursor:not-allowed}.c-checkbox-row{cursor:pointer;align-items:center;gap:.5em;display:inline-flex}.c-checkbox{block-size:1em;inline-size:1em;accent-color:var(--color-border-focus);cursor:pointer;margin:0}.c-button{border:1px solid var(--color-border-default);border-radius:var(--radius-small);background:var(--color-surface-primary);min-block-size:2em;min-inline-size:2em;color:var(--color-text-primary);font:inherit;white-space:nowrap;cursor:pointer;transition-property:border-color,scale;transition-duration:var(--duration-fast);transition-timing-function:var(--ease-out);justify-content:center;align-items:center;gap:.25em;margin:0;padding-block:.25em;padding-inline:.625em;font-size:.875em;display:inline-flex}.c-button:active{scale:.96}@media (hover:hover) and (pointer:fine){.c-button:hover{border-color:var(--color-border-focus)}}.c-button svg{block-size:1em;inline-size:1em}.c-button--icon{min-inline-size:2em;padding-inline:0}.c-button:disabled{opacity:.5;cursor:not-allowed}.c-list-editor{justify-items:start;gap:.5em;display:grid}.c-list{gap:.375em;inline-size:100%;margin:0;padding:0;list-style:none;display:grid}.c-list__item{grid-template-columns:minmax(0,1fr) repeat(3,auto);align-items:center;gap:.25em;display:grid}.c-list__item--entry{align-items:start}.c-entry{border:1px solid var(--color-border-default);border-radius:var(--radius-small);gap:.375em;padding:.5em;display:grid}.c-entry__field{gap:.125em;display:grid}.c-entry__label{font-family:var(--font-mono);color:var(--color-text-primary);font-size:.875em}.c-resize-handle{z-index:1;touch-action:none;background:0 0;border:0;padding:0;position:absolute}.c-resize-handle:after{content:\"\";background:var(--color-text-secondary);opacity:0;transition:opacity var(--duration-fast) var(--ease-out);border-radius:999px;position:absolute}@media (hover:hover) and (pointer:fine){.c-resize-handle:hover:after{opacity:.4}}.c-resize-handle:focus-visible:after{opacity:.6}:host([data-dock=right]) .c-resize-handle{cursor:col-resize;inline-size:.5em;inset-block:0;inset-inline-start:-.25em}:host([data-dock=right]) .c-resize-handle:after{inline-size:2px;inset-block:40%;inset-inline-start:.1875em}:host([data-dock=bottom]) .c-resize-handle{cursor:row-resize;block-size:.5em;inset-block-start:-.25em;inset-inline:0}:host([data-dock=bottom]) .c-resize-handle:after{block-size:2px;inset-block-start:.1875em;inset-inline:40%}.c-launcher{box-shadow:0 .25em 1em #00000029}@media (prefers-reduced-motion:reduce){.c-button,.c-resize-handle:after{transition:none}}}@layer utilities{.u-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}}";
132
+ var _ = "@layer settings{:host{--color-surface-primary:var(--styleguide-color-background-highlight,light-dark(#fff,#0a0a0a));--color-surface-sunken:var(--styleguide-color-background,light-dark(#fafafa,#050505));--color-text-primary:var(--styleguide-color-highlight,light-dark(#111827,#fafafa));--color-text-secondary:var(--styleguide-color-regular,light-dark(#666,#a3a3a3));--color-border-default:var(--styleguide-color-border,light-dark(#ebebeb,#1f1f1f));--color-border-focus:var(--styleguide-color-theme-highlight,light-dark(#2463eb,#92c2fc));--color-status-error:light-dark(#ba1c1c,#f87272);--font-mono:ui-monospace, \"Geist Mono\", sfmono-regular, menlo, monospace;--radius-default:.75em;--radius-small:.5em;--duration-fast:.15s;--ease-out:cubic-bezier(.23, 1, .32, 1)}:host([data-standalone]){--color-surface-primary:light-dark(#fff,#0a0a0a);--color-surface-sunken:light-dark(#fafafa,#050505);--color-text-primary:light-dark(#111827,#fafafa);--color-text-secondary:light-dark(#525252,#a3a3a3);--color-border-default:light-dark(#e6e6e6,#262626);--color-border-focus:light-dark(#2463eb,#92c2fc);color-scheme:light dark}:host([data-scheme=light]){color-scheme:light}:host([data-scheme=dark]){color-scheme:dark}}@layer generic{:host{display:block}.c-panel,.c-launcher{color:var(--color-text-secondary);font-size:.875rem;line-height:1.45}:host([data-standalone]) :is(.c-panel,.c-launcher){font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,sans-serif;font-size:13px}*,:before,:after{box-sizing:border-box}:focus-visible{outline:2px solid var(--color-border-focus);outline-offset:2px}[hidden]{display:none!important}}@layer components{.c-panel{border:1px solid var(--color-border-default);border-radius:var(--radius-default);background:var(--color-surface-primary);flex-direction:column;min-block-size:0;max-block-size:100%;display:flex;overflow:hidden}:host([data-standalone]) .c-panel{block-size:100%;box-shadow:0 0 0 1px var(--color-border-default), 0 .5em 2em #0000001f;border-width:0;border-radius:0}:host([data-flush]) .c-panel{border-width:0;border-radius:0}:host([data-flush]) .c-panel__header{display:none}.c-panel__header{border-block-end:1px solid var(--color-border-default);align-items:center;gap:.5em;padding-block:.5em;padding-inline:1em .5em;display:flex}.c-panel__title{min-inline-size:0;color:var(--color-text-primary);text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:1em;font-weight:600;line-height:2em;overflow:hidden}.c-panel__body{gap:1em;min-block-size:0;padding:1em;display:grid;overflow-y:auto}.c-panel__message{border-radius:var(--radius-small);color:var(--color-status-error);white-space:pre-wrap;overflow-wrap:anywhere;border:1px solid;margin:0;padding-block:.5em;padding-inline:.75em}.c-panel__footer{border-block-start:1px solid var(--color-border-default);background:var(--color-surface-sunken);justify-content:space-between;align-items:center;gap:.5em;padding-block:.5em;padding-inline:1em;display:flex}.c-panel__call{min-inline-size:0;font-family:var(--font-mono);color:var(--color-text-primary);text-overflow:ellipsis;white-space:nowrap;font-size:.75em;overflow:hidden}.c-field{gap:.25em;display:grid}.c-field__label{font-family:var(--font-mono);color:var(--color-text-primary);font-weight:600}.c-field__type{font-family:var(--font-mono)}.c-field__help,.c-field__error{margin:0;font-size:.75em}.c-field__error{color:var(--color-status-error)}.c-control{border:1px solid var(--color-border-default);border-radius:var(--radius-small);background:var(--color-surface-sunken);inline-size:100%;color:var(--color-text-primary);font:inherit;margin:0;padding-block:.375em;padding-inline:.625em;font-size:max(16px,1em);line-height:1.4;display:block}@media (hover:hover) and (pointer:fine){.c-control{font-size:inherit}}.c-control--select{appearance:none;cursor:pointer;background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - .9375em),calc(100% - .625em);background-repeat:no-repeat;background-size:.3125em .3125em;padding-inline-end:2em}.c-control--textarea{resize:vertical;min-block-size:5.5em;font-family:var(--font-mono);font-size:.75em}.c-control[aria-invalid=true]{border-color:var(--color-status-error)}.c-control:disabled,.c-checkbox:disabled{opacity:.5;cursor:not-allowed}.c-checkbox-row{cursor:pointer;align-items:center;gap:.5em;display:inline-flex}.c-checkbox{block-size:1em;inline-size:1em;accent-color:var(--color-border-focus);cursor:pointer;margin:0}.c-button{border:1px solid var(--color-border-default);border-radius:var(--radius-small);background:var(--color-surface-primary);min-block-size:2em;min-inline-size:2em;color:var(--color-text-primary);font:inherit;white-space:nowrap;cursor:pointer;transition-property:border-color,scale;transition-duration:var(--duration-fast);transition-timing-function:var(--ease-out);justify-content:center;align-items:center;gap:.25em;margin:0;padding-block:.25em;padding-inline:.625em;font-size:.875em;display:inline-flex}.c-button:active{scale:.96}@media (hover:hover) and (pointer:fine){.c-button:hover{border-color:var(--color-border-focus)}}.c-button svg{block-size:1em;inline-size:1em}.c-button--icon{min-inline-size:2em;padding-inline:0}.c-button:disabled{opacity:.5;cursor:not-allowed}.c-list-editor{justify-items:start;gap:.5em;display:grid}.c-list{gap:.375em;inline-size:100%;margin:0;padding:0;list-style:none;display:grid}.c-list__item{grid-template-columns:minmax(0,1fr) repeat(3,auto);align-items:center;gap:.25em;display:grid}.c-list__item--entry{align-items:start}.c-list__item--record{grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto}.c-record-value{grid-template-columns:auto minmax(0,1fr);gap:.25em;display:grid}.c-record-value>[hidden]{display:none}.c-entry{border:1px solid var(--color-border-default);border-radius:var(--radius-small);gap:.375em;padding:.5em;display:grid}.c-entry__field{gap:.125em;display:grid}.c-entry__label{font-family:var(--font-mono);color:var(--color-text-primary);font-size:.875em}.c-resize-handle{z-index:1;touch-action:none;background:0 0;border:0;padding:0;position:absolute}.c-resize-handle:after{content:\"\";background:var(--color-text-secondary);opacity:0;transition:opacity var(--duration-fast) var(--ease-out);border-radius:999px;position:absolute}@media (hover:hover) and (pointer:fine){.c-resize-handle:hover:after{opacity:.4}}.c-resize-handle:focus-visible:after{opacity:.6}:host([data-dock=right]) .c-resize-handle{cursor:col-resize;inline-size:.5em;inset-block:0;inset-inline-start:-.25em}:host([data-dock=right]) .c-resize-handle:after{inline-size:2px;inset-block:40%;inset-inline-start:.1875em}:host([data-dock=bottom]) .c-resize-handle{cursor:row-resize;block-size:.5em;inset-block-start:-.25em;inset-inline:0}:host([data-dock=bottom]) .c-resize-handle:after{block-size:2px;inset-block-start:.1875em;inset-inline:40%}.c-launcher{box-shadow:0 .25em 1em #00000029}@media (prefers-reduced-motion:reduce){.c-button,.c-resize-handle:after{transition:none}}}@layer utilities{.u-sr-only{clip-path:inset(50%);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}}";
117
133
  //#endregion
118
134
  //#region client/lib/playground/panel.ts
119
135
  function v(e, t = {}, n = []) {
@@ -200,7 +216,31 @@ function w(e, t, n, r, i, a) {
200
216
  controls: s
201
217
  };
202
218
  }
203
- function T(e) {
219
+ function T(e, t, n, r, i) {
220
+ if (e.values.length === 1) {
221
+ let a = S(e.values[0], t, !1, { "aria-label": n }, r, i);
222
+ return {
223
+ element: C(a),
224
+ controls: [a]
225
+ };
226
+ }
227
+ let a = e.values.filter((e) => e.kind !== "boolean"), o = [...a.length < e.values.length ? ["true", "false"] : [], ...a.map((e) => e.kind)], s = typeof t, c = s === "boolean" ? String(t) : a.find((e) => e.kind === "string" ? s === "string" : s === "number")?.kind ?? o[0], l = v("select", {
228
+ class: "c-control c-control--select",
229
+ "aria-label": `${n} type`
230
+ });
231
+ for (let e of o) l.append(v("option", { value: e }, [e]));
232
+ l.value = c;
233
+ let u = new Map(a.map((e) => [e.kind, S(e, c === e.kind ? t : void 0, !1, { "aria-label": n }, r, i)])), d = () => u.forEach((e, t) => e.hidden = l.value !== t);
234
+ return d(), l.addEventListener("change", () => {
235
+ d();
236
+ let e = u.get(l.value);
237
+ e ? e.dispatchEvent(new Event("input")) : r(l.value === "true");
238
+ }, { signal: i }), {
239
+ element: v("span", { class: "c-record-value" }, [l, ...u.values()]),
240
+ controls: [l, ...u.values()]
241
+ };
242
+ }
243
+ function E(e) {
204
244
  let { host: t, name: n, isStandalone: r = !1 } = e, i = new AbortController(), { signal: a } = i, o = t.shadowRoot ?? t.attachShadow({ mode: "open" });
205
245
  o.replaceChildren(), r && t.setAttribute("data-standalone", "");
206
246
  let s = v("style", {}, [_]), c = v("div", { class: "c-panel__header" }, [v("h2", { class: "c-panel__title" }, ["Props ", v("span", { class: "c-field__type" }, [`+${n}`])])]), l = v("p", {
@@ -227,12 +267,12 @@ function T(e) {
227
267
  m
228
268
  ]);
229
269
  o.append(s, h);
230
- let g = e.fields, y = structuredClone(e.values), b = /* @__PURE__ */ new Map(), x = () => e.onChange(structuredClone(y)), T = (e, t) => {
270
+ let g = e.fields, y = structuredClone(e.values), b = /* @__PURE__ */ new Map(), x = () => e.onChange(structuredClone(y)), E = (e, t) => {
231
271
  y[e] = t, x();
232
- }, E = (e, t) => {
272
+ }, D = (e, t) => {
233
273
  let n = b.get(e);
234
274
  n && (n.error.textContent = t ?? "", n.error.hidden = !t, n.controls().forEach((e) => e.setAttribute("aria-invalid", String(!!t))));
235
- }, D = (e, t, n, r) => {
275
+ }, O = (e, t, n, r) => {
236
276
  let i = v("ol", { class: "c-list" }), o = v("button", {
237
277
  class: "c-button",
238
278
  type: "button"
@@ -241,7 +281,7 @@ function T(e) {
241
281
  role: "group",
242
282
  "aria-labelledby": n,
243
283
  "aria-describedby": r
244
- }, [i, o]), c = [], l = new AbortController(), u = () => Array.isArray(y[e.key]) ? y[e.key] : [], d = (t) => T(e.key, e.isOptional && t.length === 0 ? void 0 : t), f = (n) => {
284
+ }, [i, o]), c = [], l = new AbortController(), u = () => Array.isArray(y[e.key]) ? y[e.key] : [], d = (t) => E(e.key, e.isOptional && t.length === 0 ? void 0 : t), f = (n) => {
245
285
  let r = (e, t) => {
246
286
  d(e), f(t);
247
287
  };
@@ -297,20 +337,85 @@ function T(e) {
297
337
  group: s,
298
338
  controls: () => [...c, o]
299
339
  };
300
- }, O = (e, t) => {
340
+ }, k = (e, t, n) => {
341
+ let r = e.record, i = v("ol", { class: "c-list" }), o = v("button", {
342
+ class: "c-button",
343
+ type: "button"
344
+ }, ["Add entry"]), s = v("div", {
345
+ class: "c-list-editor",
346
+ role: "group",
347
+ "aria-labelledby": t,
348
+ "aria-describedby": n
349
+ }, [i, o]), c = y[e.key], l = Object.entries(typeof c == "object" && c ? c : {}).map(([e, t]) => ({
350
+ key: e,
351
+ value: t
352
+ })), u = [], d = new AbortController(), f = () => {
353
+ let t = Object.fromEntries(l.filter((e) => e.key !== "").map((e) => [e.key, e.value]));
354
+ E(e.key, e.isOptional && Object.keys(t).length === 0 ? void 0 : t);
355
+ }, m = (t) => {
356
+ d.abort(), d = new AbortController(), u = [];
357
+ let n = [];
358
+ i.replaceChildren(...l.map((t, i) => {
359
+ let a = v("input", {
360
+ class: "c-control",
361
+ type: "text",
362
+ autocomplete: "off",
363
+ spellcheck: "false",
364
+ "aria-label": `${e.key} key ${i + 1}`,
365
+ pattern: r.keyPattern
366
+ });
367
+ a.value = t.key, a.addEventListener("input", () => {
368
+ l[i] = {
369
+ ...l[i],
370
+ key: a.value
371
+ }, f();
372
+ }, { signal: d.signal });
373
+ let o = T(r, t.value, `${e.key} value ${i + 1}`, (e) => {
374
+ l[i] = {
375
+ ...l[i],
376
+ value: e
377
+ }, f();
378
+ }, d.signal), s = v("button", {
379
+ class: "c-button c-button--icon",
380
+ type: "button",
381
+ "aria-label": `Remove entry ${i + 1}`
382
+ }, ["✕"]);
383
+ return s.addEventListener("click", () => {
384
+ l = l.filter((e, t) => t !== i), f(), m(Math.min(i, l.length - 1));
385
+ }, { signal: d.signal }), u.push(a, ...o.controls), n.push(a), v("li", { class: "c-list__item c-list__item--record" }, [
386
+ a,
387
+ o.element,
388
+ s
389
+ ]);
390
+ })), t !== void 0 && (n[t] ?? o).focus();
391
+ };
392
+ return o.addEventListener("click", () => {
393
+ let e = r.values.some((e) => e.kind === "boolean");
394
+ l = [...l, {
395
+ key: "",
396
+ value: e ? !0 : p(r.values[0])
397
+ }], m(l.length - 1);
398
+ }, { signal: a }), m(), {
399
+ group: s,
400
+ controls: () => [...u, o]
401
+ };
402
+ }, A = (e, t) => {
301
403
  let n = `field-${t}`, r = `${n}-label`, i = `${n}-help`, o = `${n}-error`, s = [e.description ? i : "", o].filter(Boolean).join(" "), c, l;
302
- if (e.kind === "array") {
303
- let t = D(e, n, r, s);
404
+ if (e.kind === "record") {
405
+ let t = k(e, r, s);
406
+ c = t.group, l = t.controls;
407
+ } else if (e.kind === "array") {
408
+ let t = O(e, n, r, s);
304
409
  c = t.group, l = t.controls;
305
410
  } else {
306
411
  let t = S(e, y[e.key], e.isOptional, {
307
412
  id: n,
308
413
  "aria-describedby": s,
309
414
  "aria-required": String(!e.isOptional)
310
- }, (t) => T(e.key, t), a);
415
+ }, (t) => E(e.key, t), a);
311
416
  c = C(t), l = () => [t];
312
417
  }
313
- let u = e.kind === "array" ? v("span", {
418
+ let u = e.kind === "array" || e.kind === "record" ? v("span", {
314
419
  class: "c-field__label",
315
420
  id: r
316
421
  }, [e.key]) : v("label", {
@@ -338,14 +443,14 @@ function T(e) {
338
443
  d,
339
444
  f
340
445
  ]);
341
- }, k = () => {
342
- b = /* @__PURE__ */ new Map(), u.replaceChildren(...g.map(O));
446
+ }, j = () => {
447
+ b = /* @__PURE__ */ new Map(), u.replaceChildren(...g.map(A));
343
448
  };
344
- return k(), u.addEventListener("submit", (e) => e.preventDefault(), { signal: a }), f.addEventListener("click", () => e.onReset(), { signal: a }), {
449
+ return j(), u.addEventListener("submit", (e) => e.preventDefault(), { signal: a }), f.addEventListener("click", () => e.onReset(), { signal: a }), {
345
450
  shadowRoot: o,
346
451
  header: c,
347
452
  setFields: (e, t) => {
348
- g = e, y = structuredClone(t), k();
453
+ g = e, y = structuredClone(t), j();
349
454
  },
350
455
  setIssues: (e) => {
351
456
  let t = /* @__PURE__ */ new Map(), n = [];
@@ -357,7 +462,7 @@ function T(e) {
357
462
  let [e, i] = r.path.slice(1), a = `${e === void 0 ? "" : `Entry ${Number(e) + 1}: ${i === void 0 ? "" : `${String(i)}: `}`}${r.message}`;
358
463
  t.set(r.key, [...t.get(r.key) ?? [], a]);
359
464
  }
360
- for (let e of b.keys()) E(e, t.get(e)?.join("\n"));
465
+ for (let e of b.keys()) D(e, t.get(e)?.join("\n"));
361
466
  l.textContent = n.join("\n"), l.hidden = n.length === 0;
362
467
  },
363
468
  setMessage: (e) => {
@@ -373,7 +478,7 @@ function T(e) {
373
478
  }
374
479
  //#endregion
375
480
  //#region lib/use-id.ts
376
- function E(t) {
481
+ function D(t) {
377
482
  let n = `id-${e(t)}`, r = 0;
378
483
  return (e) => {
379
484
  if (e === void 0) return `${n}-${r++}`;
@@ -383,39 +488,39 @@ function E(t) {
383
488
  }
384
489
  //#endregion
385
490
  //#region client/lib/playground/runtime.ts
386
- async function D(e, t) {
491
+ async function O(e, t) {
387
492
  let n = await fetch(new URL(e, document.baseURI), { cache: t ? "no-store" : "default" });
388
493
  if (!n.ok) throw Error(`Could not load the mixin manifest (${n.status} ${n.statusText})`);
389
494
  return n.json();
390
495
  }
391
- var O = /* @__PURE__ */ new Map();
392
- function k(e) {
496
+ var k = /* @__PURE__ */ new Map();
497
+ function A(e) {
393
498
  if (!e.module) return Promise.reject(/* @__PURE__ */ Error(`Mixin "${e.name}" has no render module`));
394
- let t = new URL(e.module, document.baseURI).href, n = O.get(t);
499
+ let t = new URL(e.module, document.baseURI).href, n = k.get(t);
395
500
  return n || (n = import(
396
501
  /* @vite-ignore */
397
502
  t
398
503
  ).then((t) => {
399
504
  if (typeof t.render != "function") throw TypeError(`${e.module} does not export render()`);
400
505
  return t.render;
401
- }), O.set(t, n)), n;
506
+ }), k.set(t, n)), n;
402
507
  }
403
- function A(e) {
508
+ function j(e) {
404
509
  return typeof e == "object" && !!e && Array.isArray(e.issues);
405
510
  }
406
- function j(e, t, r) {
511
+ function M(e, t, r) {
407
512
  try {
408
513
  return {
409
514
  isValid: !0,
410
515
  html: e({
411
516
  props: r,
412
517
  z: n,
413
- useId: E(`mixin-${t}`),
518
+ useId: D(`mixin-${t}`),
414
519
  modifierClass: ""
415
520
  })
416
521
  };
417
522
  } catch (e) {
418
- return A(e) ? {
523
+ return j(e) ? {
419
524
  isValid: !1,
420
525
  issues: e.issues.map((e) => {
421
526
  let t = e.path.filter((e) => typeof e != "symbol");
@@ -433,8 +538,8 @@ function j(e, t, r) {
433
538
  }
434
539
  //#endregion
435
540
  //#region client/lib/playground/state.ts
436
- var M = "props";
437
- function N(e) {
541
+ var N = "props";
542
+ function P(e) {
438
543
  if (e === null || e === "") return {};
439
544
  try {
440
545
  let t = JSON.parse(e);
@@ -443,72 +548,72 @@ function N(e) {
443
548
  return { error: `\`props\` is not valid JSON: ${e instanceof Error ? e.message : String(e)}` };
444
549
  }
445
550
  }
446
- var P = /^(?:javascript|vbscript|data):/i;
447
- function F(e) {
448
- return P.test([...e].filter((e) => e.charCodeAt(0) > 32).join(""));
449
- }
551
+ var F = /^(?:javascript|vbscript|data):/i;
450
552
  function I(e) {
451
- if (typeof e == "string") return e.includes("<") || F(e) ? e : void 0;
553
+ return F.test([...e].filter((e) => e.charCodeAt(0) > 32).join(""));
554
+ }
555
+ function L(e) {
556
+ if (typeof e == "string") return e.includes("<") || I(e) ? e : void 0;
452
557
  if (typeof e == "object" && e) for (let t of Object.values(e)) {
453
- let e = I(t);
558
+ let e = L(t);
454
559
  if (e !== void 0) return e;
455
560
  }
456
561
  }
457
- function L(e) {
458
- let t = N(new URLSearchParams(e.hash.slice(1)).get(M) ?? e.searchParams.get(M)), n = t.props ? I(t.props) : void 0;
562
+ function R(e) {
563
+ let t = P(new URLSearchParams(e.hash.slice(1)).get(N) ?? e.searchParams.get(N)), n = t.props ? L(t.props) : void 0;
459
564
  return n === void 0 ? t : { error: `The props from the link were not applied: they contain markup or a script URL (${JSON.stringify(n.slice(0, 40))}). Enter such values in the controls instead.` };
460
565
  }
461
- function R(e, t) {
566
+ function z(e, t) {
462
567
  let n = new URL(e), r = new URLSearchParams(n.hash.slice(1));
463
- return r.set(M, JSON.stringify(t)), n.hash = r.toString(), n;
568
+ return r.set(N, JSON.stringify(t)), n.hash = r.toString(), n;
464
569
  }
465
- function z(e, t) {
570
+ function B(e, t) {
466
571
  let n = new URL(e);
467
- return n.searchParams.set(M, JSON.stringify(t)), n.hash = "", n;
572
+ return n.searchParams.set(N, JSON.stringify(t)), n.hash = "", n;
468
573
  }
469
- var B = /^[A-Z_$][\w$]*$/i;
470
- function V(e) {
574
+ var V = /^[A-Z_$][\w$]*$/i;
575
+ function H(e) {
471
576
  if (typeof e == "string") return `'${e.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\n", "\\n")}'`;
472
- if (Array.isArray(e)) return `[${e.map(V).join(", ")}]`;
577
+ if (Array.isArray(e)) return `[${e.map(H).join(", ")}]`;
473
578
  if (typeof e == "object" && e) {
474
579
  let t = Object.entries(e);
475
- return t.length === 0 ? "{}" : `{ ${t.map(([e, t]) => `${B.test(e) ? e : V(e)}: ${V(t)}`).join(", ")} }`;
580
+ return t.length === 0 ? "{}" : `{ ${t.map(([e, t]) => `${V.test(e) ? e : H(e)}: ${H(t)}`).join(", ")} }`;
476
581
  }
477
582
  return JSON.stringify(e) ?? "undefined";
478
583
  }
479
- function H(e, t) {
584
+ function U(e, t) {
480
585
  let n = new Map(t.filter((e) => e.hasDefault).map((e) => [e.key, JSON.stringify(e.default)]));
481
586
  return Object.fromEntries(Object.entries(e).filter(([e, t]) => n.get(e) !== JSON.stringify(t)));
482
587
  }
483
- function U(e, t, n = []) {
484
- let r = H(t, n);
588
+ function W(e, t, n = []) {
589
+ let r = U(t, n);
485
590
  for (let e of n) {
486
591
  let { items: t } = e;
487
- t?.kind === "object" && Array.isArray(r[e.key]) && (r[e.key] = r[e.key].map((e) => typeof e == "object" && e ? H(e, t.fields) : e));
592
+ t?.kind === "object" && Array.isArray(r[e.key]) && (r[e.key] = r[e.key].map((e) => typeof e == "object" && e ? U(e, t.fields) : e));
488
593
  }
489
- return `+${e}(${V(r)})`;
594
+ return `+${e}(${H(r)})`;
490
595
  }
491
596
  //#endregion
492
597
  //#region client/lib/playground/validate.ts
493
- var W = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/;
494
- function G(e) {
598
+ var G = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/;
599
+ function K(e) {
495
600
  return typeof e == "string" ? `"${e}"` : String(e);
496
601
  }
497
- function K(e) {
602
+ function q(e) {
498
603
  try {
499
604
  return !!new URL(e);
500
605
  } catch {
501
606
  return !1;
502
607
  }
503
608
  }
504
- function q(e, t) {
609
+ function J(e, t) {
505
610
  return `${e} ${t}${e === 1 ? "" : "s"}`;
506
611
  }
507
- function J(e, t) {
612
+ function Y(e, t) {
508
613
  switch (e.kind) {
509
- case "enum": return e.options?.includes(t) ? void 0 : `Must be one of ${(e.options ?? []).map(G).join(", ")}`;
614
+ case "enum": return e.options?.includes(t) ? void 0 : `Must be one of ${(e.options ?? []).map(K).join(", ")}`;
510
615
  case "boolean": return typeof t == "boolean" ? void 0 : "Must be true or false";
511
- case "string": return typeof t == "string" ? e.minLength !== void 0 && t.length < e.minLength ? e.minLength === 1 ? "Must not be empty" : `Must be at least ${q(e.minLength, "character")}` : e.maxLength !== void 0 && t.length > e.maxLength ? `Must be at most ${q(e.maxLength, "character")}` : e.format === "email" && !W.test(t) ? "Must be an email address" : e.format === "uri" && !K(t) ? "Must be a URL" : e.pattern !== void 0 && e.format !== "email" && !new RegExp(e.pattern).test(t) ? `Must match ${e.pattern}` : void 0 : "Must be text";
616
+ case "string": return typeof t == "string" ? e.minLength !== void 0 && t.length < e.minLength ? e.minLength === 1 ? "Must not be empty" : `Must be at least ${J(e.minLength, "character")}` : e.maxLength !== void 0 && t.length > e.maxLength ? `Must be at most ${J(e.maxLength, "character")}` : e.format === "email" && !G.test(t) ? "Must be an email address" : e.format === "uri" && !q(t) ? "Must be a URL" : e.pattern !== void 0 && e.format !== "email" && !new RegExp(e.pattern).test(t) ? `Must match ${e.pattern}` : void 0 : "Must be text";
512
617
  case "number":
513
618
  case "integer":
514
619
  if (typeof t != "number" || Number.isNaN(t)) return "Must be a number";
@@ -524,46 +629,57 @@ function J(e, t) {
524
629
  return;
525
630
  }
526
631
  }
527
- function Y(e, t) {
528
- return typeof t != "object" || !t || Array.isArray(t) ? ["Must be an object"] : e.fields.flatMap((e) => X(e, t[e.key]).map((t) => `${e.key}: ${t}`));
529
- }
530
632
  function X(e, t) {
633
+ return typeof t != "object" || !t || Array.isArray(t) ? ["Must be an object"] : e.fields.flatMap((e) => Q(e, t[e.key]).map((t) => `${e.key}: ${t}`));
634
+ }
635
+ function Z(e, t) {
636
+ if (typeof t != "object" || !t || Array.isArray(t)) return ["Must be an object"];
637
+ let n = [];
638
+ for (let [r, i] of Object.entries(t)) {
639
+ e.keyPattern !== void 0 && !new RegExp(e.keyPattern).test(r) ? n.push(`Key "${r}": Must match ${e.keyPattern}`) : e.keyMinLength !== void 0 && r.length < e.keyMinLength ? n.push(`Key "${r}": Must be at least ${J(e.keyMinLength, "character")}`) : e.keyMaxLength !== void 0 && r.length > e.keyMaxLength && n.push(`Key "${r}": Must be at most ${J(e.keyMaxLength, "character")}`);
640
+ let t = e.values.map((e) => Y(e, i));
641
+ t.every((e) => e !== void 0) && n.push(`"${r}": ${e.values.length === 1 ? t[0] : `Must be ${e.values.map((e) => e.kind).join(" or ")}`}`);
642
+ }
643
+ return n;
644
+ }
645
+ function Q(e, t) {
531
646
  if (t === void 0) return e.isOptional ? [] : ["Required"];
647
+ if (e.kind === "record") return e.record ? Z(e.record, t) : [];
532
648
  if (e.kind !== "array") {
533
- let n = J(e, t);
649
+ let n = Y(e, t);
534
650
  return n ? [n] : [];
535
651
  }
536
652
  if (!Array.isArray(t)) return ["Must be a list"];
537
653
  let n = [];
538
- e.minItems !== void 0 && t.length < e.minItems && n.push(`Needs at least ${q(e.minItems, "entry").replace("entrys", "entries")}`), e.maxItems !== void 0 && t.length > e.maxItems && n.push(`Allows at most ${q(e.maxItems, "entry").replace("entrys", "entries")}`);
654
+ e.minItems !== void 0 && t.length < e.minItems && n.push(`Needs at least ${J(e.minItems, "entry").replace("entrys", "entries")}`), e.maxItems !== void 0 && t.length > e.maxItems && n.push(`Allows at most ${J(e.maxItems, "entry").replace("entrys", "entries")}`);
539
655
  let { items: r } = e;
540
656
  return t.forEach((e, t) => {
541
657
  if (!r) return;
542
- let i = r.kind === "object" ? Y(r, e) : [J(r, e)].filter((e) => e !== void 0);
658
+ let i = r.kind === "object" ? X(r, e) : [Y(r, e)].filter((e) => e !== void 0);
543
659
  n.push(...i.map((e) => `Entry ${t + 1}: ${e}`));
544
660
  }), n;
545
661
  }
546
- function Z(e, t) {
662
+ function $(e, t) {
547
663
  let n = /* @__PURE__ */ new Map();
548
664
  for (let r of e) {
549
- let e = X(r, t[r.key]);
665
+ let e = Q(r, t[r.key]);
550
666
  e.length > 0 && n.set(r.key, e);
551
667
  }
552
668
  return n;
553
669
  }
554
670
  //#endregion
555
671
  //#region client/lib/playground/controller.ts
556
- var Q = 1e3;
557
- async function $(e, n, r = {}) {
558
- let i = (await D(e.manifestUrl, e.isDevelopment)).mixins.find((t) => t.id === e.id);
672
+ var ee = 1e3;
673
+ async function te(e, n, r = {}) {
674
+ let i = (await O(e.manifestUrl, e.isDevelopment)).mixins.find((t) => t.id === e.id);
559
675
  if (!i || !i.hasSchema) throw Error(`Mixin "${e.name}" has no playground in ${e.manifestUrl}`);
560
- let a = d(i.jsonSchema), o = h(a, r.props), s = i.module ? await k(i) : void 0, c, l = () => g(a, o), u = () => U(i.name, l(), a), f = () => {
676
+ let a = d(i.jsonSchema), o = h(a, r.props), s = i.module ? await A(i) : void 0, c, l = () => g(a, o), u = () => W(i.name, l(), a), f = () => {
561
677
  let e = l();
562
678
  if (c?.setPugCall(u()), !s) {
563
679
  c?.setMessage(i.error?.message ?? "The mixin has not compiled yet.");
564
680
  return;
565
681
  }
566
- let t = Z(a, o);
682
+ let t = $(a, o);
567
683
  if (t.size > 0) {
568
684
  let r = [...t].flatMap(([e, t]) => t.map((t) => ({
569
685
  key: e,
@@ -576,14 +692,14 @@ async function $(e, n, r = {}) {
576
692
  }, e);
577
693
  return;
578
694
  }
579
- let r = j(s, i.id, e);
695
+ let r = M(s, i.id, e);
580
696
  if (r.isValid) {
581
697
  c?.setIssues([]), n.onRender(r.html, e);
582
698
  return;
583
699
  }
584
700
  "issues" in r ? c?.setIssues(r.issues) : (c?.setIssues([]), c?.setMessage(r.error)), n.onInvalid?.(r, e);
585
701
  };
586
- if (n.panelHost && (c = T({
702
+ if (n.panelHost && (c = E({
587
703
  host: n.panelHost,
588
704
  name: i.name,
589
705
  fields: a,
@@ -613,7 +729,7 @@ async function $(e, n, r = {}) {
613
729
  if (!r) {
614
730
  r = !0;
615
731
  try {
616
- let t = (await D(e.manifestUrl, !0)).mixins.find((t) => t.id === e.id);
732
+ let t = (await O(e.manifestUrl, !0)).mixins.find((t) => t.id === e.id);
617
733
  if (!t || !t.hasSchema) return;
618
734
  let r = i;
619
735
  i = t;
@@ -623,14 +739,14 @@ async function $(e, n, r = {}) {
623
739
  let e = l(), n = h(a);
624
740
  o = Object.fromEntries(a.map((t) => [t.key, t.key in e ? e[t.key] : n[t.key]])), c?.setFields(a, o);
625
741
  }
626
- JSON.stringify(t.error) !== JSON.stringify(r.error) && n.onCompileError?.(t.error), t.module !== r.module && t.module && (s = await k(t)), (t.module !== r.module || u) && f();
742
+ JSON.stringify(t.error) !== JSON.stringify(r.error) && n.onCompileError?.(t.error), t.module !== r.module && t.module && (s = await A(t)), (t.module !== r.module || u) && f();
627
743
  } catch (e) {
628
744
  console.warn("[kss-modern] Could not check the mixin manifest for updates", e);
629
745
  } finally {
630
746
  r = !1;
631
747
  }
632
748
  }
633
- }, Q), document.visibilityState === "visible" && p.start(), document.addEventListener("visibilitychange", () => {
749
+ }, ee), document.visibilityState === "visible" && p.start(), document.addEventListener("visibilitychange", () => {
634
750
  document.visibilityState === "visible" ? p.resume() : p.pause();
635
751
  }, { signal: m.signal });
636
752
  }
@@ -650,4 +766,4 @@ async function $(e, n, r = {}) {
650
766
  };
651
767
  }
652
768
  //#endregion
653
- export { D as a, o as c, z as i, i as l, L as n, v as o, R as r, a as s, $ as t, r as u };
769
+ export { O as a, o as c, B as i, i as l, R as n, v as o, z as r, a as s, te as t, r as u };
@@ -1,6 +1,6 @@
1
1
  import { t as e } from "./code-highlight-Fm7cxf-E.js";
2
2
  import { n as t } from "./utils-DtB-AzJa.js";
3
- import { a as n, i as r, n as i, r as a, s as o, t as s, u as c } from "./controller-BduQiyRp.js";
3
+ import { a as n, i as r, n as i, r as a, s as o, t as s, u as c } from "./controller-Bw_HCban.js";
4
4
  import { t as l } from "./alerts-DIQ8TeZB.js";
5
5
  //#region client/lib/playground/format-html.ts
6
6
  var u = /* @__PURE__ */ new Set([
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./shared-hGcWlnRM.js";
2
- import { c as t, i as n, l as r, n as i, o as a, r as o, t as s } from "./controller-BduQiyRp.js";
2
+ import { c as t, i as n, l as r, n as i, o as a, r as o, t as s } from "./controller-Bw_HCban.js";
3
3
  //#region client/playground.ts
4
4
  var c = "kss-modern:playground-panel", l = {
5
5
  dock: "right",
@@ -1139,7 +1139,7 @@ ot && import("./global-theme-select-CdFgPJ0T.js").then(({ default: e }) => e(ot)
1139
1139
  var st = document.querySelectorAll("[data-section-theme-select]");
1140
1140
  st.length > 0 && import("./section-theme-select-CO65kL5N.js").then(({ default: e }) => e(st)).catch(console.error);
1141
1141
  var ct = document.querySelector("[data-mixin-explorer]");
1142
- ct && import("./explorer-B2UH96jd.js").then(({ default: e }) => e(ct)).catch(console.error);
1142
+ ct && import("./explorer-CawEz1UK.js").then(({ default: e }) => e(ct)).catch(console.error);
1143
1143
  var lt = document.querySelector(".editor-select");
1144
1144
  lt && import("./editor-select-DIZFtqe7.js").then(({ default: e }) => e(lt)).catch(console.error);
1145
1145
  //#endregion
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kss-modern",
3
3
  "type": "module",
4
- "version": "1.7.0-beta.1",
4
+ "version": "1.7.0-beta.3",
5
5
  "description": "Modern KSS compatible styleguide generator",
6
6
  "keywords": [
7
7
  "kss",