@patternfly/react-core 6.0.0-alpha.66 → 6.0.0-alpha.67
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 +6 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/Chip/package.json +1 -1
- package/dist/dynamic/deprecated/components/DragDrop/package.json +1 -1
- package/dist/dynamic/deprecated/components/Modal/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/dynamic/styles/package.json +1 -1
- package/dist/umd/assets/{output-C4GbSx1X.css → output-DC58BpxL.css} +10024 -10024
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- package/src/demos/CustomMenus/examples/DateSelectDemo.tsx +25 -13
- package/src/demos/examples/Card/CardEventsView.tsx +15 -8
- package/src/demos/examples/Card/CardLogView.tsx +4 -4
- package/src/demos/examples/Card/CardStatusTabbed.tsx +23 -6
- package/src/demos/examples/Card/CardUtilizationDemo3.tsx +5 -2
- package/src/demos/CustomMenus/examples/ComposableDateSelect.tsx +0 -113
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"6.0.0-alpha.66","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"6.0.0-alpha.66","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"6.0.0-alpha.66","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.67",
|
|
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",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"react": "^17 || ^18",
|
|
66
66
|
"react-dom": "^17 || ^18"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d9e64b4ebcc17b91ea3ea8a1e3f8b60e901d496b"
|
|
69
69
|
}
|
|
@@ -36,27 +36,39 @@ export const DateSelectDemo: React.FunctionComponent = () => {
|
|
|
36
36
|
3: 'Last 14 days '
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const getDateNDaysBefore = (date: Date, days: number) => new Date(new Date().setDate(date.getDate() - days));
|
|
40
|
+
|
|
41
|
+
const dates = {
|
|
42
|
+
0: date,
|
|
43
|
+
1: getDateNDaysBefore(date, 1),
|
|
44
|
+
2: getDateNDaysBefore(date, 7),
|
|
45
|
+
3: getDateNDaysBefore(date, 14)
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
const dateText = {
|
|
40
|
-
0: <Timestamp>({dateString(
|
|
41
|
-
1: (
|
|
42
|
-
<Timestamp>
|
|
43
|
-
({dateString(new Date(new Date().setDate(date.getDate() - 1)))} - {dateString(date)})
|
|
44
|
-
</Timestamp>
|
|
45
|
-
),
|
|
49
|
+
0: <Timestamp date={dates[0]}>({dateString(dates[0])})</Timestamp>,
|
|
50
|
+
1: <Timestamp date={dates[1]}>({dateString(dates[1])})</Timestamp>,
|
|
46
51
|
2: (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
<>
|
|
53
|
+
<Timestamp date={dates[2]}>
|
|
54
|
+
({dateString(dates[2])}
|
|
55
|
+
-
|
|
56
|
+
</Timestamp>
|
|
57
|
+
<Timestamp date={date}>{dateString(date)})</Timestamp>
|
|
58
|
+
</>
|
|
50
59
|
),
|
|
51
60
|
3: (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
<>
|
|
62
|
+
<Timestamp date={dates[3]}>
|
|
63
|
+
({dateString(dates[3])}
|
|
64
|
+
-
|
|
65
|
+
</Timestamp>
|
|
66
|
+
<Timestamp date={date}>{dateString(date)})</Timestamp>
|
|
67
|
+
</>
|
|
55
68
|
)
|
|
56
69
|
};
|
|
57
70
|
|
|
58
71
|
return (
|
|
59
|
-
// eslint-disable-next-line no-console
|
|
60
72
|
<Select
|
|
61
73
|
isOpen={isOpen}
|
|
62
74
|
onOpenChange={(isOpen) => setIsOpen(isOpen)}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
Flex,
|
|
15
15
|
FlexItem,
|
|
16
16
|
Gallery,
|
|
17
|
+
Icon,
|
|
17
18
|
MenuToggle,
|
|
18
19
|
Select,
|
|
19
20
|
SelectList,
|
|
@@ -39,7 +40,7 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
39
40
|
Error
|
|
40
41
|
</SelectOption>
|
|
41
42
|
<SelectOption value="Warning" key="option3">
|
|
42
|
-
|
|
43
|
+
Warning
|
|
43
44
|
</SelectOption>
|
|
44
45
|
</SelectList>
|
|
45
46
|
);
|
|
@@ -76,7 +77,9 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
76
77
|
<DescriptionListTerm>
|
|
77
78
|
<Flex flexWrap={{ default: 'nowrap' }}>
|
|
78
79
|
<FlexItem>
|
|
79
|
-
<
|
|
80
|
+
<Icon status="danger">
|
|
81
|
+
<ExclamationCircleIcon aria-hidden="true" />
|
|
82
|
+
</Icon>
|
|
80
83
|
</FlexItem>
|
|
81
84
|
<FlexItem>
|
|
82
85
|
<span>Readiness probe failed</span>
|
|
@@ -88,14 +91,16 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
88
91
|
connection refused
|
|
89
92
|
</DescriptionListDescription>
|
|
90
93
|
<DescriptionListDescription>
|
|
91
|
-
<Timestamp
|
|
94
|
+
<Timestamp date={new Date('2023-06-17T11:02')} dateFormat="medium" timeFormat="short" />
|
|
92
95
|
</DescriptionListDescription>
|
|
93
96
|
</DescriptionListGroup>
|
|
94
97
|
<DescriptionListGroup>
|
|
95
98
|
<DescriptionListTerm>
|
|
96
99
|
<Flex flexWrap={{ default: 'nowrap' }}>
|
|
97
100
|
<FlexItem>
|
|
98
|
-
<
|
|
101
|
+
<Icon status="success">
|
|
102
|
+
<CheckCircleIcon aria-hidden="true" />
|
|
103
|
+
</Icon>
|
|
99
104
|
</FlexItem>
|
|
100
105
|
<FlexItem>
|
|
101
106
|
<span>Successful assignment</span>
|
|
@@ -106,7 +111,7 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
106
111
|
Successfully assigned default/example to ip-10-0-130-149.ec2.internal
|
|
107
112
|
</DescriptionListDescription>
|
|
108
113
|
<DescriptionListDescription>
|
|
109
|
-
<Timestamp
|
|
114
|
+
<Timestamp date={new Date('2023-06-17T11:13')} dateFormat="medium" timeFormat="short" />
|
|
110
115
|
</DescriptionListDescription>
|
|
111
116
|
</DescriptionListGroup>
|
|
112
117
|
<DescriptionListGroup>
|
|
@@ -122,14 +127,16 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
122
127
|
</DescriptionListTerm>
|
|
123
128
|
<DescriptionListDescription>Pulling image "openshift/hello-openshift"</DescriptionListDescription>
|
|
124
129
|
<DescriptionListDescription>
|
|
125
|
-
<Timestamp
|
|
130
|
+
<Timestamp date={new Date('2023-06-17T10:59')} dateFormat="medium" timeFormat="short" />
|
|
126
131
|
</DescriptionListDescription>
|
|
127
132
|
</DescriptionListGroup>
|
|
128
133
|
<DescriptionListGroup>
|
|
129
134
|
<DescriptionListTerm>
|
|
130
135
|
<Flex flexWrap={{ default: 'nowrap' }}>
|
|
131
136
|
<FlexItem>
|
|
132
|
-
<
|
|
137
|
+
<Icon status="success">
|
|
138
|
+
<CheckCircleIcon aria-hidden="true" />
|
|
139
|
+
</Icon>
|
|
133
140
|
</FlexItem>
|
|
134
141
|
<FlexItem>
|
|
135
142
|
<span>Created container</span>
|
|
@@ -138,7 +145,7 @@ export const CardEventsView: React.FunctionComponent = () => {
|
|
|
138
145
|
</DescriptionListTerm>
|
|
139
146
|
<DescriptionListDescription>Created container hello-openshift</DescriptionListDescription>
|
|
140
147
|
<DescriptionListDescription>
|
|
141
|
-
<Timestamp
|
|
148
|
+
<Timestamp date={new Date('2023-06-17T10:45')} dateFormat="medium" timeFormat="short" />
|
|
142
149
|
</DescriptionListDescription>
|
|
143
150
|
</DescriptionListGroup>
|
|
144
151
|
</DescriptionList>
|
|
@@ -79,7 +79,7 @@ export const CardLogView: React.FunctionComponent = () => {
|
|
|
79
79
|
connection refused
|
|
80
80
|
</DescriptionListDescription>
|
|
81
81
|
<DescriptionListDescription>
|
|
82
|
-
<Timestamp
|
|
82
|
+
<Timestamp date={new Date('2023-06-17T11:02')} dateFormat="medium" timeFormat="short" />
|
|
83
83
|
</DescriptionListDescription>
|
|
84
84
|
</DescriptionListGroup>
|
|
85
85
|
<DescriptionListGroup>
|
|
@@ -88,21 +88,21 @@ export const CardLogView: React.FunctionComponent = () => {
|
|
|
88
88
|
Successfully assigned default/example to ip-10-0-130-149.ec2.internal
|
|
89
89
|
</DescriptionListDescription>
|
|
90
90
|
<DescriptionListDescription>
|
|
91
|
-
<Timestamp
|
|
91
|
+
<Timestamp date={new Date('2023-06-17T11:13')} dateFormat="medium" timeFormat="short" />
|
|
92
92
|
</DescriptionListDescription>
|
|
93
93
|
</DescriptionListGroup>
|
|
94
94
|
<DescriptionListGroup>
|
|
95
95
|
<DescriptionListTerm>Pulling image</DescriptionListTerm>
|
|
96
96
|
<DescriptionListDescription>Pulling image "openshift/hello-openshift"</DescriptionListDescription>
|
|
97
97
|
<DescriptionListDescription>
|
|
98
|
-
<Timestamp
|
|
98
|
+
<Timestamp date={new Date('2023-06-17T10:59')} dateFormat="medium" timeFormat="short" />
|
|
99
99
|
</DescriptionListDescription>
|
|
100
100
|
</DescriptionListGroup>
|
|
101
101
|
<DescriptionListGroup>
|
|
102
102
|
<DescriptionListTerm>Created container</DescriptionListTerm>
|
|
103
103
|
<DescriptionListDescription>Created container hello-openshift</DescriptionListDescription>
|
|
104
104
|
<DescriptionListDescription>
|
|
105
|
-
<Timestamp
|
|
105
|
+
<Timestamp date={new Date('2023-06-17T10:45')} dateFormat="medium" timeFormat="short" />
|
|
106
106
|
</DescriptionListDescription>
|
|
107
107
|
</DescriptionListGroup>
|
|
108
108
|
</DescriptionList>
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
DescriptionListTerm,
|
|
10
10
|
Flex,
|
|
11
11
|
FlexItem,
|
|
12
|
+
Icon,
|
|
12
13
|
Tab,
|
|
13
14
|
TabContent,
|
|
14
15
|
Tabs,
|
|
@@ -23,25 +24,41 @@ const descriptionListData = [
|
|
|
23
24
|
status: 'Running',
|
|
24
25
|
resourceName: 'Resource name that is long and can wrap',
|
|
25
26
|
detail: '121 Systems',
|
|
26
|
-
icon:
|
|
27
|
+
icon: (
|
|
28
|
+
<Icon status="success">
|
|
29
|
+
<CheckCircleIcon />
|
|
30
|
+
</Icon>
|
|
31
|
+
)
|
|
27
32
|
},
|
|
28
33
|
{
|
|
29
|
-
status: '
|
|
34
|
+
status: 'Failed',
|
|
30
35
|
resourceName: 'Resource name that is long and can wrap',
|
|
31
36
|
detail: '123 Systems',
|
|
32
|
-
icon:
|
|
37
|
+
icon: (
|
|
38
|
+
<Icon status="danger">
|
|
39
|
+
<ExclamationCircleIcon />
|
|
40
|
+
</Icon>
|
|
41
|
+
)
|
|
33
42
|
},
|
|
34
43
|
{
|
|
35
44
|
status: 'Running',
|
|
36
45
|
resourceName: 'Resource name that is long and can wrap',
|
|
37
46
|
detail: '122 Systems',
|
|
38
|
-
icon:
|
|
47
|
+
icon: (
|
|
48
|
+
<Icon status="success">
|
|
49
|
+
<CheckCircleIcon />
|
|
50
|
+
</Icon>
|
|
51
|
+
)
|
|
39
52
|
},
|
|
40
53
|
{
|
|
41
|
-
status: '
|
|
54
|
+
status: 'Failed',
|
|
42
55
|
resourceName: 'Resource name that is long and can wrap',
|
|
43
56
|
detail: '124 Systems',
|
|
44
|
-
icon:
|
|
57
|
+
icon: (
|
|
58
|
+
<Icon status="danger">
|
|
59
|
+
<ExclamationCircleIcon />
|
|
60
|
+
</Icon>
|
|
61
|
+
)
|
|
45
62
|
}
|
|
46
63
|
];
|
|
47
64
|
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
SelectList,
|
|
16
16
|
SelectOption,
|
|
17
17
|
MenuToggle,
|
|
18
|
-
MenuToggleElement
|
|
18
|
+
MenuToggleElement,
|
|
19
|
+
Icon
|
|
19
20
|
} from '@patternfly/react-core';
|
|
20
21
|
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
|
|
21
22
|
import { Chart, ChartStack, ChartBar, ChartTooltip } from '@patternfly/react-charts';
|
|
@@ -79,7 +80,9 @@ export const CardUtilizationDemo3: React.FunctionComponent = () => {
|
|
|
79
80
|
<span>System</span>
|
|
80
81
|
</FlexItem>
|
|
81
82
|
<Flex>
|
|
82
|
-
<
|
|
83
|
+
<Icon status="danger">
|
|
84
|
+
<ExclamationCircleIcon aria-hidden />
|
|
85
|
+
</Icon>
|
|
83
86
|
<a href="#">25 incidents detected</a>
|
|
84
87
|
</Flex>
|
|
85
88
|
<FlexItem>
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MenuToggle, Menu, MenuContent, MenuList, MenuItem, Popper, Timestamp } from '@patternfly/react-core';
|
|
3
|
-
|
|
4
|
-
export const ComposableSimpleDropdown: React.FunctionComponent = () => {
|
|
5
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
-
const [selected, setSelected] = React.useState<number>(0);
|
|
7
|
-
const toggleRef = React.useRef<HTMLButtonElement>();
|
|
8
|
-
const menuRef = React.useRef<HTMLDivElement>();
|
|
9
|
-
|
|
10
|
-
const handleMenuKeys = (event: KeyboardEvent) => {
|
|
11
|
-
if (!isOpen) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
if (menuRef?.current?.contains(event.target as Node) || toggleRef?.current?.contains(event.target as Node)) {
|
|
15
|
-
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
16
|
-
setIsOpen(!isOpen);
|
|
17
|
-
toggleRef?.current?.focus();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
23
|
-
if (isOpen && !menuRef?.current?.contains(event.target as Node)) {
|
|
24
|
-
setIsOpen(false);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
React.useEffect(() => {
|
|
29
|
-
window.addEventListener('keydown', handleMenuKeys);
|
|
30
|
-
window.addEventListener('click', handleClickOutside);
|
|
31
|
-
return () => {
|
|
32
|
-
window.removeEventListener('keydown', handleMenuKeys);
|
|
33
|
-
window.removeEventListener('click', handleClickOutside);
|
|
34
|
-
};
|
|
35
|
-
}, [isOpen, menuRef]);
|
|
36
|
-
|
|
37
|
-
const onToggleClick = (ev: React.MouseEvent) => {
|
|
38
|
-
ev.stopPropagation(); // Stop handleClickOutside from handling
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
if (menuRef.current) {
|
|
41
|
-
const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
|
|
42
|
-
firstElement && (firstElement as HTMLElement).focus();
|
|
43
|
-
}
|
|
44
|
-
}, 0);
|
|
45
|
-
setIsOpen(!isOpen);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const monthStrings = [
|
|
49
|
-
'January',
|
|
50
|
-
'February',
|
|
51
|
-
'March',
|
|
52
|
-
'April',
|
|
53
|
-
'May',
|
|
54
|
-
'June',
|
|
55
|
-
'July',
|
|
56
|
-
'August',
|
|
57
|
-
'September',
|
|
58
|
-
'October',
|
|
59
|
-
'November',
|
|
60
|
-
'December'
|
|
61
|
-
];
|
|
62
|
-
|
|
63
|
-
const dateString = (date: Date) => `${monthStrings[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
|
|
64
|
-
|
|
65
|
-
const date = new Date();
|
|
66
|
-
|
|
67
|
-
const toggleText = {
|
|
68
|
-
0: 'Today ',
|
|
69
|
-
1: 'Yesterday ',
|
|
70
|
-
2: 'Last 7 days ',
|
|
71
|
-
3: 'Last 14 days '
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const dateText = {
|
|
75
|
-
0: <Timestamp>({dateString(date)})</Timestamp>,
|
|
76
|
-
1: (
|
|
77
|
-
<Timestamp>
|
|
78
|
-
({dateString(new Date(new Date().setDate(date.getDate() - 1)))} - {dateString(date)})
|
|
79
|
-
</Timestamp>
|
|
80
|
-
),
|
|
81
|
-
2: (
|
|
82
|
-
<Timestamp>
|
|
83
|
-
({dateString(new Date(new Date().setDate(date.getDate() - 7)))} - {dateString(date)})
|
|
84
|
-
</Timestamp>
|
|
85
|
-
),
|
|
86
|
-
3: (
|
|
87
|
-
<Timestamp>
|
|
88
|
-
({dateString(new Date(new Date().setDate(date.getDate() - 14)))} - {dateString(date)})
|
|
89
|
-
</Timestamp>
|
|
90
|
-
)
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const toggle = (
|
|
94
|
-
<MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen} style={{ minWidth: '250px' }}>
|
|
95
|
-
<span style={{ verticalAlign: 'middle', marginRight: '8px' }}>{toggleText[selected]}</span>
|
|
96
|
-
{dateText[selected]}
|
|
97
|
-
</MenuToggle>
|
|
98
|
-
);
|
|
99
|
-
const menu = (
|
|
100
|
-
// eslint-disable-next-line no-console
|
|
101
|
-
<Menu ref={menuRef} onSelect={(_ev, itemId) => setSelected(itemId as number)} selected={selected}>
|
|
102
|
-
<MenuContent>
|
|
103
|
-
<MenuList>
|
|
104
|
-
<MenuItem itemId={0}>Today</MenuItem>
|
|
105
|
-
<MenuItem itemId={1}>Yesterday</MenuItem>
|
|
106
|
-
<MenuItem itemId={2}>Last 7 days</MenuItem>
|
|
107
|
-
<MenuItem itemId={3}>Last 14 days</MenuItem>
|
|
108
|
-
</MenuList>
|
|
109
|
-
</MenuContent>
|
|
110
|
-
</Menu>
|
|
111
|
-
);
|
|
112
|
-
return <Popper trigger={toggle} triggerRef={toggleRef} popper={menu} popperRef={menuRef} isVisible={isOpen} />;
|
|
113
|
-
};
|