@patternfly/react-core 4.192.7 → 4.192.8

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/esm/components/Label/Label.d.ts.map +1 -1
  3. package/dist/esm/components/Label/Label.js +38 -25
  4. package/dist/esm/components/Label/Label.js.map +1 -1
  5. package/dist/esm/components/TimePicker/TimePicker.d.ts +4 -6
  6. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  7. package/dist/esm/components/TimePicker/TimePicker.js +74 -42
  8. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  9. package/dist/js/components/Label/Label.d.ts.map +1 -1
  10. package/dist/js/components/Label/Label.js +38 -25
  11. package/dist/js/components/Label/Label.js.map +1 -1
  12. package/dist/js/components/TimePicker/TimePicker.d.ts +4 -6
  13. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  14. package/dist/js/components/TimePicker/TimePicker.js +73 -41
  15. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  16. package/dist/umd/react-core.css +0 -104
  17. package/dist/umd/react-core.js +630 -607
  18. package/dist/umd/react-core.min.css +14 -118
  19. package/dist/umd/react-core.min.js +1 -1
  20. package/package.json +5 -5
  21. package/src/components/Alert/examples/AlertAsyncLiveRegion.tsx +1 -1
  22. package/src/components/ApplicationLauncher/examples/ApplicationLauncher.md +11 -577
  23. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignRight.tsx +32 -0
  24. package/src/components/ApplicationLauncher/examples/ApplicationLauncherAlignTop.tsx +31 -0
  25. package/src/components/ApplicationLauncher/examples/ApplicationLauncherBasic.tsx +23 -0
  26. package/src/components/ApplicationLauncher/examples/ApplicationLauncherCustomIcon.tsx +32 -0
  27. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDisabled.tsx +25 -0
  28. package/src/components/ApplicationLauncher/examples/ApplicationLauncherDocumentBody.tsx +31 -0
  29. package/src/components/ApplicationLauncher/examples/ApplicationLauncherFavoritesAndSearch.tsx +105 -0
  30. package/src/components/ApplicationLauncher/examples/ApplicationLauncherRouterLink.tsx +50 -0
  31. package/src/components/ApplicationLauncher/examples/ApplicationLauncherSectionsAndIcons.tsx +47 -0
  32. package/src/components/ApplicationLauncher/examples/ApplicationLauncherTooltip.tsx +35 -0
  33. package/src/components/Label/Label.tsx +58 -39
  34. package/src/components/Label/__tests__/Label.test.tsx +19 -1
  35. package/src/components/Label/__tests__/__snapshots__/Label.test.tsx.snap +109 -0
  36. package/src/components/Label/examples/Label.md +1 -41
  37. package/src/components/Label/examples/LabelEditable.tsx +57 -0
  38. package/src/components/TimePicker/TimePicker.tsx +112 -124
  39. package/src/components/TimePicker/examples/TimePicker.md +16 -10
