@patternfly/react-core 4.224.10 → 4.224.13

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 (46) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/DragDrop/DragDrop.d.ts +1 -1
  3. package/dist/esm/components/DragDrop/DragDrop.d.ts.map +1 -1
  4. package/dist/esm/components/SearchInput/SearchInput.d.ts +7 -0
  5. package/dist/esm/components/SearchInput/SearchInput.d.ts.map +1 -1
  6. package/dist/esm/components/SearchInput/SearchInput.js +9 -4
  7. package/dist/esm/components/SearchInput/SearchInput.js.map +1 -1
  8. package/dist/js/components/DragDrop/DragDrop.d.ts +1 -1
  9. package/dist/js/components/DragDrop/DragDrop.d.ts.map +1 -1
  10. package/dist/js/components/SearchInput/SearchInput.d.ts +7 -0
  11. package/dist/js/components/SearchInput/SearchInput.d.ts.map +1 -1
  12. package/dist/js/components/SearchInput/SearchInput.js +9 -4
  13. package/dist/js/components/SearchInput/SearchInput.js.map +1 -1
  14. package/dist/umd/react-core.css +415 -617
  15. package/dist/umd/react-core.js +683 -705
  16. package/dist/umd/react-core.min.css +103 -305
  17. package/dist/umd/react-core.min.js +4 -4
  18. package/package.json +5 -5
  19. package/src/components/Accordion/__tests__/Accordion.test.tsx +134 -104
  20. package/src/components/Accordion/__tests__/AccordionContent.test.tsx +180 -0
  21. package/src/components/Accordion/__tests__/AccordionExpandedContentBody.test.tsx +33 -0
  22. package/src/components/Accordion/__tests__/AccordionItem.test.tsx +18 -0
  23. package/src/components/Accordion/__tests__/AccordionToggle.test.tsx +164 -0
  24. package/src/components/Accordion/__tests__/__snapshots__/Accordion.test.tsx.snap +1 -214
  25. package/src/components/Accordion/__tests__/__snapshots__/AccordionContent.test.tsx.snap +17 -0
  26. package/src/components/Accordion/__tests__/__snapshots__/AccordionExpandedContentBody.test.tsx.snap +19 -0
  27. package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.test.tsx.snap +7 -0
  28. package/src/components/Accordion/__tests__/__snapshots__/AccordionToggle.test.tsx.snap +25 -0
  29. package/src/components/ActionList/__tests__/ActionList.test.tsx +46 -11
  30. package/src/components/ActionList/__tests__/ActionListGroup.test.tsx +34 -7
  31. package/src/components/ActionList/__tests__/ActionListItem.test.tsx +34 -7
  32. package/src/components/ActionList/__tests__/__snapshots__/ActionList.test.tsx.snap +1 -11
  33. package/src/components/ActionList/__tests__/__snapshots__/ActionListGroup.test.tsx.snap +1 -1
  34. package/src/components/ActionList/__tests__/__snapshots__/ActionListItem.test.tsx.snap +1 -1
  35. package/src/components/DragDrop/DragDrop.tsx +1 -1
  36. package/src/components/Hint/__tests__/Hint.test.tsx +63 -10
  37. package/src/components/Hint/__tests__/HintBody.test.tsx +47 -0
  38. package/src/components/Hint/__tests__/HintFooter.test.tsx +47 -0
  39. package/src/components/Hint/__tests__/HintTitle.test.tsx +47 -0
  40. package/src/components/Hint/__tests__/__snapshots__/Hint.test.tsx.snap +1 -16
  41. package/src/components/Hint/__tests__/__snapshots__/HintBody.test.tsx.snap +13 -0
  42. package/src/components/Hint/__tests__/__snapshots__/HintFooter.test.tsx.snap +13 -0
  43. package/src/components/Hint/__tests__/__snapshots__/HintTitle.test.tsx.snap +13 -0
  44. package/src/components/SearchInput/SearchInput.tsx +32 -5
  45. package/src/components/SearchInput/__tests__/SearchInput.test.tsx +37 -0
  46. package/src/components/SearchInput/__tests__/__snapshots__/SearchInput.test.tsx.snap +193 -4
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import { render, screen } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+
5
+ import { HintTitle } from "../HintTitle";
6
+
7
+ test('renders without children', () => {
8
+ render(<HintTitle data-testid="HintTitle"></HintTitle>);
9
+
10
+ expect(screen.getByTestId('HintTitle')).toBeVisible();
11
+ });
12
+
13
+ test('renders children', () => {
14
+ render(<HintTitle>{<button>Test Me</button>}</HintTitle>);
15
+
16
+ expect(screen.getByRole('button', { name: 'Test Me' })).toBeVisible();
17
+ });
18
+
19
+ test('renders with class pf-c-hint__title', () => {
20
+ render(<HintTitle>Hint Body Test</HintTitle>);
21
+
22
+ const body = screen.getByText('Hint Body Test');
23
+
24
+ expect(body).toHaveClass('pf-c-hint__title');
25
+ });
26
+
27
+ test('renders with custom class names provided via prop', () => {
28
+ render(<HintTitle className="custom-classname">Hint Body Test</HintTitle>);
29
+
30
+ const body = screen.getByText('Hint Body Test');
31
+
32
+ expect(body).toHaveClass('custom-classname');
33
+ });
34
+
35
+ test('renders with inherited element props spread to the component', () => {
36
+ render(
37
+ <HintTitle aria-label="labelling-id">Test</HintTitle>
38
+ );
39
+
40
+ expect(screen.getByText('Test')).toHaveAccessibleName('labelling-id');
41
+ });
42
+
43
+ test('matches snapshot', () => {
44
+ const { asFragment } = render(<HintTitle>{<button>Test</button>}</HintTitle>);
45
+
46
+ expect(asFragment()).toMatchSnapshot();
47
+ });
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`simple hint 1`] = `
3
+ exports[`matches hint snapshot 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
6
  class="pf-c-hint"
