@patternfly/react-core 4.276.11 → 4.277.0
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 +22 -0
- package/components/DatePicker/DatePicker.d.ts +11 -2
- package/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/components/DatePicker/DatePicker.js +15 -9
- package/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.d.ts +11 -2
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +15 -9
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/next/components/Select/Select.d.ts +8 -0
- package/dist/esm/next/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/next/components/Select/Select.js +10 -3
- package/dist/esm/next/components/Select/Select.js.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.d.ts +11 -2
- package/dist/js/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +15 -9
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/next/components/Select/Select.d.ts +8 -0
- package/dist/js/next/components/Select/Select.d.ts.map +1 -1
- package/dist/js/next/components/Select/Select.js +10 -3
- package/dist/js/next/components/Select/Select.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/next/components/Select/Select.d.ts +8 -0
- package/next/components/Select/Select.d.ts.map +1 -1
- package/next/components/Select/Select.js +10 -3
- package/next/components/Select/Select.js.map +1 -1
- package/package.json +2 -2
- package/src/components/DatePicker/DatePicker.tsx +31 -9
- package/src/components/DatePicker/examples/DatePicker.md +12 -1
- package/src/components/DatePicker/examples/DatePickerRequired.tsx +6 -0
- package/src/next/components/Select/Select.tsx +20 -9
|
@@ -27,6 +27,14 @@ export interface SelectProps extends MenuProps, OUIAProps {
|
|
|
27
27
|
zIndex?: number;
|
|
28
28
|
/** @beta Determines the accessible role of the select. For a checkbox select pass in "menu". */
|
|
29
29
|
role?: string;
|
|
30
|
+
/** The container to append the select to. Defaults to 'inline'.
|
|
31
|
+
* If your select is being cut off you can append it to an element higher up the DOM tree.
|
|
32
|
+
* Some examples:
|
|
33
|
+
* appendTo="inline"
|
|
34
|
+
* appendTo={() => document.body}
|
|
35
|
+
* appendTo={document.getElementById('target')}
|
|
36
|
+
*/
|
|
37
|
+
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
|
|
30
38
|
}
|
|
31
39
|
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<any>>;
|
|
32
40
|
//# sourceMappingURL=Select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAqB,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAgB,SAAS,EAAoB,MAAM,kBAAkB,CAAC;AAE7E,MAAM,WAAW,WAAY,SAAQ,SAAS,EAAE,SAAS;IACvD,iDAAiD;IACjD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,wIAAwI;IACxI,QAAQ,CAAC,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;IACvB,yEAAyE;IACzE,MAAM,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IAC7D,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CA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AE,OAAO,KAAK,IAAI,CAAC;IACzC,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACrC,iCAAiC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gGAAgG;IAChG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,WAAW,CAAC,GAAG,QAAQ,CAAC;CACzD;AAsGD,eAAO,MAAM,MAAM,yEAEjB,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { Menu, MenuContent } from '../../../components/Menu';
|
|
|
5
5
|
import { Popper } from '../../../helpers/Popper/Popper';
|
|
6
6
|
import { getOUIAProps, getDefaultOUIAId } from '../../../helpers';
|
|
7
7
|
const SelectBase = (_a) => {
|
|
8
|
-
var { children, className, onSelect, isOpen, selected, toggle, onOpenChange, isPlain, minWidth, innerRef, zIndex = 9999, role = 'listbox' } = _a, props = __rest(_a, ["children", "className", "onSelect", "isOpen", "selected", "toggle", "onOpenChange", "isPlain", "minWidth", "innerRef", "zIndex", "role"]);
|
|
8
|
+
var { children, className, onSelect, isOpen, selected, toggle, onOpenChange, isPlain, minWidth, innerRef, zIndex = 9999, role = 'listbox', appendTo = 'inline' } = _a, props = __rest(_a, ["children", "className", "onSelect", "isOpen", "selected", "toggle", "onOpenChange", "isPlain", "minWidth", "innerRef", "zIndex", "role", "appendTo"]);
|
|
9
9
|
const localMenuRef = React.useRef();
|
|
10
10
|
const toggleRef = React.useRef();
|
|
11
11
|
const containerRef = React.useRef();
|
|
@@ -52,8 +52,15 @@ const SelectBase = (_a) => {
|
|
|
52
52
|
}
|
|
53
53
|
}), getOUIAProps(Select.displayName, props.ouiaId !== undefined ? props.ouiaId : getDefaultOUIAId(Select.displayName), props.ouiaSafe !== undefined ? props.ouiaSafe : true), props),
|
|
54
54
|
React.createElement(MenuContent, null, children)));
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const popperProps = {
|
|
56
|
+
trigger: toggle(toggleRef),
|
|
57
|
+
removeFindDomNode: true,
|
|
58
|
+
popper: menu,
|
|
59
|
+
isVisible: isOpen,
|
|
60
|
+
zIndex
|
|
61
|
+
};
|
|
62
|
+
return appendTo === 'inline' ? (React.createElement("div", { ref: containerRef },
|
|
63
|
+
React.createElement(Popper, Object.assign({}, popperProps, { appendTo: containerRef.current || undefined })))) : (React.createElement(Popper, Object.assign({}, popperProps, { appendTo: appendTo })));
|
|
57
64
|
};
|
|
58
65
|
export const Select = React.forwardRef((props, ref) => (React.createElement(SelectBase, Object.assign({ innerRef: ref }, props))));
|
|
59
66
|
Select.displayName = 'Select';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../../src/next/components/Select/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAa,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAa,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../../src/next/components/Select/Select.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAa,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,YAAY,EAAa,g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core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.277.0",
|
|
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",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8 || ^17 || ^18",
|
|
71
71
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "19312a9d6645ccb1b54c686ef4d164097b2bf3fc"
|
|
74
74
|
}
|
|
@@ -11,6 +11,14 @@ import { useImperativeHandle } from 'react';
|
|
|
11
11
|
import { KeyTypes } from '../../helpers';
|
|
12
12
|
import { isValidDate } from '../../helpers/datetimeUtils';
|
|
13
13
|
|
|
14
|
+
/** Props that customize the requirement of a date */
|
|
15
|
+
export interface DatePickerRequiredObject {
|
|
16
|
+
/** Flag indicating the date is required. */
|
|
17
|
+
isRequired?: boolean;
|
|
18
|
+
/** Error message to display when the text input is empty and the isRequired prop is also passed in. */
|
|
19
|
+
emptyDateText?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
/** The main date picker component. */
|
|
15
23
|
|
|
16
24
|
export interface DatePickerProps
|
|
@@ -31,7 +39,7 @@ export interface DatePickerProps
|
|
|
31
39
|
className?: string;
|
|
32
40
|
/** How to format the date in the text input. */
|
|
33
41
|
dateFormat?: (date: Date) => string;
|
|
34
|
-
/** How to
|
|
42
|
+
/** How to parse the date in the text input. */
|
|
35
43
|
dateParse?: (value: string) => Date;
|
|
36
44
|
/** Helper text to display alongside the date picker. */
|
|
37
45
|
helperText?: React.ReactNode;
|
|
@@ -39,7 +47,7 @@ export interface DatePickerProps
|
|
|
39
47
|
inputProps?: TextInputProps;
|
|
40
48
|
/** Flag indicating the date picker is disabled. */
|
|
41
49
|
isDisabled?: boolean;
|
|
42
|
-
/** Error message to display when the text input
|
|
50
|
+
/** Error message to display when the text input contains a non-empty value in an invalid format. */
|
|
43
51
|
invalidFormatText?: string;
|
|
44
52
|
/** Callback called every time the text input loses focus. */
|
|
45
53
|
onBlur?: (event: any, value: string, date?: Date) => void;
|
|
@@ -49,6 +57,8 @@ export interface DatePickerProps
|
|
|
49
57
|
placeholder?: string;
|
|
50
58
|
/** Props to pass to the popover that contains the calendar month component. */
|
|
51
59
|
popoverProps?: Partial<Omit<PopoverProps, 'appendTo'>>;
|
|
60
|
+
/** Options to customize the requirement of a date */
|
|
61
|
+
requiredDateOptions?: DatePickerRequiredObject;
|
|
52
62
|
/** Functions that returns an error message if a date is invalid. */
|
|
53
63
|
validators?: ((date: Date) => string)[];
|
|
54
64
|
/** Value of the text input. */
|
|
@@ -94,6 +104,7 @@ const DatePickerBase = (
|
|
|
94
104
|
onChange = (): any => undefined,
|
|
95
105
|
onBlur = (): any => undefined,
|
|
96
106
|
invalidFormatText = 'Invalid date',
|
|
107
|
+
requiredDateOptions,
|
|
97
108
|
helperText,
|
|
98
109
|
appendTo = 'parent',
|
|
99
110
|
popoverProps,
|
|
@@ -120,6 +131,7 @@ const DatePickerBase = (
|
|
|
120
131
|
const style = { '--pf-c-date-picker__input--c-form-control--width-chars': widthChars, ...styleProps };
|
|
121
132
|
const buttonRef = React.useRef<HTMLButtonElement>();
|
|
122
133
|
const datePickerWrapperRef = React.useRef<HTMLDivElement>();
|
|
134
|
+
const emptyDateText = requiredDateOptions?.emptyDateText || 'Date cannot be blank';
|
|
123
135
|
|
|
124
136
|
React.useEffect(() => {
|
|
125
137
|
setValue(valueProp);
|
|
@@ -151,17 +163,22 @@ const DatePickerBase = (
|
|
|
151
163
|
};
|
|
152
164
|
|
|
153
165
|
const onInputBlur = (event: any) => {
|
|
154
|
-
if (pristine) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
166
|
const newValueDate = dateParse(value);
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
const dateIsValid = isValidDate(newValueDate);
|
|
168
|
+
const onBlurDateArg = dateIsValid ? new Date(newValueDate) : undefined;
|
|
169
|
+
onBlur(event, value, onBlurDateArg);
|
|
170
|
+
|
|
171
|
+
if (dateIsValid) {
|
|
160
172
|
setError(newValueDate);
|
|
161
|
-
}
|
|
162
|
-
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!dateIsValid && !pristine) {
|
|
163
176
|
setErrorText(invalidFormatText);
|
|
164
177
|
}
|
|
178
|
+
|
|
179
|
+
if (!dateIsValid && pristine && requiredDateOptions?.isRequired) {
|
|
180
|
+
setErrorText(emptyDateText);
|
|
181
|
+
}
|
|
165
182
|
};
|
|
166
183
|
|
|
167
184
|
const onDateClick = (newValueDate: Date) => {
|
|
@@ -235,6 +252,10 @@ const DatePickerBase = (
|
|
|
235
252
|
return false;
|
|
236
253
|
}
|
|
237
254
|
setPopoverOpen(false);
|
|
255
|
+
// If datepicker is required and the popover is opened without the text input
|
|
256
|
+
// first receiving focus, we want to validate that the text input is not blank upon
|
|
257
|
+
// closing the popover
|
|
258
|
+
requiredDateOptions?.isRequired && !value && setErrorText(emptyDateText);
|
|
238
259
|
if (event.key === KeyTypes.Escape && popoverOpen) {
|
|
239
260
|
event.stopPropagation();
|
|
240
261
|
}
|
|
@@ -250,6 +271,7 @@ const DatePickerBase = (
|
|
|
250
271
|
<InputGroup>
|
|
251
272
|
<TextInput
|
|
252
273
|
isDisabled={isDisabled}
|
|
274
|
+
isRequired={requiredDateOptions?.isRequired}
|
|
253
275
|
aria-label={ariaLabel}
|
|
254
276
|
placeholder={placeholder}
|
|
255
277
|
validated={errorText.trim() ? 'error' : 'default'}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: Date picker
|
|
3
3
|
section: components
|
|
4
4
|
cssPrefix: pf-c-date-picker
|
|
5
|
-
propComponents: ['DatePicker', 'CalendarFormat', 'DatePickerRef']
|
|
5
|
+
propComponents: ['DatePicker', 'CalendarFormat', 'DatePickerRef', 'DatePickerRequiredObject']
|
|
6
6
|
beta: true
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -13,6 +13,17 @@ beta: true
|
|
|
13
13
|
```ts file="./DatePickerBasic.tsx"
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
### Required
|
|
17
|
+
|
|
18
|
+
To require users to select a date before continuing, use the `requiredDateOptions.isRequired` property.
|
|
19
|
+
|
|
20
|
+
A required date picker will be invalid when the text input is empty and either the text input loses focus or the date picker popover is closed.
|
|
21
|
+
|
|
22
|
+
The error message can be customized via the `requiredDateOptions.emptyDateText` property.
|
|
23
|
+
|
|
24
|
+
```ts file="./DatePickerRequired.tsx"
|
|
25
|
+
```
|
|
26
|
+
|
|
16
27
|
### American format
|
|
17
28
|
|
|
18
29
|
```ts file="./DatePickerAmerican.tsx"
|
|
@@ -30,6 +30,14 @@ export interface SelectProps extends MenuProps, OUIAProps {
|
|
|
30
30
|
zIndex?: number;
|
|
31
31
|
/** @beta Determines the accessible role of the select. For a checkbox select pass in "menu". */
|
|
32
32
|
role?: string;
|
|
33
|
+
/** The container to append the select to. Defaults to 'inline'.
|
|
34
|
+
* If your select is being cut off you can append it to an element higher up the DOM tree.
|
|
35
|
+
* Some examples:
|
|
36
|
+
* appendTo="inline"
|
|
37
|
+
* appendTo={() => document.body}
|
|
38
|
+
* appendTo={document.getElementById('target')}
|
|
39
|
+
*/
|
|
40
|
+
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
|
|
@@ -45,6 +53,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
|
|
|
45
53
|
innerRef,
|
|
46
54
|
zIndex = 9999,
|
|
47
55
|
role = 'listbox',
|
|
56
|
+
appendTo = 'inline',
|
|
48
57
|
...props
|
|
49
58
|
}: SelectProps & OUIAProps) => {
|
|
50
59
|
const localMenuRef = React.useRef<HTMLDivElement>();
|
|
@@ -115,17 +124,19 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
|
|
|
115
124
|
<MenuContent>{children}</MenuContent>
|
|
116
125
|
</Menu>
|
|
117
126
|
);
|
|
118
|
-
|
|
127
|
+
const popperProps = {
|
|
128
|
+
trigger: toggle(toggleRef),
|
|
129
|
+
removeFindDomNode: true,
|
|
130
|
+
popper: menu,
|
|
131
|
+
isVisible: isOpen,
|
|
132
|
+
zIndex
|
|
133
|
+
};
|
|
134
|
+
return appendTo === 'inline' ? (
|
|
119
135
|
<div ref={containerRef}>
|
|
120
|
-
<Popper
|
|
121
|
-
trigger={toggle(toggleRef)}
|
|
122
|
-
removeFindDomNode
|
|
123
|
-
popper={menu}
|
|
124
|
-
appendTo={containerRef.current || undefined}
|
|
125
|
-
isVisible={isOpen}
|
|
126
|
-
zIndex={zIndex}
|
|
127
|
-
/>
|
|
136
|
+
<Popper {...popperProps} appendTo={containerRef.current || undefined} />
|
|
128
137
|
</div>
|
|
138
|
+
) : (
|
|
139
|
+
<Popper {...popperProps} appendTo={appendTo} />
|
|
129
140
|
);
|
|
130
141
|
};
|
|
131
142
|
|