@patternfly/react-core 4.273.3 → 4.274.0

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 (35) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/components/Chip/Chip.d.ts.map +1 -1
  3. package/components/Chip/Chip.js +5 -4
  4. package/components/Chip/Chip.js.map +1 -1
  5. package/components/Text/TextList.d.ts +2 -0
  6. package/components/Text/TextList.d.ts.map +1 -1
  7. package/components/Text/TextList.js +3 -2
  8. package/components/Text/TextList.js.map +1 -1
  9. package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
  10. package/dist/esm/components/Chip/Chip.js +5 -4
  11. package/dist/esm/components/Chip/Chip.js.map +1 -1
  12. package/dist/esm/components/Text/TextList.d.ts +2 -0
  13. package/dist/esm/components/Text/TextList.d.ts.map +1 -1
  14. package/dist/esm/components/Text/TextList.js +3 -2
  15. package/dist/esm/components/Text/TextList.js.map +1 -1
  16. package/dist/js/components/Chip/Chip.d.ts.map +1 -1
  17. package/dist/js/components/Chip/Chip.js +4 -4
  18. package/dist/js/components/Chip/Chip.js.map +1 -1
  19. package/dist/js/components/Text/TextList.d.ts +2 -0
  20. package/dist/js/components/Text/TextList.d.ts.map +1 -1
  21. package/dist/js/components/Text/TextList.js +3 -2
  22. package/dist/js/components/Text/TextList.js.map +1 -1
  23. package/dist/umd/react-core.min.js +2 -2
  24. package/package.json +2 -2
  25. package/src/components/Chip/Chip.tsx +4 -2
  26. package/src/components/Chip/__tests__/Chip.test.tsx +9 -0
  27. package/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +55 -0
  28. package/src/components/ChipGroup/__tests__/__snapshots__/ChipGroup.test.tsx.snap +4 -0
  29. package/src/components/Modal/examples/Modal.md +46 -11
  30. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +2 -0
  31. package/src/components/Text/TextList.tsx +5 -1
  32. package/src/components/Text/__tests__/TextList.test.tsx +5 -0
  33. package/src/components/Text/examples/Text.md +5 -0
  34. package/src/components/Text/examples/TextPlainList.tsx +24 -0
  35. package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.273.3",
3
+ "version": "4.274.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -71,5 +71,5 @@
71
71
  "react": "^16.8 || ^17 || ^18",
72
72
  "react-dom": "^16.8 || ^17 || ^18"
73
73
  },
74
- "gitHead": "9659281d5966e9cbd236a253af377bfc0f0719ae"
74
+ "gitHead": "be07a04be01d28b6c3bc0805cd4b5eeb1a774809"
75
75
  }
@@ -83,7 +83,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
83
83
  });
84
84
 
