@patternfly/react-core 4.189.5 → 4.190.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.189.5",
3
+ "version": "4.190.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -34,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.40.5",
38
- "@patternfly/react-styles": "^4.39.5",
39
- "@patternfly/react-tokens": "^4.41.5",
37
+ "@patternfly/react-icons": "^4.41.0",
38
+ "@patternfly/react-styles": "^4.40.0",
39
+ "@patternfly/react-tokens": "^4.42.0",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "01c8b913108c70fcddb6ee6d7bdf523dffc620b7"
63
+ "gitHead": "e76b0322ba29c50bd1c4c86d4a24b2e032586e5a"
64
64
  }
@@ -17,7 +17,8 @@ import {
17
17
  pmSuffix,
18
18
  getHours,
19
19
  getMinutes,
20
- isWithinMinMax
20
+ isWithinMinMax,
21
+ getSeconds
21
22
  } from './TimePickerUtils';
22
23
 
23
24
  export interface TimePickerProps
@@ -41,7 +42,7 @@ export interface TimePickerProps
41
42
  /** True if the time is 24 hour time. False if the time is 12 hour time */
42
43
  is24Hour?: boolean;
43
44
  /** Optional event handler called each time the value in the time picker input changes. */
44
- onChange?: (time: string, hour?: number, minute?: number, isValid?: boolean) => void;
45
+ onChange?: (time: string, hour?: number, minute?: number, seconds?: number, isValid?: boolean) => void;
45
46
  /** Optional validator can be provided to override the internal time validator. */
46
47
  validateTime?: (time: string) => boolean;
47
48
  /** Id of the time picker */
@@ -61,10 +62,12 @@ export interface TimePickerProps
61
62
  stepMinutes?: number;
62
63
  /** Additional props for input field */
63
64
  inputProps?: TextInputProps;
64
- /** A time string indicating the minimum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
65
+ /** A time string indicating the minimum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
65
66
  minTime?: string | Date;
66
- /** A time string indicating the maximum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
67
+ /** A time string indicating the maximum value allowed. The format could be an ISO 8601 formatted date string or in 'HH{delimiter}MM' format */
67
68
  maxTime?: string | Date;
69
+ /** Includes number of seconds with the chosen time and allows users to manually edit the seconds value. */
70
+ includeSeconds?: boolean;
68
71
  }
69
72
 
70
73
  interface TimePickerState {
@@ -106,24 +109,26 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
106
109
 
107
110
  constructor(props: TimePickerProps) {
108
111
  super(props);
109
- const { is24Hour, delimiter, time } = this.props;
112
+ const { is24Hour, delimiter, time, includeSeconds } = this.props;
110
113
  let { minTime, maxTime } = this.props;
111
114
  if (minTime === '') {
112
- minTime = is24Hour ? `00${delimiter}00` : `12${delimiter}00AM`;
115
+ const minSeconds = includeSeconds ? `${delimiter}00` : '';
116
+ minTime = is24Hour ? `00${delimiter}00${minSeconds}` : `12${delimiter}00${minSeconds} AM`;
113
117
  }
114
118
  if (maxTime === '') {
115
- maxTime = is24Hour ? `23${delimiter}59` : `11${delimiter}59PM`;
119
+ const maxSeconds = includeSeconds ? `${delimiter}59` : '';
120
+ maxTime = is24Hour ? `23${delimiter}59${maxSeconds}` : `11${delimiter}59${maxSeconds} PM`;
116
121
  }
117
122
  const timeRegex = this.getRegExp();
118
123
  this.state = {
119
124
  isInvalid: false,
120
125
  isOpen: false,
121
- timeState: parseTime(time, timeRegex, delimiter, !is24Hour),
126
+ timeState: parseTime(time, timeRegex, delimiter, !is24Hour, includeSeconds),
122
127
  focusedIndex: null,
123
128
  scrollIndex: 0,
124
129
  timeRegex,
125
- minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour),
126
- maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour)
130
+ minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour, includeSeconds),
131
+ maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour, includeSeconds)
127
132
  };
128
133
  }
129
134
 
@@ -183,7 +188,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
183
188
 
