carbon-react 111.2.0 → 111.3.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.
@@ -1,8 +1,11 @@
1
1
  import React from "react";
2
2
  import { SpaceProps, LayoutProps, FlexboxProps, ColorProps, PositionProps } from "styled-system";
3
+ declare const GAP_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
3
4
  export declare type OverflowWrap = "break-word" | "anywhere";
4
5
  export declare type ScrollVariant = "light" | "dark";
5
6
  export declare type BoxSizing = "content-box" | "border-box";
7
+ export declare type AllowedNumericalValues = typeof GAP_VALUES[number];
8
+ export declare type Gap = AllowedNumericalValues | string;
6
9
  export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorProps, Omit<PositionProps, "zIndex"> {
7
10
  as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
8
11
  /** String to set Box content break strategy. Note "anywhere" is not supported in Safari */
@@ -13,6 +16,12 @@ export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorPr
13
16
  boxSizing?: BoxSizing;
14
17
  /** Allows a tabindex to be specified */
15
18
  tabIndex?: number | string;
19
+ /** Gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
20
+ gap?: Gap;
21
+ /** Column gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
22
+ columnGap?: Gap;
23
+ /** Row gap an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
24
+ rowGap?: Gap;
16
25
  }
17
26
  declare const Box: import("styled-components").StyledComponent<"div", any, BoxProps, never>;
18
27
  export default Box;
@@ -3,11 +3,13 @@ import { space, layout, flexbox, position } from "styled-system";
3
3
  import BaseTheme from "../../style/themes/base";
4
4
  import styledColor from "../../style/utils/color";
5
5
  import boxConfig from "./box.config";
6
+ const GAP_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
6
7
  const Box = styled.div`
7
8
  ${space}
8
9
  ${layout}
9
10
  ${flexbox}
10
11
  ${position}
12
+
11
13
  ${({
12
14
  color,
13
15
  bg,
@@ -48,6 +50,25 @@ const Box = styled.div`
48
50
  }) => boxSizing && css`
49
51
  box-sizing: ${boxSizing};
50
52
  `}
53
+
54
+ ${({
55
+ display,
56
+ gap,
57
+ columnGap,
58
+ rowGap
59
+ }) => (display === "flex" || display === "inline-flex") && css`
60
+ ${gap !== undefined && css`
61
+ gap: ${boxConfig.gap(gap)};
62
+ `}
63
+
64
+ ${columnGap !== undefined && css`
65
+ column-gap: ${boxConfig.gap(columnGap)};
66
+ `}
67
+
68
+ ${rowGap !== undefined && css`
69
+ row-gap: ${boxConfig.gap(rowGap)};
70
+ `}
71
+ `};
51
72
  `;
52
73
  Box.defaultProps = {
53
74
  theme: BaseTheme
@@ -7,5 +7,6 @@ declare const _default: {
7
7
  thumb: string;
8
8
  track: string;
9
9
  };
10
+ gap: (gapValue: number | string) => string;
10
11
  };
11
12
  export default _default;
@@ -1,3 +1,4 @@
1
+ import { space } from "../../style/themes/base/base-theme.config";
1
2
  export default {
2
3
  light: {
3
4
  thumb: "var(--colorsUtilityMajor300)",
@@ -6,5 +7,12 @@ export default {
6
7
  dark: {
7
8
  thumb: "var(--colorsUtilityMajor200)",
8
9
  track: "var(--colorsUtilityMajor400)"
10
+ },
11
+ gap: gapValue => {
12
+ if (typeof gapValue === "number") {
13
+ return space[gapValue];
14
+ }
15
+
16
+ return gapValue;
9
17
  }
10
18
  };
@@ -478,6 +478,7 @@ DismissibleBox.propTypes = {
478
478
  "toString": PropTypes.func.isRequired,
479
479
  "valueOf": PropTypes.func.isRequired
480
480
  }), PropTypes.string]),
481
+ "columnGap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
481
482
  "flex": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
482
483
  "__@iterator": PropTypes.func.isRequired,
483
484
  "anchor": PropTypes.func.isRequired,
@@ -712,6 +713,7 @@ DismissibleBox.propTypes = {
712
713
  "valueOf": PropTypes.func.isRequired
713
714
  })]),
714
715
  "flexWrap": PropTypes.oneOfType([PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap"]), PropTypes.arrayOf(PropTypes.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap", null])), PropTypes.object]),
716
+ "gap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
715
717
  "hasBorderLeftHighlight": PropTypes.bool,
716
718
  "height": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
717
719
  "__@iterator": PropTypes.func.isRequired,
@@ -2152,6 +2154,7 @@ DismissibleBox.propTypes = {
2152
2154
  "trimStart": PropTypes.func.isRequired,
2153
2155
  "valueOf": PropTypes.func.isRequired
2154
2156
  }), PropTypes.string]),
2157
+ "rowGap": PropTypes.oneOfType([PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), PropTypes.string]),
2155
2158
  "scrollVariant": PropTypes.oneOf(["dark", "light"]),
2156
2159
  "size": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
2157
2160
  "__@iterator": PropTypes.func.isRequired,
@@ -3,5 +3,8 @@ import { MarginProps } from "styled-system";
3
3
  import { StyledLoaderBarProps } from "./loader-bar.style";
4
4
  export interface LoaderBarProps extends StyledLoaderBarProps, MarginProps {
5
5
  }
6
- declare const LoaderBar: ({ size, ...rest }: LoaderBarProps) => JSX.Element;
6
+ export declare const LoaderBar: {
7
+ ({ size, ...rest }: LoaderBarProps): JSX.Element;
8
+ DisplayName: string;
9
+ };
7
10
  export default LoaderBar;
@@ -173,4 +173,6 @@ LoaderBar.propTypes = {
173
173
  }), PropTypes.string]),
174
174
  "size": PropTypes.oneOf(["large", "medium", "small"])
175
175
  };
176
+ export { LoaderBar };
177
+ LoaderBar.DisplayName = "Loader Bar";
176
178
  export default LoaderBar;
@@ -132,7 +132,7 @@ const MultiActionButton = ({
132
132
  "data-element": "toggle-button",
133
133
  key: "toggle-button"
134
134
  }, mainButtonProps, {
135
- forwardRef: buttonRef,
135
+ ref: buttonRef,
136
136
  iconPosition: "after",
137
137
  iconType: "dropdown"
138
138
  }), text), showAdditionalButtons && renderAdditionalButtons());
@@ -67,12 +67,20 @@ const StyledButtonChildrenContainer = styled.div`
67
67
  ${StyledButton} {
68
68
  border: 1px solid var(--colorsActionMajorTransparent);
69
69
  color: var(--colorsActionMajor500);
70
- display: block;
70
+ display: flex;
71
+ justify-content: ${align};
71
72
  margin-left: 0;
72
73
  min-width: 100%;
73
74
  text-align: ${align};
74
75
  z-index: ${theme.zIndex.overlay};
75
76
 
77
+ /* Styling for Safari. Display flex is not supported on buttons in Safari. */
78
+ @media not all and (min-resolution: 0.001dpcm) {
79
+ @supports (-webkit-appearance: none) and (stroke-color: transparent) {
80
+ display: -webkit-box;
81
+ }
82
+ }
83
+
76
84
  &:focus,
77
85
  &:hover {
78
86
  background-color: var(--colorsActionMajor600);
@@ -1,8 +1,11 @@
1
1
  import React from "react";
2
2
  import { SpaceProps, LayoutProps, FlexboxProps, ColorProps, PositionProps } from "styled-system";
3
+ declare const GAP_VALUES: readonly [0, 1, 2, 3, 4, 5, 6, 7, 8];
3
4
  export declare type OverflowWrap = "break-word" | "anywhere";
4
5
  export declare type ScrollVariant = "light" | "dark";
5
6
  export declare type BoxSizing = "content-box" | "border-box";
7
+ export declare type AllowedNumericalValues = typeof GAP_VALUES[number];
8
+ export declare type Gap = AllowedNumericalValues | string;
6
9
  export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorProps, Omit<PositionProps, "zIndex"> {
7
10
  as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
8
11
  /** String to set Box content break strategy. Note "anywhere" is not supported in Safari */
@@ -13,6 +16,12 @@ export interface BoxProps extends SpaceProps, LayoutProps, FlexboxProps, ColorPr
13
16
  boxSizing?: BoxSizing;
14
17
  /** Allows a tabindex to be specified */
15
18
  tabIndex?: number | string;
19
+ /** Gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
20
+ gap?: Gap;
21
+ /** Column gap, an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
22
+ columnGap?: Gap;
23
+ /** Row gap an integer multiplier of the base spacing constant (8px) or any valid CSS string." */
24
+ rowGap?: Gap;
16
25
  }
17
26
  declare const Box: import("styled-components").StyledComponent<"div", any, BoxProps, never>;
18
27
  export default Box;
@@ -21,11 +21,13 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
21
21
 
22
22
  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; }
23
23
 
24
+ const GAP_VALUES = [0, 1, 2, 3, 4, 5, 6, 7, 8];
24
25
  const Box = _styledComponents.default.div`
25
26
  ${_styledSystem.space}
26
27
  ${_styledSystem.layout}
27
28
  ${_styledSystem.flexbox}
28
29
  ${_styledSystem.position}
30
+
29
31
  ${({
30
32
  color,
31
33
  bg,
@@ -66,6 +68,25 @@ const Box = _styledComponents.default.div`
66
68
  }) => boxSizing && (0, _styledComponents.css)`
67
69
  box-sizing: ${boxSizing};
68
70
  `}
