@patternfly/react-core 4.225.9 → 4.225.10
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 +8 -0
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +3 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +3 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/umd/react-core.css +35 -35
- package/dist/umd/react-core.js +3 -1
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +6 -6
- package/src/components/CalendarMonth/CalendarMonth.tsx +3 -1
- package/src/components/CalendarMonth/__tests__/CalendarMonth.test.tsx +30 -2
- package/src/demos/NotificationDrawer/NotificationDrawer.md +8 -20
- package/src/demos/PrimaryDetail.md +283 -77
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.225.
|
|
3
|
+
"version": "4.225.10",
|
|
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.76.
|
|
38
|
-
"@patternfly/react-styles": "^4.75.
|
|
39
|
-
"@patternfly/react-tokens": "^4.77.
|
|
37
|
+
"@patternfly/react-icons": "^4.76.10",
|
|
38
|
+
"@patternfly/react-styles": "^4.75.10",
|
|
39
|
+
"@patternfly/react-tokens": "^4.77.10",
|
|
40
40
|
"focus-trap": "6.9.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.204.
|
|
46
|
+
"@patternfly/patternfly": "4.204.2",
|
|
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": "ae1f341cfd4e094892f9fba068aece48bef36dd3"
|
|
64
64
|
}
|
|
@@ -345,7 +345,9 @@ export const CalendarMonth = ({
|
|
|
345
345
|
tabIndex={isFocused ? 0 : -1}
|
|
346
346
|
disabled={!isValid}
|
|
347
347
|
aria-label={
|
|
348
|
-
cellAriaLabel
|
|
348
|
+
cellAriaLabel
|
|
349
|
+
? cellAriaLabel(date)
|
|
350
|
+
: `${dayFormat(date)} ${monthFormat(date)} ${yearFormat(date)}`
|
|
349
351
|
}
|
|
350
352
|
{...(isFocused && { ref: focusRef })}
|
|
351
353
|
>
|
|
@@ -12,7 +12,7 @@ test('Renders the first date in a month when a custom weekStart is passed', () =
|
|
|
12
12
|
|
|
13
13
|
render(<CalendarMonth cellAriaLabel={formatAria} weekStart={1} date={new Date(2023, 0)} />);
|
|
14
14
|
|
|
15
|
-
const firstDate = screen.
|
|
15
|
+
const firstDate = screen.getByRole('button', { name: '1 January 2023' });
|
|
16
16
|
expect(firstDate).toBeVisible();
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -24,6 +24,34 @@ test('Renders the last date in a month when a custom weekStart is passed', () =>
|
|
|
24
24
|
|
|
25
25
|
render(<CalendarMonth cellAriaLabel={formatAria} weekStart={1} date={new Date(2023, 0)} />);
|
|
26
26
|
|
|
27
|
-
const lastDate = screen.
|
|
27
|
+
const lastDate = screen.getByRole('button', { name: '31 January 2023' });
|
|
28
28
|
expect(lastDate).toBeVisible();
|
|
29
29
|
});
|
|
30
|
+
|
|
31
|
+
test('Previous month dates have correct month in aria label', () => {
|
|
32
|
+
render(<CalendarMonth date={new Date(2024, 5)} />);
|
|
33
|
+
|
|
34
|
+
const previousMonthDate = screen.getByRole('button', { name: '31 May 2024' });
|
|
35
|
+
expect(previousMonthDate).toBeVisible();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Next month dates have correct month in aria label', () => {
|
|
39
|
+
render(<CalendarMonth date={new Date(2024, 6)} />);
|
|
40
|
+
|
|
41
|
+
const nextMonthDate = screen.getByRole('button', { name: '1 August 2024' });
|
|
42
|
+
expect(nextMonthDate).toBeVisible();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('Previous year dates have correct year in aria label', () => {
|
|
46
|
+
render(<CalendarMonth date={new Date(2024, 0)} />);
|
|
47
|
+
|
|
48
|
+
const previousYearDate = screen.getByRole('button', { name: '31 December 2023' });
|
|
49
|
+
expect(previousYearDate).toBeVisible();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('Next year dates have correct year in aria label', () => {
|
|
53
|
+
render(<CalendarMonth date={new Date(2024, 11)} />);
|
|
54
|
+
|
|
55
|
+
const nextYearDate = screen.getByRole('button', { name: '1 January 2025' });
|
|
56
|
+
expect(nextYearDate).toBeVisible();
|
|
57
|
+
});
|
|
@@ -12,7 +12,6 @@ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-
|
|
|
12
12
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
13
13
|
import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
|
|
14
14
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
15
|
-
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
16
15
|
|
|
17
16
|
## Demos
|
|
18
17
|
|
|
@@ -32,13 +31,10 @@ import {
|
|
|
32
31
|
BreadcrumbItem,
|
|
33
32
|
Button,
|
|
34
33
|
ButtonVariant,
|
|
35
|
-
Card,
|
|
36
|
-
CardBody,
|
|
37
|
-
Drawer,
|
|
38
|
-
DrawerContent,
|
|
39
|
-
DrawerContentBody,
|
|
40
34
|
Dropdown,
|
|
41
35
|
DropdownGroup,
|
|
36
|
+
DropdownPosition,
|
|
37
|
+
DropdownDirection,
|
|
42
38
|
DropdownToggle,
|
|
43
39
|
DropdownItem,
|
|
44
40
|
DropdownSeparator,
|
|
@@ -46,8 +42,7 @@ import {
|
|
|
46
42
|
EmptyStateBody,
|
|
47
43
|
EmptyStateIcon,
|
|
48
44
|
EmptyStatePrimary,
|
|
49
|
-
|
|
50
|
-
GalleryItem,
|
|
45
|
+
EmptyStateVariant,
|
|
51
46
|
KebabToggle,
|
|
52
47
|
Nav,
|
|
53
48
|
NavItem,
|
|
@@ -79,7 +74,6 @@ import {
|
|
|
79
74
|
ToolbarGroup,
|
|
80
75
|
ToolbarContent
|
|
81
76
|
} from '@patternfly/react-core';
|
|
82
|
-
import { css } from '@patternfly/react-styles';
|
|
83
77
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
84
78
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
85
79
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
@@ -87,7 +81,7 @@ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-
|
|
|
87
81
|
import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
|
|
88
82
|
import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
|
|
89
83
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
90
|
-
import
|
|
84
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
91
85
|
|
|
92
86
|
class BasicNotificationDrawer extends React.Component {
|
|
93
87
|
constructor(props) {
|
|
@@ -548,13 +542,10 @@ import {
|
|
|
548
542
|
BreadcrumbItem,
|
|
549
543
|
Button,
|
|
550
544
|
ButtonVariant,
|
|
551
|
-
Card,
|
|
552
|
-
CardBody,
|
|
553
|
-
Drawer,
|
|
554
|
-
DrawerContent,
|
|
555
|
-
DrawerContentBody,
|
|
556
545
|
Dropdown,
|
|
557
546
|
DropdownGroup,
|
|
547
|
+
DropdownPosition,
|
|
548
|
+
DropdownDirection,
|
|
558
549
|
DropdownToggle,
|
|
559
550
|
DropdownItem,
|
|
560
551
|
DropdownSeparator,
|
|
@@ -562,8 +553,7 @@ import {
|
|
|
562
553
|
EmptyStateBody,
|
|
563
554
|
EmptyStateIcon,
|
|
564
555
|
EmptyStatePrimary,
|
|
565
|
-
|
|
566
|
-
GalleryItem,
|
|
556
|
+
EmptyStateVariant,
|
|
567
557
|
KebabToggle,
|
|
568
558
|
Nav,
|
|
569
559
|
NavItem,
|
|
@@ -597,16 +587,14 @@ import {
|
|
|
597
587
|
ToolbarGroup,
|
|
598
588
|
ToolbarContent
|
|
599
589
|
} from '@patternfly/react-core';
|
|
600
|
-
import { css } from '@patternfly/react-styles';
|
|
601
590
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
602
591
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
603
|
-
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
604
592
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
605
593
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
594
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
606
595
|
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
|
|
607
596
|
import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
|
|
608
597
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
609
|
-
import { Table, TableHeader, TableBody } from '@patternfly/react-table';
|
|
610
598
|
|
|
611
599
|
class GroupedNotificationDrawer extends React.Component {
|
|
612
600
|
constructor(props) {
|
|
@@ -5,6 +5,7 @@ section: demos
|
|
|
5
5
|
|
|
6
6
|
import DashboardWrapper from './examples/DashboardWrapper';
|
|
7
7
|
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
8
|
+
import TrashIcon from '@patternfly/react-icons/dist/esm/icons/trash-icon';
|
|
8
9
|
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
9
10
|
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
10
11
|
import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
|
|
@@ -954,12 +955,17 @@ import React from 'react';
|
|
|
954
955
|
import {
|
|
955
956
|
Button,
|
|
956
957
|
Card,
|
|
958
|
+
CardActions,
|
|
957
959
|
CardHeader,
|
|
958
960
|
CardBody,
|
|
959
961
|
CardTitle,
|
|
962
|
+
Checkbox,
|
|
960
963
|
Divider,
|
|
961
964
|
Dropdown,
|
|
965
|
+
DropdownToggle,
|
|
966
|
+
DropdownToggleCheckbox,
|
|
962
967
|
DropdownItem,
|
|
968
|
+
DropdownPosition,
|
|
963
969
|
DropdownSeparator,
|
|
964
970
|
Drawer,
|
|
965
971
|
DrawerActions,
|
|
@@ -969,14 +975,10 @@ import {
|
|
|
969
975
|
DrawerContentBody,
|
|
970
976
|
DrawerHead,
|
|
971
977
|
DrawerPanelContent,
|
|
972
|
-
DrawerSection,
|
|
973
978
|
Flex,
|
|
974
979
|
FlexItem,
|
|
975
980
|
Gallery,
|
|
976
981
|
KebabToggle,
|
|
977
|
-
OverflowMenu,
|
|
978
|
-
OverflowMenuControl,
|
|
979
|
-
OverflowMenuItem,
|
|
980
982
|
PageSection,
|
|
981
983
|
PageSectionVariants,
|
|
982
984
|
Pagination,
|
|
@@ -990,10 +992,10 @@ import {
|
|
|
990
992
|
Toolbar,
|
|
991
993
|
ToolbarItem,
|
|
992
994
|
ToolbarContent,
|
|
993
|
-
ToolbarFilter
|
|
994
|
-
ToolbarToggleGroup
|
|
995
|
+
ToolbarFilter
|
|
995
996
|
} from '@patternfly/react-core';
|
|
996
997
|
import DashboardWrapper from './examples/DashboardWrapper';
|
|
998
|
+
import TrashIcon from '@patternfly/react-icons/dist/esm/icons/trash-icon';
|
|
997
999
|
import pfIcon from './pf-logo-small.svg';
|
|
998
1000
|
import activeMQIcon from './activemq-core_200x150.png';
|
|
999
1001
|
import avroIcon from './camel-avro_200x150.png';
|
|
@@ -1012,7 +1014,12 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1012
1014
|
this.state = {
|
|
1013
1015
|
page: 1,
|
|
1014
1016
|
perPage: 10,
|
|
1017
|
+
totalItemCount: 10,
|
|
1015
1018
|
isDrawerExpanded: false,
|
|
1019
|
+
isChecked: false,
|
|
1020
|
+
selectedItems: [],
|
|
1021
|
+
areAllSelected: false,
|
|
1022
|
+
splitButtonDropdownIsOpen: false,
|
|
1016
1023
|
activeCard: null,
|
|
1017
1024
|
filters: {
|
|
1018
1025
|
products: []
|
|
@@ -1032,7 +1039,7 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1032
1039
|
}));
|
|
1033
1040
|
};
|
|
1034
1041
|
|
|
1035
|
-
this.onToolbarDropdownSelect =
|
|
1042
|
+
this.onToolbarDropdownSelect = _event => {
|
|
1036
1043
|
this.setState({
|
|
1037
1044
|
isLowerToolbarDropdownOpen: !this.state.isLowerToolbarDropdownOpen
|
|
1038
1045
|
});
|
|
@@ -1044,24 +1051,23 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1044
1051
|
});
|
|
1045
1052
|
};
|
|
1046
1053
|
|
|
1047
|
-
this.onToolbarKebabDropdownSelect =
|
|
1054
|
+
this.onToolbarKebabDropdownSelect = _event => {
|
|
1048
1055
|
this.setState({
|
|
1049
1056
|
isLowerToolbarKebabDropdownOpen: !this.state.isLowerToolbarKebabDropdownOpen
|
|
1050
1057
|
});
|
|
1051
1058
|
};
|
|
1052
1059
|
|
|
1053
|
-
this.
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
});
|
|
1060
|
+
this.checkAllSelected = (selected, total) => {
|
|
1061
|
+
if (selected && selected < total) {
|
|
1062
|
+
return null;
|
|
1063
|
+
}
|
|
1064
|
+
return selected === total;
|
|
1059
1065
|
};
|
|
1060
1066
|
|
|
1061
1067
|
this.onNameSelect = (event, selection) => {
|
|
1062
1068
|
const checked = event.target.checked;
|
|
1063
1069
|
this.setState(prevState => {
|
|
1064
|
-
const prevSelections = prevState.filters
|
|
1070
|
+
const prevSelections = prevState.filters.products;
|
|
1065
1071
|
return {
|
|
1066
1072
|
filters: {
|
|
1067
1073
|
...prevState.filters,
|
|
@@ -1095,22 +1101,27 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1095
1101
|
});
|
|
1096
1102
|
};
|
|
1097
1103
|
|
|
1098
|
-
this.
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1104
|
+
this.onCheckboxClick = (event, productId) => {
|
|
1105
|
+
event.stopPropagation();
|
|
1106
|
+
this.setState(prevState =>
|
|
1107
|
+
prevState.selectedItems.includes(productId * 1) || this.state.selectedItems.includes(productId * 1)
|
|
1108
|
+
? {
|
|
1109
|
+
selectedItems: [...this.state.selectedItems.filter(id => productId * 1 !== id)],
|
|
1110
|
+
areAllSelected: this.checkAllSelected(prevState.selectedItems.length - 1, prevState.totalItemCount)
|
|
1111
|
+
}
|
|
1112
|
+
: {
|
|
1113
|
+
selectedItems: [...prevState.selectedItems, productId * 1],
|
|
1114
|
+
areAllSelected: this.checkAllSelected(prevState.selectedItems.length + 1, prevState.totalItemCount)
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1110
1117
|
};
|
|
1111
1118
|
|
|
1112
1119
|
this.onCardClick = event => {
|
|
1113
1120
|
if (event.currentTarget.id === this.state.activeCard) {
|
|
1121
|
+
this.setState({
|
|
1122
|
+
isDrawerExpanded: !this.state.isDrawerExpanded,
|
|
1123
|
+
activeCard: null
|
|
1124
|
+
});
|
|
1114
1125
|
return;
|
|
1115
1126
|
}
|
|
1116
1127
|
|
|
@@ -1140,6 +1151,135 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1140
1151
|
this.onSetPage = (_evt, page) => {
|
|
1141
1152
|
this.setState({ page });
|
|
1142
1153
|
};
|
|
1154
|
+
|
|
1155
|
+
this.selectPage = () => {
|
|
1156
|
+
const { totalItemCount, perPage } = this.state;
|
|
1157
|
+
let collection = [];
|
|
1158
|
+
|
|
1159
|
+
collection = this.getAllItems();
|
|
1160
|
+
|
|
1161
|
+
this.setState(
|
|
1162
|
+
{
|
|
1163
|
+
selectedItems: collection,
|
|
1164
|
+
areAllSelected: totalItemCount === perPage ? true : false
|
|
1165
|
+
},
|
|
1166
|
+
this.updateSelected
|
|
1167
|
+
);
|
|
1168
|
+
};
|
|
1169
|
+
|
|
1170
|
+
this.selectAll = () => {
|
|
1171
|
+
let collection = [];
|
|
1172
|
+
for (let i = 0; i <= 9; i++) {
|
|
1173
|
+
collection = [...collection, i];
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
this.setState(
|
|
1177
|
+
{
|
|
1178
|
+
selectedItems: collection,
|
|
1179
|
+
isChecked: true,
|
|
1180
|
+
areAllSelected: true
|
|
1181
|
+
},
|
|
1182
|
+
this.updateSelected
|
|
1183
|
+
);
|
|
1184
|
+
};
|
|
1185
|
+
|
|
1186
|
+
this.selectNone = () => {
|
|
1187
|
+
this.setState(
|
|
1188
|
+
{
|
|
1189
|
+
selectedItems: [],
|
|
1190
|
+
isChecked: false,
|
|
1191
|
+
areAllSelected: false,
|
|
1192
|
+
isDrawerExpanded: false,
|
|
1193
|
+
activeCard: null
|
|
1194
|
+
},
|
|
1195
|
+
this.updateSelected
|
|
1196
|
+
);
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
this.splitCheckboxSelectAll = e => {
|
|
1200
|
+
const { checked } = e.target;
|
|
1201
|
+
const { isChecked } = this.state;
|
|
1202
|
+
let collection = [];
|
|
1203
|
+
|
|
1204
|
+
if (checked) {
|
|
1205
|
+
for (let i = 0; i <= 9; i++) {
|
|
1206
|
+
collection = [...collection, i];
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
this.setState(
|
|
1211
|
+
{
|
|
1212
|
+
selectedItems: collection,
|
|
1213
|
+
areAllSelected: checked,
|
|
1214
|
+
isDrawerExpanded: false,
|
|
1215
|
+
activeCard: null,
|
|
1216
|
+
isChecked
|
|
1217
|
+
},
|
|
1218
|
+
this.updateSelected
|
|
1219
|
+
);
|
|
1220
|
+
};
|
|
1221
|
+
|
|
1222
|
+
this.onSplitButtonSelect = _event => {
|
|
1223
|
+
this.setState((prevState, _props) => ({
|
|
1224
|
+
splitButtonDropdownIsOpen: !prevState.splitButtonDropdownIsOpen,
|
|
1225
|
+
isDrawerExpanded: false,
|
|
1226
|
+
activeCard: null
|
|
1227
|
+
}));
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
this.onSplitButtonToggle = isOpen => {
|
|
1231
|
+
this.setState({
|
|
1232
|
+
splitButtonDropdownIsOpen: isOpen
|
|
1233
|
+
});
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
this.onCardKebabDropdownToggle = (event, key, isCardKebabDropdownOpen) => {
|
|
1237
|
+
event.stopPropagation();
|
|
1238
|
+
this.setState({
|
|
1239
|
+
[key]: isCardKebabDropdownOpen
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
this.onCardKebabDropdownSelect = (key, _event) => {
|
|
1244
|
+
this.setState({
|
|
1245
|
+
[key]: !this.state[key]
|
|
1246
|
+
});
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1249
|
+
this.deleteItem = (event, item) => {
|
|
1250
|
+
event.stopPropagation();
|
|
1251
|
+
const filter = getter => val => getter(val) !== item.id;
|
|
1252
|
+
const filteredCards = this.state.res.filter(filter(({ id }) => id));
|
|
1253
|
+
this.setState({
|
|
1254
|
+
res: filteredCards,
|
|
1255
|
+
selectedItems: this.state.selectedItems.filter(filter(id => id)),
|
|
1256
|
+
totalItemCount: this.state.totalItemCount - 1,
|
|
1257
|
+
isDrawerExpanded: false,
|
|
1258
|
+
activeCard: null
|
|
1259
|
+
});
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
this.onKeyDown = event => {
|
|
1263
|
+
if (event.target !== event.currentTarget) {
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
if ([13, 32].includes(event.keyCode)) {
|
|
1268
|
+
if (event.currentTarget.id === this.state.activeCard) {
|
|
1269
|
+
this.setState({
|
|
1270
|
+
isDrawerExpanded: !this.state.isDrawerExpanded,
|
|
1271
|
+
activeCard: null
|
|
1272
|
+
});
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
event.preventDefault();
|
|
1276
|
+
const newSelected = event.currentTarget.id;
|
|
1277
|
+
this.setState({
|
|
1278
|
+
activeCard: newSelected,
|
|
1279
|
+
isDrawerExpanded: true
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1143
1283
|
}
|
|
1144
1284
|
|
|
1145
1285
|
getAllItems() {
|
|
@@ -1197,16 +1337,60 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1197
1337
|
);
|
|
1198
1338
|
}
|
|
1199
1339
|
|
|
1340
|
+
buildSelectDropdown() {
|
|
1341
|
+
const { splitButtonDropdownIsOpen, selectedItems, areAllSelected } = this.state;
|
|
1342
|
+
const numSelected = selectedItems.length;
|
|
1343
|
+
const allSelected = areAllSelected;
|
|
1344
|
+
const anySelected = numSelected > 0;
|
|
1345
|
+
const someChecked = anySelected ? null : false;
|
|
1346
|
+
const isChecked = allSelected ? true : someChecked;
|
|
1347
|
+
const splitButtonDropdownItems = [
|
|
1348
|
+
<DropdownItem key="item-1" onClick={this.selectNone}>
|
|
1349
|
+
Select none (0 items)
|
|
1350
|
+
</DropdownItem>,
|
|
1351
|
+
<DropdownItem key="item-2" onClick={this.selectPage}>
|
|
1352
|
+
Select page ({this.state.res.length} items)
|
|
1353
|
+
</DropdownItem>,
|
|
1354
|
+
<DropdownItem key="item-3" onClick={this.selectAll}>
|
|
1355
|
+
Select all ({this.state.totalItemCount} items)
|
|
1356
|
+
</DropdownItem>
|
|
1357
|
+
];
|
|
1358
|
+
|
|
1359
|
+
return (
|
|
1360
|
+
<Dropdown
|
|
1361
|
+
position={DropdownPosition.left}
|
|
1362
|
+
onSelect={this.onSplitButtonSelect}
|
|
1363
|
+
toggle={
|
|
1364
|
+
<DropdownToggle
|
|
1365
|
+
splitButtonItems={[
|
|
1366
|
+
<DropdownToggleCheckbox
|
|
1367
|
+
id="example-checkbox-2"
|
|
1368
|
+
key="split-checkbox"
|
|
1369
|
+
aria-label={anySelected ? 'Deselect all' : 'Select all'}
|
|
1370
|
+
isChecked={areAllSelected}
|
|
1371
|
+
onClick={this.splitCheckboxSelectAll}
|
|
1372
|
+
></DropdownToggleCheckbox>
|
|
1373
|
+
]}
|
|
1374
|
+
onToggle={this.onSplitButtonToggle}
|
|
1375
|
+
>
|
|
1376
|
+
{numSelected !== 0 && (
|
|
1377
|
+
<React.Fragment>{allSelected ? this.state.totalItemCount : numSelected} selected</React.Fragment>
|
|
1378
|
+
)}
|
|
1379
|
+
</DropdownToggle>
|
|
1380
|
+
}
|
|
1381
|
+
isOpen={splitButtonDropdownIsOpen}
|
|
1382
|
+
dropdownItems={splitButtonDropdownItems}
|
|
1383
|
+
/>
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1200
1387
|
render() {
|
|
1201
1388
|
const {
|
|
1202
1389
|
isDrawerExpanded,
|
|
1390
|
+
isChecked,
|
|
1391
|
+
selectedItems,
|
|
1203
1392
|
activeCard,
|
|
1204
|
-
isUpperToolbarDropdownOpen,
|
|
1205
|
-
isLowerToolbarDropdownOpen,
|
|
1206
|
-
isUpperToolbarKebabDropdownOpen,
|
|
1207
1393
|
isLowerToolbarKebabDropdownOpen,
|
|
1208
|
-
isCardKebabDropdownOpen,
|
|
1209
|
-
activeItem,
|
|
1210
1394
|
filters,
|
|
1211
1395
|
res
|
|
1212
1396
|
} = this.state;
|
|
@@ -1231,35 +1415,30 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1231
1415
|
|
|
1232
1416
|
const toolbarItems = (
|
|
1233
1417
|
<React.Fragment>
|
|
1234
|
-
<ToolbarItem
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
/>
|
|
1252
|
-
</OverflowMenuControl>
|
|
1253
|
-
</OverflowMenu>
|
|
1418
|
+
<ToolbarItem>{this.buildSelectDropdown()}</ToolbarItem>
|
|
1419
|
+
<ToolbarItem>
|
|
1420
|
+
<Button variant="primary">Create instance</Button>
|
|
1421
|
+
</ToolbarItem>
|
|
1422
|
+
<ToolbarItem>
|
|
1423
|
+
<Button variant="secondary">Action</Button>
|
|
1424
|
+
</ToolbarItem>
|
|
1425
|
+
<ToolbarItem hasAdditionalOptions>
|
|
1426
|
+
<Dropdown
|
|
1427
|
+
onSelect={this.onToolbarKebabDropdownSelect}
|
|
1428
|
+
toggle={<KebabToggle onToggle={this.onToolbarKebabDropdownToggle} id="card-view-data-toolbar-dropdown" />}
|
|
1429
|
+
isOpen={isLowerToolbarKebabDropdownOpen}
|
|
1430
|
+
isPlain
|
|
1431
|
+
dropdownItems={toolbarKebabDropdownItems}
|
|
1432
|
+
isFlipEnabled
|
|
1433
|
+
menuAppendTo="parent"
|
|
1434
|
+
/>
|
|
1254
1435
|
</ToolbarItem>
|
|
1255
1436
|
</React.Fragment>
|
|
1256
1437
|
);
|
|
1257
1438
|
|
|
1258
1439
|
const filtered =
|
|
1259
1440
|
filters.products.length > 0
|
|
1260
|
-
? res.filter(card =>
|
|
1261
|
-
return filters.products.length === 0 || filters.products.includes(card.name);
|
|
1262
|
-
})
|
|
1441
|
+
? res.filter(card => filters.products.length === 0 || filters.products.includes(card.name))
|
|
1263
1442
|
: res;
|
|
1264
1443
|
|
|
1265
1444
|
const icons = {
|
|
@@ -1276,27 +1455,54 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1276
1455
|
};
|
|
1277
1456
|
|
|
1278
1457
|
const drawerContent = (
|
|
1279
|
-
<Gallery hasGutter role=
|
|
1458
|
+
<Gallery hasGutter role="region" aria-label="Selectable card container">
|
|
1280
1459
|
{filtered.map((product, key) => (
|
|
1281
|
-
<
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
>
|
|
1293
|
-
<
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1460
|
+
<Card
|
|
1461
|
+
isHoverable
|
|
1462
|
+
key={product.name}
|
|
1463
|
+
id={'card-view-' + key}
|
|
1464
|
+
onKeyDown={this.onKeyDown}
|
|
1465
|
+
onClick={this.onCardClick}
|
|
1466
|
+
onSelectableInputChange={this.onChange}
|
|
1467
|
+
isSelectableRaised
|
|
1468
|
+
isSelected={activeCard === 'card-view-' + key}
|
|
1469
|
+
hasSelectableInput
|
|
1470
|
+
>
|
|
1471
|
+
<CardHeader>
|
|
1472
|
+
<img src={icons[product.icon]} alt={`${product.name} icon`} style={{ height: '50px' }} />
|
|
1473
|
+
<CardActions>
|
|
1474
|
+
<Dropdown
|
|
1475
|
+
isPlain
|
|
1476
|
+
position="right"
|
|
1477
|
+
onSelect={e => this.onCardKebabDropdownSelect(key, e)}
|
|
1478
|
+
toggle={
|
|
1479
|
+
<KebabToggle
|
|
1480
|
+
onToggle={(isCardKebabDropdownOpen, event) =>
|
|
1481
|
+
this.onCardKebabDropdownToggle(event, key, isCardKebabDropdownOpen)
|
|
1482
|
+
}
|
|
1483
|
+
/>
|
|
1484
|
+
}
|
|
1485
|
+
isOpen={this.state[key]}
|
|
1486
|
+
dropdownItems={[
|
|
1487
|
+
<DropdownItem key="trash" onClick={e => this.deleteItem(e, product)} position="right">
|
|
1488
|
+
<TrashIcon />
|
|
1489
|
+
Delete
|
|
1490
|
+
</DropdownItem>
|
|
1491
|
+
]}
|
|
1492
|
+
/>
|
|
1493
|
+
<Checkbox
|
|
1494
|
+
checked={isChecked}
|
|
1495
|
+
onClick={event => this.onCheckboxClick(event, product.id)}
|
|
1496
|
+
value={product.id}
|
|
1497
|
+
isChecked={selectedItems.includes(product.id)}
|
|
1498
|
+
aria-label="card checkbox example"
|
|
1499
|
+
id={`check-${product.id}`}
|
|
1500
|
+
/>
|
|
1501
|
+
</CardActions>
|
|
1502
|
+
</CardHeader>
|
|
1503
|
+
<CardTitle>{product.name}</CardTitle>
|
|
1504
|
+
<CardBody>{product.description}</CardBody>
|
|
1505
|
+
</Card>
|
|
1300
1506
|
))}
|
|
1301
1507
|
</Gallery>
|
|
1302
1508
|
);
|
|
@@ -1321,10 +1527,10 @@ class PrimaryDetailCardView extends React.Component {
|
|
|
1321
1527
|
</p>
|
|
1322
1528
|
</FlexItem>
|
|
1323
1529
|
<FlexItem>
|
|
1324
|
-
<Progress value={activeCard * 10} title="Title" />
|
|
1530
|
+
<Progress value={activeCard && activeCard.charAt(activeCard.length - 1) * 10} title="Title" />
|
|
1325
1531
|
</FlexItem>
|
|
1326
1532
|
<FlexItem>
|
|
1327
|
-
<Progress value={activeCard * 5} title="Title" />
|
|
1533
|
+
<Progress value={activeCard && activeCard.charAt(activeCard.length - 1) * 5} title="Title" />
|
|
1328
1534
|
</FlexItem>
|
|
1329
1535
|
</Flex>
|
|
1330
1536
|
</DrawerPanelBody>
|