@patternfly/react-core 4.267.3 → 4.267.5

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 (30) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts +14 -1
  3. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  4. package/dist/esm/components/CalendarMonth/CalendarMonth.js +10 -2
  5. package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
  6. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts +14 -1
  7. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  8. package/dist/js/components/CalendarMonth/CalendarMonth.js +10 -2
  9. package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
  10. package/dist/umd/react-core.min.js +1 -1
  11. package/package.json +2 -2
  12. package/src/components/CalendarMonth/CalendarMonth.tsx +26 -1
  13. package/src/components/CalendarMonth/__tests__/CalendarMonth.test.tsx +9 -0
  14. package/src/components/CalendarMonth/examples/CalendarMonth.md +1 -1
  15. package/src/components/CalendarMonth/examples/CalendarMonthDateRange.tsx +19 -2
  16. package/src/components/CalendarMonth/examples/CalendarMonthSelectableDate.tsx +14 -4
  17. package/src/components/Wizard/examples/Wizard.md +14 -691
  18. package/src/components/Wizard/examples/WizardAnchorsForNavItems.tsx +42 -0
  19. package/src/components/Wizard/examples/WizardBasic.tsx +14 -0
  20. package/src/components/Wizard/examples/WizardBasicWithDisabledSteps.tsx +14 -0
  21. package/src/components/Wizard/examples/WizardEnabledOnFormValidation.tsx +139 -0
  22. package/src/components/Wizard/examples/WizardExpandableSteps.tsx +34 -0
  23. package/src/components/Wizard/examples/WizardFinished.tsx +90 -0
  24. package/src/components/Wizard/examples/WizardGetCurrentStep.tsx +33 -0
  25. package/src/components/Wizard/examples/WizardInModal.tsx +32 -0
  26. package/src/components/Wizard/examples/WizardIncrementallyEnabledSteps.tsx +61 -0
  27. package/src/components/Wizard/examples/WizardValidateOnButtonPress.tsx +204 -0
  28. package/src/components/Wizard/examples/WizardWithDrawer.tsx +126 -0
  29. package/src/components/Wizard/examples/FinishedStep.js +0 -70
  30. package/src/components/Wizard/examples/SampleForm.js +0 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.267.3",
3
+ "version": "4.267.5",
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",
@@ -77,5 +77,5 @@
77
77
  "react": "^16.8 || ^17 || ^18",
78
78
  "react-dom": "^16.8 || ^17 || ^18"
79
79
  },
80
- "gitHead": "2f30f0c83a0077a70180472f74d6825f6db023b2"
80
+ "gitHead": "caf893d71966a0eabcde909a29d9a872367d9897"
81
81
  }
@@ -20,6 +20,15 @@ export enum Weekday {
20
20
  Saturday
21
21
  }
22
22
 
23
+ export interface CalendarMonthInlineProps {
24
+ /** Component wrapping the calendar month when used inline. Recommended to be 'article'. */
25
+ component?: keyof JSX.IntrinsicElements;
26
+ /** Title of the calendar rendered above the inline calendar month. Recommended to be a 'title' component. */
27
+ title?: React.ReactNode;
28
+ /** Id of the accessible label of the calendar month. Recommended to map to the title. */
29
+ ariaLabelledby?: string;
30
+ }
31
+
23
32
  /** Additional properties that extend from and can be passed to the main component. These
24
33
  * properties allow customizing the calendar formatting and aria-labels.
25
34
  */
@@ -49,6 +58,8 @@ export interface CalendarFormat {
49
58
  weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | Weekday;
50
59
  /** Accessible label for the year input. */
51
60
  yearInputAriaLabel?: string;
61
+ /** Props used to ensure accessibility when displaying the calendar month inline. */
62
+ inlineProps?: CalendarMonthInlineProps;
52
63
  }
53
64
 
