@patternfly/react-core 4.182.0 → 4.183.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 +41 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts +1 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js +5 -0
- package/dist/esm/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.js +8 -4
- package/dist/esm/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.js +5 -1
- package/dist/esm/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/esm/components/Pagination/Navigation.d.ts +2 -0
- package/dist/esm/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Navigation.js +3 -2
- package/dist/esm/components/Pagination/Navigation.js.map +1 -1
- package/dist/esm/components/Pagination/Pagination.d.ts +2 -0
- package/dist/esm/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/esm/components/Pagination/Pagination.js +2 -1
- package/dist/esm/components/Pagination/Pagination.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +13 -0
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +28 -9
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.d.ts +2 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePickerUtils.js +45 -19
- package/dist/esm/components/TimePicker/TimePickerUtils.js.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts +1 -0
- package/dist/js/components/ClipboardCopy/ClipboardCopy.d.ts.map +1 -1
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js +5 -0
- package/dist/js/components/ClipboardCopy/ClipboardCopy.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuControl.js +7 -4
- package/dist/js/components/OverflowMenu/OverflowMenuControl.js.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.d.ts.map +1 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.js +4 -1
- package/dist/js/components/OverflowMenu/OverflowMenuGroup.js.map +1 -1
- package/dist/js/components/Pagination/Navigation.d.ts +2 -0
- package/dist/js/components/Pagination/Navigation.d.ts.map +1 -1
- package/dist/js/components/Pagination/Navigation.js +3 -2
- package/dist/js/components/Pagination/Navigation.js.map +1 -1
- package/dist/js/components/Pagination/Pagination.d.ts +2 -0
- package/dist/js/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/js/components/Pagination/Pagination.js +2 -1
- package/dist/js/components/Pagination/Pagination.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +13 -0
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +27 -8
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/components/TimePicker/TimePickerUtils.d.ts +2 -1
- package/dist/js/components/TimePicker/TimePickerUtils.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePickerUtils.js +47 -20
- package/dist/js/components/TimePicker/TimePickerUtils.js.map +1 -1
- package/dist/umd/react-core.css +218 -218
- package/dist/umd/react-core.js +93 -35
- package/dist/umd/react-core.min.css +796 -796
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +5 -5
- package/src/components/ClipboardCopy/ClipboardCopy.tsx +6 -0
- package/src/components/OverflowMenu/OverflowMenuControl.tsx +6 -2
- package/src/components/OverflowMenu/OverflowMenuGroup.tsx +3 -1
- package/src/components/Pagination/Navigation.tsx +5 -1
- package/src/components/Pagination/Pagination.tsx +4 -0
- package/src/components/Pagination/__tests__/Generated/__snapshots__/Pagination.test.tsx.snap +1 -0
- package/src/components/Pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +31 -0
- package/src/components/TimePicker/TimePicker.tsx +48 -9
- package/src/components/TimePicker/TimePickerUtils.tsx +54 -24
- package/src/components/TimePicker/examples/TimePicker.md +11 -0
package/dist/umd/react-core.js
CHANGED
|
@@ -7865,6 +7865,11 @@
|
|
|
7865
7865
|
this.updateText(this.props.children);
|
|
7866
7866
|
}
|
|
7867
7867
|
};
|
|
7868
|
+
this.componentWillUnmount = () => {
|
|
7869
|
+
if (this.timer) {
|
|
7870
|
+
window.clearTimeout(this.timer);
|
|
7871
|
+
}
|
|
7872
|
+
};
|
|
7868
7873
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
7869
7874
|
this.expandContent = (_event) => {
|
|
7870
7875
|
this.setState(prevState => ({
|
|
@@ -15840,16 +15845,22 @@
|
|
|
15840
15845
|
OverflowMenu.displayName = 'OverflowMenu';
|
|
15841
15846
|
OverflowMenu.contextType = OverflowMenuContext;
|
|
15842
15847
|
|
|
15843
|
-
const OverflowMenuControl = (
|
|
15844
|
-
" ",
|
|
15845
|
-
|
|
15846
|
-
|
|
15848
|
+
const OverflowMenuControl = (_a) => {
|
|
15849
|
+
var { className, children, hasAdditionalOptions } = _a, props = __rest$1(_a, ["className", "children", "hasAdditionalOptions"]);
|
|
15850
|
+
return (React__namespace.createElement(OverflowMenuContext.Consumer, null, value => (value.isBelowBreakpoint || hasAdditionalOptions) && (React__namespace.createElement("div", Object.assign({ className: css(_default$r.overflowMenuControl, className) }, props),
|
|
15851
|
+
' ',
|
|
15852
|
+
children,
|
|
15853
|
+
' '))));
|
|
15854
|
+
};
|
|
15847
15855
|
OverflowMenuControl.displayName = 'OverflowMenuControl';
|
|
15848
15856
|
|
|
15849
15857
|
const OverflowMenuContent = ({ className, children, isPersistent }) => (React__namespace.createElement(OverflowMenuContext.Consumer, null, value => (!value.isBelowBreakpoint || isPersistent) && (React__namespace.createElement("div", { className: css(_default$r.overflowMenuContent, className) }, children))));
|
|
15850
15858
|
OverflowMenuContent.displayName = 'OverflowMenuContent';
|
|
15851
15859
|
|
|
15852
|
-
const OverflowMenuGroup = (
|
|
15860
|
+
const OverflowMenuGroup = (_a) => {
|
|
15861
|
+
var { className, children, isPersistent = false, groupType } = _a, props = __rest$1(_a, ["className", "children", "isPersistent", "groupType"]);
|
|
15862
|
+
return (React__namespace.createElement(OverflowMenuContext.Consumer, null, value => (isPersistent || !value.isBelowBreakpoint) && (React__namespace.createElement("div", Object.assign({ className: css(_default$r.overflowMenuGroup, groupType === 'button' && _default$r.modifiers.buttonGroup, groupType === 'icon' && _default$r.modifiers.iconButtonGroup, className) }, props), children))));
|
|
15863
|
+
};
|
|
15853
15864
|
OverflowMenuGroup.displayName = 'OverflowMenuGroup';
|
|
15854
15865
|
|
|
15855
15866
|
const OverflowMenuItem = ({ className, children, isPersistent = false }) => (React__namespace.createElement(OverflowMenuContext.Consumer, null, value => (isPersistent || !value.isBelowBreakpoint) && (React__namespace.createElement("div", { className: css(_default$r.overflowMenuItem, className) },
|
|
@@ -16065,7 +16076,7 @@
|
|
|
16065
16076
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16066
16077
|
perPage,
|
|
16067
16078
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16068
|
-
onSetPage, isDisabled, itemCount, lastPage, firstPage, pagesTitle, toLastPage, toNextPage, toFirstPage, toPreviousPage, currPage, paginationTitle, ofWord, onNextClick, onPreviousClick, onFirstClick, onLastClick, onPageInput, className, isCompact } = _a, props = __rest$1(_a, ["page", "perPage", "onSetPage", "isDisabled", "itemCount", "lastPage", "firstPage", "pagesTitle", "toLastPage", "toNextPage", "toFirstPage", "toPreviousPage", "currPage", "paginationTitle", "ofWord", "onNextClick", "onPreviousClick", "onFirstClick", "onLastClick", "onPageInput", "className", "isCompact"]);
|
|
16079
|
+
onSetPage, isDisabled, itemCount, lastPage, firstPage, pagesTitle, pagesTitlePlural, toLastPage, toNextPage, toFirstPage, toPreviousPage, currPage, paginationTitle, ofWord, onNextClick, onPreviousClick, onFirstClick, onLastClick, onPageInput, className, isCompact } = _a, props = __rest$1(_a, ["page", "perPage", "onSetPage", "isDisabled", "itemCount", "lastPage", "firstPage", "pagesTitle", "pagesTitlePlural", "toLastPage", "toNextPage", "toFirstPage", "toPreviousPage", "currPage", "paginationTitle", "ofWord", "onNextClick", "onPreviousClick", "onFirstClick", "onLastClick", "onPageInput", "className", "isCompact"]);
|
|
16069
16080
|
const { userInputPage } = this.state;
|
|
16070
16081
|
return (React__namespace.createElement("nav", Object.assign({ className: css(_default$q.paginationNav, className), "aria-label": paginationTitle }, props),
|
|
16071
16082
|
!isCompact && (React__namespace.createElement("div", { className: css(_default$q.paginationNavControl, _default$q.modifiers.first) },
|
|
@@ -16088,7 +16099,7 @@
|
|
|
16088
16099
|
(itemCount || itemCount === 0) && (React__namespace.createElement("span", { "aria-hidden": "true" },
|
|
16089
16100
|
ofWord,
|
|
16090
16101
|
" ",
|
|
16091
|
-
pagesTitle ? pluralize(lastPage, pagesTitle) : lastPage)))),
|
|
16102
|
+
pagesTitle ? pluralize(lastPage, pagesTitle, pagesTitlePlural) : lastPage)))),
|
|
16092
16103
|
React__namespace.createElement("div", { className: _default$q.paginationNavControl },
|
|
16093
16104
|
React__namespace.createElement(Button, { variant: exports.ButtonVariant.plain, isDisabled: isDisabled || page === lastPage, "aria-label": toNextPage, "data-action": "next", onClick: event => {
|
|
16094
16105
|
const newPage = page + 1 <= lastPage ? page + 1 : lastPage;
|
|
@@ -16114,6 +16125,7 @@
|
|
|
16114
16125
|
lastPage: 0,
|
|
16115
16126
|
firstPage: 0,
|
|
16116
16127
|
pagesTitle: '',
|
|
16128
|
+
pagesTitlePlural: '',
|
|
16117
16129
|
toLastPage: 'Go to last page',
|
|
16118
16130
|
toNextPage: 'Go to next page',
|
|
16119
16131
|
toFirstPage: 'Go to first page',
|
|
@@ -16317,7 +16329,7 @@
|
|
|
16317
16329
|
toggleTemplate(toggleTemplateProps),
|
|
16318
16330
|
!toggleTemplate && (React__namespace.createElement(ToggleTemplate, { firstIndex: firstIndex, lastIndex: lastIndex, itemCount: itemCount, itemsTitle: titles.items, ofWord: titles.ofWord })))),
|
|
16319
16331
|
React__namespace.createElement(PaginationOptionsMenu, { itemsPerPageTitle: titles.itemsPerPage, perPageSuffix: titles.perPageSuffix, itemsTitle: isCompact ? '' : titles.items, optionsToggle: titles.optionsToggle, perPageOptions: perPageOptions, firstIndex: itemsStart !== null ? itemsStart : firstIndex, lastIndex: itemsEnd !== null ? itemsEnd : lastIndex, ofWord: titles.ofWord, defaultToFullPage: defaultToFullPage, itemCount: itemCount, page: page, perPage: perPage, lastPage: lastPage, onPerPageSelect: onPerPageSelect, dropDirection: dropDirection, widgetId: widgetId, toggleTemplate: toggleTemplate, isDisabled: isDisabled }),
|
|
16320
|
-
React__namespace.createElement(Navigation, { pagesTitle: titles.page, toLastPage: titles.toLastPage, toPreviousPage: titles.toPreviousPage, toNextPage: titles.toNextPage, toFirstPage: titles.toFirstPage, currPage: titles.currPage, paginationTitle: titles.paginationTitle, ofWord: titles.ofWord, page: itemCount && itemCount <= 0 ? 0 : page, perPage: perPage, itemCount: itemCount, firstPage: itemsStart !== null ? itemsStart : 1, lastPage: lastPage, onSetPage: onSetPage, onFirstClick: onFirstClick, onPreviousClick: onPreviousClick, onNextClick: onNextClick, onLastClick: onLastClick, onPageInput: onPageInput, isDisabled: isDisabled, isCompact: isCompact }),
|
|
16332
|
+
React__namespace.createElement(Navigation, { pagesTitle: titles.page, pagesTitlePlural: titles.pages, toLastPage: titles.toLastPage, toPreviousPage: titles.toPreviousPage, toNextPage: titles.toNextPage, toFirstPage: titles.toFirstPage, currPage: titles.currPage, paginationTitle: titles.paginationTitle, ofWord: titles.ofWord, page: itemCount && itemCount <= 0 ? 0 : page, perPage: perPage, itemCount: itemCount, firstPage: itemsStart !== null ? itemsStart : 1, lastPage: lastPage, onSetPage: onSetPage, onFirstClick: onFirstClick, onPreviousClick: onPreviousClick, onNextClick: onNextClick, onLastClick: onLastClick, onPageInput: onPageInput, isDisabled: isDisabled, isCompact: isCompact }),
|
|
16321
16333
|
children));
|
|
16322
16334
|
}
|
|
16323
16335
|
}
|
|
@@ -16333,6 +16345,7 @@
|
|
|
16333
16345
|
titles: {
|
|
16334
16346
|
items: '',
|
|
16335
16347
|
page: '',
|
|
16348
|
+
pages: '',
|
|
16336
16349
|
itemsPerPage: 'Items per page',
|
|
16337
16350
|
perPageSuffix: 'per page',
|
|
16338
16351
|
toFirstPage: 'Go to first page',
|
|
@@ -17762,7 +17775,7 @@
|
|
|
17762
17775
|
|
|
17763
17776
|
const amSuffix = ' AM';
|
|
17764
17777
|
const pmSuffix = ' PM';
|
|
17765
|
-
const makeTimeOptions = (stepMinutes, hour12, delimiter) => {
|
|
17778
|
+
const makeTimeOptions = (stepMinutes, hour12, delimiter, minTime, maxTime) => {
|
|
17766
17779
|
const res = [];
|
|
17767
17780
|
const iter = new Date(new Date().setHours(0, 0, 0, 0));
|
|
17768
17781
|
const iterDay = iter.getDay();
|
|
@@ -17780,13 +17793,16 @@
|
|
|
17780
17793
|
hour %= 12;
|
|
17781
17794
|
}
|
|
17782
17795
|
}
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17796
|
+
hour = hour12 ? hour.toString() : hour.toString().padStart(2, '0');
|
|
17797
|
+
const minutes = iter
|
|
17798
|
+
.getMinutes()
|
|
17799
|
+
.toString()
|
|
17800
|
+
.padStart(2, '0');
|
|
17801
|
+
const timeOption = hour + delimiter + minutes + (hour12 ? suffix : '');
|
|
17802
|
+
// time option is valid if within min/max constraints
|
|
17803
|
+
if (isWithinMinMax(minTime, maxTime, timeOption, delimiter)) {
|
|
17804
|
+
res.push(timeOption);
|
|
17805
|
+
}
|
|
17790
17806
|
iter.setMinutes(iter.getMinutes() + stepMinutes);
|
|
17791
17807
|
}
|
|
17792
17808
|
return res;
|
|
@@ -17811,20 +17827,14 @@
|
|
|
17811
17827
|
else if (typeof time === 'string') {
|
|
17812
17828
|
time = time.trim();
|
|
17813
17829
|
if (is12Hour && time !== '' && validateTime(time, timeRegex, delimiter, is12Hour)) {
|
|
17830
|
+
const [, hours, minutes, suffix = ''] = timeRegex.exec(time);
|
|
17831
|
+
const uppercaseSuffix = suffix.toUpperCase();
|
|
17814
17832
|
// Format AM/PM according to design
|
|
17815
17833
|
let ampm = '';
|
|
17816
|
-
if (
|
|
17817
|
-
time = time
|
|
17818
|
-
.toUpperCase()
|
|
17819
|
-
.replace(amSuffix.toUpperCase().trim(), '')
|
|
17820
|
-
.trim();
|
|
17834
|
+
if (uppercaseSuffix === amSuffix.toUpperCase().trim()) {
|
|
17821
17835
|
ampm = amSuffix;
|
|
17822
17836
|
}
|
|
17823
|
-
else if (
|
|
17824
|
-
time = time
|
|
17825
|
-
.toUpperCase()
|
|
17826
|
-
.replace(pmSuffix.toUpperCase().trim(), '')
|
|
17827
|
-
.trim();
|
|
17837
|
+
else if (uppercaseSuffix === pmSuffix.toUpperCase().trim()) {
|
|
17828
17838
|
ampm = pmSuffix;
|
|
17829
17839
|
}
|
|
17830
17840
|
else {
|
|
@@ -17832,7 +17842,7 @@
|
|
|
17832
17842
|
// append am/pm depending on time of day
|
|
17833
17843
|
ampm = new Date().getHours() > 11 ? pmSuffix : amSuffix;
|
|
17834
17844
|
}
|
|
17835
|
-
return `${
|
|
17845
|
+
return `${hours}${delimiter}${minutes}${ampm}`;
|
|
17836
17846
|
}
|
|
17837
17847
|
}
|
|
17838
17848
|
return time.toString();
|
|
@@ -17867,6 +17877,35 @@
|
|
|
17867
17877
|
const parts = time.match(timeRegex);
|
|
17868
17878
|
return parts && parts.length ? parseInt(parts[2]) : null;
|
|
17869
17879
|
};
|
|
17880
|
+
const isWithinMinMax = (minTime, maxTime, time, delimiter) => {
|
|
17881
|
+
// do not throw error if empty string
|
|
17882
|
+
if (time.trim() === '') {
|
|
17883
|
+
return true;
|
|
17884
|
+
}
|
|
17885
|
+
const convertTo24Hour = (time) => {
|
|
17886
|
+
const timeReg = new RegExp(`^\\s*(\\d\\d?)${delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
|
|
17887
|
+
const regMatches = timeReg.exec(time);
|
|
17888
|
+
if (!regMatches || !regMatches.length) {
|
|
17889
|
+
return;
|
|
17890
|
+
}
|
|
17891
|
+
let hours = regMatches[1].padStart(2, '0');
|
|
17892
|
+
const minutes = regMatches[2];
|
|
17893
|
+
const suffix = regMatches[3] || '';
|
|
17894
|
+
if (suffix.toUpperCase() === 'PM' && hours !== '12') {
|
|
17895
|
+
hours = `${parseInt(hours) + 12}`;
|
|
17896
|
+
}
|
|
17897
|
+
else if (suffix.toUpperCase() === 'AM' && hours === '12') {
|
|
17898
|
+
hours = '00';
|
|
17899
|
+
}
|
|
17900
|
+
return `${hours}${delimiter}${minutes}`;
|
|
17901
|
+
};
|
|
17902
|
+
// correctly format as 24hr times (12:30AM => 00:30, 1:15 => 01:15)
|
|
17903
|
+
minTime = convertTo24Hour(minTime);
|
|
17904
|
+
time = convertTo24Hour(time);
|
|
17905
|
+
maxTime = convertTo24Hour(maxTime);
|
|
17906
|
+
// simple string comparison for 24hr times
|
|
17907
|
+
return minTime <= time && time <= maxTime;
|
|
17908
|
+
};
|
|
17870
17909
|
|
|
17871
17910
|
class TimePicker extends React__namespace.Component {
|
|
17872
17911
|
constructor(props) {
|
|
@@ -17991,13 +18030,19 @@
|
|
|
17991
18030
|
? new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*$`)
|
|
17992
18031
|
: new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
|
|
17993
18032
|
this.getOptions = () => (this.menuRef && this.menuRef.current ? Array.from(this.menuRef.current.children) : []);
|
|
17994
|
-
this.
|
|
18033
|
+
this.isValidFormat = (time) => {
|
|
17995
18034
|
if (this.props.validateTime) {
|
|
17996
18035
|
return this.props.validateTime(time);
|
|
17997
18036
|
}
|
|
17998
18037
|
const { delimiter, is24Hour } = this.props;
|
|
17999
18038
|
return validateTime(time, this.state.timeRegex, delimiter, !is24Hour);
|
|
18000
18039
|
};
|
|
18040
|
+
this.isValidTime = (time) => {
|
|
18041
|
+
const { delimiter } = this.props;
|
|
18042
|
+
const { minTimeState, maxTimeState } = this.state;
|
|
18043
|
+
return isWithinMinMax(minTimeState, maxTimeState, time, delimiter);
|
|
18044
|
+
};
|
|
18045
|
+
this.isValid = (time) => this.isValidFormat(time) && this.isValidTime(time);
|
|
18001
18046
|
this.onToggle = (isOpen) => {
|
|
18002
18047
|
// on close, parse and validate input
|
|
18003
18048
|
this.setState(prevState => {
|
|
@@ -18047,6 +18092,13 @@
|
|
|
18047
18092
|
});
|
|
18048
18093
|
};
|
|
18049
18094
|
const { is24Hour, delimiter, time } = this.props;
|
|
18095
|
+
let { minTime, maxTime } = this.props;
|
|
18096
|
+
if (minTime === '') {
|
|
18097
|
+
minTime = is24Hour ? `00${delimiter}00` : `12${delimiter}00AM`;
|
|
18098
|
+
}
|
|
18099
|
+
if (maxTime === '') {
|
|
18100
|
+
maxTime = is24Hour ? `23${delimiter}59` : `11${delimiter}59PM`;
|
|
18101
|
+
}
|
|
18050
18102
|
const timeRegex = this.getRegExp();
|
|
18051
18103
|
this.state = {
|
|
18052
18104
|
isInvalid: false,
|
|
@@ -18054,7 +18106,9 @@
|
|
|
18054
18106
|
timeState: parseTime(time, timeRegex, delimiter, !is24Hour),
|
|
18055
18107
|
focusedIndex: null,
|
|
18056
18108
|
scrollIndex: 0,
|
|
18057
|
-
timeRegex
|
|
18109
|
+
timeRegex,
|
|
18110
|
+
minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour),
|
|
18111
|
+
maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour)
|
|
18058
18112
|
};
|
|
18059
18113
|
}
|
|
18060
18114
|
componentDidMount() {
|
|
@@ -18085,12 +18139,13 @@
|
|
|
18085
18139
|
}
|
|
18086
18140
|
}
|
|
18087
18141
|
render() {
|
|
18088
|
-
const _a = this.props, { 'aria-label': ariaLabel, isDisabled, className, placeholder, id, menuAppendTo, is24Hour, invalidFormatErrorMessage, direction, stepMinutes, width, delimiter,
|
|
18142
|
+
const _a = this.props, { 'aria-label': ariaLabel, isDisabled, className, placeholder, id, menuAppendTo, is24Hour, invalidFormatErrorMessage, invalidMinMaxErrorMessage, direction, stepMinutes, width, delimiter,
|
|
18089
18143
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
18090
|
-
onChange, time, validateTime, inputProps } = _a, props = __rest$1(_a, ['aria-label', "isDisabled", "className", "placeholder", "id", "menuAppendTo", "is24Hour", "invalidFormatErrorMessage", "direction", "stepMinutes", "width", "delimiter", "onChange", "time", "validateTime", "inputProps"]);
|
|
18091
|
-
const { timeState, isOpen, isInvalid, focusedIndex } = this.state;
|
|
18144
|
+
onChange, time, validateTime, inputProps, minTime, maxTime } = _a, props = __rest$1(_a, ['aria-label', "isDisabled", "className", "placeholder", "id", "menuAppendTo", "is24Hour", "invalidFormatErrorMessage", "invalidMinMaxErrorMessage", "direction", "stepMinutes", "width", "delimiter", "onChange", "time", "validateTime", "inputProps", "minTime", "maxTime"]);
|
|
18145
|
+
const { timeState, isOpen, isInvalid, focusedIndex, minTimeState, maxTimeState } = this.state;
|
|
18092
18146
|
const style = { '--pf-c-date-picker__input--c-form-control--Width': width };
|
|
18093
|
-
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter);
|
|
18147
|
+
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter, minTimeState, maxTimeState);
|
|
18148
|
+
const isValidFormat = this.isValidFormat(timeState);
|
|
18094
18149
|
const randomId = id || getUniqueId('time-picker');
|
|
18095
18150
|
const menuContainer = (React__namespace.createElement("ul", { ref: this.menuRef, className: css(_default$12.selectMenu), role: "listbox", "aria-labelledby": `${id}-input`, style: { maxHeight: '200px', overflowY: 'auto' } }, options.map((option, index) => (React__namespace.createElement(TimeOption, { key: index, value: option, index: index, onSelect: this.onSelect, isFocused: index === focusedIndex, id: `${id}-option-${index}` })))));
|
|
18096
18151
|
const inputAndToggle = (React__namespace.createElement("div", Object.assign({ className: css(_default$R.datePickerInput), style: style }, props),
|
|
@@ -18099,7 +18154,7 @@
|
|
|
18099
18154
|
React__namespace.createElement("div", { ref: this.toggleRef, className: css(_default$12.selectToggle, isDisabled && _default$12.modifiers.disabled, _default$12.modifiers.typeahead), style: { paddingLeft: '0' } },
|
|
18100
18155
|
React__namespace.createElement(TextInput, Object.assign({ className: css(_default$1b.formControl, _default$12.selectToggleTypeahead), id: `${randomId}-input`, "aria-label": ariaLabel, validated: isInvalid ? 'error' : 'default', placeholder: placeholder, value: timeState || '', type: "text", iconVariant: "clock", onClick: this.onInputFocus, onFocus: this.onInputFocus, onChange: this.onInputChange, onBlur: this.onBlur, autoComplete: "off", isDisabled: isDisabled, ref: this.inputRef }, inputProps))),
|
|
18101
18156
|
isOpen && menuAppendTo === 'inline' && menuContainer)),
|
|
18102
|
-
isInvalid && (React__namespace.createElement("div", { className: css(_default$R.datePickerHelperText, _default$R.modifiers.error) }, invalidFormatErrorMessage))));
|
|
18157
|
+
isInvalid && (React__namespace.createElement("div", { className: css(_default$R.datePickerHelperText, _default$R.modifiers.error) }, !isValidFormat ? invalidFormatErrorMessage : invalidMinMaxErrorMessage))));
|
|
18103
18158
|
const popperContainer = (React__namespace.createElement("div", { className: css(_default$12.select, isOpen && _default$12.modifiers.expanded, direction === exports.SelectDirection.up && _default$12.modifiers.top, className) }, isOpen && menuContainer));
|
|
18104
18159
|
return (React__namespace.createElement("div", { className: css(_default$R.datePicker, className) }, menuAppendTo === 'inline' ? (inputAndToggle) : (React__namespace.createElement(Popper, { trigger: inputAndToggle, popper: popperContainer, direction: direction, appendTo: menuAppendTo, isVisible: isOpen }))));
|
|
18105
18160
|
}
|
|
@@ -18111,6 +18166,7 @@
|
|
|
18111
18166
|
time: '',
|
|
18112
18167
|
is24Hour: false,
|
|
18113
18168
|
invalidFormatErrorMessage: 'Invalid time format',
|
|
18169
|
+
invalidMinMaxErrorMessage: 'Invalid time entered',
|
|
18114
18170
|
placeholder: 'hh:mm',
|
|
18115
18171
|
delimiter: ':',
|
|
18116
18172
|
'aria-label': 'Time picker',
|
|
@@ -18118,7 +18174,9 @@
|
|
|
18118
18174
|
direction: 'down',
|
|
18119
18175
|
width: 150,
|
|
18120
18176
|
stepMinutes: 30,
|
|
18121
|
-
inputProps: {}
|
|
18177
|
+
inputProps: {},
|
|
18178
|
+
minTime: '',
|
|
18179
|
+
maxTime: ''
|
|
18122
18180
|
};
|
|
18123
18181
|
|
|
18124
18182
|
var _default$d = {
|