@patternfly/react-core 4.164.1 → 4.168.4

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 (158) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/README.md +1 -1
  3. package/dist/esm/components/Dropdown/DropdownToggle.d.ts +1 -1
  4. package/dist/esm/components/Dropdown/DropdownToggle.d.ts.map +1 -1
  5. package/dist/esm/components/Dropdown/KebabToggle.d.ts +1 -1
  6. package/dist/esm/components/Dropdown/KebabToggle.d.ts.map +1 -1
  7. package/dist/esm/components/DualListSelector/DualListSelector.d.ts +1 -0
  8. package/dist/esm/components/DualListSelector/DualListSelector.d.ts.map +1 -1
  9. package/dist/esm/components/DualListSelector/DualListSelector.js +23 -10
  10. package/dist/esm/components/DualListSelector/DualListSelector.js.map +1 -1
  11. package/dist/esm/components/Label/Label.d.ts +2 -0
  12. package/dist/esm/components/Label/Label.d.ts.map +1 -1
  13. package/dist/esm/components/Label/Label.js +2 -2
  14. package/dist/esm/components/Label/Label.js.map +1 -1
  15. package/dist/esm/components/LabelGroup/LabelGroup.d.ts +2 -0
  16. package/dist/esm/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  17. package/dist/esm/components/LabelGroup/LabelGroup.js +5 -3
  18. package/dist/esm/components/LabelGroup/LabelGroup.js.map +1 -1
  19. package/dist/esm/components/ProgressStepper/ProgressStep.d.ts +5 -1
  20. package/dist/esm/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
  21. package/dist/esm/components/ProgressStepper/ProgressStep.js +7 -3
  22. package/dist/esm/components/ProgressStepper/ProgressStep.js.map +1 -1
  23. package/dist/esm/components/Select/SelectOption.d.ts +1 -1
  24. package/dist/esm/components/Select/SelectOption.d.ts.map +1 -1
  25. package/dist/esm/components/Tabs/TabContentBody.d.ts +11 -0
  26. package/dist/esm/components/Tabs/TabContentBody.d.ts.map +1 -0
  27. package/dist/esm/components/Tabs/TabContentBody.js +10 -0
  28. package/dist/esm/components/Tabs/TabContentBody.js.map +1 -0
  29. package/dist/esm/components/Tabs/index.d.ts +1 -0
  30. package/dist/esm/components/Tabs/index.d.ts.map +1 -1
  31. package/dist/esm/components/Tabs/index.js +1 -0
  32. package/dist/esm/components/Tabs/index.js.map +1 -1
  33. package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts +9 -0
  34. package/dist/esm/components/TextInputGroup/TextInputGroup.d.ts.map +1 -0
  35. package/dist/esm/components/TextInputGroup/TextInputGroup.js +10 -0
  36. package/dist/esm/components/TextInputGroup/TextInputGroup.js.map +1 -0
  37. package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts +15 -0
  38. package/dist/esm/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -0
  39. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js +15 -0
  40. package/dist/esm/components/TextInputGroup/TextInputGroupMain.js.map +1 -0
  41. package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.d.ts +9 -0
  42. package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.d.ts.map +1 -0
  43. package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.js +10 -0
  44. package/dist/esm/components/TextInputGroup/TextInputGroupUtilities.js.map +1 -0
  45. package/dist/esm/components/TextInputGroup/index.d.ts +4 -0
  46. package/dist/esm/components/TextInputGroup/index.d.ts.map +1 -0
  47. package/dist/esm/components/TextInputGroup/index.js +4 -0
  48. package/dist/esm/components/TextInputGroup/index.js.map +1 -0
  49. package/dist/esm/components/Toolbar/Toolbar.d.ts +2 -0
  50. package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
  51. package/dist/esm/components/Toolbar/Toolbar.js +2 -2
  52. package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
  53. package/dist/esm/components/index.d.ts +1 -0
  54. package/dist/esm/components/index.d.ts.map +1 -1
  55. package/dist/esm/components/index.js +1 -0
  56. package/dist/esm/components/index.js.map +1 -1
  57. package/dist/js/components/Dropdown/DropdownToggle.d.ts +1 -1
  58. package/dist/js/components/Dropdown/DropdownToggle.d.ts.map +1 -1
  59. package/dist/js/components/Dropdown/KebabToggle.d.ts +1 -1
  60. package/dist/js/components/Dropdown/KebabToggle.d.ts.map +1 -1
  61. package/dist/js/components/DualListSelector/DualListSelector.d.ts +1 -0
  62. package/dist/js/components/DualListSelector/DualListSelector.d.ts.map +1 -1
  63. package/dist/js/components/DualListSelector/DualListSelector.js +23 -10
  64. package/dist/js/components/DualListSelector/DualListSelector.js.map +1 -1
  65. package/dist/js/components/Label/Label.d.ts +2 -0
  66. package/dist/js/components/Label/Label.d.ts.map +1 -1
  67. package/dist/js/components/Label/Label.js +2 -2
  68. package/dist/js/components/Label/Label.js.map +1 -1
  69. package/dist/js/components/LabelGroup/LabelGroup.d.ts +2 -0
  70. package/dist/js/components/LabelGroup/LabelGroup.d.ts.map +1 -1
  71. package/dist/js/components/LabelGroup/LabelGroup.js +5 -3
  72. package/dist/js/components/LabelGroup/LabelGroup.js.map +1 -1
  73. package/dist/js/components/ProgressStepper/ProgressStep.d.ts +5 -1
  74. package/dist/js/components/ProgressStepper/ProgressStep.d.ts.map +1 -1
  75. package/dist/js/components/ProgressStepper/ProgressStep.js +7 -4
  76. package/dist/js/components/ProgressStepper/ProgressStep.js.map +1 -1
  77. package/dist/js/components/Select/SelectOption.d.ts +1 -1
  78. package/dist/js/components/Select/SelectOption.d.ts.map +1 -1
  79. package/dist/js/components/Tabs/TabContentBody.d.ts +11 -0
  80. package/dist/js/components/Tabs/TabContentBody.d.ts.map +1 -0
  81. package/dist/js/components/Tabs/TabContentBody.js +14 -0
  82. package/dist/js/components/Tabs/TabContentBody.js.map +1 -0
  83. package/dist/js/components/Tabs/index.d.ts +1 -0
  84. package/dist/js/components/Tabs/index.d.ts.map +1 -1
  85. package/dist/js/components/Tabs/index.js +1 -0
  86. package/dist/js/components/Tabs/index.js.map +1 -1
  87. package/dist/js/components/TextInputGroup/TextInputGroup.d.ts +9 -0
  88. package/dist/js/components/TextInputGroup/TextInputGroup.d.ts.map +1 -0
  89. package/dist/js/components/TextInputGroup/TextInputGroup.js +14 -0
  90. package/dist/js/components/TextInputGroup/TextInputGroup.js.map +1 -0
  91. package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts +15 -0
  92. package/dist/js/components/TextInputGroup/TextInputGroupMain.d.ts.map +1 -0
  93. package/dist/js/components/TextInputGroup/TextInputGroupMain.js +19 -0
  94. package/dist/js/components/TextInputGroup/TextInputGroupMain.js.map +1 -0
  95. package/dist/js/components/TextInputGroup/TextInputGroupUtilities.d.ts +9 -0
  96. package/dist/js/components/TextInputGroup/TextInputGroupUtilities.d.ts.map +1 -0
  97. package/dist/js/components/TextInputGroup/TextInputGroupUtilities.js +14 -0
  98. package/dist/js/components/TextInputGroup/TextInputGroupUtilities.js.map +1 -0
  99. package/dist/js/components/TextInputGroup/index.d.ts +4 -0
  100. package/dist/js/components/TextInputGroup/index.d.ts.map +1 -0
  101. package/dist/js/components/TextInputGroup/index.js +7 -0
  102. package/dist/js/components/TextInputGroup/index.js.map +1 -0
  103. package/dist/js/components/Toolbar/Toolbar.d.ts +2 -0
  104. package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
  105. package/dist/js/components/Toolbar/Toolbar.js +2 -2
  106. package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
  107. package/dist/js/components/index.d.ts +1 -0
  108. package/dist/js/components/index.d.ts.map +1 -1
  109. package/dist/js/components/index.js +1 -0
  110. package/dist/js/components/index.js.map +1 -1
  111. package/dist/styles/assets/pficon/pficon.woff +0 -0
  112. package/dist/styles/assets/pficon/pficon.woff2 +0 -0
  113. package/dist/umd/react-core.css +360 -17
  114. package/dist/umd/react-core.js +970 -890
  115. package/dist/umd/react-core.min.css +360 -17
  116. package/dist/umd/react-core.min.js +3 -3
  117. package/package.json +6 -6
  118. package/src/components/Dropdown/DropdownToggle.tsx +1 -1
  119. package/src/components/Dropdown/KebabToggle.tsx +1 -1
  120. package/src/components/DualListSelector/DualListSelector.tsx +25 -23
  121. package/src/components/Label/Label.tsx +4 -0
  122. package/src/components/Label/__tests__/Generated/__snapshots__/Label.test.tsx.snap +0 -1
  123. package/src/components/Label/examples/Label.md +72 -42
  124. package/src/components/LabelGroup/LabelGroup.tsx +10 -1
  125. package/src/components/LabelGroup/__tests__/LabelGroup.test.tsx +12 -0
  126. package/src/components/LabelGroup/__tests__/__snapshots__/LabelGroup.test.tsx.snap +8 -0
  127. package/src/components/Modal/__tests__/ModalBox.test.tsx +11 -21
  128. package/src/components/Modal/__tests__/ModalBoxDescription.test.tsx +12 -0
  129. package/src/components/Modal/__tests__/ModalBoxTitle.test.tsx +59 -0
  130. package/src/components/Modal/__tests__/ModalContent.test.tsx +15 -10
  131. package/src/components/Modal/__tests__/__snapshots__/ModalBox.test.tsx.snap +12 -30
  132. package/src/components/Modal/__tests__/__snapshots__/ModalBoxDescription.test.tsx.snap +10 -0
  133. package/src/components/Modal/__tests__/__snapshots__/ModalBoxTitle.test.tsx.snap +158 -0
  134. package/src/components/Modal/__tests__/__snapshots__/ModalContent.test.tsx.snap +53 -22
  135. package/src/components/ProgressStepper/ProgressStep.tsx +18 -4
  136. package/src/components/ProgressStepper/__tests__/ProgressStepper.test.tsx +5 -0
  137. package/src/components/ProgressStepper/__tests__/__snapshots__/ProgressStepper.test.tsx.snap +680 -517
  138. package/src/components/ProgressStepper/examples/ProgressStepper.md +78 -0
  139. package/src/components/Select/SelectOption.tsx +1 -1
  140. package/src/components/Tabs/TabContentBody.tsx +24 -0
  141. package/src/components/Tabs/__tests__/Tabs.test.tsx +4 -3
  142. package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +10 -2
  143. package/src/components/Tabs/examples/Tabs.md +40 -0
  144. package/src/components/Tabs/index.ts +1 -0
  145. package/src/components/TextInputGroup/TextInputGroup.tsx +22 -0
  146. package/src/components/TextInputGroup/TextInputGroupMain.tsx +43 -0
  147. package/src/components/TextInputGroup/TextInputGroupUtilities.tsx +22 -0
  148. package/src/components/TextInputGroup/__tests__/TextInputGroup.test.tsx +77 -0
  149. package/src/components/TextInputGroup/__tests__/__snapshots__/TextInputGroup.test.tsx.snap +211 -0
  150. package/src/components/TextInputGroup/examples/TextInputGroup.md +138 -0
  151. package/src/components/TextInputGroup/index.ts +3 -0
  152. package/src/components/Toolbar/Toolbar.tsx +4 -0
  153. package/src/components/Wizard/examples/Wizard.md +17 -1
  154. package/src/components/index.ts +1 -0
  155. package/src/demos/CardDemos.md +5 -5
  156. package/src/demos/ProgressDemo.md +82 -0
  157. package/src/demos/Tabs.md +439 -0
  158. package/src/demos/examples/DashboardWrapper.js +16 -2
