@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
|
@@ -19,10 +19,12 @@ function Combobox($$renderer, $$props) {
|
|
|
19
19
|
let {
|
|
20
20
|
id,
|
|
21
21
|
value = "",
|
|
22
|
+
onchange,
|
|
22
23
|
name,
|
|
23
24
|
inputValue = "",
|
|
24
25
|
options,
|
|
25
26
|
label,
|
|
27
|
+
"aria-label": ariaLabel,
|
|
26
28
|
placeholder,
|
|
27
29
|
filter,
|
|
28
30
|
description,
|
|
@@ -30,6 +32,7 @@ function Combobox($$renderer, $$props) {
|
|
|
30
32
|
disabled,
|
|
31
33
|
required,
|
|
32
34
|
maxVisibleOptions = 200,
|
|
35
|
+
allowCustomValue = false,
|
|
33
36
|
class: className,
|
|
34
37
|
"aria-describedby": consumerDescribedBy
|
|
35
38
|
} = $$props;
|
|
@@ -75,8 +78,12 @@ function Combobox($$renderer, $$props) {
|
|
|
75
78
|
let hiddenInputElement = null;
|
|
76
79
|
let listboxElement = null;
|
|
77
80
|
let committedLabel = "";
|
|
81
|
+
let initialCustomValue = "";
|
|
82
|
+
let hasUserCommittedValue = false;
|
|
83
|
+
let hasExplicitNavigation = false;
|
|
84
|
+
let hasStoredInitialValue = false;
|
|
78
85
|
let resetSyncTimeout;
|
|
79
|
-
|
|
86
|
+
let initialValue = untrack(() => value);
|
|
80
87
|
const initialInputValue = untrack(() => inputValue);
|
|
81
88
|
function handleEscape(event = undefined) {
|
|
82
89
|
const wasOpen = open;
|
|
@@ -89,12 +96,30 @@ function Combobox($$renderer, $$props) {
|
|
|
89
96
|
if (wasOpen)
|
|
90
97
|
event?.preventDefault();
|
|
91
98
|
}
|
|
92
|
-
const
|
|
99
|
+
const listboxVisible = $.derived(() => open && filteredOptions().length > 0);
|
|
100
|
+
const activeOptionId = $.derived(() => listboxVisible() && activeIndex >= 0 && activeIndex < filteredOptions().length ? `${id}-option-${activeIndex}` : undefined);
|
|
101
|
+
function findCommittedOption(rawValue) {
|
|
102
|
+
const query = rawValue.trim();
|
|
103
|
+
if (!query)
|
|
104
|
+
return;
|
|
105
|
+
let labelMatch;
|
|
106
|
+
for (const option of options) {
|
|
107
|
+
if (option.disabled)
|
|
108
|
+
continue;
|
|
109
|
+
if (option.value === query)
|
|
110
|
+
return option;
|
|
111
|
+
if (labelMatch === undefined && option.label === query) {
|
|
112
|
+
labelMatch = option;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return labelMatch;
|
|
116
|
+
}
|
|
93
117
|
function handleInput(event) {
|
|
94
118
|
const target = event.target;
|
|
95
119
|
inputValue = target.value;
|
|
96
120
|
open = true;
|
|
97
121
|
activeIndex = filteredOptions().length > 0 ? 0 : -1;
|
|
122
|
+
hasExplicitNavigation = false;
|
|
98
123
|
}
|
|
99
124
|
function handleFocus() {
|
|
100
125
|
if (!resolvedDisabled())
|
|
@@ -104,6 +129,10 @@ function Combobox($$renderer, $$props) {
|
|
|
104
129
|
const next = event.relatedTarget;
|
|
105
130
|
if (next && listboxElement?.contains(next))
|
|
106
131
|
return;
|
|
132
|
+
if (allowCustomValue && inputValue.trim() && inputValue !== committedLabel) {
|
|
133
|
+
commitCustomValue();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
107
136
|
open = false;
|
|
108
137
|
if (inputValue !== committedLabel) {
|
|
109
138
|
inputValue = committedLabel;
|
|
@@ -114,10 +143,35 @@ function Combobox($$renderer, $$props) {
|
|
|
114
143
|
function selectOption(option) {
|
|
115
144
|
if (option.disabled)
|
|
116
145
|
return;
|
|
146
|
+
hasUserCommittedValue = true;
|
|
117
147
|
value = option.value;
|
|
118
148
|
inputValue = option.label;
|
|
119
149
|
committedLabel = option.label;
|
|
120
150
|
open = false;
|
|
151
|
+
onchange?.(option.value);
|
|
152
|
+
}
|
|
153
|
+
function commitCustomValue() {
|
|
154
|
+
const nextValue = inputValue.trim();
|
|
155
|
+
if (!allowCustomValue || !nextValue)
|
|
156
|
+
return;
|
|
157
|
+
if (options.some((option) => option.disabled && (option.value === nextValue || option.label === nextValue))) {
|
|
158
|
+
inputValue = committedLabel;
|
|
159
|
+
if (inputElement)
|
|
160
|
+
inputElement.value = committedLabel;
|
|
161
|
+
open = false;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
hasUserCommittedValue = true;
|
|
165
|
+
const matched = findCommittedOption(nextValue);
|
|
166
|
+
const committedValue = matched?.value ?? nextValue;
|
|
167
|
+
const committedText = matched?.label ?? nextValue;
|
|
168
|
+
const previousValue = value;
|
|
169
|
+
value = committedValue;
|
|
170
|
+
inputValue = committedText;
|
|
171
|
+
committedLabel = committedText;
|
|
172
|
+
open = false;
|
|
173
|
+
if (committedValue !== previousValue)
|
|
174
|
+
onchange?.(committedValue);
|
|
121
175
|
}
|
|
122
176
|
function resetToInitialValue(event) {
|
|
123
177
|
if (resetSyncTimeout !== undefined)
|
|
@@ -126,17 +180,18 @@ function Combobox($$renderer, $$props) {
|
|
|
126
180
|
resetSyncTimeout = undefined;
|
|
127
181
|
if (event.defaultPrevented)
|
|
128
182
|
return;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
183
|
+
const resetValue = hasStoredInitialValue ? initialValue : allowCustomValue ? initialCustomValue || committedLabel : "";
|
|
184
|
+
value = resetValue;
|
|
185
|
+
const matched = options.find((option) => option.value === resetValue);
|
|
186
|
+
const nextInputValue = matched?.label ?? (allowCustomValue ? resetValue : initialInputValue);
|
|
132
187
|
inputValue = nextInputValue;
|
|
133
|
-
committedLabel = matched?.label ?? "";
|
|
188
|
+
committedLabel = matched?.label ?? (allowCustomValue ? resetValue : "");
|
|
134
189
|
open = false;
|
|
135
190
|
activeIndex = -1;
|
|
136
191
|
if (inputElement)
|
|
137
192
|
inputElement.value = nextInputValue;
|
|
138
193
|
if (hiddenInputElement)
|
|
139
|
-
hiddenInputElement.value =
|
|
194
|
+
hiddenInputElement.value = resetValue;
|
|
140
195
|
}, 0);
|
|
141
196
|
}
|
|
142
197
|
function handleKeydown(event) {
|
|
@@ -146,25 +201,32 @@ function Combobox($$renderer, $$props) {
|
|
|
146
201
|
if (filteredOptions().length === 0)
|
|
147
202
|
return;
|
|
148
203
|
activeIndex = (activeIndex + 1) % filteredOptions().length;
|
|
204
|
+
hasExplicitNavigation = true;
|
|
149
205
|
} else if (event.key === "ArrowUp") {
|
|
150
206
|
event.preventDefault();
|
|
151
207
|
open = true;
|
|
152
208
|
if (filteredOptions().length === 0)
|
|
153
209
|
return;
|
|
154
210
|
activeIndex = activeIndex <= 0 ? filteredOptions().length - 1 : activeIndex - 1;
|
|
211
|
+
hasExplicitNavigation = true;
|
|
155
212
|
} else if (event.key === "Home") {
|
|
156
213
|
if (!open)
|
|
157
214
|
return;
|
|
158
215
|
event.preventDefault();
|
|
159
216
|
activeIndex = filteredOptions().length > 0 ? 0 : -1;
|
|
217
|
+
hasExplicitNavigation = true;
|
|
160
218
|
} else if (event.key === "End") {
|
|
161
219
|
if (!open)
|
|
162
220
|
return;
|
|
163
221
|
event.preventDefault();
|
|
164
222
|
activeIndex = filteredOptions().length - 1;
|
|
223
|
+
hasExplicitNavigation = true;
|
|
165
224
|
} else if (event.key === "Enter" && open) {
|
|
166
225
|
const option = filteredOptions()[activeIndex];
|
|
167
|
-
if (option) {
|
|
226
|
+
if (allowCustomValue && !(hasExplicitNavigation && option)) {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
commitCustomValue();
|
|
229
|
+
} else if (option) {
|
|
168
230
|
event.preventDefault();
|
|
169
231
|
selectOption(option);
|
|
170
232
|
}
|
|
@@ -191,7 +253,7 @@ function Combobox($$renderer, $$props) {
|
|
|
191
253
|
} else {
|
|
192
254
|
$$renderer3.push("<!--[-1-->");
|
|
193
255
|
}
|
|
194
|
-
$$renderer3.push(`<!--]--> <div class="cinder-combobox__control"${$.attr("data-cinder-open", open || undefined)}><input${$.attr("id", id)} type="text" role="combobox" class="cinder-combobox__input" autocomplete="off" autocorrect="off" spellcheck="false"${$.attr("disabled", resolvedDisabled(), true)}${$.attr("required", resolvedRequired(), true)}${$.attr("placeholder", placeholder)}${$.attr("value", inputValue)} aria-autocomplete="list"${$.attr("aria-expanded",
|
|
256
|
+
$$renderer3.push(`<!--]--> <div class="cinder-combobox__control"${$.attr("data-cinder-open", open || undefined)}><input${$.attr("id", id)} type="text" role="combobox" class="cinder-combobox__input" autocomplete="off" autocorrect="off" spellcheck="false"${$.attr("disabled", resolvedDisabled(), true)}${$.attr("required", resolvedRequired(), true)}${$.attr("placeholder", placeholder)}${$.attr("value", inputValue)} aria-autocomplete="list"${$.attr("aria-label", ariaLabel?.trim() || undefined)}${$.attr("aria-expanded", listboxVisible())}${$.attr("aria-controls", listboxVisible() ? listboxId() : undefined)}${$.attr("aria-activedescendant", activeOptionId())}${$.attr("aria-invalid", field().ariaInvalid)}${$.attr("aria-required", resolvedRequired() || undefined)}${$.attr("aria-describedby", describedBy())}/></div> `);
|
|
195
257
|
if (name) {
|
|
196
258
|
$$renderer3.push("<!--[0-->");
|
|
197
259
|
$$renderer3.push(`<input type="hidden"${$.attr("name", name)}${$.attr("value", value)}${$.attr("disabled", resolvedDisabled(), true)}/>`);
|
|
@@ -199,7 +261,7 @@ function Combobox($$renderer, $$props) {
|
|
|
199
261
|
$$renderer3.push("<!--[-1-->");
|
|
200
262
|
}
|
|
201
263
|
$$renderer3.push(`<!--]--> `);
|
|
202
|
-
if (
|
|
264
|
+
if (listboxVisible()) {
|
|
203
265
|
$$renderer3.push("<!--[0-->");
|
|
204
266
|
Popover($$renderer3, {
|
|
205
267
|
id: listboxId(),
|
|
@@ -264,8 +326,6 @@ function Combobox($$renderer, $$props) {
|
|
|
264
326
|
}, Combobox);
|
|
265
327
|
}
|
|
266
328
|
|
|
267
|
-
|
|
268
|
-
var combobox_default = Combobox;
|
|
269
|
-
export { Combobox, combobox_default };
|
|
329
|
+
export { Combobox };
|
|
270
330
|
|
|
271
|
-
//# debugId=
|
|
331
|
+
//# debugId=C1FFCBBEAA56BF2964756E2164756E21
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRetryingLoaderCache
|
|
3
|
+
} from "./index.server-mm728d0w.js";
|
|
4
|
+
import {
|
|
5
|
+
__require
|
|
6
|
+
} from "./index.server-0v6na3yp.js";
|
|
7
|
+
|
|
8
|
+
// src/highlighters/shiki/strip-root-pre-tab-index.ts
|
|
9
|
+
function stripRootPreTabIndex(html) {
|
|
10
|
+
const openingPre = /^<pre\b[^>]*>/i.exec(html);
|
|
11
|
+
if (openingPre === null)
|
|
12
|
+
return html;
|
|
13
|
+
return openingPre[0].replace(/\s+tabindex=(?:"[^"]*"|'[^']*'|[^\s>]+)/i, "") + html.slice(openingPre[0].length);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/highlighters/shiki/index.ts
|
|
17
|
+
var DEFAULT_THEME = {
|
|
18
|
+
light: "github-light",
|
|
19
|
+
dark: "github-dark"
|
|
20
|
+
};
|
|
21
|
+
function escapeHtml(value) {
|
|
22
|
+
const safe = typeof value === "string" ? value : "";
|
|
23
|
+
return safe.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
24
|
+
}
|
|
25
|
+
function plaintextBlock(code) {
|
|
26
|
+
return `<pre class="shiki shiki-plaintext"><code>${escapeHtml(code)}</code></pre>`;
|
|
27
|
+
}
|
|
28
|
+
async function ensureLanguageLoaded(shiki, lang) {
|
|
29
|
+
const load = shiki.bundledLanguages[lang];
|
|
30
|
+
if (!load)
|
|
31
|
+
throw new Error(`Language "${lang}" is not bundled with Shiki.`);
|
|
32
|
+
await shiki.highlighter.loadLanguage(load);
|
|
33
|
+
}
|
|
34
|
+
async function ensureThemesLoaded(shiki, theme) {
|
|
35
|
+
const names = typeof theme === "string" ? [theme] : [theme.light, theme.dark];
|
|
36
|
+
for (const name of names) {
|
|
37
|
+
const load = shiki.bundledThemes[name];
|
|
38
|
+
if (!load)
|
|
39
|
+
throw new Error(`Theme "${name}" is not bundled with Shiki.`);
|
|
40
|
+
await shiki.highlighter.loadTheme(load);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function loadGuessedEmbeddedLanguages(shiki, code, lang, resolvedLanguageAliases) {
|
|
44
|
+
for (const guessed of shiki.guessEmbeddedLanguages(code, lang)) {
|
|
45
|
+
try {
|
|
46
|
+
const languageKey = await resolveLanguageKey(shiki, guessed, resolvedLanguageAliases);
|
|
47
|
+
if (languageKey !== undefined)
|
|
48
|
+
await ensureLanguageLoaded(shiki, languageKey);
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function resolveLanguageKey(shiki, normalizedLang, resolvedLanguageAliases) {
|
|
53
|
+
let languageKey = Object.hasOwn(shiki.bundledLanguages, normalizedLang) ? normalizedLang : resolvedLanguageAliases.get(normalizedLang);
|
|
54
|
+
if (languageKey === undefined && shiki.resolveLanguageAliases && !resolvedLanguageAliases.has(normalizedLang)) {
|
|
55
|
+
let loaderFailed = false;
|
|
56
|
+
for (const [candidate, loader] of Object.entries(shiki.bundledLanguages)) {
|
|
57
|
+
try {
|
|
58
|
+
const module = await loader();
|
|
59
|
+
const registrations = module.default;
|
|
60
|
+
if (registrations.some((registration) => registration.aliases?.includes(normalizedLang))) {
|
|
61
|
+
languageKey = candidate;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
} catch {
|
|
65
|
+
loaderFailed = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!loaderFailed || languageKey !== undefined) {
|
|
69
|
+
resolvedLanguageAliases.set(normalizedLang, languageKey);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return languageKey !== undefined && Object.hasOwn(shiki.bundledLanguages, languageKey) ? languageKey : undefined;
|
|
73
|
+
}
|
|
74
|
+
var sharedShikiModule;
|
|
75
|
+
var sharedCuratedModules = new WeakMap;
|
|
76
|
+
var EMPTY_LOADERS = {};
|
|
77
|
+
async function createShikiModule(languageLoaders, themeLoaders, resolveLanguageAliases = true) {
|
|
78
|
+
const [{ createOnigurumaEngine }, coreModule] = await Promise.all([
|
|
79
|
+
import("@shikijs/engine-oniguruma"),
|
|
80
|
+
import("shiki/core")
|
|
81
|
+
]);
|
|
82
|
+
const highlighter = await coreModule.createHighlighterCore({
|
|
83
|
+
themes: [],
|
|
84
|
+
langs: [],
|
|
85
|
+
engine: createOnigurumaEngine(import("shiki/wasm"))
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
highlighter,
|
|
89
|
+
bundledLanguages: languageLoaders ?? {},
|
|
90
|
+
bundledThemes: themeLoaders ?? {},
|
|
91
|
+
guessEmbeddedLanguages: coreModule.guessEmbeddedLanguages,
|
|
92
|
+
resolveLanguageAliases
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function getSharedShikiModule(languageLoaders, themeLoaders) {
|
|
96
|
+
if (languageLoaders !== undefined || themeLoaders !== undefined) {
|
|
97
|
+
const languageKey = languageLoaders ?? EMPTY_LOADERS;
|
|
98
|
+
const themeKey = themeLoaders ?? EMPTY_LOADERS;
|
|
99
|
+
let themes = sharedCuratedModules.get(languageKey);
|
|
100
|
+
if (themes === undefined) {
|
|
101
|
+
themes = new WeakMap;
|
|
102
|
+
sharedCuratedModules.set(languageKey, themes);
|
|
103
|
+
}
|
|
104
|
+
let loader = themes.get(themeKey);
|
|
105
|
+
if (loader === undefined) {
|
|
106
|
+
loader = createRetryingLoaderCache(() => createShikiModule(languageLoaders, themeLoaders));
|
|
107
|
+
themes.set(themeKey, loader);
|
|
108
|
+
}
|
|
109
|
+
return loader();
|
|
110
|
+
}
|
|
111
|
+
sharedShikiModule ??= createRetryingLoaderCache(() => createShikiModule());
|
|
112
|
+
return sharedShikiModule();
|
|
113
|
+
}
|
|
114
|
+
function shikiHighlighter(options = {}, moduleLoader) {
|
|
115
|
+
const { theme = DEFAULT_THEME, langs, languageLoaders, themeLoaders } = options;
|
|
116
|
+
const warnedLanguages = new Set;
|
|
117
|
+
const resolvedLanguageAliases = new Map;
|
|
118
|
+
const loadShiki = createRetryingLoaderCache(moduleLoader ?? (async () => {
|
|
119
|
+
const shikiModule = await getSharedShikiModule(languageLoaders, themeLoaders);
|
|
120
|
+
if (langs !== undefined) {
|
|
121
|
+
try {
|
|
122
|
+
await ensureThemesLoaded(shikiModule, theme);
|
|
123
|
+
} catch {}
|
|
124
|
+
for (const lang of langs) {
|
|
125
|
+
try {
|
|
126
|
+
await ensureLanguageLoaded(shikiModule, lang);
|
|
127
|
+
} catch {}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return shikiModule;
|
|
131
|
+
}));
|
|
132
|
+
return async function highlight(code, lang) {
|
|
133
|
+
const normalizedLang = typeof lang === "string" ? lang.trim().split(/\s+/, 1)[0] ?? "" : "";
|
|
134
|
+
if (normalizedLang === "") {
|
|
135
|
+
return plaintextBlock(code);
|
|
136
|
+
}
|
|
137
|
+
let shiki;
|
|
138
|
+
try {
|
|
139
|
+
shiki = await loadShiki();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.warn("[cinder/highlighters/shiki] failed to load shiki:", error);
|
|
142
|
+
return plaintextBlock(code);
|
|
143
|
+
}
|
|
144
|
+
const languageKey = await resolveLanguageKey(shiki, normalizedLang, resolvedLanguageAliases);
|
|
145
|
+
if (languageKey === undefined || !Object.hasOwn(shiki.bundledLanguages, languageKey)) {
|
|
146
|
+
if (!warnedLanguages.has(normalizedLang)) {
|
|
147
|
+
warnedLanguages.add(normalizedLang);
|
|
148
|
+
console.warn(`[cinder/highlighters/shiki] language "${normalizedLang}" is not in Shiki's bundle; rendering as plaintext.`);
|
|
149
|
+
}
|
|
150
|
+
return plaintextBlock(code);
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
await ensureLanguageLoaded(shiki, languageKey);
|
|
154
|
+
await ensureThemesLoaded(shiki, theme);
|
|
155
|
+
await loadGuessedEmbeddedLanguages(shiki, code, normalizedLang, resolvedLanguageAliases);
|
|
156
|
+
const html = shiki.highlighter.codeToHtml(code, {
|
|
157
|
+
lang: normalizedLang,
|
|
158
|
+
...buildThemeOption(theme)
|
|
159
|
+
});
|
|
160
|
+
return stripRootPreTabIndex(html);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (!warnedLanguages.has(normalizedLang)) {
|
|
163
|
+
warnedLanguages.add(normalizedLang);
|
|
164
|
+
console.warn(`[cinder/highlighters/shiki] failed to highlight "${normalizedLang}":`, error);
|
|
165
|
+
}
|
|
166
|
+
return plaintextBlock(code);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function buildThemeOption(theme) {
|
|
171
|
+
if (typeof theme === "string")
|
|
172
|
+
return { theme };
|
|
173
|
+
return { themes: theme };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export { createShikiModule, shikiHighlighter };
|
|
177
|
+
|
|
178
|
+
//# debugId=FA373B00056187EE64756E2164756E21
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
// src/components/json-editor/json-editor.svelte
|
|
9
9
|
import * as $ from "svelte/internal/server";
|
|
10
|
+
import { tick } from "svelte";
|
|
10
11
|
function Json_editor($$renderer, $$props) {
|
|
11
12
|
$$renderer.component(($$renderer2) => {
|
|
12
13
|
let {
|
|
@@ -17,9 +18,12 @@ function Json_editor($$renderer, $$props) {
|
|
|
17
18
|
error,
|
|
18
19
|
rows = 8,
|
|
19
20
|
showValidFeedback = true,
|
|
21
|
+
highlight = false,
|
|
20
22
|
onValueChange,
|
|
21
23
|
class: className,
|
|
22
24
|
autofocus = false,
|
|
25
|
+
wrap,
|
|
26
|
+
onscroll: consumerOnScroll,
|
|
23
27
|
"aria-describedby": consumerDescribedBy,
|
|
24
28
|
"aria-invalid": consumerInvalid,
|
|
25
29
|
$$slots,
|
|
@@ -30,6 +34,9 @@ function Json_editor($$renderer, $$props) {
|
|
|
30
34
|
let previousValue = value;
|
|
31
35
|
let textareaNode = undefined;
|
|
32
36
|
let resetSyncTimeout;
|
|
37
|
+
let highlightedHtml = null;
|
|
38
|
+
let lintPosition = null;
|
|
39
|
+
let highlightNode = undefined;
|
|
33
40
|
function syncDraftAfterFormReset() {
|
|
34
41
|
if (resetSyncTimeout !== undefined)
|
|
35
42
|
clearTimeout(resetSyncTimeout);
|
|
@@ -56,6 +63,7 @@ function Json_editor($$renderer, $$props) {
|
|
|
56
63
|
const feedbackId = $.derived(() => feedbackText() ? `${id}-feedback` : undefined);
|
|
57
64
|
const describedBy = $.derived(() => composeDescribedBy(descriptionId(), feedbackId(), consumerDescribedBy));
|
|
58
65
|
const ariaInvalid = $.derived(() => feedbackIsError() ? "true" : normalizedConsumerInvalid());
|
|
66
|
+
const hasHighlightOverlay = $.derived(() => highlight && highlightedHtml !== null);
|
|
59
67
|
$$renderer2.push(`<div${$.attr_class($.clsx(classNames("cinder-json-editor", className)))}><label class="cinder-json-editor__label"${$.attr("for", id)}>${$.escape(label)}</label> `);
|
|
60
68
|
if (description) {
|
|
61
69
|
$$renderer2.push("<!--[0-->");
|
|
@@ -63,10 +71,18 @@ function Json_editor($$renderer, $$props) {
|
|
|
63
71
|
} else {
|
|
64
72
|
$$renderer2.push("<!--[-1-->");
|
|
65
73
|
}
|
|
74
|
+
$$renderer2.push(`<!--]--> <div${$.attr_class($.clsx(classNames("cinder-json-editor__input", hasHighlightOverlay() && "cinder-json-editor__input--highlighted", wrap === "off" && "cinder-json-editor__input--nowrap")))}${$.attr("data-cinder-json-lint-position", lintPosition ?? undefined)}>`);
|
|
75
|
+
if (hasHighlightOverlay()) {
|
|
76
|
+
$$renderer2.push("<!--[0-->");
|
|
77
|
+
$$renderer2.push(`<pre class="cinder-json-editor__highlight" aria-hidden="true">${$.html(highlightedHtml)}</pre>`);
|
|
78
|
+
} else {
|
|
79
|
+
$$renderer2.push("<!--[-1-->");
|
|
80
|
+
}
|
|
66
81
|
$$renderer2.push(`<!--]--> <textarea${$.attributes({
|
|
67
82
|
...rest,
|
|
68
83
|
id,
|
|
69
84
|
rows,
|
|
85
|
+
wrap,
|
|
70
86
|
autofocus,
|
|
71
87
|
spellcheck: "false",
|
|
72
88
|
class: "cinder-json-editor__textarea",
|
|
@@ -77,7 +93,7 @@ function Json_editor($$renderer, $$props) {
|
|
|
77
93
|
if ($$body) {
|
|
78
94
|
$$renderer2.push(`${$$body}`);
|
|
79
95
|
} else {}
|
|
80
|
-
$$renderer2.push(`</textarea> `);
|
|
96
|
+
$$renderer2.push(`</textarea></div> `);
|
|
81
97
|
if (feedbackText()) {
|
|
82
98
|
$$renderer2.push("<!--[0-->");
|
|
83
99
|
$$renderer2.push(`<p${$.attr("id", feedbackId())}${$.attr_class($.clsx(classNames("cinder-json-editor__feedback", feedbackIsError() && "cinder-json-editor__feedback--error")))}${$.attr("role", feedbackIsError() ? "alert" : "status")}>${$.escape(feedbackText())}</p>`);
|
|
@@ -92,4 +108,4 @@ function Json_editor($$renderer, $$props) {
|
|
|
92
108
|
var json_editor_default = Json_editor;
|
|
93
109
|
export { Json_editor, json_editor_default };
|
|
94
110
|
|
|
95
|
-
//# debugId=
|
|
111
|
+
//# debugId=35A2985AFEE7C2EF64756E2164756E21
|
|
@@ -17,6 +17,7 @@ function Select($$renderer, $$props) {
|
|
|
17
17
|
value = undefined,
|
|
18
18
|
options,
|
|
19
19
|
label,
|
|
20
|
+
hideLabel = false,
|
|
20
21
|
description,
|
|
21
22
|
error,
|
|
22
23
|
required,
|
|
@@ -45,7 +46,7 @@ function Select($$renderer, $$props) {
|
|
|
45
46
|
$$renderer2.push(`<div${$.attr_class($.clsx(classNames("cinder-select-field", className)))}>`);
|
|
46
47
|
if (label) {
|
|
47
48
|
$$renderer2.push("<!--[0-->");
|
|
48
|
-
$$renderer2.push(`<label${$.attr("for", id)}
|
|
49
|
+
$$renderer2.push(`<label${$.attr("for", id)}${$.attr_class($.clsx(classNames("cinder-select-field__label", hideLabel && "cinder-sr-only")))}${$.attr("data-disabled", field().disabled || undefined)}>${$.escape(label)} `);
|
|
49
50
|
if (field().required) {
|
|
50
51
|
$$renderer2.push("<!--[0-->");
|
|
51
52
|
$$renderer2.push(`<span class="cinder-_required-marker" aria-hidden="true">*</span>`);
|
|
@@ -106,4 +107,4 @@ function Select($$renderer, $$props) {
|
|
|
106
107
|
|
|
107
108
|
export { Select };
|
|
108
109
|
|
|
109
|
-
//# debugId=
|
|
110
|
+
//# debugId=EA31119EFED9073364756E2164756E21
|
|
@@ -35,4 +35,6 @@ export declare const jsonHighlightInternalsForTesting: {
|
|
|
35
35
|
* result in the same `<pre>` for visual parity.
|
|
36
36
|
*/
|
|
37
37
|
export declare function highlightJson(value: string): string;
|
|
38
|
+
/** Highlight source that has already been validated by the caller. */
|
|
39
|
+
export declare function highlightJsonValidated(value: string): string;
|
|
38
40
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lostgradient/cinder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
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",
|
|
@@ -71,7 +71,23 @@
|
|
|
71
71
|
"import": "./src/components/icons/index.ts",
|
|
72
72
|
"default": "./dist/components/icons/index.js"
|
|
73
73
|
},
|
|
74
|
+
"./json-editor/enhancement": {
|
|
75
|
+
"types": "./dist/components/json-editor/json-editor-enhancement.d.ts",
|
|
76
|
+
"browser": "./src/components/json-editor/json-editor-enhancement.ts",
|
|
77
|
+
"node": "./dist/server/components/json-editor/json-editor-enhancement.js",
|
|
78
|
+
"svelte": "./src/components/json-editor/json-editor-enhancement.ts",
|
|
79
|
+
"import": "./src/components/json-editor/json-editor-enhancement.ts",
|
|
80
|
+
"default": "./dist/components/json-editor/json-editor-enhancement.js"
|
|
81
|
+
},
|
|
74
82
|
"./highlighters/shiki": {
|
|
83
|
+
"types": "./dist/highlighters/shiki/default.d.ts",
|
|
84
|
+
"browser": "./src/highlighters/shiki/default.ts",
|
|
85
|
+
"node": "./dist/server/highlighters/shiki/default.js",
|
|
86
|
+
"svelte": "./src/highlighters/shiki/default.ts",
|
|
87
|
+
"import": "./src/highlighters/shiki/default.ts",
|
|
88
|
+
"default": "./dist/highlighters/shiki/default.js"
|
|
89
|
+
},
|
|
90
|
+
"./highlighters/shiki/curated": {
|
|
75
91
|
"types": "./dist/highlighters/shiki/index.d.ts",
|
|
76
92
|
"browser": "./src/highlighters/shiki/index.ts",
|
|
77
93
|
"node": "./dist/server/highlighters/shiki/index.js",
|
|
@@ -6236,6 +6252,7 @@
|
|
|
6236
6252
|
"@types/qrcode": "^1.5.6",
|
|
6237
6253
|
"chalk": "^5.6.2",
|
|
6238
6254
|
"change-case": "^5.4.4",
|
|
6255
|
+
"esbuild": "^0.27.0",
|
|
6239
6256
|
"happy-dom": "^15.11.7",
|
|
6240
6257
|
"js-yaml": "^4.1.0",
|
|
6241
6258
|
"oxlint": "^1.56.0",
|
|
@@ -6251,6 +6268,7 @@
|
|
|
6251
6268
|
"svelte2tsx": "^0.7.33",
|
|
6252
6269
|
"ts-morph": "^28.0.0",
|
|
6253
6270
|
"typescript": "^5.9.0",
|
|
6271
|
+
"vite": "^8.0.9",
|
|
6254
6272
|
"zod": "4.4.1"
|
|
6255
6273
|
},
|
|
6256
6274
|
"peerDependencies": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
import type { Highlighter } from '../../utilities/highlighter.ts';
|
|
32
32
|
import { createRetryingLoaderCache } from '../../utilities/retrying-loader-cache.ts';
|
|
33
33
|
|
|
34
|
-
type ShikiAdapterModule = typeof import('../../highlighters/shiki/
|
|
34
|
+
type ShikiAdapterModule = typeof import('../../highlighters/shiki/default.ts');
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Dynamically import the Shiki adapter module. Kept as a dedicated arrow so
|
|
@@ -40,7 +40,7 @@ type ShikiAdapterModule = typeof import('../../highlighters/shiki/index.ts');
|
|
|
40
40
|
* is no static edge (asserted by `code-block.bundle-boundary.test.ts`).
|
|
41
41
|
*/
|
|
42
42
|
const loadShikiAdapterModule = createRetryingLoaderCache<ShikiAdapterModule>(
|
|
43
|
-
() => import('../../highlighters/shiki/
|
|
43
|
+
() => import('../../highlighters/shiki/default.ts'),
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
/** Memoized default highlighter instance, created once on first success. */
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "Visible label rendered in a `<label>` associated via `for`."
|
|
20
20
|
},
|
|
21
|
+
"aria-label": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Accessible name for the input when no visible label is rendered."
|
|
24
|
+
},
|
|
21
25
|
"placeholder": {
|
|
22
26
|
"type": "string",
|
|
23
27
|
"description": "Placeholder when no value is selected."
|
|
@@ -42,6 +46,10 @@
|
|
|
42
46
|
"type": "number",
|
|
43
47
|
"description": "Hard cap on visible filtered options. Default 200."
|
|
44
48
|
},
|
|
49
|
+
"allowCustomValue": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "Allow committing typed text that is not present in `options`."
|
|
52
|
+
},
|
|
45
53
|
"aria-describedby": {
|
|
46
54
|
"type": "string",
|
|
47
55
|
"description": "External element id(s) to compose into `aria-describedby`. Composed\nafter the component-generated description and error ids, matching the\nfield-control contract in Select. Useful for tooltip ids, counter ids,\nor any external hint."
|
|
@@ -60,6 +68,11 @@
|
|
|
60
68
|
"reason": "function-or-snippet",
|
|
61
69
|
"description": "Custom synchronous filter. Receives an option and the current input\nvalue; returns true to keep. Defaults to case-insensitive substring\nmatch on label."
|
|
62
70
|
},
|
|
71
|
+
{
|
|
72
|
+
"name": "onchange",
|
|
73
|
+
"reason": "function-or-snippet",
|
|
74
|
+
"description": "Called when an option, or an arbitrary value when enabled, is committed."
|
|
75
|
+
},
|
|
63
76
|
{
|
|
64
77
|
"name": "options",
|
|
65
78
|
"reason": "unknown-shape",
|