@lostgradient/cinder 0.24.4 → 0.24.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/components.json +1 -1
  3. package/dist/components/json-schema-editor/index.js +2147 -5517
  4. package/dist/components/json-schema-editor/json-schema-editor-state.svelte.d.ts +1 -0
  5. package/dist/components/json-schema-editor/json-schema-editor.css +8 -0
  6. package/dist/components/waveform/index.js +17 -5
  7. package/dist/components/waveform/waveform.css +27 -0
  8. package/dist/index.js +510 -428
  9. package/dist/server/components/json-schema-editor/index.js +2 -10
  10. package/dist/server/components/waveform/index.js +1 -1
  11. package/dist/server/index.js +2 -2
  12. package/dist/server/{index.server-7h3nmj3g.js → index.server-4entcat5.js} +119 -76
  13. package/dist/server/{index.server-tdrncj5e.js → index.server-qhfya7fx.js} +10 -3
  14. package/package.json +2 -1
  15. package/src/components/json-schema-editor/diff-view.svelte +1 -1
  16. package/src/components/json-schema-editor/json-schema-editor-impl.svelte +2 -2
  17. package/src/components/json-schema-editor/json-schema-editor-state.svelte.ts +26 -16
  18. package/src/components/json-schema-editor/json-schema-editor.css +8 -0
  19. package/src/components/json-schema-editor/json-schema-toolbar.svelte +2 -2
  20. package/src/components/json-schema-editor/json-schema-validator.ts +17 -3
  21. package/src/components/json-schema-editor/property-editor.constants.ts +0 -1
  22. package/src/components/json-schema-editor/property-editor.svelte +4 -10
  23. package/src/components/json-schema-editor/property-list.svelte +83 -22
  24. package/src/components/waveform/waveform.css +27 -0
  25. package/src/components/waveform/waveform.svelte +28 -15
  26. package/src/styles/tokens-base.css +3 -3
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Json_schema_editor,
3
3
  json_schema_editor_default
4
- } from "../../index.server-7h3nmj3g.js";
4
+ } from "../../index.server-4entcat5.js";
5
5
  import"../../index.server-sz6y8xqk.js";
6
6
  import"../../index.server-mm728d0w.js";
7
7
  import"../../index.server-w9dtc4a2.js";
@@ -35,11 +35,6 @@ import"../../index.server-htmd13mc.js";
35
35
  import"../../index.server-9r6rts7c.js";
36
36
  import"../../index.server-44vrcbhz.js";
37
37
  import"../../index.server-abm21gz1.js";
38
- import"../../index.server-emqv9bz6.js";
39
- import"../../index.server-grq89cv5.js";
40
- import"../../index.server-s4pfz6pb.js";
41
- import"../../index.server-mf4dr1kp.js";
42
- import"../../index.server-xvg6mjdw.js";
43
38
  import"../../index.server-en31rprd.js";
44
39
  import"../../index.server-yyarp1ny.js";
45
40
  import"../../index.server-4efnbtq1.js";
@@ -52,11 +47,8 @@ import"../../index.server-r2z5ds34.js";
52
47
  import"../../index.server-krwbxm8x.js";
53
48
  import"../../index.server-s4ynjgep.js";
54
49
  import"../../index.server-fdpe3vky.js";
55
- import"../../index.server-6pdmym90.js";
56
50
  import"../../index.server-nj8mebze.js";
57
51
  import"../../index.server-ge07r1p8.js";
58
- import"../../index.server-8hdvr9bt.js";
59
- import"../../index.server-mc6vc1pm.js";
60
52
  import"../../index.server-z7nvkz8v.js";
61
53
  import"../../index.server-0v6na3yp.js";
62
54
  export {
@@ -64,4 +56,4 @@ export {
64
56
  Json_schema_editor as JsonSchemaEditor
65
57
  };
66
58
 
67
- //# debugId=3ADE23856C59658A64756E2164756E21
59
+ //# debugId=EA9770FF5B1EEC1B64756E2164756E21
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Waveform,
3
3
  waveform_default
4
- } from "../../index.server-tdrncj5e.js";
4
+ } from "../../index.server-qhfya7fx.js";
5
5
  import"../../index.server-mmmrgvyd.js";
6
6
  import"../../index.server-6gzzpcyd.js";
7
7
  import"../../index.server-z7nvkz8v.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./index.server-8bvk5czj.js";
17
17
  import {
18
18
  waveform_default
19
- } from "./index.server-tdrncj5e.js";
19
+ } from "./index.server-qhfya7fx.js";
20
20
  import {
21
21
  tag_input_default
22
22
  } from "./index.server-75jkpk5t.js";
