@patternfly/react-core 4.202.0 → 4.202.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.202.0",
3
+ "version": "4.202.1",
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",
@@ -34,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.53.0",
38
- "@patternfly/react-styles": "^4.52.0",
39
- "@patternfly/react-tokens": "^4.54.0",
37
+ "@patternfly/react-icons": "^4.53.1",
38
+ "@patternfly/react-styles": "^4.52.1",
39
+ "@patternfly/react-tokens": "^4.54.1",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -60,5 +60,5 @@
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },
63
- "gitHead": "a328f46967c052f0d72d77dff763ecbb3318bc4e"
63
+ "gitHead": "fc88ddd5f942598163a34ad5a8df86215cc7a6a5"
64
64
  }
@@ -3,7 +3,7 @@ import { css } from '@patternfly/react-styles';
3
3
  import styles from '@patternfly/react-styles/css/components/DescriptionList/description-list';
4
4
  import { formatBreakpointMods } from '../../helpers';
5
5
 
6
- export interface AutoFitModifiers {
6
+ export interface BreakpointModifiers {
7
7
  default?: string;
8
8
  md?: string;
9
9
  lg?: string;
@@ -30,7 +30,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
30
30
  isFluid?: boolean;
31
31
  /** Sets the the default placement of description list groups to fill from top to bottom. */
32
32
  isFillColumns?: boolean;
33
- /** Sets the number of columns on the description list */
33
+ /** Sets the number of columns on the description list at various breakpoints */
34
34
  columnModifier?: {
35
35
  default?: '1Col' | '2Col' | '3Col';
36
36
  sm?: '1Col' | '2Col' | '3Col';
@@ -39,7 +39,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
39
39
  xl?: '1Col' | '2Col' | '3Col';
40
40
  '2xl'?: '1Col' | '2Col' | '3Col';
41
41
  };
42
- /** Indicates how the menu will align at screen size breakpoints. Default alignment is set via the position property. */
42
+ /** Indicates how the menu will align at various breakpoints. */
43
43
  orientation?: {
44
44
  sm?: 'vertical' | 'horizontal';
45
45
  md?: 'vertical' | 'horizontal';
@@ -47,6 +47,7 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
47
47
  xl?: 'vertical' | 'horizontal';
48
48
  '2xl'?: 'vertical' | 'horizontal';
49
49
  };
50
+ /** Sets the minimum column size for the auto-fit (isAutoFit) layout at various breakpoints. */
50
51
  autoFitMinModifier?: {
51
52
  default?: string;
52
53
  sm?: string;
@@ -55,11 +56,19 @@ export interface DescriptionListProps extends Omit<React.HTMLProps<HTMLDListElem
55
56
  xl?: string;
56
57
  '2xl'?: string;
57
58
  };
59
+ /** Sets the horizontal description list's term column width at various breakpoints. */
60
+ horizontalTermWidthModifier?: {
61
+ default?: string;
62
+ sm?: string;
63
+ md?: string;
64
+ lg?: string;
65
+ xl?: string;
66
+ '2xl'?: string;
67
+ };
58
68
  }
59
69
 
60
- const setAutoFitMinModifiers = (autoFitMinModifier: AutoFitModifiers) => {
61
- const prefix = '--pf-c-description-list--GridTemplateColumns--min';
62
- const mods = autoFitMinModifier as Partial<{ [k: string]: string }>;
70
+ const setBreakpointModifiers = (prefix: string, modifiers: BreakpointModifiers) => {
71
+ const mods = modifiers as Partial<{ [k: string]: string }>;
63
72
  return Object.keys(mods || {}).reduce(
64
73
  (acc, curr) =>
65
74
  curr === 'default' ? { ...acc, [prefix]: mods[curr] } : { ...acc, [`${prefix}-on-${curr}`]: mods[curr] },
@@ -79,33 +88,45 @@ export const DescriptionList: React.FunctionComponent<DescriptionListProps> = ({
79
88
  isFillColumns,
80
89
  columnModifier,
81
90
  autoFitMinModifier,
91
+ horizontalTermWidthModifier,
82
92
  orientation,
83
93
  style,
84
94
  ...props
85
- }: DescriptionListProps) => (
86
- <dl
87
- className={css(
88
- styles.descriptionList,
89
- (isHorizontal || isFluid) && styles.modifiers.horizontal,
90
- isAutoColumnWidths && styles.modifiers.autoColumnWidths,
91
- isAutoFit && styles.modifiers.autoFit,
92
- formatBreakpointMods(columnModifier, styles),
93
- formatBreakpointMods(orientation, styles),
94
- isInlineGrid && styles.modifiers.inlineGrid,
95
- isCompact && styles.modifiers.compact,
96
- isFluid && styles.modifiers.fluid,
97
- isFillColumns && styles.modifiers.fillColumns,
98
- className
99
- )}
100
- style={
101
- autoFitMinModifier || style
102
- ? { ...(isAutoFit ? setAutoFitMinModifiers(autoFitMinModifier) : {}), ...style }
103
- : undefined
104
- }
105
- {...props}
106
- >
107
- {children}
108
- </dl>
109
- );
95
+ }: DescriptionListProps) => {
96
+ if (isAutoFit && autoFitMinModifier) {
97
+ style = {
98
+ ...style,
99
+ ...setBreakpointModifiers('--pf-c-description-list--GridTemplateColumns--min', autoFitMinModifier)
100
+ };
101
+ }
102
+ if (isHorizontal && horizontalTermWidthModifier) {
103
+ style = {
104
+ ...style,
105
+ ...setBreakpointModifiers('--pf-c-description-list--m-horizontal__term--width', horizontalTermWidthModifier)
106
+ };
107
+ }
108
+
109
+ return (
110
+ <dl
111
+ className={css(
112
+ styles.descriptionList,
113
+ (isHorizontal || isFluid) && styles.modifiers.horizontal,
114
+ isAutoColumnWidths && styles.modifiers.autoColumnWidths,
115
+ isAutoFit && styles.modifiers.autoFit,
116
+ formatBreakpointMods(columnModifier, styles),
117
+ formatBreakpointMods(orientation, styles),
118
+ isInlineGrid && styles.modifiers.inlineGrid,
119
+ isCompact && styles.modifiers.compact,
120
+ isFluid && styles.modifiers.fluid,
121
+ isFillColumns && styles.modifiers.fillColumns,
122
+ className
123
+ )}
124
+ style={style}
125
+ {...props}
126
+ >
127
+ {children}
128
+ </dl>
129
+ );
130
+ };
110
131
 
111
132
  DescriptionList.displayName = 'DescriptionList';
@@ -239,34 +239,93 @@ import {
239
239
  } from '@patternfly/react-core';
240
240
  import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
241
241
 
242
- <DescriptionList isHorizontal>
243
- <DescriptionListGroup>
244
- <DescriptionListTerm>Name</DescriptionListTerm>
245
- <DescriptionListDescription>Example</DescriptionListDescription>
246
- </DescriptionListGroup>
247
- <DescriptionListGroup>
248
- <DescriptionListTerm>Namespace</DescriptionListTerm>
249
- <DescriptionListDescription>
250
- <a href="#">mary-test</a>
251
- </DescriptionListDescription>
252
- </DescriptionListGroup>
253
- <DescriptionListGroup>
254
- <DescriptionListTerm>Labels</DescriptionListTerm>
255
- <DescriptionListDescription>example</DescriptionListDescription>
256
- </DescriptionListGroup>
257
- <DescriptionListGroup>
258
- <DescriptionListTerm>Pod selector</DescriptionListTerm>
259
- <DescriptionListDescription>
260
- <Button variant="link" isInline icon={<PlusCircleIcon />}>
261
- app=MyApp
262
- </Button>
263
- </DescriptionListDescription>
264
- </DescriptionListGroup>
265
- <DescriptionListGroup>
266
- <DescriptionListTerm>Annotation</DescriptionListTerm>
267
- <DescriptionListDescription>2 Annotations</DescriptionListDescription>
268
- </DescriptionListGroup>
269
- </DescriptionList>;
242
+ const DescriptionListHorizontal = () => {
243
+ return (
244
+ <DescriptionList isHorizontal>
245
+ <DescriptionListGroup>
246
+ <DescriptionListTerm>Name</DescriptionListTerm>
247
+ <DescriptionListDescription>Example</DescriptionListDescription>
248
+ </DescriptionListGroup>
249
+ <DescriptionListGroup>
250
+ <DescriptionListTerm>Namespace</DescriptionListTerm>
251
+ <DescriptionListDescription>
252
+ <a href="#">mary-test</a>
253
+ </DescriptionListDescription>
254
+ </DescriptionListGroup>
255
+ <DescriptionListGroup>
256
+ <DescriptionListTerm>Labels</DescriptionListTerm>
257
+ <DescriptionListDescription>example</DescriptionListDescription>
258
+ </DescriptionListGroup>
259
+ <DescriptionListGroup>
260
+ <DescriptionListTerm>Pod selector</DescriptionListTerm>
261
+ <DescriptionListDescription>
262
+ <Button variant="link" isInline icon={<PlusCircleIcon />}>
263
+ app=MyApp
264
+ </Button>
265
+ </DescriptionListDescription>
266
+ </DescriptionListGroup>
267
+ <DescriptionListGroup>
268
+ <DescriptionListTerm>Annotation</DescriptionListTerm>
269
+ <DescriptionListDescription>2 Annotations</DescriptionListDescription>
270
+ </DescriptionListGroup>
271
+ </DescriptionList>
272
+ )
273
+ }
274
+ ```
275
+
276
+ ### Horizontal using custom term width modifier
277
+
278
+ ```js
279
+ import React from 'react';
280
+ import {
281
+ Button,
282
+ DescriptionList,
283
+ DescriptionListTerm,
284
+ DescriptionListText,
285
+ DescriptionListGroup,
286
+ DescriptionListDescription,
287
+ } from '@patternfly/react-core';
288
+ import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
289
+
290
+ const DescriptionListHorizontalTermWidthModifier = () => {
291
+ return (
292
+ <DescriptionList isHorizontal horizontalTermWidthModifier={{
293
+ default: '12ch',
294
+ sm: '15ch',
295
+ md: '20ch',
296
+ lg: '28ch',
297
+ xl: '30ch',
298
+ '2xl': '35ch'
299
+ }}>
300
+ <DescriptionListGroup>
301
+ <DescriptionListTerm>Name longer than the default term width</DescriptionListTerm>
302
+ <DescriptionListDescription>Example</DescriptionListDescription>
303
+ </DescriptionListGroup>
304
+ <DescriptionListGroup>
305
+ <DescriptionListTerm>Namespace</DescriptionListTerm>
306
+ <DescriptionListDescription>
307
+ <a href="#">mary-test</a>
308
+ </DescriptionListDescription>
309
+ </DescriptionListGroup>
310
+ <DescriptionListGroup>
311
+ <DescriptionListTerm>Labels</DescriptionListTerm>
312
+ <DescriptionListDescription>example</DescriptionListDescription>
313
+ </DescriptionListGroup>
314
+ <DescriptionListGroup>
315
+ <DescriptionListTerm>Pod selector</DescriptionListTerm>
316
+ <DescriptionListDescription>
317
+ <Button variant="link" isInline icon={<PlusCircleIcon />}>
318
+ app=MyApp
319
+ </Button>
320
+ </DescriptionListDescription>
321
+ </DescriptionListGroup>
322
+ <DescriptionListGroup>
323
+ <DescriptionListTerm>Annotation</DescriptionListTerm>
324
+ <DescriptionListDescription>2 Annotations</DescriptionListDescription>
325
+ </DescriptionListGroup>
326
+ </DescriptionList>
327
+ )
328
+ }
270
329
  ```
271
330
 
272
331
  ### Horizontal 2 col
@@ -67,7 +67,7 @@ export interface PopoverProps {
67
67
  /** Distance of the popover to its target, defaults to 25 */
68
68
  distance?: number;
69
69
  /**
70
- * If true, tries to keep the popover in view by flipping it if necessary
70
+ * If true, tries to keep the popover in view by flipping it if necessary.
71
71
  * If the position is set to 'auto', this prop is ignored
72
72
  */
73
73
  enableFlip?: boolean;