carbon-react 103.0.0 → 103.2.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.
@@ -13,11 +13,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
 
14
14
  var _core = require("@popperjs/core");
15
15
 
16
- var _styledComponents = require("styled-components");
17
-
18
16
  var _useResizeObserver = _interopRequireDefault(require("../../hooks/__internal__/useResizeObserver"));
19
17
 
20
- var _carbonScopedTokensProvider = require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component");
18
+ var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
21
19
 
22
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
21
 
@@ -34,11 +32,9 @@ const Popover = ({
34
32
  modifiers
35
33
  }) => {
36
34
  const elementDOM = (0, _react.useRef)();
37
- const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
38
35
 
39
36
  if (!elementDOM.current && !disablePortal) {
40
37
  elementDOM.current = document.createElement("div");
41
- elementDOM.current.classList.add((0, _carbonScopedTokensProvider.tokensClassName)(theme === null || theme === void 0 ? void 0 : theme.name));
42
38
  document.body.appendChild(elementDOM.current);
43
39
  }
44
40
 
@@ -98,7 +94,7 @@ const Popover = ({
98
94
  return content;
99
95
  }
100
96
 
101
- return /*#__PURE__*/_reactDom.default.createPortal(content, elementDOM.current);
97
+ return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, content), elementDOM.current);
102
98
  };
103
99
 