@@ -328,3 +328,81 @@ import PendingIcon from '@patternfly/react-icons/dist/esm/icons/pending-icon';
328
328
  </ProgressStep>
329
329
  </ProgressStepper>;
330
330
  ```
331
+
332
+ ### With help popover
333
+
334
+ To add a popover to a progress step, set the `popover` and `ref` properties on the `ProgressStep` component and the `reference` property on the `Popover` component.
335
+
336
+ ```js
337
+ import React from 'react';
338
+ import { ProgressStepper, ProgressStep, Popover } from '@patternfly/react-core';
339
+
340
+ PopoverProgressStep = () => {
341
+ const firstStepRef = React.useRef();
342
+ const secondStepRef = React.useRef();
343
+ const thirdStepRef = React.useRef();
344
+
345
+ return (
346
+ <ProgressStepper>
347
+ <ProgressStep
348
+ variant="success"
349
+ id="popover-step1"
350
+ titleId="popover-step1-title"
351
+ aria-label="completed step with popover, step with success"
352
+ popover={
353
+ <Popover
354
+ aria-label="First step help"
355
+ headerContent={<div>First step popover</div>}
356
+ bodyContent={<div>Additional info or help text content.</div>}
357
+ reference={firstStepRef}
358
+ position="right"
359
+ />
360
+ }
361
+ ref={firstStepRef}
362
+ >
363
+ First Step
364
+ </ProgressStep>
365
+ <ProgressStep
366
+ variant="danger"
367
+ id="popover-step2"
368
+ titleId="popover-step2-title"
369
+ aria-label="completed step with popover, step with danger"
370
+ popover={
371
+ <Popover
372
+ aria-label="Second step help"
373
+ headerContent={<div>Second step popover</div>}
374
+ bodyContent={<div>Additional info or help text content.</div>}
375
+ reference={secondStepRef}
376
+ position="right"
377
+ />
378
+ }
379
+ ref={secondStepRef}
380
+ >
381
+ Second Step
382
+ </ProgressStep>
383
+ <ProgressStep
384
+ variant="info"
385
+ id="popover-step3"
386
+ titleId="popover-step3-title"
387
+ aria-label="current step with popover"
388
+ popover={
389
+ <Popover
390
+ aria-label="Third step help"
391
+ headerContent={<div>Third step popover</div>}
392
+ bodyContent={<div>Additional info or help text content.</div>}
393
+ reference={thirdStepRef}
394
+ position="right"
395
+ />
396
+ }
397
+ isCurrent
398
+ ref={thirdStepRef}
399
+ >
400
+ Third Step
401
+ </ProgressStep>
402
+ <ProgressStep variant="pending" id="popover-step4" titleId="popover-step4-title" aria-label="pending step">
403
+ Fourth step
404
+ </ProgressStep>
405
+ </ProgressStepper>
406
+ );
407
+ };
408
+ ```
@@ -68,7 +68,7 @@ export interface SelectOptionProps extends Omit<React.HTMLProps<HTMLElement>, 't
68
68
  /** @hide Internal callback for the setting the index of the next item to focus after view more is clicked */
69
69
  setViewMoreNextIndex?: () => void;
70
70
  /** @hide Flag indicating this is the last option when there is a footer */
71
- isLastOptionBeforeFooter: (index: number) => boolean;
71
+ isLastOptionBeforeFooter?: (index: number) => boolean;
72
72
  }
73
73
 
74
74
  export class SelectOption extends React.Component<SelectOptionProps> {
@@ -0,0 +1,24 @@
1
+ import * as React from 'react';
2
+ import { css } from '@patternfly/react-styles';
3
+ import styles from '@patternfly/react-styles/css/components/TabContent/tab-content';
4
+
5
+ export interface TabContentBodyProps extends React.HTMLProps<HTMLDivElement> {
6
+ /** Content rendered inside the tab content body. */
7
+ children: React.ReactNode;
8
+ /** Additional classes added to the tab content body. */
9
+ className?: string;
10
+ /** Indicates if there should be padding around the tab content body */
11
+ hasPadding?: boolean;
12
+ }
13
+
14
+ export const TabContentBody: React.FunctionComponent<TabContentBodyProps> = ({
15
+ children,
16
+ className,
17
+ hasPadding,
18
+ ...props
19
+ }: TabContentBodyProps) => (
20
+ <div className={css(styles.tabContentBody, hasPadding && styles.modifiers.padding, className)} {...props}>
21
+ {children}
22
+ </div>
23
+ );
24
+ TabContentBody.displayName = 'TabContentBody';
@@ -5,6 +5,7 @@ import { Tab } from '../Tab';
5
5
  import { TabTitleText } from '../TabTitleText';
6
6
  import { TabTitleIcon } from '../TabTitleIcon';
7
7
  import { TabContent } from '../TabContent';
8
+ import { TabContentBody } from '../TabContentBody';
8
9
 
9
10
  test('should render simple tabs', () => {
10
11
  const view = render(
@@ -247,10 +248,10 @@ test('should render tabs with separate content', () => {
247
248
  Tab 1 section
248
249
  </TabContent>
249
250
  <TabContent eventKey={1} id="refTab2Section" ref={contentRef2} aria-label="Tab item 2" hidden>
250
- Tab 2 section
251
+ <TabContentBody>Tab 2 section</TabContentBody>
251
252
  </TabContent>
252
- <TabContent eventKey={2} id="refTab3Section" ref={contentRef3} aria-label="Tab item 3" hidden>
253
- Tab 3 section
253
+ <TabContent eventKey={2} id="refTab3Section" ref={contentRef3} aria-label="Tab item 3" hidden>
254
+ <TabContentBody hasPadding>Tab 3 section with padding </TabContentBody>
254
255
  </TabContent>
255
256
  </div>
256
257
  </>
@@ -1571,7 +1571,11 @@ Array [
1571
1571
  role="tabpanel"
1572
1572
  tabindex="0"
1573
1573
  >
1574
- Tab 2 section
1574
+ <div
1575
+ class="pf-c-tab-content__body"
1576
+ >
1577
+ Tab 2 section
1578
+ </div>
1575
1579
  </section>
1576
1580
  <section
1577
1581
  aria-label="Tab item 3"
@@ -1583,7 +1587,11 @@ Array [
1583
1587
  role="tabpanel"
1584
1588
  tabindex="0"
1585
1589
  >
1586
- Tab 3 section
1590
+ <div
1591
+ class="pf-c-tab-content__body pf-m-padding"
1592
+ >
1593
+ Tab 3 section with padding
1594
+ </div>
1587
1595
  </section>
1588
1596
  </div>,
1589
1597
  ]
@@ -1049,6 +1049,46 @@ class SeparateTabContent extends React.Component {
1049
1049
  }
1050
1050
  ```
