carbon-react 111.12.0 → 111.12.2

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.
Files changed (31) hide show
  1. package/esm/components/accordion/accordion.style.js +1 -1
  2. package/esm/components/switch/__internal__/switch-slider-panel.style.d.ts +7 -0
  3. package/esm/components/switch/__internal__/switch-slider-panel.style.js +0 -5
  4. package/esm/components/switch/__internal__/switch-slider.component.d.ts +11 -0
  5. package/esm/components/switch/__internal__/switch-slider.component.js +8 -8
  6. package/esm/components/switch/__internal__/switch-slider.style.d.ts +6 -0
  7. package/esm/components/switch/__internal__/switch-slider.style.js +0 -9
  8. package/esm/components/switch/index.d.ts +2 -1
  9. package/esm/components/switch/switch.component.d.ts +31 -0
  10. package/esm/components/switch/switch.component.js +522 -124
  11. package/esm/components/switch/switch.style.d.ts +4 -0
  12. package/esm/components/switch/switch.style.js +0 -8
  13. package/esm/components/toast/toast.component.js +9 -4
  14. package/esm/components/toast/toast.style.js +5 -2
  15. package/lib/components/accordion/accordion.style.js +1 -1
  16. package/lib/components/switch/__internal__/switch-slider-panel.style.d.ts +7 -0
  17. package/lib/components/switch/__internal__/switch-slider-panel.style.js +0 -6
  18. package/lib/components/switch/__internal__/switch-slider.component.d.ts +11 -0
  19. package/lib/components/switch/__internal__/switch-slider.component.js +8 -8
  20. package/lib/components/switch/__internal__/switch-slider.style.d.ts +6 -0
  21. package/lib/components/switch/__internal__/switch-slider.style.js +0 -10
  22. package/lib/components/switch/index.d.ts +2 -1
  23. package/lib/components/switch/switch.component.d.ts +31 -0
  24. package/lib/components/switch/switch.component.js +523 -127
  25. package/lib/components/switch/switch.style.d.ts +4 -0
  26. package/lib/components/switch/switch.style.js +0 -9
  27. package/lib/components/toast/toast.component.js +8 -3
  28. package/lib/components/toast/toast.style.js +5 -2
  29. package/package.json +1 -1
  30. package/esm/components/switch/switch.d.ts +0 -37
  31. package/lib/components/switch/switch.d.ts +0 -37
@@ -0,0 +1,4 @@
1
+ import { SwitchProps } from "./switch.component";
2
+ declare type StyledSwitchProps = Pick<SwitchProps, "fieldHelpInline" | "labelInline" | "reverse" | "size">;
3
+ declare const StyledSwitch: import("styled-components").StyledComponent<"div", any, StyledSwitchProps, never>;
4
+ export default StyledSwitch;
@@ -7,8 +7,6 @@ exports.default = void 0;
7
7
 
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
 
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
10
  var _styledSystem = require("styled-system");
13
11
 
14
12
  var _base = _interopRequireDefault(require("../../style/themes/base"));
@@ -174,13 +172,6 @@ const StyledSwitch = _styledComponents.default.div`
174
172
  `}
175
173
  `}
176
174
  `;
177
- StyledSwitch.propTypes = {
178
- disabled: _propTypes.default.bool,
179
- fieldHelpInline: _propTypes.default.bool,
180
- labelInline: _propTypes.default.bool,
181
- reverse: _propTypes.default.bool,
182
- size: _propTypes.default.string
183
- };
184
175
  StyledSwitch.defaultProps = {
185
176
  theme: _base.default
186
177
  };
@@ -56,6 +56,7 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
56
56
  const toastContentNodeRef = (0, _react.useRef)();
57
57
  const closeIconRef = (0, _react.useRef)();
58
58
  const focusedElementBeforeOpening = (0, _react.useRef)();
59
+ const [tabIndex, setTabIndex] = (0, _react.useState)(0);
59
60
  const refToPass = ref || toastRef;
60
61
  const componentClasses = (0, _react.useMemo)(() => {
61
62
  return (0, _classnames.default)(className);
@@ -77,15 +78,16 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
77
78
  timer.current = setTimeout(() => onDismiss(), timeout);
78
79
  }, [onDismiss, open, timeout]);
