@patternfly/react-core 4.221.11 → 4.221.14
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 +24 -0
- package/dist/umd/react-core.min.css +70 -70
- package/package.json +5 -5
- package/src/components/ExpandableSection/examples/ExpandableSection.md +7 -187
- package/src/components/ExpandableSection/examples/ExpandableSectionBasic.tsx +16 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionCustomToggle.tsx +29 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionDetached.tsx +26 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionDisclosure.tsx +22 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionIndented.tsx +21 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionUncontrolled.tsx +8 -0
- package/src/components/ExpandableSection/examples/ExpandableSectionUncontrolledDynamicToggleText.tsx +8 -0
- package/src/components/FormSelect/examples/FormSelect.md +5 -291
- package/src/components/FormSelect/examples/FormSelectBasic.tsx +28 -0
- package/src/components/FormSelect/examples/FormSelectDisabled.tsx +28 -0
- package/src/components/FormSelect/examples/FormSelectGrouped.tsx +49 -0
- package/src/components/FormSelect/examples/FormSelectIconSpriteVariant.tsx +57 -0
- package/src/components/FormSelect/examples/FormSelectValidated.tsx +69 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.221.14 (2022-06-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 4.221.13 (2022-06-10)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 4.221.12 (2022-06-10)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
6
30
|
## 4.221.11 (2022-06-09)
|
|
7
31
|
|
|
8
32
|
**Note:** Version bump only for package @patternfly/react-core
|
|
@@ -9135,6 +9135,76 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
9135
9135
|
--pf-c-helper-text__item-text--m-success--Color: var(--pf-global--success-color--100);
|
|
9136
9136
|
}
|
|
9137
9137
|
|
|
9138
|
+
.pf-c-hint {
|
|
9139
|
+
--pf-c-hint--GridRowGap: var(--pf-global--spacer--md);
|
|
9140
|
+
--pf-c-hint--PaddingTop: var(--pf-global--spacer--lg);
|
|
9141
|
+
--pf-c-hint--PaddingRight: var(--pf-global--spacer--lg);
|
|
9142
|
+
--pf-c-hint--PaddingBottom: var(--pf-global--spacer--lg);
|
|
9143
|
+
--pf-c-hint--PaddingLeft: var(--pf-global--spacer--lg);
|
|
9144
|
+
--pf-c-hint--BackgroundColor: var(--pf-global--palette--blue-50);
|
|
9145
|
+
--pf-c-hint--BorderColor: var(--pf-global--palette--blue-100);
|
|
9146
|
+
--pf-c-hint--BorderWidth: var(--pf-global--BorderWidth--sm);
|
|
9147
|
+
--pf-c-hint--BoxShadow: var(--pf-global--BoxShadow--sm);
|
|
9148
|
+
--pf-c-hint--Color: var(--pf-global--Color--100);
|
|
9149
|
+
--pf-c-hint__title--FontSize: var(--pf-global--FontSize--lg);
|
|
9150
|
+
--pf-c-hint__body--FontSize: var(--pf-global--FontSize--md);
|
|
9151
|
+
--pf-c-hint__footer--child--MarginRight: var(--pf-global--spacer--md);
|
|
9152
|
+
--pf-c-hint__actions--MarginLeft: var(--pf-global--spacer--2xl);
|
|
9153
|
+
--pf-c-hint__actions--c-dropdown--MarginTop: calc(var(--pf-global--spacer--form-element) * -1);
|
|
9154
|
+
display: grid;
|
|
9155
|
+
grid-template-columns: 1fr auto;
|
|
9156
|
+
grid-row-gap: var(--pf-c-hint--GridRowGap);
|
|
9157
|
+
padding: var(--pf-c-hint--PaddingTop) var(--pf-c-hint--PaddingRight) var(--pf-c-hint--PaddingBottom) var(--pf-c-hint--PaddingLeft);
|
|
9158
|
+
color: var(--pf-c-hint--Color);
|
|
9159
|
+
background-color: var(--pf-c-hint--BackgroundColor);
|
|
9160
|
+
border: var(--pf-c-hint--BorderWidth) solid var(--pf-c-hint--BorderColor);
|
|
9161
|
+
box-shadow: var(--pf-c-hint--BoxShadow);
|
|
9162
|
+
}
|
|
9163
|
+
|
|
9164
|
+
.pf-c-hint .pf-c-button.pf-m-link.pf-m-inline {
|
|
9165
|
+
text-align: left;
|
|
9166
|
+
white-space: normal;
|
|
9167
|
+
}
|
|
9168
|
+
|
|
9169
|
+
.pf-c-hint__actions {
|
|
9170
|
+
display: inline-grid;
|
|
9171
|
+
grid-auto-flow: column;
|
|
9172
|
+
margin-left: var(--pf-c-hint__actions--MarginLeft);
|
|
9173
|
+
text-align: right;
|
|
9174
|
+
grid-column: 2;
|
|
9175
|
+
grid-row: 1;
|
|
9176
|
+
}
|
|
9177
|
+
|
|
9178
|
+
.pf-c-hint__actions .pf-c-dropdown .pf-c-dropdown__toggle.pf-m-plain {
|
|
9179
|
+
margin-top: var(--pf-c-hint__actions--c-dropdown--MarginTop);
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
.pf-c-hint__actions + .pf-c-hint__body {
|
|
9183
|
+
grid-column: 1;
|
|
9184
|
+
}
|
|
9185
|
+
|
|
9186
|
+
.pf-c-hint__title {
|
|
9187
|
+
font-size: var(--pf-c-hint__title--FontSize);
|
|
9188
|
+
}
|
|
9189
|
+
|
|
9190
|
+
.pf-c-hint__body {
|
|
9191
|
+
grid-column: 1/-1;
|
|
9192
|
+
font-size: var(--pf-c-hint__body--FontSize);
|
|
9193
|
+
}
|
|
9194
|
+
|
|
9195
|
+
.pf-c-hint__footer {
|
|
9196
|
+
grid-column: 1/-1;
|
|
9197
|
+
}
|
|
9198
|
+
|
|
9199
|
+
.pf-c-hint__footer > :not(:last-child) {
|
|
9200
|
+
margin-right: var(--pf-c-hint__footer--child--MarginRight);
|
|
9201
|
+
}
|
|
9202
|
+
|
|
9203
|
+
:where(.pf-theme-dark) .pf-c-hint {
|
|
9204
|
+
--pf-c-hint--BackgroundColor: var(--pf-global--BackgroundColor--400);
|
|
9205
|
+
--pf-c-hint--BorderColor: var(--pf-global--BorderColor--300);
|
|
9206
|
+
}
|
|
9207
|
+
|
|
9138
9208
|
.pf-c-input-group {
|
|
9139
9209
|
--pf-global--Color--100: var(--pf-global--Color--dark-100);
|
|
9140
9210
|
--pf-global--Color--200: var(--pf-global--Color--dark-200);
|
|
@@ -9237,76 +9307,6 @@ label.pf-c-input-group__text {
|
|
|
9237
9307
|
--pf-c-input-group__text--BackgroundColor: transparent;
|
|
9238
9308
|
}
|
|
9239
9309
|
|
|
9240
|
-
.pf-c-hint {
|
|
9241
|
-
--pf-c-hint--GridRowGap: var(--pf-global--spacer--md);
|
|
9242
|
-
--pf-c-hint--PaddingTop: var(--pf-global--spacer--lg);
|
|
9243
|
-
--pf-c-hint--PaddingRight: var(--pf-global--spacer--lg);
|
|
9244
|
-
--pf-c-hint--PaddingBottom: var(--pf-global--spacer--lg);
|
|
9245
|
-
--pf-c-hint--PaddingLeft: var(--pf-global--spacer--lg);
|
|
9246
|
-
--pf-c-hint--BackgroundColor: var(--pf-global--palette--blue-50);
|
|
9247
|
-
--pf-c-hint--BorderColor: var(--pf-global--palette--blue-100);
|
|
9248
|
-
--pf-c-hint--BorderWidth: var(--pf-global--BorderWidth--sm);
|
|
9249
|
-
--pf-c-hint--BoxShadow: var(--pf-global--BoxShadow--sm);
|
|
9250
|
-
--pf-c-hint--Color: var(--pf-global--Color--100);
|
|
9251
|
-
--pf-c-hint__title--FontSize: var(--pf-global--FontSize--lg);
|
|
9252
|
-
--pf-c-hint__body--FontSize: var(--pf-global--FontSize--md);
|
|
9253
|
-
--pf-c-hint__footer--child--MarginRight: var(--pf-global--spacer--md);
|
|
9254
|
-
--pf-c-hint__actions--MarginLeft: var(--pf-global--spacer--2xl);
|
|
9255
|
-
--pf-c-hint__actions--c-dropdown--MarginTop: calc(var(--pf-global--spacer--form-element) * -1);
|
|
9256
|
-
display: grid;
|
|
9257
|
-
grid-template-columns: 1fr auto;
|
|
9258
|
-
grid-row-gap: var(--pf-c-hint--GridRowGap);
|
|
9259
|
-
padding: var(--pf-c-hint--PaddingTop) var(--pf-c-hint--PaddingRight) var(--pf-c-hint--PaddingBottom) var(--pf-c-hint--PaddingLeft);
|
|
9260
|
-
color: var(--pf-c-hint--Color);
|
|
9261
|
-
background-color: var(--pf-c-hint--BackgroundColor);
|
|
9262
|
-
border: var(--pf-c-hint--BorderWidth) solid var(--pf-c-hint--BorderColor);
|
|
9263
|
-
box-shadow: var(--pf-c-hint--BoxShadow);
|
|
9264
|
-
}
|
|
9265
|
-
|
|
9266
|
-
.pf-c-hint .pf-c-button.pf-m-link.pf-m-inline {
|
|
9267
|
-
text-align: left;
|
|
9268
|
-
white-space: normal;
|
|
9269
|
-
}
|
|
9270
|
-
|
|
9271
|
-
.pf-c-hint__actions {
|
|
9272
|
-
display: inline-grid;
|
|
9273
|
-
grid-auto-flow: column;
|
|
9274
|
-
margin-left: var(--pf-c-hint__actions--MarginLeft);
|
|
9275
|
-
text-align: right;
|
|
9276
|
-
grid-column: 2;
|
|
9277
|
-
grid-row: 1;
|
|
9278
|
-
}
|
|
9279
|
-
|
|
9280
|
-
.pf-c-hint__actions .pf-c-dropdown .pf-c-dropdown__toggle.pf-m-plain {
|
|
9281
|
-
margin-top: var(--pf-c-hint__actions--c-dropdown--MarginTop);
|
|
9282
|
-
}
|
|
9283
|
-
|
|
9284
|
-
.pf-c-hint__actions + .pf-c-hint__body {
|
|
9285
|
-
grid-column: 1;
|
|
9286
|
-
}
|
|
9287
|
-
|
|
9288
|
-
.pf-c-hint__title {
|
|
9289
|
-
font-size: var(--pf-c-hint__title--FontSize);
|
|
9290
|
-
}
|
|
9291
|
-
|
|
9292
|
-
.pf-c-hint__body {
|
|
9293
|
-
grid-column: 1/-1;
|
|
9294
|
-
font-size: var(--pf-c-hint__body--FontSize);
|
|
9295
|
-
}
|
|
9296
|
-
|
|
9297
|
-
.pf-c-hint__footer {
|
|
9298
|
-
grid-column: 1/-1;
|
|
9299
|
-
}
|
|
9300
|
-
|
|
9301
|
-
.pf-c-hint__footer > :not(:last-child) {
|
|
9302
|
-
margin-right: var(--pf-c-hint__footer--child--MarginRight);
|
|
9303
|
-
}
|
|
9304
|
-
|
|
9305
|
-
:where(.pf-theme-dark) .pf-c-hint {
|
|
9306
|
-
--pf-c-hint--BackgroundColor: var(--pf-global--BackgroundColor--400);
|
|
9307
|
-
--pf-c-hint--BorderColor: var(--pf-global--BorderColor--300);
|
|
9308
|
-
}
|
|
9309
|
-
|
|
9310
9310
|
.pf-c-jump-links {
|
|
9311
9311
|
--pf-c-jump-links__list--Display: flex;
|
|
9312
9312
|
--pf-c-jump-links__list--Visibility: visible;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.221.
|
|
3
|
+
"version": "4.221.14",
|
|
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.72.
|
|
38
|
-
"@patternfly/react-styles": "^4.71.
|
|
39
|
-
"@patternfly/react-tokens": "^4.73.
|
|
37
|
+
"@patternfly/react-icons": "^4.72.14",
|
|
38
|
+
"@patternfly/react-styles": "^4.71.14",
|
|
39
|
+
"@patternfly/react-tokens": "^4.73.14",
|
|
40
40
|
"focus-trap": "6.9.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": "
|
|
63
|
+
"gitHead": "1fd312ec1387d48aafe63455c73a55c98ea3b120"
|
|
64
64
|
}
|
|
@@ -11,217 +11,37 @@ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle
|
|
|
11
11
|
|
|
12
12
|
### Basic
|
|
13
13
|
|
|
14
|
-
```
|
|
15
|
-
import React from 'react';
|
|
16
|
-
import { ExpandableSection } from '@patternfly/react-core';
|
|
17
|
-
|
|
18
|
-
class SimpleExpandableSection extends React.Component {
|
|
19
|
-
constructor(props) {
|
|
20
|
-
super(props);
|
|
21
|
-
this.state = {
|
|
22
|
-
isExpanded: false
|
|
23
|
-
};
|
|
24
|
-
this.onToggle = isExpanded => {
|
|
25
|
-
this.setState({
|
|
26
|
-
isExpanded
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
const { isExpanded } = this.state;
|
|
33
|
-
return (
|
|
34
|
-
<ExpandableSection
|
|
35
|
-
toggleText={isExpanded ? 'Show less' : 'Show more'}
|
|
36
|
-
onToggle={this.onToggle}
|
|
37
|
-
isExpanded={isExpanded}
|
|
38
|
-
>
|
|
39
|
-
This content is visible only when the component is expanded.
|
|
40
|
-
</ExpandableSection>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
14
|
+
```ts file="ExpandableSectionBasic.tsx"
|
|
44
15
|
```
|
|
45
16
|
|
|
46
17
|
### Uncontrolled
|
|
47
18
|
|
|
48
|
-
```
|
|
49
|
-
import React from 'react';
|
|
50
|
-
import { ExpandableSection } from '@patternfly/react-core';
|
|
51
|
-
|
|
52
|
-
<ExpandableSection toggleText="Show more">
|
|
53
|
-
This content is visible only when the component is expanded.
|
|
54
|
-
</ExpandableSection>;
|
|
19
|
+
```ts file="ExpandableSectionUncontrolled.tsx"
|
|
55
20
|
```
|
|
56
21
|
|
|
57
22
|
### Uncontrolled with dynamic toggle text
|
|
58
23
|
|
|
59
|
-
```
|
|
60
|
-
import React from 'react';
|
|
61
|
-
import { ExpandableSection } from '@patternfly/react-core';
|
|
62
|
-
|
|
63
|
-
<ExpandableSection toggleTextExpanded="Show less" toggleTextCollapsed="Show more">
|
|
64
|
-
This content is visible only when the component is expanded.
|
|
65
|
-
</ExpandableSection>;
|
|
24
|
+
```ts file="ExpandableSectionUncontrolledDynamicToggleText.tsx"
|
|
66
25
|
```
|
|
67
26
|
|
|
68
27
|
### Detached
|
|
69
28
|
|
|
70
|
-
```
|
|
71
|
-
import React from 'react';
|
|
72
|
-
import { ExpandableSection, ExpandableSectionToggle, Stack, StackItem } from '@patternfly/react-core';
|
|
73
|
-
|
|
74
|
-
class DetachedExpandableSection extends React.Component {
|
|
75
|
-
constructor(props) {
|
|
76
|
-
super(props);
|
|
77
|
-
this.state = {
|
|
78
|
-
isExpanded: false
|
|
79
|
-
};
|
|
80
|
-
this.onToggle = isExpanded => {
|
|
81
|
-
this.setState({
|
|
82
|
-
isExpanded
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
render() {
|
|
88
|
-
const { isExpanded } = this.state;
|
|
89
|
-
const contentId = 'detached-toggle-content';
|
|
90
|
-
return (
|
|
91
|
-
<Stack hasGutter>
|
|
92
|
-
<StackItem>
|
|
93
|
-
<ExpandableSection isExpanded={isExpanded} isDetached contentId={contentId}>
|
|
94
|
-
This content is visible only when the component is expanded.
|
|
95
|
-
</ExpandableSection>
|
|
96
|
-
</StackItem>
|
|
97
|
-
<StackItem>
|
|
98
|
-
<ExpandableSectionToggle
|
|
99
|
-
isExpanded={isExpanded}
|
|
100
|
-
onToggle={this.onToggle}
|
|
101
|
-
contentId={contentId}
|
|
102
|
-
direction="up"
|
|
103
|
-
>
|
|
104
|
-
{isExpanded ? 'Show less' : 'Show more'}
|
|
105
|
-
</ExpandableSectionToggle>
|
|
106
|
-
</StackItem>
|
|
107
|
-
</Stack>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
29
|
+
```ts file="ExpandableSectionDetached.tsx"
|
|
111
30
|
```
|
|
112
31
|
|
|
113
32
|
### Disclosure variation
|
|
114
33
|
|
|
115
|
-
```
|
|
116
|
-
import React from 'react';
|
|
117
|
-
import { ExpandableSection } from '@patternfly/react-core';
|
|
118
|
-
|
|
119
|
-
class DisclosureExpandableSection extends React.Component {
|
|
120
|
-
constructor(props) {
|
|
121
|
-
super(props);
|
|
122
|
-
this.state = {
|
|
123
|
-
isExpanded: false
|
|
124
|
-
};
|
|
125
|
-
this.onToggle = isExpanded => {
|
|
126
|
-
this.setState({
|
|
127
|
-
isExpanded
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
render() {
|
|
133
|
-
const { isExpanded } = this.state;
|
|
134
|
-
return (
|
|
135
|
-
<ExpandableSection
|
|
136
|
-
toggleText={isExpanded ? 'Show less' : 'Show more'}
|
|
137
|
-
onToggle={this.onToggle}
|
|
138
|
-
isExpanded={isExpanded}
|
|
139
|
-
displaySize="large"
|
|
140
|
-
isWidthLimited
|
|
141
|
-
>
|
|
142
|
-
This content is visible only when the component is expanded.
|
|
143
|
-
</ExpandableSection>
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
34
|
+
```ts file="ExpandableSectionDisclosure.tsx"
|
|
147
35
|
```
|
|
148
36
|
|
|
149
37
|
### Indented
|
|
150
38
|
|
|
151
|
-
```
|
|
152
|
-
import React from 'react';
|
|
153
|
-
import { ExpandableSection } from '@patternfly/react-core';
|
|
154
|
-
|
|
155
|
-
class SimpleExpandableSection extends React.Component {
|
|
156
|
-
constructor(props) {
|
|
157
|
-
super(props);
|
|
158
|
-
this.state = {
|
|
159
|
-
isExpanded: false
|
|
160
|
-
};
|
|
161
|
-
this.onToggle = isExpanded => {
|
|
162
|
-
this.setState({
|
|
163
|
-
isExpanded
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
render() {
|
|
169
|
-
const { isExpanded } = this.state;
|
|
170
|
-
return (
|
|
171
|
-
<ExpandableSection
|
|
172
|
-
toggleText={isExpanded ? 'Show less' : 'Show more'}
|
|
173
|
-
onToggle={this.onToggle}
|
|
174
|
-
isExpanded={isExpanded}
|
|
175
|
-
isIndented={true}
|
|
176
|
-
>
|
|
177
|
-
This content is visible only when the component is expanded.
|
|
178
|
-
</ExpandableSection>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
39
|
+
```ts file="ExpandableSectionIndented.tsx"
|
|
182
40
|
```
|
|
183
41
|
|
|
184
42
|
### With custom toggle content
|
|
185
43
|
|
|
186
44
|
By using the `toggleContent` prop, you can pass in content other than a simple string such as an icon or a badge. When passing in custom content in this way, you should not pass in any interactive element such as a button.
|
|
187
45
|
|
|
188
|
-
```
|
|
189
|
-
import React from "react";
|
|
190
|
-
import { ExpandableSection, Badge } from "@patternfly/react-core";
|
|
191
|
-
import CheckCircleIcon from "@patternfly/react-icons/dist/esm/icons/check-circle-icon";
|
|
192
|
-
|
|
193
|
-
class CustomExpandableSection extends React.Component {
|
|
194
|
-
constructor(props) {
|
|
195
|
-
super(props);
|
|
196
|
-
this.state = {
|
|
197
|
-
isExpanded: false
|
|
198
|
-
};
|
|
199
|
-
this.onToggle = (isExpanded) => {
|
|
200
|
-
this.setState({
|
|
201
|
-
isExpanded
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
render() {
|
|
207
|
-
const { isExpanded } = this.state;
|
|
208
|
-
return (
|
|
209
|
-
<ExpandableSection
|
|
210
|
-
toggleContent={
|
|
211
|
-
<div>
|
|
212
|
-
<span>You can also use icons </span>
|
|
213
|
-
<CheckCircleIcon />
|
|
214
|
-
<span> or badges </span>
|
|
215
|
-
<Badge isRead={true}>4</Badge>
|
|
216
|
-
<span> !</span>
|
|
217
|
-
</div>
|
|
218
|
-
}
|
|
219
|
-
onToggle={this.onToggle}
|
|
220
|
-
isExpanded={isExpanded}
|
|
221
|
-
>
|
|
222
|
-
This content is visible only when the component is expanded.
|
|
223
|
-
</ExpandableSection>
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
46
|
+
```ts file="ExpandableSectionCustomToggle.tsx"
|
|
227
47
|
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionBasic: React.FunctionComponent = () => {
|
|
5
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isExpanded: boolean) => {
|
|
8
|
+
setIsExpanded(isExpanded);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ExpandableSection toggleText={isExpanded ? 'Show less' : 'Show more'} onToggle={onToggle} isExpanded={isExpanded}>
|
|
13
|
+
This content is visible only when the component is expanded.
|
|
14
|
+
</ExpandableSection>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection, Badge } from '@patternfly/react-core';
|
|
3
|
+
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
4
|
+
|
|
5
|
+
export const ExpandableSectionCustomToggle: React.FunctionComponent = () => {
|
|
6
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const onToggle = (isExpanded: boolean) => {
|
|
9
|
+
setIsExpanded(isExpanded);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<ExpandableSection
|
|
14
|
+
toggleContent={
|
|
15
|
+
<div>
|
|
16
|
+
<span>You can also use icons </span>
|
|
17
|
+
<CheckCircleIcon />
|
|
18
|
+
<span> or badges </span>
|
|
19
|
+
<Badge isRead={true}>4</Badge>
|
|
20
|
+
<span> !</span>
|
|
21
|
+
</div>
|
|
22
|
+
}
|
|
23
|
+
onToggle={onToggle}
|
|
24
|
+
isExpanded={isExpanded}
|
|
25
|
+
>
|
|
26
|
+
This content is visible only when the component is expanded.
|
|
27
|
+
</ExpandableSection>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection, ExpandableSectionToggle, Stack, StackItem } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionDetached: React.FunctionComponent = () => {
|
|
5
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isExpanded: boolean) => {
|
|
8
|
+
setIsExpanded(isExpanded);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const contentId = 'detached-toggle-content';
|
|
12
|
+
return (
|
|
13
|
+
<Stack hasGutter>
|
|
14
|
+
<StackItem>
|
|
15
|
+
<ExpandableSection isExpanded={isExpanded} isDetached contentId={contentId}>
|
|
16
|
+
This content is visible only when the component is expanded.
|
|
17
|
+
</ExpandableSection>
|
|
18
|
+
</StackItem>
|
|
19
|
+
<StackItem>
|
|
20
|
+
<ExpandableSectionToggle isExpanded={isExpanded} onToggle={onToggle} contentId={contentId} direction="up">
|
|
21
|
+
{isExpanded ? 'Show less' : 'Show more'}
|
|
22
|
+
</ExpandableSectionToggle>
|
|
23
|
+
</StackItem>
|
|
24
|
+
</Stack>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionDisclosure: React.FunctionComponent = () => {
|
|
5
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isExpanded: boolean) => {
|
|
8
|
+
setIsExpanded(isExpanded);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ExpandableSection
|
|
13
|
+
toggleText={isExpanded ? 'Show less' : 'Show more'}
|
|
14
|
+
onToggle={onToggle}
|
|
15
|
+
isExpanded={isExpanded}
|
|
16
|
+
displaySize="large"
|
|
17
|
+
isWidthLimited
|
|
18
|
+
>
|
|
19
|
+
This content is visible only when the component is expanded.
|
|
20
|
+
</ExpandableSection>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionIndented: React.FunctionComponent = () => {
|
|
5
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isExpanded: boolean) => {
|
|
8
|
+
setIsExpanded(isExpanded);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<ExpandableSection
|
|
13
|
+
toggleText={isExpanded ? 'Show less' : 'Show more'}
|
|
14
|
+
onToggle={onToggle}
|
|
15
|
+
isExpanded={isExpanded}
|
|
16
|
+
isIndented
|
|
17
|
+
>
|
|
18
|
+
This content is visible only when the component is expanded.
|
|
19
|
+
</ExpandableSection>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionUncontrolled: React.FunctionComponent = () => (
|
|
5
|
+
<ExpandableSection toggleText="Show more">
|
|
6
|
+
This content is visible only when the component is expanded.
|
|
7
|
+
</ExpandableSection>
|
|
8
|
+
);
|
package/src/components/ExpandableSection/examples/ExpandableSectionUncontrolledDynamicToggleText.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ExpandableSection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ExpandableSectionUncontrolledDynamicToggle: React.FunctionComponent = () => (
|
|
5
|
+
<ExpandableSection toggleTextExpanded="Show less" toggleTextCollapsed="Show more">
|
|
6
|
+
This content is visible only when the component is expanded.
|
|
7
|
+
</ExpandableSection>
|
|
8
|
+
);
|
|
@@ -9,310 +9,24 @@ ouia: true
|
|
|
9
9
|
## Examples
|
|
10
10
|
|
|
11
11
|
### Basic
|
|
12
|
-
```
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
15
|
-
|
|
16
|
-
class FormSelectInput extends React.Component {
|
|
17
|
-
constructor(props) {
|
|
18
|
-
super(props);
|
|
19
|
-
this.state = {
|
|
20
|
-
value: 'mrs'
|
|
21
|
-
};
|
|
22
|
-
this.onChange = (value, event) => {
|
|
23
|
-
this.setState({ value });
|
|
24
|
-
};
|
|
25
|
-
this.options = [
|
|
26
|
-
{ value: 'please choose', label: 'Select one', disabled: true },
|
|
27
|
-
{ value: 'mr', label: 'Mr', disabled: false },
|
|
28
|
-
{ value: 'miss', label: 'Miss', disabled: false },
|
|
29
|
-
{ value: 'mrs', label: 'Mrs', disabled: false },
|
|
30
|
-
{ value: 'ms', label: 'Ms', disabled: false },
|
|
31
|
-
{ value: 'dr', label: 'Dr', disabled: false },
|
|
32
|
-
{ value: 'other', label: 'Other', disabled: false }
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
render() {
|
|
37
|
-
return (
|
|
38
|
-
<FormSelect value={this.state.value} onChange={this.onChange} aria-label="FormSelect Input">
|
|
39
|
-
{this.options.map((option, index) => (
|
|
40
|
-
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
41
|
-
))}
|
|
42
|
-
</FormSelect>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Invalid
|
|
49
|
-
```js
|
|
50
|
-
import React from 'react';
|
|
51
|
-
import { FormSelect, FormSelectOption, FormSelectOptionGroup, ValidatedOptions } from '@patternfly/react-core';
|
|
52
|
-
|
|
53
|
-
class FormSelectInputInvalid extends React.Component {
|
|
54
|
-
constructor(props) {
|
|
55
|
-
super(props);
|
|
56
|
-
this.state = {
|
|
57
|
-
value: '',
|
|
58
|
-
validated: ValidatedOptions.default
|
|
59
|
-
};
|
|
60
|
-
this.isEmpty = () => this.state.value !== '';
|
|
61
|
-
this.onChange = (value, event) => {
|
|
62
|
-
const validated = this.isEmpty() && ValidatedOptions.error
|
|
63
|
-
this.setState({ value, validated });
|
|
64
|
-
};
|
|
65
|
-
this.options = [
|
|
66
|
-
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
67
|
-
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
68
|
-
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
69
|
-
{ value: '3', label: 'Three', disabled: false, isPlaceholder: false }
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
render() {
|
|
74
|
-
const { value, validated } = this.state;
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<FormSelect
|
|
78
|
-
validated={validated}
|
|
79
|
-
value={value}
|
|
80
|
-
onChange={this.onChange}
|
|
81
|
-
aria-label="FormSelect Input"
|
|
82
|
-
>
|
|
83
|
-
{this.options.map((option, index) => (
|
|
84
|
-
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} isPlaceholder={option.isPlaceholder} />
|
|
85
|
-
))}
|
|
86
|
-
</FormSelect>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
12
|
+
```ts file='./FormSelectBasic.tsx'
|
|
90
13
|
```
|
|
91
14
|
|
|
92
15
|
### Validated
|
|
93
|
-
```
|
|
94
|
-
import React from 'react';
|
|
95
|
-
import { Form, FormGroup, FormSelect, FormSelectOption, FormSelectOptionGroup, ValidatedOptions } from '@patternfly/react-core';
|
|
96
|
-
|
|
97
|
-
class FormSelectInputInvalid extends React.Component {
|
|
98
|
-
constructor(props) {
|
|
99
|
-
super(props);
|
|
100
|
-
this.state = {
|
|
101
|
-
value: '',
|
|
102
|
-
invalidText: 'You must choose something',
|
|
103
|
-
validated: ValidatedOptions.default
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
this.simulateNetworkCall = callback => {
|
|
107
|
-
setTimeout(callback, 2000);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
this.onChange = (value, event) => {
|
|
111
|
-
this.setState(
|
|
112
|
-
{ value, validated: ValidatedOptions.default, helperText: 'Validating...' },
|
|
113
|
-
this.simulateNetworkCall(() => {
|
|
114
|
-
if (value === '3') {
|
|
115
|
-
this.setState({ validated: ValidatedOptions.success, helperText: 'You chose wisely' });
|
|
116
|
-
} else if (value === '') {
|
|
117
|
-
this.setState({ validated: ValidatedOptions.warning, helperText: 'You must select a value' });
|
|
118
|
-
} else {
|
|
119
|
-
this.setState({ validated: ValidatedOptions.error, invalidText: 'You must chose Three (thought that was obvious)' });
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
this.options = [
|
|
126
|
-
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
127
|
-
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
128
|
-
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
129
|
-
{ value: '3', label: 'Three - the only valid option', disabled: false, isPlaceholder: false }
|
|
130
|
-
];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
render() {
|
|
134
|
-
const { value, validated, helperText, invalidText } = this.state;
|
|
135
|
-
return (
|
|
136
|
-
<Form>
|
|
137
|
-
<FormGroup
|
|
138
|
-
label="Selection:"
|
|
139
|
-
type="string"
|
|
140
|
-
helperText={helperText}
|
|
141
|
-
helperTextInvalid={invalidText}
|
|
142
|
-
fieldId="selection"
|
|
143
|
-
validated={validated}
|
|
144
|
-
>
|
|
145
|
-
<FormSelect
|
|
146
|
-
id="selection"
|
|
147
|
-
validated={validated}
|
|
148
|
-
value={value}
|
|
149
|
-
onChange={this.onChange}
|
|
150
|
-
aria-label="FormSelect Input"
|
|
151
|
-
>
|
|
152
|
-
{this.options.map((option, index) => (
|
|
153
|
-
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} isPlaceholder={option.isPlaceholder} />
|
|
154
|
-
))}
|
|
155
|
-
</FormSelect>
|
|
156
|
-
</FormGroup>
|
|
157
|
-
</Form>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
16
|
+
```ts file='./FormSelectValidated.tsx'
|
|
161
17
|
```
|
|
162
18
|
|
|
163
19
|
### Disabled
|
|
164
|
-
```
|
|
165
|
-
import React from 'react';
|
|
166
|
-
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
167
|
-
|
|
168
|
-
class FormSelectInputDisabled extends React.Component {
|
|
169
|
-
constructor(props) {
|
|
170
|
-
super(props);
|
|
171
|
-
this.state = {
|
|
172
|
-
value: 'mrs'
|
|
173
|
-
};
|
|
174
|
-
this.onChange = (value, event) => {
|
|
175
|
-
this.setState({ value });
|
|
176
|
-
};
|
|
177
|
-
this.options = [
|
|
178
|
-
{ value: 'please choose', label: 'Select one', disabled: true },
|
|
179
|
-
{ value: 'mr', label: 'Mr', disabled: false },
|
|
180
|
-
{ value: 'miss', label: 'Miss', disabled: false },
|
|
181
|
-
{ value: 'mrs', label: 'Mrs', disabled: false },
|
|
182
|
-
{ value: 'ms', label: 'Ms', disabled: false },
|
|
183
|
-
{ value: 'dr', label: 'Dr', disabled: false },
|
|
184
|
-
{ value: 'other', label: 'Other', disabled: false }
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
render() {
|
|
189
|
-
return (
|
|
190
|
-
<FormSelect value={this.state.value} onChange={this.onChange} isDisabled aria-label="FormSelect Input">
|
|
191
|
-
{this.options.map((option, index) => (
|
|
192
|
-
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
193
|
-
))}
|
|
194
|
-
</FormSelect>
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
20
|
+
```ts file='./FormSelectDisabled.tsx'
|
|
198
21
|
```
|
|
199
22
|
|
|
200
23
|
### Grouped
|
|
201
|
-
```
|
|
202
|
-
import React from 'react';
|
|
203
|
-
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
204
|
-
|
|
205
|
-
class FormSelectInputGrouped extends React.Component {
|
|
206
|
-
constructor(props) {
|
|
207
|
-
super(props);
|
|
208
|
-
this.state = {
|
|
209
|
-
value: '2'
|
|
210
|
-
};
|
|
211
|
-
this.onChange = (value, event) => {
|
|
212
|
-
this.setState({ value });
|
|
213
|
-
};
|
|
214
|
-
this.groups = [
|
|
215
|
-
{
|
|
216
|
-
groupLabel: 'Group1',
|
|
217
|
-
disabled: false,
|
|
218
|
-
options: [
|
|
219
|
-
{ value: '1', label: 'The first option', disabled: false },
|
|
220
|
-
{ value: '2', label: 'Second option is selected by default', disabled: false }
|
|
221
|
-
]
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
groupLabel: 'Group2',
|
|
225
|
-
disabled: false,
|
|
226
|
-
options: [
|
|
227
|
-
{ value: '3', label: 'The third option', disabled: false },
|
|
228
|
-
{ value: '4', label: 'The fourth option', disabled: false }
|
|
229
|
-
]
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
groupLabel: 'Group3',
|
|
233
|
-
disabled: true,
|
|
234
|
-
options: [
|
|
235
|
-
{ value: '5', label: 'The fifth option', disabled: false },
|
|
236
|
-
{ value: '6', label: 'The sixth option', disabled: false }
|
|
237
|
-
]
|
|
238
|
-
}
|
|
239
|
-
];
|
|
240
|
-
this.getOptionLbl = option => option.label;
|
|
241
|
-
this.getOptionVal = option => option.value;
|
|
242
|
-
this.getOptionsGroupLbl = group => group && group.groupLabel;
|
|
243
|
-
this.getGroupOptions = group => group && group.options;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
render() {
|
|
247
|
-
return (
|
|
248
|
-
<FormSelect value={this.state.value} onChange={this.onChange} aria-label="FormSelect Input">
|
|
249
|
-
{this.groups.map((group, index) => (
|
|
250
|
-
<FormSelectOptionGroup isDisabled={group.disabled} key={index} label={group.groupLabel}>
|
|
251
|
-
{group.options.map((option, i) => (
|
|
252
|
-
<FormSelectOption isDisabled={option.disabled} key={i} value={option.value} label={option.label} />
|
|
253
|
-
))}
|
|
254
|
-
</FormSelectOptionGroup>
|
|
255
|
-
))}
|
|
256
|
-
</FormSelect>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
24
|
+
```ts file='./FormSelectGrouped.tsx'
|
|
260
25
|
```
|
|
261
26
|
|
|
262
27
|
### Icon sprite variant
|
|
263
28
|
|
|
264
29
|
**Note:** The dropdown toggle icon is applied as a background image to the form element. By default, the image URLs for these icons are data URIs. However, there may be cases where data URIs are not ideal, such as in an application with a content security policy that disallows data URIs for security reasons. The `isIconSprite` variation changes the icon source to an external SVG file that serves as a sprite for all of the supported icons.
|
|
265
30
|
|
|
266
|
-
```
|
|
267
|
-
import React from 'react';
|
|
268
|
-
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
269
|
-
|
|
270
|
-
class FormSelectIconSpriteInput extends React.Component {
|
|
271
|
-
constructor(props) {
|
|
272
|
-
super(props);
|
|
273
|
-
this.state = {
|
|
274
|
-
value: '',
|
|
275
|
-
validated: ValidatedOptions.default
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
this.onChange = (value, event) => {
|
|
279
|
-
if (value === '3') {
|
|
280
|
-
this.setState({ value, validated: ValidatedOptions.success, helperText: 'You chose wisely' });
|
|
281
|
-
} else if (value === '') {
|
|
282
|
-
this.setState({ value, validated: ValidatedOptions.warning, helperText: 'You must select a value' });
|
|
283
|
-
} else {
|
|
284
|
-
this.setState({
|
|
285
|
-
value,
|
|
286
|
-
validated: ValidatedOptions.error,
|
|
287
|
-
invalidText: 'You must chose Three (thought that was obvious)'
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
this.options = [
|
|
293
|
-
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
294
|
-
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
295
|
-
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
296
|
-
{ value: '3', label: 'Three - the only valid option', disabled: false, isPlaceholder: false }
|
|
297
|
-
];
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
render() {
|
|
301
|
-
const { value, validated, helperText, invalidText } = this.state;
|
|
302
|
-
|
|
303
|
-
return (
|
|
304
|
-
<FormSelect
|
|
305
|
-
validated={validated}
|
|
306
|
-
isIconSprite
|
|
307
|
-
value={value}
|
|
308
|
-
onChange={this.onChange}
|
|
309
|
-
aria-label="FormSelect Input"
|
|
310
|
-
>
|
|
311
|
-
{this.options.map((option, index) => (
|
|
312
|
-
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
313
|
-
))}
|
|
314
|
-
</FormSelect>
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
31
|
+
```ts file='./FormSelectIconSpriteVariant.tsx' isBeta
|
|
318
32
|
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormSelect, FormSelectOption } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FormSelectBasic: React.FunctionComponent = () => {
|
|
5
|
+
const [formSelectValue, setFormSelectValue] = React.useState('mrs');
|
|
6
|
+
|
|
7
|
+
const onChange = (value: string) => {
|
|
8
|
+
setFormSelectValue(value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const options = [
|
|
12
|
+
{ value: 'please choose', label: 'Select one', disabled: true },
|
|
13
|
+
{ value: 'mr', label: 'Mr', disabled: false },
|
|
14
|
+
{ value: 'miss', label: 'Miss', disabled: false },
|
|
15
|
+
{ value: 'mrs', label: 'Mrs', disabled: false },
|
|
16
|
+
{ value: 'ms', label: 'Ms', disabled: false },
|
|
17
|
+
{ value: 'dr', label: 'Dr', disabled: false },
|
|
18
|
+
{ value: 'other', label: 'Other', disabled: false }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<FormSelect value={formSelectValue} onChange={onChange} aria-label="FormSelect Input">
|
|
23
|
+
{options.map((option, index) => (
|
|
24
|
+
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
25
|
+
))}
|
|
26
|
+
</FormSelect>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormSelect, FormSelectOption } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FormSelectDisabled: React.FunctionComponent = () => {
|
|
5
|
+
const [formSelectValue, setFormSelectValue] = React.useState('mrs');
|
|
6
|
+
|
|
7
|
+
const onChange = (value: string) => {
|
|
8
|
+
setFormSelectValue(value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const options = [
|
|
12
|
+
{ value: 'please choose', label: 'Select one', disabled: true },
|
|
13
|
+
{ value: 'mr', label: 'Mr', disabled: false },
|
|
14
|
+
{ value: 'miss', label: 'Miss', disabled: false },
|
|
15
|
+
{ value: 'mrs', label: 'Mrs', disabled: false },
|
|
16
|
+
{ value: 'ms', label: 'Ms', disabled: false },
|
|
17
|
+
{ value: 'dr', label: 'Dr', disabled: false },
|
|
18
|
+
{ value: 'other', label: 'Other', disabled: false }
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<FormSelect value={formSelectValue} onChange={onChange} isDisabled aria-label="FormSelect Input">
|
|
23
|
+
{options.map((option, index) => (
|
|
24
|
+
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
25
|
+
))}
|
|
26
|
+
</FormSelect>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FormSelectGrouped: React.FunctionComponent = () => {
|
|
5
|
+
const [formSelectValue, setFormSelectValue] = React.useState('2');
|
|
6
|
+
|
|
7
|
+
const onChange = (value: string) => {
|
|
8
|
+
setFormSelectValue(value);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const groups = [
|
|
12
|
+
{
|
|
13
|
+
groupLabel: 'Group1',
|
|
14
|
+
disabled: false,
|
|
15
|
+
options: [
|
|
16
|
+
{ value: '1', label: 'The first option', disabled: false },
|
|
17
|
+
{ value: '2', label: 'Second option is selected by default', disabled: false }
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
groupLabel: 'Group2',
|
|
22
|
+
disabled: false,
|
|
23
|
+
options: [
|
|
24
|
+
{ value: '3', label: 'The third option', disabled: false },
|
|
25
|
+
{ value: '4', label: 'The fourth option', disabled: false }
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
groupLabel: 'Group3',
|
|
30
|
+
disabled: true,
|
|
31
|
+
options: [
|
|
32
|
+
{ value: '5', label: 'The fifth option', disabled: false },
|
|
33
|
+
{ value: '6', label: 'The sixth option', disabled: false }
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<FormSelect value={formSelectValue} onChange={onChange} aria-label="FormSelect Input">
|
|
40
|
+
{groups.map((group, index) => (
|
|
41
|
+
<FormSelectOptionGroup isDisabled={group.disabled} key={index} label={group.groupLabel}>
|
|
42
|
+
{group.options.map((option, i) => (
|
|
43
|
+
<FormSelectOption isDisabled={option.disabled} key={i} value={option.value} label={option.label} />
|
|
44
|
+
))}
|
|
45
|
+
</FormSelectOptionGroup>
|
|
46
|
+
))}
|
|
47
|
+
</FormSelect>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form, FormGroup, FormSelect, FormSelectOption, ValidatedOptions } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FormSelectIconSpriteVariant: React.FunctionComponent = () => {
|
|
5
|
+
const [formSelectValue, setFormSelectValue] = React.useState('');
|
|
6
|
+
const [validated, setValidated] = React.useState<ValidatedOptions>(ValidatedOptions.default);
|
|
7
|
+
const [invalidText, setInvalidText] = React.useState('You must choose something');
|
|
8
|
+
const [helperText, setHelperText] = React.useState('');
|
|
9
|
+
|
|
10
|
+
const onChange = (value: string) => {
|
|
11
|
+
if (value === '3') {
|
|
12
|
+
setFormSelectValue(value);
|
|
13
|
+
setValidated(ValidatedOptions.success);
|
|
14
|
+
setHelperText('You chose wisely');
|
|
15
|
+
} else if (value === '') {
|
|
16
|
+
setFormSelectValue(value);
|
|
17
|
+
setValidated(ValidatedOptions.warning);
|
|
18
|
+
setHelperText('You must select a value');
|
|
19
|
+
} else {
|
|
20
|
+
setFormSelectValue(value);
|
|
21
|
+
setValidated(ValidatedOptions.error);
|
|
22
|
+
setInvalidText('You must chose Three (thought that was obvious)');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const options = [
|
|
27
|
+
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
28
|
+
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
29
|
+
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
30
|
+
{ value: '3', label: 'Three - the only valid option', disabled: false, isPlaceholder: false }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Form>
|
|
35
|
+
<FormGroup
|
|
36
|
+
label="Selection:"
|
|
37
|
+
type="string"
|
|
38
|
+
helperText={helperText}
|
|
39
|
+
helperTextInvalid={invalidText}
|
|
40
|
+
fieldId="selection"
|
|
41
|
+
validated={validated}
|
|
42
|
+
>
|
|
43
|
+
<FormSelect
|
|
44
|
+
validated={validated}
|
|
45
|
+
isIconSprite
|
|
46
|
+
value={formSelectValue}
|
|
47
|
+
onChange={onChange}
|
|
48
|
+
aria-label="FormSelect Input"
|
|
49
|
+
>
|
|
50
|
+
{options.map((option, index) => (
|
|
51
|
+
<FormSelectOption isDisabled={option.disabled} key={index} value={option.value} label={option.label} />
|
|
52
|
+
))}
|
|
53
|
+
</FormSelect>
|
|
54
|
+
</FormGroup>
|
|
55
|
+
</Form>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Form, FormGroup, FormSelect, FormSelectOption, ValidatedOptions } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const FormSelectValidated: React.FunctionComponent = () => {
|
|
5
|
+
const [formValue, setFormValue] = React.useState('');
|
|
6
|
+
const [invalidText, setInvalidText] = React.useState('You must choose something');
|
|
7
|
+
const [helperText, setHelperText] = React.useState('');
|
|
8
|
+
const [validated, setValidated] = React.useState<ValidatedOptions>(ValidatedOptions.default);
|
|
9
|
+
|
|
10
|
+
const simulateNetworkCall = (callback: () => void) => {
|
|
11
|
+
setTimeout(callback, 2000);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onChange = (value: string) => {
|
|
15
|
+
setFormValue(value);
|
|
16
|
+
setValidated(ValidatedOptions.default);
|
|
17
|
+
setHelperText('Validating...');
|
|
18
|
+
simulateNetworkCall(() => {
|
|
19
|
+
if (value === '3') {
|
|
20
|
+
setValidated(ValidatedOptions.success);
|
|
21
|
+
setHelperText('You chose wisely');
|
|
22
|
+
} else if (value === '') {
|
|
23
|
+
setValidated(ValidatedOptions.warning);
|
|
24
|
+
setHelperText('You must select a value');
|
|
25
|
+
} else {
|
|
26
|
+
setValidated(ValidatedOptions.error);
|
|
27
|
+
setInvalidText('You must chose Three (thought that was obvious)');
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const options = [
|
|
33
|
+
{ value: '', label: 'Select a number', disabled: false, isPlaceholder: true },
|
|
34
|
+
{ value: '1', label: 'One', disabled: false, isPlaceholder: false },
|
|
35
|
+
{ value: '2', label: 'Two', disabled: false, isPlaceholder: false },
|
|
36
|
+
{ value: '3', label: 'Three - the only valid option', disabled: false, isPlaceholder: false }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Form>
|
|
41
|
+
<FormGroup
|
|
42
|
+
label="Selection:"
|
|
43
|
+
type="string"
|
|
44
|
+
helperText={helperText}
|
|
45
|
+
helperTextInvalid={invalidText}
|
|
46
|
+
fieldId="selection"
|
|
47
|
+
validated={validated}
|
|
48
|
+
>
|
|
49
|
+
<FormSelect
|
|
50
|
+
id="selection"
|
|
51
|
+
validated={validated}
|
|
52
|
+
value={formValue}
|
|
53
|
+
onChange={onChange}
|
|
54
|
+
aria-label="FormSelect Input"
|
|
55
|
+
>
|
|
56
|
+
{options.map((option, index) => (
|
|
57
|
+
<FormSelectOption
|
|
58
|
+
isDisabled={option.disabled}
|
|
59
|
+
key={index}
|
|
60
|
+
value={option.value}
|
|
61
|
+
label={option.label}
|
|
62
|
+
isPlaceholder={option.isPlaceholder}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</FormSelect>
|
|
66
|
+
</FormGroup>
|
|
67
|
+
</Form>
|
|
68
|
+
);
|
|
69
|
+
};
|