85
85
  renderOverflowChip = () => {
86
- const { children, className, onClick, ouiaId } = this.props;
86
+ const { children, className, onClick, ouiaId, ...props } = this.props;
87
87
  const Component = this.props.component as any;
88
88
  return (
89
89
  <Component
@@ -95,6 +95,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
95
95
  className={css(styles.chip, styles.modifiers.overflow, className)}
96
96
  {...(this.props.component === 'button' ? { type: 'button' } : {})}
97
97
  {...getOUIAProps('OverflowChip', ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
98
+ {...props}
98
99
  >
99
100
  <span className={css(styles.chipText)}>{children}</span>
100
101
  </Component>
@@ -102,7 +103,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
102
103
  };
103
104
 
104
105
  renderInnerChip(id: string) {
105
- const { children, className, onClick, closeBtnAriaLabel, isReadOnly, component, ouiaId } = this.props;
106
+ const { children, className, onClick, closeBtnAriaLabel, isReadOnly, component, ouiaId, ...props } = this.props;
106
107
  const Component = component as any;
107
108
  return (
108
109
  <Component
@@ -112,6 +113,7 @@ export class Chip extends React.Component<ChipProps, ChipState> {
112
113
  className={css(styles.chip, className)}
113
114
  {...(this.state.isTooltipVisible && { tabIndex: 0 })}
114
115
  {...getOUIAProps(Chip.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
116
+ {...props}
115
117
  >
116
118
  <span ref={this.span} className={css(styles.chipText)} id={id}>
117
119
  {children}
@@ -47,4 +47,13 @@ describe('Chip', () => {
47
47
  );
48
48
  expect(asFragment()).toMatchSnapshot();
49
49
  });
50
+
51
+ test("with role='gridcell'", () => {
52
+ const { asFragment } = render(
53
+ <Chip className="my-chp-cls" role="gridcell">
54
+ I'm a roled chip
55
+ </Chip>
56
+ );
57
+ expect(asFragment()).toMatchSnapshot();
58
+ });
50
59
  });
@@ -7,6 +7,8 @@ exports[`Chip closable 1`] = `
7
7
  data-ouia-component-id="OUIA-Generated-Chip-2"
8
8
  data-ouia-component-type="PF4/Chip"
9
9
  data-ouia-safe="true"
10
+ id="chip_one"
11
+ tooltipposition="top"
10
12
  >
11
13
  <span
12
14
  class="pf-c-chip__text"
@@ -50,6 +52,8 @@ exports[`Chip closable with tooltip 1`] = `
50
52
  data-ouia-component-id="OUIA-Generated-Chip-3"
51
53
  data-ouia-component-type="PF4/Chip"
52
54
  data-ouia-safe="true"
55
+ id="chip_one"
56
+ tooltipposition="top"
53
57
  >
54
58
  <span
55
59
  class="pf-c-chip__text"
@@ -94,6 +98,8 @@ exports[`Chip custom max-width text 1`] = `
94
98
  data-ouia-component-type="PF4/Chip"
95
99
  data-ouia-safe="true"
96
100
  style="--pf-c-chip__text--MaxWidth: 100px;"
101
+ textmaxwidth="100px"
102
+ tooltipposition="top"
97
103
  >
98
104
  <span
99
105
  class="pf-c-chip__text"
@@ -134,9 +140,12 @@ exports[`Chip overflow 1`] = `
134
140
  <DocumentFragment>
135
141
  <div
136
142
  class="pf-c-chip pf-m-overflow my-chp-cls"
143
+ closebtnarialabel="close"
144
+ component="div"
137
145
  data-ouia-component-id="OUIA-Generated-Chip-1"
138
146
  data-ouia-component-type="PF4/OverflowChip"
139
147
  data-ouia-safe="true"
148
+ tooltipposition="top"
140
149
  >
141
150
  <span
142
151
  class="pf-c-chip__text"
@@ -154,6 +163,7 @@ exports[`Chip readonly 1`] = `
154
163
  data-ouia-component-id="OUIA-Generated-Chip-4"
155
164
  data-ouia-component-type="PF4/Chip"
156
165
  data-ouia-safe="true"
166
+ tooltipposition="top"
157
167
  >
158
168
  <span
159
169
  class="pf-c-chip__text"
@@ -164,3 +174,48 @@ exports[`Chip readonly 1`] = `
164
174
  </div>
165
175
  </DocumentFragment>
166
176
  `;
177
+
178
+ exports[`Chip with role='gridcell' 1`] = `
179
+ <DocumentFragment>
180
+ <div
181
+ class="pf-c-chip my-chp-cls"
182
+ data-ouia-component-id="OUIA-Generated-Chip-6"
183
+ data-ouia-component-type="PF4/Chip"
184
+ data-ouia-safe="true"
185
+ role="gridcell"
186
+ tooltipposition="top"
187
+ >
188
+ <span
189
+ class="pf-c-chip__text"
190
+ id="pf-random-id-5"
191
+ >
192
+ I'm a roled chip
193
+ </span>
194
+ <button
195
+ aria-disabled="false"
196
+ aria-label="close"
197
+ aria-labelledby="remove_pf-random-id-5 pf-random-id-5"
198
+ class="pf-c-button pf-m-plain"
199
+ data-ouia-component-id="close"
200
+ data-ouia-component-type="PF4/Button"
201
+ data-ouia-safe="true"
202
+ id="remove_pf-random-id-5"
203
+ type="button"
204
+ >
205
+ <svg
206
+ aria-hidden="true"
207
+ fill="currentColor"
208
+ height="1em"
209
+ role="img"
210
+ style="vertical-align: -0.125em;"
211
+ viewBox="0 0 352 512"
212
+ width="1em"
213
+ >
214
+ <path
215
+ d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
216
+ />
217
+ </svg>
218
+ </button>
219
+ </div>
220
+ </DocumentFragment>
221
+ `;
@@ -25,6 +25,7 @@ exports[`ChipGroup chip group default 1`] = `
25
25
  data-ouia-component-id="OUIA-Generated-Chip-1"
26
26
  data-ouia-component-type="PF4/Chip"
27
27
  data-ouia-safe="true"
28
+ tooltipposition="top"
28
29
  >
29
30
  <span
30
31
  class="pf-c-chip__text"
@@ -96,6 +97,7 @@ exports[`ChipGroup chip group with category 1`] = `
96
97
  data-ouia-component-id="OUIA-Generated-Chip-2"
97
98
  data-ouia-component-type="PF4/Chip"
98
99
  data-ouia-safe="true"
100
+ tooltipposition="top"
99
101
  >
100
102
  <span
101
103
  class="pf-c-chip__text"
@@ -167,6 +169,7 @@ exports[`ChipGroup chip group with category and tooltip 1`] = `
167
169
  data-ouia-component-id="OUIA-Generated-Chip-9"
168
170
  data-ouia-component-type="PF4/Chip"
169
171
  data-ouia-safe="true"
172
+ tooltipposition="top"
170
173
  >
171
174
  <span
172
175
  class="pf-c-chip__text"
@@ -238,6 +241,7 @@ exports[`ChipGroup chip group with closable category 1`] = `
238
241
  data-ouia-component-id="OUIA-Generated-Chip-3"
239
242
  data-ouia-component-type="PF4/Chip"
240
243
  data-ouia-safe="true"
244
+ tooltipposition="top"
241
245
  >
242
246
  <span
243
247
  class="pf-c-chip__text"
@@ -13,84 +13,119 @@ import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
13
13
 
14
14
  ## Examples
15
15
 
16
- ### Basic
16
+ ### Basic modals
17
+
18
+ Basic modals give users the option to either confirm or cancel an action. To flag an open modal, use the `isOpen` property. To execute a callback when a modal is closed, use the `onClose` property.
17
19
 
18
20
  ```ts file="./ModalBasic.tsx"
19
21
  ```
20
22
 
21
- ### With description
23
+ ### Scrollable modals
24
+
25
+ To enable keyboard-accessible scrolling of a modal’s content, pass `tabIndex={0}` to the `<Modal>`.
26
+
27
+ ```ts file="ModalWithOverflowingContent.tsx"
28
+ ```
29
+
30
+ ### With a static description
31
+
32
+ To provide additional information about a modal, use the `description` property. Descriptions are static and do not scroll with other modal content.
22
33
 
23
34
  ```ts file="./ModalWithDescription.tsx"
24
35
  ```
25
36
 
26
37
  ### Top aligned
27
38
 
39
+ To override a modal's default center alignment, use the `position` property. In this example, `position` is set to "top", which moves the modal to the top of the screen.
40
+
28
41
  ```ts file="./ModalTopAligned.tsx"
29
42
  ```
30
43
 
31
- ### Small
44
+ ### Small modal
45
+
46
+ To adjust the size of a modal, use the `variant` property. Modal variants include "small", "medium", "large", and "default".
47
+
48
+ The following example displays a "small" modal by passing in `variant={ModalVariant.small}`.
32
49
 
33
50
  ```ts file="./ModalSmall.tsx"
34
51
  ```
35
52
 
36
- ### Medium
53
+ ### Medium modal
54
+
55
+ The following example displays a "medium" modal by passing in `variant={ModalVariant.medium}`.
37
56
 
38
57
  ```ts file="./ModalMedium.tsx"
39
58
  ```
40
59
 
41
- ### Large
60
+ ### Large modal
61
+
62
+ The following example displays a "large" modal by passing in `variant={ModalVariant.large}`.
42
63
 
43
64
  ```ts file="./ModalLarge.tsx"
44
65
  ```
45
66
 
46
67
  ### Custom width
47
68
 
69
+ To choose a specific width for a modal, use the `width` property. The following example has a `width` of "50%".
70
+
48
71
  ```ts file="./ModalCustomWidth.tsx"
49
72
  ```
50
73
 
51
74
  ### Custom header and footer
52
75
 
76
+ To add a custom header and footer to a modal, set the `header` and `footer` properties to a custom implementation. The following example passes title components into both the header and the footer and also passes an icon to the footer.
77
+
53
78
  ```ts file="./ModalCustomHeaderFooter.tsx"
54
79
  ```
55
80
 
56
81
  ### No header or footer
57
82
 
83
+ To exclusively present information in a modal, remove the `header` and/or `footer`.
84
+
58
85
  ```ts file="./ModalNoHeaderFooter.tsx"
59
86
  ```
60
87
 
61
88
  ### Title icon
62
89
 
90
+ To add an icon before a modal’s title, use the `titleIconVariant`, which can be set to one of the predefined variants -- "success", "danger", "warning", "info", and "default" -- or to an imported custom icon. The following example uses a "warning" variant.
91
+
63
92
  ```ts file="./ModalTitleIcon.tsx"
64
93
  ```
65
94
 
66
95
  ### Custom title icon
67
96
 
97
+ To add a custom icon before a modal’s title, set `titleIconVariant` to an imported custom icon. The following example imports and uses a bullhorn icon.
98
+
68
99
  ```ts file="./ModalCustomTitleIcon.tsx"
69
100
  ```
70
101
 
71
102
  ### With wizard
72
103
 
104
+ To guide users through a series of steps in a modal, you can add a [wizard](/components/wizard) to a modal. To configure the `<Wizard>`, pass an array that contains a “name” and “component” value for each step into the `steps` property.
105
+
73
106
  ```ts file="./ModalWithWizard.tsx"
74
107
  ```
75
108
 
76
109
  ### With dropdown
77
110
 
111
+ To present a menu of actions or links to a user, you can add a [dropdown](/components/dropdown) to a modal. To allow the dropdown to visually break out of the modal container, set the `menuAppendTo` property to “parent”. Handle the modal’s closing behavior by listening to the `onEscapePress` callback on the `<Modal>` component. This allows the "escape" key to collapse the dropdown without closing the entire modal.
112
+
78
113
  ```ts file="./ModalWithDropdown.tsx"
79
114
  ```
80
115
 
81
116
  ### With help
82
117
 
118
+ To help simplify and explain complex models, add a help [popover](/components/popover). Only place a help icon at the modal level if its information applies to all content in the modal. If the help popover is specific to a particular modal section, place the help icon beside that section instead.
119
+
83
120
  ```ts file="./ModalWithHelp.tsx"
84
121
  ```
85
122
 
86
123
  ### With form
87
124
 
88
- ```ts file="ModalWithForm.tsx"
89
- ```
90
-
91
- ### With overflowing content
125
+ To collect user input within a modal, you can add a [form](/components/form).
92
126
 
93
- If the content that you're passing to the modal is likely to overflow the modal content area, pass `tabIndex={0}` to the modal to enable keyboard accessible scrolling.
127
+ To submit the form from a button in the modal's footer (outside of the `<Form>`), set the button's `form` property equal to the form's id.
94
128
 
95
- ```ts file="ModalWithOverflowingContent.tsx"
129
+ ```ts file="ModalWithForm.tsx"
96
130
  ```
131
+
@@ -1859,6 +1859,7 @@ exports[`typeahead multi select renders selected successfully 1`] = `
1859
1859
  data-ouia-component-id="OUIA-Generated-Chip-1"
1860
1860
  data-ouia-component-type="PF4/Chip"
1861
1861
  data-ouia-safe="true"
1862
+ tooltipposition="top"
1862
1863
  >
1863
1864
  <span
1864
1865
  class="pf-c-chip__text"
@@ -1901,6 +1902,7 @@ exports[`typeahead multi select renders selected successfully 1`] = `
1901
1902
  data-ouia-component-id="OUIA-Generated-Chip-2"
1902
1903
  data-ouia-component-type="PF4/Chip"
1903
1904
  data-ouia-safe="true"
1905
+ tooltipposition="top"
1904
1906
  >
1905
1907
  <span
1906
1908
  class="pf-c-chip__text"
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import styles from '@patternfly/react-styles/css/components/Content/content';
2
3
  import { css } from '@patternfly/react-styles';
3
4
 
4
5
  export enum TextListVariants {
@@ -14,18 +15,21 @@ export interface TextListProps extends React.HTMLProps<HTMLElement> {
14
15
  className?: string;
15
16
  /** The text list component */
16
17
  component?: 'ul' | 'ol' | 'dl';
18
+ /** Modifies the list to include plain styling */
19
+ isPlain?: boolean;
17
20
  }
18
21
 
19
22
  export const TextList: React.FunctionComponent<TextListProps> = ({
20
23
  children = null,
21
24
  className = '',
22
25
  component = TextListVariants.ul,
26
+ isPlain = false,
23
27
  ...props
24
28
  }: TextListProps) => {
25
29
  const Component: any = component;
26
30
 
27
31
  return (
28
- <Component {...props} className={css(className)}>
32
+ <Component {...props} className={css(isPlain && styles.modifiers.plain, className)}>
29
33
  {children}
30
34
  </Component>
31
35
  );
@@ -41,6 +41,11 @@ test('Renders as "dl" element when component="dl"', () => {
41
41
  expect(screen.getByText('Test')).toHaveProperty('nodeName', 'DL');
42
42
  });
43
43
 
44
+ test('Renders with plain modifier class when isPlain is set to true', () => {
45
+ render(<TextList isPlain>Test</TextList>);
46
+ expect(screen.getByRole('list')).toHaveClass('pf-m-plain');
47
+ });
48
+
44
49
  test('Renders with inherited element props spread to the component', () => {
45
50
  render(<TextList aria-label="Test label">Test</TextList>);
46
51
  expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
@@ -29,6 +29,11 @@ Text components such as Text, TextList, TextListItem need to be placed within a
29
29
  ```ts file="./TextOrderedList.tsx"
30
30
  ```
31
31
 
32
+ ### Plain list
33
+
34
+ ```ts file="./TextPlainList.tsx"
35
+ ```
36
+
32
37
  ### Description list
33
38
 
34
39
  ```ts file="./TextDescriptionList.tsx"
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Text, TextVariants, TextContent, TextList, TextListVariants, TextListItem } from '@patternfly/react-core';
3
+
4
+ export const TextPlainList: React.FunctionComponent = () => (
5
+ <TextContent>
6
+ <Text component={TextVariants.h3}>Plain unordered list</Text>
7
+ <TextList isPlain>
8
+ <TextListItem>In fermentum leo eu lectus mollis, quis dictum mi aliquet.</TextListItem>
9
+ <TextListItem>Morbi eu nulla lobortis, lobortis est in, fringilla felis.</TextListItem>
10
+ <TextListItem>Aliquam nec felis in sapien venenatis viverra fermentum nec lectus.</TextListItem>
11
+ <TextListItem>Ut non enim metus.</TextListItem>
12
+ </TextList>
13
+ <Text component={TextVariants.h3}>Plain ordered list</Text>
14
+ <TextList component={TextListVariants.ol} isPlain>
15
+ <TextListItem>Donec blandit a lorem id convallis.</TextListItem>
16
+ <TextListItem>Cras gravida arcu at diam gravida gravida.</TextListItem>
17
+ <TextListItem>Integer in volutpat libero.</TextListItem>
18
+ <TextListItem>Donec a diam tellus.</TextListItem>
19
+ <TextListItem>Aenean nec tortor orci.</TextListItem>
20
+ <TextListItem>Quisque aliquam cursus urna, non bibendum massa viverra eget.</TextListItem>
21
+ <TextListItem>Vivamus maximus ultricies pulvinar.</TextListItem>
22
+ </TextList>
23
+ </TextContent>
24
+ );
@@ -297,6 +297,7 @@ exports[`Toolbar should render with custom chip content 1`] = `
297
297
  data-ouia-component-id="OUIA-Generated-Chip-1"
298
298
  data-ouia-component-type="PF4/Chip"
299
299
  data-ouia-safe="true"
300
+ tooltipposition="top"
300
301
  >
301
302
  <span
302
303
  class="pf-c-chip__text"
@@ -339,6 +340,7 @@ exports[`Toolbar should render with custom chip content 1`] = `
339
340
  data-ouia-component-id="OUIA-Generated-Chip-2"
340
341
  data-ouia-component-type="PF4/Chip"
341
342
  data-ouia-safe="true"
343
+ tooltipposition="top"
342
344
  >
343
345
  <span
344
346
  class="pf-c-chip__text"