@mantine-vue/code-highlight 2.4.0 → 3.1.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.
Files changed (32) hide show
  1. package/cjs/index.cjs +511 -576
  2. package/cjs/index.cjs.map +1 -1
  3. package/esm/index.mjs +511 -576
  4. package/esm/index.mjs.map +1 -1
  5. package/lib/CodeHighlight/CodeHighlight.d.ts +46 -496
  6. package/lib/CodeHighlight/CodeHighlight.types.d.ts +80 -0
  7. package/lib/CodeHighlight/CodeHighlight.vue.d.ts +17 -0
  8. package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.d.ts +2 -68
  9. package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.types.d.ts +20 -0
  10. package/lib/CodeHighlight/CodeHighlightControl/CodeHighlightControl.vue.d.ts +15 -0
  11. package/lib/CodeHighlight/CopyCodeButton/CopyCodeButton.d.ts +1 -32
  12. package/lib/CodeHighlight/CopyCodeButton/CopyCodeButton.vue.d.ts +8 -0
  13. package/lib/CodeHighlight/CopyCodeButton/CopyIcon.d.ts +1 -13
  14. package/lib/CodeHighlight/CopyCodeButton/CopyIcon.vue.d.ts +6 -0
  15. package/lib/CodeHighlight/ExpandCodeButton/ExpandCodeButton.d.ts +1 -41
  16. package/lib/CodeHighlight/ExpandCodeButton/ExpandCodeButton.vue.d.ts +15 -0
  17. package/lib/CodeHighlight/ExpandCodeButton/ExpandIcon.d.ts +1 -13
  18. package/lib/CodeHighlight/ExpandCodeButton/ExpandIcon.vue.d.ts +6 -0
  19. package/lib/CodeHighlight/InlineCodeHighlight.d.ts +16 -107
  20. package/lib/CodeHighlight/InlineCodeHighlight.types.d.ts +30 -0
  21. package/lib/CodeHighlight/InlineCodeHighlight.vue.d.ts +5 -0
  22. package/lib/CodeHighlightProvider/CodeHighlightAdapterProvider.vue.d.ts +14 -0
  23. package/lib/CodeHighlightProvider/CodeHighlightProvider.d.ts +19 -32
  24. package/lib/CodeHighlightProvider/CodeHighlightProvider.types.d.ts +25 -0
  25. package/lib/CodeHighlightTabs/CodeHighlightTabs.d.ts +43 -262
  26. package/lib/CodeHighlightTabs/CodeHighlightTabs.types.d.ts +47 -0
  27. package/lib/CodeHighlightTabs/CodeHighlightTabs.vue.d.ts +21 -0
  28. package/lib/CodeHighlightTabs/FileIcon.d.ts +1 -40
  29. package/lib/CodeHighlightTabs/FileIcon.vue.d.ts +21 -0
  30. package/lib/index.d.mts +3 -3
  31. package/lib/index.d.ts +3 -3
  32. package/package.json +3 -3
package/esm/index.mjs CHANGED
@@ -1,300 +1,283 @@
1
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, mergeProps, normalizeProps, onMounted, openBlock, provide, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useAttrs, useSlots, watch, withCtx } from "vue";
1
2
  import { ActionIcon, Box, ScrollArea, Tooltip, UnstyledButton, createSafeContext, createVarsResolver, getRadius, getThemeColor, rem, useMantineContext, useProps, useStyles } from "@mantine-vue/core";
2
3
  import { useClipboard, useUncontrolled } from "@mantine-vue/hooks";
3
- import { computed, defineComponent, h, inject, onMounted, provide, ref, watch } from "vue";
4
- var CodeHighlight_module_default = {
5
- root: "_root_1avu3_1",
6
- codeHighlight: "_codeHighlight_1avu3_5",
7
- inlineCodeHighlight: "_inlineCodeHighlight_1avu3_37",
8
- pre: "_pre_1avu3_71",
9
- code: "_code_1avu3_5",
10
- controls: "_controls_1avu3_101",
11
- control: "_control_1avu3_101",
12
- controlTooltip: "_controlTooltip_1avu3_146",
13
- codeWrapper: "_codeWrapper_1avu3_158",
14
- lineNumbers: "_lineNumbers_1avu3_165",
15
- scrollarea: "_scrollarea_1avu3_182",
16
- showCodeButton: "_showCodeButton_1avu3_207",
17
- file: "_file_1avu3_234",
18
- fileIcon: "_fileIcon_1avu3_305",
19
- filesScrollarea: "_filesScrollarea_1avu3_311",
20
- files: "_files_1avu3_311"
21
- };
22
- //#endregion
23
4
  //#region src/CodeHighlightProvider/adapters/plain-text-adapter.ts
24
5
  var plainTextAdapter = { getHighlighter: () => ({ code }) => ({
25
6
  highlightedCode: code,
26
7
  isHighlighted: false
27
8
  }) };
28
9
  //#endregion
