@mantine/code-highlight 7.0.0-alpha.1 → 7.0.0-alpha.11
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/CodeHighlight.js +31 -102
- package/cjs/CodeHighlight.js.map +1 -1
- package/cjs/CodeHighlightTabs.js +60 -166
- package/cjs/CodeHighlightTabs.js.map +1 -1
- package/cjs/CopyIcon.js +9 -54
- package/cjs/CopyIcon.js.map +1 -1
- package/cjs/ExpandIcon.js +15 -67
- package/cjs/ExpandIcon.js.map +1 -1
- package/cjs/FileIcon.js +7 -7
- package/cjs/FileIcon.js.map +1 -1
- package/cjs/InlineCodeHighlight.js +19 -54
- package/cjs/InlineCodeHighlight.js.map +1 -1
- package/cjs/index.css +11 -60
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.js +55 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.module.css.js +8 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.module.css.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.theme.module.css.js +8 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlight.theme.module.css.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlightTabs.js +90 -0
- package/cjs/src/mantine-code-highlight/src/CodeHighlightTabs.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/CopyIcon.js +25 -0
- package/cjs/src/mantine-code-highlight/src/CopyIcon.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/ExpandIcon.js +31 -0
- package/cjs/src/mantine-code-highlight/src/ExpandIcon.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/FileIcon.js +22 -0
- package/cjs/src/mantine-code-highlight/src/FileIcon.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/InlineCodeHighlight.js +43 -0
- package/cjs/src/mantine-code-highlight/src/InlineCodeHighlight.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/index.js +14 -0
- package/cjs/src/mantine-code-highlight/src/index.js.map +1 -0
- package/cjs/src/mantine-code-highlight/src/use-highlight.js +29 -0
- package/cjs/src/mantine-code-highlight/src/use-highlight.js.map +1 -0
- package/cjs/use-highlight.js +13 -11
- package/cjs/use-highlight.js.map +1 -1
- package/esm/CodeHighlight.js +31 -102
- package/esm/CodeHighlight.js.map +1 -1
- package/esm/CodeHighlightTabs.js +61 -167
- package/esm/CodeHighlightTabs.js.map +1 -1
- package/esm/CopyIcon.js +9 -54
- package/esm/CopyIcon.js.map +1 -1
- package/esm/ExpandIcon.js +15 -67
- package/esm/ExpandIcon.js.map +1 -1
- package/esm/FileIcon.js +7 -7
- package/esm/FileIcon.js.map +1 -1
- package/esm/InlineCodeHighlight.js +19 -54
- package/esm/InlineCodeHighlight.js.map +1 -1
- package/esm/index.css +11 -60
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/src/mantine-code-highlight/src/CodeHighlight.js +46 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlight.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlight.module.css.js +4 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlight.module.css.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlight.theme.module.css.js +4 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlight.theme.module.css.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlightTabs.js +80 -0
- package/esm/src/mantine-code-highlight/src/CodeHighlightTabs.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/CopyIcon.js +17 -0
- package/esm/src/mantine-code-highlight/src/CopyIcon.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/ExpandIcon.js +23 -0
- package/esm/src/mantine-code-highlight/src/ExpandIcon.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/FileIcon.js +14 -0
- package/esm/src/mantine-code-highlight/src/FileIcon.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/InlineCodeHighlight.js +33 -0
- package/esm/src/mantine-code-highlight/src/InlineCodeHighlight.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/index.js +4 -0
- package/esm/src/mantine-code-highlight/src/index.js.map +1 -0
- package/esm/src/mantine-code-highlight/src/use-highlight.js +21 -0
- package/esm/src/mantine-code-highlight/src/use-highlight.js.map +1 -0
- package/esm/use-highlight.js +13 -11
- package/esm/use-highlight.js.map +1 -1
- package/lib/CodeHighlightTabs.d.ts +1 -1
- package/package.json +17 -8
- package/src/CodeHighlight.module.css +1 -0
- package/src/CodeHighlightTabs.tsx +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/styles.css +0 -326
package/cjs/ExpandIcon.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
5
6
|
var core = require('@mantine/core');
|
|
6
7
|
var React = require('react');
|
|
7
8
|
|
|
@@ -9,74 +10,21 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
10
|
|
|
10
11
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
12
|
|
|
12
|
-
var __defProp = Object.defineProperty;
|
|
13
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
14
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
16
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
-
var __spreadValues = (a, b) => {
|
|
18
|
-
for (var prop in b || (b = {}))
|
|
19
|
-
if (__hasOwnProp.call(b, prop))
|
|
20
|
-
__defNormalProp(a, prop, b[prop]);
|
|
21
|
-
if (__getOwnPropSymbols)
|
|
22
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
23
|
-
if (__propIsEnum.call(b, prop))
|
|
24
|
-
__defNormalProp(a, prop, b[prop]);
|
|
25
|
-
}
|
|
26
|
-
return a;
|
|
27
|
-
};
|
|
28
|
-
var __objRest = (source, exclude) => {
|
|
29
|
-
var target = {};
|
|
30
|
-
for (var prop in source)
|
|
31
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
32
|
-
target[prop] = source[prop];
|
|
33
|
-
if (source != null && __getOwnPropSymbols)
|
|
34
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
35
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
36
|
-
target[prop] = source[prop];
|
|
37
|
-
}
|
|
38
|
-
return target;
|
|
39
|
-
};
|
|
40
13
|
function ExpandIcon(_a) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
56
|
-
d: "M12 13v-8l-3 3m6 0l-3 -3"
|
|
57
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
58
|
-
d: "M9 17l1 0"
|
|
59
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
60
|
-
d: "M14 17l1 0"
|
|
61
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
62
|
-
d: "M19 17l1 0"
|
|
63
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
64
|
-
d: "M4 17l1 0"
|
|
65
|
-
})) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement("path", {
|
|
66
|
-
stroke: "none",
|
|
67
|
-
d: "M0 0h24v24H0z",
|
|
68
|
-
fill: "none"
|
|
69
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
70
|
-
d: "M12 11v8l3 -3m-6 0l3 3"
|
|
71
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
72
|
-
d: "M9 7l1 0"
|
|
73
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
74
|
-
d: "M14 7l1 0"
|
|
75
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
76
|
-
d: "M19 7l1 0"
|
|
77
|
-
}), /* @__PURE__ */ React__default.createElement("path", {
|
|
78
|
-
d: "M4 7l1 0"
|
|
79
|
-
})));
|
|
14
|
+
var { expanded, style } = _a, others = tslib.__rest(_a, ["expanded", "style"]);
|
|
15
|
+
return (React__default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", style: Object.assign({ width: core.rem(18), height: core.rem(18) }, style), viewBox: "0 0 24 24", strokeWidth: "2", stroke: "currentColor", fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }, others), expanded ? (React__default.createElement(React__default.Fragment, null,
|
|
16
|
+
React__default.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
17
|
+
React__default.createElement("path", { d: "M12 13v-8l-3 3m6 0l-3 -3" }),
|
|
18
|
+
React__default.createElement("path", { d: "M9 17l1 0" }),
|
|
19
|
+
React__default.createElement("path", { d: "M14 17l1 0" }),
|
|
20
|
+
React__default.createElement("path", { d: "M19 17l1 0" }),
|
|
21
|
+
React__default.createElement("path", { d: "M4 17l1 0" }))) : (React__default.createElement(React__default.Fragment, null,
|
|
22
|
+
React__default.createElement("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
|
|
23
|
+
React__default.createElement("path", { d: "M12 11v8l3 -3m-6 0l3 3" }),
|
|
24
|
+
React__default.createElement("path", { d: "M9 7l1 0" }),
|
|
25
|
+
React__default.createElement("path", { d: "M14 7l1 0" }),
|
|
26
|
+
React__default.createElement("path", { d: "M19 7l1 0" }),
|
|
27
|
+
React__default.createElement("path", { d: "M4 7l1 0" })))));
|
|
80
28
|
}
|
|
81
29
|
|
|
82
30
|
exports.ExpandIcon = ExpandIcon;
|
package/cjs/ExpandIcon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpandIcon.js","sources":["../src/ExpandIcon.tsx"],"sourcesContent":["import { rem } from '@mantine/core';\nimport React from 'react';\n\ninterface ExpandIconProps extends React.ComponentPropsWithoutRef<'svg'> {\n expanded: boolean;\n}\n\nexport function ExpandIcon({ expanded, style, ...others }: ExpandIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n style={{ width: rem(18), height: rem(18), ...style }}\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...others}\n >\n {expanded ? (\n <>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 13v-8l-3 3m6 0l-3 -3\" />\n <path d=\"M9 17l1 0\" />\n <path d=\"M14 17l1 0\" />\n <path d=\"M19 17l1 0\" />\n <path d=\"M4 17l1 0\" />\n </>\n ) : (\n <>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 11v8l3 -3m-6 0l3 3\" />\n <path d=\"M9 7l1 0\" />\n <path d=\"M14 7l1 0\" />\n <path d=\"M19 7l1 0\" />\n <path d=\"M4 7l1 0\" />\n </>\n )}\n </svg>\n );\n}\n"],"names":["React","rem"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpandIcon.js","sources":["../src/ExpandIcon.tsx"],"sourcesContent":["import { rem } from '@mantine/core';\nimport React from 'react';\n\ninterface ExpandIconProps extends React.ComponentPropsWithoutRef<'svg'> {\n expanded: boolean;\n}\n\nexport function ExpandIcon({ expanded, style, ...others }: ExpandIconProps) {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n style={{ width: rem(18), height: rem(18), ...style }}\n viewBox=\"0 0 24 24\"\n strokeWidth=\"2\"\n stroke=\"currentColor\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n {...others}\n >\n {expanded ? (\n <>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 13v-8l-3 3m6 0l-3 -3\" />\n <path d=\"M9 17l1 0\" />\n <path d=\"M14 17l1 0\" />\n <path d=\"M19 17l1 0\" />\n <path d=\"M4 17l1 0\" />\n </>\n ) : (\n <>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M12 11v8l3 -3m-6 0l3 3\" />\n <path d=\"M9 7l1 0\" />\n <path d=\"M14 7l1 0\" />\n <path d=\"M19 7l1 0\" />\n <path d=\"M4 7l1 0\" />\n </>\n )}\n </svg>\n );\n}\n"],"names":["React","rem"],"mappings":";;;;;;;;;;;;SAOgB,UAAU,CAAC,EAA+C;QAA/C,EAAE,QAAQ,EAAE,KAAK,OAA8B,EAAzB,MAAM,oBAA5B,qBAA8B,CAAF;IACrD,QACEA,oDACE,KAAK,EAAC,4BAA4B,EAClC,KAAK,kBAAI,KAAK,EAAEC,QAAG,CAAC,EAAE,CAAC,EAAE,MAAM,EAAEA,QAAG,CAAC,EAAE,CAAC,IAAK,KAAK,GAClD,OAAO,EAAC,WAAW,EACnB,WAAW,EAAC,GAAG,EACf,MAAM,EAAC,cAAc,EACrB,IAAI,EAAC,MAAM,EACX,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,IAClB,MAAM,GAET,QAAQ,IACPD;QACEA,uCAAM,MAAM,EAAC,MAAM,EAAC,CAAC,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,GAAG;QACpDA,uCAAM,CAAC,EAAC,0BAA0B,GAAG;QACrCA,uCAAM,CAAC,EAAC,WAAW,GAAG;QACtBA,uCAAM,CAAC,EAAC,YAAY,GAAG;QACvBA,uCAAM,CAAC,EAAC,YAAY,GAAG;QACvBA,uCAAM,CAAC,EAAC,WAAW,GAAG,CACrB,KAEHA;QACEA,uCAAM,MAAM,EAAC,MAAM,EAAC,CAAC,EAAC,eAAe,EAAC,IAAI,EAAC,MAAM,GAAG;QACpDA,uCAAM,CAAC,EAAC,wBAAwB,GAAG;QACnCA,uCAAM,CAAC,EAAC,UAAU,GAAG;QACrBA,uCAAM,CAAC,EAAC,WAAW,GAAG;QACtBA,uCAAM,CAAC,EAAC,WAAW,GAAG;QACtBA,uCAAM,CAAC,EAAC,UAAU,GAAG,CACpB,CACJ,CACG,EACN;AACJ;;;;"}
|
package/cjs/FileIcon.js
CHANGED
|
@@ -9,13 +9,13 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
11
|
function FileIcon({ fileIcon, fileName, getFileIcon }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (fileIcon) {
|
|
13
|
+
return React__default.createElement(React__default.Fragment, null, fileIcon);
|
|
14
|
+
}
|
|
15
|
+
if (getFileIcon && fileName) {
|
|
16
|
+
return React__default.createElement(React__default.Fragment, null, getFileIcon(fileName));
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
exports.FileIcon = FileIcon;
|
package/cjs/FileIcon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileIcon.js","sources":["../src/FileIcon.tsx"],"sourcesContent":["import React from 'react';\n\ninterface FileIconProps {\n fileName: string | undefined;\n getFileIcon?: ((fileName: string) => React.ReactNode) | undefined;\n fileIcon: React.ReactNode | undefined;\n}\n\nexport function FileIcon({ fileIcon, fileName, getFileIcon }: FileIconProps) {\n if (fileIcon) {\n return <>{fileIcon}</>;\n }\n\n if (getFileIcon && fileName) {\n return <>{getFileIcon(fileName)}</>;\n }\n\n return null;\n}\n"],"names":["React"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FileIcon.js","sources":["../src/FileIcon.tsx"],"sourcesContent":["import React from 'react';\n\ninterface FileIconProps {\n fileName: string | undefined;\n getFileIcon?: ((fileName: string) => React.ReactNode) | undefined;\n fileIcon: React.ReactNode | undefined;\n}\n\nexport function FileIcon({ fileIcon, fileName, getFileIcon }: FileIconProps) {\n if (fileIcon) {\n return <>{fileIcon}</>;\n }\n\n if (getFileIcon && fileName) {\n return <>{getFileIcon(fileName)}</>;\n }\n\n return null;\n}\n"],"names":["React"],"mappings":";;;;;;;;;;SAQgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAiB;IACzE,IAAI,QAAQ,EAAE;QACZ,OAAOA,4DAAG,QAAQ,CAAI,CAAC;KACxB;IAED,IAAI,WAAW,IAAI,QAAQ,EAAE;QAC3B,OAAOA,4DAAG,WAAW,CAAC,QAAQ,CAAC,CAAI,CAAC;KACrC;IAED,OAAO,IAAI,CAAC;AACd;;;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var cx = require('clsx');
|
|
7
8
|
var core = require('@mantine/core');
|
|
@@ -15,64 +16,28 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
15
16
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
16
17
|
var hljs__default = /*#__PURE__*/_interopDefaultLegacy(hljs);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
var __defProps = Object.defineProperties;
|
|
20
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
21
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
22
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
23
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
24
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
25
|
-
var __spreadValues = (a, b) => {
|
|
26
|
-
for (var prop in b || (b = {}))
|
|
27
|
-
if (__hasOwnProp.call(b, prop))
|
|
28
|
-
__defNormalProp(a, prop, b[prop]);
|
|
29
|
-
if (__getOwnPropSymbols)
|
|
30
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
31
|
-
if (__propIsEnum.call(b, prop))
|
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
|
33
|
-
}
|
|
34
|
-
return a;
|
|
35
|
-
};
|
|
36
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
37
|
-
var __objRest = (source, exclude) => {
|
|
38
|
-
var target = {};
|
|
39
|
-
for (var prop in source)
|
|
40
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
41
|
-
target[prop] = source[prop];
|
|
42
|
-
if (source != null && __getOwnPropSymbols)
|
|
43
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
44
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
45
|
-
target[prop] = source[prop];
|
|
46
|
-
}
|
|
47
|
-
return target;
|
|
48
|
-
};
|
|
49
|
-
const classes = __spreadProps(__spreadValues({}, CodeHighlight_module['default']), { code: cx__default(CodeHighlight_module['default'].code, CodeHighlight_theme_module['default'].theme) });
|
|
19
|
+
const classes = Object.assign(Object.assign({}, CodeHighlight_module['default']), { code: cx__default(CodeHighlight_module['default'].code, CodeHighlight_theme_module['default'].theme) });
|
|
50
20
|
const defaultProps = {
|
|
51
|
-
|
|
21
|
+
language: 'tsx',
|
|
52
22
|
};
|
|
53
23
|
const InlineCodeHighlight = core.factory((_props, ref) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
component: "code",
|
|
70
|
-
ref
|
|
71
|
-
}), others), {
|
|
72
|
-
dangerouslySetInnerHTML: { __html: highlighted }
|
|
73
|
-
}));
|
|
24
|
+
const props = core.useProps('InlineCodeHighlight', defaultProps, _props);
|
|
25
|
+
const { classNames, className, style, styles, unstyled, vars, code, language } = props, others = tslib.__rest(props, ["classNames", "className", "style", "styles", "unstyled", "vars", "code", "language"]);
|
|
26
|
+
const getStyles = core.useStyles({
|
|
27
|
+
name: 'InlineCodeHighlight',
|
|
28
|
+
props,
|
|
29
|
+
classes,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
classNames,
|
|
33
|
+
styles,
|
|
34
|
+
unstyled,
|
|
35
|
+
rootSelector: 'code',
|
|
36
|
+
});
|
|
37
|
+
const highlighted = hljs__default.highlight(code.trim(), { language: language }).value;
|
|
38
|
+
return (React__default.createElement(core.Box, Object.assign({}, getStyles('code'), { component: "code", ref: ref }, others, { dangerouslySetInnerHTML: { __html: highlighted } })));
|
|
74
39
|
});
|
|
75
|
-
InlineCodeHighlight.displayName =
|
|
40
|
+
InlineCodeHighlight.displayName = '@mantine/core/InlineCodeHighlight';
|
|
76
41
|
|
|
77
42
|
exports.InlineCodeHighlight = InlineCodeHighlight;
|
|
78
43
|
//# sourceMappingURL=InlineCodeHighlight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineCodeHighlight.js","sources":["../src/InlineCodeHighlight.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'clsx';\nimport {\n Box,\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n useStyles,\n Factory,\n} from '@mantine/core';\nimport hljs from 'highlight.js';\nimport _classes from './CodeHighlight.module.css';\nimport themeClasses from './CodeHighlight.theme.module.css';\n\nconst classes = { ..._classes, code: cx(_classes.code, themeClasses.theme) };\n\nexport type InlineCodeHighlightStylesNames = 'code';\nexport type InlineCodeHighlightVariant = string;\n\nexport interface InlineCodeHighlightProps\n extends BoxProps,\n StylesApiProps<InlineCodeHighlightFactory>,\n ElementProps<'div'> {\n /** Code to highlight */\n code: string;\n\n /** Code language, `'tsx'` by default */\n language?: string;\n}\n\nexport type InlineCodeHighlightFactory = Factory<{\n props: InlineCodeHighlightProps;\n ref: HTMLElement;\n stylesNames: InlineCodeHighlightStylesNames;\n}>;\n\nconst defaultProps: Partial<InlineCodeHighlightProps> = {\n language: 'tsx',\n};\n\nexport const InlineCodeHighlight = factory<InlineCodeHighlightFactory>((_props, ref) => {\n const props = useProps('InlineCodeHighlight', defaultProps, _props);\n const { classNames, className, style, styles, unstyled, vars, code, language, ...others } = props;\n\n const getStyles = useStyles<InlineCodeHighlightFactory>({\n name: 'InlineCodeHighlight',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n rootSelector: 'code',\n });\n\n const highlighted = hljs.highlight(code.trim(), { language: language! }).value;\n\n return (\n <Box\n {...getStyles('code')}\n component=\"code\"\n ref={ref}\n {...others}\n dangerouslySetInnerHTML={{ __html: highlighted }}\n />\n );\n});\n\nInlineCodeHighlight.displayName = '@mantine/core/InlineCodeHighlight';\n"],"names":["_classes","cx","themeClasses","factory","useProps","useStyles","hljs","React","Box"],"mappings":"
|
|
1
|
+
{"version":3,"file":"InlineCodeHighlight.js","sources":["../src/InlineCodeHighlight.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'clsx';\nimport {\n Box,\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n useStyles,\n Factory,\n} from '@mantine/core';\nimport hljs from 'highlight.js';\nimport _classes from './CodeHighlight.module.css';\nimport themeClasses from './CodeHighlight.theme.module.css';\n\nconst classes = { ..._classes, code: cx(_classes.code, themeClasses.theme) };\n\nexport type InlineCodeHighlightStylesNames = 'code';\nexport type InlineCodeHighlightVariant = string;\n\nexport interface InlineCodeHighlightProps\n extends BoxProps,\n StylesApiProps<InlineCodeHighlightFactory>,\n ElementProps<'div'> {\n /** Code to highlight */\n code: string;\n\n /** Code language, `'tsx'` by default */\n language?: string;\n}\n\nexport type InlineCodeHighlightFactory = Factory<{\n props: InlineCodeHighlightProps;\n ref: HTMLElement;\n stylesNames: InlineCodeHighlightStylesNames;\n}>;\n\nconst defaultProps: Partial<InlineCodeHighlightProps> = {\n language: 'tsx',\n};\n\nexport const InlineCodeHighlight = factory<InlineCodeHighlightFactory>((_props, ref) => {\n const props = useProps('InlineCodeHighlight', defaultProps, _props);\n const { classNames, className, style, styles, unstyled, vars, code, language, ...others } = props;\n\n const getStyles = useStyles<InlineCodeHighlightFactory>({\n name: 'InlineCodeHighlight',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n rootSelector: 'code',\n });\n\n const highlighted = hljs.highlight(code.trim(), { language: language! }).value;\n\n return (\n <Box\n {...getStyles('code')}\n component=\"code\"\n ref={ref}\n {...others}\n dangerouslySetInnerHTML={{ __html: highlighted }}\n />\n );\n});\n\nInlineCodeHighlight.displayName = '@mantine/core/InlineCodeHighlight';\n"],"names":["_classes","cx","themeClasses","factory","useProps","useStyles","hljs","React","Box"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAM,OAAO,mCAAQA,+BAAQ,KAAE,IAAI,EAAEC,WAAE,CAACD,+BAAQ,CAAC,IAAI,EAAEE,qCAAY,CAAC,KAAK,CAAC,GAAE,CAAC;AAsB7E,MAAM,YAAY,GAAsC;IACtD,QAAQ,EAAE,KAAK;CAChB,CAAC;MAEW,mBAAmB,GAAGC,YAAO,CAA6B,CAAC,MAAM,EAAE,GAAG;IACjF,MAAM,KAAK,GAAGC,aAAQ,CAAC,qBAAqB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IACpE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,KAAgB,KAAK,EAAhB,MAAM,gBAAK,KAAK,EAA3F,sFAAmF,CAAQ,CAAC;IAElG,MAAM,SAAS,GAAGC,cAAS,CAA6B;QACtD,IAAI,EAAE,qBAAqB;QAC3B,KAAK;QACL,OAAO;QACP,SAAS;QACT,KAAK;QACL,UAAU;QACV,MAAM;QACN,QAAQ;QACR,YAAY,EAAE,MAAM;KACrB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAGC,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAS,EAAE,CAAC,CAAC,KAAK,CAAC;IAE/E,QACEC,6BAACC,QAAG,oBACE,SAAS,CAAC,MAAM,CAAC,IACrB,SAAS,EAAC,MAAM,EAChB,GAAG,EAAE,GAAG,IACJ,MAAM,IACV,uBAAuB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,IAChD,EACF;AACJ,CAAC,EAAE;AAEH,mBAAmB,CAAC,WAAW,GAAG,mCAAmC;;;;"}
|
package/cjs/index.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.mantine-XIBJZDt {
|
|
2
2
|
display: inline-block;
|
|
3
|
-
padding: 0.0625rem 0.1875rem;
|
|
4
|
-
font-size: 0.8125rem;
|
|
3
|
+
padding: calc(0.0625rem * var(--mantine-scale)) calc(0.1875rem * var(--mantine-scale));
|
|
4
|
+
font-size: calc(0.8125rem * var(--mantine-scale));
|
|
5
5
|
border-radius: var(--mantine-radius-xs);
|
|
6
6
|
line-height: var(--_code-line-height, var(--mantine-line-height));
|
|
7
7
|
font-family: var(--mantine-font-family-monospace);
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
display: block;
|
|
12
12
|
padding: var(--mantine-spacing-xs) var(--mantine-spacing-md);
|
|
13
13
|
margin: 0;
|
|
14
|
+
font-size: 16px; /* Required for Safari to be set in px */
|
|
14
15
|
--_code-line-height: 1.7;
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -22,8 +23,8 @@
|
|
|
22
23
|
|
|
23
24
|
.mantine-059sM-t {
|
|
24
25
|
display: flex;
|
|
25
|
-
margin-top: 0.4375rem;
|
|
26
|
-
margin-right: 0.4375rem;
|
|
26
|
+
margin-top: calc(0.4375rem * var(--mantine-scale));
|
|
27
|
+
margin-right: calc(0.4375rem * var(--mantine-scale));
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
.mantine-tB-P5PD,
|
|
@@ -57,8 +58,8 @@
|
|
|
57
58
|
|
|
58
59
|
.mantine-tB-P5PD {
|
|
59
60
|
position: absolute;
|
|
60
|
-
top: 0.3125rem;
|
|
61
|
-
right: 0.3125rem;
|
|
61
|
+
top: calc(0.3125rem * var(--mantine-scale));
|
|
62
|
+
right: calc(0.3125rem * var(--mantine-scale));
|
|
62
63
|
z-index: 1;
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -67,14 +68,14 @@
|
|
|
67
68
|
align-items: center;
|
|
68
69
|
justify-content: center;
|
|
69
70
|
font-size: var(--mantine-font-size-xs);
|
|
70
|
-
gap: 0.4375rem;
|
|
71
|
-
padding: 0.4375rem 0.75rem;
|
|
71
|
+
gap: calc(0.4375rem * var(--mantine-scale));
|
|
72
|
+
padding: calc(0.4375rem * var(--mantine-scale)) calc(0.75rem * var(--mantine-scale));
|
|
72
73
|
font-family: var(--mantine-font-family-monospace);
|
|
73
74
|
font-weight: 700;
|
|
74
75
|
line-height: 1;
|
|
75
76
|
user-select: none;
|
|
76
77
|
cursor: var(--_file-cursor);
|
|
77
|
-
border: 0.0625rem solid var(--_file-bd);
|
|
78
|
+
border: calc(0.0625rem * var(--mantine-scale)) solid var(--_file-bd);
|
|
78
79
|
border-top: 0;
|
|
79
80
|
border-left: 0;
|
|
80
81
|
color: var(--_file-color);
|
|
@@ -123,16 +124,6 @@
|
|
|
123
124
|
--_file-active-color: var(--mantine-color-black);
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
@media (prefers-color-scheme: light) {
|
|
127
|
-
|
|
128
|
-
.mantine-PBrPXnu {
|
|
129
|
-
--_file-color: var(--mantine-color-gray-8);
|
|
130
|
-
--_file-bd: var(--mantine-color-gray-2);
|
|
131
|
-
--_file-active-bg: var(--mantine-color-white);
|
|
132
|
-
--_file-active-color: var(--mantine-color-black);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
127
|
[data-mantine-color-scheme='dark'] .mantine-PBrPXnu {
|
|
137
128
|
--_file-color: var(--mantine-color-dark-0);
|
|
138
129
|
--_file-bd: var(--mantine-color-dark-4);
|
|
@@ -140,16 +131,6 @@
|
|
|
140
131
|
--_file-active-color: var(--mantine-color-white);
|
|
141
132
|
}
|
|
142
133
|
|
|
143
|
-
@media (prefers-color-scheme: dark) {
|
|
144
|
-
|
|
145
|
-
.mantine-PBrPXnu {
|
|
146
|
-
--_file-color: var(--mantine-color-dark-0);
|
|
147
|
-
--_file-bd: var(--mantine-color-dark-4);
|
|
148
|
-
--_file-active-bg: var(--mantine-color-dark-6);
|
|
149
|
-
--_file-active-color: var(--mantine-color-white);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
134
|
.mantine-IvOddiX {
|
|
154
135
|
display: flex;
|
|
155
136
|
}
|
|
@@ -166,7 +147,7 @@
|
|
|
166
147
|
inset: 0;
|
|
167
148
|
pointer-events: none;
|
|
168
149
|
background-image: linear-gradient(0deg, var(--_background) 16%, rgba(0, 0, 0, 0) 100%);
|
|
169
|
-
border-radius: calc(var(--mantine-radius-md) - 0.0625rem);
|
|
150
|
+
border-radius: calc(var(--mantine-radius-md) - calc(0.0625rem * var(--mantine-scale)));
|
|
170
151
|
}
|
|
171
152
|
|
|
172
153
|
.mantine-YfYyOiA[data-expanded] {
|
|
@@ -216,21 +197,6 @@
|
|
|
216
197
|
--code-class-color: var(--mantine-color-orange-9);
|
|
217
198
|
}
|
|
218
199
|
|
|
219
|
-
@media (prefers-color-scheme: light) {
|
|
220
|
-
|
|
221
|
-
.mantine-h-DP-Yw {
|
|
222
|
-
--_color: var(--mantine-color-gray-7);
|
|
223
|
-
--_background: var(--mantine-color-gray-0);
|
|
224
|
-
--code-comment-color: var(--mantine-color-gray-6);
|
|
225
|
-
--code-keyword-color: var(--mantine-color-violet-8);
|
|
226
|
-
--code-tag-color: var(--mantine-color-red-9);
|
|
227
|
-
--code-literal-color: var(--mantine-color-blue-6);
|
|
228
|
-
--code-string-color: var(--mantine-color-blue-9);
|
|
229
|
-
--code-variable-color: var(--mantine-color-lime-9);
|
|
230
|
-
--code-class-color: var(--mantine-color-orange-9);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
200
|
[data-mantine-color-scheme='dark'] .mantine-h-DP-Yw {
|
|
235
201
|
--_color: var(--mantine-color-dark-1);
|
|
236
202
|
--_background: var(--mantine-color-dark-8);
|
|
@@ -243,21 +209,6 @@
|
|
|
243
209
|
--code-class-color: var(--mantine-color-orange-5);
|
|
244
210
|
}
|
|
245
211
|
|
|
246
|
-
@media (prefers-color-scheme: dark) {
|
|
247
|
-
|
|
248
|
-
.mantine-h-DP-Yw {
|
|
249
|
-
--_color: var(--mantine-color-dark-1);
|
|
250
|
-
--_background: var(--mantine-color-dark-8);
|
|
251
|
-
--code-comment-color: var(--mantine-color-dark-3);
|
|
252
|
-
--code-keyword-color: var(--mantine-color-violet-3);
|
|
253
|
-
--code-tag-color: var(--mantine-color-yellow-4);
|
|
254
|
-
--code-literal-color: var(--mantine-color-blue-4);
|
|
255
|
-
--code-string-color: var(--mantine-color-green-6);
|
|
256
|
-
--code-variable-color: var(--mantine-color-blue-2);
|
|
257
|
-
--code-class-color: var(--mantine-color-orange-5);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
212
|
.mantine-h-DP-Yw .hljs-comment,
|
|
262
213
|
.mantine-h-DP-Yw .hljs-quote {
|
|
263
214
|
font-style: italic;
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cx = require('clsx');
|
|
8
|
+
var core = require('@mantine/core');
|
|
9
|
+
var useHighlight = require('./use-highlight.js');
|
|
10
|
+
var CopyIcon = require('./CopyIcon.js');
|
|
11
|
+
var CodeHighlight_module = require('./CodeHighlight.module.css.js');
|
|
12
|
+
var CodeHighlight_theme_module = require('./CodeHighlight.theme.module.css.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
15
|
+
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
18
|
+
|
|
19
|
+
const classes = Object.assign(Object.assign({}, CodeHighlight_module['default']), { root: cx__default(CodeHighlight_module['default'].root, CodeHighlight_theme_module['default'].theme) });
|
|
20
|
+
const defaultProps = {
|
|
21
|
+
copyLabel: 'Copy code',
|
|
22
|
+
copiedLabel: 'Copied',
|
|
23
|
+
language: 'tsx',
|
|
24
|
+
withCopyButton: true,
|
|
25
|
+
};
|
|
26
|
+
const CodeHighlight = core.factory((_props, ref) => {
|
|
27
|
+
const props = core.useProps('CodeHighlight', defaultProps, _props);
|
|
28
|
+
const { classNames, className, style, styles, unstyled, vars, children, code, copiedLabel, copyLabel, language, withCopyButton, highlightOnClient } = props, others = tslib_es6.__rest(props, ["classNames", "className", "style", "styles", "unstyled", "vars", "children", "code", "copiedLabel", "copyLabel", "language", "withCopyButton", "highlightOnClient"]);
|
|
29
|
+
const getStyles = core.useStyles({
|
|
30
|
+
name: 'CodeHighlight',
|
|
31
|
+
props,
|
|
32
|
+
classes,
|
|
33
|
+
className,
|
|
34
|
+
style,
|
|
35
|
+
classNames,
|
|
36
|
+
styles,
|
|
37
|
+
unstyled,
|
|
38
|
+
});
|
|
39
|
+
const getCodeProps = useHighlight.useHighlight({
|
|
40
|
+
code,
|
|
41
|
+
language: language,
|
|
42
|
+
highlightOnClient,
|
|
43
|
+
});
|
|
44
|
+
return (React__default.createElement(core.Box, Object.assign({}, getStyles('root'), { ref: ref }, others, { dir: "ltr" }),
|
|
45
|
+
withCopyButton && (React__default.createElement(core.CopyButton, { value: code.trim() }, ({ copied, copy }) => (React__default.createElement(core.Tooltip, { label: copied ? copiedLabel : copyLabel, fz: "sm", position: "left" },
|
|
46
|
+
React__default.createElement(core.ActionIcon, Object.assign({ onClick: copy, variant: "none" }, getStyles('copy')),
|
|
47
|
+
React__default.createElement(CopyIcon.CopyIcon, { copied: copied })))))),
|
|
48
|
+
React__default.createElement(core.ScrollArea, { type: "auto", dir: "ltr", offsetScrollbars: false },
|
|
49
|
+
React__default.createElement("pre", Object.assign({}, getStyles('pre')),
|
|
50
|
+
React__default.createElement("code", Object.assign({}, getStyles('code'), getCodeProps()))))));
|
|
51
|
+
});
|
|
52
|
+
CodeHighlight.displayName = '@mantine/core/CodeHighlight';
|
|
53
|
+
|
|
54
|
+
exports.CodeHighlight = CodeHighlight;
|
|
55
|
+
//# sourceMappingURL=CodeHighlight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeHighlight.js","sources":["../../../../src/CodeHighlight.tsx"],"sourcesContent":["import React from 'react';\nimport cx from 'clsx';\nimport {\n Box,\n BoxProps,\n StylesApiProps,\n factory,\n ElementProps,\n useProps,\n useStyles,\n CopyButton,\n Tooltip,\n ActionIcon,\n ScrollArea,\n Factory,\n} from '@mantine/core';\nimport { useHighlight } from './use-highlight';\nimport { CopyIcon } from './CopyIcon';\nimport _classes from './CodeHighlight.module.css';\nimport themeClasses from './CodeHighlight.theme.module.css';\n\nconst classes = { ..._classes, root: cx(_classes.root, themeClasses.theme) };\n\nexport type CodeHighlightStylesNames = 'root' | 'code' | 'pre' | 'copy';\nexport type CodeHighlightVariant = string;\n\nexport interface CodeHighlightProps\n extends BoxProps,\n StylesApiProps<CodeHighlightFactory>,\n ElementProps<'div'> {\n /** Code to highlight */\n code: string;\n\n /** Code language, `'tsx'` by default */\n language?: string;\n\n /** Determines whether copy button should be displayed, `true` by default */\n withCopyButton?: boolean;\n\n /** Copy tooltip label, `'Copy code'` by default */\n copyLabel?: string;\n\n /** Copied tooltip label, `'Copied'` by default */\n copiedLabel?: string;\n\n /** Determines whether code should be highlighted only after component is mounted to the dom (disables code highlight on server), `false` by default */\n highlightOnClient?: boolean;\n}\n\nexport type CodeHighlightFactory = Factory<{\n props: CodeHighlightProps;\n ref: HTMLDivElement;\n stylesNames: CodeHighlightStylesNames;\n variant: CodeHighlightVariant;\n}>;\n\nconst defaultProps: Partial<CodeHighlightProps> = {\n copyLabel: 'Copy code',\n copiedLabel: 'Copied',\n language: 'tsx',\n withCopyButton: true,\n};\n\nexport const CodeHighlight = factory<CodeHighlightFactory>((_props, ref) => {\n const props = useProps('CodeHighlight', defaultProps, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n children,\n code,\n copiedLabel,\n copyLabel,\n language,\n withCopyButton,\n highlightOnClient,\n ...others\n } = props;\n\n const getStyles = useStyles<CodeHighlightFactory>({\n name: 'CodeHighlight',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n });\n\n const getCodeProps = useHighlight({\n code,\n language: language!,\n highlightOnClient,\n });\n\n return (\n <Box {...getStyles('root')} ref={ref} {...others} dir=\"ltr\">\n {withCopyButton && (\n <CopyButton value={code.trim()}>\n {({ copied, copy }) => (\n <Tooltip label={copied ? copiedLabel : copyLabel} fz=\"sm\" position=\"left\">\n <ActionIcon onClick={copy} variant=\"none\" {...getStyles('copy')}>\n <CopyIcon copied={copied} />\n </ActionIcon>\n </Tooltip>\n )}\n </CopyButton>\n )}\n\n <ScrollArea type=\"auto\" dir=\"ltr\" offsetScrollbars={false}>\n <pre {...getStyles('pre')}>\n <code {...getStyles('code')} {...getCodeProps()} />\n </pre>\n </ScrollArea>\n </Box>\n );\n});\n\nCodeHighlight.displayName = '@mantine/core/CodeHighlight';\n"],"names":["_classes","cx","themeClasses","factory","useProps","useStyles","useHighlight","React","Box","CopyButton","Tooltip","ActionIcon","CopyIcon","ScrollArea"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,MAAM,OAAO,mCAAQA,+BAAQ,KAAE,IAAI,EAAEC,WAAE,CAACD,+BAAQ,CAAC,IAAI,EAAEE,qCAAY,CAAC,KAAK,CAAC,GAAE,CAAC;AAmC7E,MAAM,YAAY,GAAgC;IAChD,SAAS,EAAE,WAAW;IACtB,WAAW,EAAE,QAAQ;IACrB,QAAQ,EAAE,KAAK;IACf,cAAc,EAAE,IAAI;CACrB,CAAC;MAEW,aAAa,GAAGC,YAAO,CAAuB,CAAC,MAAM,EAAE,GAAG;IACrE,MAAM,KAAK,GAAGC,aAAQ,CAAC,eAAe,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;IAC9D,MAAM,EACJ,UAAU,EACV,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,cAAc,EACd,iBAAiB,KAEf,KAAK,EADJ,MAAM,oBACP,KAAK,EAfH,qKAeL,CAAQ,CAAC;IAEV,MAAM,SAAS,GAAGC,cAAS,CAAuB;QAChD,IAAI,EAAE,eAAe;QACrB,KAAK;QACL,OAAO;QACP,SAAS;QACT,KAAK;QACL,UAAU;QACV,MAAM;QACN,QAAQ;KACT,CAAC,CAAC;IAEH,MAAM,YAAY,GAAGC,yBAAY,CAAC;QAChC,IAAI;QACJ,QAAQ,EAAE,QAAS;QACnB,iBAAiB;KAClB,CAAC,CAAC;IAEH,QACEC,6BAACC,QAAG,oBAAK,SAAS,CAAC,MAAM,CAAC,IAAE,GAAG,EAAE,GAAG,IAAM,MAAM,IAAE,GAAG,EAAC,KAAK;QACxD,cAAc,KACbD,6BAACE,eAAU,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAC3B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAChBF,6BAACG,YAAO,IAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,EAAE,EAAE,EAAC,IAAI,EAAC,QAAQ,EAAC,MAAM;YACvEH,6BAACI,eAAU,kBAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,IAAK,SAAS,CAAC,MAAM,CAAC;gBAC7DJ,6BAACK,iBAAQ,IAAC,MAAM,EAAE,MAAM,GAAI,CACjB,CACL,CACX,CACU,CACd;QAEDL,6BAACM,eAAU,IAAC,IAAI,EAAC,MAAM,EAAC,GAAG,EAAC,KAAK,EAAC,gBAAgB,EAAE,KAAK;YACvDN,sDAAS,SAAS,CAAC,KAAK,CAAC;gBACvBA,uDAAU,SAAS,CAAC,MAAM,CAAC,EAAM,YAAY,EAAE,EAAI,CAC/C,CACK,CACT,EACN;AACJ,CAAC,EAAE;AAEH,aAAa,CAAC,WAAW,GAAG,6BAA6B;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _classes = {"code":"mantine-XIBJZDt","pre":"mantine-RDvBcjB","header":"mantine-cmEtjrV","controls":"mantine-059sM-t","copy":"mantine-tB-P5PD","control":"mantine-NTm-nGn","file":"mantine-PBrPXnu","files":"mantine-IvOddiX","codeWrapper":"mantine-YfYyOiA","showCodeButton":"mantine-haNyFRC","root":"mantine-k6OJW8l"};
|
|
6
|
+
|
|
7
|
+
exports.default = _classes;
|
|
8
|
+
//# sourceMappingURL=CodeHighlight.module.css.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeHighlight.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeHighlight.theme.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var hljs = require('highlight.js');
|
|
8
|
+
var cx = require('clsx');
|
|
9
|
+
var hooks = require('@mantine/hooks');
|
|
10
|
+
var core = require('@mantine/core');
|
|
11
|
+
var CopyIcon = require('./CopyIcon.js');
|
|
12
|
+
var FileIcon = require('./FileIcon.js');
|
|
13
|
+
var ExpandIcon = require('./ExpandIcon.js');
|
|
14
|
+
var CodeHighlight_module = require('./CodeHighlight.module.css.js');
|
|
15
|
+
var CodeHighlight_theme_module = require('./CodeHighlight.theme.module.css.js');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
+
var hljs__default = /*#__PURE__*/_interopDefaultLegacy(hljs);
|
|
21
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
22
|
+
|
|
23
|
+
const classes = Object.assign(Object.assign({}, CodeHighlight_module['default']), { root: cx__default(CodeHighlight_module['default'].root, CodeHighlight_theme_module['default'].theme) });
|
|
24
|
+
const defaultProps = {
|
|
25
|
+
withHeader: true,
|
|
26
|
+
copyLabel: 'Copy code',
|
|
27
|
+
copiedLabel: 'Copied',
|
|
28
|
+
maxCollapsedHeight: core.rem('8rem'),
|
|
29
|
+
expandCodeLabel: 'Expand code',
|
|
30
|
+
collapseCodeLabel: 'Collapse code',
|
|
31
|
+
};
|
|
32
|
+
const varsResolver = core.createVarsResolver((_, { maxCollapsedHeight }) => ({
|
|
33
|
+
root: { '--ch-max-collapsed-height': core.rem(maxCollapsedHeight) },
|
|
34
|
+
}));
|
|
35
|
+
const CodeHighlightTabs = core.factory((_props, ref) => {
|
|
36
|
+
const props = core.useProps('CodeHighlightTabs', defaultProps, _props);
|
|
37
|
+
const { classNames, className, style, styles, unstyled, vars, children, code, defaultActiveTab, activeTab, onTabChange, withHeader, copiedLabel, copyLabel, getFileIcon, maxCollapsedHeight, expanded, defaultExpanded, onExpandedChange, expandCodeLabel, collapseCodeLabel, withExpandButton } = props, others = tslib_es6.__rest(props, ["classNames", "className", "style", "styles", "unstyled", "vars", "children", "code", "defaultActiveTab", "activeTab", "onTabChange", "withHeader", "copiedLabel", "copyLabel", "getFileIcon", "maxCollapsedHeight", "expanded", "defaultExpanded", "onExpandedChange", "expandCodeLabel", "collapseCodeLabel", "withExpandButton"]);
|
|
38
|
+
const getStyles = core.useStyles({
|
|
39
|
+
name: 'CodeHighlightTabs',
|
|
40
|
+
props,
|
|
41
|
+
classes,
|
|
42
|
+
className,
|
|
43
|
+
style,
|
|
44
|
+
classNames,
|
|
45
|
+
styles,
|
|
46
|
+
unstyled,
|
|
47
|
+
vars,
|
|
48
|
+
varsResolver,
|
|
49
|
+
});
|
|
50
|
+
const [value, setValue] = hooks.useUncontrolled({
|
|
51
|
+
defaultValue: defaultActiveTab,
|
|
52
|
+
value: activeTab,
|
|
53
|
+
finalValue: 0,
|
|
54
|
+
onChange: onTabChange,
|
|
55
|
+
});
|
|
56
|
+
const [_expanded, setExpanded] = hooks.useUncontrolled({
|
|
57
|
+
defaultValue: defaultExpanded,
|
|
58
|
+
value: expanded,
|
|
59
|
+
finalValue: true,
|
|
60
|
+
onChange: onExpandedChange,
|
|
61
|
+
});
|
|
62
|
+
const nodes = Array.isArray(code) ? code : [code];
|
|
63
|
+
const currentCode = nodes[value];
|
|
64
|
+
const highlighted = hljs__default.highlight(currentCode.code.trim(), {
|
|
65
|
+
language: currentCode.language,
|
|
66
|
+
}).value;
|
|
67
|
+
const files = nodes.map((node, index) => (React__default.createElement(core.UnstyledButton, Object.assign({}, getStyles('file'), { key: node.fileName, mod: { active: index === value }, onClick: () => setValue(index) }),
|
|
68
|
+
React__default.createElement(FileIcon.FileIcon, { fileIcon: node.icon, getFileIcon: getFileIcon, fileName: node.fileName }),
|
|
69
|
+
React__default.createElement("span", null, node.fileName))));
|
|
70
|
+
return (React__default.createElement(core.Box, Object.assign({}, getStyles('root'), { ref: ref }, others, { dir: "ltr" }),
|
|
71
|
+
withHeader && (React__default.createElement("div", Object.assign({}, getStyles('header')),
|
|
72
|
+
React__default.createElement(core.ScrollArea, { type: "never", dir: "ltr", offsetScrollbars: false },
|
|
73
|
+
React__default.createElement("div", Object.assign({}, getStyles('files')), files)),
|
|
74
|
+
React__default.createElement("div", Object.assign({}, getStyles('controls')),
|
|
75
|
+
withExpandButton && (React__default.createElement(core.Tooltip, { label: _expanded ? collapseCodeLabel : expandCodeLabel, fz: "sm", position: "left" },
|
|
76
|
+
React__default.createElement(core.ActionIcon, Object.assign({ onClick: () => setExpanded(!_expanded), variant: "none" }, getStyles('control')),
|
|
77
|
+
React__default.createElement(ExpandIcon.ExpandIcon, { expanded: _expanded })))),
|
|
78
|
+
React__default.createElement(core.CopyButton, { value: currentCode.code.trim() }, ({ copied, copy }) => (React__default.createElement(core.Tooltip, { label: copied ? copiedLabel : copyLabel, fz: "sm", position: "left" },
|
|
79
|
+
React__default.createElement(core.ActionIcon, Object.assign({ onClick: copy, variant: "none" }, getStyles('control')),
|
|
80
|
+
React__default.createElement(CopyIcon.CopyIcon, { copied: copied })))))))),
|
|
81
|
+
React__default.createElement(core.ScrollArea, { type: "auto", dir: "ltr", offsetScrollbars: false },
|
|
82
|
+
React__default.createElement(core.Box, Object.assign({}, getStyles('codeWrapper'), { mod: { expanded: _expanded } }),
|
|
83
|
+
React__default.createElement("pre", Object.assign({}, getStyles('pre')),
|
|
84
|
+
React__default.createElement("code", Object.assign({}, getStyles('code'), { dangerouslySetInnerHTML: { __html: highlighted } }))))),
|
|
85
|
+
React__default.createElement(core.UnstyledButton, Object.assign({}, getStyles('showCodeButton'), { mod: { hidden: _expanded }, onClick: () => setExpanded(true) }), "Expand code")));
|
|
86
|
+
});
|
|
87
|
+
CodeHighlightTabs.displayName = '@mantine/core/CodeHighlightTabs';
|
|
88
|
+
|
|
89
|
+
exports.CodeHighlightTabs = CodeHighlightTabs;
|
|
90
|
+
//# sourceMappingURL=CodeHighlightTabs.js.map
|