@patternfly/react-core 4.264.1 → 4.265.1

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 (99) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/esm/components/Badge/Badge.d.ts +2 -0
  3. package/dist/esm/components/Badge/Badge.d.ts.map +1 -1
  4. package/dist/esm/components/Badge/Badge.js +4 -2
  5. package/dist/esm/components/Badge/Badge.js.map +1 -1
  6. package/dist/esm/components/TimePicker/TimePicker.d.ts +0 -1
  7. package/dist/esm/components/TimePicker/TimePicker.d.ts.map +1 -1
  8. package/dist/esm/components/TimePicker/TimePicker.js +1 -9
  9. package/dist/esm/components/TimePicker/TimePicker.js.map +1 -1
  10. package/dist/esm/next/components/Dropdown/DropdownItem.d.ts +2 -0
  11. package/dist/esm/next/components/Dropdown/DropdownItem.d.ts.map +1 -1
  12. package/dist/esm/next/components/Dropdown/DropdownItem.js +2 -2
  13. package/dist/esm/next/components/Dropdown/DropdownItem.js.map +1 -1
  14. package/dist/esm/next/components/Wizard/Wizard.d.ts +1 -1
  15. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
  16. package/dist/esm/next/components/Wizard/WizardContext.d.ts +2 -2
  17. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
  18. package/dist/esm/next/components/Wizard/WizardFooter.d.ts +2 -2
  19. package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  20. package/dist/esm/next/components/Wizard/WizardNavInternal.js +2 -2
  21. package/dist/esm/next/components/Wizard/WizardNavInternal.js.map +1 -1
  22. package/dist/esm/next/components/Wizard/WizardNavItem.js +1 -1
  23. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
  24. package/dist/esm/next/components/Wizard/WizardStep.d.ts +2 -0
  25. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
  26. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
  27. package/dist/esm/next/components/Wizard/types.d.ts +4 -2
  28. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
  29. package/dist/esm/next/components/Wizard/types.js.map +1 -1
  30. package/dist/js/components/Badge/Badge.d.ts +2 -0
  31. package/dist/js/components/Badge/Badge.d.ts.map +1 -1
  32. package/dist/js/components/Badge/Badge.js +4 -2
  33. package/dist/js/components/Badge/Badge.js.map +1 -1
  34. package/dist/js/components/TimePicker/TimePicker.d.ts +0 -1
  35. package/dist/js/components/TimePicker/TimePicker.d.ts.map +1 -1
  36. package/dist/js/components/TimePicker/TimePicker.js +1 -9
  37. package/dist/js/components/TimePicker/TimePicker.js.map +1 -1
  38. package/dist/js/next/components/Dropdown/DropdownItem.d.ts +2 -0
  39. package/dist/js/next/components/Dropdown/DropdownItem.d.ts.map +1 -1
  40. package/dist/js/next/components/Dropdown/DropdownItem.js +2 -2
  41. package/dist/js/next/components/Dropdown/DropdownItem.js.map +1 -1
  42. package/dist/js/next/components/Wizard/Wizard.d.ts +1 -1
  43. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
  44. package/dist/js/next/components/Wizard/WizardContext.d.ts +2 -2
  45. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
  46. package/dist/js/next/components/Wizard/WizardFooter.d.ts +2 -2
  47. package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -1
  48. package/dist/js/next/components/Wizard/WizardNavInternal.js +2 -2
  49. package/dist/js/next/components/Wizard/WizardNavInternal.js.map +1 -1
  50. package/dist/js/next/components/Wizard/WizardNavItem.js +1 -1
  51. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
  52. package/dist/js/next/components/Wizard/WizardStep.d.ts +2 -0
  53. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
  54. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
  55. package/dist/js/next/components/Wizard/types.d.ts +4 -2
  56. package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
  57. package/dist/js/next/components/Wizard/types.js.map +1 -1
  58. package/dist/umd/react-core.min.css +360 -360
  59. package/dist/umd/react-core.min.js +2 -2
  60. package/package.json +6 -6
  61. package/src/components/Badge/Badge.tsx +4 -0
  62. package/src/components/Badge/__tests__/Badge.test.tsx +10 -0
  63. package/src/components/Badge/examples/BadgeUnread.tsx +12 -1
  64. package/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx +60 -22
  65. package/src/components/Tabs/examples/Tabs.md +21 -1557
  66. package/src/components/Tabs/examples/TabsBoxLight.tsx +63 -0
  67. package/src/components/Tabs/examples/TabsChildrenMounting.tsx +33 -0
  68. package/src/components/Tabs/examples/TabsContentWithBodyPadding.tsx +58 -0
  69. package/src/components/Tabs/examples/TabsDefault.tsx +62 -0
  70. package/src/components/Tabs/examples/TabsDefaultOverflow.tsx +74 -0
  71. package/src/components/Tabs/examples/TabsFilled.tsx +51 -0
  72. package/src/components/Tabs/examples/TabsFilledWithIcons.tsx +85 -0
  73. package/src/components/Tabs/examples/TabsIconAndText.tsx +108 -0
  74. package/src/components/Tabs/examples/TabsInset.tsx +65 -0
  75. package/src/components/Tabs/examples/TabsNav.tsx +40 -0
  76. package/src/components/Tabs/examples/TabsNavSecondary.tsx +76 -0
  77. package/src/components/Tabs/examples/TabsPageInsets.tsx +60 -0
  78. package/src/components/Tabs/examples/TabsSeparateContent.tsx +75 -0
  79. package/src/components/Tabs/examples/TabsSubtabs.tsx +115 -0
  80. package/src/components/Tabs/examples/TabsToggledSeparateContent.tsx +67 -0
  81. package/src/components/Tabs/examples/TabsTooltipReactRef.tsx +72 -0
  82. package/src/components/Tabs/examples/TabsUncontrolled.tsx +33 -0
  83. package/src/components/Tabs/examples/TabsUnmountingInvisibleChildren.tsx +33 -0
  84. package/src/components/Tabs/examples/TabsVertical.tsx +72 -0
  85. package/src/components/Tabs/examples/TabsVerticalExpandable.tsx +51 -0
  86. package/src/components/Tabs/examples/TabsVerticalExpandableUncontrolled.tsx +48 -0
  87. package/src/components/TimePicker/TimePicker.tsx +0 -11
  88. package/src/next/components/Dropdown/DropdownItem.tsx +4 -1
  89. package/src/next/components/Wizard/Wizard.tsx +1 -1
  90. package/src/next/components/Wizard/WizardContext.tsx +2 -2
  91. package/src/next/components/Wizard/WizardFooter.tsx +2 -2
  92. package/src/next/components/Wizard/WizardNavInternal.tsx +1 -1
  93. package/src/next/components/Wizard/WizardNavItem.tsx +1 -1
  94. package/src/next/components/Wizard/WizardStep.tsx +2 -0
  95. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +33 -1
  96. package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +1 -2
  97. package/src/next/components/Wizard/examples/Wizard.md +1 -1
  98. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +21 -2
  99. package/src/next/components/Wizard/types.tsx +9 -4
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { Tabs, Tab, TabTitleText } from '@patternfly/react-core';
3
+ export const TabsVerticalExpandableUncontrolled: React.FunctionComponent = () => {
4
+ const [activeTabKey, setActiveTabKey] = React.useState<string | number>(0);
5
+ // Toggle currently active tab
6
+ const handleTabClick = (
7
+ event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent,
8
+ tabIndex: string | number
9
+ ) => {
10
+ setActiveTabKey(tabIndex);
11
+ };
12
+
13
+ return (
14
+ <Tabs
15
+ activeKey={activeTabKey}
16
+ onSelect={handleTabClick}
17
+ isVertical
18
+ expandable={{ default: 'expandable', md: 'nonExpandable', lg: 'expandable' }}
19
+ defaultIsExpanded={false}
20
+ toggleText="Containers"
21
+ aria-label="Tabs in the vertical expandable uncontrolled example"
22
+ role="region"
23
+ >
24
+ <Tab
25
+ eventKey={0}
26
+ title={<TabTitleText>Users</TabTitleText>}
27
+ aria-label="Vertical expandable uncontrolled content users"
28
+ >
29
+ Users
30
+ </Tab>
31
+ <Tab eventKey={1} title={<TabTitleText>Containers</TabTitleText>}>
32
+ Containers
33
+ </Tab>
34
+ <Tab eventKey={2} title={<TabTitleText>Database</TabTitleText>}>
35
+ Database
36
+ </Tab>
37
+ <Tab eventKey={3} title={<TabTitleText>Server</TabTitleText>}>
38
+ Server
39
+ </Tab>
40
+ <Tab eventKey={4} title={<TabTitleText>System</TabTitleText>}>
41
+ System
42
+ </Tab>
43
+ <Tab eventKey={6} title={<TabTitleText>Network</TabTitleText>}>
44
+ Network
45
+ </Tab>
46
+ </Tabs>
47
+ );
48
+ };
@@ -426,16 +426,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
426
426
  });
