@dicehub/kappa 0.6.2 → 0.7.0
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 +11 -0
- package/dist/code-highlighted-BDnrVMMM.js +541 -0
- package/dist/code-highlighted-BDnrVMMM.js.map +1 -0
- package/dist/components/code-block/index.d.ts +8 -0
- package/dist/components/code-block.js +10 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/code-highlighted/CodeBlockDisclosure.vue.d.ts +36 -0
- package/dist/components/code-highlighted/CodeHighlighted.vue.d.ts +28 -1
- package/dist/components/code-highlighted/code-highlighted.d.ts +12 -1
- package/dist/components/code-highlighted/use-shiki-highlighter.d.ts +1 -0
- package/dist/components/code-highlighted.js +2 -376
- package/dist/index.js +1 -1
- package/dist/registry/component-registry.json +6 -3
- package/dist/registry/generated.d.ts +22 -4
- package/dist/{registry-DLklQtS0.js → registry-BhOIvW4q.js} +22 -4
- package/dist/registry-BhOIvW4q.js.map +1 -0
- package/dist/registry.js +1 -1
- package/dist/styles/kappa.css +1 -1
- package/package.json +1 -1
- package/dist/components/code-highlighted.js.map +0 -1
- package/dist/registry-DLklQtS0.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @dicehub/kappa
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 78886fd: Add CodeBlock as the preferred code display API at `@dicehub/kappa/components/code-block`. Existing CodeHighlighted imports remain supported. Add line wrapping, title and header actions slots, and keyboard access to scrollable code. Keep line numbers aligned when lines wrap. Add optional collapsed previews with accessible expand and collapse controls; copying always includes the full source. Display plain code and logs without ShikiProvider or highlighting dependencies; the default language is text.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 015e802: Align segmented tab borders with equal inner spacing and nested corner curves. Keep the selected border visible in dark themes and when shadows are disabled.
|
|
12
|
+
- 9823695: Show login and signup content immediately by removing the LoginLayout frame entrance fade and slide.
|
|
13
|
+
|
|
3
14
|
## 0.6.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import { t as e } from "./select-Bxs-8rkj.js";
|
|
2
|
+
import { Fragment as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, inject as u, mergeProps as d, nextTick as f, normalizeClass as p, onBeforeUnmount as m, onMounted as h, openBlock as g, provide as _, ref as v, renderList as y, renderSlot as b, shallowRef as x, toDisplayString as S, unref as C, useSlots as w, watch as T, withCtx as E } from "vue";
|
|
3
|
+
import { Clipboard as D } from "@ark-ui/vue/clipboard";
|
|
4
|
+
import { Collapsible as O } from "@ark-ui/vue/collapsible";
|
|
5
|
+
//#region src/components/code-highlighted/CodeHighlightedCopy.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var k = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "kappa-code-highlighted__copy-icon",
|
|
9
|
+
viewBox: "0 0 16 16",
|
|
10
|
+
fill: "none",
|
|
11
|
+
"aria-hidden": "true",
|
|
12
|
+
focusable: "false"
|
|
13
|
+
}, A = {
|
|
14
|
+
key: 1,
|
|
15
|
+
class: "kappa-code-highlighted__copy-icon",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
fill: "none",
|
|
18
|
+
stroke: "currentColor",
|
|
19
|
+
"stroke-width": "2",
|
|
20
|
+
"aria-hidden": "true",
|
|
21
|
+
focusable: "false"
|
|
22
|
+
}, j = {
|
|
23
|
+
class: "kappa-code-highlighted__copy-status",
|
|
24
|
+
"aria-live": "polite",
|
|
25
|
+
"aria-atomic": "true"
|
|
26
|
+
}, M = /* @__PURE__ */ l({
|
|
27
|
+
__name: "CodeHighlightedCopy",
|
|
28
|
+
props: {
|
|
29
|
+
code: {},
|
|
30
|
+
labels: {}
|
|
31
|
+
},
|
|
32
|
+
setup(e) {
|
|
33
|
+
return (t, n) => (g(), r(C(D).Root, {
|
|
34
|
+
class: "kappa-code-highlighted__copy-root",
|
|
35
|
+
"data-slot": "code-highlighted-copy",
|
|
36
|
+
"model-value": e.code,
|
|
37
|
+
timeout: 2e3
|
|
38
|
+
}, {
|
|
39
|
+
default: E(() => [c(C(D).Context, null, {
|
|
40
|
+
default: E((t) => [c(C(D).Trigger, {
|
|
41
|
+
type: "button",
|
|
42
|
+
class: "kappa-code-highlighted__copy",
|
|
43
|
+
"aria-label": t.copied ? e.labels.copied : e.labels.copy
|
|
44
|
+
}, {
|
|
45
|
+
default: E(() => [t.copied ? (g(), a("svg", k, [...n[0] ||= [o("path", {
|
|
46
|
+
d: "M3.25 8.75 6.25 11.5 12.75 4.5",
|
|
47
|
+
stroke: "currentColor",
|
|
48
|
+
"stroke-width": "1.75",
|
|
49
|
+
"stroke-linecap": "round",
|
|
50
|
+
"stroke-linejoin": "round"
|
|
51
|
+
}, null, -1)]])) : (g(), a("svg", A, [...n[1] ||= [o("rect", {
|
|
52
|
+
x: "3",
|
|
53
|
+
y: "8",
|
|
54
|
+
width: "13",
|
|
55
|
+
height: "13",
|
|
56
|
+
rx: "3"
|
|
57
|
+
}, null, -1), o("path", { d: "M8 8V6a3 3 0 0 1 3-3h7a3 3 0 0 1 3 3v7a3 3 0 0 1-3 3h-2" }, null, -1)]]))]),
|
|
58
|
+
_: 2
|
|
59
|
+
}, 1032, ["aria-label"]), o("span", j, S(t.copied ? e.labels.copied : ""), 1)]),
|
|
60
|
+
_: 1
|
|
61
|
+
})]),
|
|
62
|
+
_: 1
|
|
63
|
+
}, 8, ["model-value"]));
|
|
64
|
+
}
|
|
65
|
+
}), N = ["data-collapsible", "data-animated"], ee = { class: "kappa-code-block__content" }, P = /* @__PURE__ */ l({
|
|
66
|
+
inheritAttrs: !1,
|
|
67
|
+
__name: "CodeBlockDisclosure",
|
|
68
|
+
props: {
|
|
69
|
+
collapsible: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: !1
|
|
72
|
+
},
|
|
73
|
+
collapsedLines: { default: 10 },
|
|
74
|
+
defaultOpen: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: !1
|
|
77
|
+
},
|
|
78
|
+
open: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
expandLabel: { default: "Expand code" },
|
|
83
|
+
collapseLabel: { default: "Collapse code" }
|
|
84
|
+
},
|
|
85
|
+
emits: ["update:open", "openChange"],
|
|
86
|
+
setup(e, { emit: t }) {
|
|
87
|
+
let l = e, u = t, p = v(null), _ = v(null), y = v(l.defaultOpen), x = v(!0), w = v(!1), D, k = n(() => Number.isFinite(l.collapsedLines) ? Math.max(1, Math.floor(l.collapsedLines)) : 10), A = n(() => l.collapsible && x.value), j = n(() => l.open ?? y.value), M = n(() => !A.value || j.value), P = n(() => M.value ? l.collapseLabel : l.expandLabel);
|
|
88
|
+
function F() {
|
|
89
|
+
let e = _.value, t = e?.querySelector("pre");
|
|
90
|
+
if (!e || !t) return;
|
|
91
|
+
let n = getComputedStyle(t), r = Number.parseFloat(n.lineHeight), i = Number.parseFloat(n.paddingTop) + Number.parseFloat(n.paddingBottom);
|
|
92
|
+
x.value = t.scrollHeight > r * k.value + i + 1;
|
|
93
|
+
}
|
|
94
|
+
function I(e) {
|
|
95
|
+
w.value = !0, l.open === void 0 && (y.value = e.open), u("update:open", e.open), u("openChange", e);
|
|
96
|
+
}
|
|
97
|
+
return T(k, () => f(F)), T(j, () => {
|
|
98
|
+
w.value = !0;
|
|
99
|
+
}), T(M, (e) => {
|
|
100
|
+
!e && _.value?.contains(document.activeElement) && p.value?.querySelector("[data-slot='code-block-toggle']")?.focus();
|
|
101
|
+
}, { flush: "post" }), h(() => {
|
|
102
|
+
T(() => l.collapsible, (e) => {
|
|
103
|
+
D?.disconnect(), D = void 0, e && (F(), !(typeof ResizeObserver > "u" || !_.value) && (D = new ResizeObserver(F), D.observe(_.value)));
|
|
104
|
+
}, {
|
|
105
|
+
immediate: !0,
|
|
106
|
+
flush: "post"
|
|
107
|
+
});
|
|
108
|
+
}), m(() => D?.disconnect()), (t, n) => e.collapsible ? (g(), r(C(O).Root, {
|
|
109
|
+
key: 0,
|
|
110
|
+
"as-child": "",
|
|
111
|
+
open: M.value,
|
|
112
|
+
"collapsed-height": e.collapsible ? "calc(var(--kappa-code-collapsed-lines) * 1.25rem + 1.5rem)" : void 0,
|
|
113
|
+
onOpenChange: I
|
|
114
|
+
}, {
|
|
115
|
+
default: E(() => [o("figure", d({
|
|
116
|
+
ref_key: "rootRef",
|
|
117
|
+
ref: p
|
|
118
|
+
}, t.$attrs, {
|
|
119
|
+
"data-collapsible": e.collapsible || void 0,
|
|
120
|
+
"data-animated": w.value || void 0,
|
|
121
|
+
style: { "--kappa-code-collapsed-lines": k.value }
|
|
122
|
+
}), [
|
|
123
|
+
b(t.$slots, "header"),
|
|
124
|
+
c(C(O).Content, {
|
|
125
|
+
class: "kappa-code-block__content",
|
|
126
|
+
"data-slot": "code-block-content"
|
|
127
|
+
}, {
|
|
128
|
+
default: E(() => [o("div", {
|
|
129
|
+
ref_key: "bodyRef",
|
|
130
|
+
ref: _,
|
|
131
|
+
class: "kappa-code-block__body"
|
|
132
|
+
}, [b(t.$slots, "default", { open: M.value })], 512)]),
|
|
133
|
+
_: 3
|
|
134
|
+
}),
|
|
135
|
+
b(t.$slots, "copy"),
|
|
136
|
+
A.value ? (g(), r(C(O).Trigger, {
|
|
137
|
+
key: 0,
|
|
138
|
+
class: "kappa-code-block__toggle",
|
|
139
|
+
"data-slot": "code-block-toggle"
|
|
140
|
+
}, {
|
|
141
|
+
default: E(() => [s(S(P.value) + " ", 1), c(C(O).Indicator, { "as-child": "" }, {
|
|
142
|
+
default: E(() => [...n[0] ||= [o("svg", {
|
|
143
|
+
class: "kappa-code-block__toggle-icon",
|
|
144
|
+
viewBox: "0 0 16 16",
|
|
145
|
+
fill: "none",
|
|
146
|
+
"aria-hidden": "true"
|
|
147
|
+
}, [o("path", { d: "m4.25 6.25 3.75 3.5 3.75-3.5" })], -1)]]),
|
|
148
|
+
_: 1
|
|
149
|
+
})]),
|
|
150
|
+
_: 1
|
|
151
|
+
})) : i("", !0)
|
|
152
|
+
], 16, N)]),
|
|
153
|
+
_: 3
|
|
154
|
+
}, 8, ["open", "collapsed-height"])) : (g(), a("figure", d({
|
|
155
|
+
key: 1,
|
|
156
|
+
ref_key: "rootRef",
|
|
157
|
+
ref: p
|
|
158
|
+
}, t.$attrs), [
|
|
159
|
+
b(t.$slots, "header"),
|
|
160
|
+
o("div", ee, [o("div", {
|
|
161
|
+
ref_key: "bodyRef",
|
|
162
|
+
ref: _,
|
|
163
|
+
class: "kappa-code-block__body"
|
|
164
|
+
}, [b(t.$slots, "default", { open: !0 })], 512)]),
|
|
165
|
+
b(t.$slots, "copy")
|
|
166
|
+
], 16));
|
|
167
|
+
}
|
|
168
|
+
}), F = {
|
|
169
|
+
js: "javascript",
|
|
170
|
+
cjs: "javascript",
|
|
171
|
+
mjs: "javascript",
|
|
172
|
+
ts: "typescript",
|
|
173
|
+
cts: "typescript",
|
|
174
|
+
mts: "typescript",
|
|
175
|
+
sh: "bash",
|
|
176
|
+
zsh: "bash",
|
|
177
|
+
yml: "yaml",
|
|
178
|
+
py: "python",
|
|
179
|
+
md: "markdown",
|
|
180
|
+
gql: "graphql"
|
|
181
|
+
}, I = {
|
|
182
|
+
copy: "Copy",
|
|
183
|
+
copied: "Copied!",
|
|
184
|
+
language: "Code language"
|
|
185
|
+
};
|
|
186
|
+
function L(e) {
|
|
187
|
+
return Object.hasOwn(B, e) ? e : Object.hasOwn(F, e) ? F[e] : null;
|
|
188
|
+
}
|
|
189
|
+
function R(e, t) {
|
|
190
|
+
return [...new Set(e.map((e) => t(e)).filter((e) => e !== null))].sort();
|
|
191
|
+
}
|
|
192
|
+
function z(e, t) {
|
|
193
|
+
return R(e, t).join(",");
|
|
194
|
+
}
|
|
195
|
+
var B = {
|
|
196
|
+
javascript: !0,
|
|
197
|
+
typescript: !0,
|
|
198
|
+
jsx: !0,
|
|
199
|
+
tsx: !0,
|
|
200
|
+
json: !0,
|
|
201
|
+
jsonc: !0,
|
|
202
|
+
html: !0,
|
|
203
|
+
css: !0,
|
|
204
|
+
python: !0,
|
|
205
|
+
yaml: !0,
|
|
206
|
+
markdown: !0,
|
|
207
|
+
graphql: !0,
|
|
208
|
+
sql: !0,
|
|
209
|
+
bash: !0,
|
|
210
|
+
shell: !0,
|
|
211
|
+
diff: !0,
|
|
212
|
+
hcl: !0,
|
|
213
|
+
toml: !0,
|
|
214
|
+
vue: !0
|
|
215
|
+
}, V = Symbol("kappa-shiki-context");
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/components/code-highlighted/use-shiki-highlighter.ts
|
|
218
|
+
function te() {
|
|
219
|
+
let e = u(V, null);
|
|
220
|
+
if (!e) throw Error("useShikiHighlighter must be used within a ShikiProvider. Wrap your app with <ShikiProvider> from '@dicehub/kappa/components/code-highlighted'.");
|
|
221
|
+
return U(e);
|
|
222
|
+
}
|
|
223
|
+
function H() {
|
|
224
|
+
return U(u(V, null));
|
|
225
|
+
}
|
|
226
|
+
function U(e) {
|
|
227
|
+
return {
|
|
228
|
+
highlight: (t, n) => {
|
|
229
|
+
if (!e?.highlighter.value || [
|
|
230
|
+
"text",
|
|
231
|
+
"plain",
|
|
232
|
+
"txt"
|
|
233
|
+
].includes(n)) return null;
|
|
234
|
+
let r = L(n);
|
|
235
|
+
if (!r || !e.languages.value.includes(r)) return console.warn(`[Kappa CodeHighlighted] Language "${n}" is not in the ShikiProvider languages list. Rendering as plain text.`), null;
|
|
236
|
+
try {
|
|
237
|
+
return e.highlighter.value.codeToHtml(t, {
|
|
238
|
+
lang: r,
|
|
239
|
+
themes: {
|
|
240
|
+
light: "github-light",
|
|
241
|
+
dark: "vesper"
|
|
242
|
+
},
|
|
243
|
+
defaultColor: "light-dark()"
|
|
244
|
+
});
|
|
245
|
+
} catch (e) {
|
|
246
|
+
return console.warn(`[Kappa CodeHighlighted] Failed to highlight code with language "${n}":`, e), null;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
isLoading: e?.isLoading ?? v(!1),
|
|
250
|
+
isReady: n(() => !!(e && !e.isLoading.value && e.highlighter.value)),
|
|
251
|
+
error: e?.error ?? x(null),
|
|
252
|
+
labels: e?.labels ?? n(() => I)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/components/code-highlighted/CodeHighlighted.vue?vue&type=script&setup=true&lang.ts
|
|
257
|
+
var W = {
|
|
258
|
+
key: 0,
|
|
259
|
+
class: "kappa-code-highlighted__header"
|
|
260
|
+
}, G = {
|
|
261
|
+
key: 0,
|
|
262
|
+
class: "kappa-code-highlighted__title"
|
|
263
|
+
}, K = {
|
|
264
|
+
key: 2,
|
|
265
|
+
class: "kappa-code-highlighted__actions"
|
|
266
|
+
}, q = ["aria-label", "tabindex"], J = ["innerHTML"], Y = {
|
|
267
|
+
key: 1,
|
|
268
|
+
class: "kappa-code-highlighted__plain"
|
|
269
|
+
}, X = {
|
|
270
|
+
key: 0,
|
|
271
|
+
class: "kappa-code-highlighted__line-number",
|
|
272
|
+
"data-slot": "code-block-line-number",
|
|
273
|
+
"aria-hidden": "true"
|
|
274
|
+
}, Z = { key: 1 }, Q = /* @__PURE__ */ l({
|
|
275
|
+
inheritAttrs: !1,
|
|
276
|
+
__name: "CodeHighlighted",
|
|
277
|
+
props: {
|
|
278
|
+
code: {},
|
|
279
|
+
lang: { default: "text" },
|
|
280
|
+
title: {},
|
|
281
|
+
languageOptions: { default: () => [] },
|
|
282
|
+
showLineNumbers: {
|
|
283
|
+
type: Boolean,
|
|
284
|
+
default: !1
|
|
285
|
+
},
|
|
286
|
+
highlightLines: { default: () => [] },
|
|
287
|
+
showCopyButton: {
|
|
288
|
+
type: Boolean,
|
|
289
|
+
default: !1
|
|
290
|
+
},
|
|
291
|
+
wrap: {
|
|
292
|
+
type: Boolean,
|
|
293
|
+
default: !1
|
|
294
|
+
},
|
|
295
|
+
collapsible: {
|
|
296
|
+
type: Boolean,
|
|
297
|
+
default: !1
|
|
298
|
+
},
|
|
299
|
+
collapsedLines: { default: 10 },
|
|
300
|
+
defaultOpen: {
|
|
301
|
+
type: Boolean,
|
|
302
|
+
default: !1
|
|
303
|
+
},
|
|
304
|
+
open: {
|
|
305
|
+
type: Boolean,
|
|
306
|
+
default: void 0
|
|
307
|
+
},
|
|
308
|
+
expandLabel: { default: "Expand code" },
|
|
309
|
+
collapseLabel: { default: "Collapse code" },
|
|
310
|
+
labels: { default: () => ({}) }
|
|
311
|
+
},
|
|
312
|
+
emits: [
|
|
313
|
+
"update:lang",
|
|
314
|
+
"update:open",
|
|
315
|
+
"openChange"
|
|
316
|
+
],
|
|
317
|
+
setup(l, { emit: u }) {
|
|
318
|
+
let f = l, m = u, h = w(), _ = H(), v = n(() => ({
|
|
319
|
+
..._.labels.value,
|
|
320
|
+
...f.labels
|
|
321
|
+
})), x = n(() => f.code.split("\n")), T = n(() => x.value.length === 1), D = n(() => !!(f.title || h.title || f.languageOptions.length || h.actions)), O = n(() => _.isLoading.value || _.error.value ? null : _.highlight(f.code, f.lang)), k = n(() => N(O.value, f.highlightLines)), A = n(() => f.showLineNumbers && !T.value);
|
|
322
|
+
function j(e) {
|
|
323
|
+
let t = e[0];
|
|
324
|
+
t && t !== f.lang && m("update:lang", t);
|
|
325
|
+
}
|
|
326
|
+
function N(e, t) {
|
|
327
|
+
if (!e) return e;
|
|
328
|
+
let n = new Set(t), r = 0;
|
|
329
|
+
return e.replace(/<span class="line"><\/span>/g, "<span class=\"line\"><br></span>").replace(/<span class="line">/g, () => (r += 1, `<span class="${n.has(r) ? "line line-highlighted" : "line"}">${A.value ? `<span class="kappa-code-highlighted__line-number" data-slot="code-block-line-number" aria-hidden="true">${r}</span>` : ""}`));
|
|
330
|
+
}
|
|
331
|
+
return (n, u) => (g(), r(P, d(n.$attrs, {
|
|
332
|
+
collapsible: l.collapsible,
|
|
333
|
+
"collapsed-lines": l.collapsedLines,
|
|
334
|
+
"default-open": l.defaultOpen,
|
|
335
|
+
open: l.open,
|
|
336
|
+
"expand-label": l.expandLabel,
|
|
337
|
+
"collapse-label": l.collapseLabel,
|
|
338
|
+
"onUpdate:open": u[0] ||= (e) => m("update:open", e),
|
|
339
|
+
onOpenChange: u[1] ||= (e) => m("openChange", e),
|
|
340
|
+
class: ["kappa-code-highlighted kappa-code-block", {
|
|
341
|
+
"kappa-code-highlighted--has-copy": l.showCopyButton,
|
|
342
|
+
"kappa-code-highlighted--single-line": l.showCopyButton && T.value && !D.value,
|
|
343
|
+
"kappa-code-highlighted--with-title": l.title,
|
|
344
|
+
"kappa-code-highlighted--with-header": D.value,
|
|
345
|
+
"kappa-code-highlighted--numbered": A.value
|
|
346
|
+
}],
|
|
347
|
+
"data-slot": "code-highlighted",
|
|
348
|
+
"data-wrap": l.wrap || void 0,
|
|
349
|
+
style: { "--kappa-code-line-number-width": `${String(x.value.length).length + 2}ch` }
|
|
350
|
+
}), {
|
|
351
|
+
header: E(() => [D.value ? (g(), a("figcaption", W, [
|
|
352
|
+
l.title || n.$slots.title ? (g(), a("span", G, [b(n.$slots, "title", {}, () => [s(S(l.title), 1)])])) : i("", !0),
|
|
353
|
+
l.languageOptions.length ? (g(), r(C(e).Root, {
|
|
354
|
+
key: 1,
|
|
355
|
+
class: "kappa-code-highlighted__language-select",
|
|
356
|
+
"aria-label": v.value.language,
|
|
357
|
+
items: l.languageOptions,
|
|
358
|
+
"model-value": [l.lang],
|
|
359
|
+
positioning: {
|
|
360
|
+
placement: "bottom-end",
|
|
361
|
+
gutter: 4,
|
|
362
|
+
sameWidth: !1
|
|
363
|
+
},
|
|
364
|
+
size: "sm",
|
|
365
|
+
"onUpdate:modelValue": j
|
|
366
|
+
}, {
|
|
367
|
+
default: E(() => [c(C(e).Control, null, {
|
|
368
|
+
default: E(() => [c(C(e).Trigger, { class: "kappa-code-highlighted__language-trigger" }, {
|
|
369
|
+
default: E(() => [c(C(e).ValueText), c(C(e).Indicator)]),
|
|
370
|
+
_: 1
|
|
371
|
+
})]),
|
|
372
|
+
_: 1
|
|
373
|
+
}), c(C(e).Positioner, null, {
|
|
374
|
+
default: E(() => [c(C(e).Content, {
|
|
375
|
+
class: "kappa-code-highlighted__language-menu",
|
|
376
|
+
"aria-label": v.value.language
|
|
377
|
+
}, {
|
|
378
|
+
default: E(() => [(g(!0), a(t, null, y(l.languageOptions, (t) => (g(), r(C(e).Item, {
|
|
379
|
+
key: t.value,
|
|
380
|
+
item: t
|
|
381
|
+
}, {
|
|
382
|
+
default: E(() => [s(S(t.label), 1)]),
|
|
383
|
+
_: 2
|
|
384
|
+
}, 1032, ["item"]))), 128))]),
|
|
385
|
+
_: 1
|
|
386
|
+
}, 8, ["aria-label"])]),
|
|
387
|
+
_: 1
|
|
388
|
+
})]),
|
|
389
|
+
_: 1
|
|
390
|
+
}, 8, [
|
|
391
|
+
"aria-label",
|
|
392
|
+
"items",
|
|
393
|
+
"model-value"
|
|
394
|
+
])) : i("", !0),
|
|
395
|
+
n.$slots.actions ? (g(), a("div", K, [b(n.$slots, "actions")])) : i("", !0),
|
|
396
|
+
l.showCopyButton ? (g(), r(M, {
|
|
397
|
+
key: 3,
|
|
398
|
+
code: l.code,
|
|
399
|
+
labels: v.value
|
|
400
|
+
}, null, 8, ["code", "labels"])) : i("", !0)
|
|
401
|
+
])) : i("", !0)]),
|
|
402
|
+
default: E(({ open: e }) => [o("div", {
|
|
403
|
+
class: "kappa-code-highlighted__scroll",
|
|
404
|
+
role: "region",
|
|
405
|
+
"aria-label": l.title || "Code block",
|
|
406
|
+
tabindex: e ? 0 : -1,
|
|
407
|
+
dir: "ltr"
|
|
408
|
+
}, [k.value ? (g(), a("div", {
|
|
409
|
+
key: 0,
|
|
410
|
+
class: "kappa-code-highlighted__shiki",
|
|
411
|
+
innerHTML: k.value
|
|
412
|
+
}, null, 8, J)) : (g(), a("pre", Y, [o("code", null, [(g(!0), a(t, null, y(x.value, (e, t) => (g(), a("span", {
|
|
413
|
+
key: t,
|
|
414
|
+
class: p(["line", { "line-highlighted": l.highlightLines.includes(t + 1) }])
|
|
415
|
+
}, [
|
|
416
|
+
A.value ? (g(), a("span", X, S(t + 1), 1)) : i("", !0),
|
|
417
|
+
s(S(e), 1),
|
|
418
|
+
e ? i("", !0) : (g(), a("br", Z))
|
|
419
|
+
], 2))), 128))])]))], 8, q)]),
|
|
420
|
+
copy: E(() => [l.showCopyButton && !D.value ? (g(), r(M, {
|
|
421
|
+
key: 0,
|
|
422
|
+
code: l.code,
|
|
423
|
+
labels: v.value
|
|
424
|
+
}, null, 8, ["code", "labels"])) : i("", !0)]),
|
|
425
|
+
_: 3
|
|
426
|
+
}, 16, [
|
|
427
|
+
"collapsible",
|
|
428
|
+
"collapsed-lines",
|
|
429
|
+
"default-open",
|
|
430
|
+
"open",
|
|
431
|
+
"expand-label",
|
|
432
|
+
"collapse-label",
|
|
433
|
+
"data-wrap",
|
|
434
|
+
"style",
|
|
435
|
+
"class"
|
|
436
|
+
]));
|
|
437
|
+
}
|
|
438
|
+
}), ne = {
|
|
439
|
+
javascript: () => import("@shikijs/langs/javascript"),
|
|
440
|
+
typescript: () => import("@shikijs/langs/typescript"),
|
|
441
|
+
jsx: () => import("@shikijs/langs/jsx"),
|
|
442
|
+
tsx: () => import("@shikijs/langs/tsx"),
|
|
443
|
+
json: () => import("@shikijs/langs/json"),
|
|
444
|
+
jsonc: () => import("@shikijs/langs/jsonc"),
|
|
445
|
+
html: () => import("@shikijs/langs/html"),
|
|
446
|
+
css: () => import("@shikijs/langs/css"),
|
|
447
|
+
python: () => import("@shikijs/langs/python"),
|
|
448
|
+
yaml: () => import("@shikijs/langs/yaml"),
|
|
449
|
+
markdown: () => import("@shikijs/langs/markdown"),
|
|
450
|
+
graphql: () => import("@shikijs/langs/graphql"),
|
|
451
|
+
sql: () => import("@shikijs/langs/sql"),
|
|
452
|
+
bash: () => import("@shikijs/langs/bash"),
|
|
453
|
+
shell: () => import("@shikijs/langs/shellscript"),
|
|
454
|
+
diff: () => import("@shikijs/langs/diff"),
|
|
455
|
+
hcl: () => import("@shikijs/langs/hcl"),
|
|
456
|
+
toml: () => import("@shikijs/langs/toml"),
|
|
457
|
+
vue: () => import("@shikijs/langs/vue")
|
|
458
|
+
};
|
|
459
|
+
//#endregion
|
|
460
|
+
//#region src/components/code-highlighted/shiki-lifecycle.ts
|
|
461
|
+
function re(e) {
|
|
462
|
+
let t = !1, n = null;
|
|
463
|
+
return (async () => {
|
|
464
|
+
try {
|
|
465
|
+
let r = await e.create();
|
|
466
|
+
if (t) {
|
|
467
|
+
r.dispose();
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
n = r, e.onReady(r);
|
|
471
|
+
} catch (n) {
|
|
472
|
+
t || e.onError(n);
|
|
473
|
+
} finally {
|
|
474
|
+
t || e.onSettled();
|
|
475
|
+
}
|
|
476
|
+
})(), () => {
|
|
477
|
+
t || (t = !0, n?.dispose());
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/components/code-highlighted/ShikiProvider.vue
|
|
482
|
+
var $ = /* @__PURE__ */ l({
|
|
483
|
+
__name: "ShikiProvider",
|
|
484
|
+
props: {
|
|
485
|
+
engine: { default: "javascript" },
|
|
486
|
+
labels: { default: () => ({}) },
|
|
487
|
+
languages: {}
|
|
488
|
+
},
|
|
489
|
+
setup(e) {
|
|
490
|
+
let t = e, r = x(null), i = v(!0), a = x(null), o = v([]), s = n(() => ({
|
|
491
|
+
...I,
|
|
492
|
+
...t.labels
|
|
493
|
+
})), c = n(() => z(t.languages, L)), l = v(!1);
|
|
494
|
+
return _(V, {
|
|
495
|
+
highlighter: r,
|
|
496
|
+
isLoading: i,
|
|
497
|
+
error: a,
|
|
498
|
+
languages: o,
|
|
499
|
+
labels: s
|
|
500
|
+
}), h(() => {
|
|
501
|
+
l.value = !0;
|
|
502
|
+
}), T([
|
|
503
|
+
l,
|
|
504
|
+
() => t.engine,
|
|
505
|
+
c
|
|
506
|
+
], ([e, n], s, c) => {
|
|
507
|
+
if (!e) return;
|
|
508
|
+
let l = R(t.languages, L);
|
|
509
|
+
r.value = null, o.value = [], i.value = !0, a.value = null;
|
|
510
|
+
let u = re({
|
|
511
|
+
async create() {
|
|
512
|
+
let { createHighlighterCore: e } = await import("shiki/core"), t = n === "wasm" ? await import("shiki/engine/oniguruma").then((e) => e.createOnigurumaEngine(import("shiki/wasm"))) : await import("shiki/engine/javascript").then((e) => e.createJavaScriptRegexEngine()), [r, i] = await Promise.all([import("@shikijs/themes/github-light"), import("@shikijs/themes/vesper")]), a = await Promise.all(l.map((e) => ne[e]()));
|
|
513
|
+
return e({
|
|
514
|
+
themes: [r.default, i.default],
|
|
515
|
+
langs: a.map((e) => e.default),
|
|
516
|
+
engine: t
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
onError(e) {
|
|
520
|
+
r.value = null, o.value = [], a.value = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load Shiki");
|
|
521
|
+
},
|
|
522
|
+
onReady(e) {
|
|
523
|
+
r.value = e, o.value = l;
|
|
524
|
+
},
|
|
525
|
+
onSettled() {
|
|
526
|
+
i.value = !1;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
c(() => {
|
|
530
|
+
u(), r.value = null, o.value = [];
|
|
531
|
+
});
|
|
532
|
+
}), (e, t) => b(e.$slots, "default");
|
|
533
|
+
}
|
|
534
|
+
}), ie = Object.assign(Q, {
|
|
535
|
+
Root: Q,
|
|
536
|
+
Provider: $
|
|
537
|
+
});
|
|
538
|
+
//#endregion
|
|
539
|
+
export { I as a, te as i, $ as n, L as o, Q as r, ie as t };
|
|
540
|
+
|
|
541
|
+
//# sourceMappingURL=code-highlighted-BDnrVMMM.js.map
|