@patternfly/react-core 4.175.16 → 4.178.0
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 +52 -0
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts +3 -1
- package/dist/esm/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.js +4 -4
- package/dist/esm/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.d.ts +3 -1
- package/dist/esm/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Toggle.js +8 -3
- package/dist/esm/components/Dropdown/Toggle.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +2 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover/Popover.js +2 -22
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +2 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +7 -9
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js +9 -6
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts +3 -1
- package/dist/js/components/Dropdown/DropdownToggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.js +4 -4
- package/dist/js/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/js/components/Dropdown/Toggle.d.ts +3 -1
- package/dist/js/components/Dropdown/Toggle.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Toggle.js +8 -3
- package/dist/js/components/Dropdown/Toggle.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +2 -1
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/Popover/Popover.d.ts.map +1 -1
- package/dist/js/components/Popover/Popover.js +2 -22
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +2 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +7 -9
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js +9 -6
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/umd/react-core.css +191 -191
- package/dist/umd/react-core.js +32 -45
- package/dist/umd/react-core.min.css +69 -69
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Alert/examples/Alert.md +201 -382
- package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +61 -0
- package/src/components/Alert/examples/AlertDynamicLiveRegion.tsx +61 -0
- package/src/components/ApplicationLauncher/__tests__/__snapshots__/ApplicationLauncher.test.tsx.snap +6 -0
- package/src/components/Dropdown/DropdownToggle.tsx +6 -1
- package/src/components/Dropdown/Toggle.tsx +11 -1
- package/src/components/Dropdown/__tests__/DropdownToggle.test.tsx +51 -0
- package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +8 -0
- package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +346 -4
- package/src/components/Dropdown/__tests__/__snapshots__/Toggle.test.tsx.snap +1 -0
- package/src/components/Dropdown/examples/Dropdown.md +160 -91
- package/src/components/MenuToggle/MenuToggle.tsx +5 -2
- package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +5 -0
- package/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap +59 -0
- package/src/components/MenuToggle/examples/MenuToggle.md +60 -67
- package/src/components/OptionsMenu/__tests__/__snapshots__/OptionsMenu.test.tsx.snap +7 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +15 -0
- package/src/components/Popover/Popover.tsx +1 -19
- package/src/components/Popover/__tests__/Generated/__snapshots__/Popover.test.tsx.snap +0 -1
- package/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap +0 -4
- package/src/components/Select/Select.tsx +9 -1
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +25 -0
- package/src/components/Select/examples/Select.md +75 -9
- package/src/components/Slider/Slider.tsx +9 -6
- package/src/components/Slider/examples/Slider.md +27 -0
- package/src/demos/CardDemos.md +65 -91
- package/src/demos/Tabs/NestedTabsDemo.js +151 -0
- package/src/demos/Tabs.md +4 -0
|
@@ -22,12 +22,7 @@ import avatarImg from '../../Avatar/examples/avatarImg.svg';
|
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
24
|
import React from 'react';
|
|
25
|
-
import {
|
|
26
|
-
Dropdown,
|
|
27
|
-
DropdownToggle,
|
|
28
|
-
DropdownItem,
|
|
29
|
-
DropdownSeparator
|
|
30
|
-
} from '@patternfly/react-core';
|
|
25
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
31
26
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
32
27
|
|
|
33
28
|
class SimpleDropdown extends React.Component {
|
|
@@ -63,12 +58,12 @@ class SimpleDropdown extends React.Component {
|
|
|
63
58
|
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
64
59
|
Disabled link
|
|
65
60
|
</DropdownItem>,
|
|
66
|
-
<DropdownItem
|
|
67
|
-
key="disabled action"
|
|
68
|
-
isAriaDisabled
|
|
61
|
+
<DropdownItem
|
|
62
|
+
key="disabled action"
|
|
63
|
+
isAriaDisabled
|
|
69
64
|
component="button"
|
|
70
|
-
tooltip="Tooltip for disabled item"
|
|
71
|
-
tooltipProps={{position:
|
|
65
|
+
tooltip="Tooltip for disabled item"
|
|
66
|
+
tooltipProps={{ position: 'top' }}
|
|
72
67
|
>
|
|
73
68
|
Disabled action
|
|
74
69
|
</DropdownItem>,
|
|
@@ -98,12 +93,7 @@ class SimpleDropdown extends React.Component {
|
|
|
98
93
|
|
|
99
94
|
```js
|
|
100
95
|
import React from 'react';
|
|
101
|
-
import {
|
|
102
|
-
Dropdown,
|
|
103
|
-
DropdownToggle,
|
|
104
|
-
DropdownItem,
|
|
105
|
-
DropdownSeparator
|
|
106
|
-
} from '@patternfly/react-core';
|
|
96
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
107
97
|
|
|
108
98
|
class IntialSelectionDropdown extends React.Component {
|
|
109
99
|
constructor(props) {
|
|
@@ -236,12 +226,7 @@ class GroupedDropdown extends React.Component {
|
|
|
236
226
|
|
|
237
227
|
```js
|
|
238
228
|
import React from 'react';
|
|
239
|
-
import {
|
|
240
|
-
Dropdown,
|
|
241
|
-
DropdownToggle,
|
|
242
|
-
DropdownItem,
|
|
243
|
-
DropdownSeparator
|
|
244
|
-
} from '@patternfly/react-core';
|
|
229
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
245
230
|
|
|
246
231
|
class DisabledDropdown extends React.Component {
|
|
247
232
|
constructor(props) {
|
|
@@ -300,12 +285,7 @@ class DisabledDropdown extends React.Component {
|
|
|
300
285
|
|
|
301
286
|
```js
|
|
302
287
|
import React from 'react';
|
|
303
|
-
import {
|
|
304
|
-
Dropdown,
|
|
305
|
-
DropdownToggle,
|
|
306
|
-
DropdownItem,
|
|
307
|
-
DropdownSeparator
|
|
308
|
-
} from '@patternfly/react-core';
|
|
288
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
309
289
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
310
290
|
|
|
311
291
|
class PrimaryDropdown extends React.Component {
|
|
@@ -366,17 +346,67 @@ class PrimaryDropdown extends React.Component {
|
|
|
366
346
|
}
|
|
367
347
|
```
|
|
368
348
|
|
|
349
|
+
### Secondary toggle
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
import React from 'react';
|
|
353
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
354
|
+
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
355
|
+
|
|
356
|
+
const SecondaryDropdown = () => {
|
|
357
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
358
|
+
|
|
359
|
+
const onFocus = () => {
|
|
360
|
+
const element = document.getElementById('toggle-id-secondary');
|
|
361
|
+
element.focus();
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const dropdownItems = [
|
|
365
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
366
|
+
<DropdownItem key="action" component="button">
|
|
367
|
+
Action
|
|
368
|
+
</DropdownItem>,
|
|
369
|
+
<DropdownItem key="disabled link" isDisabled>
|
|
370
|
+
Disabled link
|
|
371
|
+
</DropdownItem>,
|
|
372
|
+
<DropdownItem key="disabled action" isDisabled component="button">
|
|
373
|
+
Disabled action
|
|
374
|
+
</DropdownItem>,
|
|
375
|
+
<DropdownSeparator key="separator" />,
|
|
376
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
377
|
+
<DropdownItem key="separated action" component="button">
|
|
378
|
+
Separated action
|
|
379
|
+
</DropdownItem>
|
|
380
|
+
];
|
|
381
|
+
|
|
382
|
+
return (
|
|
383
|
+
<Dropdown
|
|
384
|
+
onSelect={() => {
|
|
385
|
+
setIsOpen(!isOpen);
|
|
386
|
+
onFocus();
|
|
387
|
+
}}
|
|
388
|
+
toggle={
|
|
389
|
+
<DropdownToggle
|
|
390
|
+
onToggle={next => setIsOpen(next)}
|
|
391
|
+
toggleIndicator={CaretDownIcon}
|
|
392
|
+
toggleVariant="secondary"
|
|
393
|
+
id="toggle-id-secondary"
|
|
394
|
+
>
|
|
395
|
+
Dropdown
|
|
396
|
+
</DropdownToggle>
|
|
397
|
+
}
|
|
398
|
+
isOpen={isOpen}
|
|
399
|
+
dropdownItems={dropdownItems}
|
|
400
|
+
/>
|
|
401
|
+
);
|
|
402
|
+
};
|
|
403
|
+
```
|
|
404
|
+
|
|
369
405
|
### Position right
|
|
370
406
|
|
|
371
407
|
```js
|
|
372
408
|
import React from 'react';
|
|
373
|
-
import {
|
|
374
|
-
Dropdown,
|
|
375
|
-
DropdownToggle,
|
|
376
|
-
DropdownItem,
|
|
377
|
-
DropdownSeparator,
|
|
378
|
-
DropdownPosition
|
|
379
|
-
} from '@patternfly/react-core';
|
|
409
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, DropdownPosition } from '@patternfly/react-core';
|
|
380
410
|
|
|
381
411
|
class PositionRightDropdown extends React.Component {
|
|
382
412
|
constructor(props) {
|
|
@@ -437,12 +467,7 @@ class PositionRightDropdown extends React.Component {
|
|
|
437
467
|
|
|
438
468
|
```js
|
|
439
469
|
import React from 'react';
|
|
440
|
-
import {
|
|
441
|
-
Dropdown,
|
|
442
|
-
DropdownToggle,
|
|
443
|
-
DropdownItem,
|
|
444
|
-
DropdownSeparator
|
|
445
|
-
} from '@patternfly/react-core';
|
|
470
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
446
471
|
|
|
447
472
|
class AlignmentsDropdown extends React.Component {
|
|
448
473
|
constructor(props) {
|
|
@@ -509,13 +534,7 @@ class AlignmentsDropdown extends React.Component {
|
|
|
509
534
|
|
|
510
535
|
```js
|
|
511
536
|
import React from 'react';
|
|
512
|
-
import {
|
|
513
|
-
Dropdown,
|
|
514
|
-
DropdownToggle,
|
|
515
|
-
DropdownItem,
|
|
516
|
-
DropdownSeparator,
|
|
517
|
-
DropdownDirection
|
|
518
|
-
} from '@patternfly/react-core';
|
|
537
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, DropdownDirection } from '@patternfly/react-core';
|
|
519
538
|
|
|
520
539
|
class DirectionUpDropdown extends React.Component {
|
|
521
540
|
constructor(props) {
|
|
@@ -575,12 +594,7 @@ class DirectionUpDropdown extends React.Component {
|
|
|
575
594
|
|
|
576
595
|
```js
|
|
577
596
|
import React from 'react';
|
|
578
|
-
import {
|
|
579
|
-
Dropdown,
|
|
580
|
-
DropdownItem,
|
|
581
|
-
DropdownSeparator,
|
|
582
|
-
KebabToggle
|
|
583
|
-
} from '@patternfly/react-core';
|
|
597
|
+
import { Dropdown, DropdownItem, DropdownSeparator, KebabToggle } from '@patternfly/react-core';
|
|
584
598
|
|
|
585
599
|
class KebabDropdown extends React.Component {
|
|
586
600
|
constructor(props) {
|
|
@@ -641,11 +655,7 @@ class KebabDropdown extends React.Component {
|
|
|
641
655
|
|
|
642
656
|
```js
|
|
643
657
|
import React from 'react';
|
|
644
|
-
import {
|
|
645
|
-
Dropdown,
|
|
646
|
-
DropdownItem,
|
|
647
|
-
BadgeToggle
|
|
648
|
-
} from '@patternfly/react-core';
|
|
658
|
+
import { Dropdown, DropdownItem, BadgeToggle } from '@patternfly/react-core';
|
|
649
659
|
import AngleLeftIcon from '@patternfly/react-icons/dist/esm/icons/angle-left-icon';
|
|
650
660
|
|
|
651
661
|
class BadgeDropdown extends React.Component {
|
|
@@ -704,12 +714,7 @@ class BadgeDropdown extends React.Component {
|
|
|
704
714
|
|
|
705
715
|
```js
|
|
706
716
|
import React from 'react';
|
|
707
|
-
import {
|
|
708
|
-
Dropdown,
|
|
709
|
-
DropdownToggle,
|
|
710
|
-
DropdownItem,
|
|
711
|
-
DropdownSeparator
|
|
712
|
-
} from '@patternfly/react-core';
|
|
717
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
713
718
|
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
|
|
714
719
|
|
|
715
720
|
class IconDropdown extends React.Component {
|
|
@@ -1071,12 +1076,7 @@ class SplitButtonDisabledDropdown extends React.Component {
|
|
|
1071
1076
|
|
|
1072
1077
|
```js
|
|
1073
1078
|
import React from 'react';
|
|
1074
|
-
import {
|
|
1075
|
-
Dropdown,
|
|
1076
|
-
DropdownToggle,
|
|
1077
|
-
DropdownToggleAction,
|
|
1078
|
-
DropdownItem
|
|
1079
|
-
} from '@patternfly/react-core';
|
|
1079
|
+
import { Dropdown, DropdownToggle, DropdownToggleAction, DropdownItem } from '@patternfly/react-core';
|
|
1080
1080
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
1081
1081
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
1082
1082
|
import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
|
|
@@ -1180,14 +1180,95 @@ class SplitButtonActionDropdown extends React.Component {
|
|
|
1180
1180
|
}
|
|
1181
1181
|
```
|
|
1182
1182
|
|
|
1183
|
+
### Split button primary action
|
|
1184
|
+
|
|
1185
|
+
```ts
|
|
1186
|
+
import React from 'react';
|
|
1187
|
+
import { Dropdown, DropdownToggle, DropdownToggleAction, DropdownItem } from '@patternfly/react-core';
|
|
1188
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
1189
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
1190
|
+
import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
|
|
1191
|
+
|
|
1192
|
+
const PrimarySplitActionDropdown = () => {
|
|
1193
|
+
const [isActionOpen, setIsActionOpen] = React.useState(false);
|
|
1194
|
+
const [isCogOpen, setIsCogOpen] = React.useState(false);
|
|
1195
|
+
|
|
1196
|
+
const onActionClick = () => {
|
|
1197
|
+
window.alert('You selected an action button!');
|
|
1198
|
+
};
|
|
1199
|
+
const onCogClick = () => {
|
|
1200
|
+
window.alert('You selected the Cog!');
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
const dropdownItems = [
|
|
1204
|
+
<DropdownItem key="action" component="button" onClick={onActionClick}>
|
|
1205
|
+
Action
|
|
1206
|
+
</DropdownItem>,
|
|
1207
|
+
<DropdownItem key="disabled link" component="button" isDisabled onClick={onActionClick}>
|
|
1208
|
+
Disabled action
|
|
1209
|
+
</DropdownItem>,
|
|
1210
|
+
<DropdownItem key="other action" component="button" onClick={onActionClick}>
|
|
1211
|
+
Other action
|
|
1212
|
+
</DropdownItem>
|
|
1213
|
+
];
|
|
1214
|
+
const dropdownIconItems = [
|
|
1215
|
+
<DropdownItem key="action" component="button" icon={<CogIcon />} onClick={onActionClick}>
|
|
1216
|
+
Action
|
|
1217
|
+
</DropdownItem>,
|
|
1218
|
+
<DropdownItem key="disabled link" component="button" icon={<BellIcon />} isDisabled onClick={onActionClick}>
|
|
1219
|
+
Disabled action
|
|
1220
|
+
</DropdownItem>,
|
|
1221
|
+
<DropdownItem key="other action" component="button" icon={<CubesIcon />} onClick={onActionClick}>
|
|
1222
|
+
Other action
|
|
1223
|
+
</DropdownItem>
|
|
1224
|
+
];
|
|
1225
|
+
|
|
1226
|
+
return (
|
|
1227
|
+
<React.Fragment>
|
|
1228
|
+
<Dropdown
|
|
1229
|
+
onSelect={() => setIsActionOpen(!isActionOpen)}
|
|
1230
|
+
toggle={
|
|
1231
|
+
<DropdownToggle
|
|
1232
|
+
splitButtonItems={[
|
|
1233
|
+
<DropdownToggleAction key="action" onClick={onActionClick}>
|
|
1234
|
+
Action
|
|
1235
|
+
</DropdownToggleAction>
|
|
1236
|
+
]}
|
|
1237
|
+
toggleVariant="primary"
|
|
1238
|
+
splitButtonVariant="action"
|
|
1239
|
+
onToggle={next => setIsActionOpen(next)}
|
|
1240
|
+
/>
|
|
1241
|
+
}
|
|
1242
|
+
isOpen={isActionOpen}
|
|
1243
|
+
dropdownItems={dropdownItems}
|
|
1244
|
+
/>{' '}
|
|
1245
|
+
<Dropdown
|
|
1246
|
+
onSelect={() => setIsCogOpen(!isCogOpen)}
|
|
1247
|
+
toggle={
|
|
1248
|
+
<DropdownToggle
|
|
1249
|
+
splitButtonItems={[
|
|
1250
|
+
<DropdownToggleAction key="cog-action" aria-label="Action" onClick={onCogClick}>
|
|
1251
|
+
<CogIcon />
|
|
1252
|
+
</DropdownToggleAction>
|
|
1253
|
+
]}
|
|
1254
|
+
toggleVariant="primary"
|
|
1255
|
+
splitButtonVariant="action"
|
|
1256
|
+
onToggle={next => setIsCogOpen(next)}
|
|
1257
|
+
/>
|
|
1258
|
+
}
|
|
1259
|
+
isOpen={isCogOpen}
|
|
1260
|
+
dropdownItems={dropdownIconItems}
|
|
1261
|
+
/>
|
|
1262
|
+
</React.Fragment>
|
|
1263
|
+
);
|
|
1264
|
+
};
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1183
1267
|
### Basic panel
|
|
1184
1268
|
|
|
1185
1269
|
```js
|
|
1186
1270
|
import React from 'react';
|
|
1187
|
-
import {
|
|
1188
|
-
Dropdown,
|
|
1189
|
-
DropdownToggle
|
|
1190
|
-
} from '@patternfly/react-core';
|
|
1271
|
+
import { Dropdown, DropdownToggle } from '@patternfly/react-core';
|
|
1191
1272
|
|
|
1192
1273
|
class DropdownPanel extends React.Component {
|
|
1193
1274
|
constructor(props) {
|
|
@@ -1226,11 +1307,7 @@ class DropdownPanel extends React.Component {
|
|
|
1226
1307
|
|
|
1227
1308
|
```js
|
|
1228
1309
|
import React from 'react';
|
|
1229
|
-
import {
|
|
1230
|
-
Dropdown,
|
|
1231
|
-
DropdownToggle,
|
|
1232
|
-
DropdownItem
|
|
1233
|
-
} from '@patternfly/react-core';
|
|
1310
|
+
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
1234
1311
|
import { Link } from '@reach/router';
|
|
1235
1312
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
1236
1313
|
|
|
@@ -1359,11 +1436,7 @@ class ImageTextDropdown extends React.Component {
|
|
|
1359
1436
|
|
|
1360
1437
|
```js
|
|
1361
1438
|
import React from 'react';
|
|
1362
|
-
import {
|
|
1363
|
-
Dropdown,
|
|
1364
|
-
DropdownToggle,
|
|
1365
|
-
DropdownItem
|
|
1366
|
-
} from '@patternfly/react-core';
|
|
1439
|
+
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
1367
1440
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
1368
1441
|
|
|
1369
1442
|
class MenuOnDocumentBodyDropdown extends React.Component {
|
|
@@ -1415,11 +1488,7 @@ class MenuOnDocumentBodyDropdown extends React.Component {
|
|
|
1415
1488
|
|
|
1416
1489
|
```js
|
|
1417
1490
|
import React from 'react';
|
|
1418
|
-
import {
|
|
1419
|
-
Dropdown,
|
|
1420
|
-
DropdownToggle,
|
|
1421
|
-
DropdownItem
|
|
1422
|
-
} from '@patternfly/react-core';
|
|
1491
|
+
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
1423
1492
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
1424
1493
|
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
1425
1494
|
import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
|
|
@@ -15,7 +15,7 @@ export interface MenuToggleProps
|
|
|
15
15
|
/** Flag indicating the toggle is disabled */
|
|
16
16
|
isDisabled?: boolean;
|
|
17
17
|
/** Variant styles of the menu toggle */
|
|
18
|
-
variant?: 'default' | 'plain' | 'primary';
|
|
18
|
+
variant?: 'default' | 'plain' | 'primary' | 'plainText';
|
|
19
19
|
/** Optional icon rendered inside the toggle, before the children content */
|
|
20
20
|
icon?: React.ReactNode;
|
|
21
21
|
/** Optional badge rendered inside the toggle, after the children content */
|
|
@@ -37,6 +37,8 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
|
|
|
37
37
|
const { children, className, icon, badge, isExpanded, isDisabled, variant, innerRef, ...props } = this.props;
|
|
38
38
|
|
|
39
39
|
const isPlain = variant === 'plain';
|
|
40
|
+
const isPlainText = variant === 'plainText';
|
|
41
|
+
|
|
40
42
|
const content = (
|
|
41
43
|
<React.Fragment>
|
|
42
44
|
{icon && <span className={css(styles.menuToggleIcon)}>{icon}</span>}
|
|
@@ -55,7 +57,8 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
|
|
|
55
57
|
styles.menuToggle,
|
|
56
58
|
isExpanded && styles.modifiers.expanded,
|
|
57
59
|
variant === 'primary' && styles.modifiers.primary,
|
|
58
|
-
isPlain && styles.modifiers.plain,
|
|
60
|
+
(isPlain || isPlainText) && styles.modifiers.plain,
|
|
61
|
+
isPlainText && styles.modifiers.text,
|
|
59
62
|
className
|
|
60
63
|
)}
|
|
61
64
|
type="button"
|
|
@@ -40,6 +40,11 @@ describe('menu toggle', () => {
|
|
|
40
40
|
expect(view).toMatchSnapshot();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
test('shows plain text', () => {
|
|
44
|
+
const view = mount(<MenuToggle variant="plainText">Toggle</MenuToggle>);
|
|
45
|
+
expect(view).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
|
|
43
48
|
test('shows icon', () => {
|
|
44
49
|
const view = mount(<MenuToggle icon={<CogIcon />}>Toggle</MenuToggle>);
|
|
45
50
|
expect(view).toMatchSnapshot();
|
|
@@ -517,3 +517,62 @@ exports[`menu toggle shows isPrimary 1`] = `
|
|
|
517
517
|
</MenuToggleBase>
|
|
518
518
|
</MenuToggle>
|
|
519
519
|
`;
|
|
520
|
+
|
|
521
|
+
exports[`menu toggle shows plain text 1`] = `
|
|
522
|
+
<MenuToggle
|
|
523
|
+
variant="plainText"
|
|
524
|
+
>
|
|
525
|
+
<MenuToggleBase
|
|
526
|
+
className=""
|
|
527
|
+
innerRef={null}
|
|
528
|
+
isDisabled={false}
|
|
529
|
+
isExpanded={false}
|
|
530
|
+
variant="plainText"
|
|
531
|
+
>
|
|
532
|
+
<button
|
|
533
|
+
aria-expanded={false}
|
|
534
|
+
className="pf-c-menu-toggle pf-m-plain pf-m-text"
|
|
535
|
+
type="button"
|
|
536
|
+
>
|
|
537
|
+
<span
|
|
538
|
+
className="pf-c-menu-toggle__text"
|
|
539
|
+
>
|
|
540
|
+
Toggle
|
|
541
|
+
</span>
|
|
542
|
+
<span
|
|
543
|
+
className="pf-c-menu-toggle__controls"
|
|
544
|
+
>
|
|
545
|
+
<span
|
|
546
|
+
className="pf-c-menu-toggle__toggle-icon"
|
|
547
|
+
>
|
|
548
|
+
<CaretDownIcon
|
|
549
|
+
aria-hidden={true}
|
|
550
|
+
color="currentColor"
|
|
551
|
+
noVerticalAlign={false}
|
|
552
|
+
size="sm"
|
|
553
|
+
>
|
|
554
|
+
<svg
|
|
555
|
+
aria-hidden={true}
|
|
556
|
+
aria-labelledby={null}
|
|
557
|
+
fill="currentColor"
|
|
558
|
+
height="1em"
|
|
559
|
+
role="img"
|
|
560
|
+
style={
|
|
561
|
+
Object {
|
|
562
|
+
"verticalAlign": "-0.125em",
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
viewBox="0 0 320 512"
|
|
566
|
+
width="1em"
|
|
567
|
+
>
|
|
568
|
+
<path
|
|
569
|
+
d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z"
|
|
570
|
+
/>
|
|
571
|
+
</svg>
|
|
572
|
+
</CaretDownIcon>
|
|
573
|
+
</span>
|
|
574
|
+
</span>
|
|
575
|
+
</button>
|
|
576
|
+
</MenuToggleBase>
|
|
577
|
+
</MenuToggle>
|
|
578
|
+
`;
|
|
@@ -13,119 +13,112 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
13
13
|
|
|
14
14
|
### Collapsed
|
|
15
15
|
|
|
16
|
-
```
|
|
16
|
+
```ts
|
|
17
17
|
import React from 'react';
|
|
18
18
|
import { MenuToggle } from '@patternfly/react-core';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return <MenuToggle>Collapsed</MenuToggle>;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
20
|
+
<MenuToggle>Collapsed</MenuToggle>
|
|
21
|
+
|
|
25
22
|
```
|
|
26
23
|
|
|
27
24
|
### Expanded
|
|
28
25
|
|
|
29
|
-
```
|
|
26
|
+
```ts
|
|
30
27
|
import React from 'react';
|
|
31
28
|
import { MenuToggle } from '@patternfly/react-core';
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return <MenuToggle isExpanded>Expanded</MenuToggle>;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
30
|
+
<MenuToggle isExpanded>Expanded</MenuToggle>;
|
|
31
|
+
|
|
38
32
|
```
|
|
39
33
|
|
|
40
34
|
### Disabled
|
|
41
35
|
|
|
42
|
-
```
|
|
36
|
+
```ts
|
|
43
37
|
import React from 'react';
|
|
44
38
|
import { MenuToggle } from '@patternfly/react-core';
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return <MenuToggle isDisabled>Disabled</MenuToggle>;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
40
|
+
<MenuToggle isDisabled>Disabled</MenuToggle>
|
|
41
|
+
|
|
51
42
|
```
|
|
52
43
|
|
|
53
44
|
### Icon
|
|
54
45
|
|
|
55
|
-
```
|
|
46
|
+
```ts
|
|
56
47
|
import React from 'react';
|
|
57
48
|
import { MenuToggle } from '@patternfly/react-core';
|
|
58
49
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return <MenuToggle icon={<CogIcon />}>Icon</MenuToggle>;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
51
|
+
<MenuToggle icon={<CogIcon />}>Icon</MenuToggle>;
|
|
52
|
+
|
|
65
53
|
```
|
|
66
54
|
|
|
67
55
|
### Count
|
|
68
56
|
|
|
69
|
-
```
|
|
57
|
+
```ts
|
|
70
58
|
import React from 'react';
|
|
71
59
|
import { MenuToggle, Badge } from '@patternfly/react-core';
|
|
72
60
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return <MenuToggle badge={<Badge>4 selected</Badge>}>Count</MenuToggle>;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
61
|
+
<MenuToggle badge={<Badge>4 selected</Badge>}>Count</MenuToggle>
|
|
62
|
+
|
|
78
63
|
```
|
|
79
64
|
|
|
80
65
|
### Primary
|
|
81
66
|
|
|
82
|
-
```
|
|
67
|
+
```ts
|
|
83
68
|
import React from 'react';
|
|
84
69
|
import { MenuToggle } from '@patternfly/react-core';
|
|
85
70
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
86
71
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</MenuToggle>
|
|
101
|
-
</React.Fragment>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
72
|
+
<React.Fragment>
|
|
73
|
+
<MenuToggle variant="primary">Collapsed</MenuToggle>{' '}
|
|
74
|
+
<MenuToggle variant="primary" icon={<CogIcon />}>
|
|
75
|
+
Icon
|
|
76
|
+
</MenuToggle>{' '}
|
|
77
|
+
<MenuToggle variant="primary" isExpanded>
|
|
78
|
+
Expanded
|
|
79
|
+
</MenuToggle>{' '}
|
|
80
|
+
<MenuToggle variant="primary" isDisabled>
|
|
81
|
+
Disabled
|
|
82
|
+
</MenuToggle>
|
|
83
|
+
</React.Fragment>
|
|
84
|
+
|
|
105
85
|
```
|
|
106
86
|
|
|
107
87
|
### Plain
|
|
108
88
|
|
|
109
|
-
```
|
|
89
|
+
```ts
|
|
110
90
|
import React from 'react';
|
|
111
91
|
import { MenuToggle } from '@patternfly/react-core';
|
|
112
92
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
113
93
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
94
|
+
<React.Fragment>
|
|
95
|
+
<MenuToggle variant="plain" aria-label="plain kebab">
|
|
96
|
+
<EllipsisVIcon />
|
|
97
|
+
</MenuToggle>
|
|
98
|
+
<MenuToggle variant="plain" isExpanded aria-label="plain expanded kebab">
|
|
99
|
+
<EllipsisVIcon />
|
|
100
|
+
</MenuToggle>
|
|
101
|
+
<MenuToggle variant="plain" isDisabled aria-label="disabled kebab">
|
|
102
|
+
<EllipsisVIcon />
|
|
103
|
+
</MenuToggle>
|
|
104
|
+
</React.Fragment>
|
|
105
|
+
```
|
|
106
|
+
### Plain with text
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import React from 'react';
|
|
110
|
+
import { MenuToggle } from '@patternfly/react-core';
|
|
111
|
+
|
|
112
|
+
<React.Fragment>
|
|
113
|
+
<MenuToggle variant="plainText" isDisabled aria-label="Disabled plain menu toggle">
|
|
114
|
+
Disabled
|
|
115
|
+
</MenuToggle>
|
|
116
|
+
|
|
117
|
+
<MenuToggle variant="plainText" aria-label="Plain menu toggle">
|
|
118
|
+
Custom text
|
|
119
|
+
</MenuToggle>
|
|
120
|
+
<MenuToggle variant="plainText" isExpanded aria-label="Expanded plain menu toggle">
|
|
121
|
+
Custom text (expanded)
|
|
122
|
+
</MenuToggle>
|
|
123
|
+
</React.Fragment>
|
|
131
124
|
```
|