@patternfly/react-core 4.202.20 → 4.202.23
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 +27 -0
- package/dist/esm/components/DataList/DataListCheck.d.ts +6 -2
- package/dist/esm/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataListCheck.js +1 -1
- package/dist/esm/components/DataList/DataListCheck.js.map +1 -1
- package/dist/esm/components/DescriptionList/DescriptionListGroup.d.ts +1 -1
- package/dist/esm/components/DescriptionList/DescriptionListGroup.d.ts.map +1 -1
- package/dist/esm/components/DescriptionList/DescriptionListGroup.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerActions.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerActions.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerActions.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerCloseButton.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerCloseButton.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerCloseButton.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerContent.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerContent.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerContent.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerContentBody.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerContentBody.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerContentBody.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerHead.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerHead.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerHead.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerMain.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerMain.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerMain.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelBody.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerPanelBody.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerPanelBody.js.map +1 -1
- package/dist/esm/components/Drawer/DrawerSection.d.ts +1 -1
- package/dist/esm/components/Drawer/DrawerSection.d.ts.map +1 -1
- package/dist/esm/components/Drawer/DrawerSection.js.map +1 -1
- package/dist/esm/components/Dropdown/BadgeToggle.js +1 -1
- package/dist/esm/components/Dropdown/BadgeToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownItem.js +1 -1
- package/dist/esm/components/Dropdown/DropdownItem.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownSeparator.js +1 -1
- package/dist/esm/components/Dropdown/DropdownSeparator.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.js +1 -1
- package/dist/esm/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/esm/components/Dropdown/KebabToggle.js +1 -1
- package/dist/esm/components/Dropdown/KebabToggle.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuContent.d.ts +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuContent.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuContent.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.d.ts +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuDropdownItem.d.ts +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuDropdownItem.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuDropdownItem.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.d.ts +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuItem.d.ts +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuItem.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuItem.js.map +1 -1
- package/dist/esm/components/Tabs/TabContent.js.map +1 -1
- package/dist/js/components/DataList/DataListCheck.d.ts +6 -2
- package/dist/js/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/js/components/DataList/DataListCheck.js +1 -1
- package/dist/js/components/DataList/DataListCheck.js.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionListGroup.d.ts +1 -1
- package/dist/js/components/DescriptionList/DescriptionListGroup.d.ts.map +1 -1
- package/dist/js/components/DescriptionList/DescriptionListGroup.js.map +1 -1
- package/dist/js/components/Drawer/DrawerActions.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerActions.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerActions.js.map +1 -1
- package/dist/js/components/Drawer/DrawerCloseButton.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerCloseButton.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerCloseButton.js.map +1 -1
- package/dist/js/components/Drawer/DrawerContent.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerContent.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerContent.js.map +1 -1
- package/dist/js/components/Drawer/DrawerContentBody.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerContentBody.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerContentBody.js.map +1 -1
- package/dist/js/components/Drawer/DrawerHead.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerHead.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerHead.js.map +1 -1
- package/dist/js/components/Drawer/DrawerMain.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerMain.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerMain.js.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelBody.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerPanelBody.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerPanelBody.js.map +1 -1
- package/dist/js/components/Drawer/DrawerSection.d.ts +1 -1
- package/dist/js/components/Drawer/DrawerSection.d.ts.map +1 -1
- package/dist/js/components/Drawer/DrawerSection.js.map +1 -1
- package/dist/js/components/Dropdown/BadgeToggle.js +1 -1
- package/dist/js/components/Dropdown/BadgeToggle.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js +1 -1
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownItem.js +1 -1
- package/dist/js/components/Dropdown/DropdownItem.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownSeparator.js +1 -1
- package/dist/js/components/Dropdown/DropdownSeparator.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.js +1 -1
- package/dist/js/components/Dropdown/DropdownToggle.js.map +1 -1
- package/dist/js/components/Dropdown/KebabToggle.js +1 -1
- package/dist/js/components/Dropdown/KebabToggle.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuContent.d.ts +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuContent.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuContent.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.d.ts +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuDropdownItem.d.ts +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuDropdownItem.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuDropdownItem.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.d.ts +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuItem.d.ts +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuItem.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuItem.js.map +1 -1
- package/dist/js/components/Tabs/TabContent.js.map +1 -1
- package/dist/umd/react-core.css +4 -2
- package/dist/umd/react-core.js +1421 -966
- package/dist/umd/react-core.min.css +4 -2
- package/dist/umd/react-core.min.js +5 -5
- package/package.json +6 -6
- package/src/components/DataList/DataListCheck.tsx +8 -3
- package/src/components/DatePicker/examples/DatePicker.md +8 -121
- package/src/components/DatePicker/examples/DatePickerAmerican.tsx +19 -0
- package/src/components/DatePicker/examples/DatePickerBasic.tsx +11 -0
- package/src/components/DatePicker/examples/DatePickerControlled.tsx +13 -0
- package/src/components/DatePicker/examples/DatePickerControlledCalendar.tsx +17 -0
- package/src/components/DatePicker/examples/DatePickerFrench.tsx +26 -0
- package/src/components/DatePicker/examples/DatePickerHelperText.tsx +6 -0
- package/src/components/DatePicker/examples/DatePickerMinMax.tsx +17 -0
- package/src/components/DescriptionList/DescriptionListGroup.tsx +1 -1
- package/src/components/Drawer/DrawerActions.tsx +1 -1
- package/src/components/Drawer/DrawerCloseButton.tsx +1 -1
- package/src/components/Drawer/DrawerContent.tsx +1 -1
- package/src/components/Drawer/DrawerContentBody.tsx +1 -1
- package/src/components/Drawer/DrawerHead.tsx +1 -1
- package/src/components/Drawer/DrawerMain.tsx +1 -1
- package/src/components/Drawer/DrawerPanelBody.tsx +1 -1
- package/src/components/Drawer/DrawerSection.tsx +1 -1
- package/src/components/Dropdown/BadgeToggle.tsx +1 -1
- package/src/components/Dropdown/Dropdown.tsx +1 -1
- package/src/components/Dropdown/DropdownItem.tsx +1 -1
- package/src/components/Dropdown/DropdownSeparator.tsx +1 -1
- package/src/components/Dropdown/DropdownToggle.tsx +1 -1
- package/src/components/Dropdown/KebabToggle.tsx +1 -1
- package/src/components/OverflowMenu/OverflowMenuContent.tsx +1 -1
- package/src/components/OverflowMenu/OverflowMenuControl.tsx +1 -1
- package/src/components/OverflowMenu/OverflowMenuDropdownItem.tsx +1 -1
- package/src/components/OverflowMenu/OverflowMenuGroup.tsx +1 -1
- package/src/components/OverflowMenu/OverflowMenuItem.tsx +1 -1
- package/src/components/Tabs/TabContent.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.202.
|
|
3
|
+
"version": "4.202.23",
|
|
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.53.
|
|
38
|
-
"@patternfly/react-styles": "^4.52.
|
|
39
|
-
"@patternfly/react-tokens": "^4.54.
|
|
37
|
+
"@patternfly/react-icons": "^4.53.23",
|
|
38
|
+
"@patternfly/react-styles": "^4.52.23",
|
|
39
|
+
"@patternfly/react-tokens": "^4.54.23",
|
|
40
40
|
"focus-trap": "6.2.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.185.
|
|
46
|
+
"@patternfly/patternfly": "4.185.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": "542b9e9211edd7ff4b98f947f2943711a590bb54"
|
|
64
64
|
}
|
|
@@ -9,9 +9,13 @@ export interface DataListCheckProps extends Omit<React.HTMLProps<HTMLInputElemen
|
|
|
9
9
|
isValid?: boolean;
|
|
10
10
|
/** Flag to show if the DataList checkbox is disabled */
|
|
11
11
|
isDisabled?: boolean;
|
|
12
|
-
/** Flag to show if the DataList checkbox is checked
|
|
12
|
+
/** Flag to show if the DataList checkbox is checked when it is controlled by React state.
|
|
13
|
+
* To make the DataList checkbox uncontrolled, instead use the checked prop, but do not use both.
|
|
14
|
+
*/
|
|
13
15
|
isChecked?: boolean;
|
|
14
|
-
/** Flag to set default value of DataList checkbox when it is uncontrolled by React state
|
|
16
|
+
/** Flag to set default value of DataList checkbox when it is uncontrolled by React state.
|
|
17
|
+
* To make the DataList checkbox controlled, instead use the isChecked prop, but do not use both.
|
|
18
|
+
*/
|
|
15
19
|
checked?: boolean;
|
|
16
20
|
/** A callback for when the DataList checkbox selection changes */
|
|
17
21
|
onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
|
|
@@ -40,7 +44,8 @@ export const DataListCheck: React.FunctionComponent<DataListCheckProps> = ({
|
|
|
40
44
|
onChange={event => onChange(event.currentTarget.checked, event)}
|
|
41
45
|
aria-invalid={!isValid}
|
|
42
46
|
disabled={isDisabled}
|
|
43
|
-
checked
|
|
47
|
+
{...(checked !== null && { defaultChecked: checked })}
|
|
48
|
+
{...(isChecked !== null && { checked: isChecked })}
|
|
44
49
|
/>
|
|
45
50
|
</div>
|
|
46
51
|
);
|
|
@@ -7,151 +7,38 @@ beta: true
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Examples
|
|
10
|
+
|
|
10
11
|
### Basic
|
|
11
|
-
```js
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { DatePicker } from '@patternfly/react-core';
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
onBlur={(str, date) => console.log('onBlur', str, date)}
|
|
17
|
-
onChange={(str, date) => console.log('onChange', str, date)}
|
|
18
|
-
/>
|
|
13
|
+
```ts file="./DatePickerBasic.tsx"
|
|
19
14
|
```
|
|
20
15
|
|
|
21
16
|
### American format
|
|
22
|
-
```js
|
|
23
|
-
import React from 'react';
|
|
24
|
-
import { DatePicker } from '@patternfly/react-core';
|
|
25
|
-
|
|
26
|
-
AmericanFormat = () => {
|
|
27
|
-
const dateFormat = date => date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g,'-');
|
|
28
|
-
const dateParse = date => {
|
|
29
|
-
const split = date.split('-');
|
|
30
|
-
if (split.length !== 3) {
|
|
31
|
-
return new Date();
|
|
32
|
-
}
|
|
33
|
-
let month = split[0];
|
|
34
|
-
let day = split[1];
|
|
35
|
-
let year = split[2];
|
|
36
|
-
return new Date(`${year.padStart(4, '0')}-${month.padStart(2, '0')}-${day.padStart(2, '0')}T00:00:00`);
|
|
37
|
-
};
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
<DatePicker
|
|
41
|
-
value="03-05-2020"
|
|
42
|
-
placeholder="MM-DD-YYYY"
|
|
43
|
-
dateFormat={dateFormat}
|
|
44
|
-
dateParse={dateParse}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
18
|
+
```ts file="./DatePickerAmerican.tsx"
|
|
48
19
|
```
|
|
49
20
|
|
|
50
21
|
### Helper text
|
|
51
|
-
```js
|
|
52
|
-
import React from 'react';
|
|
53
|
-
import { DatePicker } from '@patternfly/react-core';
|
|
54
22
|
|
|
55
|
-
|
|
23
|
+
```ts file="./DatePickerHelperText.tsx"
|
|
56
24
|
```
|
|
57
25
|
|
|
58
26
|
### Min and max date
|
|
59
|
-
```js
|
|
60
|
-
import React from 'react';
|
|
61
|
-
import { DatePicker } from '@patternfly/react-core';
|
|
62
27
|
|
|
63
|
-
|
|
64
|
-
const minDate = new Date(2020, 2, 16);
|
|
65
|
-
const maxDate = new Date(2020, 2, 20);
|
|
66
|
-
const rangeValidator = date => {
|
|
67
|
-
if (date < minDate) {
|
|
68
|
-
return 'Date is before the allowable range.';
|
|
69
|
-
}
|
|
70
|
-
else if (date > maxDate) {
|
|
71
|
-
return 'Date is after the allowable range.';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return '';
|
|
75
|
-
};
|
|
76
|
-
return <DatePicker value="2020-03-17" validators={[rangeValidator]} />;
|
|
77
|
-
}
|
|
28
|
+
```ts file="./DatePickerMinMax.tsx"
|
|
78
29
|
```
|
|
79
30
|
|
|
80
31
|
### French
|
|
81
32
|
|
|
82
|
-
```
|
|
83
|
-
import React from 'react';
|
|
84
|
-
import { DatePicker, Weekday } from '@patternfly/react-core';
|
|
85
|
-
|
|
86
|
-
FrenchMinMaxDate = () => {
|
|
87
|
-
const minDate = new Date(2020, 2, 16);
|
|
88
|
-
const maxDate = new Date(2020, 2, 20);
|
|
89
|
-
const rangeValidator = date => {
|
|
90
|
-
if (date < minDate) {
|
|
91
|
-
return 'Cette date est antérieure à la première date valide.';
|
|
92
|
-
}
|
|
93
|
-
else if (date > maxDate) {
|
|
94
|
-
return 'Cette date est postérieure à la dernière date valide.';
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return '';
|
|
98
|
-
};
|
|
99
|
-
return (
|
|
100
|
-
<DatePicker
|
|
101
|
-
value="2020-03-17"
|
|
102
|
-
validators={[rangeValidator]}
|
|
103
|
-
placeholder="aaaa-mm-jj"
|
|
104
|
-
invalidFormatText="Cette date est invalide."
|
|
105
|
-
locale="fr"
|
|
106
|
-
weekStart={Weekday.Monday}
|
|
107
|
-
/>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
33
|
+
```ts file="./DatePickerFrench.tsx"
|
|
110
34
|
```
|
|
111
35
|
|
|
112
36
|
### Controlled
|
|
113
37
|
|
|
114
|
-
```
|
|
115
|
-
import React from 'react';
|
|
116
|
-
import { Button, DatePicker } from '@patternfly/react-core';
|
|
117
|
-
|
|
118
|
-
ControlledDate = () => {
|
|
119
|
-
const initialValue = '2020-03-17';
|
|
120
|
-
const [value, setValue] = React.useState(initialValue);
|
|
121
|
-
return (
|
|
122
|
-
<React.Fragment>
|
|
123
|
-
<Button onClick={() => setValue(initialValue)}>
|
|
124
|
-
Reset date
|
|
125
|
-
</Button>
|
|
126
|
-
<DatePicker
|
|
127
|
-
value={value}
|
|
128
|
-
onChange={value => setValue(value)}
|
|
129
|
-
/>
|
|
130
|
-
</React.Fragment>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
38
|
+
```ts file="./DatePickerControlled.tsx"
|
|
133
39
|
```
|
|
134
40
|
|
|
135
41
|
### Controlling the date picker calendar state
|
|
136
42
|
|
|
137
|
-
```
|
|
138
|
-
import React from 'react';
|
|
139
|
-
import { Button, DatePicker } from '@patternfly/react-core';
|
|
140
|
-
|
|
141
|
-
ControllingDatePicker = () => {
|
|
142
|
-
const dateRef = React.useRef(null);
|
|
143
|
-
const onClick = () => {
|
|
144
|
-
if (dateRef.current) {
|
|
145
|
-
dateRef.current.toggleCalendar()
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
return (
|
|
149
|
-
<React.Fragment>
|
|
150
|
-
<Button onClick={onClick}>
|
|
151
|
-
Toggle calendar
|
|
152
|
-
</Button>
|
|
153
|
-
<DatePicker ref={ dateRef } />
|
|
154
|
-
</React.Fragment>
|
|
155
|
-
);
|
|
156
|
-
}
|
|
43
|
+
```ts file="./DatePickerControlledCalendar.tsx"
|
|
157
44
|
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerAmerican: React.FunctionComponent = () => {
|
|
5
|
+
const dateFormat = (date: Date) =>
|
|
6
|
+
date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-');
|
|
7
|
+
const dateParse = (date: string) => {
|
|
8
|
+
const split = date.split('-');
|
|
9
|
+
if (split.length !== 3) {
|
|
10
|
+
return new Date();
|
|
11
|
+
}
|
|
12
|
+
const month = split[0];
|
|
13
|
+
const day = split[1];
|
|
14
|
+
const year = split[2];
|
|
15
|
+
return new Date(`${year.padStart(4, '0')}-${month.padStart(2, '0')}-${day.padStart(2, '0')}T00:00:00`);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return <DatePicker value="03-05-2020" placeholder="MM-DD-YYYY" dateFormat={dateFormat} dateParse={dateParse} />;
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerBasic: React.FunctionComponent = () => (
|
|
5
|
+
<DatePicker
|
|
6
|
+
// eslint-disable-next-line no-console
|
|
7
|
+
onBlur={(str, date) => console.log('onBlur', str, date)}
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
onChange={(str, date) => console.log('onChange', str, date)}
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DatePicker } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerControlled: React.FunctionComponent = () => {
|
|
5
|
+
const initialValue = '2020-03-17';
|
|
6
|
+
const [value, setValue] = React.useState(initialValue);
|
|
7
|
+
return (
|
|
8
|
+
<React.Fragment>
|
|
9
|
+
<Button onClick={() => setValue(initialValue)}>Reset date</Button>
|
|
10
|
+
<DatePicker value={value} onChange={value => setValue(value)} />
|
|
11
|
+
</React.Fragment>
|
|
12
|
+
);
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, DatePicker } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerControlledCalendar: React.FunctionComponent = () => {
|
|
5
|
+
const dateRef = React.useRef(null);
|
|
6
|
+
const onClick = () => {
|
|
7
|
+
if (dateRef.current) {
|
|
8
|
+
dateRef.current.toggleCalendar();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button onClick={onClick}>Toggle calendar</Button>
|
|
14
|
+
<DatePicker ref={dateRef} />
|
|
15
|
+
</React.Fragment>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker, Weekday } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerFrench: React.FunctionComponent = () => {
|
|
5
|
+
const minDate = new Date(2020, 2, 16);
|
|
6
|
+
const maxDate = new Date(2020, 2, 20);
|
|
7
|
+
const rangeValidator = (date: Date) => {
|
|
8
|
+
if (date < minDate) {
|
|
9
|
+
return 'Cette date est antérieure à la première date valide.';
|
|
10
|
+
} else if (date > maxDate) {
|
|
11
|
+
return 'Cette date est postérieure à la dernière date valide.';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return '';
|
|
15
|
+
};
|
|
16
|
+
return (
|
|
17
|
+
<DatePicker
|
|
18
|
+
value="2020-03-17"
|
|
19
|
+
validators={[rangeValidator]}
|
|
20
|
+
placeholder="aaaa-mm-jj"
|
|
21
|
+
invalidFormatText="Cette date est invalide."
|
|
22
|
+
locale="fr"
|
|
23
|
+
weekStart={Weekday.Monday}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePicker } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DatePickerMinMax: React.FunctionComponent = () => {
|
|
5
|
+
const minDate = new Date(2020, 2, 16);
|
|
6
|
+
const maxDate = new Date(2020, 2, 20);
|
|
7
|
+
const rangeValidator = (date: Date) => {
|
|
8
|
+
if (date < minDate) {
|
|
9
|
+
return 'Date is before the allowable range.';
|
|
10
|
+
} else if (date > maxDate) {
|
|
11
|
+
return 'Date is after the allowable range.';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return '';
|
|
15
|
+
};
|
|
16
|
+
return <DatePicker value="2020-03-17" validators={[rangeValidator]} />;
|
|
17
|
+
};
|
|
@@ -9,7 +9,7 @@ export interface DescriptionListGroupProps extends React.HTMLProps<HTMLDivElemen
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const DescriptionListGroup: React.
|
|
12
|
+
export const DescriptionListGroup: React.FunctionComponent<DescriptionListGroupProps> = ({
|
|
13
13
|
className,
|
|
14
14
|
children,
|
|
15
15
|
...props
|
|
@@ -9,7 +9,7 @@ export interface DrawerActionsProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const DrawerActions: React.
|
|
12
|
+
export const DrawerActions: React.FunctionComponent<DrawerActionsProps> = ({
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
14
|
className = '',
|
|
15
15
|
children,
|
|
@@ -13,7 +13,7 @@ export interface DrawerCloseButtonProps extends React.HTMLProps<HTMLDivElement>
|
|
|
13
13
|
'aria-label'?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const DrawerCloseButton: React.
|
|
16
|
+
export const DrawerCloseButton: React.FunctionComponent<DrawerCloseButtonProps> = ({
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
18
|
className = '',
|
|
19
19
|
onClose = () => undefined as any,
|
|
@@ -15,7 +15,7 @@ export interface DrawerContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
15
15
|
colorVariant?: DrawerColorVariant | 'light-200' | 'default';
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const DrawerContent: React.
|
|
18
|
+
export const DrawerContent: React.FunctionComponent<DrawerContentProps> = ({
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
20
|
className = '',
|
|
21
21
|
children,
|
|
@@ -11,7 +11,7 @@ export interface DrawerContentBodyProps extends React.HTMLProps<HTMLDivElement>
|
|
|
11
11
|
hasPadding?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const DrawerContentBody: React.
|
|
14
|
+
export const DrawerContentBody: React.FunctionComponent<DrawerContentBodyProps> = ({
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
16
|
className = '',
|
|
17
17
|
children,
|
|
@@ -12,7 +12,7 @@ export interface DrawerHeadProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
12
12
|
hasNoPadding?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const DrawerHead: React.
|
|
15
|
+
export const DrawerHead: React.FunctionComponent<DrawerHeadProps> = ({
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
17
|
className = '',
|
|
18
18
|
children,
|
|
@@ -9,7 +9,7 @@ export interface DrawerMainProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const DrawerMain: React.
|
|
12
|
+
export const DrawerMain: React.FunctionComponent<DrawerMainProps> = ({
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
14
|
className = '',
|
|
15
15
|
children,
|
|
@@ -11,7 +11,7 @@ export interface DrawerPanelBodyProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
11
11
|
hasNoPadding?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const DrawerPanelBody: React.
|
|
14
|
+
export const DrawerPanelBody: React.FunctionComponent<DrawerPanelBodyProps> = ({
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
16
|
className = '',
|
|
17
17
|
children,
|
|
@@ -12,7 +12,7 @@ export interface DrawerSectionProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
12
12
|
colorVariant?: DrawerColorVariant | 'light-200' | 'default';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const DrawerSection: React.
|
|
15
|
+
export const DrawerSection: React.FunctionComponent<DrawerSectionProps> = ({
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
17
|
className = '',
|
|
18
18
|
children,
|
|
@@ -52,7 +52,7 @@ export const BadgeToggle: React.FunctionComponent<BadgeToggleProps> = ({
|
|
|
52
52
|
bubbleEvent = false,
|
|
53
53
|
onToggle = () => undefined as void,
|
|
54
54
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
|
-
ref, // Types of Ref are different for React.
|
|
55
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
56
56
|
...props
|
|
57
57
|
}: BadgeToggleProps) => (
|
|
58
58
|
<Toggle
|
|
@@ -49,7 +49,7 @@ export interface DropdownProps extends ToggleMenuBaseProps, React.HTMLProps<HTML
|
|
|
49
49
|
export const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
50
50
|
onSelect,
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
-
ref, // Types of Ref are different for React.
|
|
52
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
53
53
|
ouiaId,
|
|
54
54
|
ouiaSafe,
|
|
55
55
|
alignments,
|
|
@@ -63,7 +63,7 @@ export const DropdownItem: React.FunctionComponent<DropdownItemProps> = ({
|
|
|
63
63
|
listItemClassName,
|
|
64
64
|
onClick,
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
-
ref, // Types of Ref are different for React.
|
|
66
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
67
67
|
additionalChild,
|
|
68
68
|
customChild,
|
|
69
69
|
tabIndex = -1,
|
|
@@ -14,7 +14,7 @@ export interface SeparatorProps extends React.HTMLProps<HTMLAnchorElement>, OUIA
|
|
|
14
14
|
export const DropdownSeparator: React.FunctionComponent<SeparatorProps> = ({
|
|
15
15
|
className = '',
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
ref, // Types of Ref are different for React.
|
|
17
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
18
18
|
ouiaId,
|
|
19
19
|
ouiaSafe,
|
|
20
20
|
...props
|
|
@@ -75,7 +75,7 @@ export const DropdownToggle: React.FunctionComponent<DropdownToggleProps> = ({
|
|
|
75
75
|
ouiaId,
|
|
76
76
|
ouiaSafe,
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
-
ref, // Types of Ref are different for React.
|
|
78
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
79
79
|
...props
|
|
80
80
|
}: DropdownToggleProps) => {
|
|
81
81
|
const ouiaProps = useOUIAProps(DropdownToggle.displayName, ouiaId, ouiaSafe);
|
|
@@ -47,7 +47,7 @@ export const KebabToggle: React.FunctionComponent<KebabToggleProps> = ({
|
|
|
47
47
|
bubbleEvent = false,
|
|
48
48
|
onToggle = () => undefined as void,
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
|
-
ref, // Types of Ref are different for React.
|
|
50
|
+
ref, // Types of Ref are different for React.FunctionComponent vs React.Component
|
|
51
51
|
...props
|
|
52
52
|
}: KebabToggleProps) => (
|
|
53
53
|
<Toggle
|
|
@@ -12,7 +12,7 @@ export interface OverflowMenuContentProps extends React.HTMLProps<HTMLDivElement
|
|
|
12
12
|
isPersistent?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const OverflowMenuContent: React.
|
|
15
|
+
export const OverflowMenuContent: React.FunctionComponent<OverflowMenuContentProps> = ({
|
|
16
16
|
className,
|
|
17
17
|
children,
|
|
18
18
|
isPersistent
|
|
@@ -12,7 +12,7 @@ export interface OverflowMenuControlProps extends React.HTMLProps<HTMLDivElement
|
|
|
12
12
|
hasAdditionalOptions?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const OverflowMenuControl: React.
|
|
15
|
+
export const OverflowMenuControl: React.FunctionComponent<OverflowMenuControlProps> = ({
|
|
16
16
|
className,
|
|
17
17
|
children,
|
|
18
18
|
hasAdditionalOptions,
|
|
@@ -9,7 +9,7 @@ export interface OverflowMenuDropdownItemProps extends DropdownItemProps {
|
|
|
9
9
|
index?: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const OverflowMenuDropdownItem: React.
|
|
12
|
+
export const OverflowMenuDropdownItem: React.FunctionComponent<OverflowMenuDropdownItemProps> = ({
|
|
13
13
|
children,
|
|
14
14
|
isShared = false,
|
|
15
15
|
index,
|
|
@@ -14,7 +14,7 @@ export interface OverflowMenuGroupProps extends React.HTMLProps<HTMLDivElement>
|
|
|
14
14
|
groupType?: 'button' | 'icon';
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const OverflowMenuGroup: React.
|
|
17
|
+
export const OverflowMenuGroup: React.FunctionComponent<OverflowMenuGroupProps> = ({
|
|
18
18
|
className,
|
|
19
19
|
children,
|
|
20
20
|
isPersistent = false,
|
|
@@ -12,7 +12,7 @@ export interface OverflowMenuItemProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
12
12
|
isPersistent?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const OverflowMenuItem: React.
|
|
15
|
+
export const OverflowMenuItem: React.FunctionComponent<OverflowMenuItemProps> = ({
|
|
16
16
|
className,
|
|
17
17
|
children,
|
|
18
18
|
isPersistent = false
|