@synerise/ds-code-snippet 1.1.19 → 1.1.21
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 +5 -69
- package/dist/CodeTypes/MultiCode/MultiCode.js +11 -11
- package/dist/CodeTypes/MultiCode/MultiCode.styles.d.ts +3 -30
- package/dist/CodeTypes/MultiCode/MultiCode.styles.js +9 -5
- package/dist/CodeTypes/SingleCode/SingleCode.js +12 -12
- package/dist/CodeTypes/SingleCode/SingleCode.styles.d.ts +1 -0
- package/dist/CodeTypes/SingleCode/SingleCode.styles.js +13 -8
- package/dist/Highlight/Highlight.js +17 -20
- package/package.json +10 -9
- package/dist/CopyAction/CopyAction.d.ts +0 -4
- package/dist/CopyAction/CopyAction.js +0 -62
- package/dist/CopyAction/CopyAction.styles.d.ts +0 -3
- package/dist/CopyAction/CopyAction.styles.js +0 -7
- package/dist/CopyAction/CopyAction.types.d.ts +0 -11
- package/dist/CopyAction/CopyAction.types.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,150 +3,86 @@
|
|
|
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.
|
|
6
|
+
## [1.1.21](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.20...@synerise/ds-code-snippet@1.1.21) (2025-12-15)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
9
9
|
|
|
10
|
+
## [1.1.20](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.19...@synerise/ds-code-snippet@1.1.20) (2025-11-28)
|
|
10
11
|
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
11
13
|
|
|
14
|
+
## [1.1.19](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.18...@synerise/ds-code-snippet@1.1.19) (2025-11-06)
|
|
12
15
|
|
|
16
|
+
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
13
17
|
|
|
14
18
|
## [1.1.18](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.17...@synerise/ds-code-snippet@1.1.18) (2025-10-22)
|
|
15
19
|
|
|
16
20
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
22
|
## [1.1.17](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.16...@synerise/ds-code-snippet@1.1.17) (2025-10-16)
|
|
23
23
|
|
|
24
24
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
26
|
## [1.1.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.15...@synerise/ds-code-snippet@1.1.16) (2025-10-10)
|
|
31
27
|
|
|
32
28
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
30
|
## [1.1.15](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.14...@synerise/ds-code-snippet@1.1.15) (2025-10-08)
|
|
39
31
|
|
|
40
32
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
41
33
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
34
|
## [1.1.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.13...@synerise/ds-code-snippet@1.1.14) (2025-09-25)
|
|
47
35
|
|
|
48
36
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
49
37
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
38
|
## [1.1.13](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.12...@synerise/ds-code-snippet@1.1.13) (2025-09-19)
|
|
55
39
|
|
|
56
40
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
42
|
## [1.1.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.11...@synerise/ds-code-snippet@1.1.12) (2025-09-16)
|
|
63
43
|
|
|
64
44
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
65
45
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
46
|
## [1.1.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.10...@synerise/ds-code-snippet@1.1.11) (2025-08-28)
|
|
71
47
|
|
|
72
48
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
73
49
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
50
|
## [1.1.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.9...@synerise/ds-code-snippet@1.1.10) (2025-08-20)
|
|
79
51
|
|
|
80
52
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
54
|
## [1.1.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.8...@synerise/ds-code-snippet@1.1.9) (2025-08-14)
|
|
87
55
|
|
|
88
56
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
89
57
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
58
|
## [1.1.8](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.7...@synerise/ds-code-snippet@1.1.8) (2025-07-24)
|
|
95
59
|
|
|
96
60
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
97
61
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
62
|
## [1.1.7](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.6...@synerise/ds-code-snippet@1.1.7) (2025-07-17)
|
|
103
63
|
|
|
104
64
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
105
65
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
66
|
## [1.1.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.5...@synerise/ds-code-snippet@1.1.6) (2025-07-15)
|
|
111
67
|
|
|
112
68
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
113
69
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
70
|
## [1.1.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.4...@synerise/ds-code-snippet@1.1.5) (2025-07-08)
|
|
119
71
|
|
|
120
72
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
121
73
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
74
|
## [1.1.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.3...@synerise/ds-code-snippet@1.1.4) (2025-07-01)
|
|
127
75
|
|
|
128
76
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
129
77
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
78
|
## [1.1.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.2...@synerise/ds-code-snippet@1.1.3) (2025-06-26)
|
|
135
79
|
|
|
136
80
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
137
81
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
82
|
## [1.1.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.1...@synerise/ds-code-snippet@1.1.2) (2025-06-24)
|
|
143
83
|
|
|
144
84
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
145
85
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
86
|
## [1.1.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.1.0...@synerise/ds-code-snippet@1.1.1) (2025-06-05)
|
|
151
87
|
|
|
152
88
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import copy from 'copy-to-clipboard';
|
|
3
2
|
import React from 'react';
|
|
4
3
|
import AnimateHeight from 'react-animate-height';
|
|
5
4
|
import Icon, { ArrowDownCircleM, DuplicateS } from '@synerise/ds-icon';
|
|
6
5
|
import Scrollbar from '@synerise/ds-scrollbar';
|
|
7
|
-
import CopyAction from '../../CopyAction/CopyAction';
|
|
8
6
|
import Highlight from '../../Highlight/Highlight';
|
|
9
7
|
import { ICON_CLASSNAME, LINE_HEIGHT_DEFAULT } from '../SingleCode/SingleCode.styles';
|
|
10
8
|
import * as S from './MultiCode.styles';
|
|
@@ -110,16 +108,18 @@ var MultiCode = function MultiCode(_ref) {
|
|
|
110
108
|
}, children))));
|
|
111
109
|
}, [wrap, rows, expandedState, isButtonVisible, scrollable, codeRef, extraHeightOption, children]);
|
|
112
110
|
var iconElement = React.useMemo(function () {
|
|
113
|
-
return !hideCopyButton && /*#__PURE__*/React.createElement(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
copy(children);
|
|
119
|
-
onCopy && onCopy();
|
|
111
|
+
return !hideCopyButton && /*#__PURE__*/React.createElement(S.MultiIconCopy, {
|
|
112
|
+
copyValue: children,
|
|
113
|
+
texts: {
|
|
114
|
+
copyTooltip: tooltipTitleHover,
|
|
115
|
+
copiedTooltip: tooltipTitleClick
|
|
120
116
|
},
|
|
121
|
-
|
|
122
|
-
|
|
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
123
|
});
|
|
124
124
|
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent, hideCopyButton]);
|
|
125
125
|
return /*#__PURE__*/React.createElement(S.CodeSnippetWrapperMulti, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StyledButton } from '@synerise/ds-button';
|
|
1
2
|
export declare const ContentIconWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
3
|
export declare const CodeSnippetWrapperMulti: import("styled-components").StyledComponent<"div", any, {
|
|
3
4
|
fontSize?: import("../../CodeSnippet.types").FontSize;
|
|
@@ -5,36 +6,8 @@ export declare const CodeSnippetWrapperMulti: import("styled-components").Styled
|
|
|
5
6
|
expanded?: boolean;
|
|
6
7
|
isButtonVisible?: boolean;
|
|
7
8
|
}, never>;
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
target?: string;
|
|
11
|
-
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
12
|
-
} & import("antd/lib/button/button").BaseButtonProps & Omit<import("react").AnchorHTMLAttributes<any>, "type" | "onClick"> & {
|
|
13
|
-
htmlType?: import("antd/lib/button/button").ButtonHTMLType;
|
|
14
|
-
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
15
|
-
} & Omit<import("react").ButtonHTMLAttributes<any>, "type" | "onClick">>, "type" | "ghost"> & {
|
|
16
|
-
type?: import("@synerise/ds-utils").LiteralStringUnion<import("@synerise/ds-button/dist/Button.types").ButtonType>;
|
|
17
|
-
mode?: import("@synerise/ds-utils").LiteralStringUnion<"single-icon" | "split" | "two-icons" | "label-icon" | "icon-label">;
|
|
18
|
-
color?: import("@synerise/ds-utils").LiteralStringUnion<"blue" | "grey" | "red" | "green" | "yellow" | "pink" | "mars" | "orange" | "fern" | "cyan" | "purple" | "violet">;
|
|
19
|
-
groupVariant?: import("@synerise/ds-utils").LiteralStringUnion<"left-rounded" | "squared" | "right-rounded">;
|
|
20
|
-
justifyContent?: string;
|
|
21
|
-
loading?: boolean | {
|
|
22
|
-
delay?: number;
|
|
23
|
-
};
|
|
24
|
-
onClick?: (event: import("react").MouseEvent<HTMLElement>) => void;
|
|
25
|
-
iconColor?: import("@synerise/ds-utils").LiteralStringUnion<"blue" | "grey" | "red" | "green" | "yellow" | "pink" | "mars" | "orange" | "fern" | "cyan" | "purple" | "violet">;
|
|
26
|
-
error?: boolean;
|
|
27
|
-
readOnly?: boolean;
|
|
28
|
-
tagProps?: import("@synerise/ds-tag").TagProps;
|
|
29
|
-
tooltipProps?: import("@synerise/ds-tooltip").TooltipProps;
|
|
30
|
-
} & import("react").RefAttributes<HTMLButtonElement>> & {
|
|
31
|
-
Creator: import("react").ForwardRefExoticComponent<Omit<import("@synerise/ds-button").CreatorProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
32
|
-
Expander: ({ size, expanded, disabled, onClick, className, }: import("@synerise/ds-button").ExpanderProps) => import("react").JSX.Element;
|
|
33
|
-
Star: (props: import("@synerise/ds-button").StarButtonProps) => React.ReactElement;
|
|
34
|
-
Checkbox: (props: import("@synerise/ds-button").CheckboxButtonProps) => React.ReactElement;
|
|
35
|
-
}, any, {
|
|
36
|
-
expanded?: boolean;
|
|
37
|
-
}, never>;
|
|
9
|
+
export declare const MultiIconCopy: import("styled-components").StyledComponent<({ copyValue, texts, onMouseEnter, onMouseLeave, icon, placement, onCopy, ...rest }: import("@synerise/ds-copy-icon").CopyIconProps) => React.JSX.Element, any, {}, never>;
|
|
10
|
+
export declare const ExpanderButton: StyledButton;
|
|
38
11
|
export declare const BlockCodeWrapperMulti: import("styled-components").StyledComponent<"code", any, {
|
|
39
12
|
fontSize?: import("../../CodeSnippet.types").FontSize;
|
|
40
13
|
} & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import Button from '@synerise/ds-button';
|
|
3
3
|
import { IconContainer } from '@synerise/ds-icon';
|
|
4
|
-
import { BlockCodeWrapperSingle, CodeSnippetWrapperSingle, FONT_SIZE_DEFAULT, LINE_HEIGHT_DEFAULT } from '../SingleCode/SingleCode.styles';
|
|
4
|
+
import { BlockCodeWrapperSingle, CodeSnippetWrapperSingle, FONT_SIZE_DEFAULT, LINE_HEIGHT_DEFAULT, StyledCopyIcon } from '../SingleCode/SingleCode.styles';
|
|
5
5
|
export var ContentIconWrapper = styled.div.withConfig({
|
|
6
6
|
displayName: "MultiCodestyles__ContentIconWrapper",
|
|
7
7
|
componentId: "sc-1u5vxm9-0"
|
|
@@ -9,26 +9,30 @@ export var ContentIconWrapper = styled.div.withConfig({
|
|
|
9
9
|
export var CodeSnippetWrapperMulti = 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;}", ";}
|
|
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;}", ";}"], function (props) {
|
|
13
13
|
return props.theme.palette['grey-100'];
|
|
14
14
|
}, function (props) {
|
|
15
15
|
return !!props.isButtonVisible && "\n padding-bottom:7px;\n .content-animation::after{\n content:'';\n display:block;\n position:absolute;\n bottom:0;\n left:0;\n right:0;\n height:" + LINE_HEIGHT_DEFAULT + "px;\n background-color:" + props.theme.palette['grey-100'] + ";\n z-index:10;\n }\n ";
|
|
16
16
|
});
|
|
17
|
+
export var MultiIconCopy = styled(StyledCopyIcon).withConfig({
|
|
18
|
+
displayName: "MultiCodestyles__MultiIconCopy",
|
|
19
|
+
componentId: "sc-1u5vxm9-2"
|
|
20
|
+
})(["&&{position:absolute;top:0;right:0;z-index:13;}"]);
|
|
17
21
|
export var ExpanderButton = styled(Button).withConfig({
|
|
18
22
|
displayName: "MultiCodestyles__ExpanderButton",
|
|
19
|
-
componentId: "sc-1u5vxm9-
|
|
23
|
+
componentId: "sc-1u5vxm9-3"
|
|
20
24
|
})(["&&{position:relative;z-index:15;top:-5px;", "{svg{transition:transform 0.2s linear;transform:rotate( ", " );}}}"], IconContainer, function (props) {
|
|
21
25
|
return props.expanded ? '180deg' : '0deg';
|
|
22
26
|
});
|
|
23
27
|
export var BlockCodeWrapperMulti = styled(BlockCodeWrapperSingle).withConfig({
|
|
24
28
|
displayName: "MultiCodestyles__BlockCodeWrapperMulti",
|
|
25
|
-
componentId: "sc-1u5vxm9-
|
|
29
|
+
componentId: "sc-1u5vxm9-4"
|
|
26
30
|
})(["&{padding-bottom:", ";}"], function (props) {
|
|
27
31
|
return props.isButtonVisible ? '17px' : '12px';
|
|
28
32
|
});
|
|
29
33
|
export var PreBlock = styled.pre.withConfig({
|
|
30
34
|
displayName: "MultiCodestyles__PreBlock",
|
|
31
|
-
componentId: "sc-1u5vxm9-
|
|
35
|
+
componentId: "sc-1u5vxm9-5"
|
|
32
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, function (props) {
|
|
33
37
|
return !!props.wrap && css(["white-space:pre-wrap;word-wrap:break-world;"]);
|
|
34
38
|
}, LINE_HEIGHT_DEFAULT, function (props) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import copy from 'copy-to-clipboard';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import { DuplicateS } from '@synerise/ds-icon';
|
|
2
|
+
import Icon, { DuplicateS } from '@synerise/ds-icon';
|
|
4
3
|
import { FontSize } from '../../CodeSnippet.types';
|
|
5
|
-
import CopyAction from '../../CopyAction/CopyAction';
|
|
6
4
|
import * as S from './SingleCode.styles';
|
|
7
5
|
var SingleCode = function SingleCode(_ref) {
|
|
8
6
|
var _ref$children = _ref.children,
|
|
@@ -15,16 +13,18 @@ var SingleCode = function SingleCode(_ref) {
|
|
|
15
13
|
onCopy = _ref.onCopy,
|
|
16
14
|
customTriggerComponent = _ref.customTriggerComponent;
|
|
17
15
|
var iconElement = React.useMemo(function () {
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
copy(children);
|
|
24
|
-
onCopy && onCopy();
|
|
16
|
+
return /*#__PURE__*/React.createElement(S.StyledCopyIcon, {
|
|
17
|
+
copyValue: children,
|
|
18
|
+
texts: {
|
|
19
|
+
copyTooltip: tooltipTitleHover,
|
|
20
|
+
copiedTooltip: tooltipTitleClick
|
|
25
21
|
},
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
onCopy: onCopy,
|
|
23
|
+
icon: customTriggerComponent || /*#__PURE__*/React.createElement(Icon, {
|
|
24
|
+
component: /*#__PURE__*/React.createElement(DuplicateS, null),
|
|
25
|
+
size: 24
|
|
26
|
+
}),
|
|
27
|
+
className: S.ICON_CLASSNAME,
|
|
28
28
|
"data-testid": "ds-copy-code-snippet"
|
|
29
29
|
});
|
|
30
30
|
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent]);
|
|
@@ -3,6 +3,7 @@ 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
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, ...rest }: import("@synerise/ds-copy-icon").CopyIconProps) => React.JSX.Element, any, {}, never>;
|
|
6
7
|
export declare const CodeSnippetWrapperSingle: import("styled-components").StyledComponent<"div", any, {
|
|
7
8
|
fontSize?: FontSize;
|
|
8
9
|
}, never>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import CopyIcon from '@synerise/ds-copy-icon';
|
|
2
3
|
import { FontSize } from '../../CodeSnippet.types';
|
|
3
4
|
export var FONT_SIZE_DEFAULT = FontSize.SMALL;
|
|
4
5
|
export var LINE_HEIGHT_DEFAULT = 17;
|
|
@@ -7,23 +8,27 @@ export var ContentIconWrapper = styled.div.withConfig({
|
|
|
7
8
|
displayName: "SingleCodestyles__ContentIconWrapper",
|
|
8
9
|
componentId: "sc-1l78lb-0"
|
|
9
10
|
})(["display:flex;justify-content:space-between;align-items:center;"]);
|
|
10
|
-
export var
|
|
11
|
-
displayName: "
|
|
11
|
+
export var StyledCopyIcon = styled(CopyIcon).withConfig({
|
|
12
|
+
displayName: "SingleCodestyles__StyledCopyIcon",
|
|
12
13
|
componentId: "sc-1l78lb-1"
|
|
13
|
-
})(["
|
|
14
|
-
return props.theme.palette['grey-100'];
|
|
15
|
-
}, function (props) {
|
|
16
|
-
return !!props.fontSize && "\n padding-top: " + (props.fontSize === FontSize.SMALL ? '4px' : '12px') + ";\n padding-bottom: " + (props.fontSize === FontSize.SMALL ? '4px' : '12px') + ";\n ";
|
|
17
|
-
}, function (props) {
|
|
14
|
+
})(["&&{cursor:pointer;background-color:", ";color:", ";}&:hover{color:", ";}"], function (props) {
|
|
18
15
|
return props.theme.palette['grey-100'];
|
|
19
16
|
}, function (props) {
|
|
20
17
|
return props.theme.palette['grey-400'];
|
|
21
18
|
}, function (props) {
|
|
22
19
|
return props.theme.palette['blue-600'];
|
|
23
20
|
});
|
|
21
|
+
export var CodeSnippetWrapperSingle = styled.div.withConfig({
|
|
22
|
+
displayName: "SingleCodestyles__CodeSnippetWrapperSingle",
|
|
23
|
+
componentId: "sc-1l78lb-2"
|
|
24
|
+
})(["&{height:100%;background-color:", ";border-radius:3px;padding:12px 8px 0 12px;.content-animation{position:relative;}", ";}"], function (props) {
|
|
25
|
+
return props.theme.palette['grey-100'];
|
|
26
|
+
}, function (props) {
|
|
27
|
+
return !!props.fontSize && "\n padding-top: " + (props.fontSize === FontSize.SMALL ? '4px' : '12px') + ";\n padding-bottom: " + (props.fontSize === FontSize.SMALL ? '4px' : '12px') + ";\n ";
|
|
28
|
+
});
|
|
24
29
|
export var BlockCodeWrapperSingle = styled.code.withConfig({
|
|
25
30
|
displayName: "SingleCodestyles__BlockCodeWrapperSingle",
|
|
26
|
-
componentId: "sc-1l78lb-
|
|
31
|
+
componentId: "sc-1l78lb-3"
|
|
27
32
|
})(["&{display:block;font-family:'IBM Plex Mono Regular',monospace;font-size:", ";line-height:", "px;color:", ";", ";}"], function (props) {
|
|
28
33
|
return (props.fontSize || FONT_SIZE_DEFAULT) + "px";
|
|
29
34
|
}, LINE_HEIGHT_DEFAULT, function (props) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
2
3
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
3
4
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
4
5
|
// @ts-ignore
|
|
@@ -10,31 +11,28 @@ var Highlight = function Highlight(_ref) {
|
|
|
10
11
|
style = _ref.style,
|
|
11
12
|
children = _ref.children;
|
|
12
13
|
var elementRef = useRef(null);
|
|
13
|
-
var manageHighlight = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/
|
|
14
|
+
var manageHighlight = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
14
15
|
var elements;
|
|
15
|
-
return
|
|
16
|
-
while (1) switch (_context2.
|
|
16
|
+
return _regenerator().w(function (_context2) {
|
|
17
|
+
while (1) switch (_context2.n) {
|
|
17
18
|
case 0:
|
|
18
19
|
if (!elementRef.current) {
|
|
19
|
-
_context2.
|
|
20
|
+
_context2.n = 2;
|
|
20
21
|
break;
|
|
21
22
|
}
|
|
22
23
|
elements = elementRef.current.querySelectorAll('pre code');
|
|
23
|
-
_context2.
|
|
24
|
+
_context2.n = 1;
|
|
24
25
|
return Promise.all(languages.map(/*#__PURE__*/function () {
|
|
25
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/
|
|
26
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(language) {
|
|
26
27
|
var module;
|
|
27
|
-
return
|
|
28
|
-
while (1) switch (_context.
|
|
28
|
+
return _regenerator().w(function (_context) {
|
|
29
|
+
while (1) switch (_context.n) {
|
|
29
30
|
case 0:
|
|
30
|
-
_context.
|
|
31
|
+
_context.n = 1;
|
|
31
32
|
return import("highlight.js/lib/languages/" + language);
|
|
32
|
-
case
|
|
33
|
-
module = _context.
|
|
34
|
-
return _context.
|
|
35
|
-
case 4:
|
|
36
|
-
case "end":
|
|
37
|
-
return _context.stop();
|
|
33
|
+
case 1:
|
|
34
|
+
module = _context.v;
|
|
35
|
+
return _context.a(2, hljs.registerLanguage(language, module["default"]));
|
|
38
36
|
}
|
|
39
37
|
}, _callee);
|
|
40
38
|
}));
|
|
@@ -42,13 +40,12 @@ var Highlight = function Highlight(_ref) {
|
|
|
42
40
|
return _ref3.apply(this, arguments);
|
|
43
41
|
};
|
|
44
42
|
}()));
|
|
45
|
-
case
|
|
43
|
+
case 1:
|
|
46
44
|
elements.forEach(function (element) {
|
|
47
45
|
hljs.highlightElement(element);
|
|
48
46
|
});
|
|
49
|
-
case
|
|
50
|
-
|
|
51
|
-
return _context2.stop();
|
|
47
|
+
case 2:
|
|
48
|
+
return _context2.a(2);
|
|
52
49
|
}
|
|
53
50
|
}, _callee2);
|
|
54
51
|
})), [languages]);
|
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.21",
|
|
4
4
|
"description": "CodeSnippet UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
23
23
|
"build:watch": "npm run build:js -- --watch",
|
|
24
24
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
25
|
-
"pack:ci": "
|
|
25
|
+
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
26
26
|
"prepublish": "npm run build",
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"test:watch": "npm run test -- --watchAll",
|
|
@@ -36,19 +36,20 @@
|
|
|
36
36
|
],
|
|
37
37
|
"types": "dist/index.d.ts",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@synerise/ds-button": "^1.5.
|
|
40
|
-
"@synerise/ds-icon": "^1.
|
|
41
|
-
"@synerise/ds-
|
|
42
|
-
"@synerise/ds-
|
|
43
|
-
"@synerise/ds-
|
|
44
|
-
"
|
|
39
|
+
"@synerise/ds-button": "^1.5.2",
|
|
40
|
+
"@synerise/ds-copy-icon": "^1.0.2",
|
|
41
|
+
"@synerise/ds-icon": "^1.9.1",
|
|
42
|
+
"@synerise/ds-scrollbar": "^1.2.2",
|
|
43
|
+
"@synerise/ds-tooltip": "^1.3.2",
|
|
44
|
+
"@synerise/ds-utils": "^1.5.1",
|
|
45
45
|
"highlight.js": "^10.7.2",
|
|
46
46
|
"react-animate-height": "^2.0.23"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@synerise/ds-core": "*",
|
|
50
|
+
"copy-to-clipboard": "^3.3.1",
|
|
50
51
|
"react": ">=16.9.0 <= 18.3.1",
|
|
51
52
|
"styled-components": "^5.3.3"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b1279d5354132a2bf0b6f0cfa343db4c6c928f72"
|
|
54
55
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Icon from '@synerise/ds-icon';
|
|
3
|
-
import Tooltip from '@synerise/ds-tooltip';
|
|
4
|
-
import { useOnClickOutside } from '@synerise/ds-utils';
|
|
5
|
-
import * as S from './CopyAction.styles';
|
|
6
|
-
var CopyAction = function CopyAction(_ref) {
|
|
7
|
-
var tooltipTitleHover = _ref.tooltipTitleHover,
|
|
8
|
-
tooltipTitleClick = _ref.tooltipTitleClick,
|
|
9
|
-
className = _ref.className,
|
|
10
|
-
_onClick = _ref.onClick,
|
|
11
|
-
icon = _ref.icon,
|
|
12
|
-
iconSize = _ref.iconSize,
|
|
13
|
-
customTriggerComponent = _ref.customTriggerComponent,
|
|
14
|
-
_ref$timeToHideToolti = _ref.timeToHideTooltip,
|
|
15
|
-
timeToHideTooltip = _ref$timeToHideToolti === void 0 ? 3000 : _ref$timeToHideToolti;
|
|
16
|
-
var _React$useState = React.useState(false),
|
|
17
|
-
hideHoverTooltip = _React$useState[0],
|
|
18
|
-
setHideHoverTooltip = _React$useState[1];
|
|
19
|
-
var iconRef = React.useRef(null);
|
|
20
|
-
var timeoutClickRef = React.useRef(null);
|
|
21
|
-
React.useEffect(function () {
|
|
22
|
-
return function () {
|
|
23
|
-
timeoutClickRef.current && clearTimeout(timeoutClickRef.current);
|
|
24
|
-
};
|
|
25
|
-
}, []);
|
|
26
|
-
useOnClickOutside(iconRef, function () {
|
|
27
|
-
if (hideHoverTooltip) {
|
|
28
|
-
setHideHoverTooltip(false);
|
|
29
|
-
timeoutClickRef.current && clearTimeout(timeoutClickRef.current);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
var handleIconClickTooltip = function handleIconClickTooltip() {
|
|
33
|
-
timeoutClickRef.current && clearTimeout(timeoutClickRef.current);
|
|
34
|
-
setHideHoverTooltip(true);
|
|
35
|
-
timeoutClickRef.current = setTimeout(function () {
|
|
36
|
-
setHideHoverTooltip(false);
|
|
37
|
-
}, 3000);
|
|
38
|
-
};
|
|
39
|
-
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
40
|
-
title: tooltipTitleClick,
|
|
41
|
-
trigger: "click",
|
|
42
|
-
timeToHideAfterClick: timeToHideTooltip
|
|
43
|
-
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
44
|
-
title: tooltipTitleHover,
|
|
45
|
-
overlayStyle: hideHoverTooltip ? {
|
|
46
|
-
display: 'none'
|
|
47
|
-
} : undefined
|
|
48
|
-
}, /*#__PURE__*/React.createElement(S.IconWrapper, {
|
|
49
|
-
customTriggerComponent: !!customTriggerComponent,
|
|
50
|
-
ref: iconRef,
|
|
51
|
-
className: className,
|
|
52
|
-
onClick: function onClick(e) {
|
|
53
|
-
!!e && e.stopPropagation();
|
|
54
|
-
handleIconClickTooltip();
|
|
55
|
-
_onClick && _onClick();
|
|
56
|
-
}
|
|
57
|
-
}, customTriggerComponent || /*#__PURE__*/React.createElement(Icon, {
|
|
58
|
-
component: icon,
|
|
59
|
-
size: iconSize || 24
|
|
60
|
-
}))));
|
|
61
|
-
};
|
|
62
|
-
export default CopyAction;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
export var IconWrapper = styled.div.withConfig({
|
|
3
|
-
displayName: "CopyActionstyles__IconWrapper",
|
|
4
|
-
componentId: "sc-1hrgvb2-0"
|
|
5
|
-
})(["margin-left:", ";"], function (props) {
|
|
6
|
-
return props.customTriggerComponent ? '8px' : '0';
|
|
7
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
export type CopyActionProps = {
|
|
3
|
-
tooltipTitleHover: React.ReactNode;
|
|
4
|
-
tooltipTitleClick: React.ReactNode;
|
|
5
|
-
customTriggerComponent?: React.ReactNode;
|
|
6
|
-
className?: string;
|
|
7
|
-
onClick: () => void;
|
|
8
|
-
icon: React.ReactNode;
|
|
9
|
-
iconSize?: number;
|
|
10
|
-
timeToHideTooltip?: number;
|
|
11
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|