carbon-react 102.19.1 → 102.22.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/README.md CHANGED
@@ -51,4 +51,4 @@ Thanks to [Chromatic](https://www.chromatic.com/) for providing the visual testi
51
51
 
52
52
  Carbon is licensed under the [Apache-2.0 licence](LICENSE).
53
53
 
54
- Copyright (c) 2018-2021 Sage Group Plc. All rights reserved.
54
+ Copyright (c) 2018-2022 Sage Group Plc. All rights reserved.
@@ -1,31 +1,13 @@
1
1
  export const Menu: import("styled-components").StyledComponent<"div", any, {}, never>;
2
2
  export function MenuItemFactory(button: any): import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
3
3
  export const MenuButton: import("styled-components").StyledComponent<"div", any, {}, never>;
4
- export const ButtonIcon: React.ForwardRefExoticComponent<{
5
- [x: string]: any;
6
- [x: number]: any;
7
- [x: symbol]: any;
8
- } & {
9
- theme?: any;
10
- }>;
4
+ export const ButtonIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
11
5
  export const StyledButtonIcon: import("styled-components").StyledComponent<"div", any, {}, never>;
12
- export const MenuItemIcon: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
13
- [x: string]: any;
14
- [x: number]: any;
15
- [x: symbol]: any;
16
- } & {
17
- theme?: any;
18
- }>, any, {}, never>;
6
+ export const MenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
19
7
  export const MenuItemDivider: import("styled-components").StyledComponent<"div", any, {
20
8
  "data-element": string;
21
9
  }, "data-element">;
22
- export const SubMenuItemIcon: import("styled-components").StyledComponent<React.ForwardRefExoticComponent<{
23
- [x: string]: any;
24
- [x: number]: any;
25
- [x: symbol]: any;
26
- } & {
27
- theme?: any;
28
- }>, any, {}, never>;
10
+ export const SubMenuItemIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
29
11
  export const MenuButtonOverrideWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
30
12
  export const StyledMenuItem: import("styled-components").StyledComponent<"div", any, {}, never>;
31
- import React from "react";
13
+ import Icon from "../icon";
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.StyledMenuItem = exports.MenuButtonOverrideWrapper = exports.SubMenuItemIcon = exports.MenuItemDivider = exports.MenuItemIcon = exports.StyledButtonIcon = exports.ButtonIcon = exports.MenuButton = exports.MenuItemFactory = exports.Menu = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
11
9
 
12
10
  var _styledSystem = require("styled-system");
@@ -19,30 +17,24 @@ var _button = _interopRequireDefault(require("../button/button.style"));
19
17
 
20
18
  var _browserTypeCheck = require("../../__internal__/utils/helpers/browser-type-check");
21
19
 
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
22
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
23
23
 
24
24
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
25
 
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
-
28
26
  const Menu = _styledComponents.default.div`
29
27
  ${({
30
28
  isOpen
31
29
  }) => isOpen ? "display: block;" : "visibility: hidden;"}
32
30
  margin: 0;
33
- padding: ${({
34
- theme
35
- }) => `${theme.spacing}px 0`};
36
- box-shadow: ${({
37
- theme
38
- }) => theme.shadows.depth1};
31
+ padding: var(--spacing100) 0;
32
+ box-shadow: var(--boxShadow100);
39
33
  position: absolute;
40
- background-color: ${({
41
- theme
42
- }) => theme.colors.white};
34
+ background-color: var(--colorsUtilityYang100);
43
35
  z-index: ${({
44
36
  theme
45
- }) => `${theme.zIndex.popover}`};
37
+ }) => `${theme.zIndex.popover}`}; // TODO (tokens): implement elevation tokens - FE-4437
46
38
  `;
47
39
  exports.Menu = Menu;
48
40
  const StyledMenuItem = _styledComponents.default.div`
@@ -55,9 +47,7 @@ const MenuItemFactory = button => (0, _styledComponents.default)(button)`
55
47
  disabled
56
48
  }) => disabled ? "not-allowed" : "pointer"};
57
49
  box-sizing: border-box;
58
- ${({
59
- theme
60
- }) => `padding: 0 ${theme.spacing * 3}px;`}
50
+ padding: 0 var(--spacing150);
61
51
  position: relative;
62
52
  line-height: 40px;
63
53
  white-space: nowrap;
