carbon-react 104.54.2 → 104.54.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.
- package/esm/__spec_helper__/test-utils.d.ts +1 -1
- package/esm/__spec_helper__/test-utils.js +15 -16
- package/esm/components/action-popover/action-popover-item/action-popover-item.component.js +8 -4
- package/esm/components/action-popover/action-popover.style.d.ts +1 -1
- package/esm/components/action-popover/action-popover.style.js +2 -1
- package/esm/components/button/button.component.d.ts +1 -1
- package/esm/components/button/button.component.js +11 -2
- package/esm/components/multi-action-button/multi-action-button.component.js +8 -0
- package/esm/components/split-button/split-button.component.d.ts +2 -2
- package/esm/components/split-button/split-button.component.js +12 -4
- package/lib/__spec_helper__/test-utils.d.ts +1 -1
- package/lib/__spec_helper__/test-utils.js +16 -17
- package/lib/components/action-popover/action-popover-item/action-popover-item.component.js +8 -4
- package/lib/components/action-popover/action-popover.style.d.ts +1 -1
- package/lib/components/action-popover/action-popover.style.js +2 -1
- package/lib/components/button/button.component.d.ts +1 -1
- package/lib/components/button/button.component.js +13 -2
- package/lib/components/multi-action-button/multi-action-button.component.js +10 -0
- package/lib/components/split-button/split-button.component.d.ts +2 -2
- package/lib/components/split-button/split-button.component.js +14 -4
- package/package.json +1 -1
|
@@ -29,6 +29,6 @@ export function testStyledSystemWidth(component: any, styleContainer: any): void
|
|
|
29
29
|
export function testStyledSystemLayout(component: any, styleContainer: any): void;
|
|
30
30
|
export function testStyledSystemFlexBox(component: any, styleContainer: any): void;
|
|
31
31
|
export function testStyledSystemBackground(component: any, styleContainer: any): void;
|
|
32
|
-
export function
|
|
32
|
+
export function expectConsoleOutput(message: any, type?: string): () => void;
|
|
33
33
|
declare const keydown: {};
|
|
34
34
|
export { mockMatchMedia };
|
|
@@ -317,38 +317,37 @@ const testStyledSystemBackground = (component, styleContainer) => {
|
|
|
317
317
|
}, styleContainer ? styleContainer(wrapper) : wrapper));
|
|
318
318
|
});
|
|
319
319
|
});
|
|
320
|
-
};
|
|
320
|
+
}; // this util will catch that a console output occurred without polluting the output when running the unit tests
|
|
321
|
+
|
|
321
322
|
|
|
322
|
-
const
|
|
323
|
-
if (!
|
|
324
|
-
throw new Error(
|
|
323
|
+
const expectConsoleOutput = (message, type = "error") => {
|
|
324
|
+
if (!message) {
|
|
325
|
+
throw new Error(`no ${type} message provided`);
|
|
325
326
|
}
|
|
326
327
|
|
|
327
328
|
expect.assertions(1);
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
let errorArgs;
|
|
332
|
-
jest.spyOn(global.console, "error").mockImplementation((...args) => {
|
|
329
|
+
const consoleType = global.console[type];
|
|
330
|
+
let consoleArgs;
|
|
331
|
+
jest.spyOn(global.console, type).mockImplementation((...args) => {
|
|
333
332
|
if (!args.length) return;
|
|
334
333
|
const msg = args.join(" ");
|
|
335
334
|
const params = args.slice(1, args.length);
|
|
336
335
|
|
|
337
|
-
if (sprintf(msg, ...params).includes(
|
|
338
|
-
|
|
336
|
+
if (sprintf(msg, ...params).includes(message)) {
|
|
337
|
+
consoleArgs = args;
|
|
339
338
|
return;
|
|
340
339
|
}
|
|
341
340
|
|
|
342
|
-
|
|
341
|
+
consoleType(...args);
|
|
343
342
|
});
|
|
344
343
|
return () => {
|
|
345
|
-
if (
|
|
344
|
+
if (consoleArgs) {
|
|
346
345
|
// eslint-disable-next-line no-console
|
|
347
|
-
expect(console
|
|
346
|
+
expect(console[type]).toHaveBeenCalledWith(...consoleArgs);
|
|
348
347
|
}
|
|
349
348
|
|
|
350
|
-
global.console
|
|
349
|
+
global.console[type] = consoleType;
|
|
351
350
|
};
|
|
352
351
|
};
|
|
353
352
|
|
|
354
|
-
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground,
|
|
353
|
+
export { assertStyleMatch, toCSSCase, hoverList, selectedItemOf, childrenFrom, makeArrayKeys, keyboard, assertKeyboardTraversal, assertHoverTraversal, listFrom, click, simulate, carbonThemesJestTable, mockMatchMedia, testStyledSystemSpacing, testStyledSystemMargin, testStyledSystemPadding, testStyledSystemColor, testStyledSystemWidth, testStyledSystemLayout, testStyledSystemFlexBox, testStyledSystemBackground, expectConsoleOutput };
|
|
@@ -79,12 +79,12 @@ const MenuItem = ({
|
|
|
79
79
|
e.stopPropagation();
|
|
80
80
|
|
|
81
81
|
if (!disabled) {
|
|
82
|
+
setOpenPopover(false);
|
|
83
|
+
focusButton();
|
|
84
|
+
|
|
82
85
|
if (onClickProp) {
|
|
83
86
|
onClickProp();
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
setOpenPopover(false);
|
|
87
|
-
focusButton();
|
|
88
88
|
} else {
|
|
89
89
|
ref.current.focus();
|
|
90
90
|
e.preventDefault();
|
|
@@ -128,7 +128,11 @@ const MenuItem = ({
|
|
|
128
128
|
|
|
129
129
|
e.preventDefault();
|
|
130
130
|
} else if (Events.isEnterKey(e)) {
|
|
131
|
-
if (isHref && download)
|
|
131
|
+
if (isHref && download) {
|
|
132
|
+
ref.current.click();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
e.preventDefault();
|
|
132
136
|
onClick(e);
|
|
133
137
|
}
|
|
134
138
|
} else if (Events.isEnterKey(e)) {
|
|
@@ -9,5 +9,5 @@ export const MenuItemDivider: import("styled-components").StyledComponent<"div",
|
|
|
9
9
|
}, "data-element">;
|
|
10
10
|
export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
|
|
11
11
|
export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
-
export const StyledMenuItem: import("styled-components").StyledComponent<"
|
|
12
|
+
export const StyledMenuItem: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
13
13
|
import Icon from "../icon";
|
|
@@ -17,8 +17,9 @@ const Menu = styled.div`
|
|
|
17
17
|
theme
|
|
18
18
|
}) => `${theme.zIndex.popover}`}; // TODO (tokens): implement elevation tokens - FE-4437
|
|
19
19
|
`;
|
|
20
|
-
const StyledMenuItem = styled.
|
|
20
|
+
const StyledMenuItem = styled.button`
|
|
21
21
|
text-decoration: none;
|
|
22
|
+
background-color: var(--colorsActionMajorYang100);
|
|
22
23
|
`;
|
|
23
24
|
|
|
24
25
|
const MenuItemFactory = button => styled(button)`
|
|
@@ -24,7 +24,7 @@ declare function Button({ size, subtext, as, children, forwardRef, "aria-label":
|
|
|
24
24
|
declare namespace Button {
|
|
25
25
|
const propTypes: any;
|
|
26
26
|
namespace defaultProps {
|
|
27
|
-
const
|
|
27
|
+
const buttonType: string;
|
|
28
28
|
const size: string;
|
|
29
29
|
const fullWidth: boolean;
|
|
30
30
|
const disabled: boolean;
|
|
@@ -7,6 +7,7 @@ import Icon from "../icon";
|
|
|
7
7
|
import StyledButton, { StyledButtonSubtext } from "./button.style";
|
|
8
8
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
9
9
|
import { TooltipProvider } from "../../__internal__/tooltip-provider";
|
|
10
|
+
import Logger from "../../__internal__/utils/logger";
|
|
10
11
|
|
|
11
12
|
function renderChildren({
|
|
12
13
|
/* eslint-disable react/prop-types */
|
|
@@ -51,6 +52,8 @@ function renderChildren({
|
|
|
51
52
|
}))), iconType && iconPosition === "after" && children && /*#__PURE__*/React.createElement(Icon, iconProps));
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
let deprecatedWarnTriggered = false;
|
|
56
|
+
|
|
54
57
|
const Button = ({
|
|
55
58
|
size,
|
|
56
59
|
subtext,
|
|
@@ -72,8 +75,14 @@ const Button = ({
|
|
|
72
75
|
iconTooltipPosition,
|
|
73
76
|
...rest
|
|
74
77
|
}) => {
|
|
78
|
+
if (!deprecatedWarnTriggered && as) {
|
|
79
|
+
deprecatedWarnTriggered = true;
|
|
80
|
+
Logger.deprecate( // eslint-disable-next-line max-len
|
|
81
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
const [internalRef, setInternalRef] = useState(null);
|
|
76
|
-
const buttonType =
|
|
85
|
+
const buttonType = as || buttonTypeProp;
|
|
77
86
|
|
|
78
87
|
if (subtext.length > 0 && size !== "large") {
|
|
79
88
|
throw new Error("subtext prop has no effect unless the button is large");
|
|
@@ -237,7 +246,7 @@ Button.propTypes = {
|
|
|
237
246
|
rel: PropTypes.string
|
|
238
247
|
};
|
|
239
248
|
Button.defaultProps = {
|
|
240
|
-
|
|
249
|
+
buttonType: "secondary",
|
|
241
250
|
size: "medium",
|
|
242
251
|
fullWidth: false,
|
|
243
252
|
disabled: false,
|
|
@@ -9,7 +9,9 @@ import Events from "../../__internal__/utils/helpers/events";
|
|
|
9
9
|
import Popover from "../../__internal__/popover";
|
|
10
10
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
11
11
|
import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
|
|
12
|
+
import Logger from "../../__internal__/utils/logger";
|
|
12
13
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
14
|
+
let deprecatedWarnTriggered = false;
|
|
13
15
|
|
|
14
16
|
const MultiActionButton = ({
|
|
15
17
|
align = "left",
|
|
@@ -22,6 +24,12 @@ const MultiActionButton = ({
|
|
|
22
24
|
subtext,
|
|
23
25
|
...rest
|
|
24
26
|
}) => {
|
|
27
|
+
if (!deprecatedWarnTriggered && as) {
|
|
28
|
+
deprecatedWarnTriggered = true;
|
|
29
|
+
Logger.deprecate( // eslint-disable-next-line max-len
|
|
30
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
31
|
+
}
|
|
32
|
+
|
|
25
33
|
const ref = useRef();
|
|
26
34
|
const buttonRef = useRef();
|
|
27
35
|
const buttonContainer = useRef();
|
|
@@ -2,8 +2,8 @@ export default SplitButton;
|
|
|
2
2
|
declare function SplitButton({ align, as, buttonType, children, disabled, iconPosition, iconType, onClick, size, subtext, text, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
align?: string | undefined;
|
|
5
|
-
as
|
|
6
|
-
buttonType
|
|
5
|
+
as: any;
|
|
6
|
+
buttonType?: string | undefined;
|
|
7
7
|
children: any;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
iconPosition?: string | undefined;
|
|
@@ -15,13 +15,15 @@ import Popover from "../../__internal__/popover";
|
|
|
15
15
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
16
16
|
import { baseTheme } from "../../style/themes";
|
|
17
17
|
import { defaultFocusableSelectors } from "../../__internal__/focus-trap/focus-trap-utils";
|
|
18
|
+
import Logger from "../../__internal__/utils/logger";
|
|
18
19
|
const marginPropTypes = filterStyledSystemMarginProps(styledSystemPropTypes.space);
|
|
19
20
|
const CONTENT_WIDTH_RATIO = 0.75;
|
|
21
|
+
let deprecatedWarnTriggered = false;
|
|
20
22
|
|
|
21
23
|
const SplitButton = ({
|
|
22
24
|
align = "left",
|
|
23
|
-
as
|
|
24
|
-
buttonType,
|
|
25
|
+
as,
|
|
26
|
+
buttonType = "secondary",
|
|
25
27
|
children,
|
|
26
28
|
disabled = false,
|
|
27
29
|
iconPosition = "before",
|
|
@@ -32,6 +34,12 @@ const SplitButton = ({
|
|
|
32
34
|
text,
|
|
33
35
|
...rest
|
|
34
36
|
}) => {
|
|
37
|
+
if (!deprecatedWarnTriggered && as) {
|
|
38
|
+
deprecatedWarnTriggered = true;
|
|
39
|
+
Logger.deprecate( // eslint-disable-next-line max-len
|
|
40
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
const theme = useContext(ThemeContext) || baseTheme;
|
|
36
44
|
const isToggleButtonFocused = useRef(false);
|
|
37
45
|
const buttonLabelId = useRef(guid());
|
|
@@ -120,7 +128,7 @@ const SplitButton = ({
|
|
|
120
128
|
isToggleButtonFocused.current = false;
|
|
121
129
|
},
|
|
122
130
|
onKeyDown: handleToggleButtonKeyDown,
|
|
123
|
-
buttonType:
|
|
131
|
+
buttonType: as || buttonType,
|
|
124
132
|
size
|
|
125
133
|
};
|
|
126
134
|
|
|
@@ -149,7 +157,7 @@ const SplitButton = ({
|
|
|
149
157
|
primary: theme.colors.white,
|
|
150
158
|
secondary: theme.colors.primary
|
|
151
159
|
};
|
|
152
|
-
return colorsMap[
|
|
160
|
+
return colorsMap[as || buttonType];
|
|
153
161
|
}
|
|
154
162
|
|
|
155
163
|
function renderMainButton() {
|
|
@@ -29,6 +29,6 @@ export function testStyledSystemWidth(component: any, styleContainer: any): void
|
|
|
29
29
|
export function testStyledSystemLayout(component: any, styleContainer: any): void;
|
|
30
30
|
export function testStyledSystemFlexBox(component: any, styleContainer: any): void;
|
|
31
31
|
export function testStyledSystemBackground(component: any, styleContainer: any): void;
|
|
32
|
-
export function
|
|
32
|
+
export function expectConsoleOutput(message: any, type?: string): () => void;
|
|
33
33
|
declare const keydown: {};
|
|
34
34
|
export { mockMatchMedia };
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "mockMatchMedia", {
|
|
|
9
9
|
return _mockMatchMedia.mockMatchMedia;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
exports.
|
|
12
|
+
exports.expectConsoleOutput = exports.testStyledSystemBackground = exports.testStyledSystemFlexBox = exports.testStyledSystemLayout = exports.testStyledSystemWidth = exports.testStyledSystemColor = exports.testStyledSystemPadding = exports.testStyledSystemMargin = exports.testStyledSystemSpacing = exports.carbonThemesJestTable = exports.simulate = exports.click = exports.listFrom = exports.assertHoverTraversal = exports.assertKeyboardTraversal = exports.keyboard = exports.makeArrayKeys = exports.childrenFrom = exports.selectedItemOf = exports.hoverList = exports.toCSSCase = exports.assertStyleMatch = exports.getDefaultValue = void 0;
|
|
13
13
|
|
|
14
14
|
var _enzyme = require("enzyme");
|
|
15
15
|
|
|
@@ -373,40 +373,39 @@ const testStyledSystemBackground = (component, styleContainer) => {
|
|
|
373
373
|
}, styleContainer ? styleContainer(wrapper) : wrapper));
|
|
374
374
|
});
|
|
375
375
|
});
|
|
376
|
-
};
|
|
376
|
+
}; // this util will catch that a console output occurred without polluting the output when running the unit tests
|
|
377
|
+
|
|
377
378
|
|
|
378
379
|
exports.testStyledSystemBackground = testStyledSystemBackground;
|
|
379
380
|
|
|
380
|
-
const
|
|
381
|
-
if (!
|
|
382
|
-
throw new Error(
|
|
381
|
+
const expectConsoleOutput = (message, type = "error") => {
|
|
382
|
+
if (!message) {
|
|
383
|
+
throw new Error(`no ${type} message provided`);
|
|
383
384
|
}
|
|
384
385
|
|
|
385
386
|
expect.assertions(1);
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
let errorArgs;
|
|
390
|
-
jest.spyOn(global.console, "error").mockImplementation((...args) => {
|
|
387
|
+
const consoleType = global.console[type];
|
|
388
|
+
let consoleArgs;
|
|
389
|
+
jest.spyOn(global.console, type).mockImplementation((...args) => {
|
|
391
390
|
if (!args.length) return;
|
|
392
391
|
const msg = args.join(" ");
|
|
393
392
|
const params = args.slice(1, args.length);
|
|
394
393
|
|
|
395
|
-
if ((0, _sprintfJs.sprintf)(msg, ...params).includes(
|
|
396
|
-
|
|
394
|
+
if ((0, _sprintfJs.sprintf)(msg, ...params).includes(message)) {
|
|
395
|
+
consoleArgs = args;
|
|
397
396
|
return;
|
|
398
397
|
}
|
|
399
398
|
|
|
400
|
-
|
|
399
|
+
consoleType(...args);
|
|
401
400
|
});
|
|
402
401
|
return () => {
|
|
403
|
-
if (
|
|
402
|
+
if (consoleArgs) {
|
|
404
403
|
// eslint-disable-next-line no-console
|
|
405
|
-
expect(console
|
|
404
|
+
expect(console[type]).toHaveBeenCalledWith(...consoleArgs);
|
|
406
405
|
}
|
|
407
406
|
|
|
408
|
-
global.console
|
|
407
|
+
global.console[type] = consoleType;
|
|
409
408
|
};
|
|
410
409
|
};
|
|
411
410
|
|
|
412
|
-
exports.
|
|
411
|
+
exports.expectConsoleOutput = expectConsoleOutput;
|
|
@@ -100,12 +100,12 @@ const MenuItem = ({
|
|
|
100
100
|
e.stopPropagation();
|
|
101
101
|
|
|
102
102
|
if (!disabled) {
|
|
103
|
+
setOpenPopover(false);
|
|
104
|
+
focusButton();
|
|
105
|
+
|
|
103
106
|
if (onClickProp) {
|
|
104
107
|
onClickProp();
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
setOpenPopover(false);
|
|
108
|
-
focusButton();
|
|
109
109
|
} else {
|
|
110
110
|
ref.current.focus();
|
|
111
111
|
e.preventDefault();
|
|
@@ -149,7 +149,11 @@ const MenuItem = ({
|
|
|
149
149
|
|
|
150
150
|
e.preventDefault();
|
|
151
151
|
} else if (_events.default.isEnterKey(e)) {
|
|
152
|
-
if (isHref && download)
|
|
152
|
+
if (isHref && download) {
|
|
153
|
+
ref.current.click();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
e.preventDefault();
|
|
153
157
|
onClick(e);
|
|
154
158
|
}
|
|
155
159
|
} else if (_events.default.isEnterKey(e)) {
|
|
@@ -9,5 +9,5 @@ export const MenuItemDivider: import("styled-components").StyledComponent<"div",
|
|
|
9
9
|
}, "data-element">;
|
|
10
10
|
export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
|
|
11
11
|
export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
12
|
-
export const StyledMenuItem: import("styled-components").StyledComponent<"
|
|
12
|
+
export const StyledMenuItem: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
13
13
|
import Icon from "../icon";
|
|
@@ -37,8 +37,9 @@ const Menu = _styledComponents.default.div`
|
|
|
37
37
|
}) => `${theme.zIndex.popover}`}; // TODO (tokens): implement elevation tokens - FE-4437
|
|
38
38
|
`;
|
|
39
39
|
exports.Menu = Menu;
|
|
40
|
-
const StyledMenuItem = _styledComponents.default.
|
|
40
|
+
const StyledMenuItem = _styledComponents.default.button`
|
|
41
41
|
text-decoration: none;
|
|
42
|
+
background-color: var(--colorsActionMajorYang100);
|
|
42
43
|
`;
|
|
43
44
|
exports.StyledMenuItem = StyledMenuItem;
|
|
44
45
|
|
|
@@ -24,7 +24,7 @@ declare function Button({ size, subtext, as, children, forwardRef, "aria-label":
|
|
|
24
24
|
declare namespace Button {
|
|
25
25
|
const propTypes: any;
|
|
26
26
|
namespace defaultProps {
|
|
27
|
-
const
|
|
27
|
+
const buttonType: string;
|
|
28
28
|
const size: string;
|
|
29
29
|
const fullWidth: boolean;
|
|
30
30
|
const disabled: boolean;
|
|
@@ -19,6 +19,8 @@ var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tag
|
|
|
19
19
|
|
|
20
20
|
var _tooltipProvider = require("../../__internal__/tooltip-provider");
|
|
21
21
|
|
|
22
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
23
|
+
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
25
|
|
|
24
26
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -70,6 +72,8 @@ function renderChildren({
|
|
|
70
72
|
}))), iconType && iconPosition === "after" && children && /*#__PURE__*/_react.default.createElement(_icon.default, iconProps));
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
let deprecatedWarnTriggered = false;
|
|
76
|
+
|
|
73
77
|
const Button = ({
|
|
74
78
|
size,
|
|
75
79
|
subtext,
|
|
@@ -91,8 +95,15 @@ const Button = ({
|
|
|
91
95
|
iconTooltipPosition,
|
|
92
96
|
...rest
|
|
93
97
|
}) => {
|
|
98
|
+
if (!deprecatedWarnTriggered && as) {
|
|
99
|
+
deprecatedWarnTriggered = true;
|
|
100
|
+
|
|
101
|
+
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
102
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
103
|
+
}
|
|
104
|
+
|
|
94
105
|
const [internalRef, setInternalRef] = (0, _react.useState)(null);
|
|
95
|
-
const buttonType =
|
|
106
|
+
const buttonType = as || buttonTypeProp;
|
|
96
107
|
|
|
97
108
|
if (subtext.length > 0 && size !== "large") {
|
|
98
109
|
throw new Error("subtext prop has no effect unless the button is large");
|
|
@@ -256,7 +267,7 @@ Button.propTypes = {
|
|
|
256
267
|
rel: _propTypes.default.string
|
|
257
268
|
};
|
|
258
269
|
Button.defaultProps = {
|
|
259
|
-
|
|
270
|
+
buttonType: "secondary",
|
|
260
271
|
size: "medium",
|
|
261
272
|
fullWidth: false,
|
|
262
273
|
disabled: false,
|
|
@@ -23,6 +23,8 @@ var _utils = require("../../style/utils");
|
|
|
23
23
|
|
|
24
24
|
var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
|
|
25
25
|
|
|
26
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
27
|
+
|
|
26
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
29
|
|
|
28
30
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -32,6 +34,7 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
32
34
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
35
|
|
|
34
36
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
37
|
+
let deprecatedWarnTriggered = false;
|
|
35
38
|
|
|
36
39
|
const MultiActionButton = ({
|
|
37
40
|
align = "left",
|
|
@@ -44,6 +47,13 @@ const MultiActionButton = ({
|
|
|
44
47
|
subtext,
|
|
45
48
|
...rest
|
|
46
49
|
}) => {
|
|
50
|
+
if (!deprecatedWarnTriggered && as) {
|
|
51
|
+
deprecatedWarnTriggered = true;
|
|
52
|
+
|
|
53
|
+
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
54
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
55
|
+
}
|
|
56
|
+
|
|
47
57
|
const ref = (0, _react.useRef)();
|
|
48
58
|
const buttonRef = (0, _react.useRef)();
|
|
49
59
|
const buttonContainer = (0, _react.useRef)();
|
|
@@ -2,8 +2,8 @@ export default SplitButton;
|
|
|
2
2
|
declare function SplitButton({ align, as, buttonType, children, disabled, iconPosition, iconType, onClick, size, subtext, text, ...rest }: {
|
|
3
3
|
[x: string]: any;
|
|
4
4
|
align?: string | undefined;
|
|
5
|
-
as
|
|
6
|
-
buttonType
|
|
5
|
+
as: any;
|
|
6
|
+
buttonType?: string | undefined;
|
|
7
7
|
children: any;
|
|
8
8
|
disabled?: boolean | undefined;
|
|
9
9
|
iconPosition?: string | undefined;
|
|
@@ -35,6 +35,8 @@ var _themes = require("../../style/themes");
|
|
|
35
35
|
|
|
36
36
|
var _focusTrapUtils = require("../../__internal__/focus-trap/focus-trap-utils");
|
|
37
37
|
|
|
38
|
+
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
39
|
+
|
|
38
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
41
|
|
|
40
42
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
@@ -45,11 +47,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
45
47
|
|
|
46
48
|
const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
|
|
47
49
|
const CONTENT_WIDTH_RATIO = 0.75;
|
|
50
|
+
let deprecatedWarnTriggered = false;
|
|
48
51
|
|
|
49
52
|
const SplitButton = ({
|
|
50
53
|
align = "left",
|
|
51
|
-
as
|
|
52
|
-
buttonType,
|
|
54
|
+
as,
|
|
55
|
+
buttonType = "secondary",
|
|
53
56
|
children,
|
|
54
57
|
disabled = false,
|
|
55
58
|
iconPosition = "before",
|
|
@@ -60,6 +63,13 @@ const SplitButton = ({
|
|
|
60
63
|
text,
|
|
61
64
|
...rest
|
|
62
65
|
}) => {
|
|
66
|
+
if (!deprecatedWarnTriggered && as) {
|
|
67
|
+
deprecatedWarnTriggered = true;
|
|
68
|
+
|
|
69
|
+
_logger.default.deprecate( // eslint-disable-next-line max-len
|
|
70
|
+
"The `as` prop is deprecated and will soon be removed. You should use the `buttonType` prop to achieve the same styling. The following codemod is available to help with updating your code https://github.com/Sage/carbon-codemod/tree/master/transforms/rename-prop");
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
const theme = (0, _react.useContext)(_styledComponents.ThemeContext) || _themes.baseTheme;
|
|
64
74
|
|
|
65
75
|
const isToggleButtonFocused = (0, _react.useRef)(false);
|
|
@@ -149,7 +159,7 @@ const SplitButton = ({
|
|
|
149
159
|
isToggleButtonFocused.current = false;
|
|
150
160
|
},
|
|
151
161
|
onKeyDown: handleToggleButtonKeyDown,
|
|
152
|
-
buttonType:
|
|
162
|
+
buttonType: as || buttonType,
|
|
153
163
|
size
|
|
154
164
|
};
|
|
155
165
|
|
|
@@ -178,7 +188,7 @@ const SplitButton = ({
|
|
|
178
188
|
primary: theme.colors.white,
|
|
179
189
|
secondary: theme.colors.primary
|
|
180
190
|
};
|
|
181
|
-
return colorsMap[
|
|
191
|
+
return colorsMap[as || buttonType];
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
function renderMainButton() {
|