@patternfly/react-core 4.276.3 → 4.276.5

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 (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/components/Alert/Alert.d.ts +3 -1
  3. package/components/Alert/Alert.d.ts.map +1 -1
  4. package/components/Alert/Alert.js +13 -8
  5. package/components/Alert/Alert.js.map +1 -1
  6. package/components/Chip/Chip.d.ts.map +1 -1
  7. package/components/Chip/Chip.js +16 -4
  8. package/components/Chip/Chip.js.map +1 -1
  9. package/dist/esm/components/Alert/Alert.d.ts +3 -1
  10. package/dist/esm/components/Alert/Alert.d.ts.map +1 -1
  11. package/dist/esm/components/Alert/Alert.js +13 -8
  12. package/dist/esm/components/Alert/Alert.js.map +1 -1
  13. package/dist/esm/components/Chip/Chip.d.ts.map +1 -1
  14. package/dist/esm/components/Chip/Chip.js +16 -4
  15. package/dist/esm/components/Chip/Chip.js.map +1 -1
  16. package/dist/js/components/Alert/Alert.d.ts +3 -1
  17. package/dist/js/components/Alert/Alert.d.ts.map +1 -1
  18. package/dist/js/components/Alert/Alert.js +13 -8
  19. package/dist/js/components/Alert/Alert.js.map +1 -1
  20. package/dist/js/components/Chip/Chip.d.ts.map +1 -1
  21. package/dist/js/components/Chip/Chip.js +16 -4
  22. package/dist/js/components/Chip/Chip.js.map +1 -1
  23. package/dist/umd/react-core.min.js +1 -1
  24. package/package.json +2 -2
  25. package/src/components/Alert/Alert.tsx +21 -10
  26. package/src/components/Alert/examples/Alert.md +7 -4
  27. package/src/components/Chip/Chip.tsx +36 -6
  28. package/src/components/Chip/__tests__/__snapshots__/Chip.test.tsx.snap +0 -8
  29. package/src/components/ChipGroup/__tests__/__snapshots__/ChipGroup.test.tsx.snap +0 -4
  30. package/src/components/Select/__tests__/__snapshots__/Select.test.tsx.snap +0 -2
  31. package/src/components/Toolbar/__tests__/__snapshots__/Toolbar.test.tsx.snap +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.276.3",
3
+ "version": "4.276.5",
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": "91180feefa57c641752c4b5134669ffc497e8dc8"
74
+ "gitHead": "df6e176375bb8f52dc9b1ef06909e6a7f85d1923"
75
75
  }
@@ -57,8 +57,10 @@ export interface AlertProps extends Omit<React.HTMLProps<HTMLDivElement>, 'actio
57
57
  timeoutAnimation?: number;
58
58
  /** Title of the alert. */
59
59
  title: React.ReactNode;
60
- /** Sets the heading level to use for the alert title. Default is h4. */
60
+ /** @deprecated Sets the heading level to use for the alert title. Default is h4. */
61
61
  titleHeadingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
62
+ /** Sets the element to use as the alert title. Default is h4. */
63
+ component?: keyof JSX.IntrinsicElements;
62
64
  /** Adds accessible text to the alert toggle. */
63
65
  toggleAriaLabel?: string;
64
66
  /** Position of the tooltip which is displayed if text is truncated. */
@@ -99,7 +101,8 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
99
101
  actionClose,
100
102
  actionLinks,
101
103
  title,
102
- titleHeadingLevel: TitleHeadingLevel = 'h4',
104
+ titleHeadingLevel,
105
+ component = 'h4',
103
106
  children = '',
104
107
  className = '',
105
108
  ouiaId,
@@ -126,6 +129,14 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
126
129
  );
127
130
 
128
131
  const titleRef = React.useRef(null);
132
+ const TitleComponent = (titleHeadingLevel || component) as any;
133
+ if (titleHeadingLevel !== undefined) {
134
+ // eslint-disable-next-line no-console
135
+ console.warn(
136
+ 'Alert: titleHeadingLevel is deprecated, please use the newer component prop instead to set the alert title element.'
137
+ );
138
+ }
139
+
129
140
  const divRef = React.useRef<HTMLDivElement>();
130
141
  const [isTooltipVisible, setIsTooltipVisible] = useState(false);
131
142
  React.useEffect(() => {
@@ -145,12 +156,12 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
145
156
  const [containsFocus, setContainsFocus] = useState<boolean | undefined>();
146
157
  const dismissed = timedOut && timedOutAnimation && !isMouseOver && !containsFocus;
147
158
  React.useEffect(() => {
148
- timeout = timeout === true ? 8000 : Number(timeout);
149
- if (timeout > 0) {
150
- const timer = setTimeout(() => setTimedOut(true), timeout);
159
+ const calculatedTimeout = timeout === true ? 8000 : Number(timeout);
160
+ if (calculatedTimeout > 0) {
161
+ const timer = setTimeout(() => setTimedOut(true), calculatedTimeout);
151
162
  return () => clearTimeout(timer);
152
163
  }
153
- }, []);
164
+ }, [timeout]);
154
165
  React.useEffect(() => {
155
166
  const onDocumentFocus = () => {
156
167
  if (divRef.current) {
@@ -172,10 +183,10 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
172
183
  const timer = setTimeout(() => setTimedOutAnimation(true), timeoutAnimation);
173
184
  return () => clearTimeout(timer);
174
185
  }
175
- }, [containsFocus, isMouseOver]);
186
+ }, [containsFocus, isMouseOver, timeoutAnimation]);
176
187
  React.useEffect(() => {
177
188
  dismissed && onTimeout();
178
- }, [dismissed]);
189
+ }, [dismissed, onTimeout]);
179
190
 