@@ -1,5 +1,102 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
+ exports[`editable label 1`] = `
4
+ <Label
5
+ isEditable={true}
6
+ onClose={[MockFunction]}
7
+ onEditCancel={[MockFunction]}
8
+ onEditComplete={[MockFunction]}
9
+ >
10
+ <span
11
+ className="pf-c-label pf-m-editable"
12
+ >
13
+ <span
14
+ className="pf-c-label__content"
15
+ >
16
+ <button
17
+ className="pf-c-label__editable-text"
18
+ onClick={[Function]}
19
+ >
20
+ Something
21
+ </button>
22
+ </span>
23
+ <Button
24
+ aria-label="Close Something"
25
+ onClick={[MockFunction]}
26
+ type="button"
27
+ variant="plain"
28
+ >
29
+ <ButtonBase
30
+ aria-label="Close Something"
31
+ innerRef={null}
32
+ onClick={[MockFunction]}
33
+ type="button"
34
+ variant="plain"
35
+ >
36
+ <button
37
+ aria-disabled={false}
38
+ aria-label="Close Something"
39
+ className="pf-c-button pf-m-plain"
40
+ data-ouia-component-id="OUIA-Generated-Button-plain-1"
41
+ data-ouia-component-type="PF4/Button"
42
+ data-ouia-safe={true}
43
+ disabled={false}
44
+ onClick={[MockFunction]}
45
+ role={null}
46
+ type="button"
47
+ >
48
+ <TimesIcon
49
+ color="currentColor"
50
+ noVerticalAlign={false}
51
+ size="sm"
52
+ >
53
+ <svg
54
+ aria-hidden={true}
55
+ aria-labelledby={null}
56
+ fill="currentColor"
57
+ height="1em"
58
+ role="img"
59
+ style={
60
+ Object {
61
+ "verticalAlign": "-0.125em",
62
+ }
63
+ }
64
+ viewBox="0 0 352 512"
65
+ width="1em"
66
+ >
67
+ <path
68
+ d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
69
+ />
70
+ </svg>
71
+ </TimesIcon>
72
+ </button>
73
+ </ButtonBase>
74
+ </Button>
75
+ </span>
76
+ </Label>
77
+ `;
78
+
79
+ exports[`editable label 2`] = `
80
+ <Label
81
+ isEditable={true}
82
+ onClose={[MockFunction]}
83
+ onEditCancel={[MockFunction]}
84
+ onEditComplete={[MockFunction]}
85
+ >
86
+ <span
87
+ className="pf-c-label pf-m-editable pf-m-editable-active"
88
+ >
89
+ <input
90
+ className="pf-c-label__editable-text"
91
+ id="editable-input"
92
+ onChange={[Function]}
93
+ type="text"
94
+ value="Something"
95
+ />
96
+ </span>
97
+ </Label>
98
+ `;
99
+
3
100
  exports[`label 1`] = `
4
101
  <span
5
102
  className="pf-c-label"
@@ -24,6 +121,18 @@ exports[`label 2`] = `
24
121
  </span>
25
122
  `;
26
123
 
124
+ exports[`label 3`] = `
125
+ <span
126
+ className="pf-c-label pf-m-compact"
127
+ >
128
+ <span
129
+ className="pf-c-label__content"
130
+ >
131
+ Something
132
+ </span>
133
+ </span>
134
+ `;
135
+
27
136
  exports[`label with additional class name 1`] = `
28
137
  <span
29
138
  className="pf-c-label klass1"
@@ -386,45 +386,5 @@ Click or press either enter or space to begin editing a label. After editing, cl
386
386
 
387
387
  You can also customize any Label's close button aria-label as this example shows with `closeBtnAriaLabel`.
388
388
 