1051
1051
 
1052
+ ### Tab content with body and padding
1053
+ ```js
1054
+ import React from 'react';
1055
+ import { Tabs, Tab, TabTitleText, TabContent, TabContentBody } from '@patternfly/react-core';
1056
+
1057
+ const TabContentWithBody = () => {
1058
+ const [activeTabKey, setActiveTabKey] = React.useState(0);
1059
+
1060
+ // Toggle currently active tab
1061
+ const handleTabClick = (event, tabIndex) => {
1062
+ setActiveTabKey(tabIndex);
1063
+ };
1064
+
1065
+ const contentRef1 = React.createRef();
1066
+ const contentRef2 = React.createRef();
1067
+ const contentRef3 = React.createRef();
1068
+
1069
+ return (
1070
+ <React.Fragment>
1071
+ <Tabs activeKey={activeTabKey} onSelect={handleTabClick}>
1072
+ <Tab eventKey={0} title={<TabTitleText>Tab item 1</TabTitleText>} tabContentId="refTab1Section" tabContentRef={contentRef1} />
1073
+ <Tab eventKey={1} title={<TabTitleText>Tab item 2</TabTitleText>}tabContentId="refTab2Section" tabContentRef={contentRef2} />
1074
+ <Tab eventKey={2} title={<TabTitleText>Tab item 3</TabTitleText>} tabContentId="refTab3Section" tabContentRef={contentRef3} />
1075
+ </Tabs>
1076
+ <div>
1077
+ <TabContent eventKey={0} id="refTab1Section" ref={contentRef1} aria-label="Tab item 1">
1078
+ <TabContentBody hasPadding> Tab 1 section </TabContentBody>
1079
+ </TabContent>
1080
+ <TabContent eventKey={1} id="refTab2Section" ref={contentRef2} aria-label="Tab item 2" hidden>
1081
+ <TabContentBody hasPadding> Tab 2 section </TabContentBody>
1082
+ </TabContent>
1083
+ <TabContent eventKey={2} id="refTab3Section" ref={contentRef3} aria-label="Tab item 3" hidden>
1084
+ <TabContentBody hasPadding> Tab 3 section </TabContentBody>
1085
+ </TabContent>
1086
+ </div>
1087
+ </React.Fragment>
1088
+ );
1089
+ }
1090
+ ```
1091
+
1052
1092
  ### Children mounting on click
