@patternfly/react-core 4.202.20 → 4.202.21
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/umd/react-core.css +4 -2
- package/dist/umd/react-core.min.css +4 -2
- package/package.json +6 -6
- 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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 4.202.21 (2022-04-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## 4.202.20 (2022-04-08)
|
|
7
15
|
|
|
8
16
|
|
package/dist/umd/react-core.css
CHANGED
|
@@ -8017,6 +8017,8 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8017
8017
|
--pf-c-form__label--FontSize: var(--pf-global--FontSize--sm);
|
|
8018
8018
|
--pf-c-form__label--LineHeight: var(--pf-global--LineHeight--sm);
|
|
8019
8019
|
--pf-c-form__label--m-disabled--Color: var(--pf-global--disabled-color--100);
|
|
8020
|
+
--pf-c-form__label--hover--Cursor: pointer;
|
|
8021
|
+
--pf-c-form__label--m-disabled--hover--Cursor: not-allowed;
|
|
8020
8022
|
--pf-c-form__label-text--FontWeight: var(--pf-global--FontWeight--bold);
|
|
8021
8023
|
--pf-c-form__label-required--MarginLeft: var(--pf-global--spacer--xs);
|
|
8022
8024
|
--pf-c-form__label-required--FontSize: var(--pf-global--FontSize--sm);
|
|
@@ -8328,7 +8330,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8328
8330
|
}
|
|
8329
8331
|
|
|
8330
8332
|
.pf-c-form__label:not(.pf-m-disabled):hover {
|
|
8331
|
-
cursor:
|
|
8333
|
+
cursor: var(--pf-c-form__label--hover--Cursor);
|
|
8332
8334
|
}
|
|
8333
8335
|
|
|
8334
8336
|
.pf-c-form__label.pf-m-disabled {
|
|
@@ -8336,7 +8338,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8336
8338
|
}
|
|
8337
8339
|
|
|
8338
8340
|
.pf-c-form__label.pf-m-disabled:hover {
|
|
8339
|
-
cursor:
|
|
8341
|
+
cursor: var(--pf-c-form__label--m-disabled--hover--Cursor);
|
|
8340
8342
|
}
|
|
8341
8343
|
|
|
8342
8344
|
.pf-c-form__label-text {
|
|
@@ -8017,6 +8017,8 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8017
8017
|
--pf-c-form__label--FontSize: var(--pf-global--FontSize--sm);
|
|
8018
8018
|
--pf-c-form__label--LineHeight: var(--pf-global--LineHeight--sm);
|
|
8019
8019
|
--pf-c-form__label--m-disabled--Color: var(--pf-global--disabled-color--100);
|
|
8020
|
+
--pf-c-form__label--hover--Cursor: pointer;
|
|
8021
|
+
--pf-c-form__label--m-disabled--hover--Cursor: not-allowed;
|
|
8020
8022
|
--pf-c-form__label-text--FontWeight: var(--pf-global--FontWeight--bold);
|
|
8021
8023
|
--pf-c-form__label-required--MarginLeft: var(--pf-global--spacer--xs);
|
|
8022
8024
|
--pf-c-form__label-required--FontSize: var(--pf-global--FontSize--sm);
|
|
@@ -8328,7 +8330,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8328
8330
|
}
|
|
8329
8331
|
|
|
8330
8332
|
.pf-c-form__label:not(.pf-m-disabled):hover {
|
|
8331
|
-
cursor:
|
|
8333
|
+
cursor: var(--pf-c-form__label--hover--Cursor);
|
|
8332
8334
|
}
|
|
8333
8335
|
|
|
8334
8336
|
.pf-c-form__label.pf-m-disabled {
|
|
@@ -8336,7 +8338,7 @@ label.pf-c-check, .pf-c-check__label,
|
|
|
8336
8338
|
}
|
|
8337
8339
|
|
|
8338
8340
|
.pf-c-form__label.pf-m-disabled:hover {
|
|
8339
|
-
cursor:
|
|
8341
|
+
cursor: var(--pf-c-form__label--m-disabled--hover--Cursor);
|
|
8340
8342
|
}
|
|
8341
8343
|
|
|
8342
8344
|
.pf-c-form__label-text {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.202.
|
|
3
|
+
"version": "4.202.21",
|
|
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.21",
|
|
38
|
+
"@patternfly/react-styles": "^4.52.21",
|
|
39
|
+
"@patternfly/react-tokens": "^4.54.21",
|
|
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": "15786a5112cf09f6bdbc95b067918cf24ec74ba0"
|
|
64
64
|
}
|
|
@@ -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
|
+
};
|