@patternfly/react-core 5.0.0-alpha.50 → 5.0.0-alpha.52
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/BackgroundImage/BackgroundImage.d.ts.map +1 -1
- package/dist/esm/components/BackgroundImage/BackgroundImage.js +34 -36
- package/dist/esm/components/BackgroundImage/BackgroundImage.js.map +1 -1
- package/dist/esm/components/Icon/Icon.d.ts +1 -1
- package/dist/esm/components/Icon/Icon.d.ts.map +1 -1
- package/dist/esm/components/Modal/ModalContent.js.map +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerListItem.d.ts +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerListItem.d.ts.map +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerListItem.js +1 -1
- package/dist/esm/components/NotificationDrawer/NotificationDrawerListItem.js.map +1 -1
- package/dist/esm/components/Popover/Popover.js +1 -1
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +7 -3
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/components/BackgroundImage/BackgroundImage.d.ts.map +1 -1
- package/dist/js/components/BackgroundImage/BackgroundImage.js +34 -36
- package/dist/js/components/BackgroundImage/BackgroundImage.js.map +1 -1
- package/dist/js/components/Icon/Icon.d.ts +1 -1
- package/dist/js/components/Icon/Icon.d.ts.map +1 -1
- package/dist/js/components/Modal/ModalContent.js.map +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerListItem.d.ts +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerListItem.d.ts.map +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerListItem.js +1 -1
- package/dist/js/components/NotificationDrawer/NotificationDrawerListItem.js.map +1 -1
- package/dist/js/components/Popover/Popover.js +1 -1
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +7 -3
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/styles/assets/images/pfbg-icon.svg +1 -0
- package/dist/styles/assets/pficon/pficon.scss +1 -2
- package/dist/styles/base-no-reset.css +9 -32
- package/dist/styles/base.css +43 -73
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/scripts/copyStyles.js +1 -1
- package/src/components/BackgroundImage/BackgroundImage.tsx +47 -44
- package/src/components/BackgroundImage/__tests__/__snapshots__/BackgroundImage.test.tsx.snap +4 -64
- package/src/components/Icon/Icon.tsx +1 -1
- package/src/components/Icon/__tests__/Icon.test.tsx +2 -2
- package/src/components/Icon/examples/IconStatus.tsx +1 -1
- package/src/components/LoginPage/__tests__/__snapshots__/LoginPage.test.tsx.snap +2 -32
- package/src/components/Modal/ModalContent.tsx +1 -1
- package/src/components/NotificationDrawer/NotificationDrawerListItem.tsx +2 -2
- package/src/components/NotificationDrawer/__tests__/__snapshots__/NotificationDrawerListItem.test.tsx.snap +1 -1
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/TimePicker/TimePicker.tsx +16 -4
- package/src/components/TimePicker/__tests__/TimePicker.test.tsx +22 -0
- package/src/demos/DatePicker/DatePicker.md +45 -40
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-Black.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-BlackItalic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-BoldItalic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-Italic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-Medium.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-MediumItalic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatDisplay/RedHatDisplay-Regular.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-Bold.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-BoldItalic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-Italic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-Medium.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-MediumItalic.woff +0 -0
- package/dist/styles/assets/fonts/RedHatText/RedHatText-Regular.woff +0 -0
- package/dist/styles/assets/pficon/pficon.woff +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.52",
|
|
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",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"subpaths": "node scripts/createSubpaths.js"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@patternfly/react-icons": "^5.0.0-alpha.
|
|
49
|
-
"@patternfly/react-styles": "^5.0.0-alpha.
|
|
50
|
-
"@patternfly/react-tokens": "^5.0.0-alpha.
|
|
48
|
+
"@patternfly/react-icons": "^5.0.0-alpha.8",
|
|
49
|
+
"@patternfly/react-styles": "^5.0.0-alpha.6",
|
|
50
|
+
"@patternfly/react-tokens": "^5.0.0-alpha.6",
|
|
51
51
|
"focus-trap": "7.4.0",
|
|
52
52
|
"react-dropzone": "^14.2.3",
|
|
53
53
|
"tslib": "^2.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@patternfly/patternfly": "5.0.0-alpha.
|
|
56
|
+
"@patternfly/patternfly": "5.0.0-alpha.37",
|
|
57
57
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
59
59
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "5eea8522248a6f8caa1d7cb27f5f5b95ca823b7b"
|
|
74
74
|
}
|
package/scripts/copyStyles.js
CHANGED
|
@@ -24,7 +24,7 @@ copySync(join(pfDir, 'assets/fonts'), join(stylesDir, 'assets/fonts'), {
|
|
|
24
24
|
// Copy css
|
|
25
25
|
const baseCssFiles = {
|
|
26
26
|
'base.css': 'patternfly-base.css',
|
|
27
|
-
'base-no-reset.css': 'patternfly-base-no-
|
|
27
|
+
'base-no-reset.css': 'patternfly-base-no-globals.css'
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
for (const [targetCss, baseCss] of Object.entries(baseCssFiles)) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
2
|
+
// Commented imports that no longer exist. This component will be updated with issue #8452 resolution
|
|
3
|
+
|
|
4
|
+
// import cssVar from '@patternfly/react-tokens/dist/esm/c_background_image_BackgroundImage';
|
|
5
|
+
// import cssVarName2x from '@patternfly/react-tokens/dist/esm/c_background_image_BackgroundImage_2x';
|
|
6
|
+
// import cssVarNameSm from '@patternfly/react-tokens/dist/esm/c_background_image_BackgroundImage_sm';
|
|
7
|
+
// import cssVarNameSm2x from '@patternfly/react-tokens/dist/esm/c_background_image_BackgroundImage_sm_2x';
|
|
8
|
+
// import cssVarNameLg from '@patternfly/react-tokens/dist/esm/c_background_image_BackgroundImage_lg';
|
|
9
|
+
// import cssVarNameFilter from '@patternfly/react-tokens/dist/esm/c_background_image_Filter';
|
|
8
10
|
import { css } from '@patternfly/react-styles';
|
|
9
11
|
import styles from '@patternfly/react-styles/css/components/BackgroundImage/background-image';
|
|
10
12
|
|
|
@@ -16,17 +18,17 @@ export interface BackgroundImageSrcMap {
|
|
|
16
18
|
lg: string;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const defaultFilter = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
21
|
+
// const defaultFilter = (
|
|
22
|
+
// <filter>
|
|
23
|
+
// <feColorMatrix type="matrix" values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0"></feColorMatrix>
|
|
24
|
+
// <feComponentTransfer colorInterpolationFilters="sRGB" result="duotone">
|
|
25
|
+
// <feFuncR type="table" tableValues="0.086274509803922 0.43921568627451"></feFuncR>
|
|
26
|
+
// <feFuncG type="table" tableValues="0.086274509803922 0.43921568627451"></feFuncG>
|
|
27
|
+
// <feFuncB type="table" tableValues="0.086274509803922 0.43921568627451"></feFuncB>
|
|
28
|
+
// <feFuncA type="table" tableValues="0 1"></feFuncA>
|
|
29
|
+
// </feComponentTransfer>
|
|
30
|
+
// </filter>
|
|
31
|
+
// );
|
|
30
32
|
|
|
31
33
|
export interface BackgroundImageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'src'> {
|
|
32
34
|
/** Additional classes added to the background. */
|
|
@@ -37,41 +39,42 @@ export interface BackgroundImageProps extends Omit<React.HTMLProps<HTMLDivElemen
|
|
|
37
39
|
src: string | BackgroundImageSrcMap;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
let filterCounter = 0;
|
|
42
|
+
// let filterCounter = 0;
|
|
41
43
|
|
|
42
44
|
export const BackgroundImage: React.FunctionComponent<BackgroundImageProps> = ({
|
|
43
45
|
className,
|
|
44
|
-
src,
|
|
45
|
-
filter = defaultFilter,
|
|
46
|
+
// src,
|
|
47
|
+
// filter = defaultFilter,
|
|
46
48
|
...props
|
|
47
|
-
}: BackgroundImageProps) =>
|
|
48
|
-
const getUrlValue = (size: keyof BackgroundImageSrcMap) => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
}: BackgroundImageProps) =>
|
|
50
|
+
// const getUrlValue = (size: keyof BackgroundImageSrcMap) => {
|
|
51
|
+
// if (typeof src === 'string') {
|
|
52
|
+
// return `url(${src})`;
|
|
53
|
+
// } else if (typeof src === 'object') {
|
|
54
|
+
// return `url(${src[size]})`;
|
|
55
|
+
// }
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
+
// return '';
|
|
58
|
+
// };
|
|
57
59
|
|
|
58
|
-
const filterNum = React.useMemo(() => filterCounter++, []);
|
|
59
|
-
const filterId = `patternfly-background-image-filter-overlay${filterNum}`;
|
|
60
|
-
const style = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} as React.CSSProperties;
|
|
60
|
+
// const filterNum = React.useMemo(() => filterCounter++, []);
|
|
61
|
+
// const filterId = `patternfly-background-image-filter-overlay${filterNum}`;
|
|
62
|
+
// const style = {
|
|
63
|
+
// [cssVar.name]: getUrlValue('xs'),
|
|
64
|
+
// [cssVarName2x.name]: getUrlValue('xs2x'),
|
|
65
|
+
// [cssVarNameSm.name]: getUrlValue('sm'),
|
|
66
|
+
// [cssVarNameSm2x.name]: getUrlValue('sm2x'),
|
|
67
|
+
// [cssVarNameLg.name]: getUrlValue('lg'),
|
|
68
|
+
// [cssVarNameFilter.name]: `url(#${filterId})`
|
|
69
|
+
// } as React.CSSProperties;
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
(
|
|
72
|
+
// TODO: removed inline style add it back with issue #8452 resolution. Also commented out the "React.cloneElement(filter, { id: filterId })} "
|
|
73
|
+
<div className={css(styles.backgroundImage, className)} {...props}>
|
|
71
74
|
<svg xmlns="http://www.w3.org/2000/svg" className="pf-c-background-image__filter" width="0" height="0">
|
|
72
|
-
{React.cloneElement(filter, { id: filterId })}
|
|
75
|
+
{/* {React.cloneElement(filter, { id: filterId })} */}
|
|
73
76
|
</svg>
|
|
74
77
|
</div>
|
|
75
|
-
)
|
|
76
|
-
|
|
78
|
+
)
|
|
79
|
+
;
|
|
77
80
|
BackgroundImage.displayName = 'BackgroundImage';
|
package/src/components/BackgroundImage/__tests__/__snapshots__/BackgroundImage.test.tsx.snap
CHANGED
|
@@ -4,44 +4,14 @@ exports[`BackgroundImage 1`] = `
|
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
6
|
class="pf-c-background-image"
|
|
7
|
-
|
|
7
|
+
src="[object Object]"
|
|
8
8
|
>
|
|
9
9
|
<svg
|
|
10
10
|
class="pf-c-background-image__filter"
|
|
11
11
|
height="0"
|
|
12
12
|
width="0"
|
|
13
13
|
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
-
|
|
15
|
-
<filter
|
|
16
|
-
id="patternfly-background-image-filter-overlay0"
|
|
17
|
-
>
|
|
18
|
-
<fecolormatrix
|
|
19
|
-
type="matrix"
|
|
20
|
-
values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0"
|
|
21
|
-
/>
|
|
22
|
-
<fecomponenttransfer
|
|
23
|
-
color-interpolation-filters="sRGB"
|
|
24
|
-
result="duotone"
|
|
25
|
-
>
|
|
26
|
-
<fefuncr
|
|
27
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
28
|
-
type="table"
|
|
29
|
-
/>
|
|
30
|
-
<fefuncg
|
|
31
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
32
|
-
type="table"
|
|
33
|
-
/>
|
|
34
|
-
<fefuncb
|
|
35
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
36
|
-
type="table"
|
|
37
|
-
/>
|
|
38
|
-
<fefunca
|
|
39
|
-
tableValues="0 1"
|
|
40
|
-
type="table"
|
|
41
|
-
/>
|
|
42
|
-
</fecomponenttransfer>
|
|
43
|
-
</filter>
|
|
44
|
-
</svg>
|
|
14
|
+
/>
|
|
45
15
|
</div>
|
|
46
16
|
</DocumentFragment>
|
|
47
17
|
`;
|
|
@@ -50,44 +20,14 @@ exports[`allows passing in a single string as the image src 1`] = `
|
|
|
50
20
|
<DocumentFragment>
|
|
51
21
|
<div
|
|
52
22
|
class="pf-c-background-image"
|
|
53
|
-
|
|
23
|
+
src="/assets/images/pfbg_1200.jpg"
|
|
54
24
|
>
|
|
55
25
|
<svg
|
|
56
26
|
class="pf-c-background-image__filter"
|
|
57
27
|
height="0"
|
|
58
28
|
width="0"
|
|
59
29
|
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
-
|
|
61
|
-
<filter
|
|
62
|
-
id="patternfly-background-image-filter-overlay1"
|
|
63
|
-
>
|
|
64
|
-
<fecolormatrix
|
|
65
|
-
type="matrix"
|
|
66
|
-
values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0"
|
|
67
|
-
/>
|
|
68
|
-
<fecomponenttransfer
|
|
69
|
-
color-interpolation-filters="sRGB"
|
|
70
|
-
result="duotone"
|
|
71
|
-
>
|
|
72
|
-
<fefuncr
|
|
73
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
74
|
-
type="table"
|
|
75
|
-
/>
|
|
76
|
-
<fefuncg
|
|
77
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
78
|
-
type="table"
|
|
79
|
-
/>
|
|
80
|
-
<fefuncb
|
|
81
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
82
|
-
type="table"
|
|
83
|
-
/>
|
|
84
|
-
<fefunca
|
|
85
|
-
tableValues="0 1"
|
|
86
|
-
type="table"
|
|
87
|
-
/>
|
|
88
|
-
</fecomponenttransfer>
|
|
89
|
-
</filter>
|
|
90
|
-
</svg>
|
|
30
|
+
/>
|
|
91
31
|
</div>
|
|
92
32
|
</DocumentFragment>
|
|
93
33
|
`;
|
|
@@ -17,7 +17,7 @@ export interface IconComponentProps extends Omit<React.HTMLProps<HTMLSpanElement
|
|
|
17
17
|
/** Size of progress icon. Overrides the icon size set by the size property. */
|
|
18
18
|
progressIconSize?: 'sm' | 'md' | 'lg' | 'xl';
|
|
19
19
|
/** Status color of the icon */
|
|
20
|
-
status?: '
|
|
20
|
+
status?: 'custom' | 'info' | 'success' | 'warning' | 'danger';
|
|
21
21
|
/** Indicates the icon is inline and should inherit the text font size and color. Overriden by size and iconSize properties. */
|
|
22
22
|
isInline?: boolean;
|
|
23
23
|
/** Indicates the icon is in progress. Setting this property to true will swap the icon with the progressIcon. */
|
|
@@ -109,10 +109,10 @@ test('check icon without size', () => {
|
|
|
109
109
|
expect(Array.from(iconContainer?.classList || []).some(c => /pf-m-*/.test(c))); // Check no modifier classes have been added
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
Object.values(['
|
|
112
|
+
Object.values(['custom', 'info', 'success', 'warning', 'danger']).forEach(status => {
|
|
113
113
|
test(`sets status modifier successfully - ${status}`, () => {
|
|
114
114
|
render(
|
|
115
|
-
<Icon status={status as '
|
|
115
|
+
<Icon status={status as 'custom' | 'info' | 'success' | 'warning' | 'danger'} title={`${status}-icon`}>
|
|
116
116
|
<CheckIcon />
|
|
117
117
|
</Icon>
|
|
118
118
|
);
|
|
@@ -5,44 +5,14 @@ exports[`check loginpage example against snapshot 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
alt="Pf-background"
|
|
7
7
|
class="pf-c-background-image"
|
|
8
|
-
|
|
8
|
+
src="Background src"
|
|
9
9
|
>
|
|
10
10
|
<svg
|
|
11
11
|
class="pf-c-background-image__filter"
|
|
12
12
|
height="0"
|
|
13
13
|
width="0"
|
|
14
14
|
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
-
|
|
16
|
-
<filter
|
|
17
|
-
id="patternfly-background-image-filter-overlay0"
|
|
18
|
-
>
|
|
19
|
-
<fecolormatrix
|
|
20
|
-
type="matrix"
|
|
21
|
-
values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0"
|
|
22
|
-
/>
|
|
23
|
-
<fecomponenttransfer
|
|
24
|
-
color-interpolation-filters="sRGB"
|
|
25
|
-
result="duotone"
|
|
26
|
-
>
|
|
27
|
-
<fefuncr
|
|
28
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
29
|
-
type="table"
|
|
30
|
-
/>
|
|
31
|
-
<fefuncg
|
|
32
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
33
|
-
type="table"
|
|
34
|
-
/>
|
|
35
|
-
<fefuncb
|
|
36
|
-
tableValues="0.086274509803922 0.43921568627451"
|
|
37
|
-
type="table"
|
|
38
|
-
/>
|
|
39
|
-
<fefunca
|
|
40
|
-
tableValues="0 1"
|
|
41
|
-
type="table"
|
|
42
|
-
/>
|
|
43
|
-
</fecomponenttransfer>
|
|
44
|
-
</filter>
|
|
45
|
-
</svg>
|
|
15
|
+
/>
|
|
46
16
|
</div>
|
|
47
17
|
<div
|
|
48
18
|
class="pf-c-login"
|
|
@@ -177,7 +177,7 @@ export const ModalContent: React.FunctionComponent<ModalContentProps> = ({
|
|
|
177
177
|
className={css(
|
|
178
178
|
className,
|
|
179
179
|
isVariantIcon(titleIconVariant) &&
|
|
180
|
-
modalStyles.modifiers[titleIconVariant as 'success' | 'warning' | 'info' | 'danger' | '
|
|
180
|
+
modalStyles.modifiers[titleIconVariant as 'success' | 'warning' | 'info' | 'danger' | 'custom']
|
|
181
181
|
)}
|
|
182
182
|
variant={variant}
|
|
183
183
|
position={position}
|
|
@@ -16,7 +16,7 @@ export interface NotificationDrawerListItemProps extends React.HTMLProps<HTMLLIE
|
|
|
16
16
|
/** Tab index for the list item */
|
|
17
17
|
tabIndex?: number;
|
|
18
18
|
/** Variant indicates the severity level */
|
|
19
|
-
variant?: '
|
|
19
|
+
variant?: 'custom' | 'success' | 'danger' | 'warning' | 'info';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const NotificationDrawerListItem: React.FunctionComponent<NotificationDrawerListItemProps> = ({
|
|
@@ -27,7 +27,7 @@ export const NotificationDrawerListItem: React.FunctionComponent<NotificationDra
|
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
28
|
onClick = (event: React.MouseEvent) => undefined as any,
|
|
29
29
|
tabIndex = 0,
|
|
30
|
-
variant = '
|
|
30
|
+
variant = 'custom',
|
|
31
31
|
...props
|
|
32
32
|
}: NotificationDrawerListItemProps) => {
|
|
33
33
|
const onKeyDown = (event: React.KeyboardEvent) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports[`NotificationDrawerListItem renders with PatternFly Core styles 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<li
|
|
6
|
-
class="pf-c-notification-drawer__list-item pf-m-hoverable pf-m-
|
|
6
|
+
class="pf-c-notification-drawer__list-item pf-m-hoverable pf-m-custom"
|
|
7
7
|
tabindex="0"
|
|
8
8
|
/>
|
|
9
9
|
</DocumentFragment>
|
|
@@ -210,7 +210,7 @@ export interface PopoverProps {
|
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
const alertStyle = {
|
|
213
|
-
default: styles.modifiers.
|
|
213
|
+
default: styles.modifiers.custom,
|
|
214
214
|
info: styles.modifiers.info,
|
|
215
215
|
success: styles.modifiers.success,
|
|
216
216
|
warning: styles.modifiers.warning,
|
|
@@ -373,9 +373,22 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
373
373
|
onToggle = (isOpen: boolean) => {
|
|
374
374
|
// on close, parse and validate input
|
|
375
375
|
this.setState(prevState => {
|
|
376
|
-
const { timeRegex, isInvalid } = prevState;
|
|
377
|
-
const { delimiter, is24Hour, includeSeconds } = this.props;
|
|
378
|
-
const time = parseTime(
|
|
376
|
+
const { timeRegex, isInvalid, timeState } = prevState;
|
|
377
|
+
const { delimiter, is24Hour, includeSeconds, onChange } = this.props;
|
|
378
|
+
const time = parseTime(timeState, timeRegex, delimiter, !is24Hour, includeSeconds);
|
|
379
|
+
|
|
380
|
+
// Call onChange when Enter is pressed in input and timeoption does not exist in menu
|
|
381
|
+
if (onChange && !isOpen && time !== timeState) {
|
|
382
|
+
onChange(
|
|
383
|
+
null,
|
|
384
|
+
time,
|
|
385
|
+
getHours(time, timeRegex),
|
|
386
|
+
getMinutes(time, timeRegex),
|
|
387
|
+
getSeconds(time, timeRegex),
|
|
388
|
+
this.isValid(time)
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
|
|
379
392
|
return {
|
|
380
393
|
isTimeOptionsOpen: isOpen,
|
|
381
394
|
timeState: time,
|
|
@@ -414,7 +427,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
414
427
|
onInputChange = (newTime: string, event: React.FormEvent<HTMLInputElement>) => {
|
|
415
428
|
const { onChange } = this.props;
|
|
416
429
|
const { timeRegex } = this.state;
|
|
417
|
-
|
|
418
430
|
if (onChange) {
|
|
419
431
|
onChange(
|
|
420
432
|
event,
|
|
@@ -86,6 +86,28 @@ describe('TimePicker', () => {
|
|
|
86
86
|
expects: { hour: 23, minutes: 59, seconds: null }
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
|
+
|
|
90
|
+
// Disabling because this test does not work on CI
|
|
91
|
+
xtest('should call onChange when pressing Enter', async () => {
|
|
92
|
+
const onChange = jest.fn();
|
|
93
|
+
const user = userEvent.setup();
|
|
94
|
+
|
|
95
|
+
render(<TimePicker onChange={onChange} aria-label="time picker" />);
|
|
96
|
+
|
|
97
|
+
// Take into account timezones when tests are ran
|
|
98
|
+
const isPM = new Date().getHours() > 12;
|
|
99
|
+
|
|
100
|
+
await user.type(screen.getByLabelText('time picker'), `11:11`);
|
|
101
|
+
await user.keyboard('[Enter]');
|
|
102
|
+
expect(onChange).toHaveBeenLastCalledWith(
|
|
103
|
+
expect.any(Object),
|
|
104
|
+
`11:11 ${isPM ? 'PM' : 'AM'}`,
|
|
105
|
+
isPM ? 23 : 11,
|
|
106
|
+
11,
|
|
107
|
+
null,
|
|
108
|
+
true
|
|
109
|
+
);
|
|
110
|
+
});
|
|
89
111
|
});
|
|
90
112
|
|
|
91
113
|
describe('test isInvalid', () => {
|
|
@@ -18,34 +18,35 @@ DateRangePicker = () => {
|
|
|
18
18
|
const [from, setFrom] = React.useState();
|
|
19
19
|
const [to, setTo] = React.useState();
|
|
20
20
|
|
|
21
|
-
const toValidator = date =>
|
|
22
|
-
|
|
21
|
+
const toValidator = (date) =>
|
|
22
|
+
isValidDate(from) && date >= from ? '' : 'The "to" date must be after the "from" date';
|
|
23
|
+
|
|
24
|
+
const onFromChange = (_event, _value, date) => {
|
|
23
25
|
setFrom(new Date(date));
|
|
24
26
|
if (isValidDate(date)) {
|
|
25
27
|
date.setDate(date.getDate() + 1);
|
|
26
28
|
setTo(yyyyMMddFormat(date));
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
+
} else {
|
|
29
30
|
setTo('');
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
|
|
34
|
+
const onToChange = (_event, _value, date) => {
|
|
35
|
+
if (isValidDate(date)) {
|
|
36
|
+
setTo(yyyyMMddFormat(date));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
33
40
|
return (
|
|
34
41
|
<Split>
|
|
35
42
|
<SplitItem>
|
|
36
|
-
<DatePicker
|
|
37
|
-
onChange={onFromChange}
|
|
38
|
-
aria-label="Start date"
|
|
39
|
-
placeholder="YYYY-MM-DD"
|
|
40
|
-
/>
|
|
41
|
-
</SplitItem>
|
|
42
|
-
<SplitItem style={{ padding: '6px 12px 0 12px' }}>
|
|
43
|
-
to
|
|
43
|
+
<DatePicker onChange={onFromChange} aria-label="Start date" placeholder="YYYY-MM-DD" />
|
|
44
44
|
</SplitItem>
|
|
45
|
+
<SplitItem style={{ padding: '6px 12px 0 12px' }}>to</SplitItem>
|
|
45
46
|
<SplitItem>
|
|
46
47
|
<DatePicker
|
|
47
48
|
value={to}
|
|
48
|
-
onChange={
|
|
49
|
+
onChange={onToChange}
|
|
49
50
|
isDisabled={!isValidDate(from)}
|
|
50
51
|
rangeStart={from}
|
|
51
52
|
validators={[toValidator]}
|
|
@@ -55,23 +56,34 @@ DateRangePicker = () => {
|
|
|
55
56
|
</SplitItem>
|
|
56
57
|
</Split>
|
|
57
58
|
);
|
|
58
|
-
}
|
|
59
|
+
};
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
### Date and time range picker
|
|
62
63
|
|
|
63
64
|
```js
|
|
64
|
-
import {
|
|
65
|
+
import {
|
|
66
|
+
Flex,
|
|
67
|
+
FlexItem,
|
|
68
|
+
InputGroup,
|
|
69
|
+
DatePicker,
|
|
70
|
+
isValidDate,
|
|
71
|
+
TimePicker,
|
|
72
|
+
yyyyMMddFormat,
|
|
73
|
+
updateDateTime
|
|
74
|
+
} from '@patternfly/react-core';
|
|
65
75
|
|
|
66
76
|
DateTimeRangePicker = () => {
|
|
67
77
|
const [from, setFrom] = React.useState();
|
|
68
78
|
const [to, setTo] = React.useState();
|
|
69
79
|
|
|
70
|
-
const toValidator = date => {
|
|
71
|
-
return isValidDate(from) && yyyyMMddFormat(date) >= yyyyMMddFormat(from)
|
|
80
|
+
const toValidator = (date) => {
|
|
81
|
+
return isValidDate(from) && yyyyMMddFormat(date) >= yyyyMMddFormat(from)
|
|
82
|
+
? ''
|
|
83
|
+
: 'The "to" date must be after the "from" date';
|
|
72
84
|
};
|
|
73
|
-
|
|
74
|
-
const onFromDateChange = (inputDate, newFromDate) => {
|
|
85
|
+
|
|
86
|
+
const onFromDateChange = (_event, inputDate, newFromDate) => {
|
|
75
87
|
if (isValidDate(from) && isValidDate(newFromDate) && inputDate === yyyyMMddFormat(newFromDate)) {
|
|
76
88
|
newFromDate.setHours(from.getHours());
|
|
77
89
|
newFromDate.setMinutes(from.getMinutes());
|
|
@@ -80,7 +92,7 @@ DateTimeRangePicker = () => {
|
|
|
80
92
|
setFrom(new Date(newFromDate));
|
|
81
93
|
}
|
|
82
94
|
};
|
|
83
|
-
|
|
95
|
+
|
|
84
96
|
const onFromTimeChange = (_event, time, hour, minute) => {
|
|
85
97
|
if (isValidDate(from)) {
|
|
86
98
|
const updatedFromDate = new Date(from);
|
|
@@ -90,16 +102,16 @@ DateTimeRangePicker = () => {
|
|
|
90
102
|
}
|
|
91
103
|
};
|
|
92
104
|
|
|
93
|
-
const onToDateChange = (inputDate, newToDate) => {
|
|
105
|
+
const onToDateChange = (_event, inputDate, newToDate) => {
|
|
94
106
|
if (isValidDate(to) && isValidDate(newToDate) && inputDate === yyyyMMddFormat(newToDate)) {
|
|
95
107
|
newToDate.setHours(to.getHours());
|
|
96
108
|
newToDate.setMinutes(to.getMinutes());
|
|
97
109
|
}
|
|
98
|
-
if (isValidDate(newToDate) && inputDate === yyyyMMddFormat(newToDate)){
|
|
110
|
+
if (isValidDate(newToDate) && inputDate === yyyyMMddFormat(newToDate)) {
|
|
99
111
|
setTo(newToDate);
|
|
100
112
|
}
|
|
101
113
|
};
|
|
102
|
-
|
|
114
|
+
|
|
103
115
|
const onToTimeChange = (_event, time, hour, minute) => {
|
|
104
116
|
if (isValidDate(to)) {
|
|
105
117
|
const updatedToDate = new Date(to);
|
|
@@ -110,24 +122,14 @@ DateTimeRangePicker = () => {
|
|
|
110
122
|
};
|
|
111
123
|
|
|
112
124
|
return (
|
|
113
|
-
<Flex direction={{default: 'column', lg: 'row'}}>
|
|
125
|
+
<Flex direction={{ default: 'column', lg: 'row' }}>
|
|
114
126
|
<FlexItem>
|
|
115
127
|
<InputGroup>
|
|
116
|
-
<DatePicker
|
|
117
|
-
|
|
118
|
-
aria-label="Start date"
|
|
119
|
-
placeholder="YYYY-MM-DD"
|
|
120
|
-
/>
|
|
121
|
-
<TimePicker
|
|
122
|
-
aria-label="Start time"
|
|
123
|
-
style={{width: '150px'}}
|
|
124
|
-
onChange={onFromTimeChange}
|
|
125
|
-
/>
|
|
128
|
+
<DatePicker onChange={onFromDateChange} aria-label="Start date" placeholder="YYYY-MM-DD" />
|
|
129
|
+
<TimePicker aria-label="Start time" style={{ width: '150px' }} onChange={onFromTimeChange} />
|
|
126
130
|
</InputGroup>
|
|
127
131
|
</FlexItem>
|
|
128
|
-
<FlexItem>
|
|
129
|
-
to
|
|
130
|
-
</FlexItem>
|
|
132
|
+
<FlexItem>to</FlexItem>
|
|
131
133
|
<FlexItem>
|
|
132
134
|
<InputGroup>
|
|
133
135
|
<DatePicker
|
|
@@ -139,19 +141,22 @@ DateTimeRangePicker = () => {
|
|
|
139
141
|
aria-label="End date"
|
|
140
142
|
placeholder="YYYY-MM-DD"
|
|
141
143
|
/>
|
|
142
|
-
<TimePicker style={{width: '150px'}} onChange={onToTimeChange} isDisabled={!isValidDate(from)}/>
|
|
144
|
+
<TimePicker style={{ width: '150px' }} onChange={onToTimeChange} isDisabled={!isValidDate(from)} />
|
|
143
145
|
</InputGroup>
|
|
144
146
|
</FlexItem>
|
|
145
147
|
</Flex>
|
|
146
148
|
);
|
|
147
|
-
}
|
|
149
|
+
};
|
|
148
150
|
```
|
|
149
151
|
|
|
150
|
-
|
|
151
152
|
### Date and time pickers in modal
|
|
153
|
+
|
|
152
154
|
Modals trap focus and watch a few document level events. In order to place a date picker in a modal:
|
|
155
|
+
|
|
153
156
|
- To avoid the modal's escape press event handler from overruling the date picker's escape press handlers, use the `DatePickerRef` to close the calendar when it is open and the escape key is pressed.
|
|
154
157
|
- Append the calendar to the modal to keep it as close to the date picker in the DOM while maintaining correct layouts visually
|
|
155
158
|
In order to place a time picker in the modal, its menu must be appended to the time picker's parent.
|
|
159
|
+
|
|
156
160
|
```ts file="./examples/DateTimePickerInModal.tsx"
|
|
161
|
+
|
|
157
162
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|