@patternfly/react-core 4.226.1 → 4.226.2
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 +8 -0
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts +3 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/esm/components/CalendarMonth/CalendarMonth.js +9 -6
- package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/esm/components/Wizard/Wizard.d.ts +1 -0
- package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/esm/components/Wizard/Wizard.js +5 -0
- package/dist/esm/components/Wizard/Wizard.js.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts +3 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
- package/dist/js/components/CalendarMonth/CalendarMonth.js +9 -6
- package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
- package/dist/js/components/Wizard/Wizard.d.ts +1 -0
- package/dist/js/components/Wizard/Wizard.d.ts.map +1 -1
- package/dist/js/components/Wizard/Wizard.js +5 -0
- package/dist/js/components/Wizard/Wizard.js.map +1 -1
- package/dist/umd/react-core.css +4 -3
- package/dist/umd/react-core.js +14 -6
- package/dist/umd/react-core.min.css +4 -3
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/CalendarMonth/CalendarMonth.tsx +22 -5
- package/src/components/CalendarMonth/examples/CalendarMonth.md +0 -5
- package/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx +6 -1
- package/src/components/Pagination/examples/Pagination.md +14 -14
- package/src/components/Toolbar/examples/Toolbar.md +2 -2
- package/src/components/Wizard/Wizard.tsx +6 -0
- package/src/components/Wizard/__tests__/Wizard.test.tsx +31 -0
- package/src/components/CalendarMonth/examples/CalendarMonthDefault.tsx +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.226.
|
|
3
|
+
"version": "4.226.2",
|
|
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,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.77.
|
|
38
|
-
"@patternfly/react-styles": "^4.76.
|
|
39
|
-
"@patternfly/react-tokens": "^4.78.
|
|
37
|
+
"@patternfly/react-icons": "^4.77.2",
|
|
38
|
+
"@patternfly/react-styles": "^4.76.2",
|
|
39
|
+
"@patternfly/react-tokens": "^4.78.2",
|
|
40
40
|
"focus-trap": "6.9.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.204.
|
|
46
|
+
"@patternfly/patternfly": "4.204.3",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -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": "
|
|
63
|
+
"gitHead": "fb67d6b2dfbfd2b4080e1313101f4d663a0a09c3"
|
|
64
64
|
}
|
|
@@ -57,6 +57,11 @@ export interface CalendarProps extends CalendarFormat, Omit<React.HTMLProps<HTML
|
|
|
57
57
|
onSelectToggle?: (open: boolean) => void;
|
|
58
58
|
/** Flag to set browser focus on the passed date **/
|
|
59
59
|
isDateFocused?: boolean;
|
|
60
|
+
/** Callback when month or year is changed */
|
|
61
|
+
onMonthChange?: (
|
|
62
|
+
newDate?: Date,
|
|
63
|
+
event?: React.MouseEvent | React.ChangeEvent | React.FormEvent<HTMLInputElement>
|
|
64
|
+
) => void;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
// Must be numeric given current header design
|
|
@@ -114,6 +119,7 @@ export const CalendarMonth = ({
|
|
|
114
119
|
validators = [() => true],
|
|
115
120
|
className,
|
|
116
121
|
onSelectToggle = () => {},
|
|
122
|
+
onMonthChange = () => {},
|
|
117
123
|
rangeStart,
|
|
118
124
|
prevMonthAriaLabel = 'Previous month',
|
|
119
125
|
nextMonthAriaLabel = 'Next month',
|
|
@@ -162,10 +168,11 @@ export const CalendarMonth = ({
|
|
|
162
168
|
}
|
|
163
169
|
}, [focusedDate, isDateFocused, focusedDateValidated, focusRef]);
|
|
164
170
|
|
|
165
|
-
const onMonthClick = (newDate: Date) => {
|
|
171
|
+
const onMonthClick = (newDate: Date, ev: React.MouseEvent) => {
|
|
166
172
|
setFocusedDate(newDate);
|
|
167
173
|
setHoveredDate(newDate);
|
|
168
174
|
setShouldFocus(false);
|
|
175
|
+
onMonthChange(newDate, ev);
|
|
169
176
|
};
|
|
170
177
|
|
|
171
178
|
const onKeyDown = (ev: React.KeyboardEvent<HTMLTableSectionElement>) => {
|
|
@@ -222,7 +229,11 @@ export const CalendarMonth = ({
|
|
|
222
229
|
<div className={css(styles.calendarMonth, className)} {...props}>
|
|
223
230
|
<div className={styles.calendarMonthHeader}>
|
|
224
231
|
<div className={css(styles.calendarMonthHeaderNavControl, styles.modifiers.prevMonth)}>
|
|
225
|
-
<Button
|
|
232
|
+
<Button
|
|
233
|
+
variant="plain"
|
|
234
|
+
aria-label={prevMonthAriaLabel}
|
|
235
|
+
onClick={(ev: React.MouseEvent) => onMonthClick(prevMonth, ev)}
|
|
236
|
+
>
|
|
226
237
|
<AngleLeftIcon aria-hidden={true} />
|
|
227
238
|
</Button>
|
|
228
239
|
</div>
|
|
@@ -240,7 +251,7 @@ export const CalendarMonth = ({
|
|
|
240
251
|
setIsSelectOpen(!isSelectOpen);
|
|
241
252
|
onSelectToggle(!isSelectOpen);
|
|
242
253
|
}}
|
|
243
|
-
onSelect={(
|
|
254
|
+
onSelect={(ev, monthNum) => {
|
|
244
255
|
// When we put CalendarMonth in a Popover we want the Popover's onDocumentClick
|
|
245
256
|
// to see the SelectOption as a child so it doesn't close the Popover.
|
|
246
257
|
setTimeout(() => {
|
|
@@ -251,6 +262,7 @@ export const CalendarMonth = ({
|
|
|
251
262
|
setFocusedDate(newDate);
|
|
252
263
|
setHoveredDate(newDate);
|
|
253
264
|
setShouldFocus(false);
|
|
265
|
+
onMonthChange(newDate, ev);
|
|
254
266
|
}, 0);
|
|
255
267
|
}}
|
|
256
268
|
variant="single"
|
|
@@ -268,18 +280,23 @@ export const CalendarMonth = ({
|
|
|
268
280
|
aria-label={yearInputAriaLabel}
|
|
269
281
|
type="number"
|
|
270
282
|
value={yearFormatted}
|
|
271
|
-
onChange={year => {
|
|
283
|
+
onChange={(year: string, ev: React.FormEvent<HTMLInputElement>) => {
|
|
272
284
|
const newDate = new Date(focusedDate);
|
|
273
285
|
newDate.setFullYear(+year);
|
|
274
286
|
setFocusedDate(newDate);
|
|
275
287
|
setHoveredDate(newDate);
|
|
276
288
|
setShouldFocus(false);
|
|
289
|
+
onMonthChange(newDate, ev);
|
|
277
290
|
}}
|
|
278
291
|
/>
|
|
279
292
|
</div>
|
|
280
293
|
</InputGroup>
|
|
281
294
|
<div className={css(styles.calendarMonthHeaderNavControl, styles.modifiers.nextMonth)}>
|
|
282
|
-
<Button
|
|
295
|
+
<Button
|
|
296
|
+
variant="plain"
|
|
297
|
+
aria-label={nextMonthAriaLabel}
|
|
298
|
+
onClick={(ev: React.MouseEvent) => onMonthClick(nextMonth, ev)}
|
|
299
|
+
>
|
|
283
300
|
<AngleRightIcon aria-hidden={true} />
|
|
284
301
|
</Button>
|
|
285
302
|
</div>
|
|
@@ -4,10 +4,15 @@ import { CalendarMonth } from '@patternfly/react-core';
|
|
|
4
4
|
export const CalendarMonthSelectableDate: React.FunctionComponent = () => {
|
|
5
5
|
const [date, setDate] = React.useState(new Date(2020, 10, 24));
|
|
6
6
|
|
|
7
|
+
const onMonthChange = (newDate: Date) => {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.log(`updated month: ${newDate.getMonth()}, updated year: ${newDate.getFullYear()}`);
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
return (
|
|
8
13
|
<React.Fragment>
|
|
9
14
|
<pre>Selected date: {date.toString()}</pre>
|
|
10
|
-
<CalendarMonth date={date} onChange={setDate} />
|
|
15
|
+
<CalendarMonth date={date} onChange={setDate} onMonthChange={onMonthChange} />
|
|
11
16
|
</React.Fragment>
|
|
12
17
|
);
|
|
13
18
|
};
|
|
@@ -28,9 +28,9 @@ class PaginationTop extends React.Component {
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
31
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
32
32
|
this.setState({
|
|
33
|
-
perPage
|
|
33
|
+
page, perPage
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
}
|
|
@@ -68,9 +68,9 @@ class PaginationBottom extends React.Component {
|
|
|
68
68
|
page: pageNumber
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
71
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
72
72
|
this.setState({
|
|
73
|
-
perPage
|
|
73
|
+
page, perPage
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
}
|
|
@@ -149,9 +149,9 @@ class PaginationDisabled extends React.Component {
|
|
|
149
149
|
});
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
152
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
153
153
|
this.setState({
|
|
154
|
-
perPage
|
|
154
|
+
page, perPage
|
|
155
155
|
});
|
|
156
156
|
};
|
|
157
157
|
}
|
|
@@ -193,9 +193,9 @@ class PaginationTop extends React.Component {
|
|
|
193
193
|
});
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
196
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
197
197
|
this.setState({
|
|
198
|
-
perPage
|
|
198
|
+
page, perPage
|
|
199
199
|
});
|
|
200
200
|
};
|
|
201
201
|
}
|
|
@@ -236,9 +236,9 @@ class PaginationTop extends React.Component {
|
|
|
236
236
|
});
|
|
237
237
|
};
|
|
238
238
|
|
|
239
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
239
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
240
240
|
this.setState({
|
|
241
|
-
perPage
|
|
241
|
+
page, perPage
|
|
242
242
|
});
|
|
243
243
|
};
|
|
244
244
|
}
|
|
@@ -279,9 +279,9 @@ class PaginationTop extends React.Component {
|
|
|
279
279
|
});
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
282
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
283
283
|
this.setState({
|
|
284
|
-
perPage
|
|
284
|
+
page, perPage
|
|
285
285
|
});
|
|
286
286
|
};
|
|
287
287
|
}
|
|
@@ -330,9 +330,9 @@ class PaginationSticky extends React.Component {
|
|
|
330
330
|
});
|
|
331
331
|
};
|
|
332
332
|
|
|
333
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
333
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
334
334
|
this.setState({
|
|
335
|
-
perPage
|
|
335
|
+
page, perPage
|
|
336
336
|
});
|
|
337
337
|
};
|
|
338
338
|
}
|
|
@@ -1169,9 +1169,9 @@ class ToolbarStacked extends React.Component {
|
|
|
1169
1169
|
});
|
|
1170
1170
|
};
|
|
1171
1171
|
|
|
1172
|
-
this.onPerPageSelect = (_event, perPage) => {
|
|
1172
|
+
this.onPerPageSelect = (_event, perPage, page) => {
|
|
1173
1173
|
this.setState({
|
|
1174
|
-
perPage
|
|
1174
|
+
page, perPage
|
|
1175
1175
|
});
|
|
1176
1176
|
};
|
|
1177
1177
|
|
|
@@ -367,6 +367,12 @@ export class Wizard extends React.Component<WizardProps, WizardState> {
|
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
componentDidUpdate(prevProps: Readonly<WizardProps>) {
|
|
371
|
+
if (prevProps.startAtStep !== this.props.startAtStep) {
|
|
372
|
+
this.setState({ currentStep: this.props.startAtStep });
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
370
376
|
render() {
|
|
371
377
|
const {
|
|
372
378
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
@@ -342,3 +342,34 @@ describe('Wizard', () => {
|
|
|
342
342
|
|
|
343
343
|
expect(screen.getByRole('button',{ name: "A-2" })).toBeDisabled();
|
|
344
344
|
});
|
|
345
|
+
|
|
346
|
+
test('startAtStep can be used to externally control the current step of the wizard', () => {
|
|
347
|
+
const WizardTest = () => {
|
|
348
|
+
const [step, setStep] = React.useState(1);
|
|
349
|
+
|
|
350
|
+
const incrementStep = () => {
|
|
351
|
+
setStep(prevStep => prevStep + 1);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const steps: WizardStep[] = [
|
|
355
|
+
{ name: 'A', component: <p>Step 1</p> },
|
|
356
|
+
{ name: 'B', component: <p>Step 2</p> },
|
|
357
|
+
{ name: 'C', component: <p>Step 3</p> }
|
|
358
|
+
];
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<>
|
|
362
|
+
<Wizard steps={steps} startAtStep={step} />
|
|
363
|
+
<button onClick={() => incrementStep()}>Increment step</button>
|
|
364
|
+
</>
|
|
365
|
+
);
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
render(<WizardTest />);
|
|
369
|
+
|
|
370
|
+
expect(screen.queryByText('Step 2')).not.toBeInTheDocument();
|
|
371
|
+
|
|
372
|
+
userEvent.click(screen.getByRole('button', { name: 'Increment step'}))
|
|
373
|
+
|
|
374
|
+
expect(screen.getByText('Step 2')).toBeVisible();
|
|
375
|
+
});
|