389
- ```js isBeta
390
- import React from 'react';
391
- import { Label } from '@patternfly/react-core';
392
-
393
- class EditableLabel extends React.Component {
394
- constructor(props) {
395
- super(props);
396
- this.state = {
397
- text: 'Editable label'
398
- };
399
- this.onEditCancel = prevText => {
400
- this.setState({
401
- text: prevText
402
- });
403
- };
404
- this.onEditComplete = newText => {
405
- this.setState({
406
- text: newText
407
- });
408
- };
409
- }
410
-
411
- render() {
412
- return (
413
- <Label
414
- color="blue"
415
- onClose={Function.prototype}
416
- closeBtnAriaLabel="Custom close button for editable label"
417
- onEditCancel={this.onEditCancel}
418
- onEditComplete={this.onEditComplete}
419
- isEditable
420
- editableProps={{
421
- 'aria-label': 'Editable text',
422
- id: 'editable-label'
423
- }}
424
- >
425
- {this.state.text}
426
- </Label>
427
- );
428
- }
429
- }
389
+ ```js file="LabelEditable.tsx" isBeta
430
390
  ```
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { Label } from '@patternfly/react-core';
3
+
4
+ export const LabelEditable: React.FunctionComponent = () => {
5
+ const [labelText, setLabelText] = React.useState('Editable label');
6
+ const [compactLabelText, setCompactLabelText] = React.useState('Compact editable label');
7
+
8
+ const onEditCancel = (prevText: string) => {
9
+ setLabelText(prevText);
10
+ };
11
+
12
+ const onEditComplete = (text: string) => {
13
+ setLabelText(text);
14
+ };
15
+
16
+ const onCompactEditCancel = (prevText: string) => {
17
+ setCompactLabelText(prevText);
18
+ };
19
+
20
+ const onCompactEditComplete = (text: string) => {
21
+ setCompactLabelText(text);
22
+ };
23
+
24
+ return (
25
+ <React.Fragment>
26
+ <Label
27
+ color="blue"
28
+ onClose={() => {}}
29
+ closeBtnAriaLabel="Custom close button for editable label"
30
+ onEditCancel={onEditCancel}
31
+ onEditComplete={onEditComplete}
32
+ isEditable
33
+ editableProps={{
34
+ 'aria-label': 'Editable text',
35
+ id: 'editable-label'
36
+ }}
37
+ >
38
+ {labelText}
39
+ </Label>
40
+ <Label
41
+ color="grey"
42
+ isCompact
43
+ onClose={() => {}}
44
+ closeBtnAriaLabel="Custom close button for compact editable label"
45
+ onEditCancel={onCompactEditCancel}
46
+ onEditComplete={onCompactEditComplete}
47
+ isEditable
48
+ editableProps={{
49
+ 'aria-label': 'Compact editable text',
50
+ id: 'compact-editable-label'
51
+ }}
52
+ >
53
+ {compactLabelText}
54
+ </Label>
55
+ </React.Fragment>
56
+ );
57
+ };
@@ -1,12 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
- import styles from '@patternfly/react-styles/css/components/Select/select';
4
3
  import datePickerStyles from '@patternfly/react-styles/css/components/DatePicker/date-picker';
5
4
  import formStyles from '@patternfly/react-styles/css/components/FormControl/form-control';
5
+ import menuStyles from '@patternfly/react-styles/css/components/Menu/menu';
6
6
  import { getUniqueId } from '../../helpers';
7
7
  import { Popper } from '../../helpers/Popper/Popper';
8
- import { TimeOption } from './TimeOption';
9
- import { KeyTypes, SelectDirection } from '../Select';
8
+ import { Menu, MenuContent, MenuList, MenuItem } from '../Menu';
9
+ import { KeyTypes } from '../Select';
10
10
  import { InputGroup } from '../InputGroup';
11
11
  import { TextInput, TextInputProps } from '../TextInput';
12
12
  import {
@@ -56,8 +56,6 @@ export interface TimePickerProps
56
56
  * menuAppendTo={document.getElementById('target')}
57
57
  */
58
58
  menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline';
59
- /** Flag specifying which direction the time picker menu expands */
60
- direction?: 'up' | 'down';
61
59
  /** Size of step between time options in minutes.*/
62
60
  stepMinutes?: number;
63
61
  /** Additional props for input field */
@@ -86,7 +84,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
86
84
  private parentRef = React.createRef<HTMLDivElement>();
87
85
  private toggleRef = React.createRef<HTMLDivElement>();
88
86
  private inputRef = React.createRef<HTMLInputElement>();
89
- private menuRef = React.createRef<HTMLUListElement>();
87
+ private menuRef = React.createRef<HTMLDivElement>();
90
88
 
91
89
  static defaultProps = {
92
90
  className: '',
@@ -98,9 +96,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
98
96
  placeholder: 'hh:mm',
99
97
  delimiter: ':',
100
98
  'aria-label': 'Time picker',
101
- menuAppendTo: 'inline',
102
- direction: 'down',
103
- width: 150,
99
+ width: '150px',
104
100
  stepMinutes: 30,
105
101
  inputProps: {},
106
102
  minTime: '',
@@ -145,44 +141,47 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
145
141
  }
146
142
 
147
143
  onDocClick = (event: MouseEvent | TouchEvent) => {
148
- const clickedOnToggle =
149
- this.parentRef && this.parentRef.current && this.parentRef.current.contains(event.target as Node);
150
- const clickedWithinMenu =
151
- this.menuRef &&
152
- this.menuRef.current &&
153
- this.menuRef.current.contains &&
154
- this.menuRef.current.contains(event.target as Node);
144
+ const clickedOnToggle = this.parentRef?.current?.contains(event.target as Node);
145
+ const clickedWithinMenu = this.menuRef?.current?.contains(event.target as Node);
155
146
  if (this.state.isOpen && !(clickedOnToggle || clickedWithinMenu)) {
156
147
  this.onToggle(false);
157
148
  }
158
149
  };
159
150
 
160
151
  handleGlobalKeys = (event: KeyboardEvent) => {
161
- const { isOpen, focusedIndex } = this.state;
152
+ const { isOpen, focusedIndex, scrollIndex } = this.state;
162
153
  // keyboard pressed while focus on toggle
163
- if (this.inputRef && this.inputRef.current && this.inputRef.current.contains(event.target as Node)) {
154
+ if (this.inputRef?.current?.contains(event.target as Node)) {
164
155
  if (!isOpen && event.key !== KeyTypes.Tab) {
165
156
  this.onToggle(true);
166
157
  } else if (isOpen) {
167
- if (event.key === KeyTypes.Escape) {
168
- this.onToggle(false);
169
- } else if (event.key === KeyTypes.Tab) {
158
+ if (event.key === KeyTypes.Escape || event.key === KeyTypes.Tab) {
170
159
  this.onToggle(false);
171
160
  } else if (event.key === KeyTypes.Enter) {
172
161
  if (focusedIndex !== null) {
173
- this.onSelect((this.getOptions()[focusedIndex] as HTMLElement).innerText);
162
+ this.focusSelection(focusedIndex);
174
163
  event.stopPropagation();
175
164
  } else {
176
165
  this.onToggle(false);
177
166
  }
178
- } else if (event.key === KeyTypes.ArrowDown) {
179
- this.updateFocusedIndex(1);
180
- event.preventDefault();
181
- } else if (event.key === KeyTypes.ArrowUp) {
182
- this.updateFocusedIndex(-1);
167
+ } else if (event.key === KeyTypes.ArrowDown || event.key === KeyTypes.ArrowUp) {
168
+ this.focusSelection(scrollIndex);
169
+ this.updateFocusedIndex(0);
183
170
  event.preventDefault();
184
171
  }
185
172
  }
173
+ // keyboard pressed while focus on menu item
174
+ } else if (this.menuRef?.current?.contains(event.target as Node)) {
175
+ if (event.key === KeyTypes.ArrowDown) {
176
+ this.updateFocusedIndex(1);
177
+ event.preventDefault();
178
+ } else if (event.key === KeyTypes.ArrowUp) {
179
+ this.updateFocusedIndex(-1);
180
+ event.preventDefault();
181
+ } else if (event.key === KeyTypes.Escape || event.key === KeyTypes.Tab) {
182
+ this.inputRef.current.focus();
183
+ this.onToggle(false);
184
+ }
186
185
  }
187
186
  };
188
187
 
@@ -207,7 +206,8 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
207
206
  updateFocusedIndex = (increment: number) => {
208
207
  this.setState(prevState => {
209
208
  const maxIndex = this.getOptions().length - 1;
210
- let nextIndex = prevState.focusedIndex !== null ? prevState.focusedIndex + increment : prevState.scrollIndex;
209
+ let nextIndex =
210
+ prevState.focusedIndex !== null ? prevState.focusedIndex + increment : prevState.scrollIndex + increment;
211
211
  if (nextIndex < 0) {
212
212
  nextIndex = maxIndex;
213
213
  } else if (nextIndex > maxIndex) {
@@ -220,8 +220,26 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
220
220
  });
221
221
  };
222
222
 
223
+ // fixes issue where menutAppendTo="inline" results in the menu item that should be scrolled to being out of view; this will select the menu item that comes before the intended one, causing that before-item to be placed out of view instead
224
+ getIndexToScroll = (index: number) => {
225
+ if (this.props.menuAppendTo === 'inline') {
226
+ return index > 0 ? index - 1 : 0;
227
+ }
228
+ return index;
229
+ };
230
+
223
231
  scrollToIndex = (index: number) => {
224
- this.getOptions()[index].offsetParent.scrollTop = this.getOptions()[index].offsetTop;
232
+ this.getOptions()[index].closest(`.${menuStyles.menuContent}`).scrollTop = this.getOptions()[
233
+ this.getIndexToScroll(index)
234
+ ].offsetTop;
235
+ };
236
+
237
+ focusSelection = (index: number) => {
238
+ const indexToFocus = index !== -1 ? index : 0;
239
+
240
+ if (this.menuRef?.current) {
241
+ (this.getOptions()[indexToFocus].querySelector(`.${menuStyles.menuItem}`) as HTMLElement).focus();
242
+ }
225
243
  };
226
244
 
227
245
  scrollToSelection = (time: string) => {
@@ -233,6 +251,10 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
233
251
  if (splitTime.length < 2) {
234
252
  time = `${time}${delimiter}00`;
235
253
  splitTime = time.split(delimiter);
254
+ // due to only the input including seconds when includeSeconds=true, we need to build a temporary time here without those seconds so that an exact or close match can be scrolled to within the menu (which does not include seconds in any of the options)
255
+ } else if (splitTime.length > 2) {
256
+ time = parseTime(time, this.state.timeRegex, delimiter, !is24Hour, false);
257
+ splitTime = time.split(delimiter);
236
258
  }
237
259
 
238
260
  // for 12hr variant, autoscroll to pm if it's currently the afternoon, otherwise autoscroll to am
@@ -248,7 +270,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
248
270
  ) {
249
271
  time = `${time}${new Date().getHours() > 11 ? pmSuffix : amSuffix}`;
250
272
  }
251
-
252
273
  let scrollIndex = this.getOptions().findIndex(option => option.innerText === time);
253
274
 
254
275
  // if we found an exact match, scroll to match and return index of match for focus
@@ -289,7 +310,9 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
289
310
  };
290
311
 
291
312
  getOptions = () =>
292
- (this.menuRef && this.menuRef.current ? Array.from(this.menuRef.current.children) : []) as HTMLElement[];
313
+ (this.menuRef?.current
314
+ ? Array.from(this.menuRef.current.querySelectorAll(`.${menuStyles.menuListItem}`))
315
+ : []) as HTMLElement[];
293
316
 
294
317
  isValidFormat = (time: string) => {
295
318
  if (this.props.validateTime) {
@@ -324,15 +347,15 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
324
347
  });
325
348
  };
326
349
 
327
- onSelect = (selection: string) => {
350
+ onSelect = (e: any) => {
328
351
  const { timeRegex, timeState } = this.state;
329
352
  const { delimiter, is24Hour, includeSeconds } = this.props;
330
- const time = parseTime(selection, timeRegex, delimiter, !is24Hour, includeSeconds);
331
-
353
+ const time = parseTime(e.target.textContent, timeRegex, delimiter, !is24Hour, includeSeconds);
332
354
  if (time !== timeState) {
333
355
  this.onInputChange(time);
334
356
  }
335
357
 
358
+ this.inputRef.current.focus();
336
359
  this.setState({
337
360
  isOpen: false
338
361
  });
@@ -386,7 +409,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
386
409
  is24Hour,
387
410
  invalidFormatErrorMessage,
388
411
  invalidMinMaxErrorMessage,
389
- direction,
390
412
  stepMinutes,
391
413
  width,
392
414
  delimiter,
@@ -401,107 +423,73 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
401
423
  /* eslint-enable @typescript-eslint/no-unused-vars */
402
424
  ...props
403
425
  } = this.props;
404
- const { timeState, isOpen, isInvalid, focusedIndex, minTimeState, maxTimeState } = this.state;
426
+ const { timeState, isOpen, isInvalid, minTimeState, maxTimeState } = this.state;
405
427
  const style = { '--pf-c-date-picker__input--c-form-control--Width': width } as React.CSSProperties;
406
428
  const options = makeTimeOptions(stepMinutes, !is24Hour, delimiter, minTimeState, maxTimeState);
407
429
  const isValidFormat = this.isValidFormat(timeState);
408
430
  const randomId = id || getUniqueId('time-picker');
409
431
 
410
432
  const menuContainer = (
411
- <ul
412
- ref={this.menuRef}
413
- className={css(styles.selectMenu)}
414
- role="listbox"
415
- aria-labelledby={`${id}-input`}
416
- style={{ maxHeight: '200px', overflowY: 'auto' }}
417
- >
418
- {options.map((option, index) => (
419
- <TimeOption
420
- key={index}
421
- value={option}
422
- index={index}
423
- onSelect={this.onSelect}
424
- isFocused={index === focusedIndex}
425
- id={`${id}-option-${index}`}
426
- />
427
- ))}
428
- </ul>
429
- );
430
-
431
- const inputAndToggle = (
432
- <div className={css(datePickerStyles.datePickerInput)} style={style} {...props}>
433
- <InputGroup>
434
- <div
435
- className={css(
436
- styles.select,
437
- isOpen && styles.modifiers.expanded,
438
- direction === SelectDirection.up && styles.modifiers.top,
439
- className
440
- )}
441
- id={randomId}
442
- ref={this.parentRef}
443
- >
444
- <div
445
- ref={this.toggleRef}
446
- className={css(styles.selectToggle, isDisabled && styles.modifiers.disabled, styles.modifiers.typeahead)}
447
- style={{ paddingLeft: '0' }}
448
- >
449
- <TextInput
450
- className={css(formStyles.formControl, styles.selectToggleTypeahead)}
451
- id={`${randomId}-input`}
452
- aria-label={ariaLabel}
453
- validated={isInvalid ? 'error' : 'default'}
454
- placeholder={placeholder}
455
- value={timeState || ''}
456
- type="text"
457
- iconVariant="clock"
458
- onClick={this.onInputFocus}
459
- onFocus={this.onInputFocus}
460
- onChange={this.onInputChange}
461
- onBlur={this.onBlur}
462
- autoComplete="off"
463
- isDisabled={isDisabled}
464
- ref={this.inputRef}
465
- {...inputProps}
466
- />
467
- </div>
468
- {isOpen && menuAppendTo === 'inline' && menuContainer}
469
- </div>
470
- </InputGroup>
471
- {isInvalid && (
472
- <div className={css(datePickerStyles.datePickerHelperText, datePickerStyles.modifiers.error)}>
473
- {!isValidFormat ? invalidFormatErrorMessage : invalidMinMaxErrorMessage}
474
- </div>
475
- )}
476
- </div>
433
+ <Menu ref={this.menuRef} isScrollable>
434
+ <MenuContent maxMenuHeight="200px">
435
+ <MenuList aria-labelledby={`${randomId}-input`}>
436
+ {options.map((option, index) => (
437
+ <MenuItem onClick={this.onSelect} key={option} id={`${randomId}-option-${index}`}>
438
+ {option}
439
+ </MenuItem>
440
+ ))}
441
+ </MenuList>
442
+ </MenuContent>
443
+ </Menu>
477
444
  );
478
445
 
479
- const popperContainer = (
480
- <div
481
- className={css(
482
- styles.select,
483
- isOpen && styles.modifiers.expanded,
484
- direction === SelectDirection.up && styles.modifiers.top,
485
- className
486
- )}
487
- >
488
- {isOpen && menuContainer}
489
- </div>
446
+ const textInput = (
447
+ <TextInput
448
+ className={css(formStyles.formControl)}
449
+ id={`${randomId}-input`}
450
+ aria-label={ariaLabel}
451
+ validated={isInvalid ? 'error' : 'default'}
452
+ placeholder={placeholder}
453
+ value={timeState || ''}
454
+ type="text"
455
+ iconVariant="clock"
456
+ onClick={this.onInputFocus}
457
+ onFocus={this.onInputFocus}
458
+ onChange={this.onInputChange}
459
+ onBlur={this.onBlur}
460
+ autoComplete="off"
461
+ isDisabled={isDisabled}
462
+ ref={this.inputRef}
463
+ {...inputProps}
464
+ />
490
465
  );
491
466
 
492
467
  return (
493
468
  <div className={css(datePickerStyles.datePicker, className)}>
494
- {menuAppendTo === 'inline' ? (
495
- inputAndToggle
496
- ) : (
497
- <Popper
498
- trigger={inputAndToggle}
499
- popper={popperContainer}
500
- direction={direction}
501
- appendTo={menuAppendTo}
502
- isVisible={isOpen}
503
- />
504
- )}
469
+ <div className={css(datePickerStyles.datePickerInput)} style={style} {...props}>
470
+ <InputGroup>
471
+ <div id={randomId} ref={this.parentRef}>
472
+ <div ref={this.toggleRef} style={{ paddingLeft: '0' }}>
473
+ {menuAppendTo !== 'inline' ? (
474
+ <Popper
475
+ appendTo={this.parentRef.current}
476
+ trigger={textInput}
477
+ popper={menuContainer}
478
+ isVisible={isOpen}
479
+ />
480
+ ) : (
481
+ textInput
482
+ )}
483
+ </div>
484
+ {isOpen && menuAppendTo === 'inline' && menuContainer}
485
+ </div>
486
+ </InputGroup>
487
+ {isInvalid && (
488
+ <div className={css(datePickerStyles.datePickerHelperText, datePickerStyles.modifiers.error)}>
489
+ {!isValidFormat ? invalidFormatErrorMessage : invalidMinMaxErrorMessage}
490
+ </div>
491
+ )}
492
+ </div>
505
493
  </div>
506
494
  );
507
495
  }
@@ -9,38 +9,42 @@ beta: true
9
9
  import { TimePicker } from '@patternfly/react-core';
10
10
 
11
11
  ## Examples
12
+
12
13
  ### Basic 12 hour
14
+
13
15
  ```js
14
16
  import React from 'react';
15
17
  import { TimePicker } from '@patternfly/react-core';
16
18
 
17
19
  SimpleTimePicker = () => {
18
20
  const onChange = (time, hour, minute, seconds, isValid) => {
19
- console.log("time", time);
20
- console.log("hour", hour);
21
- console.log("minute", minute);
22
- console.log("seconds", seconds);
23
- console.log("isValid", isValid);
21
+ console.log('time', time);
22
+ console.log('hour', hour);
23
+ console.log('minute', minute);
24
+ console.log('seconds', seconds);
25
+ console.log('isValid', isValid);
24
26
  };
25
27
 
26
- return <TimePicker time="3:35 AM" onChange={onChange}/>;
27
- }
28
+ return <TimePicker time="3:35 AM" onChange={onChange} />;
29
+ };
28
30
  ```
29
31
 
30
32
  ### Basic 24 hour
33
+
31
34
  ```js
32
35
  import React from 'react';
33
36
  import { TimePicker } from '@patternfly/react-core';
34
37
 
35
- <TimePicker time="2020-10-14T18:06:02Z" is24Hour />
38
+ <TimePicker time="2020-10-14T18:06:02Z" is24Hour />;
36
39
  ```
37
40
 
38
41
  ### Custom delimiter
42
+
39
43
  ```js
