@patternfly/react-core 4.201.2 → 4.202.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 +11 -0
- package/dist/esm/components/Menu/MenuContent.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuContent.js +21 -2
- package/dist/esm/components/Menu/MenuContent.js.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +5 -3
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +36 -17
- package/dist/esm/components/Select/Select.js.map +1 -1
- package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectOption.js +3 -3
- package/dist/esm/components/Select/SelectOption.js.map +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts +1 -1
- package/dist/esm/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/esm/components/Select/SelectToggle.js +14 -14
- package/dist/esm/components/Select/SelectToggle.js.map +1 -1
- package/dist/esm/components/Select/selectConstants.d.ts +1 -0
- package/dist/esm/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/esm/components/Select/selectConstants.js.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.d.ts +6 -4
- package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/esm/components/TimePicker/TimePicker.js +15 -8
- package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/js/components/Menu/MenuContent.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuContent.js +21 -2
- package/dist/js/components/Menu/MenuContent.js.map +1 -1
- package/dist/js/components/Select/Select.d.ts +5 -3
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +36 -17
- package/dist/js/components/Select/Select.js.map +1 -1
- package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
- package/dist/js/components/Select/SelectOption.js +3 -3
- package/dist/js/components/Select/SelectOption.js.map +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts +1 -1
- package/dist/js/components/Select/SelectToggle.d.ts.map +1 -1
- package/dist/js/components/Select/SelectToggle.js +14 -14
- package/dist/js/components/Select/SelectToggle.js.map +1 -1
- package/dist/js/components/Select/selectConstants.d.ts +1 -0
- package/dist/js/components/Select/selectConstants.d.ts.map +1 -1
- package/dist/js/components/Select/selectConstants.js.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.d.ts +6 -4
- package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/js/components/TimePicker/TimePicker.js +15 -8
- package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/umd/react-core.css +31 -2
- package/dist/umd/react-core.js +96 -46
- package/dist/umd/react-core.min.css +31 -2
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/Menu/MenuContent.tsx +27 -2
- package/src/components/Select/Select.tsx +39 -18
- package/src/components/Select/SelectOption.tsx +7 -4
- package/src/components/Select/SelectToggle.tsx +15 -15
- package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
- package/src/components/Select/examples/Select.md +93 -40
- package/src/components/Select/selectConstants.tsx +1 -0
- package/src/components/TimePicker/TimePicker.tsx +20 -11
- package/src/components/TimePicker/examples/TimePicker.md +2 -0
|
@@ -299,7 +299,9 @@ class GroupedSingleSelectInput extends React.Component {
|
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
```
|
|
302
|
+
|
|
302
303
|
### Validated
|
|
304
|
+
|
|
303
305
|
```js
|
|
304
306
|
import React from 'react';
|
|
305
307
|
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
@@ -384,12 +386,15 @@ class ValidatedSelect extends React.Component {
|
|
|
384
386
|
>
|
|
385
387
|
{this.options}
|
|
386
388
|
</Select>
|
|
387
|
-
<div aria-live="polite" id="validated-helper" hidden>
|
|
389
|
+
<div aria-live="polite" id="validated-helper" hidden>
|
|
390
|
+
{validated}
|
|
391
|
+
</div>
|
|
388
392
|
</div>
|
|
389
393
|
);
|
|
390
394
|
}
|
|
391
395
|
}
|
|
392
396
|
```
|
|
397
|
+
|
|
393
398
|
### Checkbox input
|
|
394
399
|
|
|
395
400
|
```js
|
|
@@ -467,6 +472,7 @@ class CheckboxSelectInput extends React.Component {
|
|
|
467
472
|
}
|
|
468
473
|
}
|
|
469
474
|
```
|
|
475
|
+
|
|
470
476
|
### Checkbox input with counts
|
|
471
477
|
|
|
472
478
|
```js
|
|
@@ -719,7 +725,7 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
719
725
|
selected: '',
|
|
720
726
|
isCreatable: false,
|
|
721
727
|
isInputValuePersisted: false,
|
|
722
|
-
isInputFilterPersisted: false
|
|
728
|
+
isInputFilterPersisted: false
|
|
723
729
|
};
|
|
724
730
|
|
|
725
731
|
this.options = [
|
|
@@ -742,8 +748,7 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
742
748
|
};
|
|
743
749
|
|
|
744
750
|
this.onSelect = (event, selection) => {
|
|
745
|
-
this.setState({ selected: selection, isOpen: false }),
|
|
746
|
-
console.log('selected: ', selection);
|
|
751
|
+
this.setState({ selected: selection, isOpen: false }), console.log('selected: ', selection);
|
|
747
752
|
};
|
|
748
753
|
|
|
749
754
|
this.onFilter = (_, textInput) => {
|
|
@@ -784,7 +789,14 @@ class FilteringSingleSelectInput extends React.Component {
|
|
|
784
789
|
}
|
|
785
790
|
|
|
786
791
|
render() {
|
|
787
|
-
const {
|
|
792
|
+
const {
|
|
793
|
+
isOpen,
|
|
794
|
+
selected,
|
|
795
|
+
filteredOptions,
|
|
796
|
+
isInputValuePersisted,
|
|
797
|
+
isInputFilterPersisted,
|
|
798
|
+
isCreatable
|
|
799
|
+
} = this.state;
|
|
788
800
|
const titleId = 'single-filtering-select-id';
|
|
789
801
|
return (
|
|
790
802
|
<div>
|
|
@@ -1199,7 +1211,8 @@ class TypeaheadSelectInput extends React.Component {
|
|
|
1199
1211
|
isCreatable: false,
|
|
1200
1212
|
isInputValuePersisted: false,
|
|
1201
1213
|
isInputFilterPersisted: false,
|
|
1202
|
-
hasOnCreateOption: false
|
|
1214
|
+
hasOnCreateOption: false,
|
|
1215
|
+
resetOnSelect: true
|
|
1203
1216
|
};
|
|
1204
1217
|
|
|
1205
1218
|
this.onToggle = isOpen => {
|
|
@@ -1213,7 +1226,7 @@ class TypeaheadSelectInput extends React.Component {
|
|
|
1213
1226
|
else {
|
|
1214
1227
|
this.setState({
|
|
1215
1228
|
selected: selection,
|
|
1216
|
-
isOpen: false
|
|
1229
|
+
isOpen: this.state.resetOnSelect ? false : this.state.isOpen
|
|
1217
1230
|
});
|
|
1218
1231
|
console.log('selected:', selection);
|
|
1219
1232
|
}
|
|
@@ -1262,10 +1275,26 @@ class TypeaheadSelectInput extends React.Component {
|
|
|
1262
1275
|
isInputFilterPersisted: checked
|
|
1263
1276
|
});
|
|
1264
1277
|
};
|
|
1278
|
+
|
|
1279
|
+
this.toggleResetOnSelect = checked => {
|
|
1280
|
+
this.setState({
|
|
1281
|
+
resetOnSelect: checked
|
|
1282
|
+
});
|
|
1283
|
+
};
|
|
1265
1284
|
}
|
|
1266
1285
|
|
|
1267
1286
|
render() {
|
|
1268
|
-
const {
|
|
1287
|
+
const {
|
|
1288
|
+
isOpen,
|
|
1289
|
+
selected,
|
|
1290
|
+
isDisabled,
|
|
1291
|
+
isCreatable,
|
|
1292
|
+
hasOnCreateOption,
|
|
1293
|
+
isInputValuePersisted,
|
|
1294
|
+
isInputFilterPersisted,
|
|
1295
|
+
resetOnSelect,
|
|
1296
|
+
options
|
|
1297
|
+
} = this.state;
|
|
1269
1298
|
const titleId = 'typeahead-select-id-1';
|
|
1270
1299
|
return (
|
|
1271
1300
|
<div>
|
|
@@ -1287,6 +1316,7 @@ class TypeaheadSelectInput extends React.Component {
|
|
|
1287
1316
|
isDisabled={isDisabled}
|
|
1288
1317
|
isCreatable={isCreatable}
|
|
1289
1318
|
onCreateOption={(hasOnCreateOption && this.onCreateOption) || undefined}
|
|
1319
|
+
shouldResetOnSelect={resetOnSelect}
|
|
1290
1320
|
>
|
|
1291
1321
|
{options.map((option, index) => (
|
|
1292
1322
|
<SelectOption
|
|
@@ -1337,6 +1367,14 @@ class TypeaheadSelectInput extends React.Component {
|
|
|
1337
1367
|
id="toggle-input-filter-persisted"
|
|
1338
1368
|
name="toggle-input-filter-persisted"
|
|
1339
1369
|
/>
|
|
1370
|
+
<Checkbox
|
|
1371
|
+
label="shouldResetOnSelect"
|
|
1372
|
+
isChecked={this.state.resetOnSelect}
|
|
1373
|
+
onChange={this.toggleResetOnSelect}
|
|
1374
|
+
aria-label="toggle reset checkbox"
|
|
1375
|
+
id="toggle-reset-typeahead"
|
|
1376
|
+
name="toggle-reset-typeahead"
|
|
1377
|
+
/>
|
|
1340
1378
|
</div>
|
|
1341
1379
|
);
|
|
1342
1380
|
}
|
|
@@ -1580,7 +1618,8 @@ class MultiTypeaheadSelectInput extends React.Component {
|
|
|
1580
1618
|
selected: [],
|
|
1581
1619
|
isCreatable: false,
|
|
1582
1620
|
hasOnCreateOption: false,
|
|
1583
|
-
hasDisabledOption: false
|
|
1621
|
+
hasDisabledOption: false,
|
|
1622
|
+
resetOnSelect: true
|
|
1584
1623
|
};
|
|
1585
1624
|
|
|
1586
1625
|
this.onCreateOption = newValue => {
|
|
@@ -1629,18 +1668,24 @@ class MultiTypeaheadSelectInput extends React.Component {
|
|
|
1629
1668
|
});
|
|
1630
1669
|
};
|
|
1631
1670
|
|
|
1632
|
-
this.toggleOptionDisabled =
|
|
1671
|
+
this.toggleOptionDisabled = toggleIndex => () => {
|
|
1633
1672
|
this.setState(prevState => ({
|
|
1634
1673
|
hasDisabledOption: !prevState.hasDisabledOption,
|
|
1635
1674
|
options: prevState.options.map((option, index) =>
|
|
1636
1675
|
index === toggleIndex ? { ...option, disabled: !option.disabled } : option
|
|
1637
|
-
)
|
|
1676
|
+
)
|
|
1638
1677
|
}));
|
|
1639
1678
|
};
|
|
1679
|
+
|
|
1680
|
+
this.toggleResetOnSelect = checked => {
|
|
1681
|
+
this.setState({
|
|
1682
|
+
resetOnSelect: checked
|
|
1683
|
+
});
|
|
1684
|
+
};
|
|
1640
1685
|
}
|
|
1641
1686
|
|
|
1642
1687
|
render() {
|
|
1643
|
-
const { isOpen, selected, isCreatable, hasOnCreateOption, options } = this.state;
|
|
1688
|
+
const { isOpen, selected, isCreatable, hasOnCreateOption, resetOnSelect, options } = this.state;
|
|
1644
1689
|
const titleId = 'multi-typeahead-select-id-1';
|
|
1645
1690
|
|
|
1646
1691
|
return (
|
|
@@ -1660,6 +1705,7 @@ class MultiTypeaheadSelectInput extends React.Component {
|
|
|
1660
1705
|
placeholderText="Select a state"
|
|
1661
1706
|
isCreatable={isCreatable}
|
|
1662
1707
|
onCreateOption={(hasOnCreateOption && this.onCreateOption) || undefined}
|
|
1708
|
+
shouldResetOnSelect={resetOnSelect}
|
|
1663
1709
|
>
|
|
1664
1710
|
{options.map((option, index) => (
|
|
1665
1711
|
<SelectOption
|
|
@@ -1694,6 +1740,14 @@ class MultiTypeaheadSelectInput extends React.Component {
|
|
|
1694
1740
|
id="toggle-disable-first-option"
|
|
1695
1741
|
name="toggle-disable-first-option"
|
|
1696
1742
|
/>
|
|
1743
|
+
<Checkbox
|
|
1744
|
+
label="shouldResetOnSelect"
|
|
1745
|
+
isChecked={this.state.resetOnSelect}
|
|
1746
|
+
onChange={this.toggleResetOnSelect}
|
|
1747
|
+
aria-label="toggle multi reset checkbox"
|
|
1748
|
+
id="toggle-reset-multi-typeahead"
|
|
1749
|
+
name="toggle-reset-multi-typeahead"
|
|
1750
|
+
/>
|
|
1697
1751
|
</div>
|
|
1698
1752
|
);
|
|
1699
1753
|
}
|
|
@@ -2379,8 +2433,6 @@ class SelectWithFooter extends React.Component {
|
|
|
2379
2433
|
};
|
|
2380
2434
|
}
|
|
2381
2435
|
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
2436
|
render() {
|
|
2385
2437
|
const { isOpen, selected, isDisabled, direction, isToggleIcon } = this.state;
|
|
2386
2438
|
const titleId = 'title-id-footer';
|
|
@@ -2400,11 +2452,13 @@ class SelectWithFooter extends React.Component {
|
|
|
2400
2452
|
aria-labelledby={titleId}
|
|
2401
2453
|
isDisabled={isDisabled}
|
|
2402
2454
|
direction={direction}
|
|
2403
|
-
footer={
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2455
|
+
footer={
|
|
2456
|
+
<>
|
|
2457
|
+
<Button variant="link" isInline>
|
|
2458
|
+
Action
|
|
2459
|
+
</Button>
|
|
2460
|
+
</>
|
|
2461
|
+
}
|
|
2408
2462
|
>
|
|
2409
2463
|
{this.options}
|
|
2410
2464
|
</Select>
|
|
@@ -2483,7 +2537,11 @@ class SelectWithFooterCheckbox extends React.Component {
|
|
|
2483
2537
|
isOpen={isOpen}
|
|
2484
2538
|
placeholderText="Filter by status"
|
|
2485
2539
|
aria-labelledby={titleId}
|
|
2486
|
-
footer={
|
|
2540
|
+
footer={
|
|
2541
|
+
<Button variant="link" isInline>
|
|
2542
|
+
Action
|
|
2543
|
+
</Button>
|
|
2544
|
+
}
|
|
2487
2545
|
>
|
|
2488
2546
|
{this.options}
|
|
2489
2547
|
</Select>
|
|
@@ -2497,11 +2555,7 @@ class SelectWithFooterCheckbox extends React.Component {
|
|
|
2497
2555
|
|
|
2498
2556
|
```js isBeta
|
|
2499
2557
|
import React from 'react';
|
|
2500
|
-
import {
|
|
2501
|
-
Select,
|
|
2502
|
-
SelectOption,
|
|
2503
|
-
SelectVariant
|
|
2504
|
-
} from '@patternfly/react-core';
|
|
2558
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2505
2559
|
|
|
2506
2560
|
class SelectViewMore extends React.Component {
|
|
2507
2561
|
constructor(props) {
|
|
@@ -2578,7 +2632,10 @@ class SelectViewMore extends React.Component {
|
|
|
2578
2632
|
selections={selected}
|
|
2579
2633
|
isOpen={isOpen}
|
|
2580
2634
|
aria-labelledby={titleId}
|
|
2581
|
-
{...(!isLoading &&
|
|
2635
|
+
{...(!isLoading &&
|
|
2636
|
+
numOptions < this.options.length && {
|
|
2637
|
+
loadingVariant: { text: 'View more', onClick: this.onViewMoreClick }
|
|
2638
|
+
})}
|
|
2582
2639
|
{...(isLoading && { loadingVariant: 'spinner' })}
|
|
2583
2640
|
>
|
|
2584
2641
|
{this.options.slice(0, numOptions)}
|
|
@@ -2593,11 +2650,7 @@ class SelectViewMore extends React.Component {
|
|
|
2593
2650
|
|
|
2594
2651
|
```js isBeta
|
|
2595
2652
|
import React from 'react';
|
|
2596
|
-
import {
|
|
2597
|
-
Select,
|
|
2598
|
-
SelectOption,
|
|
2599
|
-
SelectVariant,
|
|
2600
|
-
} from '@patternfly/react-core';
|
|
2653
|
+
import { Select, SelectOption, SelectVariant } from '@patternfly/react-core';
|
|
2601
2654
|
|
|
2602
2655
|
class SelectViewMoreCheckbox extends React.Component {
|
|
2603
2656
|
constructor(props) {
|
|
@@ -2649,7 +2702,6 @@ class SelectViewMoreCheckbox extends React.Component {
|
|
|
2649
2702
|
});
|
|
2650
2703
|
};
|
|
2651
2704
|
|
|
2652
|
-
|
|
2653
2705
|
this.simulateNetworkCall = callback => {
|
|
2654
2706
|
setTimeout(callback, 2000);
|
|
2655
2707
|
};
|
|
@@ -2682,7 +2734,10 @@ class SelectViewMoreCheckbox extends React.Component {
|
|
|
2682
2734
|
isOpen={isOpen}
|
|
2683
2735
|
placeholderText="Filter by status"
|
|
2684
2736
|
aria-labelledby={titleId}
|
|
2685
|
-
{...(!isLoading &&
|
|
2737
|
+
{...(!isLoading &&
|
|
2738
|
+
numOptions < this.options.length && {
|
|
2739
|
+
loadingVariant: { text: 'View more', onClick: this.onViewMoreClick }
|
|
2740
|
+
})}
|
|
2686
2741
|
{...(isLoading && { loadingVariant: 'spinner' })}
|
|
2687
2742
|
>
|
|
2688
2743
|
{this.options.slice(0, numOptions)}
|
|
@@ -2690,7 +2745,6 @@ class SelectViewMoreCheckbox extends React.Component {
|
|
|
2690
2745
|
</div>
|
|
2691
2746
|
);
|
|
2692
2747
|
}
|
|
2693
|
-
|
|
2694
2748
|
}
|
|
2695
2749
|
```
|
|
2696
2750
|
|
|
@@ -2701,8 +2755,8 @@ import React from 'react';
|
|
|
2701
2755
|
import { Select, SelectOption } from '@patternfly/react-core';
|
|
2702
2756
|
|
|
2703
2757
|
function SelectWithPlaceholderStyle() {
|
|
2704
|
-
const [
|
|
2705
|
-
const [
|
|
2758
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
2759
|
+
const [selected, setSelected] = React.useState([]);
|
|
2706
2760
|
|
|
2707
2761
|
const options = [
|
|
2708
2762
|
<SelectOption key={0} value="Active" />,
|
|
@@ -2748,7 +2802,6 @@ function SelectWithPlaceholderStyle() {
|
|
|
2748
2802
|
}
|
|
2749
2803
|
```
|
|
2750
2804
|
|
|
2751
|
-
|
|
2752
2805
|
### With a style applied to the placeholder option
|
|
2753
2806
|
|
|
2754
2807
|
```js
|
|
@@ -2756,11 +2809,11 @@ import React from 'react';
|
|
|
2756
2809
|
import { Select, SelectOption } from '@patternfly/react-core';
|
|
2757
2810
|
|
|
2758
2811
|
function SelectWithPlaceholderStyle() {
|
|
2759
|
-
const [
|
|
2760
|
-
const [
|
|
2812
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
2813
|
+
const [selected, setSelected] = React.useState([]);
|
|
2761
2814
|
|
|
2762
2815
|
const options = [
|
|
2763
|
-
<SelectOption key={0} value="Filter by status" isPlaceholder/>,
|
|
2816
|
+
<SelectOption key={0} value="Filter by status" isPlaceholder />,
|
|
2764
2817
|
<SelectOption key={1} value="Active" />,
|
|
2765
2818
|
<SelectOption key={2} value="Cancelled" />,
|
|
2766
2819
|
<SelectOption key={3} value="Paused" />
|
|
@@ -11,6 +11,7 @@ export interface SelectContextInterface {
|
|
|
11
11
|
onFavorite: (itemId: string, isFavorite: boolean) => void;
|
|
12
12
|
variant: string;
|
|
13
13
|
inputIdPrefix: string;
|
|
14
|
+
shouldResetOnSelect: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export const SelectContext = React.createContext<SelectContextInterface | null>(null);
|
|
@@ -49,13 +49,14 @@ export interface TimePickerProps
|
|
|
49
49
|
id?: string;
|
|
50
50
|
/** Width of the time picker. */
|
|
51
51
|
width?: string;
|
|
52
|
-
/** The container to append the menu to. Defaults to 'inline'
|
|
52
|
+
/** The container to append the menu to. Defaults to 'inline'.
|
|
53
53
|
* If your menu is being cut off you can append it to an element higher up the DOM tree.
|
|
54
54
|
* Some examples:
|
|
55
|
+
* menuAppendTo="parent"
|
|
55
56
|
* menuAppendTo={() => document.body}
|
|
56
57
|
* menuAppendTo={document.getElementById('target')}
|
|
57
58
|
*/
|
|
58
|
-
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline';
|
|
59
|
+
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
|
|
59
60
|
/** Size of step between time options in minutes.*/
|
|
60
61
|
stepMinutes?: number;
|
|
61
62
|
/** Additional props for input field */
|
|
@@ -81,7 +82,7 @@ interface TimePickerState {
|
|
|
81
82
|
|
|
82
83
|
export class TimePicker extends React.Component<TimePickerProps, TimePickerState> {
|
|
83
84
|
static displayName = 'TimePicker';
|
|
84
|
-
private
|
|
85
|
+
private baseComponentRef = React.createRef<any>();
|
|
85
86
|
private toggleRef = React.createRef<HTMLDivElement>();
|
|
86
87
|
private inputRef = React.createRef<HTMLInputElement>();
|
|
87
88
|
private menuRef = React.createRef<HTMLDivElement>();
|
|
@@ -97,6 +98,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
97
98
|
delimiter: ':',
|
|
98
99
|
'aria-label': 'Time picker',
|
|
99
100
|
width: '150px',
|
|
101
|
+
menuAppendTo: 'inline',
|
|
100
102
|
stepMinutes: 30,
|
|
101
103
|
inputProps: {},
|
|
102
104
|
minTime: '',
|
|
@@ -141,7 +143,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
onDocClick = (event: MouseEvent | TouchEvent) => {
|
|
144
|
-
const clickedOnToggle = this.
|
|
146
|
+
const clickedOnToggle = this.toggleRef?.current?.contains(event.target as Node);
|
|
145
147
|
const clickedWithinMenu = this.menuRef?.current?.contains(event.target as Node);
|
|
146
148
|
if (this.state.isOpen && !(clickedOnToggle || clickedWithinMenu)) {
|
|
147
149
|
this.onToggle(false);
|
|
@@ -362,7 +364,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
362
364
|
});
|
|
363
365
|
};
|
|
364
366
|
|
|
365
|
-
|
|
367
|
+
onInputClick = (e: any) => {
|
|
366
368
|
if (!this.state.isOpen) {
|
|
367
369
|
this.onToggle(true);
|
|
368
370
|
}
|
|
@@ -429,10 +431,17 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
429
431
|
const isValidFormat = this.isValidFormat(timeState);
|
|
430
432
|
const randomId = id || getUniqueId('time-picker');
|
|
431
433
|
|
|
434
|
+
const getParentElement = () => {
|
|
435
|
+
if (this.baseComponentRef && this.baseComponentRef.current) {
|
|
436
|
+
return this.baseComponentRef.current.parentElement;
|
|
437
|
+
}
|
|
438
|
+
return null;
|
|
439
|
+
};
|
|
440
|
+
|
|
432
441
|
const menuContainer = (
|
|
433
442
|
<Menu ref={this.menuRef} isScrollable>
|
|
434
443
|
<MenuContent maxMenuHeight="200px">
|
|
435
|
-
<MenuList aria-
|
|
444
|
+
<MenuList aria-label={ariaLabel}>
|
|
436
445
|
{options.map((option, index) => (
|
|
437
446
|
<MenuItem onClick={this.onSelect} key={option} id={`${randomId}-option-${index}`}>
|
|
438
447
|
{option}
|
|
@@ -445,6 +454,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
445
454
|
|
|
446
455
|
const textInput = (
|
|
447
456
|
<TextInput
|
|
457
|
+
aria-haspopup="menu"
|
|
448
458
|
className={css(formStyles.formControl)}
|
|
449
459
|
id={`${randomId}-input`}
|
|
450
460
|
aria-label={ariaLabel}
|
|
@@ -453,8 +463,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
453
463
|
value={timeState || ''}
|
|
454
464
|
type="text"
|
|
455
465
|
iconVariant="clock"
|
|
456
|
-
onClick={this.
|
|
457
|
-
onFocus={this.onInputFocus}
|
|
466
|
+
onClick={this.onInputClick}
|
|
458
467
|
onChange={this.onInputChange}
|
|
459
468
|
onBlur={this.onBlur}
|
|
460
469
|
autoComplete="off"
|
|
@@ -465,14 +474,14 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
|
|
|
465
474
|
);
|
|
466
475
|
|
|
467
476
|
return (
|
|
468
|
-
<div className={css(datePickerStyles.datePicker, className)}>
|
|
477
|
+
<div ref={this.baseComponentRef} className={css(datePickerStyles.datePicker, className)}>
|
|
469
478
|
<div className={css(datePickerStyles.datePickerInput)} style={style} {...props}>
|
|
470
479
|
<InputGroup>
|
|
471
|
-
<div id={randomId}
|
|
480
|
+
<div id={randomId}>
|
|
472
481
|
<div ref={this.toggleRef} style={{ paddingLeft: '0' }}>
|
|
473
482
|
{menuAppendTo !== 'inline' ? (
|
|
474
483
|
<Popper
|
|
475
|
-
appendTo={
|
|
484
|
+
appendTo={menuAppendTo === 'parent' ? getParentElement() : menuAppendTo}
|
|
476
485
|
trigger={textInput}
|
|
477
486
|
popper={menuContainer}
|
|
478
487
|
isVisible={isOpen}
|
|
@@ -10,6 +10,8 @@ import { TimePicker } from '@patternfly/react-core';
|
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
13
|
+
Appending the TimePicker to the `document.body` may cause accessibility issues, including being unable to navigate into the menu via keyboard or other assistive technologies. Instead, appending to the `"parent"` is recommended.
|
|
14
|
+
|
|
13
15
|
### Basic 12 hour
|
|
14
16
|
|
|
15
17
|
```js
|