@patternfly/react-core 4.201.1 → 4.201.2

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 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
+ ## 4.201.2 (2022-03-23)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-core
9
+
10
+
11
+
12
+
13
+
6
14
  ## 4.201.1 (2022-03-23)
7
15
 
8
16
  **Note:** Version bump only for package @patternfly/react-core
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.201.1",
3
+ "version": "4.201.2",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.52.1",
38
- "@patternfly/react-styles": "^4.51.1",
39
- "@patternfly/react-tokens": "^4.53.1",
37
+ "@patternfly/react-icons": "^4.52.2",
38
+ "@patternfly/react-styles": "^4.51.2",
39
+ "@patternfly/react-tokens": "^4.53.2",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "ebbf69c3f929c9aabaebe49726deb1c72130951e"
63
+ "gitHead": "c7164830706215f812e1982fdad6c9903229e71f"
64
64
  }
@@ -12,203 +12,10 @@ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
12
12
 
13
13
  ### Basic
14
14
 
15
- ```js
16
- import React from 'react';
17
- import { CodeBlock, CodeBlockAction, CodeBlockCode, ClipboardCopyButton, Button } from '@patternfly/react-core';
18
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
19
- import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
20
-
21
- class BasicCodeBlock extends React.Component {
22
- constructor(props) {
23
- super(props);
24
- this.timer = null;
25
-
26
- this.state = {
27
- copied: false
28
- };
29
-
30
- this.clipboardCopyFunc = (event, text) => {
31
- const clipboard = event.currentTarget.parentElement;
32
- const el = document.createElement('textarea');
33
- el.value = text.toString();
34
- clipboard.appendChild(el);
35
- el.select();
36
- document.execCommand('copy');
37
- clipboard.removeChild(el);
38
- };
39
-
40
- this.onClick = (event, text) => {
41
- if (this.timer) {
42
- window.clearTimeout(this.timer);
43
- this.setState({ copied: false });
44
- }
45
- this.clipboardCopyFunc(event, text);
46
- this.setState({ copied: true }, () => {
47
- this.timer = window.setTimeout(() => {
48
- this.setState({ copied: false });
49
- this.timer = null;
50
- }, 1000);
51
- });
52
- };
53
- }
54
-
55
- render() {
56
- const code = `apiVersion: helm.openshift.io/v1beta1/
57
- kind: HelmChartRepository
58
- metadata:
59
- name: azure-sample-repo
60
- spec:
61
- connectionConfig:
62
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
63
-
64
- const actions = (
65
- <React.Fragment>
66
- <CodeBlockAction>
67
- <ClipboardCopyButton
68
- id="copy-button"
69
- textId="code-content"
70
- aria-label="Copy to clipboard"
71
- onClick={e => this.onClick(e, code)}
72
- exitDelay={600}
73
- maxWidth="110px"
74
- variant="plain"
75
- >
76
- {this.state.copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
77
- </ClipboardCopyButton>
78
- </CodeBlockAction>
79
- <CodeBlockAction>
80
- <Button variant="plain" aria-label="Play icon">
81
- <PlayIcon />
82
- </Button>
83
- </CodeBlockAction>
84
- </React.Fragment>
85
- );
86
-
87
- return (
88
- <CodeBlock actions={actions}>
89
- <CodeBlockCode id="code-content">{code}</CodeBlockCode>
90
- </CodeBlock>
91
- );
92
- }
93
- }
15
+ ```ts file="./CodeBlockBasic.tsx"
94
16
  ```
95
17
 
96
18
  ### Expandable
97
19
 