40
44
  import React from 'react';
41
45
  import { TimePicker } from '@patternfly/react-core';
42
46
 
43
- <TimePicker is24Hour delimiter="h" placeholder=""/>
47
+ <TimePicker is24Hour delimiter="h" placeholder="" />;
44
48
  ```
45
49
 
46
50
  ### Minimum/maximum times
@@ -51,10 +55,11 @@ The `minTime`/`maxTime` props restrict the options shown for the user to select
51
55
  import React from 'react';
52
56
  import { TimePicker } from '@patternfly/react-core';
53
57
 
54
- <TimePicker is24Hour minTime="9:30" maxTime="17:15" placeholder="14:00"/>
58
+ <TimePicker is24Hour minTime="9:30" maxTime="17:15" placeholder="14:00" />;
55
59
  ```
56
60
 
57
61
  ### With seconds
62
+
58
63
  ```js
59
64
  import React from 'react';
60
65
  import { TimePicker } from '@patternfly/react-core';
@@ -63,6 +68,7 @@ SimpleTimePicker = () => <TimePicker time="3:35:20 PM" includeSeconds />;
63
68
  ```
64
69
 
65
70
  ### 24 hours with seconds
71
+
66
72
  ```js
67
73
  import React from 'react';
68
74
  import { TimePicker } from '@patternfly/react-core';