71
+
72
+ ${({
73
+ display,
74
+ gap,
75
+ columnGap,
76
+ rowGap
77
+ }) => (display === "flex" || display === "inline-flex") && (0, _styledComponents.css)`
78
+ ${gap !== undefined && (0, _styledComponents.css)`
79
+ gap: ${_box.default.gap(gap)};
80
+ `}
81
+
82
+ ${columnGap !== undefined && (0, _styledComponents.css)`
83
+ column-gap: ${_box.default.gap(columnGap)};
84
+ `}
85
+
86
+ ${rowGap !== undefined && (0, _styledComponents.css)`
87
+ row-gap: ${_box.default.gap(rowGap)};
88
+ `}
89
+ `};
69
90
  `;
70
91
  Box.defaultProps = {
71
92
  theme: _base.default
@@ -7,5 +7,6 @@ declare const _default: {
7
7
  thumb: string;
8
8
  track: string;
9
9
  };
10
+ gap: (gapValue: number | string) => string;
10
11
  };
11
12
  export default _default;
@@ -4,6 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+
8
+ var _baseTheme = require("../../style/themes/base/base-theme.config");
9
+
7
10
  var _default = {
8
11
  light: {
9
12
  thumb: "var(--colorsUtilityMajor300)",
@@ -12,6 +15,13 @@ var _default = {
12
15
  dark: {
13
16
  thumb: "var(--colorsUtilityMajor200)",
14
17
  track: "var(--colorsUtilityMajor400)"
18
+ },
19
+ gap: gapValue => {
20
+ if (typeof gapValue === "number") {
21
+ return _baseTheme.space[gapValue];
22
+ }
23
+
24
+ return gapValue;
15
25
  }
16
26
  };
17
27
  exports.default = _default;
@@ -492,6 +492,7 @@ DismissibleBox.propTypes = {
492
492
  "toString": _propTypes.default.func.isRequired,
493
493
  "valueOf": _propTypes.default.func.isRequired
494
494
  }), _propTypes.default.string]),
495
+ "columnGap": _propTypes.default.oneOfType([_propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), _propTypes.default.string]),
495
496
  "flex": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
496
497
  "__@iterator": _propTypes.default.func.isRequired,
497
498
  "anchor": _propTypes.default.func.isRequired,
@@ -726,6 +727,7 @@ DismissibleBox.propTypes = {
726
727
  "valueOf": _propTypes.default.func.isRequired
727
728
  })]),
728
729
  "flexWrap": _propTypes.default.oneOfType([_propTypes.default.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap"]), _propTypes.default.arrayOf(_propTypes.default.oneOf(["-moz-initial", "inherit", "initial", "nowrap", "revert", "unset", "wrap-reverse", "wrap", null])), _propTypes.default.object]),
730
+ "gap": _propTypes.default.oneOfType([_propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), _propTypes.default.string]),
729
731
  "hasBorderLeftHighlight": _propTypes.default.bool,
730
732
  "height": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
731
733
  "__@iterator": _propTypes.default.func.isRequired,
@@ -2166,6 +2168,7 @@ DismissibleBox.propTypes = {
2166
2168
  "trimStart": _propTypes.default.func.isRequired,
2167
2169
  "valueOf": _propTypes.default.func.isRequired
2168
2170
  }), _propTypes.default.string]),
2171
+ "rowGap": _propTypes.default.oneOfType([_propTypes.default.oneOf([0, 1, 2, 3, 4, 5, 6, 7, 8]), _propTypes.default.string]),
2169
2172
  "scrollVariant": _propTypes.default.oneOf(["dark", "light"]),
2170
2173
  "size": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
2171
2174
  "__@iterator": _propTypes.default.func.isRequired,
@@ -3,5 +3,8 @@ import { MarginProps } from "styled-system";
3
3
  import { StyledLoaderBarProps } from "./loader-bar.style";
4
4
  export interface LoaderBarProps extends StyledLoaderBarProps, MarginProps {
5
5
  }
6
- declare const LoaderBar: ({ size, ...rest }: LoaderBarProps) => JSX.Element;
6
+ export declare const LoaderBar: {
7
+ ({ size, ...rest }: LoaderBarProps): JSX.Element;
8
+ DisplayName: string;
9
+ };
7
10
  export default LoaderBar;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = exports.LoaderBar = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -32,6 +32,7 @@ const LoaderBar = ({
32
32
  })));
33
33
  };
34
34
 
35
+ exports.LoaderBar = LoaderBar;
35
36
  LoaderBar.propTypes = {
36
37
  "m": _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.oneOf([null]), _propTypes.default.number, _propTypes.default.shape({
37
38
  "__@toStringTag": _propTypes.default.string.isRequired,
@@ -189,5 +190,6 @@ LoaderBar.propTypes = {
189
190
  }), _propTypes.default.string]),
190
191
  "size": _propTypes.default.oneOf(["large", "medium", "small"])
191
192
  };
193
+ LoaderBar.DisplayName = "Loader Bar";
192
194
  var _default = LoaderBar;
193
195
  exports.default = _default;
@@ -153,7 +153,7 @@ const MultiActionButton = ({
153
153
  "data-element": "toggle-button",
154
154
  key: "toggle-button"
155
155
  }, mainButtonProps, {
156
- forwardRef: buttonRef,
156
+ ref: buttonRef,
157
157
  iconPosition: "after",
158
158
  iconType: "dropdown"
159
159
  }), text), showAdditionalButtons && renderAdditionalButtons());
@@ -86,12 +86,20 @@ const StyledButtonChildrenContainer = _styledComponents.default.div`
86
86
  ${_button.default} {
87
87
  border: 1px solid var(--colorsActionMajorTransparent);
88
88
  color: var(--colorsActionMajor500);
89
- display: block;
89
+ display: flex;
90
+ justify-content: ${align};
90
91
  margin-left: 0;
91
92
  min-width: 100%;
92
93
  text-align: ${align};
93
94
  z-index: ${theme.zIndex.overlay};
94
95
 
96
+ /* Styling for Safari. Display flex is not supported on buttons in Safari. */
97
+ @media not all and (min-resolution: 0.001dpcm) {
98
+ @supports (-webkit-appearance: none) and (stroke-color: transparent) {
99
+ display: -webkit-box;
100
+ }
101
+ }
102
+
95
103
  &:focus,
96
104
  &:hover {
97
105
  background-color: var(--colorsActionMajor600);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.2.0",
3
+ "version": "111.3.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",