1053
1093
  ```js
1054
1094
  import React from 'react';
@@ -1,6 +1,7 @@
1
1
  export * from './Tab';
2
2
  export * from './Tabs';
3
3
  export * from './TabContent';
4
+ export * from './TabContentBody';
4
5
  export * from './TabsContext';
5
6
  export * from './TabTitleText';
6
7
  export * from './TabTitleIcon';
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
3
+ import { css } from '@patternfly/react-styles';
4
+
5
+ export interface TextInputGroupProps extends React.HTMLProps<HTMLDivElement> {
6
+ /** Content rendered inside the text input group */
7
+ children?: React.ReactNode;
8
+ /** Additional classes applied to the text input group container */
9
+ className?: string;
10
+ }
11
+
12
+ export const TextInputGroup: React.FunctionComponent<TextInputGroupProps> = ({
13
+ children,
14
+ className,
15
+ ...props
16
+ }: TextInputGroupProps) => (
17
+ <div className={css(styles.textInputGroup, className)} {...props}>
18
+ {children}
19
+ </div>
20
+ );
21
+
22
+ TextInputGroup.displayName = 'TextInputGroup';
@@ -0,0 +1,43 @@
1
+ import * as React from 'react';
2
+ import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
3
+ import { css } from '@patternfly/react-styles';
4
+
5
+ export interface TextInputGroupMainProps extends React.HTMLProps<HTMLDivElement> {
6
+ /** Content rendered inside the text input group main div */
7
+ children?: React.ReactNode;
8
+ /** Additional classes applied to the text input group main container */
9
+ className?: string;
10
+ /** Icon to be shown on the left side of the text input group main container */
11
+ icon?: React.ReactNode;
12
+ /** Callback for when there is a change in the input field*/
13
+ onChange?: () => void;
14
+ /** Accessibility label for the input */
15
+ 'aria-label'?: string;
16
+ }
17
+
18
+ export const TextInputGroupMain: React.FunctionComponent<TextInputGroupMainProps> = ({
19
+ children,
20
+ className,
21
+ icon,
22
+ onChange,
23
+ 'aria-label': ariaLabel,
24
+ value: inputValue,
25
+ ...props
26
+ }: TextInputGroupMainProps) => (
27
+ <div className={css(styles.textInputGroupMain, icon && styles.modifiers.icon, className)} {...props}>
28
+ {children}
29
+ <span className={css(styles.textInputGroupText)}>
30
+ {icon && <span className={css(styles.textInputGroupIcon)}>{icon}</span>}
31
+ <input
32
+ type="text"
33
+ className={css(styles.textInputGroupTextInput)}
34
+ aria-label={ariaLabel}
35
+ onChange={onChange}
36
+ value={inputValue}
37
+ />
38
+ </span>
39
+ </div>
40
+ );
41
+
42
+ TextInputGroupMain.defaultProps = { 'aria-label': 'Type to filter' };
43
+ TextInputGroupMain.displayName = 'TextInputGroupMain';
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import styles from '@patternfly/react-styles/css/components/TextInputGroup/text-input-group';
3
+ import { css } from '@patternfly/react-styles';
4
+
5
+ export interface TextInputGroupUtilitiesProps extends React.HTMLProps<HTMLDivElement> {
6
+ /** Content rendered inside the text input group utilities div */
7
+ children?: React.ReactNode;
8
+ /** Additional classes applied to the text input group utilities container */
9
+ className?: string;
10
+ }
11
+
12
+ export const TextInputGroupUtilities: React.FunctionComponent<TextInputGroupUtilitiesProps> = ({
13
+ children,
14
+ className,
15
+ ...props
16
+ }: TextInputGroupUtilitiesProps) => (
17
+ <div className={css(styles.textInputGroupUtilities, className)} {...props}>
18
+ {children}
19
+ </div>
20
+ );
21
+
22
+ TextInputGroupUtilities.displayName = 'TextInputGroupUtilities';
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import { TextInputGroup } from '../TextInputGroup';
4
+ import { TextInputGroupMain } from '../TextInputGroupMain';
5
+ import { TextInputGroupUtilities } from '../TextInputGroupUtilities';
6
+ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
7
+
8
+ describe('TextInputGroup', () => {
9
+ test('renders content', () => {
10
+ const view = mount(
11
+ <TextInputGroup>
12
+ <TextInputGroupMain>Foo</TextInputGroupMain>
13
+ <TextInputGroupUtilities />
14
+ </TextInputGroup>
15
+ );
16
+ expect(view).toMatchSnapshot();
17
+ });
18
+
19
+ test('gets custom class and id', () => {
20
+ const view = mount(
21
+ <TextInputGroup className="custom-class" id="test-id">
22
+ <TextInputGroupMain>Foo</TextInputGroupMain>
23
+ <TextInputGroupUtilities />
24
+ </TextInputGroup>
25
+ );
26
+ expect(view).toMatchSnapshot();
27
+ });
28
+
29
+ test('renders with the proper stying for an icon on the left side of the component', () => {
30
+ const view = mount(
31
+ <TextInputGroup>
32
+ <TextInputGroupMain>Foo</TextInputGroupMain>
33
+ <TextInputGroupUtilities />
34
+ </TextInputGroup>
35
+ );
36
+ expect(view).toMatchSnapshot();
37
+ });
38
+ });
39
+
40
+ describe('TextInputGroupMain', () => {
41
+ test('renders content', () => {
42
+ const view = mount(<TextInputGroupMain>Foo</TextInputGroupMain>);
43
+ expect(view).toMatchSnapshot();
44
+ });
45
+
46
+ test('renders given input icon props', () => {
47
+ const view = mount(<TextInputGroupMain icon={<SearchIcon />}>Foo</TextInputGroupMain>);
48
+ expect(view).toMatchSnapshot();
49
+ });
50
+
51
+ test('renders the input with custom aria label when given', () => {
52
+ const view = mount(<TextInputGroupMain aria-label="Foo">Foo</TextInputGroupMain>);
53
+ expect(view).toMatchSnapshot();
54
+ });
55
+
56
+ test('does not call onChange callback when the input does not change', () => {
57
+ const onChangeMock = jest.fn();
58
+
59
+ const view = mount(<TextInputGroupMain onChange={onChangeMock}>Foo</TextInputGroupMain>);
60
+ expect(onChangeMock).not.toHaveBeenCalled();
61
+ });
62
+
63
+ test('calls the onChange callback when the input changes', () => {
64
+ const onChangeMock = jest.fn();
65
+
66
+ const view = mount(<TextInputGroupMain onChange={onChangeMock}>Foo</TextInputGroupMain>);
67
+ view.find('input').simulate('change', { target: { value: 'Foo' } });
68
+ expect(onChangeMock).toHaveBeenCalledTimes(1);
69
+ });
70
+ });
71
+
72
+ describe('TextInputGroupUtilities', () => {
73
+ test('renders the content', () => {
74
+ const view = mount(<TextInputGroupUtilities>{<button>Foo</button>}</TextInputGroupUtilities>);
75
+ expect(view).toMatchSnapshot();
76
+ });
77
+ });
@@ -0,0 +1,211 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`TextInputGroup gets custom class and id 1`] = `
4
+ <TextInputGroup
5
+ className="custom-class"
6
+ id="test-id"
7
+ >
8
+ <div
9
+ className="pf-c-text-input-group custom-class"
10
+ id="test-id"
11
+ >
12
+ <TextInputGroupMain
13
+ aria-label="Type to filter"
14
+ >
15
+ <div
16
+ className="pf-c-text-input-group__main"
17
+ >
18
+ Foo
19
+ <span
20
+ className="pf-c-text-input-group__text"
21
+ >
22
+ <input
23
+ aria-label="Type to filter"
24
+ className="pf-c-text-input-group__text-input"
25
+ type="text"
26
+ />
27
+ </span>
28
+ </div>
29
+ </TextInputGroupMain>
30
+ <TextInputGroupUtilities>
31
+ <div
32
+ className="pf-c-text-input-group__utilities"
33
+ />
34
+ </TextInputGroupUtilities>
35
+ </div>
36
+ </TextInputGroup>
37
+ `;
38
+
39
+ exports[`TextInputGroup renders content 1`] = `
40
+ <TextInputGroup>
41
+ <div
42
+ className="pf-c-text-input-group"
43
+ >
44
+ <TextInputGroupMain
45
+ aria-label="Type to filter"
46
+ >
47
+ <div
48
+ className="pf-c-text-input-group__main"
49
+ >
50
+ Foo
51
+ <span
52
+ className="pf-c-text-input-group__text"
53
+ >
54
+ <input
55
+ aria-label="Type to filter"
56
+ className="pf-c-text-input-group__text-input"
57
+ type="text"
58
+ />
59
+ </span>
60
+ </div>
61
+ </TextInputGroupMain>
62
+ <TextInputGroupUtilities>
63
+ <div
64
+ className="pf-c-text-input-group__utilities"
65
+ />
66
+ </TextInputGroupUtilities>
67
+ </div>
68
+ </TextInputGroup>
69
+ `;
70
+
71
+ exports[`TextInputGroup renders with the proper stying for an icon on the left side of the component 1`] = `
72
+ <TextInputGroup>
73
+ <div
74
+ className="pf-c-text-input-group"
75
+ >
76
+ <TextInputGroupMain
77
+ aria-label="Type to filter"
78
+ >
79
+ <div
80
+ className="pf-c-text-input-group__main"
81
+ >
82
+ Foo
83
+ <span
84
+ className="pf-c-text-input-group__text"
85
+ >
86
+ <input
87
+ aria-label="Type to filter"
88
+ className="pf-c-text-input-group__text-input"
89
+ type="text"
90
+ />
91
+ </span>
92
+ </div>
93
+ </TextInputGroupMain>
94
+ <TextInputGroupUtilities>
95
+ <div
96
+ className="pf-c-text-input-group__utilities"
97
+ />
98
+ </TextInputGroupUtilities>
99
+ </div>
100
+ </TextInputGroup>
101
+ `;
102
+
103
+ exports[`TextInputGroupMain renders content 1`] = `
104
+ <TextInputGroupMain
105
+ aria-label="Type to filter"
106
+ >
107
+ <div
108
+ className="pf-c-text-input-group__main"
109
+ >
110
+ Foo
111
+ <span
112
+ className="pf-c-text-input-group__text"
113
+ >
114
+ <input
115
+ aria-label="Type to filter"
116
+ className="pf-c-text-input-group__text-input"
117
+ type="text"
118
+ />
119
+ </span>
120
+ </div>
121
+ </TextInputGroupMain>
122
+ `;
123
+
124
+ exports[`TextInputGroupMain renders given input icon props 1`] = `
125
+ <TextInputGroupMain
126
+ aria-label="Type to filter"
127
+ icon={
128
+ <SearchIcon
129
+ color="currentColor"
130
+ noVerticalAlign={false}
131
+ size="sm"
132
+ />
133
+ }
134
+ >
135
+ <div
136
+ className="pf-c-text-input-group__main pf-m-icon"
137
+ >
138
+ Foo
139
+ <span
140
+ className="pf-c-text-input-group__text"
141
+ >
142
+ <span
143
+ className="pf-c-text-input-group__icon"
144
+ >
145
+ <SearchIcon
146
+ color="currentColor"
147
+ noVerticalAlign={false}
148
+ size="sm"
149
+ >
150
+ <svg
151
+ aria-hidden={true}
152
+ aria-labelledby={null}
153
+ fill="currentColor"
154
+ height="1em"
155
+ role="img"
156
+ style={
157
+ Object {
158
+ "verticalAlign": "-0.125em",
159
+ }
160
+ }
161
+ viewBox="0 0 512 512"
162
+ width="1em"
163
+ >
164
+ <path
165
+ d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
166
+ />
167
+ </svg>
168
+ </SearchIcon>
169
+ </span>
170
+ <input
171
+ aria-label="Type to filter"
172
+ className="pf-c-text-input-group__text-input"
173
+ type="text"
174
+ />
175
+ </span>
176
+ </div>
177
+ </TextInputGroupMain>
178
+ `;
179
+
180
+ exports[`TextInputGroupMain renders the input with custom aria label when given 1`] = `
181
+ <TextInputGroupMain
182
+ aria-label="Foo"
183
+ >
184
+ <div
185
+ className="pf-c-text-input-group__main"
186
+ >
187
+ Foo
188
+ <span
189
+ className="pf-c-text-input-group__text"
190
+ >
191
+ <input
192
+ aria-label="Foo"
193
+ className="pf-c-text-input-group__text-input"
194
+ type="text"
195
+ />
196
+ </span>
197
+ </div>
198
+ </TextInputGroupMain>
199
+ `;
200
+
201
+ exports[`TextInputGroupUtilities renders the content 1`] = `
202
+ <TextInputGroupUtilities>
203
+ <div
204
+ className="pf-c-text-input-group__utilities"
205
+ >
206
+ <button>
207
+ Foo
208
+ </button>
209
+ </div>
210
+ </TextInputGroupUtilities>
211
+ `;