@@ -8,21 +8,6 @@ exports[`simple hint 1`] = `
8
8
  <div
9
9
  class="pf-c-hint__actions"
10
10
  />
11
- <div
12
- class="pf-c-hint__title"
13
- >
14
- Title
15
- </div>
16
- <div
17
- class="pf-c-hint__body"
18
- >
19
- Body
20
- </div>
21
- <div
22
- class="pf-c-hint__footer"
23
- >
24
- Footer
25
- </div>
26
11
  </div>
27
12
  </DocumentFragment>
28
13
  `;
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`matches snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-hint__body"
7
+ >
8
+ <button>
9
+ Test
10
+ </button>
11
+ </div>
12
+ </DocumentFragment>
13
+ `;
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`matches snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-hint__footer"
7
+ >
8
+ <button>
9
+ Test
10
+ </button>
11
+ </div>
12
+ </DocumentFragment>
13
+ `;
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`matches snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="pf-c-hint__title"
7
+ >
8
+ <button>
9
+ Test
10
+ </button>
11
+ </div>
12
+ </DocumentFragment>
13
+ `;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
- import styles from '@patternfly/react-styles/css/components/SearchInput/search-input';
4
3
  import { Button, ButtonVariant } from '../Button';
5
4
  import { Badge } from '../Badge';
6
5
  import AngleDownIcon from '@patternfly/react-icons/dist/esm/icons/angle-down-icon';
@@ -12,6 +11,7 @@ import ArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/arrow-right-i
12
11
  import { AdvancedSearchMenu } from './AdvancedSearchMenu';
13
12
  import { TextInputGroup, TextInputGroupMain, TextInputGroupUtilities } from '../TextInputGroup';
14
13
  import { InputGroup } from '../InputGroup';
14
+ import { Popper } from '../../helpers';
15
15
 
