@synerise/ds-code-snippet 1.1.38 → 1.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +23 -0
- package/dist/CodeSnippet.d.ts +2 -3
- package/dist/CodeSnippet.js +31 -68
- package/dist/CodeSnippet.types.d.ts +2 -2
- package/dist/CodeSnippet.types.js +15 -11
- package/dist/CodeTypes/InlineCode/InlineCode.d.ts +1 -1
- package/dist/CodeTypes/InlineCode/InlineCode.js +10 -10
- package/dist/CodeTypes/InlineCode/InlineCode.styles.d.ts +1 -1
- package/dist/CodeTypes/InlineCode/InlineCode.styles.js +6 -5
- package/dist/CodeTypes/MultiCode/MultiCode.d.ts +2 -2
- package/dist/CodeTypes/MultiCode/MultiCode.js +70 -126
- package/dist/CodeTypes/MultiCode/MultiCode.styles.d.ts +8 -8
- package/dist/CodeTypes/MultiCode/MultiCode.styles.js +35 -26
- package/dist/CodeTypes/SingleCode/SingleCode.d.ts +1 -1
- package/dist/CodeTypes/SingleCode/SingleCode.js +25 -37
- package/dist/CodeTypes/SingleCode/SingleCode.styles.d.ts +4 -4
- package/dist/CodeTypes/SingleCode/SingleCode.styles.js +28 -29
- package/dist/Highlight/Highlight.d.ts +2 -2
- package/dist/Highlight/Highlight.js +63 -57
- package/dist/Highlight/Highlight.styles.d.ts +1 -1
- package/dist/Highlight/Highlight.styles.js +6 -27
- package/dist/Highlight/Highlight.types.d.ts +1 -1
- package/dist/Highlight/Highlight.types.js +1 -1
- package/dist/_virtual/preload-helper.js +57 -0
- package/dist/assets/style/index-tn0RQdqM.css +0 -0
- package/dist/index.js +6 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +10 -10
- package/dist/CodeSnippet.figma.d.ts +0 -1
- package/dist/CodeSnippet.figma.js +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.40](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.39...@synerise/ds-code-snippet@1.1.40) (2026-04-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
9
|
+
|
|
10
|
+
## [1.1.39](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.38...@synerise/ds-code-snippet@1.1.39) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
13
|
+
|
|
6
14
|
## [1.1.38](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.37...@synerise/ds-code-snippet@1.1.38) (2026-03-20)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
package/README.md
CHANGED
|
@@ -24,6 +24,29 @@ import CodeSnippet from '@synerise/ds-code-snippet'
|
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Syntax highlighting
|
|
28
|
+
|
|
29
|
+
The following languages are bundled and work out of the box with any bundler: `javascript`, `typescript`, `json`, `css`, `html`, `xml`.
|
|
30
|
+
|
|
31
|
+
Other languages from the `LanguageHighlight` type are loaded on demand via dynamic `import()`. This works automatically with webpack. **Vite** users need to add an alias so the dynamic import can resolve `highlight.js` from the filesystem:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// vite.config.ts
|
|
35
|
+
import { resolve } from 'path';
|
|
36
|
+
import { defineConfig } from 'vite';
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: {
|
|
41
|
+
'highlight.js': resolve(
|
|
42
|
+
__dirname,
|
|
43
|
+
'node_modules/highlight.js',
|
|
44
|
+
),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
27
50
|
## Demo
|
|
28
51
|
|
|
29
52
|
<iframe src="/storybook-static/iframe.html?id=components-code-snippet--default"></iframe>
|
package/dist/CodeSnippet.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import './style/index.less';
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CodeSnippetProps } from './CodeSnippet.types';
|
|
4
3
|
declare const CodeSnippet: ({ type, languages, children, colorSyntax, fontSize, tooltipTitleHover, tooltipTitleClick, labelBeforeExpanded, labelAfterExpanded, wrap, rows, className, onExpand, onCopy, customTriggerComponent, expanded, hideExpandButton, hideCopyButton, }: CodeSnippetProps) => React.JSX.Element;
|
|
5
4
|
export default CodeSnippet;
|
package/dist/CodeSnippet.js
CHANGED
|
@@ -1,75 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CodeSnippetType, FontSize } from
|
|
3
|
-
import InlineCode from
|
|
4
|
-
import MultiCode from
|
|
5
|
-
import SingleCode from
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CodeSnippetType, FontSize } from "./CodeSnippet.types.js";
|
|
3
|
+
import InlineCode from "./CodeTypes/InlineCode/InlineCode.js";
|
|
4
|
+
import MultiCode from "./CodeTypes/MultiCode/MultiCode.js";
|
|
5
|
+
import SingleCode from "./CodeTypes/SingleCode/SingleCode.js";
|
|
6
6
|
import "./style/index.css";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
wrap = _ref$wrap === void 0 ? false : _ref$wrap,
|
|
28
|
-
_ref$rows = _ref.rows,
|
|
29
|
-
rows = _ref$rows === void 0 ? 6 : _ref$rows,
|
|
30
|
-
className = _ref.className,
|
|
31
|
-
onExpand = _ref.onExpand,
|
|
32
|
-
onCopy = _ref.onCopy,
|
|
33
|
-
customTriggerComponent = _ref.customTriggerComponent,
|
|
34
|
-
_ref$expanded = _ref.expanded,
|
|
35
|
-
expanded = _ref$expanded === void 0 ? false : _ref$expanded,
|
|
36
|
-
_ref$hideExpandButton = _ref.hideExpandButton,
|
|
37
|
-
hideExpandButton = _ref$hideExpandButton === void 0 ? false : _ref$hideExpandButton,
|
|
38
|
-
_ref$hideCopyButton = _ref.hideCopyButton,
|
|
39
|
-
hideCopyButton = _ref$hideCopyButton === void 0 ? false : _ref$hideCopyButton;
|
|
7
|
+
const CodeSnippet = ({
|
|
8
|
+
type = CodeSnippetType.INLINE,
|
|
9
|
+
languages = ["javascript", "typescript", "json"],
|
|
10
|
+
children = "",
|
|
11
|
+
colorSyntax = false,
|
|
12
|
+
fontSize = FontSize.SMALL,
|
|
13
|
+
tooltipTitleHover = "Copy",
|
|
14
|
+
tooltipTitleClick = "Copied!",
|
|
15
|
+
labelBeforeExpanded = "Show more",
|
|
16
|
+
labelAfterExpanded = "Show less",
|
|
17
|
+
wrap = false,
|
|
18
|
+
rows = 6,
|
|
19
|
+
className,
|
|
20
|
+
onExpand,
|
|
21
|
+
onCopy,
|
|
22
|
+
customTriggerComponent,
|
|
23
|
+
expanded = false,
|
|
24
|
+
hideExpandButton = false,
|
|
25
|
+
hideCopyButton = false
|
|
26
|
+
}) => {
|
|
40
27
|
switch (type) {
|
|
41
28
|
case CodeSnippetType.SINGLE_LINE:
|
|
42
|
-
return
|
|
43
|
-
fontSize: fontSize,
|
|
44
|
-
tooltipTitleHover: tooltipTitleHover,
|
|
45
|
-
tooltipTitleClick: tooltipTitleClick,
|
|
46
|
-
className: className,
|
|
47
|
-
onCopy: onCopy,
|
|
48
|
-
customTriggerComponent: customTriggerComponent
|
|
49
|
-
}, children);
|
|
29
|
+
return /* @__PURE__ */ jsx(SingleCode, { fontSize, tooltipTitleHover, tooltipTitleClick, className, onCopy, customTriggerComponent, children });
|
|
50
30
|
case CodeSnippetType.MULTI_LINE:
|
|
51
|
-
return
|
|
52
|
-
languages: languages,
|
|
53
|
-
colorSyntax: colorSyntax,
|
|
54
|
-
fontSize: fontSize,
|
|
55
|
-
tooltipTitleHover: tooltipTitleHover,
|
|
56
|
-
tooltipTitleClick: tooltipTitleClick,
|
|
57
|
-
labelBeforeExpanded: labelBeforeExpanded,
|
|
58
|
-
labelAfterExpanded: labelAfterExpanded,
|
|
59
|
-
expanded: expanded,
|
|
60
|
-
className: className,
|
|
61
|
-
wrap: wrap,
|
|
62
|
-
rows: rows,
|
|
63
|
-
onExpand: onExpand,
|
|
64
|
-
onCopy: onCopy,
|
|
65
|
-
customTriggerComponent: customTriggerComponent,
|
|
66
|
-
hideExpandButton: hideExpandButton,
|
|
67
|
-
hideCopyButton: hideCopyButton
|
|
68
|
-
}, children);
|
|
31
|
+
return /* @__PURE__ */ jsx(MultiCode, { languages, colorSyntax, fontSize, tooltipTitleHover, tooltipTitleClick, labelBeforeExpanded, labelAfterExpanded, expanded, className, wrap, rows, onExpand, onCopy, customTriggerComponent, hideExpandButton, hideCopyButton, children });
|
|
69
32
|
default:
|
|
70
|
-
return
|
|
71
|
-
className: className
|
|
72
|
-
}, children);
|
|
33
|
+
return /* @__PURE__ */ jsx(InlineCode, { className, children });
|
|
73
34
|
}
|
|
74
35
|
};
|
|
75
|
-
export
|
|
36
|
+
export {
|
|
37
|
+
CodeSnippet as default
|
|
38
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LanguageHighlight } from './Highlight/Highlight.types';
|
|
3
3
|
export declare enum FontSize {
|
|
4
4
|
SMALL = 12,
|
|
5
5
|
MEDIUM = 14
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
-
}({});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
-
}({});
|
|
1
|
+
var FontSize = /* @__PURE__ */ ((FontSize2) => {
|
|
2
|
+
FontSize2[FontSize2["SMALL"] = 12] = "SMALL";
|
|
3
|
+
FontSize2[FontSize2["MEDIUM"] = 14] = "MEDIUM";
|
|
4
|
+
return FontSize2;
|
|
5
|
+
})(FontSize || {});
|
|
6
|
+
var CodeSnippetType = /* @__PURE__ */ ((CodeSnippetType2) => {
|
|
7
|
+
CodeSnippetType2["INLINE"] = "inline";
|
|
8
|
+
CodeSnippetType2["SINGLE_LINE"] = "single-line";
|
|
9
|
+
CodeSnippetType2["MULTI_LINE"] = "multi-line";
|
|
10
|
+
return CodeSnippetType2;
|
|
11
|
+
})(CodeSnippetType || {});
|
|
12
|
+
export {
|
|
13
|
+
CodeSnippetType,
|
|
14
|
+
FontSize
|
|
15
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { InlineCodeWrapper } from "./InlineCode.styles.js";
|
|
3
|
+
const InlineCode = ({
|
|
4
|
+
children = "",
|
|
5
|
+
className
|
|
6
|
+
}) => {
|
|
7
|
+
return /* @__PURE__ */ jsx(InlineCodeWrapper, { className, children });
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
InlineCode as default
|
|
10
11
|
};
|
|
11
|
-
export default InlineCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const InlineCodeWrapper: import(
|
|
1
|
+
export declare const InlineCodeWrapper: import('styled-components').StyledComponent<"code", any, {}, never>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const InlineCodeWrapper = /* @__PURE__ */ styled.code.withConfig({
|
|
3
3
|
displayName: "InlineCodestyles__InlineCodeWrapper",
|
|
4
4
|
componentId: "sc-2t3lx8-0"
|
|
5
|
-
})(["&{font-size:12px;font-family:'IBM Plex Mono Regular',monospace;display:inline-block;padding:0 4px;margin-right:4px;border-radius:3px;color:#e31a5d;background-color:", ";}"],
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
})(["&{font-size:12px;font-family:'IBM Plex Mono Regular',monospace;display:inline-block;padding:0 4px;margin-right:4px;border-radius:3px;color:#e31a5d;background-color:", ";}"], (props) => props.theme.palette[`pink-100`]);
|
|
6
|
+
export {
|
|
7
|
+
InlineCodeWrapper
|
|
8
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CodeSnippetProps } from '../../CodeSnippet.types';
|
|
3
3
|
declare const MultiCode: React.FC<CodeSnippetProps>;
|
|
4
4
|
export default MultiCode;
|
|
@@ -1,139 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
import React from
|
|
3
|
-
import AnimateHeight from
|
|
4
|
-
import Icon, {
|
|
5
|
-
import Scrollbar from
|
|
6
|
-
import Highlight from
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
expandedState
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setScrollable = _React$useState2[1];
|
|
41
|
-
var _React$useState3 = React.useState(1),
|
|
42
|
-
allRows = _React$useState3[0],
|
|
43
|
-
setAllRows = _React$useState3[1];
|
|
44
|
-
var codeRef = React.useRef(null);
|
|
45
|
-
var buttonProps = React.useMemo(function () {
|
|
46
|
-
return {
|
|
47
|
-
type: 'ghost',
|
|
48
|
-
mode: 'icon-label',
|
|
49
|
-
className: 'btn-expander',
|
|
50
|
-
expanded: expandedState
|
|
51
|
-
};
|
|
52
|
-
}, [expandedState]);
|
|
53
|
-
var initialContentHeight = React.useMemo(function () {
|
|
54
|
-
var numberRows = allRows > rows ? rows : allRows;
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import AnimateHeight from "react-animate-height";
|
|
4
|
+
import Icon, { DuplicateS, ArrowDownCircleM } from "@synerise/ds-icon";
|
|
5
|
+
import Scrollbar from "@synerise/ds-scrollbar";
|
|
6
|
+
import Highlight from "../../Highlight/Highlight.js";
|
|
7
|
+
import { LINE_HEIGHT_DEFAULT, ICON_CLASSNAME } from "../SingleCode/SingleCode.styles.js";
|
|
8
|
+
import { PreBlock, BlockCodeWrapperMulti, MultiIconCopy, CodeSnippetWrapperMulti, ContentIconWrapper, ExpanderButton } from "./MultiCode.styles.js";
|
|
9
|
+
const ANIMATE_HEIGHT_TIME = 300;
|
|
10
|
+
const MultiCode = ({
|
|
11
|
+
languages = ["javascript", "typescript", "json"],
|
|
12
|
+
children = "",
|
|
13
|
+
className,
|
|
14
|
+
colorSyntax = false,
|
|
15
|
+
tooltipTitleHover,
|
|
16
|
+
tooltipTitleClick,
|
|
17
|
+
labelBeforeExpanded,
|
|
18
|
+
labelAfterExpanded,
|
|
19
|
+
wrap = false,
|
|
20
|
+
rows = 6,
|
|
21
|
+
onExpand,
|
|
22
|
+
onCopy,
|
|
23
|
+
customTriggerComponent,
|
|
24
|
+
hideExpandButton = false,
|
|
25
|
+
hideCopyButton = false,
|
|
26
|
+
expanded = false
|
|
27
|
+
}) => {
|
|
28
|
+
const [expandedState, setExpandedState] = React.useState(expanded);
|
|
29
|
+
const [scrollable, setScrollable] = React.useState(false);
|
|
30
|
+
const [allRows, setAllRows] = React.useState(1);
|
|
31
|
+
const codeRef = React.useRef(null);
|
|
32
|
+
const buttonProps = React.useMemo(() => ({
|
|
33
|
+
type: "ghost",
|
|
34
|
+
mode: "icon-label",
|
|
35
|
+
className: "btn-expander",
|
|
36
|
+
expanded: expandedState
|
|
37
|
+
}), [expandedState]);
|
|
38
|
+
const initialContentHeight = React.useMemo(() => {
|
|
39
|
+
const numberRows = allRows > rows ? rows : allRows;
|
|
55
40
|
return (numberRows + 1) * LINE_HEIGHT_DEFAULT;
|
|
56
41
|
}, [rows, allRows]);
|
|
57
|
-
|
|
58
|
-
if (!!codeRef && !!
|
|
42
|
+
const onMounting = React.useCallback(() => {
|
|
43
|
+
if (!!codeRef && !!codeRef?.current) {
|
|
59
44
|
setAllRows(Math.round(codeRef.current.offsetHeight / LINE_HEIGHT_DEFAULT));
|
|
60
45
|
}
|
|
61
46
|
}, [codeRef]);
|
|
62
|
-
React.useLayoutEffect(
|
|
47
|
+
React.useLayoutEffect(() => {
|
|
63
48
|
onMounting();
|
|
64
49
|
}, [onMounting, children, rows, wrap]);
|
|
65
|
-
|
|
66
|
-
setExpandedState(
|
|
67
|
-
return !prevState;
|
|
68
|
-
});
|
|
50
|
+
const handleButton = React.useCallback((isScroll) => {
|
|
51
|
+
setExpandedState((prevState) => !prevState);
|
|
69
52
|
if (isScroll) {
|
|
70
|
-
setTimeout(
|
|
71
|
-
return setScrollable(function (prevState) {
|
|
72
|
-
return !prevState;
|
|
73
|
-
});
|
|
74
|
-
}, ANIMATE_HEIGHT_TIME);
|
|
53
|
+
setTimeout(() => setScrollable((prevState) => !prevState), ANIMATE_HEIGHT_TIME);
|
|
75
54
|
} else {
|
|
76
|
-
setScrollable(
|
|
77
|
-
return !prevState;
|
|
78
|
-
});
|
|
55
|
+
setScrollable((prevState) => !prevState);
|
|
79
56
|
}
|
|
80
57
|
onExpand && onExpand();
|
|
81
58
|
}, [onExpand]);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
ref: codeRef,
|
|
107
|
-
isButtonVisible: isButtonVisible
|
|
108
|
-
}, children))));
|
|
109
|
-
}, [wrap, rows, expandedState, isButtonVisible, scrollable, codeRef, extraHeightOption, children]);
|
|
110
|
-
var iconElement = React.useMemo(function () {
|
|
111
|
-
return !hideCopyButton && /*#__PURE__*/React.createElement(S.MultiIconCopy, {
|
|
112
|
-
copyValue: children,
|
|
113
|
-
texts: {
|
|
114
|
-
copyTooltip: tooltipTitleHover,
|
|
115
|
-
copiedTooltip: tooltipTitleClick
|
|
116
|
-
},
|
|
117
|
-
onCopy: onCopy,
|
|
118
|
-
className: ICON_CLASSNAME,
|
|
119
|
-
icon: customTriggerComponent || /*#__PURE__*/React.createElement(Icon, {
|
|
120
|
-
component: /*#__PURE__*/React.createElement(DuplicateS, null),
|
|
121
|
-
size: 24
|
|
122
|
-
})
|
|
123
|
-
});
|
|
124
|
-
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent, hideCopyButton]);
|
|
125
|
-
return /*#__PURE__*/React.createElement(S.CodeSnippetWrapperMulti, {
|
|
126
|
-
expanded: expandedState,
|
|
127
|
-
isButtonVisible: isButtonVisible,
|
|
128
|
-
className: className
|
|
129
|
-
}, /*#__PURE__*/React.createElement(S.ContentIconWrapper, null, colorSyntax && languages ? /*#__PURE__*/React.createElement(Highlight, {
|
|
130
|
-
languages: languages
|
|
131
|
-
}, multilineStructureContent) : multilineStructureContent, iconElement), !hideExpandButton && rows && isButtonVisible && /*#__PURE__*/React.createElement(S.ExpanderButton, _extends({}, buttonProps, {
|
|
132
|
-
onClick: function onClick() {
|
|
133
|
-
return handleButton(expandedState);
|
|
134
|
-
}
|
|
135
|
-
}), /*#__PURE__*/React.createElement(Icon, {
|
|
136
|
-
component: /*#__PURE__*/React.createElement(ArrowDownCircleM, null)
|
|
137
|
-
}), expandedState ? labelAfterExpanded : labelBeforeExpanded));
|
|
59
|
+
const isButtonVisible = React.useMemo(() => allRows > rows + 1, [rows, allRows]);
|
|
60
|
+
const extraHeightOption = React.useMemo(() => isButtonVisible ? initialContentHeight : "auto", [isButtonVisible, initialContentHeight]);
|
|
61
|
+
const multilineStructureContent = React.useMemo(() => /* @__PURE__ */ jsx(PreBlock, { wrap, expanded: expandedState, isButtonVisible, children: /* @__PURE__ */ jsx(AnimateHeight, { className: "content-animation", duration: ANIMATE_HEIGHT_TIME, height: !expandedState ? extraHeightOption : "auto", style: {
|
|
62
|
+
minHeight: LINE_HEIGHT_DEFAULT
|
|
63
|
+
}, children: /* @__PURE__ */ jsx(Scrollbar, { maxHeight: !scrollable ? (rows + 1) * LINE_HEIGHT_DEFAULT : "100%", style: {
|
|
64
|
+
marginRight: "17px"
|
|
65
|
+
}, children: /* @__PURE__ */ jsx(BlockCodeWrapperMulti, { ref: codeRef, isButtonVisible, children }) }) }) }), [wrap, rows, expandedState, isButtonVisible, scrollable, codeRef, extraHeightOption, children]);
|
|
66
|
+
const iconElement = React.useMemo(() => !hideCopyButton && /* @__PURE__ */ jsx(MultiIconCopy, { copyValue: children, texts: {
|
|
67
|
+
copyTooltip: tooltipTitleHover,
|
|
68
|
+
copiedTooltip: tooltipTitleClick
|
|
69
|
+
}, onCopy, className: ICON_CLASSNAME, icon: customTriggerComponent || /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(DuplicateS, {}), size: 24 }) }), [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent, hideCopyButton]);
|
|
70
|
+
return /* @__PURE__ */ jsxs(CodeSnippetWrapperMulti, { expanded: expandedState, isButtonVisible, className, children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(ContentIconWrapper, { children: [
|
|
72
|
+
colorSyntax && languages ? /* @__PURE__ */ jsx(Highlight, { languages, children: multilineStructureContent }) : multilineStructureContent,
|
|
73
|
+
iconElement
|
|
74
|
+
] }),
|
|
75
|
+
!hideExpandButton && rows && isButtonVisible && /* @__PURE__ */ jsxs(ExpanderButton, { ...buttonProps, onClick: () => handleButton(expandedState), children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(ArrowDownCircleM, {}) }),
|
|
77
|
+
expandedState ? labelAfterExpanded : labelBeforeExpanded
|
|
78
|
+
] })
|
|
79
|
+
] });
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
MultiCode as default
|
|
138
83
|
};
|
|
139
|
-
export default MultiCode;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const ContentIconWrapper: import(
|
|
3
|
-
export declare const CodeSnippetWrapperMulti: import(
|
|
4
|
-
fontSize?: import(
|
|
1
|
+
import { StyledButton } from '@synerise/ds-button';
|
|
2
|
+
export declare const ContentIconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const CodeSnippetWrapperMulti: import('styled-components').StyledComponent<"div", any, {
|
|
4
|
+
fontSize?: import('../../CodeSnippet.types').FontSize;
|
|
5
5
|
} & {
|
|
6
6
|
expanded?: boolean;
|
|
7
7
|
isButtonVisible?: boolean;
|
|
8
8
|
}, never>;
|
|
9
|
-
export declare const MultiIconCopy: import(
|
|
9
|
+
export declare const MultiIconCopy: import('styled-components').StyledComponent<({ copyValue, texts, onMouseEnter, onMouseLeave, icon, placement, onCopy, onClick, ...rest }: import('@synerise/ds-copy-icon').CopyIconProps) => React.JSX.Element, any, {}, never>;
|
|
10
10
|
export declare const ExpanderButton: StyledButton;
|
|
11
|
-
export declare const BlockCodeWrapperMulti: import(
|
|
12
|
-
fontSize?: import(
|
|
11
|
+
export declare const BlockCodeWrapperMulti: import('styled-components').StyledComponent<"code", any, {
|
|
12
|
+
fontSize?: import('../../CodeSnippet.types').FontSize;
|
|
13
13
|
} & {
|
|
14
14
|
isButtonVisible?: boolean;
|
|
15
15
|
}, never>;
|
|
16
|
-
export declare const PreBlock: import(
|
|
16
|
+
export declare const PreBlock: import('styled-components').StyledComponent<"pre", any, {
|
|
17
17
|
wrap?: boolean;
|
|
18
18
|
expanded?: boolean;
|
|
19
19
|
isButtonVisible?: boolean;
|
|
@@ -1,40 +1,49 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
import Button from
|
|
3
|
-
import { IconContainer } from
|
|
4
|
-
import { BlockCodeWrapperSingle, CodeSnippetWrapperSingle,
|
|
5
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import { IconContainer } from "@synerise/ds-icon";
|
|
4
|
+
import { BlockCodeWrapperSingle, CodeSnippetWrapperSingle, LINE_HEIGHT_DEFAULT, StyledCopyIcon, FONT_SIZE_DEFAULT } from "../SingleCode/SingleCode.styles.js";
|
|
5
|
+
const ContentIconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
6
6
|
displayName: "MultiCodestyles__ContentIconWrapper",
|
|
7
7
|
componentId: "sc-1u5vxm9-0"
|
|
8
8
|
})(["position:relative;"]);
|
|
9
|
-
|
|
9
|
+
const CodeSnippetWrapperMulti = /* @__PURE__ */ styled(CodeSnippetWrapperSingle).withConfig({
|
|
10
10
|
displayName: "MultiCodestyles__CodeSnippetWrapperMulti",
|
|
11
11
|
componentId: "sc-1u5vxm9-1"
|
|
12
|
-
})(["&{min-width:250px;pre::before{background-color:", ";content:'';display:block;position:absolute;top:0;bottom:0;right:0;width:28px;z-index:10;}.content-animation{position:relative;}", ";}"],
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
})(["&{min-width:250px;pre::before{background-color:", ";content:'';display:block;position:absolute;top:0;bottom:0;right:0;width:28px;z-index:10;}.content-animation{position:relative;}", ";}"], (props) => props.theme.palette["grey-100"], (props) => !!props.isButtonVisible && `
|
|
13
|
+
padding-bottom:7px;
|
|
14
|
+
.content-animation::after{
|
|
15
|
+
content:'';
|
|
16
|
+
display:block;
|
|
17
|
+
position:absolute;
|
|
18
|
+
bottom:0;
|
|
19
|
+
left:0;
|
|
20
|
+
right:0;
|
|
21
|
+
height:${LINE_HEIGHT_DEFAULT}px;
|
|
22
|
+
background-color:${props.theme.palette["grey-100"]};
|
|
23
|
+
z-index:10;
|
|
24
|
+
}
|
|
25
|
+
`);
|
|
26
|
+
const MultiIconCopy = /* @__PURE__ */ styled(StyledCopyIcon).withConfig({
|
|
18
27
|
displayName: "MultiCodestyles__MultiIconCopy",
|
|
19
28
|
componentId: "sc-1u5vxm9-2"
|
|
20
29
|
})(["&&{position:absolute;top:0;right:0;z-index:13;}"]);
|
|
21
|
-
|
|
30
|
+
const ExpanderButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
22
31
|
displayName: "MultiCodestyles__ExpanderButton",
|
|
23
32
|
componentId: "sc-1u5vxm9-3"
|
|
24
|
-
})(["&&{position:relative;z-index:15;top:-5px;", "{svg{transition:transform 0.2s linear;transform:rotate( ", " );}}}"], IconContainer,
|
|
25
|
-
|
|
26
|
-
});
|
|
27
|
-
export var BlockCodeWrapperMulti = styled(BlockCodeWrapperSingle).withConfig({
|
|
33
|
+
})(["&&{position:relative;z-index:15;top:-5px;", "{svg{transition:transform 0.2s linear;transform:rotate( ", " );}}}"], IconContainer, (props) => props.expanded ? "180deg" : "0deg");
|
|
34
|
+
const BlockCodeWrapperMulti = /* @__PURE__ */ styled(BlockCodeWrapperSingle).withConfig({
|
|
28
35
|
displayName: "MultiCodestyles__BlockCodeWrapperMulti",
|
|
29
36
|
componentId: "sc-1u5vxm9-4"
|
|
30
|
-
})(["&{padding-bottom:", ";}"],
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
export var PreBlock = styled.pre.withConfig({
|
|
37
|
+
})(["&{padding-bottom:", ";}"], (props) => props.isButtonVisible ? "17px" : "12px");
|
|
38
|
+
const PreBlock = /* @__PURE__ */ styled.pre.withConfig({
|
|
34
39
|
displayName: "MultiCodestyles__PreBlock",
|
|
35
40
|
componentId: "sc-1u5vxm9-5"
|
|
36
|
-
})(["&{font-family:'IBM Plex Mono Regular',monospace;font-size:", "px;line-height:", "px;margin:0;", ";.ps__rail-x{height:", "px;z-index:11;opacity:0;}.ps__rail-x > .ps__thumb-x{bottom:", ";}.ps__rail-y{opacity:0;z-index:11;}}"], FONT_SIZE_DEFAULT, LINE_HEIGHT_DEFAULT,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
})(["&{font-family:'IBM Plex Mono Regular',monospace;font-size:", "px;line-height:", "px;margin:0;", ";.ps__rail-x{height:", "px;z-index:11;opacity:0;}.ps__rail-x > .ps__thumb-x{bottom:", ";}.ps__rail-y{opacity:0;z-index:11;}}"], FONT_SIZE_DEFAULT, LINE_HEIGHT_DEFAULT, (props) => !!props.wrap && css(["white-space:pre-wrap;word-wrap:break-world;"]), LINE_HEIGHT_DEFAULT, (props) => props.isButtonVisible ? "10px" : "6px");
|
|
42
|
+
export {
|
|
43
|
+
BlockCodeWrapperMulti,
|
|
44
|
+
CodeSnippetWrapperMulti,
|
|
45
|
+
ContentIconWrapper,
|
|
46
|
+
ExpanderButton,
|
|
47
|
+
MultiIconCopy,
|
|
48
|
+
PreBlock
|
|
49
|
+
};
|
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
className: S.ICON_CLASSNAME,
|
|
28
|
-
"data-testid": "ds-copy-code-snippet"
|
|
29
|
-
});
|
|
30
|
-
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent]);
|
|
31
|
-
return /*#__PURE__*/React.createElement(S.CodeSnippetWrapperSingle, {
|
|
32
|
-
fontSize: fontSize,
|
|
33
|
-
className: className
|
|
34
|
-
}, /*#__PURE__*/React.createElement(S.ContentIconWrapper, null, /*#__PURE__*/React.createElement(S.BlockCodeWrapperSingle, {
|
|
35
|
-
fontSize: fontSize
|
|
36
|
-
}, children), iconElement));
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import Icon, { DuplicateS } from "@synerise/ds-icon";
|
|
4
|
+
import { FontSize } from "../../CodeSnippet.types.js";
|
|
5
|
+
import { StyledCopyIcon, ICON_CLASSNAME, CodeSnippetWrapperSingle, ContentIconWrapper, BlockCodeWrapperSingle } from "./SingleCode.styles.js";
|
|
6
|
+
const SingleCode = ({
|
|
7
|
+
children = "",
|
|
8
|
+
fontSize = FontSize.SMALL,
|
|
9
|
+
tooltipTitleHover,
|
|
10
|
+
tooltipTitleClick,
|
|
11
|
+
className,
|
|
12
|
+
onCopy,
|
|
13
|
+
customTriggerComponent
|
|
14
|
+
}) => {
|
|
15
|
+
const iconElement = React.useMemo(() => /* @__PURE__ */ jsx(StyledCopyIcon, { copyValue: children, texts: {
|
|
16
|
+
copyTooltip: tooltipTitleHover,
|
|
17
|
+
copiedTooltip: tooltipTitleClick
|
|
18
|
+
}, onCopy, icon: customTriggerComponent || /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(DuplicateS, {}), size: 24 }), className: ICON_CLASSNAME, "data-testid": "ds-copy-code-snippet" }), [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent]);
|
|
19
|
+
return /* @__PURE__ */ jsx(CodeSnippetWrapperSingle, { fontSize, className, children: /* @__PURE__ */ jsxs(ContentIconWrapper, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx(BlockCodeWrapperSingle, { fontSize, children }),
|
|
21
|
+
iconElement
|
|
22
|
+
] }) });
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
SingleCode as default
|
|
37
26
|
};
|
|
38
|
-
export default SingleCode;
|
|
@@ -2,11 +2,11 @@ import { FontSize } from '../../CodeSnippet.types';
|
|
|
2
2
|
export declare const FONT_SIZE_DEFAULT = FontSize.SMALL;
|
|
3
3
|
export declare const LINE_HEIGHT_DEFAULT = 17;
|
|
4
4
|
export declare const ICON_CLASSNAME = "copy";
|
|
5
|
-
export declare const ContentIconWrapper: import(
|
|
6
|
-
export declare const StyledCopyIcon: import(
|
|
7
|
-
export declare const CodeSnippetWrapperSingle: import(
|
|
5
|
+
export declare const ContentIconWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledCopyIcon: import('styled-components').StyledComponent<({ copyValue, texts, onMouseEnter, onMouseLeave, icon, placement, onCopy, onClick, ...rest }: import('@synerise/ds-copy-icon').CopyIconProps) => React.JSX.Element, any, {}, never>;
|
|
7
|
+
export declare const CodeSnippetWrapperSingle: import('styled-components').StyledComponent<"div", any, {
|
|
8
8
|
fontSize?: FontSize;
|
|
9
9
|
}, never>;
|
|
10
|
-
export declare const BlockCodeWrapperSingle: import(
|
|
10
|
+
export declare const BlockCodeWrapperSingle: import('styled-components').StyledComponent<"code", any, {
|
|
11
11
|
fontSize?: FontSize;
|
|
12
12
|
}, never>;
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import CopyIcon from
|
|
3
|
-
import { FontSize } from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import CopyIcon from "@synerise/ds-copy-icon";
|
|
3
|
+
import { FontSize } from "../../CodeSnippet.types.js";
|
|
4
|
+
const FONT_SIZE_DEFAULT = FontSize.SMALL;
|
|
5
|
+
const LINE_HEIGHT_DEFAULT = 17;
|
|
6
|
+
const ICON_CLASSNAME = "copy";
|
|
7
|
+
const ContentIconWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
8
8
|
displayName: "SingleCodestyles__ContentIconWrapper",
|
|
9
9
|
componentId: "sc-1l78lb-0"
|
|
10
10
|
})(["display:flex;justify-content:space-between;align-items:center;"]);
|
|
11
|
-
|
|
11
|
+
const StyledCopyIcon = /* @__PURE__ */ styled(CopyIcon).withConfig({
|
|
12
12
|
displayName: "SingleCodestyles__StyledCopyIcon",
|
|
13
13
|
componentId: "sc-1l78lb-1"
|
|
14
|
-
})(["&&{cursor:pointer;background-color:", ";color:", ";}&:hover{color:", ";}"],
|
|
15
|
-
|
|
16
|
-
}, function (props) {
|
|
17
|
-
return props.theme.palette['grey-400'];
|
|
18
|
-
}, function (props) {
|
|
19
|
-
return props.theme.palette['blue-600'];
|
|
20
|
-
});
|
|
21
|
-
export var CodeSnippetWrapperSingle = styled.div.withConfig({
|
|
14
|
+
})(["&&{cursor:pointer;background-color:", ";color:", ";}&:hover{color:", ";}"], (props) => props.theme.palette["grey-100"], (props) => props.theme.palette["grey-400"], (props) => props.theme.palette["blue-600"]);
|
|
15
|
+
const CodeSnippetWrapperSingle = /* @__PURE__ */ styled.div.withConfig({
|
|
22
16
|
displayName: "SingleCodestyles__CodeSnippetWrapperSingle",
|
|
23
17
|
componentId: "sc-1l78lb-2"
|
|
24
|
-
})(["&{height:100%;background-color:", ";border-radius:3px;padding:12px 8px 0 12px;.content-animation{position:relative;}", ";}"],
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export var BlockCodeWrapperSingle = styled.code.withConfig({
|
|
18
|
+
})(["&{height:100%;background-color:", ";border-radius:3px;padding:12px 8px 0 12px;.content-animation{position:relative;}", ";}"], (props) => props.theme.palette["grey-100"], (props) => !!props.fontSize && `
|
|
19
|
+
padding-top: ${props.fontSize === FontSize.SMALL ? "4px" : "12px"};
|
|
20
|
+
padding-bottom: ${props.fontSize === FontSize.SMALL ? "4px" : "12px"};
|
|
21
|
+
`);
|
|
22
|
+
const BlockCodeWrapperSingle = /* @__PURE__ */ styled.code.withConfig({
|
|
30
23
|
displayName: "SingleCodestyles__BlockCodeWrapperSingle",
|
|
31
24
|
componentId: "sc-1l78lb-3"
|
|
32
|
-
})(["&{display:block;font-family:'IBM Plex Mono Regular',monospace;font-size:", ";line-height:", "px;color:", ";", ";}"],
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
})(["&{display:block;font-family:'IBM Plex Mono Regular',monospace;font-size:", ";line-height:", "px;color:", ";", ";}"], (props) => `${props.fontSize || FONT_SIZE_DEFAULT}px`, LINE_HEIGHT_DEFAULT, (props) => props.theme.palette[`grey-600`], (props) => !!props.fontSize && `
|
|
26
|
+
padding-right: 4px;
|
|
27
|
+
line-height:24px;
|
|
28
|
+
`);
|
|
29
|
+
export {
|
|
30
|
+
BlockCodeWrapperSingle,
|
|
31
|
+
CodeSnippetWrapperSingle,
|
|
32
|
+
ContentIconWrapper,
|
|
33
|
+
FONT_SIZE_DEFAULT,
|
|
34
|
+
ICON_CLASSNAME,
|
|
35
|
+
LINE_HEIGHT_DEFAULT,
|
|
36
|
+
StyledCopyIcon
|
|
37
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { HighlightProps } from './Highlight.types';
|
|
3
3
|
declare const Highlight: ({ languages, style, children }: HighlightProps) => React.JSX.Element;
|
|
4
4
|
export default Highlight;
|
|
@@ -1,60 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
import { __vitePreload } from "../_virtual/preload-helper.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import hljs from "highlight.js/lib/core";
|
|
4
|
+
import css from "highlight.js/lib/languages/css";
|
|
5
|
+
import javascript from "highlight.js/lib/languages/javascript";
|
|
6
|
+
import json from "highlight.js/lib/languages/json";
|
|
7
|
+
import typescript from "highlight.js/lib/languages/typescript";
|
|
8
|
+
import xml from "highlight.js/lib/languages/xml";
|
|
9
|
+
import { useRef, useCallback, useEffect } from "react";
|
|
10
|
+
import { Highlight as Highlight$1 } from "./Highlight.styles.js";
|
|
11
|
+
const BUNDLED_LANGUAGES = {
|
|
12
|
+
css,
|
|
13
|
+
html: xml,
|
|
14
|
+
xml,
|
|
15
|
+
javascript,
|
|
16
|
+
json,
|
|
17
|
+
typescript
|
|
18
|
+
};
|
|
19
|
+
const registeredLanguages = /* @__PURE__ */ new Set();
|
|
20
|
+
function registerLanguages(languages) {
|
|
21
|
+
for (const language of languages) {
|
|
22
|
+
if (registeredLanguages.has(language)) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const definition = BUNDLED_LANGUAGES[language];
|
|
26
|
+
if (definition) {
|
|
27
|
+
hljs.registerLanguage(language, definition);
|
|
28
|
+
registeredLanguages.add(language);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const Highlight = ({
|
|
33
|
+
languages,
|
|
34
|
+
style,
|
|
35
|
+
children
|
|
36
|
+
}) => {
|
|
37
|
+
const elementRef = useRef(null);
|
|
38
|
+
const manageHighlight = useCallback(async () => {
|
|
39
|
+
if (elementRef.current) {
|
|
40
|
+
const elements = elementRef.current.querySelectorAll("pre code");
|
|
41
|
+
registerLanguages(languages);
|
|
42
|
+
const unbundled = languages.filter((lang) => !registeredLanguages.has(lang));
|
|
43
|
+
await Promise.all(unbundled.map(async (language) => {
|
|
44
|
+
try {
|
|
45
|
+
const module = await __vitePreload(() => import(
|
|
46
|
+
/* @vite-ignore */
|
|
47
|
+
`highlight.js/lib/languages/${language}`
|
|
48
|
+
), true ? [] : void 0);
|
|
49
|
+
hljs.registerLanguage(language, module.default);
|
|
50
|
+
registeredLanguages.add(language);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}));
|
|
54
|
+
elements.forEach((element) => {
|
|
55
|
+
hljs.highlightElement(element);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, [languages]);
|
|
59
|
+
useEffect(() => {
|
|
53
60
|
manageHighlight();
|
|
54
61
|
}, [manageHighlight]);
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
return /* @__PURE__ */ jsx(Highlight$1, { ref: elementRef, style, children });
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
Highlight as default
|
|
59
66
|
};
|
|
60
|
-
export default Highlight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const Highlight: import(
|
|
1
|
+
export declare const Highlight: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,29 +1,8 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const Highlight = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "Highlightstyles__Highlight",
|
|
4
4
|
componentId: "sc-5c5o8n-0"
|
|
5
|
-
})([".hljs{color:", ";}.hljs-attr,.hljs-template-tag{color:", ";}.hljs-comment,.hljs-doctag,.hljs-quote{color:", ";}.hljs-params{color:", ";}.hljs-regexp{color:", ";}.hljs-tag,.hljs-selector-id,.hljs-number,.hljs-literal{color:", ";}.hljs-meta,.hljs-meta .hljs-keyword{color:", ";}.hljs-operator,.hljs-punctuation{}.hljs-selector-class,.hljs-code,.hljs-formula,.hljs-variable,.hljs-template-variable,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-link,.hljs-keyword{color:", ";}.hljs-built_in,.hljs-title,.hljs-deletion{color:", ";}.hljs-type,.hljs-section,.hljs-function,.hljs-name,.hljs-property,.hljs-attribute{color:", ";}.hljs-meta .hljs-string,.hljs-string,.hljs-subst,.hljs-symbol,.hljs-bullet,.hljs-addition{color:", ";}.hljs-selector-tag{color:", ";}.hljs-emphasis{font-style:italic;}.hljs-strong{font-weight:bold;}"],
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, function (props) {
|
|
10
|
-
return props.theme.palette['cyan-600'];
|
|
11
|
-
}, function (props) {
|
|
12
|
-
return props.theme.palette['grey-600'];
|
|
13
|
-
}, function (props) {
|
|
14
|
-
return props.theme.palette['violet-600'];
|
|
15
|
-
}, function (props) {
|
|
16
|
-
return props.theme.palette['red-600'];
|
|
17
|
-
}, function (props) {
|
|
18
|
-
return props.theme.palette['blue-600'];
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return props.theme.palette['blue-600'];
|
|
21
|
-
}, function (props) {
|
|
22
|
-
return props.theme.palette['orange-600'];
|
|
23
|
-
}, function (props) {
|
|
24
|
-
return props.theme.palette['yellow-600'];
|
|
25
|
-
}, function (props) {
|
|
26
|
-
return props.theme.palette['green-600'];
|
|
27
|
-
}, function (props) {
|
|
28
|
-
return props.theme.palette['purple-600'];
|
|
29
|
-
});
|
|
5
|
+
})([".hljs{color:", ";}.hljs-attr,.hljs-template-tag{color:", ";}.hljs-comment,.hljs-doctag,.hljs-quote{color:", ";}.hljs-params{color:", ";}.hljs-regexp{color:", ";}.hljs-tag,.hljs-selector-id,.hljs-number,.hljs-literal{color:", ";}.hljs-meta,.hljs-meta .hljs-keyword{color:", ";}.hljs-operator,.hljs-punctuation{}.hljs-selector-class,.hljs-code,.hljs-formula,.hljs-variable,.hljs-template-variable,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-link,.hljs-keyword{color:", ";}.hljs-built_in,.hljs-title,.hljs-deletion{color:", ";}.hljs-type,.hljs-section,.hljs-function,.hljs-name,.hljs-property,.hljs-attribute{color:", ";}.hljs-meta .hljs-string,.hljs-string,.hljs-subst,.hljs-symbol,.hljs-bullet,.hljs-addition{color:", ";}.hljs-selector-tag{color:", ";}.hljs-emphasis{font-style:italic;}.hljs-strong{font-weight:bold;}"], (props) => props.theme.palette["grey-700"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["cyan-600"], (props) => props.theme.palette["grey-600"], (props) => props.theme.palette["violet-600"], (props) => props.theme.palette["red-600"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["blue-600"], (props) => props.theme.palette["orange-600"], (props) => props.theme.palette["yellow-600"], (props) => props.theme.palette["green-600"], (props) => props.theme.palette["purple-600"]);
|
|
6
|
+
export {
|
|
7
|
+
Highlight
|
|
8
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const scriptRel = "modulepreload";
|
|
2
|
+
const assetsURL = function(dep) {
|
|
3
|
+
return "/" + dep;
|
|
4
|
+
};
|
|
5
|
+
const seen = {};
|
|
6
|
+
const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
7
|
+
let promise = Promise.resolve();
|
|
8
|
+
if (deps && deps.length > 0) {
|
|
9
|
+
let allSettled = function(promises$2) {
|
|
10
|
+
return Promise.all(promises$2.map((p) => Promise.resolve(p).then((value$1) => ({
|
|
11
|
+
status: "fulfilled",
|
|
12
|
+
value: value$1
|
|
13
|
+
}), (reason) => ({
|
|
14
|
+
status: "rejected",
|
|
15
|
+
reason
|
|
16
|
+
}))));
|
|
17
|
+
};
|
|
18
|
+
document.getElementsByTagName("link");
|
|
19
|
+
const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
|
|
20
|
+
const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
|
|
21
|
+
promise = allSettled(deps.map((dep) => {
|
|
22
|
+
dep = assetsURL(dep);
|
|
23
|
+
if (dep in seen) return;
|
|
24
|
+
seen[dep] = true;
|
|
25
|
+
const isCss = dep.endsWith(".css");
|
|
26
|
+
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
|
|
27
|
+
if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) return;
|
|
28
|
+
const link = document.createElement("link");
|
|
29
|
+
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
30
|
+
if (!isCss) link.as = "script";
|
|
31
|
+
link.crossOrigin = "";
|
|
32
|
+
link.href = dep;
|
|
33
|
+
if (cspNonce) link.setAttribute("nonce", cspNonce);
|
|
34
|
+
document.head.appendChild(link);
|
|
35
|
+
if (isCss) return new Promise((res, rej) => {
|
|
36
|
+
link.addEventListener("load", res);
|
|
37
|
+
link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
|
|
38
|
+
});
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
function handlePreloadError(err$2) {
|
|
42
|
+
const e$1 = new Event("vite:preloadError", { cancelable: true });
|
|
43
|
+
e$1.payload = err$2;
|
|
44
|
+
window.dispatchEvent(e$1);
|
|
45
|
+
if (!e$1.defaultPrevented) throw err$2;
|
|
46
|
+
}
|
|
47
|
+
return promise.then((res) => {
|
|
48
|
+
for (const item of res || []) {
|
|
49
|
+
if (item.status !== "rejected") continue;
|
|
50
|
+
handlePreloadError(item.reason);
|
|
51
|
+
}
|
|
52
|
+
return baseModule().catch(handlePreloadError);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
__vitePreload
|
|
57
|
+
};
|
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { default as default2 } from "./CodeSnippet.js";
|
|
2
|
+
import { CodeSnippetType } from "./CodeSnippet.types.js";
|
|
3
|
+
export {
|
|
4
|
+
CodeSnippetType,
|
|
5
|
+
default2 as default
|
|
6
|
+
};
|
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-code-snippet",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.40",
|
|
4
4
|
"description": "CodeSnippet UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "
|
|
20
|
+
"build": "vite build",
|
|
21
21
|
"build:css": "node ../../../scripts/style/less.js",
|
|
22
22
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
23
|
-
"build:watch": "
|
|
23
|
+
"build:watch": "vite build --watch",
|
|
24
24
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
25
25
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
26
26
|
"prepublish": "pnpm run build",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
],
|
|
37
37
|
"types": "dist/index.d.ts",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@synerise/ds-button": "^1.5.
|
|
40
|
-
"@synerise/ds-copy-icon": "^1.2.
|
|
41
|
-
"@synerise/ds-icon": "^1.15.
|
|
42
|
-
"@synerise/ds-scrollbar": "^1.2.
|
|
43
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
44
|
-
"@synerise/ds-utils": "^1.7.
|
|
39
|
+
"@synerise/ds-button": "^1.5.19",
|
|
40
|
+
"@synerise/ds-copy-icon": "^1.2.3",
|
|
41
|
+
"@synerise/ds-icon": "^1.15.2",
|
|
42
|
+
"@synerise/ds-scrollbar": "^1.2.18",
|
|
43
|
+
"@synerise/ds-tooltip": "^1.4.11",
|
|
44
|
+
"@synerise/ds-utils": "^1.7.1",
|
|
45
45
|
"highlight.js": "^10.7.2",
|
|
46
46
|
"react-animate-height": "^2.0.23"
|
|
47
47
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"react": ">=16.9.0 <= 18.3.1",
|
|
55
55
|
"styled-components": "^5.3.3"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "c2384982c3533a31eb5e5e0408f8dcecb2b0f399"
|
|
58
58
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import figma from '@figma/code-connect';
|
|
2
|
-
import CodeSnippet from './CodeSnippet';
|
|
3
|
-
import { CodeSnippetType, FontSize } from './CodeSnippet.types';
|
|
4
|
-
var FIGMA_URL = 'https://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=725:13723&m=dev';
|
|
5
|
-
figma.connect(CodeSnippet, FIGMA_URL, {
|
|
6
|
-
variant: {
|
|
7
|
-
Size: 'Small'
|
|
8
|
-
},
|
|
9
|
-
example: function example() {
|
|
10
|
-
return /*#__PURE__*/React.createElement(CodeSnippet, {
|
|
11
|
-
type: CodeSnippetType.SINGLE_LINE,
|
|
12
|
-
fontSize: FontSize.SMALL
|
|
13
|
-
}, 'code here');
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
figma.connect(CodeSnippet, FIGMA_URL, {
|
|
17
|
-
variant: {
|
|
18
|
-
Size: 'Large'
|
|
19
|
-
},
|
|
20
|
-
example: function example() {
|
|
21
|
-
return /*#__PURE__*/React.createElement(CodeSnippet, {
|
|
22
|
-
type: CodeSnippetType.SINGLE_LINE,
|
|
23
|
-
fontSize: FontSize.MEDIUM
|
|
24
|
-
}, 'code here');
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
var FIGMA_URL_INLINE = 'https://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=725:13620&m=dev';
|
|
28
|
-
figma.connect(CodeSnippet, FIGMA_URL_INLINE, {
|
|
29
|
-
example: function example() {
|
|
30
|
-
return /*#__PURE__*/React.createElement(CodeSnippet, {
|
|
31
|
-
type: CodeSnippetType.INLINE
|
|
32
|
-
}, 'code here');
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
var FIGMA_URL_MULTI = 'https://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=725:13726&m=dev';
|
|
36
|
-
figma.connect(CodeSnippet, FIGMA_URL_MULTI, {
|
|
37
|
-
example: function example() {
|
|
38
|
-
return /*#__PURE__*/React.createElement(CodeSnippet, {
|
|
39
|
-
type: CodeSnippetType.MULTI_LINE,
|
|
40
|
-
colorSyntax: true
|
|
41
|
-
}, 'code here');
|
|
42
|
-
}
|
|
43
|
-
});
|