@@ -67,9 +57,8 @@ const MenuItemFactory = button => (0, _styledComponents.default)(button)`
67
57
  border: none;
68
58
  width: 100%;
69
59
  color: ${({
70
- disabled,
71
- theme
72
- }) => disabled ? theme.menu.itemColorDisabled : theme.menu.itemColor};
60
+ disabled
61
+ }) => disabled ? "var(--colorsUtilityYin030)" : "var(--colorsUtilityYin090)"};
73
62
  font-size: 14px;
74
63
  font-weight: 700;
75
64
  justify-content: ${({
@@ -80,16 +69,12 @@ const MenuItemFactory = button => (0, _styledComponents.default)(button)`
80
69
  ${({
81
70
  disabled
82
71
  }) => !disabled && (0, _styledComponents.css)`
83
- background-color: ${({
84
- theme
85
- }) => theme.menu.focus};
72
+ background-color: var(--colorsUtilityMajor025);
86
73
  `}
87
74
  }
88
75
  &:focus {
89
- outline: none;
90
- box-shadow: inset 0px 0px 0px 2px ${({
91
- theme
92
- }) => theme.colors.focus};
76
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
77
+ z-index: 1;
93
78
  }
94
79
  ${({
95
80
  disabled
@@ -103,7 +88,7 @@ const MenuItemFactory = button => (0, _styledComponents.default)(button)`
103
88
  }) => disabled && (0, _styledComponents.css)`
104
89
  && ${_icon2.default} {
105
90
  cursor: not-allowed;
106
- color: inherit;
91
+ color: var(--colorsUtilityYin030);
107
92
  }
108
93
  `}
109
94
  `;
@@ -112,11 +97,9 @@ exports.MenuItemFactory = MenuItemFactory;
112
97
  const MenuItemDivider = _styledComponents.default.div.attrs({
113
98
  "data-element": "action-popover-divider"
114
99
  })`
115
- background-color: ${({
116
- theme
117
- }) => theme.menu.divider};
118
- height: 1px;
119
- margin: 9px;
100
+ background-color: var(--colorsUtilityMajor050);
101
+ height: var(--borderWidth100);
102
+ margin: var(--spacing100) var(--spacing150);
120
103
  `;
121
104
  exports.MenuItemDivider = MenuItemDivider;
122
105
  const MenuButton = _styledComponents.default.div`
@@ -127,100 +110,59 @@ const MenuButton = _styledComponents.default.div`
127
110
  width: fit-content;
128
111
  margin: auto;
129
112
  ${_styledSystem.margin}
130
- ${({
131
- isOpen,
132
- theme
133
- }) => isOpen && `background-color: ${theme.colors.white}`}
134
113
  `;
135
- /**
136
- * Creates a factory that returns a styled component with a custom
137
- * theme provider wrapped around it
138
- * @param {*} themeFn
139
- */
140
-
141
114
  exports.MenuButton = MenuButton;
115
+ const ButtonIcon = (0, _styledComponents.default)(_icon.default)`
116
+ color: var(--colorsActionMinor500);
142
117
 
143
- const iconThemeProviderFactory = (Component, themeFn) => (0, _styledComponents.withTheme)(({
144
- theme,
145
- ...props
146
- }) => {
147
- const color = themeFn(theme.palette);
148
- const customTheme = { ...theme,
149
- icon: {
150
- default: color,
151
- defaultHover: color
152
- }
153
- };
154
- return /*#__PURE__*/_react.default.createElement(_styledComponents.ThemeProvider, {
155
- theme: customTheme
156
- }, /*#__PURE__*/_react.default.createElement(Component, props));
157
- });
158
-
159
- const ButtonIcon = iconThemeProviderFactory(_icon.default, palette => palette.slate);
118
+ :hover {
119
+ color: var(--colorsActionMinor600);
120
+ }
121
+ `;
160
122
  exports.ButtonIcon = ButtonIcon;
161
123
  const StyledButtonIcon = _styledComponents.default.div`
162
- &:hover,
163
- &:focus {
164
- background-color: ${({
165
- theme
166
- }) => theme.colors.white};
167
- }
168
-
169
124
  &:focus {
170
- outline: 2px solid ${({
171
- theme
172
- }) => theme.colors.focus};
125
+ outline: var(--borderWidth300) solid var(--colorsSemanticFocus500);
173
126
  }
174
127
  `;
175
128
  exports.StyledButtonIcon = StyledButtonIcon;
176
- const MenuItemIcon = (0, _styledComponents.default)(iconThemeProviderFactory(_icon.default, () => "inherit"))`
177
- ${({
178
- theme,
179
- horizontalAlignment
180
- }) => (0, _styledComponents.css)`
181
- ${horizontalAlignment === "right" ? "padding-left" : "padding-right"}: ${theme.spacing}px;
182
- `}
129
+ const MenuItemIcon = (0, _styledComponents.default)(_icon.default)`
130
+ padding: var(--spacing100);
131
+ color: var(--colorsUtilityYin065);
183
132
  `;
184
133
  exports.MenuItemIcon = MenuItemIcon;
185
134
  const SubMenuItemIcon = (0, _styledComponents.default)(ButtonIcon)`
186
135
  ${({
187
- theme,
188
136
  type
189
137
  }) => (0, _styledComponents.css)`
190
138
  position: absolute;
191
- &,
192
- :hover {
193
- color: ${theme.colors.border};
194
- }
195
139
  ${type === "chevron_left" && (0, _styledComponents.css)`
196
- left: 0px;
140
+ left: -2px;
197
141
  `}
198
142
 
199
143
  ${type === "chevron_right" && (0, _styledComponents.css)`
200
- right: 0px;
144
+ right: -5px;
201
145
  ${(0, _browserTypeCheck.isSafari)(navigator) && (0, _styledComponents.css)`
202
- top: ${theme.spacing}px;
146
+ top: var(--sizing100);
203
147
  `}
204
148
  `}
205
149
  `}
206
150
  `;
207
151
  exports.SubMenuItemIcon = SubMenuItemIcon;
208
152
  const MenuButtonOverrideWrapper = _styledComponents.default.div`
209
- ${({
210
- theme
211
- }) => (0, _styledComponents.css)`
212
- ${_button.default} {
213
- padding: 0px ${theme.spacing}px;
214
- width: 100%;
215
- &:focus {
216
- outline-width: 2px;
217
- }
153
+ ${_button.default} {
154
+ padding: 0px var(--sizing100);
155
+ width: 100%;
156
+
157
+ &:hover,
158
+ &:focus {
159
+ background-color: var(--colorsActionMajorTransparent);
160
+ color: var(--colorsActionMajor600);
218
161
 
219
- &:hover,
220
- &:focus {
221
- background-color: ${theme.colors.white};
162
+ span[color] {
163
+ color: var(--colorsActionMajor600);
222
164
  }
223
165
  }
224
- `}
166
+ }
225
167
  `;
226
168
  exports.MenuButtonOverrideWrapper = MenuButtonOverrideWrapper;
@@ -82,7 +82,7 @@ const Confirm = ({
82
82
  buttonType: confirmButtonType,
83
83
  destructive: destructive || confirmButtonDestructive,
84
84
  disabled: isLoadingConfirm || disableConfirm,
85
- ml: cancelButtonType === "tertiary" ? "3px" : 2,
85
+ ml: 2,
86
86
  iconType: confirmButtonIconType,
87
87
  iconPosition: confirmButtonIconPosition
88
88
  }, isLoadingConfirm ? /*#__PURE__*/_react.default.createElement(_loader.default, {
@@ -5,12 +5,11 @@ export const StyledHeader: import("styled-components").StyledComponent<"div", an
5
5
  export const StyledSeparator: import("styled-components").StyledComponent<"hr", any, {}, never>;
6
6
  export const StyledHeaderHelp: import("styled-components").StyledComponent<typeof Help, any, {}, never>;
7
7
  export const StyledHeadingTitle: import("styled-components").StyledComponent<typeof Typography, any, {}, never>;
8
- export const StyledDivider: import("styled-components").StyledComponent<typeof Hr, any, {}, never>;
8
+ export const StyledDivider: import("styled-components").StyledComponent<({ adaptiveMxBreakpoint, ml, mr, ...rest }: import("../hr/hr.component").HrProps) => JSX.Element, any, {}, never>;
9
9
  export const StyledHeaderContent: import("styled-components").StyledComponent<"div", any, {}, never>;
10
10
  export const StyledHeadingBackButton: import("styled-components").StyledComponent<typeof Link, any, {}, never>;
11
11
  export const StyledHeadingPills: import("styled-components").StyledComponent<"span", any, {}, never>;
12
12
  import Icon from "../icon";
13
13
  import Help from "../help";
14
14
  import Typography from "../typography";
15
- import Hr from "../hr";
16
15
  import Link from "../link";
@@ -1,13 +1,9 @@
1
- export default Hr;
2
- declare function Hr({ adaptiveMxBreakpoint, ml, mr, ...props }: {
3
- [x: string]: any;
4
- adaptiveMxBreakpoint: any;
5
- ml: any;
6
- mr: any;
7
- }): JSX.Element;
8
- declare namespace Hr {
9
- namespace propTypes {
10
- const adaptiveMxBreakpoint: PropTypes.Requireable<number>;
11
- }
1
+ /// <reference types="react" />
2
+ import { MarginProps } from "styled-system";
3
+ export interface HrProps extends MarginProps {
4
+ /** Breakpoint for adaptive left and right margins (below the breakpoint they go to 0).
5
+ * Enables the adaptive behaviour when set */
6
+ adaptiveMxBreakpoint?: number;
12
7
  }
13
- import PropTypes from "prop-types";
8
+ export declare const Hr: ({ adaptiveMxBreakpoint, ml, mr, ...rest }: HrProps) => JSX.Element;
9
+ export default Hr;