16
16
  export interface SearchAttribute {
17
17
  /** The search attribute's value to be provided in the search input's query string.
@@ -83,6 +83,13 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
83
83
  /** Delimiter in the query string for pairing attributes with search values.
84
84
  * Required whenever attributes are passed as props */
85
85
  advancedSearchDelimiter?: string;
86
+ /** The container to append the menu to.
87
+ * If your menu is being cut off you can append it to an element higher up the DOM tree.
88
+ * Some examples:
89
+ * appendTo={() => document.body}
90
+ * appendTo={document.getElementById('target')}
91
+ */
92
+ appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
86
93
  }
87
94
 
88
95
  const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
@@ -112,6 +119,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
112
119
  nextNavigationButtonAriaLabel = 'Next',
113
120
  submitSearchButtonLabel = 'Search',
114
121
  isDisabled = false,
122
+ appendTo,
115
123
  ...props
116
124
  }: SearchInputProps) => {
117
125
  const [isSearchMenuOpen, setIsSearchMenuOpen] = React.useState(false);
@@ -277,11 +285,9 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
277
285
 
278
286
  if (!!onSearch || attributes.length > 0 || !!onToggleAdvancedSearch) {
279
287
  if (attributes.length > 0) {
280
- return (
281
- <div className={css(className, styles.searchInput)} ref={searchInputRef} {...props}>
282
- {buildSearchTextInputGroupWithExtraButtons()}
288
+ const AdvancedSearch = (
289
+ <span>
283
290
  <AdvancedSearchMenu
284
- className={styles.searchInputMenu}
285
291
  value={value}
286
292
  parentRef={searchInputRef}
287
293
  parentInputRef={searchInputInputRef}
@@ -298,8 +304,29 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
298
304
  getAttrValueMap={getAttrValueMap}
299
305
  isSearchMenuOpen={isSearchMenuOpen}
300
306
  />
307
+ </span>
308
+ );
309
+
310
+ const AdvancedSearchWithPopper = (
311
+ <div className={css(className)} ref={searchInputRef} {...props}>
312
+ <Popper
313
+ trigger={buildSearchTextInputGroupWithExtraButtons()}
314
+ popper={AdvancedSearch}
315
+ isVisible={isSearchMenuOpen}
316
+ enableFlip={true}
317
+ appendTo={() => appendTo || searchInputRef.current}
318
+ />
301
319
  </div>
302
320
  );
321
+
322
+ const AdvancedSearchInline = (
323
+ <div className={css(className)} ref={searchInputRef} {...props}>
324
+ {buildSearchTextInputGroupWithExtraButtons()}
325
+ {AdvancedSearch}
326
+ </div>
327
+ );
328
+
329
+ return appendTo !== 'inline' ? AdvancedSearchWithPopper : AdvancedSearchInline;
303
330
  }
304
331
 
305
332
  return buildSearchTextInputGroupWithExtraButtons({ ...searchInputProps });
@@ -81,6 +81,7 @@ describe('SearchInput', () => {
81
81
  test('advanced search with custom attributes', () => {
82
82
  const { asFragment } = render(
83
83
  <SearchInput
84
+ data-testid="test-id"
84
85
  attributes={[
85
86
  { attr: 'username', display: 'Username' },
86
87
  { attr: 'firstname', display: 'First name' }
@@ -102,7 +103,43 @@ describe('SearchInput', () => {
102
103
 
103
104
  userEvent.click(screen.getByRole('button', { name: 'Search' }));
104
105
 
106
+ userEvent.click(screen.getByRole('button', { name: 'Open advanced search' }));
107
+ expect(screen.getByTestId('test-id')).toContainElement(screen.getByText('First name'))
108
+
105
109
  expect(props.onSearch).toHaveBeenCalled();
106
110
  expect(asFragment()).toMatchSnapshot();
107
111
  });
112
+
113
+ test('advanced search with custom attributes and appendTo="inline', () => {
114
+ const {container} = render(
115
+ <SearchInput
116
+ data-testid="test-id"
117
+ attributes={[
118
+ { attr: 'test', display: 'test' },
119
+ ]}
120
+ appendTo='inline'
121
+ />
122
+ );
123
+
124
+ userEvent.click(screen.getByRole('button', { name: 'Open advanced search' }));
125
+
126
+ expect(screen.getByTestId('test-id')).toContainElement(screen.getByText('test'))
127
+ });
128
+
129
+ test('advanced search with custom attributes and appendTo external DOM element', () => {
130
+ const {container} = render(
131
+ <SearchInput
132
+ data-testid="test-id"
133
+ attributes={[
134
+ { attr: 'test', display: 'test' },
135
+ ]}
136
+ appendTo={document.body}
137
+ />
138
+ );
139
+
140
+ userEvent.click(screen.getByRole('button', { name: 'Open advanced search' }));
141
+
142
+ expect(screen.getByTestId('test-id')).not.toContainElement(screen.getByText('test'))
143
+ expect(document.body).toContainElement(screen.getByText('test'))
144
+ });
108
145
  });
@@ -3,7 +3,7 @@
3
3
  exports[`SearchInput advanced search 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
- class="pf-c-search-input"
6
+ class=""
7
7
  >
8
8
  <div
9
9
  class="pf-c-input-group"
@@ -125,7 +125,8 @@ exports[`SearchInput advanced search 1`] = `
125
125
  exports[`SearchInput advanced search with custom attributes 1`] = `
126
126
  <DocumentFragment>
127
127
  <div
128
- class="pf-c-search-input"
128
+ class=""
129
+ data-testid="test-id"
129
130
  >
130
131
  <div
131
132
  class="pf-c-input-group"
@@ -194,9 +195,9 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
194
195
  </div>
195
196
  <button
196
197
  aria-disabled="false"
197
- aria-expanded="false"
198
+ aria-expanded="true"
198
199
  aria-label="Open advanced search"
199
- class="pf-c-button pf-m-control"
200
+ class="pf-c-button pf-m-control pf-m-expanded"
200
201
  data-ouia-component-id="OUIA-Generated-Button-control-8"
201
202
  data-ouia-component-type="PF4/Button"
202
203
  data-ouia-safe="true"
@@ -240,6 +241,194 @@ exports[`SearchInput advanced search with custom attributes 1`] = `
240
241
  </svg>
241
242
  </button>
242
243
  </div>
244
+ <span
245
+ class=""
246
+ style="position: absolute; left: 0px; top: 0px; z-index: 9999; width: 0px;"
247
+ >
248
+ <div
249
+ class="pf-c-panel pf-m-raised"
250
+ >
251
+ <div
252
+ class="pf-c-panel__main"
253
+ >
254
+ <div
255
+ class="pf-c-panel__main-body"
256
+ >
257
+ <form
258
+ class="pf-c-form"
259
+ novalidate=""
260
+ >
261
+ <div
262
+ class="pf-c-form__group"
263
+ >
264
+ <div
265
+ class="pf-c-form__group-label"
266
+ >
267
+ <label
268
+ class="pf-c-form__label"
269
+ for="username_0"
270
+ >
271
+ <span
272
+ class="pf-c-form__label-text"
273
+ >
274
+ Username
275
+ </span>
276
+ </label>
277
+
278
+ </div>
279
+ <div
280
+ class="pf-c-form__group-control"
281
+ >
282
+ <input
283
+ aria-invalid="false"
284
+ class="pf-c-form-control"
285
+ data-ouia-component-id="OUIA-Generated-TextInputBase-1"
286
+ data-ouia-component-type="PF4/TextInput"
287
+ data-ouia-safe="true"
288
+ id="username_0"
289
+ type="text"
290
+ value="player"
291
+ />
292
+ </div>
293
+ </div>
294
+ <div
295
+ class="pf-c-form__group"
296
+ >
297
+ <div
298
+ class="pf-c-form__group-label"
299
+ >
300
+ <label
301
+ class="pf-c-form__label"
302
+ for="firstname_1"
303
+ >
304
+ <span
305
+ class="pf-c-form__label-text"
306
+ >
307
+ First name
308
+ </span>
309
+ </label>
310
+
311
+ </div>
312
+ <div
313
+ class="pf-c-form__group-control"
314
+ >
315
+ <input
316
+ aria-invalid="false"
317
+ class="pf-c-form-control"
318
+ data-ouia-component-id="OUIA-Generated-TextInputBase-2"
319
+ data-ouia-component-type="PF4/TextInput"
320
+ data-ouia-safe="true"
321
+ id="firstname_1"
322
+ type="text"
323
+ value="john"
324
+ />
325
+ </div>
326
+ </div>
327
+ <div
328
+ class="pf-c-form__group"
329
+ >
330
+ <div
331
+ class="pf-c-form__group-label"
332
+ >
333
+ <label
334
+ class="pf-c-form__label"
335
+ for="pf-random-id-2"
336
+ >
337
+ <span
338
+ class="pf-c-form__label-text"
339
+ >
340
+ Has words
341
+ </span>
342
+ </label>
343
+
344
+ </div>
345
+ <div
346
+ class="pf-c-form__group-control"
347
+ >
348
+ <input
349
+ aria-invalid="false"
350
+ class="pf-c-form-control"
351
+ data-ouia-component-id="OUIA-Generated-TextInputBase-3"
352
+ data-ouia-component-type="PF4/TextInput"
353
+ data-ouia-safe="true"
354
+ id="pf-random-id-2"
355
+ type="text"
356
+ value=""
357
+ />
358
+ </div>
359
+ </div>
360
+ <div
361
+ class="pf-c-form__group"
362
+ >
363
+ <div
364
+ class="pf-c-form__group-control"
365
+ >
366
+ <button
367
+ aria-disabled="false"
368
+ class="pf-c-button pf-m-link pf-m-inline"
369
+ data-ouia-component-id="OUIA-Generated-Button-link-1"
370
+ data-ouia-component-type="PF4/Button"
371
+ data-ouia-safe="true"
372
+ type="button"
373
+ >
374
+ Link
375
+ <span
376
+ class="pf-c-button__icon pf-m-end"
377
+ >
378
+ <svg
379
+ aria-hidden="true"
380
+ fill="currentColor"
381
+ height="1em"
382
+ role="img"
383
+ style="vertical-align: -0.125em;"
384
+ viewBox="0 0 448 512"
385
+ width="1em"
386
+ >
387
+ <path
388
+ d="M448 80v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48zm-88 16H248.029c-21.313 0-32.08 25.861-16.971 40.971l31.984 31.987L67.515 364.485c-4.686 4.686-4.686 12.284 0 16.971l31.029 31.029c4.687 4.686 12.285 4.686 16.971 0l195.526-195.526 31.988 31.991C358.058 263.977 384 253.425 384 231.979V120c0-13.255-10.745-24-24-24z"
389
+ />
390
+ </svg>
391
+ </span>
392
+ </button>
393
+ </div>
394
+ </div>
395
+ <div
396
+ class="pf-c-form__group pf-m-action"
397
+ >
398
+ <div
399
+ class="pf-c-form__group-control"
400
+ >
401
+ <div
402
+ class="pf-c-form__actions"
403
+ >
404
+ <button
405
+ aria-disabled="false"
406
+ class="pf-c-button pf-m-primary"
407
+ data-ouia-component-id="OUIA-Generated-Button-primary-1"
408
+ data-ouia-component-type="PF4/Button"
409
+ data-ouia-safe="true"
410
+ type="submit"
411
+ >
412
+ Search
413
+ </button>
414
+ <button
415
+ aria-disabled="false"
416
+ class="pf-c-button pf-m-link"
417
+ data-ouia-component-id="OUIA-Generated-Button-link-2"
418
+ data-ouia-component-type="PF4/Button"
419
+ data-ouia-safe="true"
420
+ type="reset"
421
+ >
422
+ Reset
423
+ </button>
424
+ </div>
425
+ </div>
426
+ </div>
427
+ </form>
428
+ </div>
429
+ </div>
430
+ </div>
431
+ </span>
243
432
  </div>
244
433
  </DocumentFragment>
245
434
  `;