184
189
  componentDidUpdate(prevProps: TimePickerProps, prevState: TimePickerState) {
185
190
  const { timeState, isOpen, isInvalid, timeRegex } = this.state;
186
- const { time, is24Hour, delimiter } = this.props;
191
+ const { time, is24Hour, delimiter, includeSeconds } = this.props;
187
192
  if (isOpen && !prevState.isOpen && timeState && !isInvalid) {
188
193
  this.scrollToSelection(timeState);
189
194
  }
@@ -194,7 +199,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
194
199
  }
195
200
  if (time !== '' && time !== prevProps.time) {
196
201
  this.setState({
197
- timeState: parseTime(time, timeRegex, delimiter, !is24Hour)
202
+ timeState: parseTime(time, timeRegex, delimiter, !is24Hour, includeSeconds)
198
203
  });
199
204
  }
200
205
  }
@@ -272,10 +277,16 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
272
277
  });
273
278
  };
274
279
 
275
- getRegExp = () =>
276
- this.props.is24Hour
277
- ? new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*$`)
278
- : new RegExp(`^\\s*(\\d\\d?)${this.props.delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
280
+ getRegExp = (includeSeconds: boolean = true) => {
281
+ const { is24Hour, delimiter } = this.props;
282
+ let baseRegex = `\\s*(\\d\\d?)${delimiter}([0-5]\\d)`;
283
+
284
+ if (includeSeconds) {
285
+ baseRegex += `${delimiter}?([0-5]\\d)?`;
286
+ }
287
+
288
+ return new RegExp(`^${baseRegex}${is24Hour ? '' : '\\s*([AaPp][Mm])?'}\\s*$`);
289
+ };
279
290
 
280
291
  getOptions = () =>
281
292
  (this.menuRef && this.menuRef.current ? Array.from(this.menuRef.current.children) : []) as HTMLElement[];
@@ -284,14 +295,16 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
284
295
  if (this.props.validateTime) {
285
296
  return this.props.validateTime(time);
286
297
  }
287
- const { delimiter, is24Hour } = this.props;
288
- return validateTime(time, this.state.timeRegex, delimiter, !is24Hour);
298
+
299
+ const { delimiter, is24Hour, includeSeconds } = this.props;
300
+ return validateTime(time, this.getRegExp(includeSeconds), delimiter, !is24Hour);
289
301
  };
290
302
 
291
303
  isValidTime = (time: string) => {
292
- const { delimiter } = this.props;
304
+ const { delimiter, includeSeconds } = this.props;
293
305
  const { minTimeState, maxTimeState } = this.state;
294
- return isWithinMinMax(minTimeState, maxTimeState, time, delimiter);
306
+
307
+ return isWithinMinMax(minTimeState, maxTimeState, time, delimiter, includeSeconds);
295
308
  };
296
309
 
297
310
  isValid = (time: string) => this.isValidFormat(time) && this.isValidTime(time);
@@ -300,8 +313,9 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
300
313
  // on close, parse and validate input