104
100
  Popover.propTypes = {
@@ -1,5 +1,5 @@
1
1
  export const StyledBadgeWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
- export const StyledButton: import("styled-components").StyledComponent<typeof Button, any, import("../button").ButtonDefaultProps, never>;
2
+ export const StyledButton: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
3
3
  export const StyledCrossIcon: import("styled-components").StyledComponent<typeof Icon, any, {}, never>;
4
4
  export const StyledCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
5
5
  import Button from "../button";
@@ -37,9 +37,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
37
37
  top: -11px;
38
38
  right: -11px;
39
39
  margin-right: 0;
40
- background: ${({
41
- theme
42
- }) => theme.colors.white};
40
+ background: var(--colorsActionMajorYang100);
43
41
 
44
42
  ::-moz-focus-inner {
45
43
  border: none;
@@ -47,9 +45,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
47
45
 
48
46
  &:hover,
49
47
  &:focus {
50
- background: ${({
51
- theme
52
- }) => theme.colors.primary};
48
+ background: var(--colorsActionMajor500);
53
49
  border: none;
54
50
  ${StyledCounter} {
55
51
  display: none;
@@ -63,9 +59,7 @@ const StyledButton = (0, _styledComponents.default)(_button.default)`
63
59
 
64
60
  :before {
65
61
  font-size: 16px;
66
- color: ${({
67
- theme
68
- }) => theme.colors.white};
62
+ color: var(--colorsActionMajorYang100);
69
63
  }
70
64
  }
71
65
  }
@@ -1,9 +1,9 @@
1
1
  export default Decimal;
2
2
  declare function Decimal({ align, defaultValue, precision, inputWidth, readOnly, onChange, onBlur, onKeyPress, id, name, allowEmptyValue, required, locale, value, ...rest }: {
3
3
  [x: string]: any;
4
- align?: string | undefined;
4
+ align: any;
5
5
  defaultValue: any;
6
- precision?: number | undefined;
6
+ precision: any;
7
7
  inputWidth: any;
8
8
  readOnly: any;
9
9
  onChange: any;
@@ -11,7 +11,7 @@ declare function Decimal({ align, defaultValue, precision, inputWidth, readOnly,
11
11
  onKeyPress: any;
12
12
  id: any;
13
13
  name: any;
14
- allowEmptyValue?: boolean | undefined;
14
+ allowEmptyValue: any;
15
15
  required: any;
16
16
  locale: any;
17
17
  value: any;
@@ -77,5 +77,10 @@ declare namespace Decimal {
77
77
  /** Aria label for rendered help component */
78
78
  helpAriaLabel: PropTypes.Requireable<string>;
79
79
  };
80
+ namespace defaultProps {
81
+ const precision: number;
82
+ const allowEmptyValue: boolean;
83
+ const align: string;
84
+ }
80
85
  }
81
86
  import PropTypes from "prop-types";
@@ -30,9 +30,9 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
30
30
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
31
31
 
32
32
  const Decimal = ({
33
- align = "right",
33
+ align,
34
34
  defaultValue,
35
- precision = 2,
35
+ precision,
36
36
  inputWidth,
37
37
  readOnly,
38
38
  onChange,
@@ -40,7 +40,7 @@ const Decimal = ({
40
40
  onKeyPress,
41
41
  id,
42
42
  name,
43
- allowEmptyValue = false,
43
+ allowEmptyValue,
44
44
  required,
45
45
  locale,
46
46
  value,
@@ -309,5 +309,10 @@ Decimal.propTypes = {
309
309
  /** Aria label for rendered help component */
310
310
  helpAriaLabel: _propTypes.default.string
311
311
  };
312
+ Decimal.defaultProps = {
313
+ precision: 2,
314
+ allowEmptyValue: false,
315
+ align: "right"
316
+ };
312
317
  var _default = Decimal;
313
318
  exports.default = _default;
@@ -11,13 +11,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _reactDom = _interopRequireDefault(require("react-dom"));
13
13
 
14
- var _styledComponents = require("styled-components");
15
-
16
14
  var _guid = _interopRequireDefault(require("../../__internal__/utils/helpers/guid"));
17
15
 
18
16
  var _browser = _interopRequireDefault(require("../../__internal__/utils/helpers/browser"));
19
17
 
20
- var _carbonScopedTokensProvider = require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component");
18
+ var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
21
19
 
22
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
21
 
@@ -33,7 +31,6 @@ const Portal = ({
33
31
  }) => {
34
32
  const [portalNode, setPortalNode] = (0, _react.useState)(null);
35
33
  const uniqueId = (0, _react.useMemo)(() => (0, _guid.default)(), []);
36
- const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
37
34
  (0, _react.useEffect)(() => {
38
35
  if (onReposition) {
39
36
  onReposition();
@@ -68,7 +65,7 @@ const Portal = ({
68
65
  setPortalNode(node);
69
66
  } else if (!node) {
70
67
  node = document.createElement("div");
71
- node.classList.add(portalClassName, (0, _carbonScopedTokensProvider.tokensClassName)((theme === null || theme === void 0 ? void 0 : theme.name) || ""));
68
+ node.classList.add(portalClassName);
72
69
  node.setAttribute("data-portal-exit", uniqueId);
73
70
 
74
71
  if (id !== undefined) {
@@ -99,7 +96,7 @@ const Portal = ({
99
96
 
100
97
  return /*#__PURE__*/_react.default.createElement("span", {
101
98
  "data-portal-entrance": uniqueId
102
- }, /*#__PURE__*/_reactDom.default.createPortal(children, getPortalContainer()));
99
+ }, /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, children), getPortalContainer()));
103
100
  };
104
101
 
105
102
  Portal.propTypes = {
@@ -1,6 +1,12 @@
1
1
  export default ProgressTracker;
2
- declare function ProgressTracker({ size, progress, showDefaultLabels, currentProgressLabel, maxProgressLabel, orientation, direction, labelsPosition, ...rest }: {
2
+ declare function ProgressTracker({ "aria-label": ariaLabel, "aria-describedby": ariaDescribedBy, "aria-valuenow": ariaValueNow, "aria-valuemin": ariaValueMin, "aria-valuemax": ariaValueMax, "aria-valuetext": ariaValueText, size, progress, showDefaultLabels, currentProgressLabel, maxProgressLabel, orientation, direction, labelsPosition, ...rest }: {
3
3
  [x: string]: any;
4
+ "aria-label"?: string | undefined;
5
+ "aria-describedby": any;
6
+ "aria-valuenow": any;
7
+ "aria-valuemin": any;
8
+ "aria-valuemax": any;
9
+ "aria-valuetext": any;
4
10
  size?: string | undefined;
5
11
  progress?: number | undefined;
6
12
  showDefaultLabels?: boolean | undefined;
@@ -11,15 +17,40 @@ declare function ProgressTracker({ size, progress, showDefaultLabels, currentPro
11
17
  labelsPosition: any;
12
18
  }): JSX.Element;
13
19
  declare namespace ProgressTracker {
14
- namespace propTypes {
15
- const size: PropTypes.Requireable<string>;
16
- const progress: PropTypes.Requireable<number>;
17
- const showDefaultLabels: PropTypes.Requireable<boolean>;
18
- const currentProgressLabel: PropTypes.Requireable<string>;
19
- const maxProgressLabel: PropTypes.Requireable<string>;
20
- const orientation: PropTypes.Requireable<string>;
21
- const direction: PropTypes.Requireable<string>;
22
- const labelsPosition: PropTypes.Requireable<string>;
23
- }
20
+ const propTypes: {
21
+ /** Specifies an aria label to the component */
22
+ "aria-label": PropTypes.Requireable<string>;
23
+ /** Specifies the aria describedby for the component */
24
+ "aria-describedby": PropTypes.Requireable<string>;
25
+ /** The value of progress to be read out to the user. */
26
+ "aria-valuenow": PropTypes.Requireable<number>;
27
+ /** The minimum value of the progress tracker */
28
+ "aria-valuemin": PropTypes.Requireable<number>;
29
+ /** The maximum value of the progress tracker */
30
+ "aria-valuemax": PropTypes.Requireable<number>;
31
+ /** Prop to define the human readable text alternative of aria-valuenow
32
+ * if aria-valuenow is not a number
33
+ */
34
+ "aria-valuetext": PropTypes.Requireable<string>;
35
+ /** Size of the progress bar. */
36
+ size: PropTypes.Requireable<string>;
37
+ /** Current progress (percentage). */
38
+ progress: PropTypes.Requireable<number>;
39
+ /** Flag to control whether the default value labels (as percentages) should be rendered. */
40
+ showDefaultLabels: PropTypes.Requireable<boolean>;
41
+ /** Value to display as current progress. */
42
+ currentProgressLabel: PropTypes.Requireable<string>;
43
+ /** Value to display as the maximum progress limit. */
44
+ maxProgressLabel: PropTypes.Requireable<string>;
45
+ /** The orientation of the component. */
46
+ orientation: PropTypes.Requireable<string>;
47
+ /** The direction the bar should move as progress increases, only applies in vertical orientation. */
48
+ direction: PropTypes.Requireable<string>;
49
+ /**
50
+ * The position the value label are rendered in.
51
+ * Top/bottom apply to horizontal and left/right to vertical orientation.
52
+ */
53
+ labelsPosition: PropTypes.Requireable<string>;
54
+ };
24
55
  }
25
56
  import PropTypes from "prop-types";
@@ -24,6 +24,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
24
24
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
25
25
 
26
26
  const ProgressTracker = ({
27
+ "aria-label": ariaLabel = "progress tracker",
28
+ "aria-describedby": ariaDescribedBy,
29
+ "aria-valuenow": ariaValueNow,
30
+ "aria-valuemin": ariaValueMin,
31
+ "aria-valuemax": ariaValueMax,
32
+ "aria-valuetext": ariaValueText,
27
33
  size = "medium",
28
34
  progress = 0,
29
35
  showDefaultLabels = false,
@@ -63,7 +69,15 @@ const ProgressTracker = ({
63
69
  return /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressTracker, _extends({
64
70
  size: size,
65
71
  isVertical: isVertical
66
- }, rest, (0, _tags.default)("progress-bar", rest)), prefixLabels && renderValueLabels(), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressBar, {
72
+ }, rest, (0, _tags.default)("progress-bar", rest), {
73
+ role: "progressbar",
74
+ "aria-label": ariaLabel,
75
+ "aria-describedby": ariaDescribedBy,
76
+ "aria-valuenow": ariaValueNow,
77
+ "aria-valuemin": ariaValueMin,
78
+ "aria-valuemax": ariaValueMax,
79
+ "aria-valuetext": ariaValueText
80
+ }), prefixLabels && renderValueLabels(), /*#__PURE__*/_react.default.createElement(_progressTracker.StyledProgressBar, {
67
81
  direction: isVertical ? direction : undefined,
68
82
  isVertical: isVertical,
69
83
  size: size
@@ -76,6 +90,26 @@ const ProgressTracker = ({
76
90
 
77
91
  ProgressTracker.propTypes = { ...marginPropTypes,
78
92
 
93
+ /** Specifies an aria label to the component */
94
+ "aria-label": _propTypes.default.string,
95
+
96
+ /** Specifies the aria describedby for the component */
97
+ "aria-describedby": _propTypes.default.string,
98
+
99
+ /** The value of progress to be read out to the user. */
100
+ "aria-valuenow": _propTypes.default.number,
101
+
102
+ /** The minimum value of the progress tracker */
103
+ "aria-valuemin": _propTypes.default.number,
104
+
105
+ /** The maximum value of the progress tracker */
106
+ "aria-valuemax": _propTypes.default.number,
107
+
108
+ /** Prop to define the human readable text alternative of aria-valuenow
109
+ * if aria-valuenow is not a number
110
+ */
111
+ "aria-valuetext": _propTypes.default.string,
112
+
79
113
  /** Size of the progress bar. */
80
114
  size: _propTypes.default.oneOf(["small", "medium", "large"]),
81
115
 
@@ -1,6 +1,19 @@
1
1
  import { MarginProps } from "styled-system";
2
2
 
3
3
  export interface ProgressBarProps extends MarginProps {
4
+ /** Specifies an aria-label to the component */
5
+ "aria-label"?: string;
6
+ /** Specifies the aria-describedby for the component */
7
+ "aria-describedby"?: string;
8
+ /** The value of progress to be read out to the user. */
9
+ "aria-valuenow"?: number;
10
+ /** The minimum value of the progress tracker */
11
+ "aria-valuemin"?: number;
12
+ /** The maximum value of the progress tracker */
13
+ "aria-valueMax"?: number;
14
+ /** Prop to define the human readable text alternative of aria-valuenow
15
+ * if aria-valuenow is not a number */
16
+ "aria-valuetext"?: string;
4
17
  /** Size of the progressBar. */
5
18
  size?: "small" | "medium" | "large";
6
19
  /** Current progress (percentage). */
@@ -11,15 +11,13 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _headless = _interopRequireDefault(require("@tippyjs/react/headless"));
13
13
 
14
- var _styledComponents = require("styled-components");
15
-
16
14
  var _tooltip = _interopRequireDefault(require("./tooltip.style"));
17
15
 
18
16
  var _tooltipPointer = _interopRequireDefault(require("./tooltip-pointer.style"));
19
17
 
20
18
  var _tags = _interopRequireDefault(require("../../__internal__/utils/helpers/tags/tags"));
21
19
 
22
- var _carbonScopedTokensProvider = require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component");
20
+ var _carbonScopedTokensProvider = _interopRequireDefault(require("../../style/design-tokens/carbon-scoped-tokens-provider/carbon-scoped-tokens-provider.component"));
23
21
 
24
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
23
 
@@ -47,12 +45,10 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
47
45
  ...rest
48
46
  }, ref) => {
49
47
  const tooltipRef = (0, _react.useRef)(ref || null);
50
- const theme = (0, _react.useContext)(_styledComponents.ThemeContext);
51
48
 
52
49
  const tooltip = (attrs, content) => {
53
50
  const currentPosition = attrs["data-placement"] || position;
54
- return /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
55
- className: (0, _carbonScopedTokensProvider.tokensClassName)(theme === null || theme === void 0 ? void 0 : theme.name),
51
+ return /*#__PURE__*/_react.default.createElement(_carbonScopedTokensProvider.default, null, /*#__PURE__*/_react.default.createElement(_tooltip.default, _extends({
56
52
  "data-element": "tooltip",
57
53
  role: "tooltip",
58
54
  tabIndex: "-1",
@@ -75,7 +71,7 @@ const Tooltip = /*#__PURE__*/_react.default.forwardRef(({
75
71
  "data-popper-arrow": "",
76
72
  "data-element": "tooltip-pointer",
77
73
  bgColor: bgColor
78
- })), /*#__PURE__*/_react.default.createElement("div", null, content));
74
+ })), /*#__PURE__*/_react.default.createElement("div", null, content)));
79
75
  };
80
76
 
81
77
  return /*#__PURE__*/_react.default.createElement(_headless.default, _extends({
@@ -1,6 +1,8 @@
1
- export function tokensClassName(theme: any): string;
2
- export const GlobalTokens: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
3
1
  export default CarbonScopedTokensProvider;
4
- declare function CarbonScopedTokensProvider({ children }: {
5
- children: any;
6
- }): JSX.Element;
2
+ /**
3
+ *
4
+ * Converts theme properties to css variables form and set them locally for
5
+ * given scope
6
+ *
7
+ */
8
+ declare const CarbonScopedTokensProvider: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -3,20 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.GlobalTokens = exports.tokensClassName = void 0;
6
+ exports.default = void 0;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
 
10
- var _styledComponents = _interopRequireWildcard(require("styled-components"));
10
+ var _themes = require("../../themes");
11
11
 
12
12
  var _generateCssVariables = _interopRequireDefault(require("../generate-css-variables.util"));
13
13
 
14
- var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
15
-
16
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
17
-
18
- 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; }
19
-
20
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
15
 
22
16
  /**
@@ -25,37 +19,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
19
  * given scope
26
20
  *
27
21
  */
28
- const activeThemes = {};
29
- const carbonInstanceId = (0, _guid.default)();
30
-
31
- const kebabCase = input => input && input.toString().toLowerCase().match(/\w*/gm).filter(Boolean).join("-");
32
-
33
- const tokensClassName = theme => `sage-design-tokens-${kebabCase(theme)}-${carbonInstanceId}`;
34
-
35
- exports.tokensClassName = tokensClassName;
36
- const GlobalTokens = (0, _styledComponents.createGlobalStyle)`
37
- ${({
38
- theme
39
- }) => {
40
- const className = tokensClassName(theme.name);
41
- activeThemes[className] = activeThemes[className] || (0, _generateCssVariables.default)(theme.compatibility);
42
- return Object.entries(activeThemes).reduce((acc, [name, definitions]) => `${acc} .${name} { ${definitions} }`, "");
43
- }}`;
44
- exports.GlobalTokens = GlobalTokens;
45
- const TokensProviderWrapper = _styledComponents.default.div.attrs(({
46
- theme
47
- }) => ({
48
- className: tokensClassName(theme.name)
49
- }))`
22
+ const CarbonScopedTokensProvider = _styledComponents.default.div`
50
23
  margin: 0;
51
24
  padding: 0;
52
25
  width: auto;
53
26
  display: inline;
54
- `;
55
-
56
- const CarbonScopedTokensProvider = ({
57
- children
58
- }) => /*#__PURE__*/_react.default.createElement(TokensProviderWrapper, null, /*#__PURE__*/_react.default.createElement(GlobalTokens, null), children);
59
27
 
28
+ ${({
29
+ theme
30
+ }) => (0, _generateCssVariables.default)(theme.compatibility)}
31
+ `;
32
+ CarbonScopedTokensProvider.defaultProps = {
33
+ theme: _themes.baseTheme
34
+ };
60
35
  var _default = CarbonScopedTokensProvider;
61
36
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "103.0.0",
3
+ "version": "103.2.3",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {