@patternfly/react-core 4.199.5 → 4.200.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/esm/components/Avatar/Avatar.d.ts +2 -0
  3. package/dist/esm/components/Avatar/Avatar.d.ts.map +1 -1
  4. package/dist/esm/components/Avatar/Avatar.js +2 -2
  5. package/dist/esm/components/Avatar/Avatar.js.map +1 -1
  6. package/dist/esm/components/FormSelect/FormSelect.d.ts +2 -0
  7. package/dist/esm/components/FormSelect/FormSelect.d.ts.map +1 -1
  8. package/dist/esm/components/FormSelect/FormSelect.js +3 -2
  9. package/dist/esm/components/FormSelect/FormSelect.js.map +1 -1
  10. package/dist/esm/components/TextArea/TextArea.d.ts +2 -0
  11. package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
  12. package/dist/esm/components/TextArea/TextArea.js +4 -3
  13. package/dist/esm/components/TextArea/TextArea.js.map +1 -1
  14. package/dist/esm/components/TextInput/TextInput.d.ts +2 -0
  15. package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
  16. package/dist/esm/components/TextInput/TextInput.js +3 -2
  17. package/dist/esm/components/TextInput/TextInput.js.map +1 -1
  18. package/dist/js/components/Avatar/Avatar.d.ts +2 -0
  19. package/dist/js/components/Avatar/Avatar.d.ts.map +1 -1
  20. package/dist/js/components/Avatar/Avatar.js +2 -2
  21. package/dist/js/components/Avatar/Avatar.js.map +1 -1
  22. package/dist/js/components/FormSelect/FormSelect.d.ts +2 -0
  23. package/dist/js/components/FormSelect/FormSelect.d.ts.map +1 -1
  24. package/dist/js/components/FormSelect/FormSelect.js +3 -2
  25. package/dist/js/components/FormSelect/FormSelect.js.map +1 -1
  26. package/dist/js/components/TextArea/TextArea.d.ts +2 -0
  27. package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
  28. package/dist/js/components/TextArea/TextArea.js +4 -3
  29. package/dist/js/components/TextArea/TextArea.js.map +1 -1
  30. package/dist/js/components/TextInput/TextInput.d.ts +2 -0
  31. package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
  32. package/dist/js/components/TextInput/TextInput.js +3 -2
  33. package/dist/js/components/TextInput/TextInput.js.map +1 -1
  34. package/dist/umd/react-core.js +12 -9
  35. package/dist/umd/react-core.min.js +2 -2
  36. package/package.json +5 -5
  37. package/src/components/Avatar/Avatar.tsx +4 -0
  38. package/src/components/Avatar/examples/Avatar.md +33 -4
  39. package/src/components/ChipGroup/__tests__/ChipGroup.test.tsx +14 -9
  40. package/src/components/ClipboardCopy/__tests__/ClipboardCopyToggle.test.tsx +28 -19
  41. package/src/components/ClipboardCopy/__tests__/__snapshots__/ClipboardCopyToggle.test.tsx.snap +1 -1
  42. package/src/components/ContextSelector/__tests__/ContextSelector.test.tsx +21 -14
  43. package/src/components/ContextSelector/__tests__/ContextSelectorToggle.test.tsx +49 -34
  44. package/src/components/ContextSelector/__tests__/__snapshots__/ContextSelector.test.tsx.snap +2 -169
  45. package/src/components/ContextSelector/__tests__/__snapshots__/ContextSelectorToggle.test.tsx.snap +5 -247
  46. package/src/components/DataList/__tests__/DataList.test.tsx +49 -40
  47. package/src/components/DataList/__tests__/__snapshots__/DataList.test.tsx.snap +1 -9
  48. package/src/components/Dropdown/__tests__/Dropdown.test.tsx +54 -42
  49. package/src/components/Dropdown/__tests__/DropdownToggle.test.tsx +179 -177
  50. package/src/components/Dropdown/__tests__/DropdownToggleCheckbox.test.tsx +51 -55
  51. package/src/components/Dropdown/__tests__/Generated/DropdownItem.test.tsx +28 -26
  52. package/src/components/Dropdown/__tests__/Generated/DropdownSeparator.test.tsx +14 -15
  53. package/src/components/Dropdown/__tests__/Generated/InternalDropdownItem.test.tsx +39 -36
  54. package/src/components/Dropdown/__tests__/Generated/__snapshots__/DropdownItem.test.tsx.snap +6 -4
  55. package/src/components/Dropdown/__tests__/Generated/__snapshots__/DropdownSeparator.test.tsx.snap +11 -4
  56. package/src/components/Dropdown/__tests__/Generated/__snapshots__/InternalDropdownItem.test.tsx.snap +7 -4
  57. package/src/components/Dropdown/__tests__/InternalDropdownItem.test.tsx +66 -69
  58. package/src/components/Dropdown/__tests__/__snapshots__/Dropdown.test.tsx.snap +15 -816
  59. package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggle.test.tsx.snap +9 -454
  60. package/src/components/Dropdown/__tests__/__snapshots__/DropdownToggleCheckbox.test.tsx.snap +7 -141
  61. package/src/components/Dropdown/__tests__/__snapshots__/InternalDropdownItem.test.tsx.snap +10 -163
  62. package/src/components/FormSelect/FormSelect.tsx +16 -1
  63. package/src/components/FormSelect/examples/FormSelect.md +58 -0
  64. package/src/components/Nav/__tests__/Generated/NavList.test.tsx +28 -18
  65. package/src/components/Nav/__tests__/Generated/__snapshots__/NavList.test.tsx.snap +8 -4
  66. package/src/components/OptionsMenu/__tests__/Generated/OptionsMenuItem.test.tsx +21 -19
  67. package/src/components/OptionsMenu/__tests__/Generated/__snapshots__/OptionsMenuItem.test.tsx.snap +20 -11
  68. package/src/components/OverflowMenu/__tests__/Generated/OverflowMenuDropdownItem.test.tsx +14 -10
  69. package/src/components/OverflowMenu/__tests__/Generated/__snapshots__/OverflowMenuDropdownItem.test.tsx.snap +18 -4
  70. package/src/components/Select/__tests__/Generated/SelectGroup.test.tsx +22 -10
  71. package/src/components/Select/__tests__/Generated/SelectMenu.test.tsx +22 -26
  72. package/src/components/Select/__tests__/Generated/__snapshots__/SelectGroup.test.tsx.snap +15 -4
  73. package/src/components/Select/__tests__/Generated/__snapshots__/SelectMenu.test.tsx.snap +7 -19
  74. package/src/components/Select/__tests__/SelectGroup.test.tsx +14 -7
  75. package/src/components/Select/__tests__/SelectOption.test.tsx +51 -30
  76. package/src/components/Select/__tests__/__snapshots__/SelectGroup.test.tsx.snap +1 -5
  77. package/src/components/Select/__tests__/__snapshots__/SelectOption.test.tsx.snap +10 -272
  78. package/src/components/TextArea/TextArea.tsx +5 -0
  79. package/src/components/TextArea/__tests__/__snapshots__/TextArea.test.tsx.snap +2 -0
  80. package/src/components/TextArea/examples/TextArea.md +43 -0
  81. package/src/components/TextInput/TextInput.tsx +5 -0
  82. package/src/components/TextInput/__tests__/__snapshots__/TextInput.test.tsx.snap +2 -0
  83. package/src/components/TextInput/examples/TextInput.md +104 -27
  84. package/src/components/Toolbar/__tests__/Generated/ToolbarToggleGroup.test.tsx +25 -11
  85. package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarToggleGroup.test.tsx.snap +26 -4
  86. package/src/components/Toolbar/__tests__/Toolbar.test.tsx +129 -0
  87. package/src/components/Toolbar/__tests__/ToolbarItem.test.tsx +19 -0
  88. package/src/components/Toolbar/__tests__/ToolbarToggleGroup.test.tsx +12 -135
  89. package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +7 -0
  90. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.test.tsx.snap +3 -0
  91. package/src/components/Tooltip/examples/Tooltip.md +9 -1
  92. package/src/components/Tooltip/examples/TooltipExamples.css +4 -4
  93. package/src/components/Select/__tests__/Generated/SelectOption.test.tsx +0 -29
  94. package/src/components/Select/__tests__/Generated/__snapshots__/SelectOption.test.tsx.snap +0 -7
  95. package/src/components/Toolbar/__tests__/__snapshots__/ToolbarToggleGroup.test.tsx.snap +0 -516
  96. package/src/components/Wizard/__tests__/Generated/Wizard.test.tsx +0 -43
  97. package/src/components/Wizard/__tests__/Generated/__snapshots__/Wizard.test.tsx.snap +0 -69
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { shallow, mount } from 'enzyme';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+
4
5
  import { SelectOption, SelectOptionObject } from '../SelectOption';
5
6
  import { SelectProvider } from '../selectConstants';
6
7
 
@@ -18,43 +19,48 @@ class User implements SelectOptionObject {
18
19
  toString = (): string => `${this.title}: ${this.firstName} ${this.lastName}`;
19
20
  }
20
21
 
21
- describe('select options', () => {
22
+ describe('SelectOption', () => {
22
23
  test('renders with value parameter successfully', () => {
23
- const view = mount(
24
+ render(
24
25
  <SelectProvider
25
26
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
26
27
  >
27
- <SelectOption id="option-1" value="test" sendRef={jest.fn()} />
28
+ <SelectOption id="option-1" value="test" sendRef={jest.fn()} data-testid="test-id" />
28
29
  </SelectProvider>
29
30
  );
30
- expect(view.instance().props).toHaveProperty('value', 'test');
31
- expect(view).toMatchSnapshot();
31
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
32
32
  });
33
33
 
34
34
  test('renders with description successfully', () => {
35
- const view = render(
35
+ render(
36
36
  <SelectProvider
37
37
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
38
38
  >
39
- <SelectOption id="option-1" value="test" description="This is a description" sendRef={jest.fn()} />
39
+ <SelectOption
40
+ id="option-1"
41
+ value="test"
42
+ description="This is a description"
43
+ sendRef={jest.fn()}
44
+ data-testid="test-id"
45
+ />
40
46
  </SelectProvider>
41
47
  );
42
- expect(view.container).toMatchSnapshot();
48
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
43
49
  });
44
50
 
45
51
  test('renders with item count successfully', () => {
46
- const view = render(
52
+ render(
47
53
  <SelectProvider
48
54
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
49
55
  >
50
- <SelectOption id="option-1" value="test" itemCount={3} sendRef={jest.fn()} />
56
+ <SelectOption id="option-1" value="test" itemCount={3} sendRef={jest.fn()} data-testid="test-id" />
51
57
  </SelectProvider>
52
58
  );
53
- expect(view.container).toMatchSnapshot();
59
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
54
60
  });
55
61
 
56
62
  test('renders with custom display successfully', () => {
57
- const view = render(
63
+ render(
58
64
  <SelectProvider
59
65
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
60
66
  >
@@ -63,22 +69,22 @@ describe('select options', () => {
63
69
  </SelectOption>
64
70
  </SelectProvider>
65
71
  );
66
- expect(view.container).toMatchSnapshot();
72
+ expect(screen.getByText('test display').outerHTML).toMatchSnapshot();
67
73
  });
68
74
 
69
75
  test('renders with custom user object successfully', () => {
70
- const view = render(
76
+ render(
71
77
  <SelectProvider
72
78
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
73
79
  >
74
- <SelectOption id="option-1" value={new User('Mr.', 'Test', 'User')} sendRef={jest.fn()} />
80
+ <SelectOption id="option-1" value={new User('Mr.', 'Test', 'User')} sendRef={jest.fn()} data-testid="test-id" />
75
81
  </SelectProvider>
76
82
  );
77
- expect(view.container).toMatchSnapshot();
83
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
78
84
  });
79
85
 
80
86
  test('renders with custom display and custom user object successfully', () => {
81
- const view = render(
87
+ render(
82
88
  <SelectProvider
83
89
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
84
90
  >
@@ -87,11 +93,11 @@ describe('select options', () => {
87
93
  </SelectOption>
88
94
  </SelectProvider>
89
95
  );
90
- expect(view.container).toMatchSnapshot();
96
+ expect(screen.getByText('test display').outerHTML).toMatchSnapshot();
91
97
  });
92
98
 
93
99
  test('renders custom component', () => {
94
- const view = render(
100
+ render(
95
101
  <SelectProvider
96
102
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
97
103
  >
@@ -100,34 +106,47 @@ describe('select options', () => {
100
106
  </SelectOption>
101
107
  </SelectProvider>
102
108
  );
103
- expect(view.container).toMatchSnapshot();
109
+ expect(screen.getByText('test display').outerHTML).toMatchSnapshot();
104
110
  });
105
111
 
106
112
  describe('disabled', () => {
107
113
  test('renders disabled successfully', () => {
108
- const view = mount(
114
+ render(
109
115
  <SelectProvider
110
116
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
111
117
  >
112
- <SelectOption id="option-1" isDisabled value="test" sendRef={jest.fn()} />
118
+ <SelectOption id="option-1" isDisabled value="test" sendRef={jest.fn()} data-testid="test-id" />
113
119
  </SelectProvider>
114
120
  );
115
- expect(view.find('button').hasClass('pf-m-disabled')).toBe(true);
116
- expect(view).toMatchSnapshot();
121
+
122
+ expect(screen.getByText('test').className).toContain('pf-m-disabled');
123
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
117
124
  });
118
125
  });
119
126
 
120
127
  describe('is selected', () => {
121
128
  test('renders selected successfully', () => {
122
- const view = shallow(<SelectOption id="option-1" isSelected value="test" sendRef={jest.fn()} />);
123
- expect(view).toMatchSnapshot();
129
+ render(
130
+ <SelectProvider
131
+ value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
132
+ >
133
+ <SelectOption id="option-1" isSelected value="test" sendRef={jest.fn()} data-testid="test-id" />
134
+ </SelectProvider>
135
+ );
136
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
124
137
  });
125
138
  });
126
139
 
127
140
  describe('checked', () => {
128
141
  test('renders with checked successfully', () => {
129
- const view = shallow(<SelectOption id="option-1" isChecked value="test" sendRef={jest.fn()} />);
130
- expect(view).toMatchSnapshot();
142
+ render(
143
+ <SelectProvider
144
+ value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
145
+ >
146
+ <SelectOption id="option-1" isChecked value="test" sendRef={jest.fn()} data-testid="test-id" />
147
+ </SelectProvider>
148
+ );
149
+ expect(screen.getByTestId('test-id').outerHTML).toMatchSnapshot();
131
150
  });
132
151
  });
133
152
 
@@ -135,6 +154,7 @@ describe('select options', () => {
135
154
  test('generates warning when id is undefined and isFavorites is set', () => {
136
155
  const myMock = jest.fn() as any;
137
156
  global.console = { error: myMock } as any;
157
+
138
158
  render(
139
159
  <SelectProvider
140
160
  value={{ onSelect: () => {}, onFavorite: () => {}, onClose: () => {}, variant: 'single', inputIdPrefix: '' }}
@@ -142,6 +162,7 @@ describe('select options', () => {
142
162
  <SelectOption isFavorite value="test" sendRef={jest.fn()} />
143
163
  </SelectProvider>
144
164
  );
165
+
145
166
  expect(myMock).toBeCalled();
146
167
  });
147
168
  });
@@ -1,7 +1,3 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`select group renders with children successfully 1`] = `
4
- <ContextConsumer>
5
- <Component />
6
- </ContextConsumer>
7
- `;
3
+ exports[`SelectGroup renders with children successfully 1`] = `"<div data-testid=\\"test-id\\" class=\\"pf-c-select__menu-group\\"><div class=\\"pf-c-select__menu-group-title\\" id=\\"\\" aria-hidden=\\"true\\">test</div><ul role=\\"listbox\\"><div>child</div></ul></div>"`;
@@ -1,283 +1,21 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`select options checked renders with checked successfully 1`] = `
4
- <ContextConsumer>
5
- <Component />
6
- </ContextConsumer>
7
- `;
3
+ exports[`SelectOption checked renders with checked successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item\\" role=\\"option\\" type=\\"button\\">test</button>"`;
8
4
 
9
- exports[`select options disabled renders disabled successfully 1`] = `
10
- <SelectOption
11
- className=""
12
- component="button"
13
- id="option-1"
14
- index={0}
15
- inputId=""
16
- isChecked={false}
17
- isDisabled={true}
18
- isFavorite={null}
19
- isLastOptionBeforeFooter={[Function]}
20
- isLoad={false}
21
- isLoading={false}
22
- isNoResultsOption={false}
23
- isPlaceholder={false}
24
- isSelected={false}
25
- keyHandler={[Function]}
26
- onClick={[Function]}
27
- sendRef={
28
- [MockFunction] {
29
- "calls": Array [
30
- Array [
31
- null,
32
- null,
33
- null,
34
- 0,
35
- ],
36
- ],
37
- "results": Array [
38
- Object {
39
- "type": "return",
40
- "value": undefined,
41
- },
42
- ],
43
- }
44
- }
45
- setViewMoreNextIndex={[Function]}
46
- value="test"
47
- >
48
- <li
49
- className="pf-c-select__menu-wrapper"
50
- id="option-1"
51
- role="presentation"
52
- >
53
- <button
54
- aria-selected={null}
55
- className="pf-c-select__menu-item pf-m-disabled"
56
- onClick={[Function]}
57
- onKeyDown={[Function]}
58
- role="option"
59
- type="button"
60
- >
61
- test
62
- </button>
63
- </li>
64
- </SelectOption>
65
- `;
5
+ exports[`SelectOption disabled renders disabled successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item pf-m-disabled\\" role=\\"option\\" type=\\"button\\">test</button>"`;
66
6
 
67
- exports[`select options is selected renders selected successfully 1`] = `
68
- <ContextConsumer>
69
- <Component />
70
- </ContextConsumer>
71
- `;
7
+ exports[`SelectOption is selected renders selected successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item pf-m-selected\\" role=\\"option\\" aria-selected=\\"true\\" type=\\"button\\">test<span class=\\"pf-c-select__menu-item-icon\\"><svg style=\\"vertical-align: -0.125em;\\" fill=\\"currentColor\\" height=\\"1em\\" width=\\"1em\\" viewBox=\\"0 0 512 512\\" aria-hidden=\\"true\\" role=\\"img\\"><path d=\\"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z\\"></path></svg></span></button>"`;
72
8
 
73
- exports[`select options renders custom component 1`] = `
74
- <div>
75
- <li
76
- class="pf-c-select__menu-wrapper"
77
- id="option-1"
78
- role="presentation"
79
- >
80
- <div
81
- class="pf-c-select__menu-item"
82
- role="option"
83
- type="button"
84
- >
85
- <div>
86
- test display
87
- </div>
88
- </div>
89
- </li>
90
- </div>
91
- `;
9
+ exports[`SelectOption renders custom component 1`] = `"<div>test display</div>"`;
92
10
 
93
- exports[`select options renders with custom display and custom user object successfully 1`] = `
94
- <div>
95
- <li
96
- class="pf-c-select__menu-wrapper"
97
- id="option-1"
98
- role="presentation"
99
- >
100
- <button
101
- class="pf-c-select__menu-item"
102
- role="option"
103
- type="button"
104
- >
105
- <div>
106
- test display
107
- </div>
108
- </button>
109
- </li>
110
- </div>
111
- `;
11
+ exports[`SelectOption renders with custom display and custom user object successfully 1`] = `"<div>test display</div>"`;
112
12
 
113
- exports[`select options renders with custom display successfully 1`] = `
114
- <div>
115
- <li
116
- class="pf-c-select__menu-wrapper"
117
- id="option-1"
118
- role="presentation"
119
- >
120
- <button
121
- class="pf-c-select__menu-item"
122
- role="option"
123
- type="button"
124
- >
125
- <div>
126
- test display
127
- </div>
128
- </button>
129
- </li>
130
- </div>
131
- `;
13
+ exports[`SelectOption renders with custom display successfully 1`] = `"<div>test display</div>"`;
132
14
 
133
- exports[`select options renders with custom user object successfully 1`] = `
134
- <div>
135
- <li
136
- class="pf-c-select__menu-wrapper"
137
- id="option-1"
138
- role="presentation"
139
- >
140
- <button
141
- class="pf-c-select__menu-item"
142
- role="option"
143
- type="button"
144
- >
145
- Mr.: Test User
146
- </button>
147
- </li>
148
- </div>
149
- `;
15
+ exports[`SelectOption renders with custom user object successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item\\" role=\\"option\\" type=\\"button\\">Mr.: Test User</button>"`;
150
16
 
151
- exports[`select options renders with description successfully 1`] = `
152
- <div>
153
- <li
154
- class="pf-c-select__menu-wrapper"
155
- id="option-1"
156
- role="presentation"
157
- >
158
- <button
159
- class="pf-c-select__menu-item pf-m-description"
160
- role="option"
161
- type="button"
162
- >
163
- <span
164
- class="pf-c-select__menu-item-main"
165
- >
166
- test
167
- </span>
168
- <span
169
- class="pf-c-select__menu-item-description"
170
- >
171
- This is a description
172
- </span>
173
- </button>
174
- </li>
175
- </div>
176
- `;
17
+ exports[`SelectOption renders with description successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item pf-m-description\\" role=\\"option\\" type=\\"button\\"><span class=\\"pf-c-select__menu-item-main\\">test</span><span class=\\"pf-c-select__menu-item-description\\">This is a description</span></button>"`;
177
18
 
178
- exports[`select options renders with item count successfully 1`] = `
179
- <div>
180
- <li
181
- class="pf-c-select__menu-wrapper"
182
- id="option-1"
183
- role="presentation"
184
- >
185
- <button
186
- class="pf-c-select__menu-item"
187
- role="option"
188
- type="button"
189
- >
190
- <span
191
- class="pf-c-select__menu-item-row"
192
- >
193
- <span
194
- class="pf-c-select__menu-item-text"
195
- >
196
- test
197
- </span>
198
- <span
199
- class="pf-c-select__menu-item-count"
200
- >
201
- 3
202
- </span>
203
- </span>
204
- </button>
205
- </li>
206
- </div>
207
- `;
19
+ exports[`SelectOption renders with item count successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item\\" role=\\"option\\" type=\\"button\\"><span class=\\"pf-c-select__menu-item-row\\"><span class=\\"pf-c-select__menu-item-text\\">test</span><span class=\\"pf-c-select__menu-item-count\\">3</span></span></button>"`;
208
20
 
209
- exports[`select options renders with value parameter successfully 1`] = `
210
- <SelectOption
211
- className=""
212
- component="button"
213
- id="option-1"
214
- index={0}
215
- inputId=""
216
- isChecked={false}
217
- isDisabled={false}
218
- isFavorite={null}
219
- isLastOptionBeforeFooter={[Function]}
220
- isLoad={false}
221
- isLoading={false}
222
- isNoResultsOption={false}
223
- isPlaceholder={false}
224
- isSelected={false}
225
- keyHandler={[Function]}
226
- onClick={[Function]}
227
- sendRef={
228
- [MockFunction] {
229
- "calls": Array [
230
- Array [
231
- <button
232
- class="pf-c-select__menu-item"
233
- role="option"
234
- type="button"
235
- >
236
- test
237
- </button>,
238
- null,
239
- <li
240
- class="pf-c-select__menu-wrapper"
241
- id="option-1"
242
- role="presentation"
243
- >
244
- <button
245
- class="pf-c-select__menu-item"
246
- role="option"
247
- type="button"
248
- >
249
- test
250
- </button>
251
- </li>,
252
- 0,
253
- ],
254
- ],
255
- "results": Array [
256
- Object {
257
- "type": "return",
258
- "value": undefined,
259
- },
260
- ],
261
- }
262
- }
263
- setViewMoreNextIndex={[Function]}
264
- value="test"
265
- >
266
- <li
267
- className="pf-c-select__menu-wrapper"
268
- id="option-1"
269
- role="presentation"
270
- >
271
- <button
272
- aria-selected={null}
273
- className="pf-c-select__menu-item"
274
- onClick={[Function]}
275
- onKeyDown={[Function]}
276
- role="option"
277
- type="button"
278
- >
279
- test
280
- </button>
281
- </li>
282
- </SelectOption>
283
- `;
21
+ exports[`SelectOption renders with value parameter successfully 1`] = `"<button data-testid=\\"test-id\\" class=\\"pf-c-select__menu-item\\" role=\\"option\\" type=\\"button\\">test</button>"`;
@@ -20,6 +20,8 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC
20
20
  isDisabled?: boolean;
21
21
  /** Flag to show if the TextArea is read only. */
22
22
  isReadOnly?: boolean;
23
+ /** Use the external file instead of a data URI */
24
+ isIconSprite?: boolean;
23
25
  /** Flag to modify height based on contents. */
24
26
  autoResize?: boolean;
25
27
  /** Value to indicate if the textarea is modified to show that validation state.
@@ -46,6 +48,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
46
48
  className: '',
47
49
  isRequired: false,
48
50
  isDisabled: false,
51
+ isIconSprite: false,
49
52
  validated: 'default',
50
53
  resizeOrientation: 'both',
51
54
  'aria-label': null as string
@@ -86,6 +89,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
86
89
  validated,
87
90
  isRequired,
88
91
  isDisabled,
92
+ isIconSprite,
89
93
  isReadOnly,
90
94
  resizeOrientation,
91
95
  innerRef,
@@ -102,6 +106,7 @@ export class TextAreaBase extends React.Component<TextAreaProps> {
102
106
  <textarea
103
107
  className={css(
104
108
  styles.formControl,
109
+ isIconSprite && styles.modifiers.iconSprite,
105
110
  className,
106
111
  resizeOrientation !== TextAreResizeOrientation.both && styles.modifiers[orientation],
107
112
  validated === ValidatedOptions.success && styles.modifiers.success,
@@ -116,6 +116,7 @@ exports[`validated text area success 1`] = `
116
116
  className=""
117
117
  innerRef={null}
118
118
  isDisabled={false}
119
+ isIconSprite={false}
119
120
  isRequired={false}
120
121
  onChange={[MockFunction]}
121
122
  required={true}
@@ -148,6 +149,7 @@ exports[`validated text area warning 1`] = `
148
149
  className=""
149
150
  innerRef={null}
150
151
  isDisabled={false}
152
+ isIconSprite={false}
151
153
  isRequired={false}
152
154
  onChange={[MockFunction]}
153
155
  required={true}
@@ -207,3 +207,46 @@ import { TextArea } from '@patternfly/react-core';
207
207
  <TextArea aria-label="auto resizing text area example" autoResize />
208
208
  ```
209
209
 
210
+ ### Icon sprite variants
211
+
212
+ **Note:** The icons for the success, invalid, calendar, etc. variations in form control elements are applied as background images to the form element. By default, the image URLs for these icons are data URIs. However, there may be cases where data URIs are not ideal, such as in an application with a content security policy that disallows data URIs for security reasons. The `isIconSprite` variation changes the icon source to an external SVG file that serves as a sprite for all of the supported icons.
213
+
214
+ ```js isBeta
215
+ import React from 'react';
216
+ import { TextArea } from '@patternfly/react-core';
217
+
218
+ IconSpriteTextArea = () => {
219
+ const [success, setSuccess] = React.useState('');
220
+ const [warning, setWarning] = React.useState('');
221
+ const [error, setError] = React.useState('');
222
+
223
+ return (
224
+ <>
225
+ <TextArea
226
+ validated={ValidatedOptions.success}
227
+ isIconSprite
228
+ type="text"
229
+ onChange={value => setSuccess(value)}
230
+ aria-label="success icon sprite text area example"
231
+ />
232
+ <br />
233
+ <br />
234
+ <TextArea
235
+ validated={ValidatedOptions.warning}
236
+ isIconSprite
237
+ type="text"
238
+ onChange={value => setWarning(value)}
239
+ aria-label="warning icon sprite text input example"
240
+ />
241
+ <br />
242
+ <br />
243
+ <TextArea
244
+ validated={ValidatedOptions.error}
245
+ isIconSprite
246
+ type="text"
247
+ onChange={value => setError(value)}
248
+ aria-label="error icon sprite text area example"
249
+ />
250
+ </>
251
+ );
252
+ };
@@ -65,6 +65,8 @@ export interface TextInputProps
65
65
  onBlur?: (event?: any) => void;
66
66
  /** icon variant */
67
67
  iconVariant?: 'calendar' | 'clock' | 'search';
68
+ /** Use the external file instead of a data URI */
69
+ isIconSprite?: boolean;
68
70
  /** Custom icon url to set as the input's background-image */
69
71
  customIconUrl?: string;
70
72
  /** Dimensions for the custom icon set as the input's background-size */
@@ -84,6 +86,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
84
86
  validated: 'default' as 'success' | 'warning' | 'error' | 'default',
85
87
  isDisabled: false,
86
88
  isReadOnly: false,
89
+ isIconSprite: false,
87
90
  type: TextInputTypes.text,
88
91
  isLeftTruncated: false,
89
92
  onChange: (): any => undefined,
@@ -170,6 +173,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
170
173
  isReadOnly,
171
174
  isRequired,
172
175
  isDisabled,
176
+ isIconSprite,
173
177
  iconVariant,
174
178
  customIconUrl,
175
179
  customIconDimensions,
@@ -193,6 +197,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
193
197
  onBlur={this.onBlur}
194
198
  className={css(
195
199
  styles.formControl,
200
+ isIconSprite && styles.modifiers.iconSprite,
196
201
  validated === ValidatedOptions.success && styles.modifiers.success,
197
202
  validated === ValidatedOptions.warning && styles.modifiers.warning,
198
203
  ((iconVariant && iconVariant !== 'search') || customIconUrl) && styles.modifiers.icon,
@@ -90,6 +90,7 @@ exports[`validated text input success 1`] = `
90
90
  className=""
91
91
  innerRef={null}
92
92
  isDisabled={false}
93
+ isIconSprite={false}
93
94
  isLeftTruncated={false}
94
95
  isReadOnly={false}
95
96
  isRequired={false}
@@ -133,6 +134,7 @@ exports[`validated text input success 2`] = `
133
134
  className=""
134
135
  innerRef={null}
135
136
  isDisabled={false}
137
+ isIconSprite={false}
136
138
  isLeftTruncated={false}
137
139
  isReadOnly={false}
138
140
  isRequired={false}