301
314
  this.setState(prevState => {
302
315
  const { timeRegex, isInvalid } = prevState;
303
- const { delimiter, is24Hour } = this.props;
304
- const time = parseTime(prevState.timeState, timeRegex, delimiter, !is24Hour);
316
+ const { delimiter, is24Hour, includeSeconds } = this.props;
317
+ const time = parseTime(prevState.timeState, timeRegex, delimiter, !is24Hour, includeSeconds);
318
+
305
319
  return {
306
320
  isOpen,
307
321
  timeState: time,
@@ -312,11 +326,13 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
312
326
 
313
327
  onSelect = (selection: string) => {
314
328
  const { timeRegex, timeState } = this.state;
315
- const { delimiter, is24Hour } = this.props;
316
- const time = parseTime(selection, timeRegex, delimiter, !is24Hour);
329
+ const { delimiter, is24Hour, includeSeconds } = this.props;
330
+ const time = parseTime(selection, timeRegex, delimiter, !is24Hour, includeSeconds);
331
+
317
332
  if (time !== timeState) {
318
333
  this.onInputChange(time);
319
334
  }
335
+
320
336
  this.setState({
321
337
  isOpen: false
322
338
  });
@@ -330,11 +346,15 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
330
346
  };
331
347
 
332
348
  onInputChange = (newTime: string) => {
333
- if (this.props.onChange) {
334
- this.props.onChange(
349
+ const { onChange } = this.props;
350
+ const { timeRegex } = this.state;
351
+
352
+ if (onChange) {
353
+ onChange(
335
354
  newTime,
336
- getHours(newTime, this.state.timeRegex),
337
- getMinutes(newTime, this.state.timeRegex),
355
+ getHours(newTime, timeRegex),
356
+ getMinutes(newTime, timeRegex),
357
+ getSeconds(newTime, timeRegex),
338
358
  this.isValid(newTime)
339
359
  );
340
360
  }
@@ -347,8 +367,9 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
347
367
 
348
368
  onBlur = (event: React.FocusEvent<HTMLInputElement>) => {
349
369
  const { timeRegex } = this.state;
350
- const { delimiter, is24Hour } = this.props;
351
- const time = parseTime(event.currentTarget.value, timeRegex, delimiter, !is24Hour);
370
+ const { delimiter, is24Hour, includeSeconds } = this.props;
371
+ const time = parseTime(event.currentTarget.value, timeRegex, delimiter, !is24Hour, includeSeconds);
372
+
352
373
  this.setState({
353
374
  isInvalid: !this.isValid(time)
354
375
  });
@@ -369,13 +390,15 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
369
390
  stepMinutes,
370
391
  width,
371
392
  delimiter,
393
+ inputProps,
372
394
  /* eslint-disable @typescript-eslint/no-unused-vars */
373
395
  onChange,
374
396
  time,
375
397
  validateTime,
376
- inputProps,
377
398
  minTime,
378
399
  maxTime,
400
+ includeSeconds,
401
+ /* eslint-enable @typescript-eslint/no-unused-vars */
379
402
  ...props
380
403
  } = this.props;
381
404
  const { timeState, isOpen, isInvalid, focusedIndex, minTimeState, maxTimeState } = this.state;
@@ -29,7 +29,7 @@ export const makeTimeOptions = (
29
29
  .getMinutes()
30
30
  .toString()
31
31
  .padStart(2, '0');
32
- const timeOption = hour + delimiter + minutes + (hour12 ? suffix : '');
32
+ const timeOption = `${hour}${delimiter}${minutes}${hour12 ? suffix : ''}`;
33
33
  // time option is valid if within min/max constraints
34
34
  if (isWithinMinMax(minTime, maxTime, timeOption, delimiter)) {
35
35
  res.push(timeOption);
@@ -39,7 +39,13 @@ export const makeTimeOptions = (
39
39
  return res;
40
40
  };
41
41
 
42
- export const parseTime = (time: string | Date, timeRegex: RegExp, delimiter: string, is12Hour: boolean): string => {
42
+ export const parseTime = (
43
+ time: string | Date,
44
+ timeRegex: RegExp,
45
+ delimiter: string,
46
+ is12Hour: boolean,
47
+ includeSeconds: boolean
48
+ ): string => {
43
49
  const date = new Date(time);
44
50
 
45
51
  // if default time is a ISO 8601 formatted date string, we parse it to hh:mm(am/pm) format
@@ -48,30 +54,40 @@ export const parseTime = (time: string | Date, timeRegex: RegExp, delimiter: str
48
54
  ? `${date.getHours() > 12 ? date.getHours() - 12 : date.getHours()}`
49
55
  : `${date.getHours()}`.padStart(2, '0');
50
56
  const minutes = `${date.getMinutes()}`.padStart(2, '0');
57
+ const seconds = includeSeconds ? `${date.getSeconds()}`.padStart(2, '0') : '';
58
+ const secondsWithDelimiter = seconds ? `${delimiter}${seconds}` : '';
51
59
  let ampm = '';
60
+
52
61
  if (is12Hour && date.getHours() > 11) {
53
62
  ampm = pmSuffix;
54
63
  } else if (is12Hour) {
55
64
  ampm = amSuffix;
56
65
  }
57
- return `${hours}${delimiter}${minutes}${ampm}`;
66
+
67
+ return `${hours}${delimiter}${minutes}${secondsWithDelimiter}${ampm}`;
58
68
  } else if (typeof time === 'string') {
59
69
  time = time.trim();
60
- if (is12Hour && time !== '' && validateTime(time, timeRegex, delimiter, is12Hour)) {
61
- const [, hours, minutes, suffix = ''] = timeRegex.exec(time);
62
- const uppercaseSuffix = suffix.toUpperCase();
63
- // Format AM/PM according to design
70
+ if (time !== '' && validateTime(time, timeRegex, delimiter, is12Hour)) {
71
+ const [, hours, minutes, seconds, suffix = ''] = timeRegex.exec(time);
72
+ const secondsWithDelimiter = includeSeconds ? `${delimiter}${seconds ?? '00'}` : '';
64
73
  let ampm = '';
65
- if (uppercaseSuffix === amSuffix.toUpperCase().trim()) {
66
- ampm = amSuffix;
67
- } else if (uppercaseSuffix === pmSuffix.toUpperCase().trim()) {
68
- ampm = pmSuffix;
69
- } else {
70
- // if this 12 hour time is missing am/pm but otherwise valid,
71
- // append am/pm depending on time of day
72
- ampm = new Date().getHours() > 11 ? pmSuffix : amSuffix;
74
+
75
+ // Format AM/PM according to design
76
+ if (is12Hour) {
77
+ const uppercaseSuffix = suffix.toUpperCase();
78
+
79
+ if (uppercaseSuffix === amSuffix.toUpperCase().trim()) {
80
+ ampm = amSuffix;
81
+ } else if (uppercaseSuffix === pmSuffix.toUpperCase().trim()) {
82
+ ampm = pmSuffix;
83
+ } else {
84
+ // if this 12 hour time is missing am/pm but otherwise valid,
85
+ // append am/pm depending on time of day
86
+ ampm = new Date().getHours() > 11 ? pmSuffix : amSuffix;
87
+ }
73
88
  }
74
- return `${hours}${delimiter}${minutes}${ampm}`;
89
+
90
+ return `${hours}${delimiter}${minutes}${secondsWithDelimiter}${ampm}`;
75
91
  }
76
92
  }
77
93
  return time.toString();
@@ -95,10 +111,10 @@ export const validateTime = (time: string, timeRegex: RegExp, delimiter: string,
95
111
  export const getHours = (time: string, timeRegex: RegExp) => {
96
112
  const parts = time.match(timeRegex);
97
113
  if (parts && parts.length) {
98
- if (/pm/i.test(parts[3])) {
114
+ if (/pm/i.test(parts[4])) {
99
115
  return parseInt(parts[1]) === 12 ? parseInt(parts[1]) : parseInt(parts[1]) + 12;
100
116
  }
101
- if (/am/i.test(parts[3])) {
117
+ if (/am/i.test(parts[4])) {
102
118
  return parseInt(parts[1]) === 12 ? 0 : parseInt(parts[1]);
103
119
  }
104
120
  return parseInt(parts[1]);
@@ -111,33 +127,54 @@ export const getMinutes = (time: string, timeRegex: RegExp) => {
111
127
  return parts && parts.length ? parseInt(parts[2]) : null;
112
128
  };
113
129
 
114
- export const isWithinMinMax = (minTime: string, maxTime: string, time: string, delimiter: string) => {
130
+ export const getSeconds = (time: string, timeRegex: RegExp) => {
131
+ const seconds = time.match(timeRegex)?.[3];
132
+
133
+ return seconds ? parseInt(seconds) : null;
134
+ };
135
+
136
+ export const isWithinMinMax = (
137
+ minTime: string,
138
+ maxTime: string,
139
+ time: string,
140
+ delimiter: string,
141
+ includeSeconds?: boolean
142
+ ) => {
115
143
  // do not throw error if empty string
116
144
  if (time.trim() === '') {
117
145
  return true;
118
146
  }
119
- const convertTo24Hour = (time: string): string => {
120
- const timeReg = new RegExp(`^\\s*(\\d\\d?)${delimiter}([0-5]\\d)\\s*([AaPp][Mm])?\\s*$`);
121
- const regMatches = timeReg.exec(time);
122
- if (!regMatches || !regMatches.length) {
123
- return;
124
- }
125
- let hours = regMatches[1].padStart(2, '0');
126
- const minutes = regMatches[2];
127
- const suffix = regMatches[3] || '';
128
- if (suffix.toUpperCase() === 'PM' && hours !== '12') {
129
- hours = `${parseInt(hours) + 12}`;
130
- } else if (suffix.toUpperCase() === 'AM' && hours === '12') {
131
- hours = '00';
132
- }
133
- return `${hours}${delimiter}${minutes}`;
134
- };
135
147
 
136
148
  // correctly format as 24hr times (12:30AM => 00:30, 1:15 => 01:15)
137
- minTime = convertTo24Hour(minTime);
138
- time = convertTo24Hour(time);
139
- maxTime = convertTo24Hour(maxTime);
149
+ const min24HourTime = convertTo24Hour(minTime, delimiter, includeSeconds);
150
+ const selected24HourTime = convertTo24Hour(time, delimiter, includeSeconds);
151
+ const max24HourTime = convertTo24Hour(maxTime, delimiter, includeSeconds);
140
152
 
141
153
  // simple string comparison for 24hr times
142
- return minTime <= time && time <= maxTime;
154
+ return min24HourTime <= selected24HourTime && selected24HourTime <= max24HourTime;
155
+ };
156
+
157
+ const convertTo24Hour = (time: string, delimiter: string, includeSeconds: boolean): string => {
158
+ const timeReg = new RegExp(`^\\s*(\\d\\d?)${delimiter}([0-5]\\d)${delimiter}?([0-5]\\d)?\\s*([AaPp][Mm])?\\s*$`);
159
+ const regMatches = timeReg.exec(time);
160
+ if (!regMatches || !regMatches.length) {
161
+ return;
162
+ }
163
+ let hours = regMatches[1].padStart(2, '0');
164
+ const minutes = regMatches[2];
165
+ let seconds = regMatches[3] ? `${delimiter}${regMatches[3]}` : '';
166
+
167
+ // When seconds is empty and 'includeSeconds' is enabled, append 0 seconds.
168
+ if (!seconds && includeSeconds) {
169
+ seconds = `${delimiter}00`;
170
+ }
171
+
172
+ const suffix = regMatches[4] || '';
173
+ if (suffix.toUpperCase() === 'PM' && hours !== '12') {
174
+ hours = `${parseInt(hours) + 12}`;
175
+ } else if (suffix.toUpperCase() === 'AM' && hours === '12') {
176
+ hours = '00';
177
+ }
178
+
179
+ return `${hours}${delimiter}${minutes}${seconds}`;
143
180
  };
@@ -4,42 +4,42 @@ import { act } from 'react-dom/test-utils';
4
4
  import { TimePicker } from '../TimePicker'
5
5
 
6
6
  describe('test timepicker onChange method with valid values', () => {
7
- const testOnChange = ({ input, expects }) => {
7
+ const testOnChange = ({ inputProps, expects }) => {
8
8
  const onChange = jest.fn();
9
9
 
10
10
  const event: any = {
11
- currentTarget: { value: input.value }
11
+ currentTarget: { value: inputProps.value }
12
12
  };
13
- const view = mount(<TimePicker onChange={onChange} value={input.value} is24Hour={input.is24Hour} aria-label="time picker" />);
14
-
13
+ const view = mount(<TimePicker onChange={onChange} {...inputProps} aria-label="time picker" />);
14
+
15
15
  act(() => {
16
16
  view.find('input').prop('onChange')(event);
17
17
  })
18
- expect(onChange).toBeCalledWith(input.value, expects.hour, expects.minutes, true);
18
+ expect(onChange).toBeCalledWith(inputProps.value, expects.hour, expects.minutes, expects.seconds, true);
19
19
  }
20
20
 
21
21
  test('should return the correct value using the AM/PM pattern - midnight', () => {
22
- testOnChange({ input: { value: "12:00 AM", is24Hour: false }, expects: { hour: 0, minutes: 0 }})
22
+ testOnChange({ inputProps: { value: "12:00 AM", is24Hour: false }, expects: { hour: 0, minutes: 0, seconds: null }})
23
23
  })
24
24
 
25
25
  test('should return the correct value using the AM/PM pattern - midday', () => {
26
- testOnChange({ input: { value: "12:35 PM", is24Hour: false }, expects: { hour: 12, minutes: 35 }})
26
+ testOnChange({ inputProps: { value: "12:35 PM", is24Hour: false }, expects: { hour: 12, minutes: 35, seconds: null }})
27
27
  })
28
28
 
29
29
  test('should return the correct value using the AM/PM pattern - last minute of the day', () => {
30
- testOnChange({ input: { value: "11:59 PM", is24Hour: false }, expects: { hour: 23, minutes: 59 }})
30
+ testOnChange({ inputProps: { value: "11:59 PM", is24Hour: false }, expects: { hour: 23, minutes: 59, seconds: null }})
31
31
  })
32
32
 
33
33
  test('should return the correct value using the 24h pattern - midnight', () => {
34
- testOnChange({ input: { value: "00:00", is24Hour: true }, expects: { hour: 0, minutes: 0 }})
34
+ testOnChange({ inputProps: { value: "00:00:00", is24Hour: true, includeSeconds: true }, expects: { hour: 0, minutes: 0, seconds: 0 }})
35
35
  })
36
36
 
37
37
  test('should return the correct value using the 24h pattern - midday', () => {
38
- testOnChange({ input: { value: "12:35", is24Hour: false }, expects: { hour: 12, minutes: 35 }})
38
+ testOnChange({ inputProps: { value: "12:35", is24Hour: false }, expects: { hour: 12, minutes: 35, seconds: null }})
39
39
  })
40
40
 
41
41
  test('should return the correct value using the 24h pattern - last minute of the day', () => {
42
- testOnChange({ input: { value: "23:59", is24Hour: true }, expects: { hour: 23, minutes: 59 }})
42
+ testOnChange({ inputProps: { value: "23:59", is24Hour: true }, expects: { hour: 23, minutes: 59, seconds: null }})
43
43
  })
44
44
  })
45
45
 
@@ -90,3 +90,41 @@ describe('test isInvalid', () => {
90
90
  expect(view.find('.pf-m-error')).toHaveLength(1);
91
91
  })
92
92
  })
93
+
94
+ describe('test includeSeconds', () => {
95
+ const baseProps = {
96
+ "aria-label": "time picker",
97
+ value: "12:00 PM",
98
+ includeSeconds: true
99
+ };
100
+
101
+ it('should be valid still with a max value of "11:59:59 PM" by default', () => {
102
+ const event: any = { currentTarget: { value: "11:59:59 PM" } };
103
+ const view = mount(<TimePicker {...baseProps} />);
104
+
105
+ act(() => view.find('input').prop('onChange')(event));
106
+ view.update();
107
+
108
+ expect(view.find('.pf-m-error')).toHaveLength(0);
109
+ });
110
+
111
+ it('should be valid still with a max value of "23:59:59" by default when using 24 hour time', () => {
112
+ const event: any = { currentTarget: { value: "23:59:59" } };
113
+ const view = mount(<TimePicker {...baseProps} value="20:00" is24Hour />);
114
+
115
+ act(() => view.find('input').prop('onChange')(event));
116
+ view.update();
117
+
118
+ expect(view.find('.pf-m-error')).toHaveLength(0);
119
+ });
120
+
121
+ it('should be invalid with a max value of "24:00:00" by default', () => {
122
+ const event: any = { currentTarget: { value: "24:00:00" } };
123
+ const view = mount(<TimePicker {...baseProps} value="20:00" is24Hour />);
124
+
125
+ act(() => view.find('input').prop('onChange')(event));
126
+ view.update();
127
+
128
+ expect(view.find('.pf-m-error')).toHaveLength(1);
129
+ });
130
+ });
@@ -15,13 +15,14 @@ import React from 'react';
15
15
  import { TimePicker } from '@patternfly/react-core';
16
16
 
17
17
  SimpleTimePicker = () => {
18
- const onChange = (time, hour, minute, isValid) => {
18
+ const onChange = (time, hour, minute, seconds, isValid) => {
19
19
  console.log("time", time);
20
20
  console.log("hour", hour);
21
21
  console.log("minute", minute);
22
+ console.log("seconds", seconds);
22
23
  console.log("isValid", isValid);
23
24
  };
24
-
25
+
25
26
  return <TimePicker time="3:35 AM" onChange={onChange}/>;
26
27
  }
27
28
  ```
@@ -52,3 +53,19 @@ import { TimePicker } from '@patternfly/react-core';
52
53
 
53
54
  <TimePicker is24Hour minTime="9:30" maxTime="17:15" placeholder="14:00"/>
54
55
  ```
56
+
57
+ ### With seconds
58
+ ```js
59
+ import React from 'react';
60
+ import { TimePicker } from '@patternfly/react-core';
61
+
62
+ SimpleTimePicker = () => <TimePicker time="3:35:20 PM" includeSeconds />;
63
+ ```
64
+
65
+ ### 24 hours with seconds
66
+ ```js
67
+ import React from 'react';
68
+ import { TimePicker } from '@patternfly/react-core';
69
+
70
+ SimpleTimePicker = () => <TimePicker time="12:35:50" includeSeconds is24Hour />;
71
+ ```