@synerise/ds-code-snippet 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/CodeSnippet.d.ts +1 -1
- package/dist/CodeSnippet.js +11 -2
- package/dist/CodeSnippet.types.d.ts +2 -0
- package/dist/CodeTypes/MultiCode/MultiCode.js +11 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.0.9...@synerise/ds-code-snippet@1.1.0) (2025-06-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **code-snippet:** add hide expand and copy button props ([7db9ff1](https://github.com/Synerise/synerise-design/commit/7db9ff120215b057d8d8db0a8cc752a0ce8cf89a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [1.0.9](https://github.com/Synerise/synerise-design/compare/@synerise/ds-code-snippet@1.0.8...@synerise/ds-code-snippet@1.0.9) (2025-05-26)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @synerise/ds-code-snippet
|
package/dist/CodeSnippet.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style/index.less';
|
|
3
3
|
import { CodeSnippetProps } from './CodeSnippet.types';
|
|
4
|
-
declare const CodeSnippet: ({ type, languages, children, colorSyntax, fontSize, tooltipTitleHover, tooltipTitleClick, labelBeforeExpanded, labelAfterExpanded, wrap, rows, className, onExpand, onCopy, customTriggerComponent, }: CodeSnippetProps) => React.JSX.Element;
|
|
4
|
+
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
5
|
export default CodeSnippet;
|
package/dist/CodeSnippet.js
CHANGED
|
@@ -30,7 +30,13 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
30
30
|
className = _ref.className,
|
|
31
31
|
onExpand = _ref.onExpand,
|
|
32
32
|
onCopy = _ref.onCopy,
|
|
33
|
-
customTriggerComponent = _ref.customTriggerComponent
|
|
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;
|
|
34
40
|
switch (type) {
|
|
35
41
|
case CodeSnippetType.SINGLE_LINE:
|
|
36
42
|
return /*#__PURE__*/React.createElement(SingleCode, {
|
|
@@ -50,12 +56,15 @@ var CodeSnippet = function CodeSnippet(_ref) {
|
|
|
50
56
|
tooltipTitleClick: tooltipTitleClick,
|
|
51
57
|
labelBeforeExpanded: labelBeforeExpanded,
|
|
52
58
|
labelAfterExpanded: labelAfterExpanded,
|
|
59
|
+
expanded: expanded,
|
|
53
60
|
className: className,
|
|
54
61
|
wrap: wrap,
|
|
55
62
|
rows: rows,
|
|
56
63
|
onExpand: onExpand,
|
|
57
64
|
onCopy: onCopy,
|
|
58
|
-
customTriggerComponent: customTriggerComponent
|
|
65
|
+
customTriggerComponent: customTriggerComponent,
|
|
66
|
+
hideExpandButton: hideExpandButton,
|
|
67
|
+
hideCopyButton: hideCopyButton
|
|
59
68
|
}, children);
|
|
60
69
|
default:
|
|
61
70
|
return /*#__PURE__*/React.createElement(InlineCode, {
|
|
@@ -27,8 +27,14 @@ var MultiCode = function MultiCode(_ref) {
|
|
|
27
27
|
rows = _ref$rows === void 0 ? 6 : _ref$rows,
|
|
28
28
|
onExpand = _ref.onExpand,
|
|
29
29
|
onCopy = _ref.onCopy,
|
|
30
|
-
customTriggerComponent = _ref.customTriggerComponent
|
|
31
|
-
|
|
30
|
+
customTriggerComponent = _ref.customTriggerComponent,
|
|
31
|
+
_ref$hideExpandButton = _ref.hideExpandButton,
|
|
32
|
+
hideExpandButton = _ref$hideExpandButton === void 0 ? false : _ref$hideExpandButton,
|
|
33
|
+
_ref$hideCopyButton = _ref.hideCopyButton,
|
|
34
|
+
hideCopyButton = _ref$hideCopyButton === void 0 ? false : _ref$hideCopyButton,
|
|
35
|
+
_ref$expanded = _ref.expanded,
|
|
36
|
+
expanded = _ref$expanded === void 0 ? false : _ref$expanded;
|
|
37
|
+
var _React$useState = React.useState(expanded),
|
|
32
38
|
expandedState = _React$useState[0],
|
|
33
39
|
setExpandedState = _React$useState[1];
|
|
34
40
|
var _React$useState2 = React.useState(false),
|
|
@@ -100,7 +106,7 @@ var MultiCode = function MultiCode(_ref) {
|
|
|
100
106
|
}, children))));
|
|
101
107
|
}, [wrap, rows, expandedState, isButtonVisible, scrollable, codeRef, extraHeightOption, children]);
|
|
102
108
|
var iconElement = React.useMemo(function () {
|
|
103
|
-
return /*#__PURE__*/React.createElement(CopyAction, {
|
|
109
|
+
return !hideCopyButton && /*#__PURE__*/React.createElement(CopyAction, {
|
|
104
110
|
tooltipTitleHover: tooltipTitleHover,
|
|
105
111
|
tooltipTitleClick: tooltipTitleClick,
|
|
106
112
|
className: ICON_CLASSNAME,
|
|
@@ -111,14 +117,14 @@ var MultiCode = function MultiCode(_ref) {
|
|
|
111
117
|
icon: /*#__PURE__*/React.createElement(DuplicateS, null),
|
|
112
118
|
customTriggerComponent: customTriggerComponent
|
|
113
119
|
});
|
|
114
|
-
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent]);
|
|
120
|
+
}, [children, tooltipTitleHover, tooltipTitleClick, onCopy, customTriggerComponent, hideCopyButton]);
|
|
115
121
|
return /*#__PURE__*/React.createElement(S.CodeSnippetWrapperMulti, {
|
|
116
122
|
expanded: expandedState,
|
|
117
123
|
isButtonVisible: isButtonVisible,
|
|
118
124
|
className: className
|
|
119
125
|
}, /*#__PURE__*/React.createElement(S.ContentIconWrapper, null, colorSyntax && languages ? /*#__PURE__*/React.createElement(Highlight, {
|
|
120
126
|
languages: languages
|
|
121
|
-
}, multilineStructureContent) : multilineStructureContent, iconElement), rows && isButtonVisible && /*#__PURE__*/React.createElement(S.ExpanderButton, _extends({}, buttonProps, {
|
|
127
|
+
}, multilineStructureContent) : multilineStructureContent, iconElement), !hideExpandButton && rows && isButtonVisible && /*#__PURE__*/React.createElement(S.ExpanderButton, _extends({}, buttonProps, {
|
|
122
128
|
onClick: function onClick() {
|
|
123
129
|
return handleButton(expandedState);
|
|
124
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-code-snippet",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "CodeSnippet UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-button": "^1.3.
|
|
38
|
+
"@synerise/ds-button": "^1.3.2",
|
|
39
39
|
"@synerise/ds-icon": "^1.5.1",
|
|
40
40
|
"@synerise/ds-scrollbar": "^1.0.9",
|
|
41
41
|
"@synerise/ds-tooltip": "^1.1.8",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"react": ">=16.9.0 <= 18.3.1",
|
|
50
50
|
"styled-components": "^5.3.3"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "12eaee0c6431aac9a7b2dbc42e0f8567b3de7244"
|
|
53
53
|
}
|