98
- ```js
99
- import React from 'react';
100
- import {
101
- CodeBlock,
102
- CodeBlockAction,
103
- CodeBlockCode,
104
- ClipboardCopyButton,
105
- ExpandableSection,
106
- ExpandableSectionToggle,
107
- Button
108
- } from '@patternfly/react-core';
109
- import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
110
- import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
111
-
112
- class BasicCodeBlock extends React.Component {
113
- constructor(props) {
114
- super(props);
115
- this.timer = null;
116
-
117
- this.state = {
118
- isExpanded: false,
119
- copied: false
120
- };
121
-
122
- this.onToggle = isExpanded => {
123
- this.setState({
124
- isExpanded
125
- });
126
- };
127
-
128
- this.clipboardCopyFunc = (event, text) => {
129
- const clipboard = event.currentTarget.parentElement;
130
- const el = document.createElement('textarea');
131
- el.value = text.toString();
132
- clipboard.appendChild(el);
133
- el.select();
134
- document.execCommand('copy');
135
- clipboard.removeChild(el);
136
- };
137
-
138
- this.onClick = (event, text) => {
139
- if (this.timer) {
140
- window.clearTimeout(this.timer);
141
- this.setState({ copied: false });
142
- }
143
- this.clipboardCopyFunc(event, text);
144
- this.setState({ copied: true }, () => {
145
- this.timer = window.setTimeout(() => {
146
- this.setState({ copied: false });
147
- this.timer = null;
148
- }, 1000);
149
- });
150
- };
151
- }
152
-
153
- render() {
154
- const { isExpanded } = this.state;
155
-
156
- const copyBlock = `apiVersion: helm.openshift.io/v1beta1/
157
- kind: HelmChartRepository
158
- metadata:
159
- name: azure-sample-repo
160
- spec:
161
- connectionConfig:
162
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
163
-
164
- const code = `apiVersion: helm.openshift.io/v1beta1/
165
- kind: HelmChartRepository
166
- metadata:
167
- name: azure-sample-repo`;
168
- const expandedCode = `spec:
169
- connectionConfig:
170
- url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
171
-
172
- const actions = (
173
- <React.Fragment>
174
- <CodeBlockAction>
175
- <ClipboardCopyButton
176
- id="copy-button"
177
- textId="code-content"
178
- aria-label="Copy to clipboard"
179
- onClick={e => this.onClick(e, copyBlock)}
180
- exitDelay={600}
181
- maxWidth="110px"
182
- variant="plain"
183
- >
184
- {this.state.copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
185
- </ClipboardCopyButton>
186
- </CodeBlockAction>
187
- <CodeBlockAction>
188
- <Button variant="plain" aria-label="Play icon">
189
- <PlayIcon />
190
- </Button>
191
- </CodeBlockAction>
192
- </React.Fragment>
193
- );
194
- return (
195
- <CodeBlock actions={actions}>
196
- <CodeBlockCode>
197
- {code}
198
- <ExpandableSection isExpanded={isExpanded} isDetached contentId="code-block-expand">
199
- {expandedCode}
200
- </ExpandableSection>
201
- </CodeBlockCode>
202
- <ExpandableSectionToggle
203
- isExpanded={isExpanded}
204
- onToggle={this.onToggle}
205
- contentId="code-block-expand"
206
- direction="up"
207
- >
208
- {isExpanded ? 'Show Less' : 'Show More'}
209
- </ExpandableSectionToggle>
210
- </CodeBlock>
211
- );
212
- }
213
- }
20
+ ```ts file="./CodeBlockExpandable.tsx"
214
21
  ```
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { CodeBlock, CodeBlockAction, CodeBlockCode, ClipboardCopyButton, Button } from '@patternfly/react-core';
3
+ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
4
+
5
+ export const BasicCodeBlock: React.FunctionComponent = () => {
6
+ const [copied, setCopied] = React.useState(false);
7
+
8
+ const clipboardCopyFunc = (event, text) => {
9
+ const clipboard = event.currentTarget.parentElement;
10
+ const el = document.createElement('textarea');
11
+ el.value = text.toString();
12
+ clipboard.appendChild(el);
13
+ el.select();
14
+ document.execCommand('copy');
15
+ clipboard.removeChild(el);
16
+ };
17
+
18
+ const onClick = (event, text) => {
19
+ clipboardCopyFunc(event, text);
20
+ setCopied(true);
21
+ };
22
+
23
+ const code = `apiVersion: helm.openshift.io/v1beta1/
24
+ kind: HelmChartRepository
25
+ metadata:
26
+ name: azure-sample-repo0oooo00ooo
27
+ spec:
28
+ connectionConfig:
29
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
30
+
31
+ const actions = (
32
+ <React.Fragment>
33
+ <CodeBlockAction>
34
+ <ClipboardCopyButton
35
+ id="copy-button"
36
+ textId="code-content"
37
+ aria-label="Copy to clipboard"
38
+ onClick={e => onClick(e, code)}
39
+ exitDelay={600}
40
+ maxWidth="110px"
41
+ variant="plain"
42
+ >
43
+ {copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
44
+ </ClipboardCopyButton>
45
+ </CodeBlockAction>
46
+ <CodeBlockAction>
47
+ <Button variant="plain" aria-label="Play icon">
48
+ <PlayIcon />
49
+ </Button>
50
+ </CodeBlockAction>
51
+ </React.Fragment>
52
+ );
53
+
54
+ return (
55
+ <CodeBlock actions={actions}>
56
+ <CodeBlockCode id="code-content">{code}</CodeBlockCode>
57
+ </CodeBlock>
58
+ );
59
+ };
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import {
3
+ CodeBlock,
4
+ CodeBlockAction,
5
+ CodeBlockCode,
6
+ ClipboardCopyButton,
7
+ ExpandableSection,
8
+ ExpandableSectionToggle,
9
+ Button
10
+ } from '@patternfly/react-core';
11
+ import PlayIcon from '@patternfly/react-icons/dist/esm/icons/play-icon';
12
+
13
+ export const ExpandableCodeBlock: React.FunctionComponent = () => {
14
+ const [isExpanded, setIsExpanded] = React.useState(false);
15
+ const [copied, setCopied] = React.useState(false);
16
+
17
+ const onToggle = isExpanded => {
18
+ setIsExpanded(isExpanded);
19
+ };
20
+
21
+ const clipboardCopyFunc = (event, text) => {
22
+ const clipboard = event.currentTarget.parentElement;
23
+ const el = document.createElement('textarea');
24
+ el.value = text.toString();
25
+ clipboard.appendChild(el);
26
+ el.select();
27
+ document.execCommand('copy');
28
+ clipboard.removeChild(el);
29
+ };
30
+
31
+ const onClick = (event, text) => {
32
+ clipboardCopyFunc(event, text);
33
+ setCopied(true);
34
+ };
35
+
36
+ const copyBlock = `apiVersion: helm.openshift.io/v1beta1/
37
+ kind: HelmChartRepository
38
+ metadata:
39
+ name: azure-sample-repo
40
+ spec:
41
+ connectionConfig:
42
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
43
+
44
+ const code = `apiVersion: helm.openshift.io/v1beta1/
45
+ kind: HelmChartRepository
46
+ metadata:
47
+ name: azure-sample-repo`;
48
+ const expandedCode = `spec:
49
+ connectionConfig:
50
+ url: https://raw.githubusercontent.com/Azure-Samples/helm-charts/master/docs`;
51
+
52
+ const actions = (
53
+ <React.Fragment>
54
+ <CodeBlockAction>
55
+ <ClipboardCopyButton
56
+ id="copy-button"
57
+ textId="code-content"
58
+ aria-label="Copy to clipboard"
59
+ onClick={e => onClick(e, copyBlock)}
60
+ exitDelay={600}
61
+ maxWidth="110px"
62
+ variant="plain"
63
+ >
64
+ {copied ? 'Successfully copied to clipboard!' : 'Copy to clipboard'}
65
+ </ClipboardCopyButton>
66
+ </CodeBlockAction>
67
+ <CodeBlockAction>
68
+ <Button variant="plain" aria-label="Play icon">
69
+ <PlayIcon />
70
+ </Button>
71
+ </CodeBlockAction>
72
+ </React.Fragment>
73
+ );
74
+
75
+ return (
76
+ <CodeBlock actions={actions}>
77
+ <CodeBlockCode>
78
+ {code}
79
+ <ExpandableSection isExpanded={isExpanded} isDetached contentId="code-block-expand">
80
+ {expandedCode}
81
+ </ExpandableSection>
82
+ </CodeBlockCode>
83
+ <ExpandableSectionToggle isExpanded={isExpanded} onToggle={onToggle} contentId="code-block-expand" direction="up">
84
+ {isExpanded ? 'Show Less' : 'Show More'}
85
+ </ExpandableSectionToggle>
86
+ </CodeBlock>
87
+ );
88
+ };