@patternfly/react-core 4.182.0 → 4.182.1
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 +11 -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/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/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 +104 -104
- package/dist/umd/react-core.js +88 -32
- 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/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.css
CHANGED
|
@@ -9427,6 +9427,110 @@ button.pf-c-label__content:focus {
|
|
|
9427
9427
|
color: var(--pf-c-label__icon--Color);
|
|
9428
9428
|
}
|
|
9429
9429
|
|
|
9430
|
+
.pf-c-inline-edit {
|
|
9431
|
+
--pf-c-inline-edit__group--item--MarginRight: var(--pf-global--spacer--sm);
|
|
9432
|
+
--pf-c-inline-edit__action--c-button--m-valid--m-plain--Color: var(--pf-global--link--Color);
|
|
9433
|
+
--pf-c-inline-edit__action--c-button--m-valid--m-plain--hover--Color: var(--pf-global--link--Color--hover);
|
|
9434
|
+
--pf-c-inline-edit__action--m-icon-group--item--MarginRight: 0;
|
|
9435
|
+
--pf-c-inline-edit__group--m-footer--MarginTop: var(--pf-global--spacer--xl);
|
|
9436
|
+
--pf-c-inline-edit__label--m-bold--FontWeight: var(--pf-global--FontWeight--semi-bold);
|
|
9437
|
+
}
|
|
9438
|
+
|
|
9439
|
+
.pf-c-inline-edit__group {
|
|
9440
|
+
display: flex;
|
|
9441
|
+
align-items: baseline;
|
|
9442
|
+
}
|
|
9443
|
+
|
|
9444
|
+
.pf-c-inline-edit__group > * {
|
|
9445
|
+
margin-right: var(--pf-c-inline-edit__group--item--MarginRight);
|
|
9446
|
+
}
|
|
9447
|
+
|
|
9448
|
+
.pf-c-inline-edit__group.pf-m-icon-group {
|
|
9449
|
+
--pf-c-inline-edit__group--item--MarginRight: var(--pf-c-inline-edit__action--m-icon-group--item--MarginRight);
|
|
9450
|
+
}
|
|
9451
|
+
|
|
9452
|
+
.pf-c-inline-edit__group.pf-m-footer {
|
|
9453
|
+
margin-top: var(--pf-c-inline-edit__group--m-footer--MarginTop);
|
|
9454
|
+
}
|
|
9455
|
+
|
|
9456
|
+
.pf-c-inline-edit__group.pf-m-column {
|
|
9457
|
+
--pf-c-inline-edit__group--item--MarginRight: 0;
|
|
9458
|
+
flex-direction: column;
|
|
9459
|
+
}
|
|
9460
|
+
|
|
9461
|
+
.pf-c-inline-edit__group > :last-child {
|
|
9462
|
+
--pf-c-inline-edit__group--item--MarginRight: 0;
|
|
9463
|
+
}
|
|
9464
|
+
|
|
9465
|
+
.pf-c-inline-edit__input {
|
|
9466
|
+
flex: 1;
|
|
9467
|
+
}
|
|
9468
|
+
|
|
9469
|
+
.pf-c-inline-edit__action.pf-m-valid .pf-c-button.pf-m-plain {
|
|
9470
|
+
--pf-c-button--m-plain--Color: var(--pf-c-inline-edit__action--c-button--m-valid--m-plain--Color);
|
|
9471
|
+
}
|
|
9472
|
+
|
|
9473
|
+
.pf-c-inline-edit__action.pf-m-valid .pf-c-button.pf-m-plain:hover {
|
|
9474
|
+
--pf-c-button--m-plain--Color: var(--pf-c-inline-edit__action--c-button--m-valid--m-plain--hover--Color);
|
|
9475
|
+
}
|
|
9476
|
+
|
|
9477
|
+
.pf-c-inline-edit__input,
|
|
9478
|
+
.pf-c-inline-edit__action,
|
|
9479
|
+
.pf-c-inline-edit__group.pf-m-action-group {
|
|
9480
|
+
display: none;
|
|
9481
|
+
visibility: hidden;
|
|
9482
|
+
}
|
|
9483
|
+
|
|
9484
|
+
.pf-c-inline-edit__action.pf-m-enable-editable {
|
|
9485
|
+
display: inline-block;
|
|
9486
|
+
visibility: visible;
|
|
9487
|
+
}
|
|
9488
|
+
|
|
9489
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9490
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9491
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group,
|
|
9492
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9493
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9494
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group {
|
|
9495
|
+
visibility: visible;
|
|
9496
|
+
}
|
|
9497
|
+
|
|
9498
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9499
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__input {
|
|
9500
|
+
display: block;
|
|
9501
|
+
}
|
|
9502
|
+
|
|
9503
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9504
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action {
|
|
9505
|
+
display: inline-block;
|
|
9506
|
+
}
|
|
9507
|
+
|
|
9508
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group,
|
|
9509
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group {
|
|
9510
|
+
display: inline-flex;
|
|
9511
|
+
}
|
|
9512
|
+
|
|
9513
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__value,
|
|
9514
|
+
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action.pf-m-enable-editable,
|
|
9515
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__value,
|
|
9516
|
+
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action.pf-m-enable-editable {
|
|
9517
|
+
display: none;
|
|
9518
|
+
visibility: hidden;
|
|
9519
|
+
}
|
|
9520
|
+
|
|
9521
|
+
.pf-c-inline-edit__label + .pf-c-inline-edit__action.pf-m-enable > .pf-c-button {
|
|
9522
|
+
margin-top: calc(var(--pf-c-button--PaddingTop) * -1);
|
|
9523
|
+
margin-bottom: calc(var(--pf-c-button--PaddingBottom) * -1);
|
|
9524
|
+
}
|
|
9525
|
+
|
|
9526
|
+
.pf-c-inline-edit__label.pf-m-bold {
|
|
9527
|
+
font-weight: var(--pf-c-inline-edit__label--m-bold--FontWeight);
|
|
9528
|
+
}
|
|
9529
|
+
|
|
9530
|
+
.pf-c-inline-edit__editable-text br {
|
|
9531
|
+
display: none;
|
|
9532
|
+
}
|
|
9533
|
+
|
|
9430
9534
|
.pf-c-label-group {
|
|
9431
9535
|
--pf-c-label-group__list--MarginBottom: calc(var(--pf-global--spacer--xs) * -1);
|
|
9432
9536
|
--pf-c-label-group__list--MarginRight: calc(var(--pf-global--spacer--xs) * -1);
|
|
@@ -9570,110 +9674,6 @@ button.pf-c-label__content:focus {
|
|
|
9570
9674
|
display: none;
|
|
9571
9675
|
}
|
|
9572
9676
|
|
|
9573
|
-
.pf-c-inline-edit {
|
|
9574
|
-
--pf-c-inline-edit__group--item--MarginRight: var(--pf-global--spacer--sm);
|
|
9575
|
-
--pf-c-inline-edit__action--c-button--m-valid--m-plain--Color: var(--pf-global--link--Color);
|
|
9576
|
-
--pf-c-inline-edit__action--c-button--m-valid--m-plain--hover--Color: var(--pf-global--link--Color--hover);
|
|
9577
|
-
--pf-c-inline-edit__action--m-icon-group--item--MarginRight: 0;
|
|
9578
|
-
--pf-c-inline-edit__group--m-footer--MarginTop: var(--pf-global--spacer--xl);
|
|
9579
|
-
--pf-c-inline-edit__label--m-bold--FontWeight: var(--pf-global--FontWeight--semi-bold);
|
|
9580
|
-
}
|
|
9581
|
-
|
|
9582
|
-
.pf-c-inline-edit__group {
|
|
9583
|
-
display: flex;
|
|
9584
|
-
align-items: baseline;
|
|
9585
|
-
}
|
|
9586
|
-
|
|
9587
|
-
.pf-c-inline-edit__group > * {
|
|
9588
|
-
margin-right: var(--pf-c-inline-edit__group--item--MarginRight);
|
|
9589
|
-
}
|
|
9590
|
-
|
|
9591
|
-
.pf-c-inline-edit__group.pf-m-icon-group {
|
|
9592
|
-
--pf-c-inline-edit__group--item--MarginRight: var(--pf-c-inline-edit__action--m-icon-group--item--MarginRight);
|
|
9593
|
-
}
|
|
9594
|
-
|
|
9595
|
-
.pf-c-inline-edit__group.pf-m-footer {
|
|
9596
|
-
margin-top: var(--pf-c-inline-edit__group--m-footer--MarginTop);
|
|
9597
|
-
}
|
|
9598
|
-
|
|
9599
|
-
.pf-c-inline-edit__group.pf-m-column {
|
|
9600
|
-
--pf-c-inline-edit__group--item--MarginRight: 0;
|
|
9601
|
-
flex-direction: column;
|
|
9602
|
-
}
|
|
9603
|
-
|
|
9604
|
-
.pf-c-inline-edit__group > :last-child {
|
|
9605
|
-
--pf-c-inline-edit__group--item--MarginRight: 0;
|
|
9606
|
-
}
|
|
9607
|
-
|
|
9608
|
-
.pf-c-inline-edit__input {
|
|
9609
|
-
flex: 1;
|
|
9610
|
-
}
|
|
9611
|
-
|
|
9612
|
-
.pf-c-inline-edit__action.pf-m-valid .pf-c-button.pf-m-plain {
|
|
9613
|
-
--pf-c-button--m-plain--Color: var(--pf-c-inline-edit__action--c-button--m-valid--m-plain--Color);
|
|
9614
|
-
}
|
|
9615
|
-
|
|
9616
|
-
.pf-c-inline-edit__action.pf-m-valid .pf-c-button.pf-m-plain:hover {
|
|
9617
|
-
--pf-c-button--m-plain--Color: var(--pf-c-inline-edit__action--c-button--m-valid--m-plain--hover--Color);
|
|
9618
|
-
}
|
|
9619
|
-
|
|
9620
|
-
.pf-c-inline-edit__input,
|
|
9621
|
-
.pf-c-inline-edit__action,
|
|
9622
|
-
.pf-c-inline-edit__group.pf-m-action-group {
|
|
9623
|
-
display: none;
|
|
9624
|
-
visibility: hidden;
|
|
9625
|
-
}
|
|
9626
|
-
|
|
9627
|
-
.pf-c-inline-edit__action.pf-m-enable-editable {
|
|
9628
|
-
display: inline-block;
|
|
9629
|
-
visibility: visible;
|
|
9630
|
-
}
|
|
9631
|
-
|
|
9632
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9633
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9634
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group,
|
|
9635
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9636
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9637
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group {
|
|
9638
|
-
visibility: visible;
|
|
9639
|
-
}
|
|
9640
|
-
|
|
9641
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__input,
|
|
9642
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__input {
|
|
9643
|
-
display: block;
|
|
9644
|
-
}
|
|
9645
|
-
|
|
9646
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action,
|
|
9647
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action {
|
|
9648
|
-
display: inline-block;
|
|
9649
|
-
}
|
|
9650
|
-
|
|
9651
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group,
|
|
9652
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__group.pf-m-action-group {
|
|
9653
|
-
display: inline-flex;
|
|
9654
|
-
}
|
|
9655
|
-
|
|
9656
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__value,
|
|
9657
|
-
.pf-c-inline-edit.pf-m-inline-editable .pf-c-inline-edit__action.pf-m-enable-editable,
|
|
9658
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__value,
|
|
9659
|
-
.pf-c-inline-edit .pf-m-inline-editable .pf-c-inline-edit__action.pf-m-enable-editable {
|
|
9660
|
-
display: none;
|
|
9661
|
-
visibility: hidden;
|
|
9662
|
-
}
|
|
9663
|
-
|
|
9664
|
-
.pf-c-inline-edit__label + .pf-c-inline-edit__action.pf-m-enable > .pf-c-button {
|
|
9665
|
-
margin-top: calc(var(--pf-c-button--PaddingTop) * -1);
|
|
9666
|
-
margin-bottom: calc(var(--pf-c-button--PaddingBottom) * -1);
|
|
9667
|
-
}
|
|
9668
|
-
|
|
9669
|
-
.pf-c-inline-edit__label.pf-m-bold {
|
|
9670
|
-
font-weight: var(--pf-c-inline-edit__label--m-bold--FontWeight);
|
|
9671
|
-
}
|
|
9672
|
-
|
|
9673
|
-
.pf-c-inline-edit__editable-text br {
|
|
9674
|
-
display: none;
|
|
9675
|
-
}
|
|
9676
|
-
|
|
9677
9677
|
.pf-c-list {
|
|
9678
9678
|
--pf-c-list--PaddingLeft: var(--pf-global--spacer--lg);
|
|
9679
9679
|
--pf-c-list--nested--MarginTop: var(--pf-global--spacer--sm);
|
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) },
|
|
@@ -17762,7 +17773,7 @@
|
|
|
17762
17773
|
|
|
17763
17774
|
const amSuffix = ' AM';
|
|
17764
17775
|
const pmSuffix = ' PM';
|
|
17765
|
-
const makeTimeOptions = (stepMinutes, hour12, delimiter) => {
|
|
17776
|
+
const makeTimeOptions = (stepMinutes, hour12, delimiter, minTime, maxTime) => {
|
|
17766
17777
|
const res = [];
|
|
17767
17778
|
const iter = new Date(new Date().setHours(0, 0, 0, 0));
|
|
17768
17779
|
const iterDay = iter.getDay();
|
|
@@ -17780,13 +17791,16 @@
|
|
|
17780
17791
|
hour %= 12;
|
|
17781
17792
|
}
|
|
17782
17793
|
}
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17794
|
+
hour = hour12 ? hour.toString() : hour.toString().padStart(2, '0');
|
|
17795
|
+
const minutes = iter
|
|
17796
|
+
.getMinutes()
|
|
17797
|
+
.toString()
|
|
17798
|
+
.padStart(2, '0');
|
|
17799
|
+
const timeOption = hour + delimiter + minutes + (hour12 ? suffix : '');
|
|
17800
|
+
// time option is valid if within min/max constraints
|
|
17801
|
+
if (isWithinMinMax(minTime, maxTime, timeOption, delimiter)) {
|
|
17802
|
+
res.push(timeOption);
|
|
17803
|
+
}
|
|
17790
17804
|
iter.setMinutes(iter.getMinutes() + stepMinutes);
|
|
17791
17805
|
}
|
|
17792
17806
|
return res;
|
|
@@ -17811,20 +17825,14 @@
|
|
|
17811
17825
|
else if (typeof time === 'string') {
|
|
17812
17826
|
time = time.trim();
|
|
17813
17827
|
if (is12Hour && time !== '' && validateTime(time, timeRegex, delimiter, is12Hour)) {
|
|
17828
|
+
const [, hours, minutes, suffix = ''] = timeRegex.exec(time);
|
|
17829
|
+
const uppercaseSuffix = suffix.toUpperCase();
|
|
17814
17830
|
// Format AM/PM according to design
|
|
17815
17831
|
let ampm = '';
|
|
17816
|
-
if (
|
|
17817
|
-
time = time
|
|
17818
|
-
.toUpperCase()
|
|
17819
|
-
.replace(amSuffix.toUpperCase().trim(), '')
|
|
17820
|
-
.trim();
|
|
17832
|
+
if (uppercaseSuffix === amSuffix.toUpperCase().trim()) {
|
|
17821
17833
|
ampm = amSuffix;
|
|
17822
17834
|
}
|
|
17823
|
-
else if (
|
|
17824
|
-
time = time
|
|
17825
|
-
.toUpperCase()
|
|
17826
|
-
.replace(pmSuffix.toUpperCase().trim(), '')
|
|
17827
|
-
.trim();
|
|
17835
|
+
else if (uppercaseSuffix === pmSuffix.toUpperCase().trim()) {
|
|
17828
17836
|
ampm = pmSuffix;
|
|
17829
17837
|
}
|
|
17830
17838
|
else {
|
|
@@ -17832,7 +17840,7 @@
|
|
|
17832
17840
|
// append am/pm depending on time of day
|
|
17833
17841
|
ampm = new Date().getHours() > 11 ? pmSuffix : amSuffix;
|
|
17834
17842
|
}
|
|
17835
|
-
return `${
|
|
17843
|
+
return `${hours}${delimiter}${minutes}${ampm}`;
|
|
17836
17844
|
}
|
|
17837
17845
|
}
|
|
17838
17846
|
return time.toString();
|
|
@@ -17867,6 +17875,35 @@
|
|
|
17867
17875
|
const parts = time.match(timeRegex);
|
|
17868
17876
|
return parts && parts.length ? parseInt(parts[2]) : null;
|
|
17869
17877
|
};
|
|
17878
|
+
const isWithinMinMax = (minTime, maxTime, time, delimiter) => {
|
|
17879
|
+
// do not throw error if empty string
|
|
17880
|
+
if (time.trim() === '') {
|
|
17881
|
+
return true;
|
|
17882
|
+
}
|
|
17883
|
+
const convertTo24Hour = (time) => {
|
|
17884
|
+
const timeReg = new RegExp(`^\\s*(\\d\\d?)${delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
|
|
17885
|
+
const regMatches = timeReg.exec(time);
|
|
17886
|
+
if (!regMatches || !regMatches.length) {
|
|
17887
|
+
return;
|
|
17888
|
+
}
|
|
17889
|
+
let hours = regMatches[1].padStart(2, '0');
|
|
17890
|
+
const minutes = regMatches[2];
|
|
17891
|
+
const suffix = regMatches[3] || '';
|
|
17892
|
+
if (suffix.toUpperCase() === 'PM' && hours !== '12') {
|
|
17893
|
+
hours = `${parseInt(hours) + 12}`;
|
|
17894
|
+
}
|
|
17895
|
+
else if (suffix.toUpperCase() === 'AM' && hours === '12') {
|
|
17896
|
+
hours = '00';
|
|
17897
|
+
}
|
|
17898
|
+
return `${hours}${delimiter}${minutes}`;
|
|
17899
|
+
};
|
|
17900
|
+
// correctly format as 24hr times (12:30AM => 00:30, 1:15 => 01:15)
|
|
17901
|
+
minTime = convertTo24Hour(minTime);
|
|
17902
|
+
time = convertTo24Hour(time);
|
|
17903
|
+
maxTime = convertTo24Hour(maxTime);
|
|
17904
|
+
// simple string comparison for 24hr times
|
|
17905
|
+
return minTime <= time && time <= maxTime;
|
|
17906
|
+
};
|
|
17870
17907
|
|
|
17871
17908
|
class TimePicker extends React__namespace.Component {
|
|
17872
17909
|
constructor(props) {
|
|
@@ -17991,13 +18028,19 @@
|
|
|
17991
18028
|
? new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*$`)
|
|
17992
18029
|
: new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
|
|
17993
18030
|
this.getOptions = () => (this.menuRef && this.menuRef.current ? Array.from(this.menuRef.current.children) : []);
|
|
17994
|
-
this.
|
|
18031
|
+
this.isValidFormat = (time) => {
|
|
17995
18032
|
if (this.props.validateTime) {
|
|
17996
18033
|
return this.props.validateTime(time);
|
|
17997
18034
|
}
|
|
17998
18035
|
const { delimiter, is24Hour } = this.props;
|
|
17999
18036
|
return validateTime(time, this.state.timeRegex, delimiter, !is24Hour);
|
|
18000
18037
|
};
|
|
18038
|
+
this.isValidTime = (time) => {
|
|
18039
|
+
const { delimiter } = this.props;
|
|
18040
|
+
const { minTimeState, maxTimeState } = this.state;
|
|
18041
|
+
return isWithinMinMax(minTimeState, maxTimeState, time, delimiter);
|
|
18042
|
+
};
|
|
18043
|
+
this.isValid = (time) => this.isValidFormat(time) && this.isValidTime(time);
|
|
18001
18044
|
this.onToggle = (isOpen) => {
|
|
18002
18045
|
// on close, parse and validate input
|
|
18003
18046
|
this.setState(prevState => {
|
|
@@ -18047,6 +18090,13 @@
|
|
|
18047
18090
|
});
|
|
18048
18091
|
};
|
|
18049
18092
|
const { is24Hour, delimiter, time } = this.props;
|
|
18093
|
+
let { minTime, maxTime } = this.props;
|
|
18094
|
+
if (minTime === '') {
|
|
18095
|
+
minTime = is24Hour ? `00${delimiter}00` : `12${delimiter}00AM`;
|
|
18096
|
+
}
|
|
18097
|
+
if (maxTime === '') {
|
|
18098
|
+
maxTime = is24Hour ? `23${delimiter}59` : `11${delimiter}59PM`;
|
|
18099
|
+
}
|
|
18050
18100
|
const timeRegex = this.getRegExp();
|
|
18051
18101
|
this.state = {
|
|
18052
18102
|
isInvalid: false,
|
|
@@ -18054,7 +18104,9 @@
|
|
|
18054
18104
|
timeState: parseTime(time, timeRegex, delimiter, !is24Hour),
|
|
18055
18105
|
focusedIndex: null,
|
|
18056
18106
|
scrollIndex: 0,
|
|
18057
|
-
timeRegex
|
|
18107
|
+
timeRegex,
|
|
18108
|
+
minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour),
|
|
18109
|
+
maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour)
|
|
18058
18110
|
};
|
|
18059
18111
|
}
|
|
18060
18112
|
componentDidMount() {
|
|
@@ -18085,12 +18137,13 @@
|
|
|
18085
18137
|
}
|
|
18086
18138
|
}
|
|
18087
18139
|
render() {
|
|
18088
|
-
const _a = this.props, { 'aria-label': ariaLabel, isDisabled, className, placeholder, id, menuAppendTo, is24Hour, invalidFormatErrorMessage, direction, stepMinutes, width, delimiter,
|
|
18140
|
+
const _a = this.props, { 'aria-label': ariaLabel, isDisabled, className, placeholder, id, menuAppendTo, is24Hour, invalidFormatErrorMessage, invalidMinMaxErrorMessage, direction, stepMinutes, width, delimiter,
|
|
18089
18141
|
/* 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;
|
|
18142
|
+
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"]);
|
|
18143
|
+
const { timeState, isOpen, isInvalid, focusedIndex, minTimeState, maxTimeState } = this.state;
|
|
18092
18144
|
const style = { '--pf-c-date-picker__input--c-form-control--Width': width };
|
|
18093
|
-
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter);
|
|
18145
|
+
const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter, minTimeState, maxTimeState);
|
|
18146
|
+
const isValidFormat = this.isValidFormat(timeState);
|
|
18094
18147
|
const randomId = id || getUniqueId('time-picker');
|
|
18095
18148
|
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
18149
|
const inputAndToggle = (React__namespace.createElement("div", Object.assign({ className: css(_default$R.datePickerInput), style: style }, props),
|
|
@@ -18099,7 +18152,7 @@
|
|
|
18099
18152
|
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
18153
|
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
18154
|
isOpen && menuAppendTo === 'inline' && menuContainer)),
|
|
18102
|
-
isInvalid && (React__namespace.createElement("div", { className: css(_default$R.datePickerHelperText, _default$R.modifiers.error) }, invalidFormatErrorMessage))));
|
|
18155
|
+
isInvalid && (React__namespace.createElement("div", { className: css(_default$R.datePickerHelperText, _default$R.modifiers.error) }, !isValidFormat ? invalidFormatErrorMessage : invalidMinMaxErrorMessage))));
|
|
18103
18156
|
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
18157
|
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
18158
|
}
|
|
@@ -18111,6 +18164,7 @@
|
|
|
18111
18164
|
time: '',
|
|
18112
18165
|
is24Hour: false,
|
|
18113
18166
|
invalidFormatErrorMessage: 'Invalid time format',
|
|
18167
|
+
invalidMinMaxErrorMessage: 'Invalid time entered',
|
|
18114
18168
|
placeholder: 'hh:mm',
|
|
18115
18169
|
delimiter: ':',
|
|
18116
18170
|
'aria-label': 'Time picker',
|
|
@@ -18118,7 +18172,9 @@
|
|
|
18118
18172
|
direction: 'down',
|
|
18119
18173
|
width: 150,
|
|
18120
18174
|
stepMinutes: 30,
|
|
18121
|
-
inputProps: {}
|
|
18175
|
+
inputProps: {},
|
|
18176
|
+
minTime: '',
|
|
18177
|
+
maxTime: ''
|
|
18122
18178
|
};
|
|
18123
18179
|
|
|
18124
18180
|
var _default$d = {
|