@lostgradient/cinder 0.24.4 → 0.24.5
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/CHANGELOG.md +10 -0
- package/components.json +1 -1
- package/dist/components/json-schema-editor/index.js +2095 -5515
- package/dist/components/json-schema-editor/json-schema-editor-state.svelte.d.ts +1 -0
- package/dist/components/json-schema-editor/json-schema-editor.css +4 -0
- package/dist/components/waveform/index.js +17 -5
- package/dist/components/waveform/waveform.css +27 -0
- package/dist/index.js +344 -312
- package/dist/server/components/json-schema-editor/index.js +2 -10
- package/dist/server/components/waveform/index.js +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/{index.server-tdrncj5e.js → index.server-qhfya7fx.js} +10 -3
- package/dist/server/{index.server-7h3nmj3g.js → index.server-tb414d8x.js} +62 -58
- package/package.json +2 -1
- package/src/components/json-schema-editor/diff-view.svelte +1 -1
- package/src/components/json-schema-editor/json-schema-editor-impl.svelte +2 -2
- package/src/components/json-schema-editor/json-schema-editor-state.svelte.ts +26 -16
- package/src/components/json-schema-editor/json-schema-editor.css +4 -0
- package/src/components/json-schema-editor/json-schema-toolbar.svelte +2 -2
- package/src/components/json-schema-editor/json-schema-validator.ts +17 -3
- package/src/components/json-schema-editor/property-editor.constants.ts +0 -1
- package/src/components/json-schema-editor/property-editor.svelte +4 -10
- package/src/components/json-schema-editor/property-list.svelte +19 -4
- package/src/components/waveform/waveform.css +27 -0
- package/src/components/waveform/waveform.svelte +28 -15
- 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-
|
|
4
|
+
} from "../../index.server-tb414d8x.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=
|
|
59
|
+
//# debugId=EA9770FF5B1EEC1B64756E2164756E21
|
package/dist/server/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./index.server-8bvk5czj.js";
|
|
17
17
|
import {
|
|
18
18
|
waveform_default
|
|
19
|
-
} from "./index.server-
|
|
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-
|
|
329
|
+
} from "./index.server-tb414d8x.js";
|
|
330
330
|
import"./index.server-sz6y8xqk.js";
|
|
331
331
|
import"./index.server-mm728d0w.js";
|
|
332
332
|
import"./index.server-w9dtc4a2.js";
|
|
@@ -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(`<
|
|
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=
|
|
241
|
+
//# debugId=00D4A740022BB65A64756E2164756E21
|
|
@@ -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.
|
|
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",
|
|
@@ -331,6 +327,7 @@ function Property_editor_constraints($$renderer, $$props) {
|
|
|
331
327
|
// src/components/json-schema-editor/property-list.svelte
|
|
332
328
|
import * as $3 from "svelte/internal/server";
|
|
333
329
|
import { onDestroy } 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
|
|
@@ -527,15 +524,31 @@ function Property_list($$renderer, $$props) {
|
|
|
527
524
|
let key = each_array[$$index];
|
|
528
525
|
const isRequired = required.includes(key);
|
|
529
526
|
const isOpen = expanded[key] === true;
|
|
527
|
+
const childValidationErrorCount = childValidationCounts[key] ?? 0;
|
|
530
528
|
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)}>`);
|
|
529
|
+
$$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", panelId)}>`);
|
|
532
530
|
Chevron_down($$renderer2, {
|
|
533
531
|
class: "cinder-jse-property-row__chevron",
|
|
534
532
|
size: 14,
|
|
535
533
|
strokeWidth: 2,
|
|
536
534
|
"aria-hidden": "true"
|
|
537
535
|
});
|
|
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
|
|
536
|
+
$$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> `);
|
|
537
|
+
if (childValidationErrorCount > 0) {
|
|
538
|
+
$$renderer2.push("<!--[0-->");
|
|
539
|
+
Badge2($$renderer2, {
|
|
540
|
+
variant: "danger",
|
|
541
|
+
"aria-label": `${childValidationErrorCount} validation ${childValidationErrorCount === 1 ? "error" : "errors"} in ${key}`,
|
|
542
|
+
children: ($$renderer3) => {
|
|
543
|
+
$$renderer3.push(`<!---->${$3.escape(childValidationErrorCount)}
|
|
544
|
+
${$3.escape(childValidationErrorCount === 1 ? "error" : "errors")}`);
|
|
545
|
+
},
|
|
546
|
+
$$slots: { default: true }
|
|
547
|
+
});
|
|
548
|
+
} else {
|
|
549
|
+
$$renderer2.push("<!--[-1-->");
|
|
550
|
+
}
|
|
551
|
+
$$renderer2.push(`<!--]--></button> <span class="cinder-jse-property-row__spacer"></span> `);
|
|
539
552
|
Button($$renderer2, {
|
|
540
553
|
variant: isRequired ? "primary" : "ghost",
|
|
541
554
|
size: "xs",
|
|
@@ -553,7 +566,7 @@ function Property_list($$renderer, $$props) {
|
|
|
553
566
|
variant: "ghost",
|
|
554
567
|
size: "xs",
|
|
555
568
|
disabled: readonly,
|
|
556
|
-
"aria-label":
|
|
569
|
+
"aria-label": `Move ${key} up`,
|
|
557
570
|
onclick: () => moveProperty(key, -1),
|
|
558
571
|
children: ($$renderer3) => {
|
|
559
572
|
$$renderer3.push(`<!---->↑`);
|
|
@@ -565,7 +578,7 @@ function Property_list($$renderer, $$props) {
|
|
|
565
578
|
variant: "ghost",
|
|
566
579
|
size: "xs",
|
|
567
580
|
disabled: readonly,
|
|
568
|
-
"aria-label":
|
|
581
|
+
"aria-label": `Move ${key} down`,
|
|
569
582
|
onclick: () => moveProperty(key, 1),
|
|
570
583
|
children: ($$renderer3) => {
|
|
571
584
|
$$renderer3.push(`<!---->↓`);
|
|
@@ -1065,45 +1078,22 @@ function Property_editor($$renderer, $$props) {
|
|
|
1065
1078
|
},
|
|
1066
1079
|
$$slots: { default: true }
|
|
1067
1080
|
});
|
|
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>`);
|
|
1081
|
+
$$renderer2.push(`<!----></div>`);
|
|
1088
1082
|
} else {
|
|
1089
1083
|
$$renderer2.push("<!--[-1-->");
|
|
1090
1084
|
}
|
|
1091
1085
|
$$renderer2.push(`<!--]--> `);
|
|
1092
|
-
if (
|
|
1086
|
+
if (preservedKeys().length > 0) {
|
|
1093
1087
|
$$renderer2.push("<!--[0-->");
|
|
1094
|
-
|
|
1095
|
-
|
|
1088
|
+
$$renderer2.push(`<div class="cinder-jse-advanced-row">`);
|
|
1089
|
+
Badge($$renderer2, {
|
|
1090
|
+
variant: "info",
|
|
1096
1091
|
children: ($$renderer3) => {
|
|
1097
|
-
|
|
1098
|
-
variant: "info",
|
|
1099
|
-
children: ($$renderer4) => {
|
|
1100
|
-
$$renderer4.push(`<!---->+${$4.escape(preservedKeys().length)} preserved`);
|
|
1101
|
-
},
|
|
1102
|
-
$$slots: { default: true }
|
|
1103
|
-
});
|
|
1092
|
+
$$renderer3.push(`<!---->+${$4.escape(preservedKeys().length)} preserved`);
|
|
1104
1093
|
},
|
|
1105
1094
|
$$slots: { default: true }
|
|
1106
1095
|
});
|
|
1096
|
+
$$renderer2.push(`<!----> <span>Preserved keywords: ${$4.escape(preservedKeys().join(", "))}</span></div>`);
|
|
1107
1097
|
} else {
|
|
1108
1098
|
$$renderer2.push("<!--[-1-->");
|
|
1109
1099
|
}
|
|
@@ -1350,6 +1340,12 @@ function resolveDraft(draft) {
|
|
|
1350
1340
|
var loadAjv = createRetryingLoaderCache(() => import("ajv").then((module) => module.default));
|
|
1351
1341
|
var loadAjv2019 = createRetryingLoaderCache(() => import("ajv/dist/2019.js").then((module) => module.default));
|
|
1352
1342
|
var loadAjv2020 = createRetryingLoaderCache(() => import("ajv/dist/2020.js").then((module) => module.default));
|
|
1343
|
+
var loadAjvFormats = createRetryingLoaderCache(() => import("ajv-formats").then((module) => module.default));
|
|
1344
|
+
async function registerStandardFormats(ajv) {
|
|
1345
|
+
const formats = await loadAjvFormats();
|
|
1346
|
+
formats(ajv);
|
|
1347
|
+
return ajv;
|
|
1348
|
+
}
|
|
1353
1349
|
var metaAjv2020 = null;
|
|
1354
1350
|
var metaAjv2019 = null;
|
|
1355
1351
|
var metaAjv07 = null;
|
|
@@ -1424,13 +1420,13 @@ async function tryCompile(schema, draft) {
|
|
|
1424
1420
|
let ajv;
|
|
1425
1421
|
if (resolved === "2020-12") {
|
|
1426
1422
|
const Ajv2020Class = await loadAjv2020();
|
|
1427
|
-
ajv = new Ajv2020Class({ strict: false, addUsedSchema: false });
|
|
1423
|
+
ajv = await registerStandardFormats(new Ajv2020Class({ strict: false, addUsedSchema: false }));
|
|
1428
1424
|
} else if (resolved === "2019-09") {
|
|
1429
1425
|
const Ajv2019Class = await loadAjv2019();
|
|
1430
|
-
ajv = new Ajv2019Class({ strict: false, addUsedSchema: false });
|
|
1426
|
+
ajv = await registerStandardFormats(new Ajv2019Class({ strict: false, addUsedSchema: false }));
|
|
1431
1427
|
} else {
|
|
1432
1428
|
const AjvClass = await loadAjv();
|
|
1433
|
-
ajv = new AjvClass({ strict: false, addUsedSchema: false });
|
|
1429
|
+
ajv = await registerStandardFormats(new AjvClass({ strict: false, addUsedSchema: false }));
|
|
1434
1430
|
}
|
|
1435
1431
|
ajv.compile(schema);
|
|
1436
1432
|
return { ok: true };
|
|
@@ -1589,6 +1585,15 @@ var COMPILE_DEFER_BYTES = 1e5;
|
|
|
1589
1585
|
function serialise(value) {
|
|
1590
1586
|
return JSON.stringify(value, null, PRETTY_INDENT2);
|
|
1591
1587
|
}
|
|
1588
|
+
function createSchemaHistory(initial, maxDepth) {
|
|
1589
|
+
const options = {
|
|
1590
|
+
initial,
|
|
1591
|
+
equals: (left, right) => JSON.stringify(left) === JSON.stringify(right)
|
|
1592
|
+
};
|
|
1593
|
+
if (maxDepth !== undefined)
|
|
1594
|
+
options.maxDepth = maxDepth;
|
|
1595
|
+
return useHistory(options);
|
|
1596
|
+
}
|
|
1592
1597
|
function isPlainRecord(value) {
|
|
1593
1598
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1594
1599
|
}
|
|
@@ -1784,10 +1789,7 @@ function createEditorState(options) {
|
|
|
1784
1789
|
originalLoadError = baselineResult.error;
|
|
1785
1790
|
}
|
|
1786
1791
|
if (schemaResult.ok) {
|
|
1787
|
-
|
|
1788
|
-
if (options.maxHistory !== undefined)
|
|
1789
|
-
useHistoryOptions.maxDepth = options.maxHistory;
|
|
1790
|
-
history = useHistory(useHistoryOptions);
|
|
1792
|
+
history = createSchemaHistory(schemaResult.schema, options.maxHistory);
|
|
1791
1793
|
jsonDraftText = schemaResult.canonicalText;
|
|
1792
1794
|
} else {
|
|
1793
1795
|
history = null;
|
|
@@ -1810,6 +1812,11 @@ function createEditorState(options) {
|
|
|
1810
1812
|
return originalRawText.length > 0;
|
|
1811
1813
|
return stableSerialise(originalSchema) !== stableSerialise(committedSchema());
|
|
1812
1814
|
});
|
|
1815
|
+
const hasDiffChanges = $7.derived(() => {
|
|
1816
|
+
if (originalSchema === null && committedSchema() === null)
|
|
1817
|
+
return false;
|
|
1818
|
+
return (originalCanonicalText || originalRawText) !== committedCanonicalText();
|
|
1819
|
+
});
|
|
1813
1820
|
const isFormEditable = $7.derived(() => committedSchema() !== null && !readonly && !jsonDraftIsDirty());
|
|
1814
1821
|
return {
|
|
1815
1822
|
get view() {
|
|
@@ -1848,6 +1855,9 @@ function createEditorState(options) {
|
|
|
1848
1855
|
get hasChanges() {
|
|
1849
1856
|
return hasChanges();
|
|
1850
1857
|
},
|
|
1858
|
+
get hasDiffChanges() {
|
|
1859
|
+
return hasDiffChanges();
|
|
1860
|
+
},
|
|
1851
1861
|
get isFormEditable() {
|
|
1852
1862
|
return isFormEditable();
|
|
1853
1863
|
},
|
|
@@ -1915,10 +1925,7 @@ function createEditorState(options) {
|
|
|
1915
1925
|
if (history) {
|
|
1916
1926
|
history.commit(schema, { label: "apply JSON" });
|
|
1917
1927
|
} else {
|
|
1918
|
-
|
|
1919
|
-
if (options.maxHistory !== undefined)
|
|
1920
|
-
applyOptions.maxDepth = options.maxHistory;
|
|
1921
|
-
history = useHistory(applyOptions);
|
|
1928
|
+
history = createSchemaHistory(schema, options.maxHistory);
|
|
1922
1929
|
}
|
|
1923
1930
|
jsonDraftText = serialise(history.current);
|
|
1924
1931
|
metaResult = meta;
|
|
@@ -1968,10 +1975,7 @@ function createEditorState(options) {
|
|
|
1968
1975
|
if (readonly)
|
|
1969
1976
|
return;
|
|
1970
1977
|
if (originalSchema !== null) {
|
|
1971
|
-
|
|
1972
|
-
if (options.maxHistory !== undefined)
|
|
1973
|
-
revertOptions.maxDepth = options.maxHistory;
|
|
1974
|
-
history = useHistory(revertOptions);
|
|
1978
|
+
history = createSchemaHistory(originalSchema, options.maxHistory);
|
|
1975
1979
|
jsonDraftText = originalCanonicalText;
|
|
1976
1980
|
emitChange();
|
|
1977
1981
|
const epoch = beginValidationCycle();
|
|
@@ -2140,7 +2144,7 @@ function Json_schema_toolbar($$renderer, $$props) {
|
|
|
2140
2144
|
size: "sm",
|
|
2141
2145
|
iconOnly: true,
|
|
2142
2146
|
label: "Revert",
|
|
2143
|
-
disabled: !editorState.
|
|
2147
|
+
disabled: !editorState.hasDiffChanges || editorState.readonly,
|
|
2144
2148
|
onclick: () => onRevert?.(),
|
|
2145
2149
|
children: ($$renderer3) => {
|
|
2146
2150
|
Rotate_ccw($$renderer3, { class: "cinder-icon-sm" });
|
|
@@ -2358,7 +2362,7 @@ function Json_schema_editor_impl($$renderer, $$props) {
|
|
|
2358
2362
|
$$renderer5.push(`<!----> `);
|
|
2359
2363
|
{
|
|
2360
2364
|
let trailing = function($$renderer6) {
|
|
2361
|
-
if (editorState.
|
|
2365
|
+
if (editorState.hasDiffChanges) {
|
|
2362
2366
|
$$renderer6.push("<!--[0-->");
|
|
2363
2367
|
Badge($$renderer6, {
|
|
2364
2368
|
variant: "neutral",
|
|
@@ -2378,7 +2382,7 @@ function Json_schema_editor_impl($$renderer, $$props) {
|
|
|
2378
2382
|
trailing,
|
|
2379
2383
|
children: ($$renderer6) => {
|
|
2380
2384
|
$$renderer6.push(`<!---->Diff`);
|
|
2381
|
-
if (editorState.
|
|
2385
|
+
if (editorState.hasDiffChanges) {
|
|
2382
2386
|
$$renderer6.push("<!--[0-->");
|
|
2383
2387
|
$$renderer6.push(`<span class="cinder-sr-only">, has changes</span>`);
|
|
2384
2388
|
} else {
|
|
@@ -2473,4 +2477,4 @@ function Json_schema_editor($$renderer, $$props) {
|
|
|
2473
2477
|
var json_schema_editor_default = Json_schema_editor;
|
|
2474
2478
|
export { useHistory, Json_schema_editor, json_schema_editor_default };
|
|
2475
2479
|
|
|
2476
|
-
//# debugId=
|
|
2480
|
+
//# debugId=0B7834071136231A64756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lostgradient/cinder",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.5",
|
|
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.
|
|
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.
|
|
189
|
+
Diff{#if editorState.hasDiffChanges}<span class="cinder-sr-only">, has changes</span>{/if}
|
|
190
190
|
{#snippet trailing()}
|
|
191
|
-
{#if editorState.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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();
|
|
@@ -63,7 +63,7 @@ $effect(() => {
|
|
|
63
63
|
// when participation changes.
|
|
64
64
|
void editorState.canUndo;
|
|
65
65
|
void editorState.canRedo;
|
|
66
|
-
void editorState.
|
|
66
|
+
void editorState.hasDiffChanges;
|
|
67
67
|
void editorState.readonly;
|
|
68
68
|
void editorState.copyValue;
|
|
69
69
|
// Track `rovingIndex` too so a keydown/focusin handler moving the roved
|
|
@@ -175,7 +175,7 @@ function handleRightFocusin(event) {
|
|
|
175
175
|
size="sm"
|
|
176
176
|
iconOnly
|
|
177
177
|
label="Revert"
|
|
178
|
-
disabled={!editorState.
|
|
178
|
+
disabled={!editorState.hasDiffChanges || editorState.readonly}
|
|
179
179
|
onclick={() => onRevert?.()}
|
|
180
180
|
>
|
|
181
181
|
<RotateCcw class="cinder-icon-sm" />
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import type Ajv from 'ajv';
|
|
22
|
+
import type { FormatsPlugin } from 'ajv-formats';
|
|
22
23
|
import type Ajv2019 from 'ajv/dist/2019.js';
|
|
23
24
|
import type Ajv2020 from 'ajv/dist/2020.js';
|
|
24
25
|
|
|
@@ -83,6 +84,15 @@ const loadAjv2019 = createRetryingLoaderCache(() =>
|
|
|
83
84
|
const loadAjv2020 = createRetryingLoaderCache(() =>
|
|
84
85
|
import('ajv/dist/2020.js').then((module) => module.default),
|
|
85
86
|
);
|
|
87
|
+
const loadAjvFormats = createRetryingLoaderCache(() =>
|
|
88
|
+
import('ajv-formats').then((module) => module.default),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
async function registerStandardFormats(ajv: Ajv | Ajv2019 | Ajv2020) {
|
|
92
|
+
const formats: FormatsPlugin = await loadAjvFormats();
|
|
93
|
+
formats(ajv);
|
|
94
|
+
return ajv;
|
|
95
|
+
}
|
|
86
96
|
|
|
87
97
|
// Long-lived meta-schema validators. Safe to share — they don't compile the
|
|
88
98
|
// user's schema, only validate against the meta-schema.
|
|
@@ -192,13 +202,17 @@ export async function tryCompile(
|
|
|
192
202
|
let ajv: Ajv | Ajv2020 | Ajv2019;
|
|
193
203
|
if (resolved === '2020-12') {
|
|
194
204
|
const Ajv2020Class = await loadAjv2020();
|
|
195
|
-
ajv =
|
|
205
|
+
ajv = await registerStandardFormats(
|
|
206
|
+
new Ajv2020Class({ strict: false, addUsedSchema: false }),
|
|
207
|
+
);
|
|
196
208
|
} else if (resolved === '2019-09') {
|
|
197
209
|
const Ajv2019Class = await loadAjv2019();
|
|
198
|
-
ajv =
|
|
210
|
+
ajv = await registerStandardFormats(
|
|
211
|
+
new Ajv2019Class({ strict: false, addUsedSchema: false }),
|
|
212
|
+
);
|
|
199
213
|
} else {
|
|
200
214
|
const AjvClass = await loadAjv();
|
|
201
|
-
ajv = new AjvClass({ strict: false, addUsedSchema: false });
|
|
215
|
+
ajv = await registerStandardFormats(new AjvClass({ strict: false, addUsedSchema: false }));
|
|
202
216
|
}
|
|
203
217
|
|
|
204
218
|
ajv.compile(schema);
|
|
@@ -14,7 +14,6 @@ import Button from '../button/button.svelte';
|
|
|
14
14
|
import Checkbox from '../checkbox/checkbox.svelte';
|
|
15
15
|
import Collapsible from '@lostgradient/cinder/collapsible';
|
|
16
16
|
import Input from '../input/input.svelte';
|
|
17
|
-
import Tooltip from '../tooltip/tooltip.svelte';
|
|
18
17
|
import { reconcileCompositionBranchKeys } from './composition-branch-keys.ts';
|
|
19
18
|
import { DEFAULT_COLLAPSE_DEPTH, EDITABLE_KEYWORDS, MAX_RENDER_DEPTH, PRIMITIVE_TYPES, } from './property-editor.constants.ts';
|
|
20
19
|
import PropertyEditor from './property-editor.svelte';
|
|
@@ -416,19 +415,14 @@ function addCompositionBranch(keyword) {
|
|
|
416
415
|
>
|
|
417
416
|
Add $ref
|
|
418
417
|
</Button>
|
|
419
|
-
{#if preservedKeys.length > 0}
|
|
420
|
-
<Tooltip text={`Preserved keys: ${preservedKeys.join(', ')}`}>
|
|
421
|
-
<Badge variant="info">+{preservedKeys.length} preserved</Badge>
|
|
422
|
-
</Tooltip>
|
|
423
|
-
{/if}
|
|
424
418
|
</div>
|
|
425
419
|
{/if}
|
|
426
420
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
<Tooltip text={`Preserved keys: ${preservedKeys.join(', ')}`}>
|
|
421
|
+
{#if preservedKeys.length > 0}
|
|
422
|
+
<div class="cinder-jse-advanced-row">
|
|
430
423
|
<Badge variant="info">+{preservedKeys.length} preserved</Badge>
|
|
431
|
-
|
|
424
|
+
<span>Preserved keywords: {preservedKeys.join(', ')}</span>
|
|
425
|
+
</div>
|
|
432
426
|
{/if}
|
|
433
427
|
{/if}
|
|
434
428
|
</div>
|