180
191
  const [isExpanded, setIsExpanded] = useState(false);
181
192
  const onToggleExpand = () => {
@@ -197,13 +208,13 @@ export const Alert: React.FunctionComponent<AlertProps> = ({
197
208
  return null;
198
209
  }
199
210
  const Title = (
200
- <TitleHeadingLevel
211
+ <TitleComponent
201
212
  {...(isTooltipVisible && { tabIndex: 0 })}
202
213
  ref={titleRef}
203
214
  className={css(styles.alertTitle, truncateTitle && styles.modifiers.truncate)}
204
215
  >
205
216
  {getHeadingContent}
206
- </TitleHeadingLevel>
217
+ </TitleComponent>
207
218
  );
208
219
 
209
220
  return (
@@ -50,8 +50,9 @@ PatternFly supports several properties and variations that can be used to add ex
50
50
 
51
51
  * As demonstrated in the 3rd and 4th variations below, use the `actionClose` property to add an `<AlertActionCloseButton>` component, which can be used to manage and customize alert dismissals. `actionClose` can be used with or without the presence of `actionLinks`.
52
52
 
53
- * As demonstrated in the 5th and 6th variations below, use the `titleHeadingLevel` property to set the heading level of an alert title. Headings should be ordered by their level and heading levels should not be skipped. For example, a heading of an `h2` level should not be followed directly by an `h4`.
54
-
53
+ * As demonstrated in the 5th and 6th variations below, use the `component` property to set the element for an alert title.
54
+ * If the `description` prop is not passed in, then the `component` prop should be set to a non-heading element such as a `span` or `div`.
55
+ * If the `description` prop is passed in, then the `component` prop should be a heading element. Headings should be ordered by their level and heading levels should not be skipped. For example, a heading of an `h2` level should not be followed directly by an `h4`.
55
56
  ```ts
56
57
  import React from 'react';
57
58
  import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/react-core';
@@ -88,8 +89,10 @@ import { Alert, AlertActionCloseButton, AlertActionLink } from '@patternfly/reac
88
89
  }
89
90
  />
90
91
  <Alert variant="success" title="Success alert title" actionClose={<AlertActionCloseButton onClose={() => alert('Clicked the close button')} />} />
91
- <Alert variant="success" title="h1 Success alert title" titleHeadingLevel="h1" />
92
- <Alert variant="success" title="h6 Success alert title" titleHeadingLevel="h6" />
92
+ <Alert variant="success" title="div success alert title" component="div" />
93
+ <Alert variant="success" title="h6 Success alert title" component="h6" >
94
+ <p>Short alert description</p>
95
+ </Alert>
93
96
  </React.Fragment>
94
97
  ```
95
98
  ### Alert timeout
@@ -83,17 +83,34 @@ export class Chip extends React.Component<ChipProps, ChipState> {
83
83
  });
84
84
 
85
85
  renderOverflowChip = () => {
86
- const { children, className, onClick, ouiaId, ...props } = this.props;
87
- const Component = this.props.component as any;
86
+ const {
87
+ children,
88
+ className,
89
+ onClick,
90
+ ouiaId,
91
+ textMaxWidth,
92
+ style,
93
+ component,
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
95
+ tooltipPosition,
96
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
97
+ isOverflowChip,
98
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
99
+ closeBtnAriaLabel,
100
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
101
+ isReadOnly,
102
+ ...props
103
+ } = this.props;
104
+ const Component = component as any;
88
105
  return (
89
106
  <Component
90
107
  onClick={onClick}
91
- {...(this.props.textMaxWidth && {
108
+ {...(textMaxWidth && {
92
109
  style: this.setChipStyle(),
93
- ...this.props.style
110
+ ...style
94
111
  })}
95
112
  className={css(styles.chip, styles.modifiers.overflow, className)}
96
- {...(this.props.component === 'button' ? { type: 'button' } : {})}
113
+ {...(component === 'button' ? { type: 'button' } : {})}
97
114
  {...getOUIAProps('OverflowChip', ouiaId !== undefined ? ouiaId : this.state.ouiaStateId)}
98
115
  {...props}
99
116
  >
@@ -103,7 +120,20 @@ export class Chip extends React.Component<ChipProps, ChipState> {
103
120
  };
104
121
 
105
122
  renderInnerChip(id: string) {
106
- const { children, className, onClick, closeBtnAriaLabel, isReadOnly, component, ouiaId, ...props } = this.props;
123
+ const {
124
+ children,
125
+ className,
126
+ onClick,
127
+ closeBtnAriaLabel,
128
+ isReadOnly,
129
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
130
+ isOverflowChip,
131
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
132
+ tooltipPosition,
133
+ component,
134
+ ouiaId,
135
+ ...props
136
+ } = this.props;
107
137
  const Component = component as any;
108
138
  return (
109
139
  <Component
@@ -8,7 +8,6 @@ exports[`Chip closable 1`] = `
8
8
  data-ouia-component-type="PF4/Chip"
9
9
  data-ouia-safe="true"
10
10
  id="chip_one"
11
- tooltipposition="top"
12
11
  >
13
12
  <span
14
13
  class="pf-c-chip__text"
@@ -53,7 +52,6 @@ exports[`Chip closable with tooltip 1`] = `
53
52
  data-ouia-component-type="PF4/Chip"
54
53
  data-ouia-safe="true"
55
54
  id="chip_one"
56
- tooltipposition="top"
57
55
  >
58
56
  <span
59
57
  class="pf-c-chip__text"
@@ -99,7 +97,6 @@ exports[`Chip custom max-width text 1`] = `
99
97
  data-ouia-safe="true"
100
98
  style="--pf-c-chip__text--MaxWidth: 100px;"
101
99
  textmaxwidth="100px"
102
- tooltipposition="top"
103
100
  >
104
101
  <span
105
102
  class="pf-c-chip__text"
@@ -140,12 +137,9 @@ exports[`Chip overflow 1`] = `
140
137
  <DocumentFragment>
141
138
  <div
142
139
  class="pf-c-chip pf-m-overflow my-chp-cls"
143
- closebtnarialabel="close"
144
- component="div"
145
140
  data-ouia-component-id="OUIA-Generated-Chip-1"
146
141
  data-ouia-component-type="PF4/OverflowChip"
147
142
  data-ouia-safe="true"
148
- tooltipposition="top"
149
143
  >
150
144
  <span
151
145
  class="pf-c-chip__text"
@@ -163,7 +157,6 @@ exports[`Chip readonly 1`] = `
163
157
  data-ouia-component-id="OUIA-Generated-Chip-4"
164
158
  data-ouia-component-type="PF4/Chip"
165
159
  data-ouia-safe="true"
166
- tooltipposition="top"
167
160
  >
168
161
  <span
169
162
  class="pf-c-chip__text"
@@ -183,7 +176,6 @@ exports[`Chip with role='gridcell' 1`] = `
183
176
  data-ouia-component-type="PF4/Chip"
184
177
  data-ouia-safe="true"
185
178
  role="gridcell"
186
- tooltipposition="top"
187
179
  >
188
180
  <span
189
181
  class="pf-c-chip__text"
@@ -25,7 +25,6 @@ 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"
29
28
  >
30
29
  <span
31
30
  class="pf-c-chip__text"
@@ -97,7 +96,6 @@ exports[`ChipGroup chip group with category 1`] = `
97
96
  data-ouia-component-id="OUIA-Generated-Chip-2"
98
97
  data-ouia-component-type="PF4/Chip"
99
98
  data-ouia-safe="true"
100
- tooltipposition="top"
101
99
  >
102
100
  <span
103
101
  class="pf-c-chip__text"
@@ -169,7 +167,6 @@ exports[`ChipGroup chip group with category and tooltip 1`] = `
169
167
  data-ouia-component-id="OUIA-Generated-Chip-9"
170
168
  data-ouia-component-type="PF4/Chip"
171
169
  data-ouia-safe="true"
172
- tooltipposition="top"
173
170
  >
174
171
  <span
175
172
  class="pf-c-chip__text"
@@ -241,7 +238,6 @@ exports[`ChipGroup chip group with closable category 1`] = `
241
238
  data-ouia-component-id="OUIA-Generated-Chip-3"
242
239
  data-ouia-component-type="PF4/Chip"
243
240
  data-ouia-safe="true"
244
- tooltipposition="top"
245
241
  >
246
242
  <span
247
243
  class="pf-c-chip__text"
@@ -1859,7 +1859,6 @@ 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"
1863
1862
  >
1864
1863
  <span
1865
1864
  class="pf-c-chip__text"
@@ -1902,7 +1901,6 @@ exports[`typeahead multi select renders selected successfully 1`] = `
1902
1901
  data-ouia-component-id="OUIA-Generated-Chip-2"
1903
1902
  data-ouia-component-type="PF4/Chip"
1904
1903
  data-ouia-safe="true"
1905
- tooltipposition="top"
1906
1904
  >
1907
1905
  <span
1908
1906
  class="pf-c-chip__text"
@@ -297,7 +297,6 @@ 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"
301
300
  >
302
301
  <span
303
302
  class="pf-c-chip__text"
@@ -340,7 +339,6 @@ exports[`Toolbar should render with custom chip content 1`] = `
340
339
  data-ouia-component-id="OUIA-Generated-Chip-2"
341
340
  data-ouia-component-type="PF4/Chip"
342
341
  data-ouia-safe="true"
343
- tooltipposition="top"
344
342
  >
345
343
  <span
346
344
  class="pf-c-chip__text"