@lostgradient/cinder 0.17.0 → 0.19.1
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 +28 -0
- package/components.json +3 -2
- package/dist/cli/index.js +2 -2
- package/dist/cli/types.d.ts +1 -0
- package/dist/components/approval-card/index.js +105 -37
- package/dist/components/code-block/index.js +103 -36
- package/dist/components/combobox/combobox.schema.js +14 -1
- package/dist/components/combobox/combobox.svelte.d.ts +12 -12
- package/dist/components/combobox/combobox.types.d.ts +11 -5
- package/dist/components/combobox/index.js +94 -16
- package/dist/components/event-stream-viewer/index.js +3 -2
- package/dist/components/faceted-filter-bar/faceted-filter-bar.css +1 -1
- package/dist/components/invocation-rule-builder/index.js +3602 -380
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +14 -0
- package/dist/components/json-editor/index.js +86 -18
- package/dist/components/json-editor/json-editor-enhancement.d.ts +7 -0
- package/dist/components/json-editor/json-editor-enhancement.js +201 -0
- package/dist/components/json-editor/json-editor.css +68 -0
- package/dist/components/json-editor/json-editor.schema.js +5 -1
- package/dist/components/json-editor/json-editor.types.d.ts +2 -0
- package/dist/components/run-step-timeline/index.js +3 -2
- package/dist/components/schedule-builder/index.js +11 -5
- package/dist/components/schema-form/index.js +11 -5
- package/dist/components/select/index.js +11 -5
- package/dist/components/select/select.schema.js +5 -1
- package/dist/components/select/select.types.d.ts +2 -0
- package/dist/components/stat-group/stat-group.css +1 -0
- package/dist/components/status-dot/index.js +3 -2
- package/dist/highlighters/shiki/default.d.ts +5 -0
- package/dist/highlighters/shiki/default.js +278 -0
- package/dist/highlighters/shiki/index.d.ts +9 -2
- package/dist/highlighters/shiki/index.js +72 -35
- package/dist/index.js +618 -360
- package/dist/server/components/approval-card/index.js +2 -2
- package/dist/server/components/combobox/index.js +5 -3
- package/dist/server/components/event-stream-viewer/index.js +2 -2
- package/dist/server/components/invocation-rule-builder/index.js +15 -2
- package/dist/server/components/json-editor/index.js +1 -1
- package/dist/server/components/json-editor/json-editor-enhancement.js +150 -0
- package/dist/server/components/run-step-timeline/index.js +2 -2
- package/dist/server/components/schedule-builder/index.js +2 -2
- package/dist/server/components/schema-form/index.js +2 -2
- package/dist/server/components/select/index.js +2 -2
- package/dist/server/components/status-dot/index.js +2 -2
- package/dist/server/highlighters/shiki/default.js +39 -0
- package/dist/server/highlighters/shiki/index.js +7 -131
- package/dist/server/index.js +14 -13
- package/dist/server/{index.server-npxtkwjp.js → index.server-0gg1njz4.js} +3 -2
- package/dist/server/{index.server-j87v28yy.js → index.server-0hjcds3y.js} +35 -18
- package/dist/server/{index.server-9vqfmhez.js → index.server-20km2ga0.js} +1 -1
- package/dist/server/{index.server-qxneqxf8.js → index.server-62593nnh.js} +1 -1
- package/dist/server/{index.server-m8ya4p7w.js → index.server-8grn4zd3.js} +74 -14
- package/dist/server/index.server-c9gtmre4.js +178 -0
- package/dist/server/{index.server-66nm5gd5.js → index.server-ghvvqkfc.js} +1 -1
- package/dist/server/{index.server-tez36va4.js → index.server-kvn6cj65.js} +1 -1
- package/dist/server/{index.server-9nac5z11.js → index.server-psqfjzpc.js} +1 -1
- package/dist/server/{index.server-93vt8ktj.js → index.server-v73af5rk.js} +18 -2
- package/dist/server/{index.server-qke3ekjt.js → index.server-ww54rv4y.js} +1 -1
- package/dist/server/index.server-x4a15jpm.js +9 -0
- package/dist/server/{index.server-ex3ea9z0.js → index.server-xsdzbgs2.js} +3 -2
- package/dist/server/{index.server-8ak2cftv.js → index.server-z754e36a.js} +1 -1
- package/dist/utilities/json-highlight.d.ts +2 -0
- package/package.json +19 -1
- package/src/components/code-block/code-block-default-highlighter.ts +2 -2
- package/src/components/combobox/combobox.schema.json +13 -0
- package/src/components/combobox/combobox.schema.ts +13 -0
- package/src/components/combobox/combobox.svelte +100 -14
- package/src/components/combobox/combobox.types.ts +11 -5
- package/src/components/faceted-filter-bar/faceted-filter-bar.css +1 -1
- package/src/components/invocation-rule-builder/invocation-rule-builder.css +14 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +1 -1
- package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +30 -16
- package/src/components/json-editor/json-editor-enhancement.ts +48 -0
- package/src/components/json-editor/json-editor.css +68 -0
- package/src/components/json-editor/json-editor.examples.json +2 -2
- package/src/components/json-editor/json-editor.schema.json +4 -0
- package/src/components/json-editor/json-editor.schema.ts +5 -0
- package/src/components/json-editor/json-editor.svelte +80 -20
- package/src/components/json-editor/json-editor.types.ts +2 -0
- package/src/components/select/select.schema.json +4 -0
- package/src/components/select/select.schema.ts +4 -0
- package/src/components/select/select.svelte +9 -2
- package/src/components/select/select.types.ts +2 -0
- package/src/components/stat-group/stat-group.css +1 -0
- package/src/components/status-dot/status-dot.svelte +6 -1
- package/src/highlighters/shiki/default.ts +46 -0
- package/src/highlighters/shiki/index.ts +101 -32
- package/src/utilities/json-highlight.ts +5 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
|
|
2
|
+
@import '../combobox/combobox.css';
|
|
2
3
|
|
|
3
4
|
@layer cinder.components {
|
|
4
5
|
.cinder-invocation-rule-builder {
|
|
@@ -133,6 +134,19 @@
|
|
|
133
134
|
background-repeat: no-repeat;
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
.cinder-invocation-rule-builder__condition-combobox {
|
|
138
|
+
flex: 1 1 8rem;
|
|
139
|
+
min-inline-size: 6rem;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.cinder-invocation-rule-builder__condition-combobox .cinder-combobox__control {
|
|
143
|
+
min-block-size: var(--cinder-control-height-sm, 2rem);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.cinder-invocation-rule-builder__condition-combobox .cinder-combobox__input {
|
|
147
|
+
min-block-size: var(--cinder-control-height-sm, 2rem);
|
|
148
|
+
}
|
|
149
|
+
|
|
136
150
|
.cinder-invocation-rule-builder__condition-select:focus-visible {
|
|
137
151
|
outline: var(--cinder-ring-width) solid transparent;
|
|
138
152
|
box-shadow: var(--_cinder-focus-ring-shadow);
|
|
@@ -57,6 +57,7 @@ import"@lostgradient/cinder/json-editor/styles";
|
|
|
57
57
|
// src/components/json-editor/json-editor.svelte
|
|
58
58
|
import"svelte/internal/disclose-version";
|
|
59
59
|
import * as $ from "svelte/internal/client";
|
|
60
|
+
import { tick } from "svelte";
|
|
60
61
|
|
|
61
62
|
// src/_internal/field-control.ts
|
|
62
63
|
function describeId(fieldId, hasDescription) {
|
|
@@ -113,28 +114,65 @@ var rest_excludes = new Set([
|
|
|
113
114
|
"error",
|
|
114
115
|
"rows",
|
|
115
116
|
"showValidFeedback",
|
|
117
|
+
"highlight",
|
|
116
118
|
"onValueChange",
|
|
117
119
|
"class",
|
|
118
120
|
"autofocus",
|
|
121
|
+
"wrap",
|
|
122
|
+
"onscroll",
|
|
119
123
|
"aria-describedby",
|
|
120
124
|
"aria-invalid"
|
|
121
125
|
]);
|
|
122
126
|
var root = $.from_html(`<p class="cinder-json-editor__description"> </p>`);
|
|
123
|
-
var root_1 = $.from_html(`<
|
|
124
|
-
var root_2 = $.from_html(`<
|
|
127
|
+
var root_1 = $.from_html(`<pre class="cinder-json-editor__highlight" aria-hidden="true"></pre>`);
|
|
128
|
+
var root_2 = $.from_html(`<p> </p>`);
|
|
129
|
+
var root_3 = $.from_html(`<div><label class="cinder-json-editor__label"> </label> <!> <div><!> <textarea></textarea></div> <!></div>`);
|
|
125
130
|
function Json_editor($$anchor, $$props) {
|
|
126
131
|
$.push($$props, true);
|
|
127
|
-
let rows = $.prop($$props, "rows", 3, 8), showValidFeedback = $.prop($$props, "showValidFeedback", 3, true), autofocus = $.prop($$props, "autofocus", 3, false), rest = $.rest_props($$props, rest_excludes);
|
|
132
|
+
let rows = $.prop($$props, "rows", 3, 8), showValidFeedback = $.prop($$props, "showValidFeedback", 3, true), highlight = $.prop($$props, "highlight", 3, false), autofocus = $.prop($$props, "autofocus", 3, false), rest = $.rest_props($$props, rest_excludes);
|
|
128
133
|
let draftValue = $.state($.proxy($$props.value));
|
|
129
134
|
let previousValue = $$props.value;
|
|
130
135
|
let textareaNode = $.state(undefined);
|
|
131
136
|
let resetSyncTimeout;
|
|
137
|
+
let highlightedHtml = $.state(null);
|
|
138
|
+
let lintPosition = $.state(null);
|
|
139
|
+
let highlightNode = $.state(undefined);
|
|
132
140
|
$.user_effect(() => {
|
|
133
141
|
if ($$props.value === previousValue)
|
|
134
142
|
return;
|
|
135
143
|
previousValue = $$props.value;
|
|
136
144
|
$.set(draftValue, $$props.value, true);
|
|
137
145
|
});
|
|
146
|
+
$.user_effect(() => {
|
|
147
|
+
if (!highlight() || $.get(externalError)) {
|
|
148
|
+
$.set(highlightedHtml, null);
|
|
149
|
+
$.set(lintPosition, null);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const pendingValue = $.get(draftValue);
|
|
153
|
+
let cancelled = false;
|
|
154
|
+
import("@lostgradient/cinder/json-editor/enhancement").then(({ enhanceJson }) => {
|
|
155
|
+
if (cancelled)
|
|
156
|
+
return;
|
|
157
|
+
const result = enhanceJson(pendingValue, $.get(parseIsValid));
|
|
158
|
+
$.set(highlightedHtml, result.html, true);
|
|
159
|
+
$.set(lintPosition, result.lint?.position ?? null, true);
|
|
160
|
+
tick().then(() => {
|
|
161
|
+
if (!cancelled && $.get(highlightNode) && $.get(textareaNode)) {
|
|
162
|
+
$.get(highlightNode).scrollTop = $.get(textareaNode).scrollTop;
|
|
163
|
+
$.get(highlightNode).scrollLeft = $.get(textareaNode).scrollLeft;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}).catch(() => {
|
|
167
|
+
if (!cancelled) {
|
|
168
|
+
$.set(highlightedHtml, null);
|
|
169
|
+
$.set(lintPosition, null);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return () => {
|
|
173
|
+
cancelled = true;
|
|
174
|
+
};
|
|
175
|
+
});
|
|
138
176
|
function syncDraftAfterFormReset() {
|
|
139
177
|
if (resetSyncTimeout !== undefined)
|
|
140
178
|
clearTimeout(resetSyncTimeout);
|
|
@@ -174,7 +212,8 @@ function Json_editor($$anchor, $$props) {
|
|
|
174
212
|
const feedbackId = $.derived(() => $.get(feedbackText) ? `${$$props.id}-feedback` : undefined);
|
|
175
213
|
const describedBy = $.derived(() => composeDescribedBy($.get(descriptionId), $.get(feedbackId), $$props["aria-describedby"]));
|
|
176
214
|
const ariaInvalid2 = $.derived(() => $.get(feedbackIsError) ? "true" : $.get(normalizedConsumerInvalid));
|
|
177
|
-
|
|
215
|
+
const hasHighlightOverlay = $.derived(() => highlight() && $.get(highlightedHtml) !== null);
|
|
216
|
+
var div = root_3();
|
|
178
217
|
var label_1 = $.child(div);
|
|
179
218
|
var text = $.child(label_1, true);
|
|
180
219
|
$.reset(label_1);
|
|
@@ -195,33 +234,59 @@ function Json_editor($$anchor, $$props) {
|
|
|
195
234
|
$$render(consequent);
|
|
196
235
|
});
|
|
197
236
|
}
|
|
198
|
-
var
|
|
199
|
-
$.
|
|
237
|
+
var div_1 = $.sibling(node, 2);
|
|
238
|
+
var node_1 = $.child(div_1);
|
|
239
|
+
{
|
|
240
|
+
var consequent_1 = ($$anchor2) => {
|
|
241
|
+
var pre = root_1();
|
|
242
|
+
$.html(pre, () => $.get(highlightedHtml), true);
|
|
243
|
+
$.reset(pre);
|
|
244
|
+
$.bind_this(pre, ($$value) => $.set(highlightNode, $$value), () => $.get(highlightNode));
|
|
245
|
+
$.append($$anchor2, pre);
|
|
246
|
+
};
|
|
247
|
+
$.if(node_1, ($$render) => {
|
|
248
|
+
if ($.get(hasHighlightOverlay))
|
|
249
|
+
$$render(consequent_1);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
var textarea_1 = $.sibling(node_1, 2);
|
|
253
|
+
$.remove_textarea_child(textarea_1);
|
|
200
254
|
var event_handler = (event) => {
|
|
201
255
|
$.set(draftValue, event.currentTarget.value, true);
|
|
202
256
|
$$props.onValueChange?.($.get(draftValue));
|
|
203
257
|
};
|
|
204
|
-
|
|
258
|
+
var event_handler_1 = (event) => {
|
|
259
|
+
const textarea = event.currentTarget;
|
|
260
|
+
if (!$.get(highlightNode))
|
|
261
|
+
return;
|
|
262
|
+
$.get(highlightNode).scrollTop = textarea.scrollTop;
|
|
263
|
+
$.get(highlightNode).scrollLeft = textarea.scrollLeft;
|
|
264
|
+
$$props.onscroll?.(event);
|
|
265
|
+
};
|
|
266
|
+
$.attribute_effect(textarea_1, () => ({
|
|
205
267
|
...rest,
|
|
206
268
|
id: $$props.id,
|
|
207
269
|
rows: rows(),
|
|
270
|
+
wrap: $$props.wrap,
|
|
208
271
|
autofocus: autofocus(),
|
|
209
272
|
value: $.get(draftValue),
|
|
210
273
|
spellcheck: "false",
|
|
211
274
|
class: "cinder-json-editor__textarea",
|
|
212
275
|
"aria-describedby": $.get(describedBy),
|
|
213
276
|
"aria-invalid": $.get(ariaInvalid2),
|
|
214
|
-
oninput: event_handler
|
|
277
|
+
oninput: event_handler,
|
|
278
|
+
onscroll: event_handler_1
|
|
215
279
|
}));
|
|
216
|
-
$.bind_this(
|
|
217
|
-
$.attach(
|
|
280
|
+
$.bind_this(textarea_1, ($$value) => $.set(textareaNode, $$value), () => $.get(textareaNode));
|
|
281
|
+
$.attach(textarea_1, () => (element) => {
|
|
218
282
|
if (autofocus())
|
|
219
283
|
element.focus();
|
|
220
284
|
});
|
|
221
|
-
|
|
285
|
+
$.reset(div_1);
|
|
286
|
+
var node_2 = $.sibling(div_1, 2);
|
|
222
287
|
{
|
|
223
|
-
var
|
|
224
|
-
var p_1 =
|
|
288
|
+
var consequent_2 = ($$anchor2) => {
|
|
289
|
+
var p_1 = root_2();
|
|
225
290
|
var text_2 = $.child(p_1, true);
|
|
226
291
|
$.reset(p_1);
|
|
227
292
|
$.template_effect(($0) => {
|
|
@@ -234,18 +299,21 @@ function Json_editor($$anchor, $$props) {
|
|
|
234
299
|
]);
|
|
235
300
|
$.append($$anchor2, p_1);
|
|
236
301
|
};
|
|
237
|
-
$.if(
|
|
302
|
+
$.if(node_2, ($$render) => {
|
|
238
303
|
if ($.get(feedbackText))
|
|
239
|
-
$$render(
|
|
304
|
+
$$render(consequent_2);
|
|
240
305
|
});
|
|
241
306
|
}
|
|
242
307
|
$.reset(div);
|
|
243
|
-
$.template_effect(($0) => {
|
|
308
|
+
$.template_effect(($0, $1) => {
|
|
244
309
|
$.set_class(div, 1, $0);
|
|
245
310
|
$.set_attribute(label_1, "for", $$props.id);
|
|
246
311
|
$.set_text(text, $$props.label);
|
|
312
|
+
$.set_class(div_1, 1, $1);
|
|
313
|
+
$.set_attribute(div_1, "data-cinder-json-lint-position", $.get(lintPosition) ?? undefined);
|
|
247
314
|
}, [
|
|
248
|
-
() => $.clsx(classNames("cinder-json-editor", $$props.class))
|
|
315
|
+
() => $.clsx(classNames("cinder-json-editor", $$props.class)),
|
|
316
|
+
() => $.clsx(classNames("cinder-json-editor__input", $.get(hasHighlightOverlay) && "cinder-json-editor__input--highlighted", $$props.wrap === "off" && "cinder-json-editor__input--nowrap"))
|
|
249
317
|
]);
|
|
250
318
|
$.append($$anchor, div);
|
|
251
319
|
$.pop();
|
|
@@ -258,4 +326,4 @@ export {
|
|
|
258
326
|
Json_editor as JsonEditor
|
|
259
327
|
};
|
|
260
328
|
|
|
261
|
-
//# debugId=
|
|
329
|
+
//# debugId=422AB84E6C2CAC5764756E2164756E21
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
function __accessProp(key) {
|
|
7
|
+
return this[key];
|
|
8
|
+
}
|
|
9
|
+
var __toESMCache_node;
|
|
10
|
+
var __toESMCache_esm;
|
|
11
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
12
|
+
var canCache = mod != null && typeof mod === "object";
|
|
13
|
+
if (canCache) {
|
|
14
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
15
|
+
var cached = cache.get(mod);
|
|
16
|
+
if (cached)
|
|
17
|
+
return cached;
|
|
18
|
+
}
|
|
19
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
20
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
21
|
+
for (let key of __getOwnPropNames(mod))
|
|
22
|
+
if (!__hasOwnProp.call(to, key))
|
|
23
|
+
__defProp(to, key, {
|
|
24
|
+
get: __accessProp.bind(mod, key),
|
|
25
|
+
enumerable: true
|
|
26
|
+
});
|
|
27
|
+
if (canCache)
|
|
28
|
+
cache.set(mod, to);
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
32
|
+
var __returnValue = (v) => v;
|
|
33
|
+
function __exportSetter(name, newValue) {
|
|
34
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
35
|
+
}
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, {
|
|
39
|
+
get: all[name],
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
set: __exportSetter.bind(all, name)
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
46
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
47
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
48
|
+
}) : x)(function(x) {
|
|
49
|
+
if (typeof require !== "undefined")
|
|
50
|
+
return require.apply(this, arguments);
|
|
51
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/utilities/json-highlight.ts
|
|
55
|
+
var KEYWORD_NULL = "null";
|
|
56
|
+
var KEYWORD_TRUE = "true";
|
|
57
|
+
var KEYWORD_FALSE = "false";
|
|
58
|
+
function escapeHtml(text) {
|
|
59
|
+
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
60
|
+
}
|
|
61
|
+
function span(kind, raw) {
|
|
62
|
+
return `<span class="cinder-json-token cinder-json-token-${kind}">${escapeHtml(raw)}</span>`;
|
|
63
|
+
}
|
|
64
|
+
function readStringLiteral(source, startIndex) {
|
|
65
|
+
const stringPattern = /"(?:\\.|[^"\\])*"/y;
|
|
66
|
+
stringPattern.lastIndex = startIndex;
|
|
67
|
+
const match = stringPattern.exec(source);
|
|
68
|
+
return match?.[0] ?? source[startIndex] ?? "";
|
|
69
|
+
}
|
|
70
|
+
function readNumberLiteral(source, startIndex) {
|
|
71
|
+
const numberPattern = /-?(?:\d+)(?:\.\d+)?(?:[eE][+-]?\d+)?/y;
|
|
72
|
+
numberPattern.lastIndex = startIndex;
|
|
73
|
+
const match = numberPattern.exec(source);
|
|
74
|
+
return match?.[0] ?? source[startIndex] ?? "";
|
|
75
|
+
}
|
|
76
|
+
function tokenize(source) {
|
|
77
|
+
let output = "";
|
|
78
|
+
let index = 0;
|
|
79
|
+
let pendingKey = false;
|
|
80
|
+
const openerStack = [];
|
|
81
|
+
while (index < source.length) {
|
|
82
|
+
const character = source[index];
|
|
83
|
+
if (character === undefined)
|
|
84
|
+
break;
|
|
85
|
+
if (character === " " || character === "\t" || character === `
|
|
86
|
+
` || character === "\r") {
|
|
87
|
+
output += escapeHtml(character);
|
|
88
|
+
index += 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (character === "{") {
|
|
92
|
+
output += span("punctuation", "{");
|
|
93
|
+
openerStack.push("{");
|
|
94
|
+
pendingKey = true;
|
|
95
|
+
index += 1;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (character === "[") {
|
|
99
|
+
output += span("punctuation", "[");
|
|
100
|
+
openerStack.push("[");
|
|
101
|
+
pendingKey = false;
|
|
102
|
+
index += 1;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (character === "}" || character === "]") {
|
|
106
|
+
output += span("punctuation", character);
|
|
107
|
+
openerStack.pop();
|
|
108
|
+
index += 1;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (character === ",") {
|
|
112
|
+
output += span("punctuation", ",");
|
|
113
|
+
pendingKey = openerStack[openerStack.length - 1] === "{";
|
|
114
|
+
index += 1;
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (character === ":") {
|
|
118
|
+
output += span("punctuation", ":");
|
|
119
|
+
pendingKey = false;
|
|
120
|
+
index += 1;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (character === '"') {
|
|
124
|
+
const literal = readStringLiteral(source, index);
|
|
125
|
+
output += span(pendingKey ? "key" : "string", literal);
|
|
126
|
+
index += literal.length;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (character === "-" || character >= "0" && character <= "9") {
|
|
130
|
+
const literal = readNumberLiteral(source, index);
|
|
131
|
+
output += span("number", literal);
|
|
132
|
+
index += literal.length;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (source.startsWith(KEYWORD_TRUE, index)) {
|
|
136
|
+
output += span("boolean", KEYWORD_TRUE);
|
|
137
|
+
index += KEYWORD_TRUE.length;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (source.startsWith(KEYWORD_FALSE, index)) {
|
|
141
|
+
output += span("boolean", KEYWORD_FALSE);
|
|
142
|
+
index += KEYWORD_FALSE.length;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (source.startsWith(KEYWORD_NULL, index)) {
|
|
146
|
+
output += span("null", KEYWORD_NULL);
|
|
147
|
+
index += KEYWORD_NULL.length;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
output += escapeHtml(character);
|
|
151
|
+
index += 1;
|
|
152
|
+
}
|
|
153
|
+
return `<code class="cinder-json">${output}</code>`;
|
|
154
|
+
}
|
|
155
|
+
function highlightJsonValidated(value) {
|
|
156
|
+
return tokenize(value);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/components/json-editor/json-editor-enhancement.ts
|
|
160
|
+
function lintJson(value, validated) {
|
|
161
|
+
if (validated)
|
|
162
|
+
return;
|
|
163
|
+
try {
|
|
164
|
+
JSON.parse(value);
|
|
165
|
+
return;
|
|
166
|
+
} catch (error) {
|
|
167
|
+
const message = error instanceof SyntaxError ? error.message : "";
|
|
168
|
+
const positionMatch = message.match(/position (\d+)/i);
|
|
169
|
+
const lineColumnMatch = message.match(/line\s+(\d+)\s+column\s+(\d+)/i);
|
|
170
|
+
let position = Number(positionMatch?.[1] ?? value.length);
|
|
171
|
+
if (!positionMatch && lineColumnMatch) {
|
|
172
|
+
const line = Number(lineColumnMatch[1]);
|
|
173
|
+
const column = Number(lineColumnMatch[2]);
|
|
174
|
+
const lines = value.split(`
|
|
175
|
+
`);
|
|
176
|
+
position = lines.slice(0, line - 1).reduce((offset, current) => offset + current.length + 1, 0) + Math.max(0, column - 1);
|
|
177
|
+
}
|
|
178
|
+
return { position };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function escapeHtml2(text) {
|
|
182
|
+
return text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
183
|
+
}
|
|
184
|
+
function enhanceJson(value, validated = false) {
|
|
185
|
+
const lint = lintJson(value, validated);
|
|
186
|
+
if (!lint)
|
|
187
|
+
return { html: highlightJsonValidated(value), lint };
|
|
188
|
+
const position = Math.min(lint.position, value.length);
|
|
189
|
+
const before = escapeHtml2(value.slice(0, position));
|
|
190
|
+
const character = escapeHtml2(value[position] ?? " ");
|
|
191
|
+
const after = escapeHtml2(value.slice(position + 1));
|
|
192
|
+
return {
|
|
193
|
+
html: `<code class="cinder-json">${before}<span class="cinder-json-lint">${character}</span>${after}</code>`,
|
|
194
|
+
lint
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export {
|
|
198
|
+
enhanceJson
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
//# debugId=4F6B4FB19CE86F8E64756E2164756E21
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.cinder-json-editor__textarea {
|
|
23
|
+
display: block;
|
|
24
|
+
inline-size: 100%;
|
|
23
25
|
min-block-size: 10rem;
|
|
24
26
|
resize: vertical;
|
|
25
27
|
border: 1px solid var(--cinder-border);
|
|
@@ -31,6 +33,72 @@
|
|
|
31
33
|
font-size: var(--cinder-text-sm);
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
.cinder-json-editor__input {
|
|
37
|
+
position: relative;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cinder-json-editor__highlight {
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: 0;
|
|
43
|
+
overflow: auto;
|
|
44
|
+
margin: 0;
|
|
45
|
+
border: 1px solid transparent;
|
|
46
|
+
border-radius: var(--cinder-radius-md);
|
|
47
|
+
padding: var(--cinder-space-2);
|
|
48
|
+
background: var(--cinder-surface);
|
|
49
|
+
pointer-events: none;
|
|
50
|
+
white-space: pre-wrap;
|
|
51
|
+
overflow-wrap: anywhere;
|
|
52
|
+
font-family: var(--cinder-font-mono);
|
|
53
|
+
font-size: var(--cinder-text-sm);
|
|
54
|
+
line-height: normal;
|
|
55
|
+
scrollbar-width: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cinder-json-editor__input--nowrap .cinder-json-editor__highlight {
|
|
59
|
+
white-space: pre;
|
|
60
|
+
overflow-wrap: normal;
|
|
61
|
+
width: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cinder-json-editor__highlight::-webkit-scrollbar {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.cinder-json-editor__input--highlighted .cinder-json-editor__textarea {
|
|
69
|
+
position: relative;
|
|
70
|
+
background: transparent;
|
|
71
|
+
color: transparent;
|
|
72
|
+
caret-color: var(--cinder-text);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cinder-json-editor .cinder-json-token-key {
|
|
76
|
+
color: var(--cinder-accent-text);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.cinder-json-editor .cinder-json-token-string {
|
|
80
|
+
color: var(--cinder-color-success-fg);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.cinder-json-editor .cinder-json-token-number {
|
|
84
|
+
color: var(--cinder-color-warning-fg);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.cinder-json-editor .cinder-json-token-boolean,
|
|
88
|
+
.cinder-json-editor .cinder-json-token-null {
|
|
89
|
+
color: var(--cinder-color-info-fg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.cinder-json-editor .cinder-json-token-punctuation {
|
|
93
|
+
color: var(--cinder-text-muted);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.cinder-json-editor .cinder-json-lint {
|
|
97
|
+
text-decoration: underline wavy var(--cinder-danger);
|
|
98
|
+
text-decoration-thickness: 1px;
|
|
99
|
+
text-underline-offset: 2px;
|
|
100
|
+
}
|
|
101
|
+
|
|
34
102
|
.cinder-json-editor__textarea:focus-visible {
|
|
35
103
|
outline: var(--cinder-ring-width) solid transparent;
|
|
36
104
|
box-shadow: var(--_cinder-focus-ring-shadow);
|
|
@@ -92,6 +92,10 @@ var schema = {
|
|
|
92
92
|
type: "boolean",
|
|
93
93
|
description: "Whether valid JSON should render an announced success message. Defaults to true."
|
|
94
94
|
},
|
|
95
|
+
highlight: {
|
|
96
|
+
type: "boolean",
|
|
97
|
+
description: "Enables a lazy syntax-highlighted view with inline parse-error annotation. Defaults to false."
|
|
98
|
+
},
|
|
95
99
|
class: {
|
|
96
100
|
type: "string",
|
|
97
101
|
description: "Extra class names merged onto the field wrapper."
|
|
@@ -114,4 +118,4 @@ export {
|
|
|
114
118
|
json_editor_schema_default as default
|
|
115
119
|
};
|
|
116
120
|
|
|
117
|
-
//# debugId=
|
|
121
|
+
//# debugId=19CC9200CDC727B564756E2164756E21
|
|
@@ -18,6 +18,8 @@ export type JsonEditorProps = Omit<HTMLTextareaAttributes, 'id' | 'value' | 'cla
|
|
|
18
18
|
required?: boolean;
|
|
19
19
|
/** Whether valid JSON should render an announced success message. Defaults to true. */
|
|
20
20
|
showValidFeedback?: boolean;
|
|
21
|
+
/** Enables a lazy syntax-highlighted view with inline parse-error annotation. Defaults to false. */
|
|
22
|
+
highlight?: boolean;
|
|
21
23
|
/** Called with the proposed JSON source whenever the user edits the textarea. */
|
|
22
24
|
onValueChange?: (value: string) => void;
|
|
23
25
|
/** Extra class names merged onto the field wrapper. */
|
|
@@ -621,6 +621,7 @@ function Status_dot($$anchor, $$props) {
|
|
|
621
621
|
const resolvedAriaLabel = $7.derived(() => $7.get(normalizedAriaLabel) ?? $7.get(normalizedLabel) ?? $7.get(resolvedStatus));
|
|
622
622
|
const visibleLabelIsLiveDuplicate = $7.derived(() => $7.get(resolvedLive) && $7.get(normalizedLabel) !== undefined && $7.get(resolvedAriaLabel) !== $7.get(normalizedLabel));
|
|
623
623
|
const needsHiddenLiveLabel = $7.derived(() => $7.get(resolvedLive) && (!$7.get(hasVisibleLabel) || $7.get(visibleLabelIsLiveDuplicate)));
|
|
624
|
+
const liveAriaLabel = $7.derived(() => !$7.get(hasVisibleLabel) && ($7.get(normalizedLabel) !== undefined || $7.get(normalizedAriaLabel) !== undefined) ? $7.get(resolvedAriaLabel) : undefined);
|
|
624
625
|
var span = root_24();
|
|
625
626
|
$7.attribute_effect(span, ($0) => ({
|
|
626
627
|
...rest,
|
|
@@ -631,7 +632,7 @@ function Status_dot($$anchor, $$props) {
|
|
|
631
632
|
role: $7.get(resolvedLive) ? "status" : "img",
|
|
632
633
|
"aria-live": $7.get(resolvedLive) ? "polite" : undefined,
|
|
633
634
|
"aria-atomic": $7.get(resolvedLive) ? "true" : undefined,
|
|
634
|
-
"aria-label": $7.get(resolvedLive) ?
|
|
635
|
+
"aria-label": $7.get(resolvedLive) ? $7.get(liveAriaLabel) : $7.get(resolvedAriaLabel)
|
|
635
636
|
}), [() => classNames("cinder-status-dot", $$props.class)]);
|
|
636
637
|
var node = $7.sibling($7.child(span), 2);
|
|
637
638
|
{
|
|
@@ -1718,4 +1719,4 @@ export {
|
|
|
1718
1719
|
Run_step_timeline as RunStepTimeline
|
|
1719
1720
|
};
|
|
1720
1721
|
|
|
1721
|
-
//# debugId=
|
|
1722
|
+
//# debugId=B0C29A50890B24FA64756E2164756E21
|
|
@@ -1769,6 +1769,7 @@ var rest_excludes6 = new Set([
|
|
|
1769
1769
|
"value",
|
|
1770
1770
|
"options",
|
|
1771
1771
|
"label",
|
|
1772
|
+
"hideLabel",
|
|
1772
1773
|
"description",
|
|
1773
1774
|
"error",
|
|
1774
1775
|
"required",
|
|
@@ -1778,14 +1779,14 @@ var rest_excludes6 = new Set([
|
|
|
1778
1779
|
"aria-invalid"
|
|
1779
1780
|
]);
|
|
1780
1781
|
var root6 = $7.from_html(`<span class="cinder-_required-marker" aria-hidden="true">*</span>`);
|
|
1781
|
-
var root_16 = $7.from_html(`<label
|
|
1782
|
+
var root_16 = $7.from_html(`<label> <!></label>`);
|
|
1782
1783
|
var root_26 = $7.from_html(`<select></select>`);
|
|
1783
1784
|
var root_36 = $7.from_html(`<option> </option>`);
|
|
1784
1785
|
var root_45 = $7.from_html(`<p class="cinder-select-field__description"> </p>`);
|
|
1785
1786
|
var root_53 = $7.from_html(`<div><!> <span class="cinder-select-field__control"><!> <span class="cinder-select-field__chevron" aria-hidden="true"></span></span> <!> <p class="cinder-select-field__error" aria-live="polite"> </p></div>`);
|
|
1786
1787
|
function Select($$anchor, $$props) {
|
|
1787
1788
|
$7.push($$props, true);
|
|
1788
|
-
let value = $7.prop($$props, "value", 15), rest = $7.rest_props($$props, rest_excludes6);
|
|
1789
|
+
let value = $7.prop($$props, "value", 15), hideLabel = $7.prop($$props, "hideLabel", 3, false), rest = $7.rest_props($$props, rest_excludes6);
|
|
1789
1790
|
const context = getFormFieldContext();
|
|
1790
1791
|
const field = $7.derived(() => resolveFieldControl({
|
|
1791
1792
|
id: $$props.id,
|
|
@@ -1803,6 +1804,8 @@ function Select($$anchor, $$props) {
|
|
|
1803
1804
|
$7.user_effect(() => {
|
|
1804
1805
|
if ($$props.options.length === 0) {
|
|
1805
1806
|
devWarn("[cinder/Select] options is empty — pass at least one option, or ignore during async load.");
|
|
1807
|
+
} else if (value() !== undefined && !$$props.options.some((option) => option.value === value())) {
|
|
1808
|
+
devWarn("[cinder/Select] value does not match any option — pass a value from options or omit it.");
|
|
1806
1809
|
}
|
|
1807
1810
|
});
|
|
1808
1811
|
var div = root_53();
|
|
@@ -1823,11 +1826,14 @@ function Select($$anchor, $$props) {
|
|
|
1823
1826
|
});
|
|
1824
1827
|
}
|
|
1825
1828
|
$7.reset(label_1);
|
|
1826
|
-
$7.template_effect(() => {
|
|
1829
|
+
$7.template_effect(($0) => {
|
|
1827
1830
|
$7.set_attribute(label_1, "for", $$props.id);
|
|
1831
|
+
$7.set_class(label_1, 1, $0);
|
|
1828
1832
|
$7.set_attribute(label_1, "data-disabled", $7.get(field).disabled || undefined);
|
|
1829
1833
|
$7.set_text(text, `${$$props.label ?? ""} `);
|
|
1830
|
-
}
|
|
1834
|
+
}, [
|
|
1835
|
+
() => $7.clsx(classNames("cinder-select-field__label", hideLabel() && "cinder-sr-only"))
|
|
1836
|
+
]);
|
|
1831
1837
|
$7.append($$anchor2, label_1);
|
|
1832
1838
|
};
|
|
1833
1839
|
$7.if(node, ($$render) => {
|
|
@@ -3345,4 +3351,4 @@ export {
|
|
|
3345
3351
|
Schedule_builder as ScheduleBuilder
|
|
3346
3352
|
};
|
|
3347
3353
|
|
|
3348
|
-
//# debugId=
|
|
3354
|
+
//# debugId=3D9D2023D93D716464756E2164756E21
|
|
@@ -1167,6 +1167,7 @@ var rest_excludes4 = new Set([
|
|
|
1167
1167
|
"value",
|
|
1168
1168
|
"options",
|
|
1169
1169
|
"label",
|
|
1170
|
+
"hideLabel",
|
|
1170
1171
|
"description",
|
|
1171
1172
|
"error",
|
|
1172
1173
|
"required",
|
|
@@ -1176,14 +1177,14 @@ var rest_excludes4 = new Set([
|
|
|
1176
1177
|
"aria-invalid"
|
|
1177
1178
|
]);
|
|
1178
1179
|
var root4 = $4.from_html(`<span class="cinder-_required-marker" aria-hidden="true">*</span>`);
|
|
1179
|
-
var root_14 = $4.from_html(`<label
|
|
1180
|
+
var root_14 = $4.from_html(`<label> <!></label>`);
|
|
1180
1181
|
var root_24 = $4.from_html(`<select></select>`);
|
|
1181
1182
|
var root_34 = $4.from_html(`<option> </option>`);
|
|
1182
1183
|
var root_44 = $4.from_html(`<p class="cinder-select-field__description"> </p>`);
|
|
1183
1184
|
var root_53 = $4.from_html(`<div><!> <span class="cinder-select-field__control"><!> <span class="cinder-select-field__chevron" aria-hidden="true"></span></span> <!> <p class="cinder-select-field__error" aria-live="polite"> </p></div>`);
|
|
1184
1185
|
function Select($$anchor, $$props) {
|
|
1185
1186
|
$4.push($$props, true);
|
|
1186
|
-
let value = $4.prop($$props, "value", 15), rest = $4.rest_props($$props, rest_excludes4);
|
|
1187
|
+
let value = $4.prop($$props, "value", 15), hideLabel = $4.prop($$props, "hideLabel", 3, false), rest = $4.rest_props($$props, rest_excludes4);
|
|
1187
1188
|
const context = getFormFieldContext();
|
|
1188
1189
|
const field = $4.derived(() => resolveFieldControl({
|
|
1189
1190
|
id: $$props.id,
|
|
@@ -1201,6 +1202,8 @@ function Select($$anchor, $$props) {
|
|
|
1201
1202
|
$4.user_effect(() => {
|
|
1202
1203
|
if ($$props.options.length === 0) {
|
|
1203
1204
|
devWarn("[cinder/Select] options is empty — pass at least one option, or ignore during async load.");
|
|
1205
|
+
} else if (value() !== undefined && !$$props.options.some((option) => option.value === value())) {
|
|
1206
|
+
devWarn("[cinder/Select] value does not match any option — pass a value from options or omit it.");
|
|
1204
1207
|
}
|
|
1205
1208
|
});
|
|
1206
1209
|
var div = root_53();
|
|
@@ -1221,11 +1224,14 @@ function Select($$anchor, $$props) {
|
|
|
1221
1224
|
});
|
|
1222
1225
|
}
|
|
1223
1226
|
$4.reset(label_1);
|
|
1224
|
-
$4.template_effect(() => {
|
|
1227
|
+
$4.template_effect(($0) => {
|
|
1225
1228
|
$4.set_attribute(label_1, "for", $$props.id);
|
|
1229
|
+
$4.set_class(label_1, 1, $0);
|
|
1226
1230
|
$4.set_attribute(label_1, "data-disabled", $4.get(field).disabled || undefined);
|
|
1227
1231
|
$4.set_text(text, `${$$props.label ?? ""} `);
|
|
1228
|
-
}
|
|
1232
|
+
}, [
|
|
1233
|
+
() => $4.clsx(classNames("cinder-select-field__label", hideLabel() && "cinder-sr-only"))
|
|
1234
|
+
]);
|
|
1229
1235
|
$4.append($$anchor2, label_1);
|
|
1230
1236
|
};
|
|
1231
1237
|
$4.if(node, ($$render) => {
|
|
@@ -2727,4 +2733,4 @@ export {
|
|
|
2727
2733
|
Schema_form as SchemaForm
|
|
2728
2734
|
};
|
|
2729
2735
|
|
|
2730
|
-
//# debugId=
|
|
2736
|
+
//# debugId=9E1A8A930A67D35164756E2164756E21
|