427
427
  };
428
428
 
429
- onBlur = (event: React.FocusEvent<HTMLInputElement>) => {
430
- const { timeRegex } = this.state;
431
- const { delimiter, is24Hour, includeSeconds } = this.props;
432
- const time = parseTime(event.currentTarget.value, timeRegex, delimiter, !is24Hour, includeSeconds);
433
-
434
- this.setState({
435
- isInvalid: !this.isValid(time)
436
- });
437
- };
438
-
439
429
  render() {
440
430
  const {
441
431
  'aria-label': ariaLabel,
@@ -507,7 +497,6 @@ export class TimePicker extends React.Component<TimePickerProps, TimePickerState
507
497
  iconVariant="clock"
508
498
  onClick={this.onInputClick}
509
499
  onChange={this.onInputChange}
510
- onBlur={this.onBlur}
511
500
  autoComplete="off"
512
501
  isDisabled={isDisabled}
513
502
  ref={this.inputRef}
@@ -10,6 +10,8 @@ export interface DropdownItemProps extends Omit<MenuItemProps, 'ref'>, OUIAProps
10
10
  className?: string;
11
11
  /** Description of the dropdown item */
12
12
  description?: React.ReactNode;
13
+ /** Identifies the component in the dropdown onSelect callback */
14
+ itemId?: any;
13
15
  /** Value to overwrite the randomly generated data-ouia-component-id.*/
14
16
  ouiaId?: number | string;
15
17
  /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
@@ -20,13 +22,14 @@ export const DropdownItem: React.FunctionComponent<MenuItemProps> = ({
20
22
  children,
21
23
  className,
22
24
  description,
25
+ itemId,
23
26
  ouiaId,
24
27
  ouiaSafe,
25
28
  ...props
26
29
  }: DropdownItemProps) => {
27
30
  const ouiaProps = useOUIAProps(DropdownItem.displayName, ouiaId, ouiaSafe);
28
31
  return (
29
- <MenuItem className={css(className)} description={description} {...ouiaProps} {...props}>
32
+ <MenuItem className={css(className)} description={description} itemId={itemId} {...ouiaProps} {...props}>
30
33
  {children}
31
34
  </MenuItem>
32
35
  );
@@ -49,7 +49,7 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
49
49
  /** Callback function after back button is clicked */
50
50
  onBack?: WizardNavStepFunction;
51
51
  /** Callback function to save at the end of the wizard, if not specified uses onClose */
52
- onSave?: () => void;
52
+ onSave?: () => void | Promise<void>;
53
53
  /** Callback function to close the wizard */
54
54
  onClose?: () => void;
55
55
  }
@@ -12,9 +12,9 @@ export interface WizardContextProps {
12
12
  /** Footer element */
13
13
  footer: React.ReactElement;
14
14
  /** Navigate to the next step */
15
- onNext: () => void;
15
+ onNext: () => void | Promise<void>;
16
16
  /** Navigate to the previous step */
17
- onBack: () => void;
17
+ onBack: () => void | Promise<void>;
18
18
  /** Close the wizard */
19
19
  onClose: () => void;
20
20
  /** Navigate to step by ID */
@@ -14,9 +14,9 @@ export interface WizardFooterProps {
14
14
  /** The active step */
15
15
  activeStep: WizardControlStep;
16
16
  /** Next button callback */
17
- onNext: () => WizardNavStepFunction | void;
17
+ onNext: () => WizardNavStepFunction | void | Promise<void>;
18
18
  /** Back button callback */
19
- onBack: () => WizardNavStepFunction | void;
19
+ onBack: () => WizardNavStepFunction | void | Promise<void>;
20
20
  /** Cancel link callback */
21
21
  onClose: () => void;
22
22
  /** Custom text for the Next button. The current step's nextButtonText takes precedence. */
@@ -97,7 +97,7 @@ export const WizardNavInternal = ({ nav, isStepVisitRequired, isNavExpanded }: W
97
97
  key={step.id}
98
98
  id={step.id}
99
99
  content={step.name}
100
- isExpandable={true}
100
+ isExpandable={step.isCollapsible ?? true}
101
101
  isCurrent={hasActiveChild}
102
102
  isDisabled={!hasEnabledChildren}
103
103
  isVisited={step.isVisited}
@@ -109,7 +109,7 @@ export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
109
109
  <span className={css(styles.wizardNavLinkText)}>{content}</span>
110
110
  <span className={css(styles.wizardNavLinkToggle)}>
111
111
  <span className={css(styles.wizardNavLinkToggleIcon)}>
112
- <AngleRightIcon />
112
+ <AngleRightIcon aria-label={`${isCurrent ? 'Collapse' : 'Expand'} step icon`} />
113
113
  </span>
114
114
  </span>
115
115
  </>
@@ -30,6 +30,8 @@ export interface WizardStepProps {
30
30
  footer?: React.ReactElement | Partial<WizardFooterProps>;
31
31
  /** Used to determine icon next to the step's navigation item */
32
32
  status?: 'default' | 'error';
33
+ /** Flag to determine whether sub-steps can collapse or not */
34
+ isCollapsible?: boolean;
33
35
  }
34
36
 
35
37
  export const WizardStep = ({ children, steps: _subSteps, ...props }: WizardStepProps) => {
@@ -278,7 +278,7 @@ test('calls onClose on cancel link click', async () => {
278
278
  expect(onClose).toHaveBeenCalled();
279
279
  });
280
280
 
281
- test('unmounts inactive steps by default', async () => {
281
+ test('does not render inactive step content', async () => {
282
282
  const user = userEvent.setup();
283
283
 
284
284
  render(
@@ -297,3 +297,35 @@ test('unmounts inactive steps by default', async () => {
297
297
  expect(screen.queryByText('Step 1 content')).toBeNull();
298
298
  expect(screen.getByText('Step 2 content')).toBeVisible();
299
299
  });
300
+
301
+ test('parent steps have collapsed sub-steps by default unless the step is active', async () => {
302
+ const user = userEvent.setup();
303
+
304
+ render(
305
+ <Wizard startIndex={2}>
306
+ <WizardStep id="step-1" name="Test step 1" />
307
+ <WizardStep id="step-2" name="Test step 2" steps={[<WizardStep id="sub-step-1" name="Test sub step 1" />]} />
308
+ </Wizard>
309
+ );
310
+
311
+ expect(screen.getByLabelText('Expand step icon')).toBeVisible();
312
+
313
+ await user.click(screen.getByRole('button', { name: 'Next' }));
314
+
315
+ expect(screen.getByLabelText('Collapse step icon')).toBeVisible();
316
+ });
317
+
318
+ test('parent step can be non-collapsible by setting isCollapsible to false', () => {
319
+ render(
320
+ <Wizard>
321
+ <WizardStep
322
+ id="step-1"
323
+ name="Test step 1"
324
+ isCollapsible={false}
325
+ steps={[<WizardStep id="sub-step-1" name="Sub step 1" />]}
326
+ />
327
+ </Wizard>
328
+ );
329
+
330
+ expect(screen.queryByLabelText('step icon', { exact: false })).toBeNull();
331
+ });
@@ -31,8 +31,7 @@ const wizardContext: WizardContext.WizardContextProps = {
31
31
  goToStepByName: jest.fn(),
32
32
  goToStepByIndex: jest.fn(),
33
33
  setFooter: jest.fn(),
34
- getStep: jest.fn(),
35
- setSteps: jest.fn()
34
+ getStep: jest.fn()
36
35
  };
37
36
 
38
37
  const useWizardContextSpy = jest.spyOn(WizardContext, 'useWizardContext');
@@ -96,7 +96,7 @@ Custom operations when navigating between steps can be achieved by utilizing `on
96
96
 
97
97
  ```noLive
98
98
  /** Callback for the Wizard's 'onNext', 'onBack', and 'onNavByIndex' properties */
99
- type WizardNavStepFunction = (currentStep: WizardNavStepData, previousStep: WizardNavStepData) => void;
99
+ type WizardNavStepFunction = (currentStep: WizardNavStepData, previousStep: WizardNavStepData) => void | Promise<void>;
100
100
 
101
101
  /** Data returned for either parameter of WizardNavStepFunction */
102
102
  type WizardNavStepData = Pick<WizardControlStep, 'id' | 'name'>;
@@ -161,6 +161,16 @@ const StepContentWithActions = () => {
161
161
 
162
162
  export const WizardKitchenSink: React.FunctionComponent = () => {
163
163
  const onNext: WizardNavStepFunction = (_currentStep: WizardNavStepData, _previousStep: WizardNavStepData) => {};
164
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
165
+
166
+ async function onSubmit(): Promise<void> {
167
+ setIsSubmitting(true);
168
+
169
+ await new Promise(resolve => setTimeout(resolve, 5000));
170
+
171
+ setIsSubmitting(false);
172
+ alert('50 points to Gryffindor!');
173
+ }
164
174
 
165
175
  return (
166
176
  <SomeContextProvider>
@@ -207,8 +217,17 @@ export const WizardKitchenSink: React.FunctionComponent = () => {
207
217
  >
208
218
  Step 3 content w/ custom async footer
209
219
  </WizardStep>
210
- <WizardStep id={StepId.ReviewStep} name="Review" footer={{ nextButtonText: 'Submit' }}>
211
- Review step content
220
+ <WizardStep
221
+ id={StepId.ReviewStep}
222
+ name="Review"
223
+ footer={{
224
+ nextButtonText: 'Submit',
225
+ onNext: onSubmit,
226
+ isNextDisabled: isSubmitting,
227
+ isBackDisabled: isSubmitting
228
+ }}
229
+ >
230
+ {isSubmitting ? 'Calculating wizard score...' : 'Review step content'}
212
231
  </WizardStep>
213
232
  </Wizard>
214
233
  )}
@@ -34,6 +34,8 @@ export enum WizardNavItemStatus {
34
34
  export interface WizardParentStep extends WizardBasicStep {
35
35
  /** Nested step IDs */
36
36
  subStepIds: (string | number)[];
37
+ /** Flag to determine whether sub-steps can collapse or not */
38
+ isCollapsible?: boolean;
37
39
  }
38
40
 
39
41
  /** Type used to define sub-steps. */
@@ -46,7 +48,10 @@ export interface WizardSubStep extends WizardBasicStep {
46
48
  export type WizardControlStep = WizardBasicStep | WizardParentStep | WizardSubStep;
47
49
 
48
50
  /** Callback for the Wizard's 'onNext', 'onBack', and 'onNavByIndex' properties. */
49
- export type WizardNavStepFunction = (currentStep: WizardNavStepData, previousStep: WizardNavStepData) => void;
51
+ export type WizardNavStepFunction = (
52
+ currentStep: WizardNavStepData,
53
+ previousStep: WizardNavStepData
54
+ ) => void | Promise<void>;
50
55
 
51
56
  /** Data returned for either parameter of WizardNavStepFunction. */
52
57
  export interface WizardNavStepData {
@@ -81,9 +86,9 @@ export type CustomWizardNavItemFunction = (
81
86
  /** Callback for the Wizard's 'footer' property. Returns element which replaces the Wizard's default footer. */
82
87
  export type CustomWizardFooterFunction = (
83
88
  activeStep: WizardControlStep,
84
- onNext: () => void,
85
- onBack: () => void,
86
- onClose: () => void
89
+ onNext: () => void | Promise<void>,
90
+ onBack: () => void | Promise<void>,
91
+ onClose: () => void | Promise<void>
87
92
  ) => React.ReactElement<WizardFooterProps>;
88
93
 
89
94
  export function isCustomWizardNav(nav: WizardNavType): nav is CustomWizardNavFunction | React.ReactElement {