@patternfly/react-core 4.258.5 → 4.258.7

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.258.5",
3
+ "version": "4.258.7",
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",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "bc0ffb995ba53ffe29765ddc745f88c57806ad64"
73
+ "gitHead": "69c78cfc668577eb1b005710b0c77522cbabe9c6"
74
74
  }
@@ -14,10 +14,10 @@ export const LabelCompact: React.FunctionComponent = () => (
14
14
  <Label isCompact icon={<InfoCircleIcon />} onClose={() => Function.prototype}>
15
15
  Compact icon removable
16
16
  </Label>{' '}
17
- <Label isCompact href="#outline">
17
+ <Label isCompact href="#compact">
18
18
  Compact link
19
19
  </Label>{' '}
20
- <Label isCompact href="#outline" onClose={() => Function.prototype}>
20
+ <Label isCompact href="#compact" onClose={() => Function.prototype}>
21
21
  Compact link removable
22
22
  </Label>
23
23
  <Label isCompact icon={<InfoCircleIcon />} onClose={() => Function.prototype} isTruncated>
@@ -143,6 +143,8 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
143
143
  document.addEventListener('mousedown', this.onDocClick);
144
144
  document.addEventListener('touchstart', this.onDocClick);
145
145
  document.addEventListener('keydown', this.handleGlobalKeys);
146
+
147
+ this.setState({ isInvalid: !this.isValid(this.state.timeState) });
146
148
  }
147
149
 
148
150
  componentWillUnmount() {
@@ -198,7 +200,7 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
198
200
 
199
201
  componentDidUpdate(prevProps: TimePickerProps, prevState: TimePickerState) {
200
202
  const { timeState, isTimeOptionsOpen, isInvalid, timeRegex } = this.state;
201
- const { time, is24Hour, delimiter, includeSeconds, isOpen } = this.props;
203
+ const { time, is24Hour, delimiter, includeSeconds, isOpen, minTime, maxTime } = this.props;
202
204
  if (prevProps.isOpen !== isOpen) {
203
205
  this.onToggle(isOpen);
204
206
  }
@@ -212,8 +214,22 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
212
214
  });
213
215
  }
214
216
  if (time !== '' && time !== prevProps.time) {
217
+ const parsedTime = parseTime(time, timeRegex, delimiter, !is24Hour, includeSeconds);
218
+
219
+ this.setState({
220
+ timeState: parsedTime,
221
+ isInvalid: !this.isValid(parsedTime)
222
+ });
223
+ }
224
+ if (minTime !== '' && minTime !== prevProps.minTime) {
225
+ this.setState({
226
+ minTimeState: parseTime(minTime, timeRegex, delimiter, !is24Hour, includeSeconds)
227
+ });
228
+ }
229
+
230
+ if (maxTime !== '' && maxTime !== prevProps.maxTime) {
215
231
  this.setState({
216
- timeState: parseTime(time, timeRegex, delimiter, !is24Hour, includeSeconds)
232
+ maxTimeState: parseTime(maxTime, timeRegex, delimiter, !is24Hour, includeSeconds)
217
233
  });
218
234
  }
219
235
  }
@@ -107,24 +107,27 @@ describe('TimePicker', () => {
107
107
  });
108
108
 
109
109
  test('should be invalid after onBlur', async () => {
110
- const validateTime = (_time: string) => {
111
- return false;
112
- };
113
110
  const user = userEvent.setup();
114
111
 
115
112
  render(
116
113
  <>
117
114
  <div>Other element</div>
118
- <TimePicker value={'00:00'} validateTime={validateTime} aria-label="time picker" />
115
+ <TimePicker value={'00:00'} aria-label="time picker" />
119
116
  </>
120
117
  );
121
118
 
122
- await user.type(screen.getByLabelText('time picker'), '01:00');
119
+ await user.type(screen.getByLabelText('time picker'), '14:00');
123
120
  expect(screen.queryByText('Invalid time format')).toBeNull();
124
121
 
125
122
  await user.click(screen.getByText('Other element'));
126
123
  expect(screen.getByText('Invalid time format')).toBeInTheDocument();
127
124
  });
125
+
126
+ test('should be invalid when invalid time prop is passed', () => {
127
+ render(<TimePicker time="00:00" aria-label="time picker" />);
128
+
129
+ expect(screen.getByText('Invalid time format')).toBeInTheDocument();
130
+ });
128
131
  });
129
132
 
130
133
  describe('test includeSeconds', () => {