@patternfly/react-core 4.206.1 → 4.206.4
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 +30 -0
- package/dist/esm/components/DataList/DataListCheck.d.ts +9 -3
- package/dist/esm/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataListCheck.js +2 -2
- package/dist/esm/components/DataList/DataListCheck.js.map +1 -1
- package/dist/js/components/DataList/DataListCheck.d.ts +9 -3
- package/dist/js/components/DataList/DataListCheck.d.ts.map +1 -1
- package/dist/js/components/DataList/DataListCheck.js +2 -2
- package/dist/js/components/DataList/DataListCheck.js.map +1 -1
- package/dist/umd/react-core.js +2 -2
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/DataList/DataListCheck.tsx +12 -5
- package/src/demos/DateTimePicker.md +67 -51
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.206.
|
|
3
|
+
"version": "4.206.4",
|
|
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,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.57.
|
|
38
|
-
"@patternfly/react-styles": "^4.56.
|
|
39
|
-
"@patternfly/react-tokens": "^4.58.
|
|
37
|
+
"@patternfly/react-icons": "^4.57.4",
|
|
38
|
+
"@patternfly/react-styles": "^4.56.4",
|
|
39
|
+
"@patternfly/react-tokens": "^4.58.4",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -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": "cc80f358e790331d92df19b49df25488b095265b"
|
|
64
64
|
}
|
|
@@ -9,14 +9,20 @@ 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 when it is controlled by React state.
|
|
13
|
-
*
|
|
12
|
+
/** Flag to show if the DataList checkbox is checked when it is controlled by React state. Both isChecked and checked are valid,
|
|
13
|
+
* but only use one.
|
|
14
|
+
* To make the DataList checkbox uncontrolled, instead use the defaultChecked prop, but do not use both.
|
|
14
15
|
*/
|
|
15
16
|
isChecked?: boolean;
|
|
17
|
+
/** Flag to show if the DataList checkbox is checked when it is controlled by React state. Both isChecked and checked are valid,
|
|
18
|
+
* but only use one.
|
|
19
|
+
* To make the DataList checkbox uncontrolled, instead use the defaultChecked prop, but do not use both.
|
|
20
|
+
*/
|
|
21
|
+
checked?: boolean;
|
|
16
22
|
/** Flag to set default value of DataList checkbox when it is uncontrolled by React state.
|
|
17
23
|
* To make the DataList checkbox controlled, instead use the isChecked prop, but do not use both.
|
|
18
24
|
*/
|
|
19
|
-
|
|
25
|
+
defaultChecked?: boolean;
|
|
20
26
|
/** A callback for when the DataList checkbox selection changes */
|
|
21
27
|
onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
|
|
22
28
|
/** Aria-labelledby of the DataList checkbox */
|
|
@@ -33,6 +39,7 @@ export const DataListCheck: React.FunctionComponent<DataListCheckProps> = ({
|
|
|
33
39
|
isDisabled = false,
|
|
34
40
|
isChecked = null,
|
|
35
41
|
checked = null,
|
|
42
|
+
defaultChecked,
|
|
36
43
|
otherControls = false,
|
|
37
44
|
...props
|
|
38
45
|
}: DataListCheckProps) => {
|
|
@@ -44,8 +51,8 @@ export const DataListCheck: React.FunctionComponent<DataListCheckProps> = ({
|
|
|
44
51
|
onChange={event => onChange(event.currentTarget.checked, event)}
|
|
45
52
|
aria-invalid={!isValid}
|
|
46
53
|
disabled={isDisabled}
|
|
47
|
-
{...(
|
|
48
|
-
{...(
|
|
54
|
+
{...([true, false].includes(defaultChecked) && { defaultChecked })}
|
|
55
|
+
{...(![true, false].includes(defaultChecked) && { checked: isChecked || checked })}
|
|
49
56
|
/>
|
|
50
57
|
</div>
|
|
51
58
|
);
|
|
@@ -15,18 +15,28 @@ In this demo, learn how to use a [CalendarMonth](/components/calendar-month) com
|
|
|
15
15
|
|
|
16
16
|
```js
|
|
17
17
|
import React from 'react';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
Dropdown,
|
|
20
|
+
DropdownToggle,
|
|
21
|
+
DropdownItem,
|
|
22
|
+
CalendarMonth,
|
|
23
|
+
InputGroup,
|
|
24
|
+
TextInput,
|
|
25
|
+
Button,
|
|
26
|
+
Popover
|
|
27
|
+
} from '@patternfly/react-core';
|
|
19
28
|
import OutlinedCalendarAltIcon from '@patternfly/react-icons/dist/esm/icons/outlined-calendar-alt-icon';
|
|
20
29
|
import OutlinedClockIcon from '@patternfly/react-icons/dist/esm/icons/outlined-clock-icon';
|
|
21
30
|
|
|
22
31
|
DateTimePicker = () => {
|
|
23
32
|
const [isCalendarOpen, setIsCalendarOpen] = React.useState(false);
|
|
24
33
|
const [isTimeOpen, setIsTimeOpen] = React.useState(false);
|
|
25
|
-
const [valueDate, setValueDate] = React.useState(
|
|
26
|
-
const [valueTime, setValueTime] = React.useState(
|
|
34
|
+
const [valueDate, setValueDate] = React.useState('MM-DD-YYYY');
|
|
35
|
+
const [valueTime, setValueTime] = React.useState('HH:MM');
|
|
27
36
|
const times = Array.from(new Array(10), (_, i) => i + 8);
|
|
28
|
-
const defaultTime =
|
|
29
|
-
const dateFormat = date =>
|
|
37
|
+
const defaultTime = '0:00';
|
|
38
|
+
const dateFormat = date =>
|
|
39
|
+
date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-');
|
|
30
40
|
|
|
31
41
|
const onToggleCalendar = () => {
|
|
32
42
|
setIsCalendarOpen(!isCalendarOpen);
|
|
@@ -34,69 +44,75 @@ DateTimePicker = () => {
|
|
|
34
44
|
};
|
|
35
45
|
|
|
36
46
|
const onToggleTime = ev => {
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
setIsTimeOpen(!isTimeOpen);
|
|
48
|
+
setIsCalendarOpen(false);
|
|
39
49
|
};
|
|
40
50
|
|
|
41
51
|
const onSelectCalendar = newValueDate => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
const newValue = dateFormat(newValueDate);
|
|
53
|
+
setValueDate(newValue);
|
|
54
|
+
setIsCalendarOpen(!isCalendarOpen);
|
|
55
|
+
// setting default time when it is not picked
|
|
56
|
+
if (valueTime === 'HH:MM') {
|
|
57
|
+
setValueTime(defaultTime);
|
|
58
|
+
}
|
|
49
59
|
};
|
|
50
60
|
|
|
51
61
|
const onSelectTime = ev => {
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
setValueTime(ev.target.value);
|
|
63
|
+
setIsTimeOpen(!isTimeOpen);
|
|
54
64
|
};
|
|
55
65
|
|
|
56
66
|
const timeOptions = times.map(time => (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
<DropdownItem key={time} component="button" value={`${time}:00`}>
|
|
68
|
+
{`${time}:00`}
|
|
69
|
+
</DropdownItem>
|
|
60
70
|
));
|
|
61
|
-
const calendar =
|
|
62
|
-
<CalendarMonth
|
|
63
|
-
date={valueDate}
|
|
64
|
-
onChange={onSelectCalendar}
|
|
65
|
-
/>
|
|
66
|
-
);
|
|
71
|
+
const calendar = <CalendarMonth date={valueDate} onChange={onSelectCalendar} />;
|
|
67
72
|
const time = (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
<Dropdown
|
|
74
|
+
onSelect={onSelectTime}
|
|
75
|
+
toggle={
|
|
76
|
+
<DropdownToggle
|
|
77
|
+
aria-label="Toggle the time picker menu"
|
|
78
|
+
toggleIndicator={null}
|
|
79
|
+
onToggle={onToggleTime}
|
|
80
|
+
style={{ padding: '6px 16px' }}
|
|
81
|
+
>
|
|
82
|
+
<OutlinedClockIcon />
|
|
83
|
+
</DropdownToggle>
|
|
84
|
+
}
|
|
85
|
+
isOpen={isTimeOpen}
|
|
86
|
+
dropdownItems={timeOptions}
|
|
77
87
|
/>
|
|
78
88
|
);
|
|
79
89
|
const calendarButton = (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
<Button variant="control" aria-label="Toggle the calendar" onClick={onToggleCalendar}>
|
|
91
|
+
<OutlinedCalendarAltIcon />
|
|
92
|
+
</Button>
|
|
83
93
|
);
|
|
84
94
|
return (
|
|
85
95
|
<div style={{ width: '300px' }}>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
<Popover
|
|
97
|
+
position="bottom"
|
|
98
|
+
bodyContent={calendar}
|
|
99
|
+
showClose={false}
|
|
100
|
+
isVisible={isCalendarOpen}
|
|
101
|
+
hasNoPadding
|
|
102
|
+
hasAutoWidth
|
|
103
|
+
>
|
|
104
|
+
<InputGroup>
|
|
105
|
+
<TextInput
|
|
106
|
+
type="'datetime-local"
|
|
107
|
+
id="date-time"
|
|
108
|
+
aria-label="date and time picker demo"
|
|
109
|
+
value={valueDate + ' ' + valueTime}
|
|
110
|
+
isReadOnly
|
|
111
|
+
/>
|
|
112
|
+
{calendarButton}
|
|
113
|
+
{time}
|
|
114
|
+
</InputGroup>
|
|
115
|
+
</Popover>
|
|
100
116
|
</div>
|
|
101
117
|
);
|
|
102
118
|
};
|