29
- //#region src/CodeHighlightProvider/CodeHighlightProvider.ts
30
- var CodeHighlightContext = Symbol("CodeHighlightContext");
31
- function provideCodeHighlightAdapterContext(value) {
32
- provide(CodeHighlightContext, value);
33
- }
34
- function useHighlight() {
35
- return inject(CodeHighlightContext, null)?.highlight || plainTextAdapter.getHighlighter(null);
36
- }
37
- var CodeHighlightAdapterProvider = defineComponent({
10
+ //#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue?vue&type=script&setup=true&lang.ts
11
+ var _hoisted_1$1 = { style: { "display": "contents" } };
12
+ //#endregion
13
+ //#region src/CodeHighlightProvider/CodeHighlightAdapterProvider.vue
14
+ var CodeHighlightAdapterProvider_default = /* @__PURE__ */ defineComponent({
38
15
  name: "CodeHighlightAdapterProvider",
39
- props: { adapter: {
40
- type: Object,
41
- required: true
42
- } },
43
- setup(props, { slots }) {
16
+ __name: "CodeHighlightAdapterProvider",
17
+ props: { adapter: {} },
18
+ setup(__props) {
19
+ const props = __props;
44
20
  const context = ref(null);
45
21
  const highlight = computed(() => props.adapter.getHighlighter(context.value));
46
- onMounted(() => {
47
- props.adapter.loadContext?.().then((value) => {
48
- context.value = value;
49
- });
50
- });
22
+ onMounted(() => props.adapter.loadContext?.().then((value) => {
23
+ context.value = value;
24
+ }));
51
25
  provideCodeHighlightAdapterContext({
52
26
  adapter: props.adapter,
53
27
  get highlight() {
54
28
  return highlight.value;
55
29
  }
56
30
  });
57
- return () => h("div", { style: { display: "contents" } }, slots.default?.());
31
+ return (_ctx, _cache) => {
32
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [renderSlot(_ctx.$slots, "default")]);
33
+ };
58
34
  }
59
35
  });
60
36
  //#endregion
37
+ //#region src/CodeHighlightProvider/CodeHighlightProvider.ts
38
+ var CodeHighlightContext = Symbol("CodeHighlightContext");
39
+ function provideCodeHighlightAdapterContext(value) {
40
+ provide(CodeHighlightContext, value);
41
+ }
42
+ function useHighlight() {
43
+ return inject(CodeHighlightContext, null)?.highlight || plainTextAdapter.getHighlighter(null);
44
+ }
45
+ var CodeHighlightAdapterProvider = CodeHighlightAdapterProvider_default;
46
+ //#endregion
61
47
  //#region src/CodeHighlight/CodeHighlight.context.ts
62
48
  var [provideCodeHighlightContext, useCodeHighlightContext] = createSafeContext("CodeHighlightProvider was not found in the component tree");
63
49
  //#endregion
64
- //#region src/CodeHighlight/CodeHighlightControl/CodeHighlightControl.ts
65
- var CodeHighlightControl = defineComponent({
50
+ //#region src/CodeHighlight/CodeHighlightControl/CodeHighlightControl.vue
51
+ var CodeHighlightControl_default = /* @__PURE__ */ defineComponent({
66
52
  name: "CodeHighlightControl",
67
53
  inheritAttrs: false,
54
+ __name: "CodeHighlightControl",
68
55
  props: {
69
- tooltipLabel: {
70
- type: String,
71
- default: void 0
72
- },
73
- classNames: {
74
- type: [Object, Function],
75
- default: void 0
76
- },
77
- styles: {
78
- type: [Object, Function],
79
- default: void 0
80
- },
81
- vars: {
82
- type: [Object, Function],
83
- default: void 0
84
- },
85
- component: {
86
- type: String,
87
- default: "button"
88
- },
89
- onClick: {
90
- type: Function,
91
- default: void 0
92
- }
56
+ tooltipLabel: {},
57
+ component: { default: "button" },
58
+ classNames: {},
59
+ styles: {},
60
+ vars: {}
93
61
  },
94
- setup(rawProps, { attrs, slots }) {
62
+ emits: ["click"],
63
+ setup(__props, { emit: __emit }) {
64
+ const rawProps = __props;
65
+ const emit = __emit;
95
66
  const props = useProps("CodeHighlightControl", null, rawProps);
67
+ const attrs = useAttrs();
96
68
  const ctx = useCodeHighlightContext();
97
- return () => {
98
- const tooltipStyles = ctx.getStyles("controlTooltip");
99
- const control = h(ActionIcon, {
100
- ...ctx.getStyles("control"),
101
- ...attrs,
102
- component: props.component,
103
- variant: "none",
104
- "data-code-color-scheme": ctx.codeColorScheme,
105
- onClick: props.onClick
106
- }, slots);
107
- return props.tooltipLabel ? h(Tooltip, {
108
- label: props.tooltipLabel,
69
+ const tooltipStyles = computed(() => ctx.getStyles("controlTooltip"));
70
+ return (_ctx, _cache) => {
71
+ return unref(props).tooltipLabel ? (openBlock(), createBlock(unref(Tooltip), {
72
+ key: 0,
73
+ label: unref(props).tooltipLabel,
109
74
  fz: "sm",
110
75
  position: "bottom",
111
- classNames: { tooltip: tooltipStyles.class },
112
- styles: { tooltip: tooltipStyles.style },
113
- "data-code-color-scheme": ctx.codeColorScheme,
114
- transitionProps: { duration: 0 }
115
- }, () => control) : control;
76
+ "class-names": { tooltip: tooltipStyles.value.class },
77
+ styles: { tooltip: tooltipStyles.value.style },
78
+ "data-code-color-scheme": unref(ctx).codeColorScheme,
79
+ "transition-props": { duration: 0 }
80
+ }, {
81
+ default: withCtx(() => [createVNode(unref(ActionIcon), mergeProps({
82
+ ...unref(ctx).getStyles("control"),
83
+ ...unref(attrs)
84
+ }, {
85
+ component: unref(props).component,
86
+ variant: "none",
87
+ "data-code-color-scheme": unref(ctx).codeColorScheme,
88
+ onClick: _cache[0] || (_cache[0] = (event) => emit("click", event))
89
+ }), {
90
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
91
+ _: 3
92
+ }, 16, ["component", "data-code-color-scheme"])]),
93
+ _: 3
94
+ }, 8, [
95
+ "label",
96
+ "class-names",
97
+ "styles",
98
+ "data-code-color-scheme"
99
+ ])) : (openBlock(), createBlock(unref(ActionIcon), mergeProps({ key: 1 }, {
100
+ ...unref(ctx).getStyles("control"),
101
+ ...unref(attrs)
102
+ }, {
103
+ component: unref(props).component,
104
+ variant: "none",
105
+ "data-code-color-scheme": unref(ctx).codeColorScheme,
106
+ onClick: _cache[1] || (_cache[1] = (event) => emit("click", event))
107
+ }), {
108
+ default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
109
+ _: 3
110
+ }, 16, ["component", "data-code-color-scheme"]));
116
111
  };
117
112
  }
118
113
  });
119
114
  //#endregion
120
- //#region src/CodeHighlight/CopyCodeButton/CopyIcon.ts
121
- var CopyIcon = defineComponent({
115
+ //#region src/CodeHighlight/CopyCodeButton/CopyIcon.vue
116
+ var CopyIcon_default = /* @__PURE__ */ defineComponent({
122
117
  name: "CopyIcon",
123
118
  inheritAttrs: false,
124
- props: { copied: {
125
- type: Boolean,
126
- required: true
127
- } },
128
- setup(props, { attrs }) {
129
- return () => h("svg", {
130
- ...attrs,
131
- xmlns: "http://www.w3.org/2000/svg",
132
- viewBox: "0 0 24 24",
133
- strokeWidth: "2",
134
- stroke: "currentColor",
135
- fill: "none",
136
- strokeLinecap: "round",
137
- strokeLinejoin: "round"
138
- }, props.copied ? [h("path", {
139
- stroke: "none",
140
- d: "M0 0h24v24H0z",
141
- fill: "none"
142
- }), h("path", { d: "M5 12l5 5l10 -10" })] : [
143
- h("path", {
119
+ __name: "CopyIcon",
120
+ props: { copied: { type: Boolean } },
121
+ setup(__props) {
122
+ return (_ctx, _cache) => {
123
+ return openBlock(), createElementBlock("svg", mergeProps(_ctx.$attrs, {
124
+ xmlns: "http://www.w3.org/2000/svg",
125
+ viewBox: "0 0 24 24",
126
+ "stroke-width": "2",
127
+ stroke: "currentColor",
128
+ fill: "none",
129
+ "stroke-linecap": "round",
130
+ "stroke-linejoin": "round"
131
+ }), [__props.copied ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[0] || (_cache[0] = createElementVNode("path", {
144
132
  stroke: "none",
145
133
  d: "M0 0h24v24H0z",
146
134
  fill: "none"
147
- }),
148
- h("path", { d: "M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z" }),
149
- h("path", { d: "M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" })
150
- ]);
135
+ }, null, -1)), _cache[1] || (_cache[1] = createElementVNode("path", { d: "M5 12l5 5l10 -10" }, null, -1))], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
136
+ _cache[2] || (_cache[2] = createElementVNode("path", {
137
+ stroke: "none",
138
+ d: "M0 0h24v24H0z",
139
+ fill: "none"
140
+ }, null, -1)),
141
+ _cache[3] || (_cache[3] = createElementVNode("path", { d: "M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z" }, null, -1)),
142
+ _cache[4] || (_cache[4] = createElementVNode("path", { d: "M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2" }, null, -1))
143
+ ], 64))], 16);
144
+ };
151
145
  }
152
146
  });
153
147
  //#endregion
154
- //#region src/CodeHighlight/CopyCodeButton/CopyCodeButton.ts
155
- var CopyCodeButton = defineComponent({
148
+ //#region src/CodeHighlight/CopyCodeButton/CopyCodeButton.vue
149
+ var CopyCodeButton_default = /* @__PURE__ */ defineComponent({
156
150
  name: "CopyCodeButton",
151
+ __name: "CopyCodeButton",
157
152
  props: {
158
- code: {
159
- type: String,
160
- required: true
161
- },
162
- copiedLabel: {
163
- type: String,
164
- default: "Copied"
165
- },
166
- copyLabel: {
167
- type: String,
168
- default: "Copy"
169
- }
153
+ code: {},
154
+ copiedLabel: { default: "Copied" },
155
+ copyLabel: { default: "Copy" }
170
156
  },
171
- setup(props) {
157
+ setup(__props) {
158
+ const props = __props;
172
159
  const clipboard = useClipboard();
173
- return () => h(CodeHighlightControl, {
174
- onClick: () => clipboard.copy(props.code.trim()),
175
- variant: "none",
176
- tooltipLabel: clipboard.copied.value ? props.copiedLabel : props.copyLabel,
177
- "aria-label": clipboard.copied.value ? props.copiedLabel : `${props.copyLabel} code`
178
- }, () => h(CopyIcon, { copied: clipboard.copied.value }));
160
+ return (_ctx, _cache) => {
161
+ return openBlock(), createBlock(CodeHighlightControl_default, {
162
+ variant: "none",
163
+ "tooltip-label": unref(clipboard).copied.value ? props.copiedLabel : props.copyLabel,
164
+ "aria-label": unref(clipboard).copied.value ? props.copiedLabel : `${props.copyLabel} code`,
165
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(clipboard).copy(props.code.trim()))
166
+ }, {
167
+ default: withCtx(() => [createVNode(CopyIcon_default, { copied: unref(clipboard).copied.value }, null, 8, ["copied"])]),
168
+ _: 1
169
+ }, 8, ["tooltip-label", "aria-label"]);
170
+ };
179
171
  }
180
172
  });
181
173
  //#endregion
182
- //#region src/CodeHighlight/ExpandCodeButton/ExpandIcon.ts
183
- var ExpandIcon = defineComponent({
174
+ //#region src/CodeHighlight/ExpandCodeButton/ExpandIcon.vue
175
+ var ExpandIcon_default = /* @__PURE__ */ defineComponent({
184
176
  name: "ExpandIcon",
185
177
  inheritAttrs: false,
186
- props: { expanded: {
187
- type: Boolean,
188
- required: true
189
- } },
190
- setup(props, { attrs }) {
191
- return () => h("svg", {
192
- ...attrs,
193
- xmlns: "http://www.w3.org/2000/svg",
194
- viewBox: "0 0 24 24",
195
- strokeWidth: "2",
196
- stroke: "currentColor",
197
- fill: "none",
198
- strokeLinecap: "round",
199
- strokeLinejoin: "round"
200
- }, props.expanded ? [
201
- h("path", {
202
- stroke: "none",
203
- d: "M0 0h24v24H0z",
204
- fill: "none"
205
- }),
206
- h("path", { d: "M12 13v-8l-3 3m6 0l-3 -3" }),
207
- h("path", { d: "M9 17l1 0" }),
208
- h("path", { d: "M14 17l1 0" }),
209
- h("path", { d: "M19 17l1 0" }),
210
- h("path", { d: "M4 17l1 0" })
211
- ] : [
212
- h("path", {
178
+ __name: "ExpandIcon",
179
+ props: { expanded: { type: Boolean } },
180
+ setup(__props) {
181
+ return (_ctx, _cache) => {
182
+ return openBlock(), createElementBlock("svg", mergeProps(_ctx.$attrs, {
183
+ xmlns: "http://www.w3.org/2000/svg",
184
+ viewBox: "0 0 24 24",
185
+ "stroke-width": "2",
186
+ stroke: "currentColor",
187
+ fill: "none",
188
+ "stroke-linecap": "round",
189
+ "stroke-linejoin": "round"
190
+ }), [_cache[2] || (_cache[2] = createElementVNode("path", {
213
191
  stroke: "none",
214
192
  d: "M0 0h24v24H0z",
215
193
  fill: "none"
216
- }),
217
- h("path", { d: "M12 11v8l3 -3m-6 0l3 3" }),
218
- h("path", { d: "M9 7l1 0" }),
219
- h("path", { d: "M14 7l1 0" }),
220
- h("path", { d: "M19 7l1 0" }),
221
- h("path", { d: "M4 7l1 0" })
222
- ]);
194
+ }, null, -1)), __props.expanded ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [_cache[0] || (_cache[0] = createStaticVNode("<path d=\"M12 13v-8l-3 3m6 0l-3 -3\"></path><path d=\"M9 17l1 0\"></path><path d=\"M14 17l1 0\"></path><path d=\"M19 17l1 0\"></path><path d=\"M4 17l1 0\"></path>", 5))], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [_cache[1] || (_cache[1] = createStaticVNode("<path d=\"M12 11v8l3 -3m-6 0l3 3\"></path><path d=\"M9 7l1 0\"></path><path d=\"M14 7l1 0\"></path><path d=\"M19 7l1 0\"></path><path d=\"M4 7l1 0\"></path>", 5))], 64))], 16);
195
+ };
223
196
  }
224
197
  });
225
198
  //#endregion
226
- //#region src/CodeHighlight/ExpandCodeButton/ExpandCodeButton.ts
227
- var ExpandCodeButton = defineComponent({
199
+ //#region src/CodeHighlight/ExpandCodeButton/ExpandCodeButton.vue
200
+ var ExpandCodeButton_default = /* @__PURE__ */ defineComponent({
228
201
  name: "ExpandCodeButton",
202
+ __name: "ExpandCodeButton",
229
203
  props: {
230
- expanded: {
231
- type: Boolean,
232
- required: true
233
- },
234
- onExpand: {
235
- type: Function,
236
- required: true
237
- },
238
- collapseCodeLabel: {
239
- type: String,
240
- default: "Collapse code"
241
- },
242
- expandCodeLabel: {
243
- type: String,
244
- default: "Expand code"
245
- }
204
+ expanded: { type: Boolean },
205
+ collapseCodeLabel: { default: "Collapse code" },
206
+ expandCodeLabel: { default: "Expand code" }
246
207
  },
247
- setup(props) {
248
- return () => h(CodeHighlightControl, {
249
- onClick: () => props.onExpand(!props.expanded),
250
- tooltipLabel: props.expanded ? props.collapseCodeLabel : props.expandCodeLabel,
251
- "aria-label": props.expanded ? props.collapseCodeLabel : props.expandCodeLabel
252
- }, () => h(ExpandIcon, { expanded: props.expanded }));
208
+ emits: ["expand"],
209
+ setup(__props, { emit: __emit }) {
210
+ const props = __props;
211
+ const emit = __emit;
212
+ return (_ctx, _cache) => {
213
+ return openBlock(), createBlock(CodeHighlightControl_default, {
214
+ "tooltip-label": props.expanded ? props.collapseCodeLabel : props.expandCodeLabel,
215
+ "aria-label": props.expanded ? props.collapseCodeLabel : props.expandCodeLabel,
216
+ onClick: _cache[0] || (_cache[0] = ($event) => emit("expand", !props.expanded))
217
+ }, {
218
+ default: withCtx(() => [createVNode(ExpandIcon_default, { expanded: props.expanded }, null, 8, ["expanded"])]),
219
+ _: 1
220
+ }, 8, ["tooltip-label", "aria-label"]);
221
+ };
253
222
  }
254
223
  });
255
- //#endregion
256
- //#region src/CodeHighlight/CodeHighlight.ts
257
- var defaultProps = {
258
- withCopyButton: true,
259
- expandCodeLabel: "Expand code",
260
- collapseCodeLabel: "Collapse code"
224
+ var CodeHighlight_module_default = {
225
+ root: "_root_1avu3_1",
226
+ codeHighlight: "_codeHighlight_1avu3_5",
227
+ inlineCodeHighlight: "_inlineCodeHighlight_1avu3_37",
228
+ pre: "_pre_1avu3_71",
229
+ code: "_code_1avu3_5",
230
+ controls: "_controls_1avu3_101",
231
+ control: "_control_1avu3_101",
232
+ controlTooltip: "_controlTooltip_1avu3_146",
233
+ codeWrapper: "_codeWrapper_1avu3_158",
234
+ lineNumbers: "_lineNumbers_1avu3_165",
235
+ scrollarea: "_scrollarea_1avu3_182",
236
+ showCodeButton: "_showCodeButton_1avu3_207",
237
+ file: "_file_1avu3_234",
238
+ fileIcon: "_fileIcon_1avu3_305",
239
+ filesScrollarea: "_filesScrollarea_1avu3_311",
240
+ files: "_files_1avu3_311"
261
241
  };
242
+ //#endregion
243
+ //#region src/CodeHighlight/CodeHighlight.vue?vue&type=script&setup=true&lang.ts
244
+ var _hoisted_1 = ["data-with-border", "innerHTML"];
245
+ var _hoisted_2 = ["data-with-border"];
246
+ var _hoisted_3 = ["data-with-offset"];
247
+ var _hoisted_4 = ["data-with-offset"];
248
+ var _hoisted_5 = ["data-with-offset"];
249
+ var _hoisted_6 = ["innerHTML"];
262
250
  var varsResolver$1 = createVarsResolver((theme, { maxCollapsedHeight, background, radius }) => ({ codeHighlight: {
263
251
  "--ch-max-height": rem(maxCollapsedHeight),
264
252
  "--ch-background": background ? getThemeColor(background, theme) : void 0,
265
253
  "--ch-radius": typeof radius !== "undefined" ? getRadius(radius) : void 0
266
254
  } }));
267
- function renderHtmlOrText(isHighlighted, highlightedCode, code) {
268
- return isHighlighted ? { innerHTML: highlightedCode } : { textContent: code.trim() };
269
- }
270
- function cx(...values) {
271
- return values.filter(Boolean);
272
- }
273
- function resolveColorScheme(value) {
274
- if (value !== "auto") return value;
275
- return typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
276
- }
277
- var CodeHighlightBase = defineComponent({
255
+ //#endregion
256
+ //#region src/CodeHighlight/CodeHighlight.vue
257
+ var CodeHighlight_default = /* @__PURE__ */ defineComponent({
278
258
  name: "CodeHighlight",
279
259
  inheritAttrs: false,
280
- slots: Object,
260
+ __name: "CodeHighlight",
281
261
  props: {
282
- code: {
283
- type: String,
284
- required: true
285
- },
286
- language: {
287
- type: String,
288
- default: void 0
289
- },
290
- copyLabel: {
291
- type: String,
292
- default: void 0
262
+ __withOffset: {
263
+ type: Boolean,
264
+ default: false
293
265
  },
294
- copiedLabel: {
295
- type: String,
296
- default: void 0
266
+ __staticSelector: {},
267
+ __inline: {
268
+ type: Boolean,
269
+ default: false
297
270
  },
271
+ code: {},
272
+ language: {},
273
+ classNames: {},
274
+ styles: {},
275
+ vars: {},
276
+ unstyled: { type: Boolean },
277
+ class: {},
278
+ style: {},
279
+ copyLabel: {},
280
+ copiedLabel: {},
298
281
  defaultExpanded: {
299
282
  type: Boolean,
300
283
  default: void 0
@@ -303,38 +286,19 @@ var CodeHighlightBase = defineComponent({
303
286
  type: Boolean,
304
287
  default: void 0
305
288
  },
306
- onExpandedChange: {
307
- type: Function,
308
- default: void 0
309
- },
310
- maxCollapsedHeight: {
311
- type: [String, Number],
312
- default: void 0
313
- },
289
+ maxCollapsedHeight: {},
314
290
  withCopyButton: {
315
291
  type: Boolean,
316
- default: void 0
292
+ default: true
317
293
  },
318
294
  withExpandButton: {
319
295
  type: Boolean,
320
296
  default: false
321
297
  },
322
- expandCodeLabel: {
323
- type: String,
324
- default: void 0
325
- },
326
- collapseCodeLabel: {
327
- type: String,
328
- default: void 0
329
- },
330
- background: {
331
- type: String,
332
- default: void 0
333
- },
334
- radius: {
335
- type: [String, Number],
336
- default: void 0
337
- },
298
+ expandCodeLabel: { default: "Expand code" },
299
+ collapseCodeLabel: { default: "Collapse code" },
300
+ background: {},
301
+ radius: {},
338
302
  withBorder: {
339
303
  type: Boolean,
340
304
  default: false
@@ -343,45 +307,16 @@ var CodeHighlightBase = defineComponent({
343
307
  type: Boolean,
344
308
  default: false
345
309
  },
346
- controls: {
347
- type: [Array, Function],
348
- default: void 0
349
- },
350
- codeColorScheme: {
351
- type: String,
352
- default: void 0
353
- },
354
- __withOffset: {
355
- type: Boolean,
356
- default: false
357
- },
358
- __staticSelector: {
359
- type: String,
360
- default: void 0
361
- },
362
- __inline: {
363
- type: Boolean,
364
- default: false
365
- },
366
- classNames: {
367
- type: [Object, Function],
368
- default: void 0
369
- },
370
- styles: {
371
- type: [Object, Function],
372
- default: void 0
373
- },
374
- vars: {
375
- type: [Object, Function],
376
- default: void 0
377
- },
378
- unstyled: {
379
- type: Boolean,
380
- default: false
381
- }
310
+ controls: {},
311
+ codeColorScheme: {}
382
312
  },
383
- setup(rawProps, { attrs, slots }) {
384
- const props = useProps("CodeHighlight", defaultProps, rawProps);
313
+ emits: ["update:expanded", "expanded-change"],
314
+ setup(__props, { emit: __emit }) {
315
+ const rawProps = __props;
316
+ const emit = __emit;
317
+ const props = useProps("CodeHighlight", null, rawProps);
318
+ const attrs = useAttrs();
319
+ const slots = useSlots();
385
320
  const mantine = useMantineContext();
386
321
  const getStyles = useStyles({
387
322
  name: props.__staticSelector || "CodeHighlight",
@@ -400,147 +335,161 @@ var CodeHighlightBase = defineComponent({
400
335
  value: () => props.expanded,
401
336
  defaultValue: props.defaultExpanded,
402
337
  finalValue: true,
403
- onChange: (value) => props.onExpandedChange?.(value)
338
+ onChange: (value) => {
339
+ emit("update:expanded", value);
340
+ emit("expanded-change", value);
341
+ }
404
342
  });
405
343
  const highlight = useHighlight();
344
+ function resolveColorScheme(value) {
345
+ if (value !== "auto") return value;
346
+ return typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
347
+ }
348
+ const highlighted = computed(() => highlight({
349
+ code: props.code.trim(),
350
+ language: props.language,
351
+ colorScheme: props.codeColorScheme ?? resolveColorScheme(mantine.colorScheme.value)
352
+ }));
353
+ const renderedControls = computed(() => {
354
+ const value = props.controls !== void 0 ? typeof props.controls === "function" ? props.controls() : props.controls : slots.controls?.();
355
+ return Array.isArray(value) ? value : value ? [value] : [];
356
+ });
357
+ const shouldDisplayControls = computed(() => renderedControls.value.length > 0 || props.withExpandButton || props.withCopyButton);
358
+ const lineNumbers = computed(() => props.code.trim().split("\n").map((_, index) => index + 1));
359
+ const renderControls = () => renderedControls.value;
406
360
  provideCodeHighlightContext({
407
361
  getStyles,
408
362
  get codeColorScheme() {
409
363
  return props.codeColorScheme;
410
364
  }
411
365
  });
412
- return () => {
413
- const colorScheme = resolveColorScheme(mantine.colorScheme.value);
414
- const highlightedCode = highlight({
415
- code: props.code.trim(),
416
- language: props.language,
417
- colorScheme: props.codeColorScheme ?? colorScheme
418
- });
419
- const codeContent = renderHtmlOrText(highlightedCode.isHighlighted, highlightedCode.highlightedCode, props.code);
420
- if (props.__inline) return h(Box, {
421
- component: "code",
422
- ...attrs,
423
- ...highlightedCode.codeElementProps,
424
- ...getStyles("codeHighlight", {
425
- className: cx(highlightedCode.codeElementProps?.class, attrs.class),
426
- style: [highlightedCode.codeElementProps?.style, attrs.style]
427
- }),
428
- "data-with-border": props.withBorder || void 0,
429
- ...codeContent
430
- });
431
- const renderedControls = props.controls !== void 0 ? typeof props.controls === "function" ? props.controls() : props.controls : slots.controls?.();
432
- const controlsArray = Array.isArray(renderedControls) ? renderedControls : renderedControls ? [renderedControls] : [];
433
- const shouldDisplayControls = controlsArray.length > 0 || props.withExpandButton || props.withCopyButton;
434
- return h(Box, {
435
- ...attrs,
436
- ...getStyles("codeHighlight"),
366
+ return (_ctx, _cache) => {
367
+ return unref(props).__inline && highlighted.value.isHighlighted ? (openBlock(), createElementBlock("code", mergeProps({ key: 0 }, {
368
+ ...unref(attrs),
369
+ ...highlighted.value.codeElementProps,
370
+ ...unref(getStyles)("codeHighlight", {
371
+ className: [highlighted.value.codeElementProps?.class, unref(attrs).class],
372
+ style: [highlighted.value.codeElementProps?.style, unref(attrs).style]
373
+ })
374
+ }, {
375
+ "data-with-border": unref(props).withBorder || void 0,
376
+ innerHTML: highlighted.value.highlightedCode
377
+ }), null, 16, _hoisted_1)) : unref(props).__inline ? (openBlock(), createElementBlock("code", mergeProps({ key: 1 }, {
378
+ ...unref(attrs),
379
+ ...highlighted.value.codeElementProps,
380
+ ...unref(getStyles)("codeHighlight", {
381
+ className: [highlighted.value.codeElementProps?.class, unref(attrs).class],
382
+ style: [highlighted.value.codeElementProps?.style, unref(attrs).style]
383
+ })
384
+ }, { "data-with-border": unref(props).withBorder || void 0 }), toDisplayString(unref(props).code.trim()), 17, _hoisted_2)) : (openBlock(), createBlock(unref(Box), mergeProps({ key: 2 }, {
385
+ ...unref(attrs),
386
+ ...unref(getStyles)("codeHighlight")
387
+ }, {
437
388
  dir: "ltr",
438
- "data-code-color-scheme": props.codeColorScheme,
439
- "data-with-border": props.withBorder || void 0
440
- }, () => [
441
- shouldDisplayControls ? h("div", {
442
- ...getStyles("controls"),
443
- "data-with-offset": props.__withOffset || void 0
444
- }, [
445
- ...controlsArray,
446
- props.withExpandButton ? h(ExpandCodeButton, {
447
- expanded: expanded.value,
448
- onExpand: setExpanded,
449
- expandCodeLabel: props.expandCodeLabel,
450
- collapseCodeLabel: props.collapseCodeLabel
451
- }) : null,
452
- props.withCopyButton ? h(CopyCodeButton, {
453
- code: props.code,
454
- copiedLabel: props.copiedLabel,
455
- copyLabel: props.copyLabel
456
- }) : null
457
- ]) : null,
458
- h(ScrollArea, {
459
- type: "hover",
460
- scrollbarSize: 4,
461
- dir: "ltr",
462
- offsetScrollbars: false,
463
- "data-collapsed": !expanded.value || void 0,
464
- styles: { viewport: { overscrollBehaviorInline: "none" } },
465
- ...getStyles("scrollarea")
466
- }, () => h("div", getStyles("codeWrapper"), [props.withLineNumbers ? h("div", {
467
- ...getStyles("lineNumbers"),
468
- "data-with-offset": props.__withOffset || void 0
469
- }, props.code.trim().split("\n").map((_, index) => h("div", { key: index }, index + 1))) : null, h("pre", {
470
- ...getStyles("pre"),
471
- "data-with-offset": props.__withOffset || void 0
472
- }, h("code", {
473
- ...highlightedCode.codeElementProps,
474
- ...getStyles("code", {
475
- className: highlightedCode.codeElementProps?.class,
476
- style: highlightedCode.codeElementProps?.style
477
- }),
478
- ...codeContent
479
- }))])),
480
- h(UnstyledButton, {
481
- ...getStyles("showCodeButton"),
482
- mod: { hidden: expanded.value },
483
- onClick: () => setExpanded(true),
484
- "data-code-color-scheme": props.codeColorScheme
485
- }, () => props.expandCodeLabel)
486
- ]);
389
+ "data-code-color-scheme": unref(props).codeColorScheme,
390
+ "data-with-border": unref(props).withBorder || void 0
391
+ }), {
392
+ default: withCtx(() => [
393
+ shouldDisplayControls.value ? (openBlock(), createElementBlock("div", mergeProps({ key: 0 }, unref(getStyles)("controls"), { "data-with-offset": unref(props).__withOffset || void 0 }), [
394
+ (openBlock(), createBlock(resolveDynamicComponent(renderControls))),
395
+ unref(props).withExpandButton ? (openBlock(), createBlock(ExpandCodeButton_default, {
396
+ key: 0,
397
+ expanded: unref(expanded),
398
+ "expand-code-label": unref(props).expandCodeLabel,
399
+ "collapse-code-label": unref(props).collapseCodeLabel,
400
+ onExpand: unref(setExpanded)
401
+ }, null, 8, [
402
+ "expanded",
403
+ "expand-code-label",
404
+ "collapse-code-label",
405
+ "onExpand"
406
+ ])) : createCommentVNode("", true),
407
+ unref(props).withCopyButton ? (openBlock(), createBlock(CopyCodeButton_default, {
408
+ key: 1,
409
+ code: unref(props).code,
410
+ "copied-label": unref(props).copiedLabel,
411
+ "copy-label": unref(props).copyLabel
412
+ }, null, 8, [
413
+ "code",
414
+ "copied-label",
415
+ "copy-label"
416
+ ])) : createCommentVNode("", true)
417
+ ], 16, _hoisted_3)) : createCommentVNode("", true),
418
+ createVNode(unref(ScrollArea), mergeProps({
419
+ type: "hover",
420
+ "scrollbar-size": 4,
421
+ dir: "ltr",
422
+ "offset-scrollbars": false,
423
+ "data-collapsed": !unref(expanded) || void 0,
424
+ styles: { viewport: { overscrollBehaviorInline: "none" } }
425
+ }, unref(getStyles)("scrollarea")), {
426
+ default: withCtx(() => [createElementVNode("div", normalizeProps(guardReactiveProps(unref(getStyles)("codeWrapper"))), [unref(props).withLineNumbers ? (openBlock(), createElementBlock("div", mergeProps({ key: 0 }, unref(getStyles)("lineNumbers"), { "data-with-offset": unref(props).__withOffset || void 0 }), [(openBlock(true), createElementBlock(Fragment, null, renderList(lineNumbers.value, (line) => {
427
+ return openBlock(), createElementBlock("div", { key: line }, toDisplayString(line), 1);
428
+ }), 128))], 16, _hoisted_4)) : createCommentVNode("", true), createElementVNode("pre", mergeProps(unref(getStyles)("pre"), { "data-with-offset": unref(props).__withOffset || void 0 }), [highlighted.value.isHighlighted ? (openBlock(), createElementBlock("code", mergeProps({ key: 0 }, {
429
+ ...highlighted.value.codeElementProps,
430
+ ...unref(getStyles)("code", {
431
+ className: highlighted.value.codeElementProps?.class,
432
+ style: highlighted.value.codeElementProps?.style
433
+ })
434
+ }, { innerHTML: highlighted.value.highlightedCode }), null, 16, _hoisted_6)) : (openBlock(), createElementBlock("code", normalizeProps(mergeProps({ key: 1 }, {
435
+ ...highlighted.value.codeElementProps,
436
+ ...unref(getStyles)("code", {
437
+ className: highlighted.value.codeElementProps?.class,
438
+ style: highlighted.value.codeElementProps?.style
439
+ })
440
+ })), toDisplayString(unref(props).code.trim()), 17))], 16, _hoisted_5)], 16)]),
441
+ _: 1
442
+ }, 16, ["data-collapsed"]),
443
+ createVNode(unref(UnstyledButton), mergeProps(unref(getStyles)("showCodeButton"), {
444
+ mod: { hidden: unref(expanded) },
445
+ "data-code-color-scheme": unref(props).codeColorScheme,
446
+ onClick: _cache[0] || (_cache[0] = ($event) => unref(setExpanded)(true))
447
+ }), {
448
+ default: withCtx(() => [createTextVNode(toDisplayString(unref(props).expandCodeLabel), 1)]),
449
+ _: 1
450
+ }, 16, ["mod", "data-code-color-scheme"])
451
+ ]),
452
+ _: 1
453
+ }, 16, ["data-code-color-scheme", "data-with-border"]));
487
454
  };
488
455
  }
489
456
  });
490
- var CodeHighlight = Object.assign(CodeHighlightBase, {
457
+ //#endregion
458
+ //#region src/CodeHighlight/CodeHighlight.ts
459
+ var CodeHighlight = Object.assign(CodeHighlight_default, {
491
460
  classes: CodeHighlight_module_default,
492
461
  varsResolver: varsResolver$1,
493
- Control: CodeHighlightControl
462
+ Control: CodeHighlightControl_default
494
463
  });
495
464
  //#endregion
496
- //#region src/CodeHighlight/InlineCodeHighlight.ts
465
+ //#region src/CodeHighlight/InlineCodeHighlight.vue?vue&type=script&setup=true&lang.ts
497
466
  var varsResolver = createVarsResolver((theme, { background, radius }) => ({ inlineCodeHighlight: {
498
467
  "--ch-background": background ? getThemeColor(background, theme) : void 0,
499
468
  "--ch-radius": typeof radius !== "undefined" ? getRadius(radius) : void 0
500
469
  } }));
501
- var InlineCodeHighlight = defineComponent({
470
+ //#endregion
471
+ //#region src/CodeHighlight/InlineCodeHighlight.ts
472
+ var InlineCodeHighlight = Object.assign(/* @__PURE__ */ defineComponent({
502
473
  name: "InlineCodeHighlight",
503
474
  inheritAttrs: false,
475
+ __name: "InlineCodeHighlight",
504
476
  props: {
505
- code: {
506
- type: String,
507
- required: true
508
- },
509
- language: {
510
- type: String,
511
- default: void 0
512
- },
513
- background: {
514
- type: String,
515
- default: void 0
516
- },
517
- radius: {
518
- type: [String, Number],
519
- default: void 0
520
- },
477
+ code: {},
478
+ language: {},
479
+ background: {},
480
+ radius: {},
521
481
  withBorder: {
522
482
  type: Boolean,
523
483
  default: false
524
484
  },
525
- classNames: {
526
- type: [Object, Function],
527
- default: void 0
528
- },
529
- styles: {
530
- type: [Object, Function],
531
- default: void 0
532
- },
533
- vars: {
534
- type: [Object, Function],
535
- default: void 0
536
- },
537
- unstyled: {
538
- type: Boolean,
539
- default: false
540
- }
485
+ classNames: {},
486
+ styles: {},
487
+ vars: {},
488
+ unstyled: { type: Boolean }
541
489
  },
542
- setup(rawProps, { attrs }) {
543
- const props = useProps("InlineCodeHighlight", null, rawProps);
490
+ setup(__props) {
491
+ const props = useProps("InlineCodeHighlight", null, __props);
492
+ const attrs = useAttrs();
544
493
  const getStyles = useStyles({
545
494
  name: "InlineCodeHighlight",
546
495
  classes: CodeHighlight_module_default,
@@ -554,81 +503,68 @@ var InlineCodeHighlight = defineComponent({
554
503
  varsResolver,
555
504
  rootSelector: "inlineCodeHighlight"
556
505
  });
557
- return () => h(CodeHighlight, {
558
- ...attrs,
559
- ...props,
560
- ...getStyles("inlineCodeHighlight"),
561
- __inline: true
562
- });
506
+ return (_ctx, _cache) => {
507
+ return openBlock(), createBlock(CodeHighlight_default, mergeProps({
508
+ ...unref(attrs),
509
+ ...unref(props),
510
+ ...unref(getStyles)("inlineCodeHighlight")
511
+ }, { __inline: "" }), null, 16);
512
+ };
563
513
  }
564
- });
565
- Object.assign(InlineCodeHighlight, {
514
+ }), {
566
515
  classes: CodeHighlight_module_default,
567
516
  varsResolver
568
517
  });
569
518
  //#endregion
570
- //#region src/CodeHighlightTabs/FileIcon.ts
571
- var FileIcon = defineComponent({
519
+ //#region src/CodeHighlightTabs/FileIcon.vue
520
+ var FileIcon_default = /* @__PURE__ */ defineComponent({
572
521
  name: "FileIcon",
573
522
  inheritAttrs: false,
574
- slots: Object,
523
+ __name: "FileIcon",
575
524
  props: {
576
- fileName: {
577
- type: String,
578
- default: void 0
579
- },
580
- getFileIcon: {
581
- type: Function,
582
- default: void 0
583
- },
584
- fileIcon: {
585
- type: [
586
- String,
587
- Number,
588
- Object,
589
- Function,
590
- Array
591
- ],
592
- default: void 0
593
- }
525
+ fileName: {},
526
+ getFileIcon: { type: Function },
527
+ fileIcon: { type: [
528
+ Object,
529
+ String,
530
+ Number,
531
+ Boolean,
532
+ null,
533
+ Array
534
+ ] }
594
535
  },
595
- setup(props, { attrs, slots }) {
596
- return () => {
597
- if (props.fileIcon) return h("span", attrs, props.fileIcon);
598
- if (props.getFileIcon && props.fileName) return h("span", attrs, props.getFileIcon(props.fileName));
599
- if (slots.fileIcon) return h("span", attrs, slots.fileIcon());
600
- if (slots.getFileIcon && props.fileName) return h("span", attrs, slots.getFileIcon({ fileName: props.fileName }));
536
+ setup(__props) {
537
+ const props = __props;
538
+ const slots = useSlots();
539
+ const renderIcon = () => {
540
+ if (props.fileIcon) return props.fileIcon;
541
+ if (props.getFileIcon && props.fileName) return props.getFileIcon(props.fileName);
542
+ if (slots.fileIcon) return slots.fileIcon();
543
+ if (slots.getFileIcon && props.fileName) return slots.getFileIcon({ fileName: props.fileName });
601
544
  return null;
602
545
  };
546
+ return (_ctx, _cache) => {
547
+ return renderIcon() ? (openBlock(), createElementBlock("span", normalizeProps(mergeProps({ key: 0 }, _ctx.$attrs)), [(openBlock(), createBlock(resolveDynamicComponent(renderIcon)))], 16)) : createCommentVNode("", true);
548
+ };
603
549
  }
604
550
  });
605
551
  //#endregion
606
552
  //#region src/CodeHighlightTabs/CodeHighlightTabs.ts
607
- var CodeHighlightTabs = defineComponent({
553
+ var CodeHighlightTabs = Object.assign(/* @__PURE__ */ defineComponent({
608
554
  name: "CodeHighlightTabs",
609
555
  inheritAttrs: false,
610
- slots: Object,
556
+ __name: "CodeHighlightTabs",
611
557
  props: {
612
- code: {
613
- type: Array,
614
- required: true
615
- },
616
- getFileIcon: {
617
- type: Function,
618
- default: void 0
619
- },
620
- defaultActiveTab: {
621
- type: Number,
622
- default: void 0
623
- },
624
- activeTab: {
625
- type: Number,
626
- default: void 0
627
- },
628
- onTabChange: {
629
- type: Function,
630
- default: void 0
631
- },
558
+ code: {},
559
+ getFileIcon: {},
560
+ defaultActiveTab: {},
561
+ activeTab: {},
562
+ classNames: {},
563
+ styles: {},
564
+ vars: {},
565
+ unstyled: { type: Boolean },
566
+ copyLabel: {},
567
+ copiedLabel: {},
632
568
  defaultExpanded: {
633
569
  type: Boolean,
634
570
  default: void 0
@@ -637,81 +573,39 @@ var CodeHighlightTabs = defineComponent({
637
573
  type: Boolean,
638
574
  default: void 0
639
575
  },
640
- onExpandedChange: {
641
- type: Function,
642
- default: void 0
643
- },
644
- withCopyButton: {
645
- type: Boolean,
646
- default: void 0
647
- },
576
+ maxCollapsedHeight: {},
577
+ withCopyButton: { type: Boolean },
648
578
  withExpandButton: {
649
579
  type: Boolean,
650
580
  default: false
651
581
  },
582
+ expandCodeLabel: {},
583
+ collapseCodeLabel: {},
584
+ background: {},
585
+ radius: {},
652
586
  withBorder: {
653
587
  type: Boolean,
654
588
  default: false
655
589
  },
656
- radius: {
657
- type: [String, Number],
658
- default: void 0
659
- },
660
- maxCollapsedHeight: {
661
- type: [String, Number],
662
- default: void 0
663
- },
664
- copyLabel: {
665
- type: String,
666
- default: void 0
667
- },
668
- copiedLabel: {
669
- type: String,
670
- default: void 0
671
- },
672
- expandCodeLabel: {
673
- type: String,
674
- default: void 0
675
- },
676
- collapseCodeLabel: {
677
- type: String,
678
- default: void 0
679
- },
680
- background: {
681
- type: String,
682
- default: void 0
683
- },
684
- controls: {
685
- type: [Array, Function],
686
- default: void 0
687
- },
688
- codeColorScheme: {
689
- type: String,
690
- default: void 0
691
- },
692
590
  withLineNumbers: {
693
591
  type: Boolean,
694
592
  default: false
695
593
  },
696
- classNames: {
697
- type: [Object, Function],
698
- default: void 0
699
- },
700
- styles: {
701
- type: [Object, Function],
702
- default: void 0
703
- },
704
- vars: {
705
- type: [Object, Function],
706
- default: void 0
707
- },
708
- unstyled: {
709
- type: Boolean,
710
- default: false
711
- }
594
+ controls: {},
595
+ codeColorScheme: {}
712
596
  },
713
- setup(rawProps, { attrs, slots }) {
597
+ emits: [
598
+ "update:activeTab",
599
+ "tab-change",
600
+ "update:expanded",
601
+ "expanded-change"
602
+ ],
603
+ setup(__props, { emit: __emit }) {
604
+ const rawProps = __props;
605
+ const emit = __emit;
714
606
  const props = useProps("CodeHighlightTabs", null, rawProps);
607
+ const attrs = useAttrs();
608
+ const slots = useSlots();
715
609
  const getStyles = useStyles({
716
610
  name: "CodeHighlightTabs",
717
611
  classes: CodeHighlight_module_default,
@@ -727,73 +621,114 @@ var CodeHighlightTabs = defineComponent({
727
621
  defaultValue: props.defaultActiveTab,
728
622
  value: () => props.activeTab,
729
623
  finalValue: 0,
730
- onChange: (tab) => props.onTabChange?.(tab)
624
+ onChange: (tab) => {
625
+ emit("update:activeTab", tab);
626
+ emit("tab-change", tab);
627
+ }
731
628
  });
732
629
  const [expanded, setExpanded] = useUncontrolled({
733
630
  defaultValue: props.defaultExpanded,
734
631
  value: () => props.expanded,
735
632
  finalValue: true,
736
- onChange: (next) => props.onExpandedChange?.(next)
633
+ onChange: (next) => {
634
+ emit("update:expanded", next);
635
+ emit("expanded-change", next);
636
+ }
737
637
  });
738
- watch(() => [value.value, props.code.length], ([currentValue, length]) => {
739
- if (currentValue >= length) setValue(length - 1);
638
+ watch(() => [value.value, props.code.length], ([current, length]) => {
639
+ if (current >= length) setValue(length - 1);
740
640
  }, { immediate: true });
741
- return () => {
742
- if (props.code.length <= 0) return null;
743
- const currentCode = props.code[value.value] || {
744
- code: "",
745
- language: "tsx",
746
- fileName: ""
747
- };
748
- const getFileIcon = props.getFileIcon ?? (slots.getFileIcon ? (fileName) => slots.getFileIcon?.({ fileName }) : void 0);
749
- const files = props.code.map((node, index) => h(UnstyledButton, {
750
- ...getStyles("file"),
751
- key: node.fileName ?? index,
752
- mod: { active: index === value.value },
753
- onClick: () => setValue(index),
754
- "data-color-scheme": props.codeColorScheme
755
- }, () => [h(FileIcon, {
756
- fileIcon: node.icon,
757
- getFileIcon,
758
- fileName: node.fileName,
759
- key: "file-icon",
760
- ...getStyles("fileIcon")
761
- }), h("span", { key: "file-name" }, node.fileName)]));
762
- return h(Box, {
763
- ...attrs,
764
- ...getStyles("root")
765
- }, () => [h(ScrollArea, {
766
- type: "never",
767
- dir: "ltr",
768
- offsetScrollbars: false,
769
- ...getStyles("filesScrollarea")
770
- }, () => h("div", getStyles("files"), files)), h(CodeHighlight, {
771
- code: currentCode.code,
772
- language: currentCode.language,
773
- expanded: expanded.value,
774
- onExpandedChange: setExpanded,
775
- withCopyButton: props.withCopyButton,
776
- withExpandButton: props.withExpandButton,
777
- withBorder: props.withBorder,
778
- radius: props.radius,
779
- maxCollapsedHeight: props.maxCollapsedHeight,
780
- copiedLabel: props.copiedLabel,
781
- copyLabel: props.copyLabel,
782
- expandCodeLabel: props.expandCodeLabel,
783
- collapseCodeLabel: props.collapseCodeLabel,
784
- background: props.background,
785
- controls: props.controls,
786
- codeColorScheme: props.codeColorScheme,
787
- withLineNumbers: props.withLineNumbers,
788
- __withOffset: true,
789
- __staticSelector: "CodeHighlightTabs",
790
- classNames: props.classNames,
791
- styles: props.styles
792
- }, { controls: slots.controls })]);
641
+ const currentCode = computed(() => props.code[value.value] || {
642
+ code: "",
643
+ language: "tsx",
644
+ fileName: ""
645
+ });
646
+ const fileIconResolver = computed(() => props.getFileIcon ?? (slots.getFileIcon ? (fileName) => slots.getFileIcon?.({ fileName }) : void 0));
647
+ return (_ctx, _cache) => {
648
+ return unref(props).code.length ? (openBlock(), createBlock(unref(Box), normalizeProps(mergeProps({ key: 0 }, {
649
+ ...unref(attrs),
650
+ ...unref(getStyles)("root")
651
+ })), {
652
+ default: withCtx(() => [createVNode(unref(ScrollArea), mergeProps({
653
+ type: "never",
654
+ dir: "ltr",
655
+ "offset-scrollbars": false
656
+ }, unref(getStyles)("filesScrollarea")), {
657
+ default: withCtx(() => [createElementVNode("div", normalizeProps(guardReactiveProps(unref(getStyles)("files"))), [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(props).code, (node, index) => {
658
+ return openBlock(), createBlock(unref(UnstyledButton), mergeProps({ key: node.fileName ?? index }, { ref_for: true }, unref(getStyles)("file"), {
659
+ mod: { active: index === unref(value) },
660
+ "data-color-scheme": unref(props).codeColorScheme,
661
+ onClick: ($event) => unref(setValue)(index)
662
+ }), {
663
+ default: withCtx(() => [createVNode(FileIcon_default, mergeProps({
664
+ "file-icon": node.icon,
665
+ "get-file-icon": fileIconResolver.value,
666
+ "file-name": node.fileName
667
+ }, { ref_for: true }, unref(getStyles)("fileIcon")), null, 16, [
668
+ "file-icon",
669
+ "get-file-icon",
670
+ "file-name"
671
+ ]), createElementVNode("span", null, toDisplayString(node.fileName), 1)]),
672
+ _: 2
673
+ }, 1040, [
674
+ "mod",
675
+ "data-color-scheme",
676
+ "onClick"
677
+ ]);
678
+ }), 128))], 16)]),
679
+ _: 1
680
+ }, 16), createVNode(CodeHighlight_default, {
681
+ code: currentCode.value.code,
682
+ language: currentCode.value.language,
683
+ expanded: unref(expanded),
684
+ "with-copy-button": unref(props).withCopyButton,
685
+ "with-expand-button": unref(props).withExpandButton,
686
+ "with-border": unref(props).withBorder,
687
+ radius: unref(props).radius,
688
+ "max-collapsed-height": unref(props).maxCollapsedHeight,
689
+ "copied-label": unref(props).copiedLabel,
690
+ "copy-label": unref(props).copyLabel,
691
+ "expand-code-label": unref(props).expandCodeLabel,
692
+ "collapse-code-label": unref(props).collapseCodeLabel,
693
+ background: unref(props).background,
694
+ controls: unref(props).controls,
695
+ "code-color-scheme": unref(props).codeColorScheme,
696
+ "with-line-numbers": unref(props).withLineNumbers,
697
+ "__with-offset": "",
698
+ "__static-selector": "CodeHighlightTabs",
699
+ onExpandedChange: unref(setExpanded),
700
+ "class-names": unref(props).classNames,
701
+ styles: unref(props).styles
702
+ }, createSlots({ _: 2 }, [_ctx.$slots.controls ? {
703
+ name: "controls",
704
+ fn: withCtx(() => [renderSlot(_ctx.$slots, "controls")]),
705
+ key: "0"
706
+ } : void 0]), 1032, [
707
+ "code",
708
+ "language",
709
+ "expanded",
710
+ "with-copy-button",
711
+ "with-expand-button",
712
+ "with-border",
713
+ "radius",
714
+ "max-collapsed-height",
715
+ "copied-label",
716
+ "copy-label",
717
+ "expand-code-label",
718
+ "collapse-code-label",
719
+ "background",
720
+ "controls",
721
+ "code-color-scheme",
722
+ "with-line-numbers",
723
+ "onExpandedChange",
724
+ "class-names",
725
+ "styles"
726
+ ])]),
727
+ _: 3
728
+ }, 16)) : createCommentVNode("", true);
793
729
  };
794
730
  }
795
- });
796
- Object.assign(CodeHighlightTabs, { classes: CodeHighlight_module_default });
731
+ }), { classes: CodeHighlight_module_default });
797
732
  //#endregion
798
733
  //#region src/CodeHighlightProvider/adapters/highlight-js-adapter.ts
799
734
  function createHighlightJsAdapter(hljs) {
@@ -1975,6 +1910,6 @@ var createShikiAdapter = (loadShiki, { forceColorScheme } = {}) => ({
1975
1910
  }
1976
1911
  });
1977
1912
  //#endregion
1978
- export { CodeHighlight, CodeHighlightAdapterProvider, CodeHighlightControl, CodeHighlightTabs, InlineCodeHighlight, createHighlightJsAdapter, createShikiAdapter, plainTextAdapter, stripShikiCodeBlocks, useCodeHighlightContext, useHighlight };
1913
+ export { CodeHighlight, CodeHighlightAdapterProvider, CodeHighlightControl_default as CodeHighlightControl, CodeHighlightTabs, InlineCodeHighlight, createHighlightJsAdapter, createShikiAdapter, plainTextAdapter, stripShikiCodeBlocks, useCodeHighlightContext, useHighlight };
1979
1914
 
1980
1915
  //# sourceMappingURL=index.mjs.map