54
65
  export interface CalendarProps extends CalendarFormat, Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {
@@ -133,6 +144,7 @@ export const CalendarMonth = ({
133
144
  yearInputAriaLabel = 'Select year',
134
145
  cellAriaLabel,
135
146
  isDateFocused = false,
147
+ inlineProps,
136
148
  ...props
137
149
  }: CalendarProps) => {
138
150
  const longMonths = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(monthNum => new Date(1990, monthNum)).map(monthFormat);
@@ -232,7 +244,8 @@ export const CalendarMonth = ({
232
244
  const isHoveredDateValid = isValidated(hoveredDate);
233
245
  const monthFormatted = monthFormat(focusedDate);
234
246
  const yearFormatted = yearFormat(focusedDate);
235
- return (
247
+
248
+ const calendarToRender = (
236
249
  <div className={css(styles.calendarMonth, className)} {...props}>
237
250
  <div className={styles.calendarMonthHeader}>
238
251
  <div className={css(styles.calendarMonthHeaderNavControl, styles.modifiers.prevMonth)}>
@@ -386,4 +399,16 @@ export const CalendarMonth = ({
386
399
  </table>
387
400
  </div>
388
401
  );
402
+
403
+ if (inlineProps !== undefined) {
404
+ const Component = (inlineProps.component ? inlineProps.component : 'article') as any;
405
+ return (
406
+ <Component {...(inlineProps.ariaLabelledby && { 'aria-labelledby': inlineProps.ariaLabelledby })}>
407
+ {inlineProps.title}
408
+ {calendarToRender}
409
+ </Component>
410
+ );
411
+ }
412
+ return calendarToRender;
389
413
  };
414
+ CalendarMonth.displayName = 'CalendarMonth';
@@ -55,3 +55,12 @@ test('Next year dates have correct year in aria label', () => {
55
55
  const nextYearDate = screen.getByRole('button', { name: '1 January 2025' });
56
56
  expect(nextYearDate).toBeVisible();
57
57
  });
58
+
59
+ test('InlineProps render correct wrapper component and attributes', () => {
60
+ render(<CalendarMonth inlineProps={{component: 'article', title: <div id="hi">Title</div>, ariaLabelledby: "hi"}} />);
61
+
62
+ const article = screen.getByRole('article');
63
+ expect(article).toHaveAttribute('aria-labelledby', 'hi');
64
+ const title = screen.getByText('Title');
65
+ expect(title).toBeVisible();
66
+ });
@@ -2,7 +2,7 @@
2
2
  id: Calendar month
3
3
  section: components
4
4
  cssPrefix: pf-c-calendar-month
5
- propComponents: ['CalendarMonth', 'CalendarFormat']
5
+ propComponents: ['CalendarMonth', 'CalendarFormat', 'CalendarMonthInlineProps']
6
6
  ---
7
7
 
8
8
  ## Examples
@@ -1,10 +1,27 @@
1
1
  import React from 'react';
2
- import { CalendarMonth } from '@patternfly/react-core';
2
+ import { CalendarMonth, Title, CalendarMonthInlineProps } from '@patternfly/react-core';
3
3
 
4
4
  export const CalendarMonthDateRange: React.FunctionComponent = () => {
5
5
  const startDate = new Date(2020, 10, 11);
6
6
  const endDate = new Date(2020, 10, 24);
7
7
  const disablePreStartDates = (date: Date) => date >= startDate;
8
8
 
9
- return <CalendarMonth validators={[disablePreStartDates]} date={endDate} rangeStart={startDate} />;
9
+ const inlineProps: CalendarMonthInlineProps = {
10
+ component: 'article',
11
+ title: (
12
+ <Title id="display-range" headingLevel="h4">
13
+ Calendar month displaying a range
14
+ </Title>
15
+ ),
16
+ ariaLabelledby: 'display-range'
17
+ };
18
+
19
+ return (
20
+ <CalendarMonth
21
+ validators={[disablePreStartDates]}
22
+ date={endDate}
23
+ rangeStart={startDate}
24
+ inlineProps={inlineProps}
25
+ />
26
+ );
10
27
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { CalendarMonth } from '@patternfly/react-core';
2
+ import { CalendarMonth, Title, CalendarMonthInlineProps } from '@patternfly/react-core';
3
3
 
4
4
  export const CalendarMonthSelectableDate: React.FunctionComponent = () => {
5
5
  const [date, setDate] = React.useState(new Date(2020, 10, 24));
@@ -9,10 +9,20 @@ export const CalendarMonthSelectableDate: React.FunctionComponent = () => {
9
9
  console.log(`updated month: ${newDate.getMonth()}, updated year: ${newDate.getFullYear()}`);
10
10
  };
11
11
 
12
+ const inlineProps: CalendarMonthInlineProps = {
13
+ component: 'article',
14
+ title: (
15
+ <Title headingLevel="h4" id="favorite-date">
16
+ Select your favorite date
17
+ </Title>
18
+ ),
19
+ ariaLabelledby: 'favorite-date'
20
+ };
21
+
12
22
  return (
13
- <React.Fragment>
23
+ <>
24
+ <CalendarMonth date={date} onChange={setDate} onMonthChange={onMonthChange} inlineProps={inlineProps} />
14
25
  <pre>Selected date: {date.toString()}</pre>
15
- <CalendarMonth date={date} onChange={setDate} onMonthChange={onMonthChange} />
16
- </React.Fragment>
26
+ </>
17
27
  );
18
28
  };