@mantine-vue/code-highlight 2.3.1 → 3.0.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/cjs/index.cjs +12 -6
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +12 -6
- package/esm/index.mjs.map +1 -1
- package/lib/CodeHighlight/CodeHighlight.d.ts +6 -3
- package/lib/CodeHighlightTabs/CodeHighlightTabs.d.ts +8 -2
- package/lib/CodeHighlightTabs/FileIcon.d.ts +8 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.d.ts +2 -2
- package/package.json +3 -3
package/cjs/index.cjs
CHANGED
|
@@ -278,6 +278,7 @@ function resolveColorScheme(value) {
|
|
|
278
278
|
var CodeHighlightBase = (0, vue.defineComponent)({
|
|
279
279
|
name: "CodeHighlight",
|
|
280
280
|
inheritAttrs: false,
|
|
281
|
+
slots: Object,
|
|
281
282
|
props: {
|
|
282
283
|
code: {
|
|
283
284
|
type: String,
|
|
@@ -380,7 +381,7 @@ var CodeHighlightBase = (0, vue.defineComponent)({
|
|
|
380
381
|
default: false
|
|
381
382
|
}
|
|
382
383
|
},
|
|
383
|
-
setup(rawProps, { attrs }) {
|
|
384
|
+
setup(rawProps, { attrs, slots }) {
|
|
384
385
|
const props = (0, _mantine_vue_core.useProps)("CodeHighlight", defaultProps, rawProps);
|
|
385
386
|
const mantine = (0, _mantine_vue_core.useMantineContext)();
|
|
386
387
|
const getStyles = (0, _mantine_vue_core.useStyles)({
|
|
@@ -428,7 +429,7 @@ var CodeHighlightBase = (0, vue.defineComponent)({
|
|
|
428
429
|
"data-with-border": props.withBorder || void 0,
|
|
429
430
|
...codeContent
|
|
430
431
|
});
|
|
431
|
-
const renderedControls = typeof props.controls === "function" ? props.controls() : props.controls;
|
|
432
|
+
const renderedControls = props.controls !== void 0 ? typeof props.controls === "function" ? props.controls() : props.controls : slots.controls?.();
|
|
432
433
|
const controlsArray = Array.isArray(renderedControls) ? renderedControls : renderedControls ? [renderedControls] : [];
|
|
433
434
|
const shouldDisplayControls = controlsArray.length > 0 || props.withExpandButton || props.withCopyButton;
|
|
434
435
|
return (0, vue.h)(_mantine_vue_core.Box, {
|
|
@@ -571,6 +572,7 @@ Object.assign(InlineCodeHighlight, {
|
|
|
571
572
|
var FileIcon = (0, vue.defineComponent)({
|
|
572
573
|
name: "FileIcon",
|
|
573
574
|
inheritAttrs: false,
|
|
575
|
+
slots: Object,
|
|
574
576
|
props: {
|
|
575
577
|
fileName: {
|
|
576
578
|
type: String,
|
|
@@ -591,10 +593,12 @@ var FileIcon = (0, vue.defineComponent)({
|
|
|
591
593
|
default: void 0
|
|
592
594
|
}
|
|
593
595
|
},
|
|
594
|
-
setup(props, { attrs }) {
|
|
596
|
+
setup(props, { attrs, slots }) {
|
|
595
597
|
return () => {
|
|
596
598
|
if (props.fileIcon) return (0, vue.h)("span", attrs, props.fileIcon);
|
|
597
599
|
if (props.getFileIcon && props.fileName) return (0, vue.h)("span", attrs, props.getFileIcon(props.fileName));
|
|
600
|
+
if (slots.fileIcon) return (0, vue.h)("span", attrs, slots.fileIcon());
|
|
601
|
+
if (slots.getFileIcon && props.fileName) return (0, vue.h)("span", attrs, slots.getFileIcon({ fileName: props.fileName }));
|
|
598
602
|
return null;
|
|
599
603
|
};
|
|
600
604
|
}
|
|
@@ -604,6 +608,7 @@ var FileIcon = (0, vue.defineComponent)({
|
|
|
604
608
|
var CodeHighlightTabs = (0, vue.defineComponent)({
|
|
605
609
|
name: "CodeHighlightTabs",
|
|
606
610
|
inheritAttrs: false,
|
|
611
|
+
slots: Object,
|
|
607
612
|
props: {
|
|
608
613
|
code: {
|
|
609
614
|
type: Array,
|
|
@@ -706,7 +711,7 @@ var CodeHighlightTabs = (0, vue.defineComponent)({
|
|
|
706
711
|
default: false
|
|
707
712
|
}
|
|
708
713
|
},
|
|
709
|
-
setup(rawProps, { attrs }) {
|
|
714
|
+
setup(rawProps, { attrs, slots }) {
|
|
710
715
|
const props = (0, _mantine_vue_core.useProps)("CodeHighlightTabs", null, rawProps);
|
|
711
716
|
const getStyles = (0, _mantine_vue_core.useStyles)({
|
|
712
717
|
name: "CodeHighlightTabs",
|
|
@@ -741,6 +746,7 @@ var CodeHighlightTabs = (0, vue.defineComponent)({
|
|
|
741
746
|
language: "tsx",
|
|
742
747
|
fileName: ""
|
|
743
748
|
};
|
|
749
|
+
const getFileIcon = props.getFileIcon ?? (slots.getFileIcon ? (fileName) => slots.getFileIcon?.({ fileName }) : void 0);
|
|
744
750
|
const files = props.code.map((node, index) => (0, vue.h)(_mantine_vue_core.UnstyledButton, {
|
|
745
751
|
...getStyles("file"),
|
|
746
752
|
key: node.fileName ?? index,
|
|
@@ -749,7 +755,7 @@ var CodeHighlightTabs = (0, vue.defineComponent)({
|
|
|
749
755
|
"data-color-scheme": props.codeColorScheme
|
|
750
756
|
}, () => [(0, vue.h)(FileIcon, {
|
|
751
757
|
fileIcon: node.icon,
|
|
752
|
-
getFileIcon
|
|
758
|
+
getFileIcon,
|
|
753
759
|
fileName: node.fileName,
|
|
754
760
|
key: "file-icon",
|
|
755
761
|
...getStyles("fileIcon")
|
|
@@ -784,7 +790,7 @@ var CodeHighlightTabs = (0, vue.defineComponent)({
|
|
|
784
790
|
__staticSelector: "CodeHighlightTabs",
|
|
785
791
|
classNames: props.classNames,
|
|
786
792
|
styles: props.styles
|
|
787
|
-
})]);
|
|
793
|
+
}, { controls: slots.controls })]);
|
|
788
794
|
};
|
|
789
795
|
}
|
|
790
796
|
});
|