79
80
  (0, _react.useEffect)(() => {
80
- if (onDismiss && !disableAutoFocus) {
81
+ if (!disableAutoFocus) {
81
82
  if (open) {
82
- var _closeIconRef$current;
83
+ var _toastContentNodeRef$;
83
84
 
84
85
  focusedElementBeforeOpening.current = document.activeElement;
85
- (_closeIconRef$current = closeIconRef.current) === null || _closeIconRef$current === void 0 ? void 0 : _closeIconRef$current.focus();
86
+ (_toastContentNodeRef$ = toastContentNodeRef.current) === null || _toastContentNodeRef$ === void 0 ? void 0 : _toastContentNodeRef$.focus();
86
87
  } else if (focusedElementBeforeOpening.current) {
87
88
  focusedElementBeforeOpening.current.focus();
88
89
  focusedElementBeforeOpening.current = undefined;
90
+ setTabIndex(0);
89
91
  }
90
92
  }
91
93
  }, [open, onDismiss, disableAutoFocus]);
@@ -131,6 +133,9 @@ const Toast = /*#__PURE__*/_react.default.forwardRef(({
131
133
  className: componentClasses
132
134
  }, (0, _tags.default)(restProps["data-component"] || "toast", restProps), toastProps, {
133
135
  ref: toastContentNodeRef
136
+ }, !disableAutoFocus && {
137
+ tabIndex,
138
+ onBlur: () => setTabIndex(undefined)
134
139
  }), !isNotice && /*#__PURE__*/_react.default.createElement(_toast.TypeIcon, {
135
140
  variant: toastProps.variant
136
141
  }, /*#__PURE__*/_react.default.createElement(_icon.default, {
@@ -78,8 +78,11 @@ const ToastStyle = (0, _styledComponents.default)(_message.default)`
78
78
  margin-right: ${isCenter ? "auto" : "30px"};
79
79
  `}
80
80
 
81
- &${animationName}-appear,
82
- &${animationName}-enter {
81
+ :focus {
82
+ outline: none;
83
+ }
84
+
85
+ &${animationName}-appear, &${animationName}-enter {
83
86
  opacity: 0;
84
87
  transform: scale(0.5);
85
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "111.12.0",
3
+ "version": "111.12.2",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",
@@ -1,37 +0,0 @@
1
- import * as React from "react";
2
- import { MarginProps } from "styled-system";
3
- import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
4
-
5
- export type LabelAlign = "left" | "right";
6
-
7
- export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
8
- /** Identifier used for testing purposes, applied to the root element of the component. */
9
- "data-component"?: string;
10
- /** Identifier used for testing purposes, applied to the root element of the component. */
11
- "data-element"?: string;
12
- /** Identifier used for testing purposes, applied to the root element of the component. */
13
- "data-role"?: string;
14
- /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
15
- adaptiveLabelBreakpoint?: number;
16
- /** Set the default value of the Switch if component is meant to be used as uncontrolled */
17
- defaultChecked?: boolean;
18
- /** Text alignment of the label */
19
- labelAlign?: LabelAlign;
20
- /** When true label is inline */
21
- labelInline?: boolean;
22
- /** Triggers loading animation */
23
- loading?: boolean;
24
- /** When true, validation icon will be placed on label instead of being placed on the input */
25
- validationOnLabel?: boolean;
26
- /** The value of the switch, passed on form submit */
27
- value?: string;
28
- /** Overrides the default tooltip position */
29
- tooltipPosition?: "top" | "bottom" | "left" | "right";
30
- /** Aria label for rendered help component */
31
- helpAriaLabel?: string;
32
- }
33
-
34
- declare function Switch(props: SwitchProps): JSX.Element;
35
-
36
- export { Switch as BaseSwitch };
37
- export default Switch;
@@ -1,37 +0,0 @@
1
- import * as React from "react";
2
- import { MarginProps } from "styled-system";
3
- import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
4
-
5
- export type LabelAlign = "left" | "right";
6
-
7
- export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
8
- /** Identifier used for testing purposes, applied to the root element of the component. */
9
- "data-component"?: string;
10
- /** Identifier used for testing purposes, applied to the root element of the component. */
11
- "data-element"?: string;
12
- /** Identifier used for testing purposes, applied to the root element of the component. */
13
- "data-role"?: string;
14
- /** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
15
- adaptiveLabelBreakpoint?: number;
16
- /** Set the default value of the Switch if component is meant to be used as uncontrolled */
17
- defaultChecked?: boolean;
18
- /** Text alignment of the label */
19
- labelAlign?: LabelAlign;
20
- /** When true label is inline */
21
- labelInline?: boolean;
22
- /** Triggers loading animation */
23
- loading?: boolean;
24
- /** When true, validation icon will be placed on label instead of being placed on the input */
25
- validationOnLabel?: boolean;
26
- /** The value of the switch, passed on form submit */
27
- value?: string;
28
- /** Overrides the default tooltip position */
29
- tooltipPosition?: "top" | "bottom" | "left" | "right";
30
- /** Aria label for rendered help component */
31
- helpAriaLabel?: string;
32
- }
33
-
34
- declare function Switch(props: SwitchProps): JSX.Element;
35
-
36
- export { Switch as BaseSwitch };
37
- export default Switch;