@patternfly/react-core 4.226.2 → 4.227.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.226.2",
3
+ "version": "4.227.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",
@@ -34,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.77.2",
38
- "@patternfly/react-styles": "^4.76.2",
39
- "@patternfly/react-tokens": "^4.78.2",
37
+ "@patternfly/react-icons": "^4.78.0",
38
+ "@patternfly/react-styles": "^4.77.0",
39
+ "@patternfly/react-tokens": "^4.79.0",
40
40
  "focus-trap": "6.9.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": "fb67d6b2dfbfd2b4080e1313101f4d663a0a09c3"
63
+ "gitHead": "9ab68189931ffebc2eb1d2dd3a39ad5d8bc88b58"
64
64
  }
@@ -120,6 +120,7 @@ export const DropdownToggle: React.FunctionComponent<DropdownToggleProps> = ({
120
120
  styles.modifiers.splitButton,
121
121
  splitButtonVariant === 'action' && styles.modifiers.action,
122
122
  (toggleVariant === 'primary' || isPrimary) && splitButtonVariant === 'action' && styles.modifiers.primary,
123
+ toggleVariant === 'secondary' && splitButtonVariant === 'action' && styles.modifiers.secondary,
123
124
  isDisabled && styles.modifiers.disabled
124
125
  )}
125
126
  >
@@ -184,6 +184,24 @@ describe('DropdownToggle', () => {
184
184
  expect(asFragment()).toMatchSnapshot();
185
185
  });
186
186
 
187
+ test('action split button - renders secondary variant', () => {
188
+ const { asFragment } = render(
189
+ <DropdownToggle
190
+ id="Dropdown Toggle"
191
+ toggleVariant="secondary"
192
+ splitButtonItems={[<div key="1">test</div>]}
193
+ splitButtonVariant="action"
194
+ parentRef={document.createElement('div')}
195
+ >
196
+ Dropdown
197
+ </DropdownToggle>
198
+ );
199
+
200
+ const dropdownToggle = screen.getByRole('button').parentElement;
201
+
202
+ expect(dropdownToggle).toHaveClass('pf-m-secondary');
203
+ });
204
+
187
205
  test('class changes', () => {
188
206
  const { asFragment } = render(
189
207
  <DropdownContext.Provider
@@ -198,7 +198,7 @@ exports[`DropdownToggle state class changes 1`] = `
198
198
  <button
199
199
  aria-expanded="false"
200
200
  class="pf-c-dropdown__toggle"
201
- data-ouia-component-id="OUIA-Generated-DropdownToggle-13"
201
+ data-ouia-component-id="OUIA-Generated-DropdownToggle-14"
202
202
  data-ouia-component-type="PF4/DropdownToggle"
203
203
  data-ouia-safe="true"
204
204
  id="Dropdown Toggle"
@@ -113,6 +113,11 @@ import avatarImg from '../../Avatar/examples/avatarImg.svg';
113
113
  ```ts file="./DropdownSplitButtonActionPrimary.tsx"
114
114
  ```
115
115
 
116
+ ### Split button secondary action
117
+
118
+ ```ts file="./DropdownSplitButtonActionSecondary.tsx"
119
+ ```
120
+
116
121
  ### Basic panel
117
122
 
118
123
  ```ts file="./DropdownBasicPanel.tsx"
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { Dropdown, DropdownToggle, DropdownToggleAction, DropdownItem } from '@patternfly/react-core';
3
+ import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
4
+ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
5
+ import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
6
+
7
+ export const DropdownSplitButtonActionSecondary: React.FunctionComponent = () => {
8
+ const [isActionOpen, setIsActionOpen] = React.useState(false);
9
+ const [isCogOpen, setIsCogOpen] = React.useState(false);
10
+
11
+ const onActionToggle = (isActionOpen: boolean) => {
12
+ setIsActionOpen(isActionOpen);
13
+ };
14
+ const onCogToggle = (isCogOpen: boolean) => {
15
+ setIsCogOpen(isCogOpen);
16
+ };
17
+
18
+ const onActionClick = () => {
19
+ window.alert('You selected an action button!');
20
+ };
21
+ const onCogClick = () => {
22
+ window.alert('You selected the Cog!');
23
+ };
24
+
25
+ const onActionFocus = () => {
26
+ const element = document.getElementById('toggle-split-button-action-secondary');
27
+ element.focus();
28
+ };
29
+ const onCogFocus = () => {
30
+ const element = document.getElementById('toggle-split-button-cog-secondary');
31
+ element.focus();
32
+ };
33
+
34
+ const onActionSelect = () => {
35
+ setIsActionOpen(false);
36
+ onActionFocus();
37
+ };
38
+ const onCogSelect = () => {
39
+ setIsCogOpen(false);
40
+ onCogFocus();
41
+ };
42
+
43
+ const dropdownItems = [
44
+ <DropdownItem key="action" component="button" onClick={onActionClick}>
45
+ Action
46
+ </DropdownItem>,
47
+ <DropdownItem key="disabled link" component="button" isDisabled onClick={onActionClick}>
48
+ Disabled action
49
+ </DropdownItem>,
50
+ <DropdownItem key="other action" component="button" onClick={onActionClick}>
51
+ Other action
52
+ </DropdownItem>
53
+ ];
54
+
55
+ const dropdownIconItems = [
56
+ <DropdownItem key="action" component="button" icon={<CogIcon />} onClick={onActionClick}>
57
+ Action
58
+ </DropdownItem>,
59
+ <DropdownItem key="disabled link" component="button" icon={<BellIcon />} isDisabled onClick={onActionClick}>
60
+ Disabled action
61
+ </DropdownItem>,
62
+ <DropdownItem key="other action" component="button" icon={<CubesIcon />} onClick={onActionClick}>
63
+ Other action
64
+ </DropdownItem>
65
+ ];
66
+
67
+ return (
68
+ <React.Fragment>
69
+ <Dropdown
70
+ onSelect={onActionSelect}
71
+ toggle={
72
+ <DropdownToggle
73
+ id="toggle-split-button-action-secondary"
74
+ splitButtonItems={[
75
+ <DropdownToggleAction key="action" onClick={onActionClick}>
76
+ Action
77
+ </DropdownToggleAction>
78
+ ]}
79
+ toggleVariant="secondary"
80
+ splitButtonVariant="action"
81
+ onToggle={onActionToggle}
82
+ />
83
+ }
84
+ isOpen={isActionOpen}
85
+ dropdownItems={dropdownItems}
86
+ />{' '}
87
+ <Dropdown
88
+ onSelect={onCogSelect}
89
+ toggle={
90
+ <DropdownToggle
91
+ id="toggle-split-button-cog-secondary"
92
+ splitButtonItems={[
93
+ <DropdownToggleAction key="cog-action" aria-label="Action" onClick={onCogClick}>
94
+ <CogIcon />
95
+ </DropdownToggleAction>
96
+ ]}
97
+ toggleVariant="secondary"
98
+ splitButtonVariant="action"
99
+ onToggle={onCogToggle}
100
+ />
101
+ }
102
+ isOpen={isCogOpen}
103
+ dropdownItems={dropdownIconItems}
104
+ />
105
+ </React.Fragment>
106
+ );
107
+ };