genesys-react-components 0.3.0 → 0.3.1-devengage-1574-implementing-code-fences.220
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/build/codefence/CodeFence.d.ts +22 -0
- package/build/index.d.ts +2 -1
- package/build/index.js/index-a1accecb.js +29479 -0
- package/build/index.js/index-a1accecb.js.map +1 -0
- package/build/index.js/index.js +2232 -0
- package/build/index.js/index.js.map +1 -0
- package/package.json +55 -53
- package/src/codefence/CodeFence.scss +103 -0
- package/src/codefence/CodeFence.tsx +68 -0
- package/src/index.ts +2 -0
- package/build/index.js +0 -631
- package/build/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,54 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
2
|
+
"name": "genesys-react-components",
|
|
3
|
+
"version": "0.3.1-devengage-1574-implementing-code-fences.220",
|
|
4
|
+
"description": "A React component library containing standardized form elements.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"require": "./src/index.ts",
|
|
9
|
+
"default": "./build/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"build",
|
|
13
|
+
"src"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "rm -rf build && rollup -c rollup.config.js",
|
|
17
|
+
"localbuild": "npm i && npm run build && rm -rf node_modules",
|
|
18
|
+
"test": "echo \"0/0 tests passed. That's technically a perfect score. Keep up the great work!\""
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+ssh://git@github.com/purecloudlabs/genesys-react-components.git"
|
|
23
|
+
},
|
|
24
|
+
"author": "Genesys",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/purecloudlabs/genesys-react-components/issues"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://purecloudlabs.github.io/genesys-react-components",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
32
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
33
|
+
"@types/react": "^16",
|
|
34
|
+
"genesys-dev-icons": "^0.3.0",
|
|
35
|
+
"react": "^16",
|
|
36
|
+
"react-dom": "^16",
|
|
37
|
+
"rollup": "^2.60.2",
|
|
38
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
39
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
40
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
|
41
|
+
"sass": "^1.44.0",
|
|
42
|
+
"typescript": "^4.5.2",
|
|
43
|
+
"uuid": "^8.3.2"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"genesys-dev-icons": "0.x",
|
|
47
|
+
"react": ">=16",
|
|
48
|
+
"react-dom": ">=16",
|
|
49
|
+
"uuid": "^8.3.2"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
53
|
+
"postcss": "^8.4.6",
|
|
54
|
+
"react-syntax-highlighter": "^15.5.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
@import '../theme/variables.scss';
|
|
2
|
+
|
|
3
|
+
.fence {
|
|
4
|
+
border-radius: 0;
|
|
5
|
+
margin: 40px 0;
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&.json-editor-fence {
|
|
9
|
+
margin: 1rem 0 0 0 !important;
|
|
10
|
+
height: 80%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.fence-header {
|
|
16
|
+
background-color: var($--theme-codefence-header-background-color);
|
|
17
|
+
color: var($--theme-codefence-header-text-color);
|
|
18
|
+
font-size: 14px;
|
|
19
|
+
border-radius: 4px 4px 0px 0px;
|
|
20
|
+
border-bottom: 1px solid var($--theme-codefence-border-color);
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 5px 16px;
|
|
23
|
+
min-height: 24px;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: row-reverse;
|
|
26
|
+
flex-wrap: nowrap;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 16px;
|
|
30
|
+
|
|
31
|
+
&.clickable {
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
& > * {
|
|
36
|
+
flex-grow: 0;
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.copy-button {
|
|
41
|
+
font-size: 14px;
|
|
42
|
+
padding: 0;
|
|
43
|
+
color: var($--theme-codefence-header-text-color);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.fence-title {
|
|
47
|
+
flex-grow: 1;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.icon {
|
|
51
|
+
line-height: 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.fence-body {
|
|
56
|
+
padding: 0;
|
|
57
|
+
overflow: auto;
|
|
58
|
+
border-radius: 0 0 4px 4px;
|
|
59
|
+
|
|
60
|
+
&.json-editor-body {
|
|
61
|
+
height: 100%;
|
|
62
|
+
line-height: 21px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.collapsed {
|
|
66
|
+
max-height: 15px;
|
|
67
|
+
|
|
68
|
+
pre {
|
|
69
|
+
padding-top: 3px;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
pre {
|
|
74
|
+
display: block;
|
|
75
|
+
margin: 0 !important;
|
|
76
|
+
padding: 0 !important;
|
|
77
|
+
border-radius: 0 0 4px 4px !important;
|
|
78
|
+
background: var($--theme-codefence-background-color) !important;
|
|
79
|
+
height: 100%;
|
|
80
|
+
width: 100%;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
|
|
83
|
+
&.json-editor-pre {
|
|
84
|
+
height: 100%;
|
|
85
|
+
width: 100%;
|
|
86
|
+
box-sizing: border-box;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
code {
|
|
90
|
+
background-color: transparent;
|
|
91
|
+
margin: 0 !important;
|
|
92
|
+
padding: 20px !important;
|
|
93
|
+
display: block !important;
|
|
94
|
+
max-height: 600px;
|
|
95
|
+
color: white;
|
|
96
|
+
|
|
97
|
+
.linenumber {
|
|
98
|
+
min-width: 26px !important;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { PrismAsync as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
4
|
+
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
5
|
+
|
|
6
|
+
import CopyButton from '../copybutton/CopyButton';
|
|
7
|
+
|
|
8
|
+
import './CodeFence.scss';
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
Prism: any;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface IProps {
|
|
17
|
+
value: string | JSX.Element;
|
|
18
|
+
noCollapse?: boolean;
|
|
19
|
+
noHeader?: boolean;
|
|
20
|
+
autoCollapse?: boolean;
|
|
21
|
+
title?: string;
|
|
22
|
+
language?: string;
|
|
23
|
+
showLineNumbers?: boolean;
|
|
24
|
+
indentation?: string;
|
|
25
|
+
className?: string;
|
|
26
|
+
jsonEditor?: boolean;
|
|
27
|
+
innerRef?: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function CodeFence(props: IProps) {
|
|
31
|
+
const [collapsed, setCollapsed] = useState(props.noCollapse ? false : props.autoCollapse || false);
|
|
32
|
+
|
|
33
|
+
const bodyClassNames: string[] = ['fence-body'];
|
|
34
|
+
if (props.jsonEditor) bodyClassNames.push('json-editor-body');
|
|
35
|
+
|
|
36
|
+
const classNames: string[] = ['fence'];
|
|
37
|
+
if (props.className) classNames.push(props.className);
|
|
38
|
+
if (props.noCollapse) classNames.push('nocollapse');
|
|
39
|
+
if (props.indentation) classNames.push(`indent-${props.indentation}`);
|
|
40
|
+
if (props.jsonEditor) classNames.push('json-editor-fence');
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div className={classNames.join(' ')}>
|
|
44
|
+
{props.noHeader || typeof props.value !== 'string' ? (
|
|
45
|
+
''
|
|
46
|
+
) : (
|
|
47
|
+
<div
|
|
48
|
+
className={`fence-header${props.noCollapse ? '' : ' clickable'}`}
|
|
49
|
+
onClick={() => setCollapsed(props.noCollapse ? false : !collapsed)}
|
|
50
|
+
>
|
|
51
|
+
{/* this is a row-reverse flexbox, the JSX is meant to be backwards */}
|
|
52
|
+
{props.noCollapse ? undefined : (
|
|
53
|
+
<GenesysDevIcon icon={collapsed ? GenesysDevIcons.AppChevronDown : GenesysDevIcons.AppChevronUp} />
|
|
54
|
+
)}
|
|
55
|
+
<CopyButton copyText={props.value} />
|
|
56
|
+
<span className="fence-title">{props.title}</span>
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
59
|
+
{collapsed ? undefined : (
|
|
60
|
+
<div ref={props.innerRef || undefined} className={bodyClassNames.join(' ')}>
|
|
61
|
+
<SyntaxHighlighter language={props.language} style={vscDarkPlus} showLineNumbers={props.showLineNumbers}>
|
|
62
|
+
{props.value}
|
|
63
|
+
</SyntaxHighlighter>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,7 @@ import AlertBlock from './alertblock/AlertBlock';
|
|
|
13
13
|
import LoadingPlaceholder from './loadingplaceholder/LoadingPlaceholder';
|
|
14
14
|
import Tooltip from './tooltip/Tooltip';
|
|
15
15
|
import CopyButton from './copybutton/CopyButton';
|
|
16
|
+
import CodeFence from './codefence/CodeFence';
|
|
16
17
|
|
|
17
18
|
export {
|
|
18
19
|
DxAccordion,
|
|
@@ -29,6 +30,7 @@ export {
|
|
|
29
30
|
CopyButton,
|
|
30
31
|
LoadingPlaceholder,
|
|
31
32
|
AlertBlock,
|
|
33
|
+
CodeFence,
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
export interface StringChangedCallback {
|