@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.
Files changed (32) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +23 -0
  3. package/dist/CodeSnippet.d.ts +2 -3
  4. package/dist/CodeSnippet.js +31 -68
  5. package/dist/CodeSnippet.types.d.ts +2 -2
  6. package/dist/CodeSnippet.types.js +15 -11
  7. package/dist/CodeTypes/InlineCode/InlineCode.d.ts +1 -1
  8. package/dist/CodeTypes/InlineCode/InlineCode.js +10 -10
  9. package/dist/CodeTypes/InlineCode/InlineCode.styles.d.ts +1 -1
  10. package/dist/CodeTypes/InlineCode/InlineCode.styles.js +6 -5
  11. package/dist/CodeTypes/MultiCode/MultiCode.d.ts +2 -2
  12. package/dist/CodeTypes/MultiCode/MultiCode.js +70 -126
  13. package/dist/CodeTypes/MultiCode/MultiCode.styles.d.ts +8 -8
  14. package/dist/CodeTypes/MultiCode/MultiCode.styles.js +35 -26
  15. package/dist/CodeTypes/SingleCode/SingleCode.d.ts +1 -1
  16. package/dist/CodeTypes/SingleCode/SingleCode.js +25 -37
  17. package/dist/CodeTypes/SingleCode/SingleCode.styles.d.ts +4 -4
  18. package/dist/CodeTypes/SingleCode/SingleCode.styles.js +28 -29
  19. package/dist/Highlight/Highlight.d.ts +2 -2
  20. package/dist/Highlight/Highlight.js +63 -57
  21. package/dist/Highlight/Highlight.styles.d.ts +1 -1
  22. package/dist/Highlight/Highlight.styles.js +6 -27
  23. package/dist/Highlight/Highlight.types.d.ts +1 -1
  24. package/dist/Highlight/Highlight.types.js +1 -1
  25. package/dist/_virtual/preload-helper.js +57 -0
  26. package/dist/assets/style/index-tn0RQdqM.css +0 -0
  27. package/dist/index.js +6 -2
  28. package/dist/modules.d.js +1 -1
  29. package/dist/modules.d.ts +0 -0
  30. package/package.json +10 -10
  31. package/dist/CodeSnippet.figma.d.ts +0 -1
  32. 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>
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import { type CodeSnippetProps } from './CodeSnippet.types';
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;
@@ -1,75 +1,38 @@
1
- import React from 'react';
2
- import { CodeSnippetType, FontSize } from './CodeSnippet.types';
3
- import InlineCode from './CodeTypes/InlineCode/InlineCode';
4
- import MultiCode from './CodeTypes/MultiCode/MultiCode';
5
- import SingleCode from './CodeTypes/SingleCode/SingleCode';
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
- var CodeSnippet = function CodeSnippet(_ref) {
8
- var _ref$type = _ref.type,
9
- type = _ref$type === void 0 ? CodeSnippetType.INLINE : _ref$type,
10
- _ref$languages = _ref.languages,
11
- languages = _ref$languages === void 0 ? ['javascript', 'typescript', 'json'] : _ref$languages,
12
- _ref$children = _ref.children,
13
- children = _ref$children === void 0 ? '' : _ref$children,
14
- _ref$colorSyntax = _ref.colorSyntax,
15
- colorSyntax = _ref$colorSyntax === void 0 ? false : _ref$colorSyntax,
16
- _ref$fontSize = _ref.fontSize,
17
- fontSize = _ref$fontSize === void 0 ? FontSize.SMALL : _ref$fontSize,
18
- _ref$tooltipTitleHove = _ref.tooltipTitleHover,
19
- tooltipTitleHover = _ref$tooltipTitleHove === void 0 ? 'Copy' : _ref$tooltipTitleHove,
20
- _ref$tooltipTitleClic = _ref.tooltipTitleClick,
21
- tooltipTitleClick = _ref$tooltipTitleClic === void 0 ? 'Copied!' : _ref$tooltipTitleClic,
22
- _ref$labelBeforeExpan = _ref.labelBeforeExpanded,
23
- labelBeforeExpanded = _ref$labelBeforeExpan === void 0 ? 'Show more' : _ref$labelBeforeExpan,
24
- _ref$labelAfterExpand = _ref.labelAfterExpanded,
25
- labelAfterExpanded = _ref$labelAfterExpand === void 0 ? 'Show less' : _ref$labelAfterExpand,
26
- _ref$wrap = _ref.wrap,
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 /*#__PURE__*/React.createElement(SingleCode, {
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 /*#__PURE__*/React.createElement(MultiCode, {
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 /*#__PURE__*/React.createElement(InlineCode, {
71
- className: className
72
- }, children);
33
+ return /* @__PURE__ */ jsx(InlineCode, { className, children });
73
34
  }
74
35
  };
75
- export default CodeSnippet;
36
+ export {
37
+ CodeSnippet as default
38
+ };
@@ -1,5 +1,5 @@
1
- import type React from 'react';
2
- import { type LanguageHighlight } from './Highlight/Highlight.types';
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
- export var FontSize = /*#__PURE__*/function (FontSize) {
2
- FontSize[FontSize["SMALL"] = 12] = "SMALL";
3
- FontSize[FontSize["MEDIUM"] = 14] = "MEDIUM";
4
- return FontSize;
5
- }({});
6
- export var CodeSnippetType = /*#__PURE__*/function (CodeSnippetType) {
7
- CodeSnippetType["INLINE"] = "inline";
8
- CodeSnippetType["SINGLE_LINE"] = "single-line";
9
- CodeSnippetType["MULTI_LINE"] = "multi-line";
10
- return CodeSnippetType;
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,4 +1,4 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  export interface InlineCodeProps {
3
3
  children?: string;
4
4
  className?: string;
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
- import * as S from './InlineCode.styles';
3
- var InlineCode = function InlineCode(_ref) {
4
- var _ref$children = _ref.children,
5
- children = _ref$children === void 0 ? '' : _ref$children,
6
- className = _ref.className;
7
- return /*#__PURE__*/React.createElement(S.InlineCodeWrapper, {
8
- className: className
9
- }, children);
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("styled-components").StyledComponent<"code", any, {}, never>;
1
+ export declare const InlineCodeWrapper: import('styled-components').StyledComponent<"code", any, {}, never>;
@@ -1,7 +1,8 @@
1
- import styled from 'styled-components';
2
- export var InlineCodeWrapper = styled.code.withConfig({
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:", ";}"], function (props) {
6
- return props.theme.palette["pink-100"];
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 { type CodeSnippetProps } from '../../CodeSnippet.types';
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
- 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 React from 'react';
3
- import AnimateHeight from 'react-animate-height';
4
- import Icon, { ArrowDownCircleM, DuplicateS } from '@synerise/ds-icon';
5
- import Scrollbar from '@synerise/ds-scrollbar';
6
- import Highlight from '../../Highlight/Highlight';
7
- import { ICON_CLASSNAME, LINE_HEIGHT_DEFAULT } from '../SingleCode/SingleCode.styles';
8
- import * as S from './MultiCode.styles';
9
- var ANIMATE_HEIGHT_TIME = 300;
10
- var MultiCode = function MultiCode(_ref) {
11
- var _ref$languages = _ref.languages,
12
- languages = _ref$languages === void 0 ? ['javascript', 'typescript', 'json'] : _ref$languages,
13
- _ref$children = _ref.children,
14
- children = _ref$children === void 0 ? '' : _ref$children,
15
- className = _ref.className,
16
- _ref$colorSyntax = _ref.colorSyntax,
17
- colorSyntax = _ref$colorSyntax === void 0 ? false : _ref$colorSyntax,
18
- tooltipTitleHover = _ref.tooltipTitleHover,
19
- tooltipTitleClick = _ref.tooltipTitleClick,
20
- labelBeforeExpanded = _ref.labelBeforeExpanded,
21
- labelAfterExpanded = _ref.labelAfterExpanded,
22
- _ref$wrap = _ref.wrap,
23
- wrap = _ref$wrap === void 0 ? false : _ref$wrap,
24
- _ref$rows = _ref.rows,
25
- rows = _ref$rows === void 0 ? 6 : _ref$rows,
26
- onExpand = _ref.onExpand,
27
- onCopy = _ref.onCopy,
28
- customTriggerComponent = _ref.customTriggerComponent,
29
- _ref$hideExpandButton = _ref.hideExpandButton,
30
- hideExpandButton = _ref$hideExpandButton === void 0 ? false : _ref$hideExpandButton,
31
- _ref$hideCopyButton = _ref.hideCopyButton,
32
- hideCopyButton = _ref$hideCopyButton === void 0 ? false : _ref$hideCopyButton,
33
- _ref$expanded = _ref.expanded,
34
- expanded = _ref$expanded === void 0 ? false : _ref$expanded;
35
- var _React$useState = React.useState(expanded),
36
- expandedState = _React$useState[0],
37
- setExpandedState = _React$useState[1];
38
- var _React$useState2 = React.useState(false),
39
- scrollable = _React$useState2[0],
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
- var onMounting = React.useCallback(function () {
58
- if (!!codeRef && !!(codeRef != null && codeRef.current)) {
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(function () {
47
+ React.useLayoutEffect(() => {
63
48
  onMounting();
64
49
  }, [onMounting, children, rows, wrap]);
65
- var handleButton = React.useCallback(function (isScroll) {
66
- setExpandedState(function (prevState) {
67
- return !prevState;
68
- });
50
+ const handleButton = React.useCallback((isScroll) => {
51
+ setExpandedState((prevState) => !prevState);
69
52
  if (isScroll) {
70
- setTimeout(function () {
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(function (prevState) {
77
- return !prevState;
78
- });
55
+ setScrollable((prevState) => !prevState);
79
56
  }
80
57
  onExpand && onExpand();
81
58
  }, [onExpand]);
82
- var isButtonVisible = React.useMemo(function () {
83
- return allRows > rows + 1;
84
- }, [rows, allRows]);
85
- var extraHeightOption = React.useMemo(function () {
86
- return isButtonVisible ? initialContentHeight : 'auto';
87
- }, [isButtonVisible, initialContentHeight]);
88
- var multilineStructureContent = React.useMemo(function () {
89
- return /*#__PURE__*/React.createElement(S.PreBlock, {
90
- wrap: wrap,
91
- expanded: expandedState,
92
- isButtonVisible: isButtonVisible
93
- }, /*#__PURE__*/React.createElement(AnimateHeight, {
94
- className: "content-animation",
95
- duration: ANIMATE_HEIGHT_TIME,
96
- height: !expandedState ? extraHeightOption : 'auto',
97
- style: {
98
- minHeight: LINE_HEIGHT_DEFAULT
99
- }
100
- }, /*#__PURE__*/React.createElement(Scrollbar, {
101
- maxHeight: !scrollable ? (rows + 1) * LINE_HEIGHT_DEFAULT : '100%',
102
- style: {
103
- marginRight: '17px'
104
- }
105
- }, /*#__PURE__*/React.createElement(S.BlockCodeWrapperMulti, {
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 { type 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;
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("styled-components").StyledComponent<({ copyValue, texts, onMouseEnter, onMouseLeave, icon, placement, onCopy, onClick, ...rest }: import("@synerise/ds-copy-icon").CopyIconProps) => React.JSX.Element, any, {}, never>;
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("styled-components").StyledComponent<"code", any, {
12
- fontSize?: import("../../CodeSnippet.types").FontSize;
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("styled-components").StyledComponent<"pre", any, {
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 'styled-components';
2
- import Button from '@synerise/ds-button';
3
- import { IconContainer } from '@synerise/ds-icon';
4
- import { BlockCodeWrapperSingle, CodeSnippetWrapperSingle, FONT_SIZE_DEFAULT, LINE_HEIGHT_DEFAULT, StyledCopyIcon } from '../SingleCode/SingleCode.styles';
5
- export var ContentIconWrapper = styled.div.withConfig({
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
- export var CodeSnippetWrapperMulti = styled(CodeSnippetWrapperSingle).withConfig({
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;}", ";}"], function (props) {
13
- return props.theme.palette['grey-100'];
14
- }, function (props) {
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
- });
17
- export var MultiIconCopy = styled(StyledCopyIcon).withConfig({
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
- export var ExpanderButton = styled(Button).withConfig({
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, function (props) {
25
- return props.expanded ? '180deg' : '0deg';
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:", ";}"], function (props) {
31
- return props.isButtonVisible ? '17px' : '12px';
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, function (props) {
37
- return !!props.wrap && css(["white-space:pre-wrap;word-wrap:break-world;"]);
38
- }, LINE_HEIGHT_DEFAULT, function (props) {
39
- return props.isButtonVisible ? '10px' : '6px';
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,4 +1,4 @@
1
- import React from 'react';
1
+ import { default as React } from 'react';
2
2
  import { FontSize } from '../../CodeSnippet.types';
3
3
  export interface SingleCodeProps {
4
4
  children?: string;
@@ -1,38 +1,26 @@
1
- import React from 'react';
2
- import Icon, { DuplicateS } from '@synerise/ds-icon';
3
- import { FontSize } from '../../CodeSnippet.types';
4
- import * as S from './SingleCode.styles';
5
- var SingleCode = function SingleCode(_ref) {
6
- var _ref$children = _ref.children,
7
- children = _ref$children === void 0 ? '' : _ref$children,
8
- _ref$fontSize = _ref.fontSize,
9
- fontSize = _ref$fontSize === void 0 ? FontSize.SMALL : _ref$fontSize,
10
- tooltipTitleHover = _ref.tooltipTitleHover,
11
- tooltipTitleClick = _ref.tooltipTitleClick,
12
- className = _ref.className,
13
- onCopy = _ref.onCopy,
14
- customTriggerComponent = _ref.customTriggerComponent;
15
- var iconElement = React.useMemo(function () {
16
- return /*#__PURE__*/React.createElement(S.StyledCopyIcon, {
17
- copyValue: children,
18
- texts: {
19
- copyTooltip: tooltipTitleHover,
20
- copiedTooltip: tooltipTitleClick
21
- },
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
- "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("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, {
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("styled-components").StyledComponent<"code", any, {
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 'styled-components';
2
- import CopyIcon from '@synerise/ds-copy-icon';
3
- import { FontSize } from '../../CodeSnippet.types';
4
- export var FONT_SIZE_DEFAULT = FontSize.SMALL;
5
- export var LINE_HEIGHT_DEFAULT = 17;
6
- export var ICON_CLASSNAME = 'copy';
7
- export var ContentIconWrapper = styled.div.withConfig({
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
- export var StyledCopyIcon = styled(CopyIcon).withConfig({
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:", ";}"], function (props) {
15
- return props.theme.palette['grey-100'];
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;}", ";}"], 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
- });
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:", ";", ";}"], function (props) {
33
- return (props.fontSize || FONT_SIZE_DEFAULT) + "px";
34
- }, LINE_HEIGHT_DEFAULT, function (props) {
35
- return props.theme.palette["grey-600"];
36
- }, function (props) {
37
- return !!props.fontSize && "\n padding-right: 4px;\n line-height:24px;\n ";
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 { type HighlightProps } from './Highlight.types';
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
- 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); }
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); }
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); }); }; }
5
- // @ts-ignore
6
- import hljs from 'highlight.js/lib/core';
7
- import React, { useCallback, useEffect, useRef } from 'react';
8
- import * as S from './Highlight.styles';
9
- var Highlight = function Highlight(_ref) {
10
- var languages = _ref.languages,
11
- style = _ref.style,
12
- children = _ref.children;
13
- var elementRef = useRef(null);
14
- var manageHighlight = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
15
- var elements;
16
- return _regenerator().w(function (_context2) {
17
- while (1) switch (_context2.n) {
18
- case 0:
19
- if (!elementRef.current) {
20
- _context2.n = 2;
21
- break;
22
- }
23
- elements = elementRef.current.querySelectorAll('pre code');
24
- _context2.n = 1;
25
- return Promise.all(languages.map(/*#__PURE__*/function () {
26
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(language) {
27
- var module;
28
- return _regenerator().w(function (_context) {
29
- while (1) switch (_context.n) {
30
- case 0:
31
- _context.n = 1;
32
- return import("highlight.js/lib/languages/" + language);
33
- case 1:
34
- module = _context.v;
35
- return _context.a(2, hljs.registerLanguage(language, module["default"]));
36
- }
37
- }, _callee);
38
- }));
39
- return function (_x) {
40
- return _ref3.apply(this, arguments);
41
- };
42
- }()));
43
- case 1:
44
- elements.forEach(function (element) {
45
- hljs.highlightElement(element);
46
- });
47
- case 2:
48
- return _context2.a(2);
49
- }
50
- }, _callee2);
51
- })), [languages]);
52
- useEffect(function () {
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 /*#__PURE__*/React.createElement(S.Highlight, {
56
- ref: elementRef,
57
- style: style
58
- }, children);
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("styled-components").StyledComponent<"div", any, {}, never>;
1
+ export declare const Highlight: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,29 +1,8 @@
1
- import styled from 'styled-components';
2
- export var Highlight = styled.div.withConfig({
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;}"], function (props) {
6
- return props.theme.palette['grey-700'];
7
- }, function (props) {
8
- return props.theme.palette['blue-600'];
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,4 +1,4 @@
1
- import { type CSSProperties, type ReactNode } from 'react';
1
+ import { CSSProperties, ReactNode } from 'react';
2
2
  export type HighlightProps = {
3
3
  languages: LanguageHighlight[];
4
4
  style?: CSSProperties;
@@ -1 +1 @@
1
- export {};
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
- export { default } from './CodeSnippet';
2
- export { CodeSnippetType } from './CodeSnippet.types';
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 '@testing-library/jest-dom';
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.38",
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": "pnpm run build:js && pnpm run build:css && pnpm run defs",
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": "pnpm run build:js -- --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.17",
40
- "@synerise/ds-copy-icon": "^1.2.1",
41
- "@synerise/ds-icon": "^1.15.0",
42
- "@synerise/ds-scrollbar": "^1.2.16",
43
- "@synerise/ds-tooltip": "^1.4.9",
44
- "@synerise/ds-utils": "^1.7.0",
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": "8efc031fa688c0b87c7b3915bae93546bb63bcac"
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
- });