@patternfly/react-core 4.201.1 → 4.202.1
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 +27 -0
- package/dist/esm/components/DescriptionList/DescriptionList.d.ts +13 -3
- package/dist/esm/components/DescriptionList/DescriptionList.d.ts.map +1 -1
- package/dist/esm/components/DescriptionList/DescriptionList.js +10 -6
- package/dist/esm/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/esm/components/Menu/MenuContent.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuContent.js +21 -2
- package/dist/esm/components/Menu/MenuContent.js.map +1 -1
- package/dist/esm/components/Popover/Popover.d.ts +1 -1
- package/dist/esm/components/Select/Select.d.ts +5 -3
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +36 -17
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +3 -3
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +14 -14
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/components/Select/selectConstants.d.ts +1 -0
- package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/esm/components/Select/selectConstants.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +6 -4
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +15 -8
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionList.d.ts +13 -3
- package/dist/js/components/DescriptionList/DescriptionList.d.ts.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionList.js +10 -6
- package/dist/js/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/js/components/Menu/MenuContent.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuContent.js +21 -2
- package/dist/js/components/Menu/MenuContent.js.map +1 -1
- package/dist/js/components/Popover/Popover.d.ts +1 -1
- package/dist/js/components/Select/Select.d.ts +5 -3
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +36 -17
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +3 -3
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +14 -14
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/components/Select/selectConstants.d.ts +1 -0
- package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/js/components/Select/selectConstants.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +6 -4
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +15 -8
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/umd/react-core.css +31 -2
- package/dist/umd/react-core.js +106 -52
- package/dist/umd/react-core.min.css +31 -2
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/CodeBlock/examples/CodeBlock.md +2 -195
- package/src/components/CodeBlock/examples/CodeBlockBasic.tsx +59 -0
- package/src/components/CodeBlock/examples/CodeBlockExpandable.tsx +88 -0
- package/src/components/DescriptionList/DescriptionList.tsx +52 -31
- package/src/components/DescriptionList/examples/DescriptionList.md +87 -28
- package/src/components/Menu/MenuContent.tsx +27 -2
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/Select/Select.tsx +39 -18
- package/src/components/Select/SelectOption.tsx +7 -4
- package/src/components/Select/SelectToggle.tsx +15 -15
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
- package/src/components/Select/examples/Select.md +93 -40
- package/src/components/Select/selectConstants.tsx +1 -0
- package/src/components/TimePicker/TimePicker.tsx +20 -11
- package/src/components/TimePicker/examples/TimePicker.md +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.202.1",
|
|
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,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.53.1",
|
|
38
|
+
"@patternfly/react-styles": "^4.52.1",
|
|
39
|
+
"@patternfly/react-tokens": "^4.54.1",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.
|
|
46
|
+
"@patternfly/patternfly": "4.184.1",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -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": "
|
|
63
|
+
"gitHead": "fc88ddd5f942598163a34ad5a8df86215cc7a6a5"
|
|
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
|
-
```
|
|
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
|
-
```
|
|
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
|
+
};
|
|
@@ -3,7 +3,7 @@ import { css } from '@patternfly/react-styles';
|
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/DescriptionList/description-list';
|
|
4
4
|
import { formatBreakpointMods } from '../../helpers';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface BreakpointModifiers {
|
|
7
7
|
default?: string;
|
|
8
8
|
md?: string;
|
|
9
9
|
lg?: string;
|
|
@@ -30,7 +30,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
30
30
|
isFluid?: boolean;
|
|
31
31
|
/** Sets the the default placement of description list groups to fill from top to bottom. */
|
|
32
32
|
isFillColumns?: boolean;
|
|
33
|
-
/** Sets the number of columns on the description list */
|
|
33
|
+
/** Sets the number of columns on the description list at various breakpoints */
|
|
34
34
|
columnModifier?: {
|
|
35
35
|
default?: '1Col' | '2Col' | '3Col';
|
|
36
36
|
sm?: '1Col' | '2Col' | '3Col';
|
|
@@ -39,7 +39,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
39
39
|
xl?: '1Col' | '2Col' | '3Col';
|
|
40
40
|
'2xl'?: '1Col' | '2Col' | '3Col';
|
|
41
41
|
};
|
|
42
|
-
/** Indicates how the menu will align at
|
|
42
|
+
/** Indicates how the menu will align at various breakpoints. */
|
|
43
43
|
orientation?: {
|
|
44
44
|
sm?: 'vertical' | 'horizontal';
|
|
45
45
|
md?: 'vertical' | 'horizontal';
|
|
@@ -47,6 +47,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
47
47
|
xl?: 'vertical' | 'horizontal';
|
|
48
48
|
'2xl'?: 'vertical' | 'horizontal';
|
|
49
49
|
};
|
|
50
|
+
/** Sets the minimum column size for the auto-fit (isAutoFit) layout at various breakpoints. */
|
|
50
51
|
autoFitMinModifier?: {
|
|
51
52
|
default?: string;
|
|
52
53
|
sm?: string;
|
|
@@ -55,11 +56,19 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
|
|
|
55
56
|
xl?: string;
|
|
56
57
|
'2xl'?: string;
|
|
57
58
|
};
|
|
59
|
+
/** Sets the horizontal description list's term column width at various breakpoints. */
|
|
60
|
+
horizontalTermWidthModifier?: {
|
|
61
|
+
default?: string;
|
|
62
|
+
sm?: string;
|
|
63
|
+
md?: string;
|
|
64
|
+
lg?: string;
|
|
65
|
+
xl?: string;
|
|
66
|
+
'2xl'?: string;
|
|
67
|
+
};
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const mods = autoFitMinModifier as Partial<{ [k: string]: string }>;
|
|
70
|
+
const setBreakpointModifiers = (prefix: string, modifiers: BreakpointModifiers) => {
|
|
71
|
+
const mods = modifiers as Partial<{ [k: string]: string }>;
|
|
63
72
|
return Object.keys(mods || {}).reduce(
|
|
64
73
|
(acc, curr) =>
|
|
65
74
|
curr === 'default' ? { ...acc, [prefix]: mods[curr] } : { ...acc, [`${prefix}-on-${curr}`]: mods[curr] },
|
|
@@ -79,33 +88,45 @@ export const DescriptionList: React.FunctionComponent<DescriptionListProps> = ({
|
|
|
79
88
|
isFillColumns,
|
|
80
89
|
columnModifier,
|
|
81
90
|
autoFitMinModifier,
|
|
91
|
+
horizontalTermWidthModifier,
|
|
82
92
|
orientation,
|
|
83
93
|
style,
|
|
84
94
|
...props
|
|
85
|
-
}: DescriptionListProps) =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
95
|
+
}: DescriptionListProps) => {
|
|
96
|
+
if (isAutoFit && autoFitMinModifier) {
|
|
97
|
+
style = {
|
|
98
|
+
...style,
|
|
99
|
+
...setBreakpointModifiers('--pf-c-description-list--GridTemplateColumns--min', autoFitMinModifier)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (isHorizontal && horizontalTermWidthModifier) {
|
|
103
|
+
style = {
|
|
104
|
+
...style,
|
|
105
|
+
...setBreakpointModifiers('--pf-c-description-list--m-horizontal__term--width', horizontalTermWidthModifier)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<dl
|
|
111
|
+
className={css(
|
|
112
|
+
styles.descriptionList,
|
|
113
|
+
(isHorizontal || isFluid) && styles.modifiers.horizontal,
|
|
114
|
+
isAutoColumnWidths && styles.modifiers.autoColumnWidths,
|
|
115
|
+
isAutoFit && styles.modifiers.autoFit,
|
|
116
|
+
formatBreakpointMods(columnModifier, styles),
|
|
117
|
+
formatBreakpointMods(orientation, styles),
|
|
118
|
+
isInlineGrid && styles.modifiers.inlineGrid,
|
|
119
|
+
isCompact && styles.modifiers.compact,
|
|
120
|
+
isFluid && styles.modifiers.fluid,
|
|
121
|
+
isFillColumns && styles.modifiers.fillColumns,
|
|
122
|
+
className
|
|
123
|
+
)}
|
|
124
|
+
style={style}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
{children}
|
|
128
|
+
</dl>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
110
131
|
|
|
111
132
|
DescriptionList.displayName = 'DescriptionList';
|
|
@@ -239,34 +239,93 @@ import {
|
|
|
239
239
|
} from '@patternfly/react-core';
|
|
240
240
|
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
241
241
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
</
|
|
242
|
+
const DescriptionListHorizontal = () => {
|
|
243
|
+
return (
|
|
244
|
+
<DescriptionList isHorizontal>
|
|
245
|
+
<DescriptionListGroup>
|
|
246
|
+
<DescriptionListTerm>Name</DescriptionListTerm>
|
|
247
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
248
|
+
</DescriptionListGroup>
|
|
249
|
+
<DescriptionListGroup>
|
|
250
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
251
|
+
<DescriptionListDescription>
|
|
252
|
+
<a href="#">mary-test</a>
|
|
253
|
+
</DescriptionListDescription>
|
|
254
|
+
</DescriptionListGroup>
|
|
255
|
+
<DescriptionListGroup>
|
|
256
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
257
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
258
|
+
</DescriptionListGroup>
|
|
259
|
+
<DescriptionListGroup>
|
|
260
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
261
|
+
<DescriptionListDescription>
|
|
262
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
263
|
+
app=MyApp
|
|
264
|
+
</Button>
|
|
265
|
+
</DescriptionListDescription>
|
|
266
|
+
</DescriptionListGroup>
|
|
267
|
+
<DescriptionListGroup>
|
|
268
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
269
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
270
|
+
</DescriptionListGroup>
|
|
271
|
+
</DescriptionList>
|
|
272
|
+
)
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Horizontal using custom term width modifier
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
import React from 'react';
|
|
280
|
+
import {
|
|
281
|
+
Button,
|
|
282
|
+
DescriptionList,
|
|
283
|
+
DescriptionListTerm,
|
|
284
|
+
DescriptionListText,
|
|
285
|
+
DescriptionListGroup,
|
|
286
|
+
DescriptionListDescription,
|
|
287
|
+
} from '@patternfly/react-core';
|
|
288
|
+
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
289
|
+
|
|
290
|
+
const DescriptionListHorizontalTermWidthModifier = () => {
|
|
291
|
+
return (
|
|
292
|
+
<DescriptionList isHorizontal horizontalTermWidthModifier={{
|
|
293
|
+
default: '12ch',
|
|
294
|
+
sm: '15ch',
|
|
295
|
+
md: '20ch',
|
|
296
|
+
lg: '28ch',
|
|
297
|
+
xl: '30ch',
|
|
298
|
+
'2xl': '35ch'
|
|
299
|
+
}}>
|
|
300
|
+
<DescriptionListGroup>
|
|
301
|
+
<DescriptionListTerm>Name longer than the default term width</DescriptionListTerm>
|
|
302
|
+
<DescriptionListDescription>Example</DescriptionListDescription>
|
|
303
|
+
</DescriptionListGroup>
|
|
304
|
+
<DescriptionListGroup>
|
|
305
|
+
<DescriptionListTerm>Namespace</DescriptionListTerm>
|
|
306
|
+
<DescriptionListDescription>
|
|
307
|
+
<a href="#">mary-test</a>
|
|
308
|
+
</DescriptionListDescription>
|
|
309
|
+
</DescriptionListGroup>
|
|
310
|
+
<DescriptionListGroup>
|
|
311
|
+
<DescriptionListTerm>Labels</DescriptionListTerm>
|
|
312
|
+
<DescriptionListDescription>example</DescriptionListDescription>
|
|
313
|
+
</DescriptionListGroup>
|
|
314
|
+
<DescriptionListGroup>
|
|
315
|
+
<DescriptionListTerm>Pod selector</DescriptionListTerm>
|
|
316
|
+
<DescriptionListDescription>
|
|
317
|
+
<Button variant="link" isInline icon={<PlusCircleIcon />}>
|
|
318
|
+
app=MyApp
|
|
319
|
+
</Button>
|
|
320
|
+
</DescriptionListDescription>
|
|
321
|
+
</DescriptionListGroup>
|
|
322
|
+
<DescriptionListGroup>
|
|
323
|
+
<DescriptionListTerm>Annotation</DescriptionListTerm>
|
|
324
|
+
<DescriptionListDescription>2 Annotations</DescriptionListDescription>
|
|
325
|
+
</DescriptionListGroup>
|
|
326
|
+
</DescriptionList>
|
|
327
|
+
)
|
|
328
|
+
}
|
|
270
329
|
```
|
|
271
330
|
|
|
272
331
|
### Horizontal 2 col
|
|
@@ -21,8 +21,33 @@ export const MenuContent = React.forwardRef((props: MenuContentProps, ref: React
|
|
|
21
21
|
const menuContentRef = React.createRef<HTMLDivElement>();
|
|
22
22
|
const refCallback = (el: HTMLElement, menuId: string, onGetMenuHeight: (menuId: string, height: number) => void) => {
|
|
23
23
|
if (el) {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
let clientHeight = el.clientHeight;
|
|
25
|
+
|
|
26
|
+
// if this menu is a submenu, we need to account for the root menu list's padding and root menu content's border.
|
|
27
|
+
let rootMenuList = null;
|
|
28
|
+
let parentEl = el.closest(`.${styles.menuList}`);
|
|
29
|
+
while (parentEl !== null && parentEl.nodeType === 1) {
|
|
30
|
+
if (parentEl.classList.contains(styles.menuList)) {
|
|
31
|
+
rootMenuList = parentEl;
|
|
32
|
+
}
|
|
33
|
+
parentEl = parentEl.parentElement;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (rootMenuList) {
|
|
37
|
+
const rootMenuListStyles = getComputedStyle(rootMenuList);
|
|
38
|
+
const rootMenuListPaddingOffset =
|
|
39
|
+
parseFloat(rootMenuListStyles.getPropertyValue('padding-top').replace(/px/g, '')) +
|
|
40
|
+
parseFloat(rootMenuListStyles.getPropertyValue('padding-bottom').replace(/px/g, '')) +
|
|
41
|
+
parseFloat(
|
|
42
|
+
getComputedStyle(rootMenuList.parentElement)
|
|
43
|
+
.getPropertyValue('border-bottom-width')
|
|
44
|
+
.replace(/px/g, '')
|
|
45
|
+
);
|
|
46
|
+
clientHeight = clientHeight + rootMenuListPaddingOffset;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
onGetMenuHeight && onGetMenuHeight(menuId, clientHeight);
|
|
50
|
+
getHeight && getHeight(clientHeight.toString());
|
|
26
51
|
}
|
|
27
52
|
return ref || menuContentRef;
|
|
28
53
|
};
|