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