@@ -326,7 +326,7 @@ import {
326
326
  import {
327
327
  json_schema_editor_default,
328
328
  useHistory
329
- } from "./index.server-7h3nmj3g.js";
329
+ } from "./index.server-4entcat5.js";
330
330
  import"./index.server-sz6y8xqk.js";
331
331
  import"./index.server-mm728d0w.js";
332
332
  import"./index.server-w9dtc4a2.js";
@@ -52,9 +52,6 @@ import {
52
52
  import {
53
53
  Copy_button
54
54
  } from "./index.server-e97zrck0.js";
55
- import {
56
- Tooltip
57
- } from "./index.server-emqv9bz6.js";
58
55
  import {
59
56
  Badge
60
57
  } from "./index.server-en31rprd.js";
@@ -131,7 +128,7 @@ function Diff_view($$renderer, $$props) {
131
128
  $$renderer2.push("<!--[-1-->");
132
129
  }
133
130
  $$renderer2.push(`<!--]--> `);
134
- if (!state.hasChanges) {
131
+ if (!state.hasDiffChanges) {
135
132
  $$renderer2.push("<!--[0-->");
136
133
  Empty_state($$renderer2, {
137
134
  title: "No changes yet",
@@ -184,7 +181,6 @@ var EDITABLE_KEYWORDS = new Set([
184
181
  "default",
185
182
  "examples",
186
183
  "const",
187
- "enum",
188
184
  "minLength",
189
185
  "maxLength",
190
186
  "pattern",
@@ -330,7 +326,8 @@ function Property_editor_constraints($$renderer, $$props) {
330
326
 
331
327
  // src/components/json-schema-editor/property-list.svelte
332
328
  import * as $3 from "svelte/internal/server";
333
- import { onDestroy } from "svelte";
329
+ import { onDestroy, tick } from "svelte";
330
+ import Badge2 from "@lostgradient/cinder/badge";
334
331
  import Collapsible2 from "@lostgradient/cinder/collapsible";
335
332
 
336
333
  // src/components/json-schema-editor/property-list-validation.ts
@@ -390,7 +387,7 @@ function Property_list($$renderer, $$props) {
390
387
  return;
391
388
  }
392
389
  renameError = null;
393
- const next = {};
390
+ const next = Object.create(null);
394
391
  for (const k of propertyNames()) {
395
392
  next[k === oldKey ? draft : k] = properties[k];
396
393
  }
@@ -407,9 +404,33 @@ function Property_list($$renderer, $$props) {
407
404
  }
408
405
  onValueChange(next, nextRequired);
409
406
  }
410
- function deleteProperty(key) {
407
+ let actionAnnouncement = "";
408
+ const propertyTriggerElements = new Map;
409
+ let addPropertyElement = undefined;
410
+ function propertyTrigger(element, key) {
411
+ propertyTriggerElements.set(key, element);
412
+ return {
413
+ update(nextKey) {
414
+ if (nextKey === key)
415
+ return;
416
+ propertyTriggerElements.delete(key);
417
+ key = nextKey;
418
+ propertyTriggerElements.set(key, element);
419
+ },
420
+ destroy() {
421
+ propertyTriggerElements.delete(key);
422
+ }
423
+ };
424
+ }
425
+ async function announceAction(message) {
426
+ actionAnnouncement = "";
427
+ await tick();
428
+ actionAnnouncement = message;
429
+ }
430
+ async function deleteProperty(key, index) {
411
431
  if (readonly)
412
432
  return;
433
+ const focusKey = propertyNames()[index + 1] ?? propertyNames()[index - 1];
413
434
  const next = { ...properties };
414
435
  delete next[key];
415
436
  const nextRequired = required.filter((name) => name !== key);
@@ -418,6 +439,10 @@ function Property_list($$renderer, $$props) {
418
439
  const { [key]: _removedChildCount, ...remainingChildCounts } = childValidationCounts;
419
440
  childValidationCounts = remainingChildCounts;
420
441
  onValueChange(next, nextRequired);
442
+ await announceAction(`Deleted ${key} property.`);
443
+ await tick();
444
+ const focusTarget = focusKey ? propertyTriggerElements.get(focusKey) : addPropertyElement?.querySelector("button");
445
+ focusTarget?.focus();
421
446
  }
422
447
  function setChildValidationErrorCount(key, count) {
423
448
  if ((childValidationCounts[key] ?? 0) === count)
@@ -434,19 +459,30 @@ function Property_list($$renderer, $$props) {
434
459
  if (isOpen)
435
460
  setChildValidationErrorCount(key, 0);
436
461
  }
437
- function moveProperty(key, direction) {
438
- if (readonly)
462
+ async function moveProperty(key, direction, index) {
463
+ if (readonly || !canMoveProperty(index, direction))
439
464
  return;
440
- const index = propertyNames().indexOf(key);
441
465
  const target = index + direction;
442
466
  if (target < 0 || target >= propertyNames().length)
443
467
  return;
444
468
  const reordered = [...propertyNames()];
445
469
  [reordered[index], reordered[target]] = [reordered[target], reordered[index]];
446
- const next = {};
470
+ const next = Object.create(null);
447
471
  for (const name of reordered)
448
472
  next[name] = properties[name];
449
473
  onValueChange(next, required);
474
+ await announceAction(`Moved ${key} property to position ${target + 1} of ${reordered.length}.`);
475
+ }
476
+ function canMoveProperty(index, direction) {
477
+ const target = index + direction;
478
+ if (target < 0 || target >= propertyNames().length)
479
+ return false;
480
+ const reordered = [...propertyNames()];
481
+ [reordered[index], reordered[target]] = [reordered[target], reordered[index]];
482
+ const next = Object.create(null);
483
+ for (const name of reordered)
484
+ next[name] = properties[name];
485
+ return Object.keys(next).every((name, nextIndex) => name === reordered[nextIndex]);
450
486
  }
451
487
  function toggleRequired(key) {
452
488
  if (readonly)
@@ -501,7 +537,7 @@ function Property_list($$renderer, $$props) {
501
537
  return;
502
538
  onValueChange(properties, required.filter((entry) => entry !== name));
503
539
  }
504
- $$renderer2.push(`<div class="cinder-jse-property-list">`);
540
+ $$renderer2.push(`<p class="cinder-sr-only" aria-live="polite">${$3.escape(actionAnnouncement)}</p> <div class="cinder-jse-property-list">`);
505
541
  if (renameError) {
506
542
  $$renderer2.push("<!--[0-->");
507
543
  Alert($$renderer2, {
@@ -523,25 +559,41 @@ function Property_list($$renderer, $$props) {
523
559
  }
524
560
  $$renderer2.push(`<!--]--> <!--[-->`);
525
561
  const each_array = $3.ensure_array_like(propertyNames());
526
- for (let $$index = 0, $$length = each_array.length;$$index < $$length; $$index++) {
527
- let key = each_array[$$index];
562
+ for (let index = 0, $$length = each_array.length;index < $$length; index++) {
563
+ let key = each_array[index];
528
564
  const isRequired = required.includes(key);
529
565
  const isOpen = expanded[key] === true;
566
+ const childValidationErrorCount = childValidationCounts[key] ?? 0;
530
567
  const panelId = `${idPrefix}-${key}-panel`;
531
- $$renderer2.push(`<div class="cinder-jse-property-row"${$3.attr("data-cinder-required", isRequired ? "" : undefined)}><div class="cinder-jse-property-row__summary"${$3.attr_style(`--cinder-jse-property-depth: ${depth}`)}><button type="button" class="cinder-jse-property-row__trigger"${$3.attr("aria-label", `${isOpen ? "Collapse" : "Expand"} ${key} property`)}${$3.attr("aria-expanded", isOpen)}${$3.attr("aria-controls", panelId)}>`);
568
+ $$renderer2.push(`<div class="cinder-jse-property-row"${$3.attr("data-cinder-required", isRequired ? "" : undefined)}${$3.attr("data-cinder-invalid", childValidationErrorCount > 0 ? "" : undefined)}><div class="cinder-jse-property-row__summary"${$3.attr_style(`--cinder-jse-property-depth: ${depth}`)}><button type="button" class="cinder-jse-property-row__trigger"${$3.attr("aria-label", `${isOpen ? "Collapse" : "Expand"} ${key} property${childValidationErrorCount > 0 ? `, ${childValidationErrorCount} validation ${childValidationErrorCount === 1 ? "error" : "errors"}` : ""}`)}${$3.attr("aria-expanded", isOpen)}${$3.attr("aria-controls", isOpen ? panelId : undefined)}>`);
532
569
  Chevron_down($$renderer2, {
533
570
  class: "cinder-jse-property-row__chevron",
534
571
  size: 14,
535
572
  strokeWidth: 2,
536
573
  "aria-hidden": "true"
537
574
  });
538
- $$renderer2.push(`<!----> <span class="cinder-jse-property-row__name">${$3.escape(key)}</span> <span class="cinder-jse-property-row__type">${$3.escape(summariseType(properties[key] ?? {}))}</span></button> <span class="cinder-jse-property-row__spacer"></span> `);
575
+ $$renderer2.push(`<!----> <span class="cinder-jse-property-row__name">${$3.escape(key)}</span> <span class="cinder-jse-property-row__type">${$3.escape(summariseType(properties[key] ?? {}))}</span> `);
576
+ if (childValidationErrorCount > 0) {
577
+ $$renderer2.push("<!--[0-->");
578
+ Badge2($$renderer2, {
579
+ variant: "danger",
580
+ "aria-label": `${childValidationErrorCount} validation ${childValidationErrorCount === 1 ? "error" : "errors"} in ${key}`,
581
+ children: ($$renderer3) => {
582
+ $$renderer3.push(`<!---->${$3.escape(childValidationErrorCount)}
583
+ ${$3.escape(childValidationErrorCount === 1 ? "error" : "errors")}`);
584
+ },
585
+ $$slots: { default: true }
586
+ });
587
+ } else {
588
+ $$renderer2.push("<!--[-1-->");
589
+ }
590
+ $$renderer2.push(`<!--]--></button> <span class="cinder-jse-property-row__spacer"></span> `);
539
591
  Button($$renderer2, {
540
592
  variant: isRequired ? "primary" : "ghost",
541
593
  size: "xs",
542
594
  disabled: readonly,
543
595
  "aria-pressed": isRequired,
544
- "aria-label": isRequired ? "Required (toggle off)" : "Optional (toggle required)",
596
+ "aria-label": `${key}: ${isRequired ? "Required (toggle off)" : "Optional (toggle required)"}`,
545
597
  onclick: () => toggleRequired(key),
546
598
  children: ($$renderer3) => {
547
599
  $$renderer3.push(`<!---->${$3.escape(isRequired ? "Required" : "Optional")}`);
@@ -552,9 +604,9 @@ function Property_list($$renderer, $$props) {
552
604
  Button($$renderer2, {
553
605
  variant: "ghost",
554
606
  size: "xs",
555
- disabled: readonly,
556
- "aria-label": "Move up",
557
- onclick: () => moveProperty(key, -1),
607
+ disabled: readonly || !canMoveProperty(index, -1),
608
+ "aria-label": `Move ${key} up`,
609
+ onclick: () => moveProperty(key, -1, index),
558
610
  children: ($$renderer3) => {
559
611
  $$renderer3.push(`<!---->↑`);
560
612
  },
@@ -564,9 +616,9 @@ function Property_list($$renderer, $$props) {
564
616
  Button($$renderer2, {
565
617
  variant: "ghost",
566
618
  size: "xs",
567
- disabled: readonly,
568
- "aria-label": "Move down",
569
- onclick: () => moveProperty(key, 1),
619
+ disabled: readonly || !canMoveProperty(index, 1),
620
+ "aria-label": `Move ${key} down`,
621
+ onclick: () => moveProperty(key, 1, index),
570
622
  children: ($$renderer3) => {
571
623
  $$renderer3.push(`<!---->↓`);
572
624
  },
@@ -578,7 +630,7 @@ function Property_list($$renderer, $$props) {
578
630
  size: "xs",
579
631
  disabled: readonly,
580
632
  "aria-label": `Delete ${key}`,
581
- onclick: () => deleteProperty(key),
633
+ onclick: () => deleteProperty(key, index),
582
634
  children: ($$renderer3) => {
583
635
  $$renderer3.push(`<!---->Delete`);
584
636
  },
@@ -612,7 +664,7 @@ function Property_list($$renderer, $$props) {
612
664
  }
613
665
  $$renderer2.push(`<!--]--></div>`);
614
666
  }
615
- $$renderer2.push(`<!--]--> `);
667
+ $$renderer2.push(`<!--]--> <span class="cinder-jse-property-list__add-property-reference">`);
616
668
  Button($$renderer2, {
617
669
  variant: "secondary",
618
670
  size: "sm",
@@ -623,7 +675,7 @@ function Property_list($$renderer, $$props) {
623
675
  },
624
676
  $$slots: { default: true }
625
677
  });
626
- $$renderer2.push(`<!----> `);
678
+ $$renderer2.push(`<!----></span> `);
627
679
  if (!readonly || requiredOnly().length > 0) {
628
680
  $$renderer2.push("<!--[0-->");
629
681
  Collapsible2($$renderer2, {
@@ -1065,45 +1117,22 @@ function Property_editor($$renderer, $$props) {
1065
1117
  },
1066
1118
  $$slots: { default: true }
1067
1119
  });
1068
- $$renderer2.push(`<!----> `);
1069
- if (preservedKeys().length > 0) {
1070
- $$renderer2.push("<!--[0-->");
1071
- Tooltip($$renderer2, {
1072
- text: `Preserved keys: ${preservedKeys().join(", ")}`,
1073
- children: ($$renderer3) => {
1074
- Badge($$renderer3, {
1075
- variant: "info",
1076
- children: ($$renderer4) => {
1077
- $$renderer4.push(`<!---->+${$4.escape(preservedKeys().length)} preserved`);
1078
- },
1079
- $$slots: { default: true }
1080
- });
1081
- },
1082
- $$slots: { default: true }
1083
- });
1084
- } else {
1085
- $$renderer2.push("<!--[-1-->");
1086
- }
1087
- $$renderer2.push(`<!--]--></div>`);
1120
+ $$renderer2.push(`<!----></div>`);
1088
1121
  } else {
1089
1122
  $$renderer2.push("<!--[-1-->");
1090
1123
  }
1091
1124
  $$renderer2.push(`<!--]--> `);
1092
- if (readonly && objectValue().$ref === undefined && preservedKeys().length > 0) {
1125
+ if (preservedKeys().length > 0) {
1093
1126
  $$renderer2.push("<!--[0-->");
1094
- Tooltip($$renderer2, {
1095
- text: `Preserved keys: ${preservedKeys().join(", ")}`,
1127
+ $$renderer2.push(`<div class="cinder-jse-advanced-row">`);
1128
+ Badge($$renderer2, {
1129
+ variant: "info",
1096
1130
  children: ($$renderer3) => {
1097
- Badge($$renderer3, {
1098
- variant: "info",
1099
- children: ($$renderer4) => {
1100
- $$renderer4.push(`<!---->+${$4.escape(preservedKeys().length)} preserved`);
1101
- },
1102
- $$slots: { default: true }
1103
- });
1131
+ $$renderer3.push(`<!---->+${$4.escape(preservedKeys().length)} preserved`);
1104
1132
  },
1105
1133
  $$slots: { default: true }
1106
1134
  });
1135
+ $$renderer2.push(`<!----> <span>Preserved keywords: ${$4.escape(preservedKeys().join(", "))}</span></div>`);
1107
1136
  } else {
1108
1137
  $$renderer2.push("<!--[-1-->");
1109
1138
  }
@@ -1350,6 +1379,12 @@ function resolveDraft(draft) {
1350
1379
  var loadAjv = createRetryingLoaderCache(() => import("ajv").then((module) => module.default));
1351
1380
  var loadAjv2019 = createRetryingLoaderCache(() => import("ajv/dist/2019.js").then((module) => module.default));
1352
1381
  var loadAjv2020 = createRetryingLoaderCache(() => import("ajv/dist/2020.js").then((module) => module.default));
1382
+ var loadAjvFormats = createRetryingLoaderCache(() => import("ajv-formats").then((module) => module.default));
1383
+ async function registerStandardFormats(ajv) {
1384
+ const formats = await loadAjvFormats();
1385
+ formats(ajv);
1386
+ return ajv;
1387
+ }
1353
1388
  var metaAjv2020 = null;
1354
1389
  var metaAjv2019 = null;
1355
1390
  var metaAjv07 = null;
@@ -1424,13 +1459,13 @@ async function tryCompile(schema, draft) {
1424
1459
  let ajv;
1425
1460
  if (resolved === "2020-12") {
1426
1461
  const Ajv2020Class = await loadAjv2020();
1427
- ajv = new Ajv2020Class({ strict: false, addUsedSchema: false });
1462
+ ajv = await registerStandardFormats(new Ajv2020Class({ strict: false, addUsedSchema: false }));
1428
1463
  } else if (resolved === "2019-09") {
1429
1464
  const Ajv2019Class = await loadAjv2019();
1430
- ajv = new Ajv2019Class({ strict: false, addUsedSchema: false });
1465
+ ajv = await registerStandardFormats(new Ajv2019Class({ strict: false, addUsedSchema: false }));
1431
1466
  } else {
1432
1467
  const AjvClass = await loadAjv();
1433
- ajv = new AjvClass({ strict: false, addUsedSchema: false });
1468
+ ajv = await registerStandardFormats(new AjvClass({ strict: false, addUsedSchema: false }));
1434
1469
  }
1435
1470
  ajv.compile(schema);
1436
1471
  return { ok: true };
@@ -1589,6 +1624,15 @@ var COMPILE_DEFER_BYTES = 1e5;
1589
1624
  function serialise(value) {
1590
1625
  return JSON.stringify(value, null, PRETTY_INDENT2);
1591
1626
  }
1627
+ function createSchemaHistory(initial, maxDepth) {
1628
+ const options = {
1629
+ initial,
1630
+ equals: (left, right) => JSON.stringify(left) === JSON.stringify(right)
1631
+ };
1632
+ if (maxDepth !== undefined)
1633
+ options.maxDepth = maxDepth;
1634
+ return useHistory(options);
1635
+ }
1592
1636
  function isPlainRecord(value) {
1593
1637
  return value !== null && typeof value === "object" && !Array.isArray(value);
1594
1638
  }
@@ -1784,10 +1828,7 @@ function createEditorState(options) {
1784
1828
  originalLoadError = baselineResult.error;
1785
1829
  }
1786
1830
  if (schemaResult.ok) {
1787
- const useHistoryOptions = { initial: schemaResult.schema };
1788
- if (options.maxHistory !== undefined)
1789
- useHistoryOptions.maxDepth = options.maxHistory;
1790
- history = useHistory(useHistoryOptions);
1831
+ history = createSchemaHistory(schemaResult.schema, options.maxHistory);
1791
1832
  jsonDraftText = schemaResult.canonicalText;
1792
1833
  } else {
1793
1834
  history = null;
@@ -1810,6 +1851,11 @@ function createEditorState(options) {
1810
1851
  return originalRawText.length > 0;
1811
1852
  return stableSerialise(originalSchema) !== stableSerialise(committedSchema());
1812
1853
  });
1854
+ const hasDiffChanges = $7.derived(() => {
1855
+ if (originalSchema === null && committedSchema() === null)
1856
+ return false;
1857
+ return (originalCanonicalText || originalRawText) !== committedCanonicalText();
1858
+ });
1813
1859
  const isFormEditable = $7.derived(() => committedSchema() !== null && !readonly && !jsonDraftIsDirty());
1814
1860
  return {
1815
1861
  get view() {
@@ -1848,6 +1894,9 @@ function createEditorState(options) {
1848
1894
  get hasChanges() {
1849
1895
  return hasChanges();
1850
1896
  },
1897
+ get hasDiffChanges() {
1898
+ return hasDiffChanges();
1899
+ },
1851
1900
  get isFormEditable() {
1852
1901
  return isFormEditable();
1853
1902
  },
@@ -1915,10 +1964,7 @@ function createEditorState(options) {
1915
1964
  if (history) {
1916
1965
  history.commit(schema, { label: "apply JSON" });
1917
1966
  } else {
1918
- const applyOptions = { initial: schema };
1919
- if (options.maxHistory !== undefined)
1920
- applyOptions.maxDepth = options.maxHistory;
1921
- history = useHistory(applyOptions);
1967
+ history = createSchemaHistory(schema, options.maxHistory);
1922
1968
  }
1923
1969
  jsonDraftText = serialise(history.current);
1924
1970
  metaResult = meta;
@@ -1968,10 +2014,7 @@ function createEditorState(options) {
1968
2014
  if (readonly)
1969
2015
  return;
1970
2016
  if (originalSchema !== null) {
1971
- const revertOptions = { initial: originalSchema };
1972
- if (options.maxHistory !== undefined)
1973
- revertOptions.maxDepth = options.maxHistory;
1974
- history = useHistory(revertOptions);
2017
+ history = createSchemaHistory(originalSchema, options.maxHistory);
1975
2018
  jsonDraftText = originalCanonicalText;
1976
2019
  emitChange();
1977
2020
  const epoch = beginValidationCycle();
@@ -2140,7 +2183,7 @@ function Json_schema_toolbar($$renderer, $$props) {
2140
2183
  size: "sm",
2141
2184
  iconOnly: true,
2142
2185
  label: "Revert",
2143
- disabled: !editorState.hasChanges || editorState.readonly,
2186
+ disabled: !editorState.hasDiffChanges || editorState.readonly,
2144
2187
  onclick: () => onRevert?.(),
2145
2188
  children: ($$renderer3) => {
2146
2189
  Rotate_ccw($$renderer3, { class: "cinder-icon-sm" });
@@ -2358,7 +2401,7 @@ function Json_schema_editor_impl($$renderer, $$props) {
2358
2401
  $$renderer5.push(`<!----> `);
2359
2402
  {
2360
2403
  let trailing = function($$renderer6) {
2361
- if (editorState.hasChanges) {
2404
+ if (editorState.hasDiffChanges) {
2362
2405
  $$renderer6.push("<!--[0-->");
2363
2406
  Badge($$renderer6, {
2364
2407
  variant: "neutral",
@@ -2378,7 +2421,7 @@ function Json_schema_editor_impl($$renderer, $$props) {
2378
2421
  trailing,
2379
2422
  children: ($$renderer6) => {
2380
2423
  $$renderer6.push(`<!---->Diff`);
2381
- if (editorState.hasChanges) {
2424
+ if (editorState.hasDiffChanges) {
2382
2425
  $$renderer6.push("<!--[0-->");
2383
2426
  $$renderer6.push(`<span class="cinder-sr-only">, has changes</span>`);
2384
2427
  } else {
@@ -2473,4 +2516,4 @@ function Json_schema_editor($$renderer, $$props) {
2473
2516
  var json_schema_editor_default = Json_schema_editor;
2474
2517
  export { useHistory, Json_schema_editor, json_schema_editor_default };
2475
2518
 
2476
- //# debugId=33E9AFFDF380697164756E2164756E21
2519
+ //# debugId=400C62C9FEB3D0D164756E2164756E21
@@ -213,13 +213,20 @@ function Waveform($$renderer, $$props) {
213
213
  $$renderer2.push(`<!--]--></svg></div> `);
214
214
  if (hasDataTable()) {
215
215
  $$renderer2.push("<!--[0-->");
216
- $$renderer2.push(`<table${$.attr_class($.clsx(dataTableClass(dataTableVisibility)))}><caption>${$.escape(tableCaption())}</caption><thead><tr><th scope="col">Sample index</th><th scope="col">Amplitude</th></tr></thead><tbody><!--[-->`);
216
+ $$renderer2.push(`<div${$.attributes({
217
+ class: $.clsx(dataTableVisibility === "screen-reader-only" ? "cinder-sr-only" : "cinder-waveform__table-scroll"),
218
+ ...dataTableVisibility === "visible" ? {
219
+ role: "region",
220
+ "aria-label": `${label} data table`,
221
+ tabindex: 0
222
+ } : {}
223
+ })}><table${$.attr_class($.clsx(dataTableClass(dataTableVisibility === "screen-reader-only" ? "visible" : dataTableVisibility)))}><caption>${$.escape(tableCaption())}</caption><thead><tr><th scope="col">Sample index</th><th scope="col">Amplitude</th></tr></thead><tbody><!--[-->`);
217
224
  const each_array_1 = $.ensure_array_like(tableSamples());
218
225
  for (let $$index_1 = 0, $$length = each_array_1.length;$$index_1 < $$length; $$index_1++) {
219
226
  let sample = each_array_1[$$index_1];
220
227
  $$renderer2.push(`<tr><td>${$.escape(sample.index)}</td><td>${$.escape(sample.value.toFixed(4))}</td></tr>`);
221
228
  }
222
- $$renderer2.push(`<!--]--></tbody></table>`);
229
+ $$renderer2.push(`<!--]--></tbody></table></div>`);
223
230
  } else {
224
231
  $$renderer2.push("<!--[-1-->");
225
232
  }
@@ -231,4 +238,4 @@ function Waveform($$renderer, $$props) {
231
238
  var waveform_default = Waveform;
232
239
  export { Waveform, waveform_default };
233
240
 
234
- //# debugId=A30082752EC1FED564756E2164756E21
241
+ //# debugId=00D4A740022BB65A64756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lostgradient/cinder",
3
- "version": "0.24.4",
3
+ "version": "0.24.6",
4
4
  "description": "A Svelte 5 component library and design system focused on accessibility, theming, and per-component tree-shaking.",
5
5
  "keywords": [
6
6
  "svelte",
@@ -5829,6 +5829,7 @@
5829
5829
  "@shikijs/types": "^3.21.0",
5830
5830
  "@tanstack/virtual-core": "^3.17.1",
5831
5831
  "ajv": "^8",
5832
+ "ajv-formats": "^3.0.1",
5832
5833
  "esm-env": "^1.2.0",
5833
5834
  "libphonenumber-js": "^1.13.3",
5834
5835
  "lucide-svelte": "0.503.0",
@@ -39,7 +39,7 @@ function lineKindClass(line) {
39
39
  </Alert>
40
40
  {/if}
41
41
 
42
- {#if !state.hasChanges}
42
+ {#if !state.hasDiffChanges}
43
43
  <EmptyState title="No changes yet" description="Edit the schema to see a diff here." />
44
44
  {:else}
45
45
  <div class="cinder-jse-diff-lines" role="group" aria-label="JSON diff">
@@ -186,9 +186,9 @@ function onKeyDown(event) {
186
186
  <Tab value="form">Form</Tab>
187
187
  <Tab value="json">JSON</Tab>
188
188
  <Tab value="diff">
189
- Diff{#if editorState.hasChanges}<span class="cinder-sr-only">, has changes</span>{/if}
189
+ Diff{#if editorState.hasDiffChanges}<span class="cinder-sr-only">, has changes</span>{/if}
190
190
  {#snippet trailing()}
191
- {#if editorState.hasChanges}
191
+ {#if editorState.hasDiffChanges}
192
192
  <Badge variant="neutral" aria-hidden="true">●</Badge>
193
193
  {/if}
194
194
  {/snippet}
@@ -29,6 +29,18 @@ const COMPILE_DEFER_BYTES = 100_000;
29
29
  function serialise(value) {
30
30
  return JSON.stringify(value, null, PRETTY_INDENT);
31
31
  }
32
+ function createSchemaHistory(initial, maxDepth) {
33
+ const options = {
34
+ initial,
35
+ // Schema property order is observable in the editor's emitted JSON and
36
+ // diff. History must retain a reorder even though `hasChanges` keeps its
37
+ // documented key-order-insensitive semantic comparison.
38
+ equals: (left, right) => JSON.stringify(left) === JSON.stringify(right),
39
+ };
40
+ if (maxDepth !== undefined)
41
+ options.maxDepth = maxDepth;
42
+ return useHistory(options);
43
+ }
32
44
  function isPlainRecord(value) {
33
45
  return value !== null && typeof value === 'object' && !Array.isArray(value);
34
46
  }
@@ -288,12 +300,7 @@ export function createEditorState(options) {
288
300
  originalLoadError = baselineResult.error;
289
301
  }
290
302
  if (schemaResult.ok) {
291
- const useHistoryOptions = {
292
- initial: schemaResult.schema,
293
- };
294
- if (options.maxHistory !== undefined)
295
- useHistoryOptions.maxDepth = options.maxHistory;
296
- history = useHistory(useHistoryOptions);
303
+ history = createSchemaHistory(schemaResult.schema, options.maxHistory);
297
304
  jsonDraftText = schemaResult.canonicalText;
298
305
  }
299
306
  else {
@@ -319,6 +326,14 @@ export function createEditorState(options) {
319
326
  return originalRawText.length > 0;
320
327
  return stableSerialise(originalSchema) !== stableSerialise(committedSchema);
321
328
  });
329
+ // `hasChanges` intentionally treats object-key order as semantically equal.
330
+ // The Diff view, however, presents the emitted JSON text, where property
331
+ // order is observable (for example in generated forms and documentation).
332
+ const hasDiffChanges = $derived.by(() => {
333
+ if (originalSchema === null && committedSchema === null)
334
+ return false;
335
+ return (originalCanonicalText || originalRawText) !== committedCanonicalText;
336
+ });
322
337
  const isFormEditable = $derived(committedSchema !== null && !readonly && !jsonDraftIsDirty);
323
338
  // ===== Public API =====
324
339
  return {
@@ -359,6 +374,9 @@ export function createEditorState(options) {
359
374
  get hasChanges() {
360
375
  return hasChanges;
361
376
  },
377
+ get hasDiffChanges() {
378
+ return hasDiffChanges;
379
+ },
362
380
  get isFormEditable() {
363
381
  return isFormEditable;
364
382
  },
@@ -455,10 +473,7 @@ export function createEditorState(options) {
455
473
  history.commit(schema, { label: 'apply JSON' });
456
474
  }
457
475
  else {
458
- const applyOptions = { initial: schema };
459
- if (options.maxHistory !== undefined)
460
- applyOptions.maxDepth = options.maxHistory;
461
- history = useHistory(applyOptions);
476
+ history = createSchemaHistory(schema, options.maxHistory);
462
477
  }
463
478
  jsonDraftText = serialise(history.current);
464
479
  metaResult = meta;
@@ -508,12 +523,7 @@ export function createEditorState(options) {
508
523
  if (readonly)
509
524
  return;
510
525
  if (originalSchema !== null) {
511
- const revertOptions = {
512
- initial: originalSchema,
513
- };
514
- if (options.maxHistory !== undefined)
515
- revertOptions.maxDepth = options.maxHistory;
516
- history = useHistory(revertOptions);
526
+ history = createSchemaHistory(originalSchema, options.maxHistory);
517
527
  jsonDraftText = originalCanonicalText;
518
528
  emitChange();
519
529
  const epoch = beginValidationCycle();
@@ -174,6 +174,14 @@
174
174
  border-top: 0;
175
175
  }
176
176
 
177
+ .cinder-jse-property-list__add-property-reference {
178
+ display: contents;
179
+ }
180
+
181
+ .cinder-jse-property-row[data-cinder-invalid] {
182
+ border-inline-start: 2px solid var(--cinder-color-danger-border);
183
+ }
184
+
177
185
  .cinder-jse-property-row__summary {
178
186
  display: flex;
179
187
  align-items: center;