@patternfly/react-core 4.202.0 → 4.202.3

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 (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/esm/components/DescriptionList/DescriptionList.d.ts +13 -3
  3. package/dist/esm/components/DescriptionList/DescriptionList.d.ts.map +1 -1
  4. package/dist/esm/components/DescriptionList/DescriptionList.js +10 -6
  5. package/dist/esm/components/DescriptionList/DescriptionList.js.map +1 -1
  6. package/dist/esm/components/MenuToggle/MenuToggle.d.ts +1 -1
  7. package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  8. package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
  9. package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
  10. package/dist/esm/components/Popover/Popover.d.ts +1 -1
  11. package/dist/js/components/DescriptionList/DescriptionList.d.ts +13 -3
  12. package/dist/js/components/DescriptionList/DescriptionList.d.ts.map +1 -1
  13. package/dist/js/components/DescriptionList/DescriptionList.js +10 -6
  14. package/dist/js/components/DescriptionList/DescriptionList.js.map +1 -1
  15. package/dist/js/components/MenuToggle/MenuToggle.d.ts +1 -1
  16. package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
  17. package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
  18. package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
  19. package/dist/js/components/Popover/Popover.d.ts +1 -1
  20. package/dist/umd/react-core.css +1724 -1724
  21. package/dist/umd/react-core.js +11 -7
  22. package/dist/umd/react-core.min.js +2 -2
  23. package/package.json +5 -5
  24. package/src/components/DescriptionList/DescriptionList.tsx +52 -31
  25. package/src/components/DescriptionList/examples/DescriptionList.md +87 -28
  26. package/src/components/MenuToggle/MenuToggle.tsx +2 -1
  27. package/src/components/MenuToggle/examples/MenuToggle.css +3 -0
  28. package/src/components/MenuToggle/examples/MenuToggle.md +53 -11
  29. package/src/components/Popover/Popover.tsx +1 -1
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.3",
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.3",
38
+ "@patternfly/react-styles": "^4.52.3",
39
+ "@patternfly/react-tokens": "^4.54.3",
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": "c12101227ce64e1f7920cebfba4404d81d403b93"
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
@@ -17,7 +17,7 @@ export interface MenuToggleProps
17
17
  /** Flag indicating the toggle is full height */
18
18
  isFullHeight?: boolean;
19
19
  /** Variant styles of the menu toggle */
20
- variant?: 'default' | 'plain' | 'primary' | 'plainText';
20
+ variant?: 'default' | 'plain' | 'primary' | 'plainText' | 'secondary';
21
21
  /** Optional icon rendered inside the toggle, before the children content */
22
22
  icon?: React.ReactNode;
23
23
  /** Optional badge rendered inside the toggle, after the children content */
@@ -71,6 +71,7 @@ export class MenuToggleBase extends React.Component<MenuToggleProps> {
71
71
  styles.menuToggle,
72
72
  isExpanded && styles.modifiers.expanded,
73
73
  variant === 'primary' && styles.modifiers.primary,
74
+ variant === 'secondary' && styles.modifiers.secondary,
74
75
  (isPlain || isPlainText) && styles.modifiers.plain,
75
76
  isPlainText && styles.modifiers.text,
76
77
  isFullHeight && styles.modifiers.fullHeight,
@@ -0,0 +1,3 @@
1
+ #ws-react-c-menu-toggle-primary .pf-c-menu-toggle, #ws-react-c-menu-toggle-secondary .pf-c-menu-toggle {
2
+ vertical-align: bottom;
3
+ }
@@ -6,8 +6,11 @@ propComponents: ['MenuToggle']
6
6
  beta: true
7
7
  ---
8
8
 
9
+ import './MenuToggle.css'
10
+
9
11
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
10
12
  import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
13
+ import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
11
14
 
12
15
  ## Examples
13
16
 
@@ -41,17 +44,6 @@ import { MenuToggle } from '@patternfly/react-core';
41
44
 
42
45
  ```
43
46
 
44
- ### Icon
45
-
46
- ```ts
47
- import React from 'react';
48
- import { MenuToggle } from '@patternfly/react-core';
49
- import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
50
-
51
- <MenuToggle icon={<CogIcon />}>Icon</MenuToggle>;
52
-
53
- ```
54
-
55
47
  ### Count
56
48
 
57
49
  ```ts
@@ -84,6 +76,28 @@ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
84
76
 
85
77
  ```
86
78
 
79
+ ### Secondary
80
+
81
+ ```ts
82
+ import React from 'react';
83
+ import { MenuToggle } from '@patternfly/react-core';
84
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
85
+
86
+ <React.Fragment>
87
+ <MenuToggle variant="secondary">Collapsed</MenuToggle>{' '}
88
+ <MenuToggle variant="secondary" icon={<CogIcon />}>
89
+ Icon
90
+ </MenuToggle>{' '}
91
+ <MenuToggle variant="secondary" isExpanded>
92
+ Expanded
93
+ </MenuToggle>{' '}
94
+ <MenuToggle variant="secondary" isDisabled>
95
+ Disabled
96
+ </MenuToggle>
97
+ </React.Fragment>
98
+
99
+ ```
100
+
87
101
  ### Plain
88
102
 
89
103
  ```ts
@@ -123,6 +137,34 @@ import { MenuToggle } from '@patternfly/react-core';
123
137
  </React.Fragment>
124
138
  ```
125
139
 
140
+
141
+ ### With icon/image and text
142
+
143
+ ```ts
144
+ import React from 'react';
145
+ import { MenuToggle, Avatar } from '@patternfly/react-core';
146
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
147
+
148
+ <React.Fragment>
149
+ <MenuToggle icon={<CogIcon />} variant="secondary">Icon</MenuToggle>{' '}
150
+ <MenuToggle icon={<CogIcon />} variant="secondary" isDisabled>Icon</MenuToggle>
151
+ </React.Fragment>
152
+ ```
153
+
154
+ ### With avatar and text
155
+
156
+ ```ts
157
+ import React from 'react';
158
+ import { MenuToggle, Avatar } from '@patternfly/react-core';
159
+ import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
160
+
161
+ <React.Fragment>
162
+ <MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />}>Ned Username</MenuToggle>{' '}
163
+ <MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isExpanded>Ned Username</MenuToggle>{' '}
164
+ <MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isDisabled>Ned Username</MenuToggle>
165
+ </React.Fragment>
166
+ ```
167
+
126
168
  ### Full height
127
169
 
128
170
  ```ts
@@ -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;