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.
- package/esm/components/accordion/accordion.style.js +1 -1
- package/esm/components/switch/__internal__/switch-slider-panel.style.d.ts +7 -0
- package/esm/components/switch/__internal__/switch-slider-panel.style.js +0 -5
- package/esm/components/switch/__internal__/switch-slider.component.d.ts +11 -0
- package/esm/components/switch/__internal__/switch-slider.component.js +8 -8
- package/esm/components/switch/__internal__/switch-slider.style.d.ts +6 -0
- package/esm/components/switch/__internal__/switch-slider.style.js +0 -9
- package/esm/components/switch/index.d.ts +2 -1
- package/esm/components/switch/switch.component.d.ts +31 -0
- package/esm/components/switch/switch.component.js +522 -124
- package/esm/components/switch/switch.style.d.ts +4 -0
- package/esm/components/switch/switch.style.js +0 -8
- package/esm/components/toast/toast.component.js +9 -4
- package/esm/components/toast/toast.style.js +5 -2
- package/lib/components/accordion/accordion.style.js +1 -1
- package/lib/components/switch/__internal__/switch-slider-panel.style.d.ts +7 -0
- package/lib/components/switch/__internal__/switch-slider-panel.style.js +0 -6
- package/lib/components/switch/__internal__/switch-slider.component.d.ts +11 -0
- package/lib/components/switch/__internal__/switch-slider.component.js +8 -8
- package/lib/components/switch/__internal__/switch-slider.style.d.ts +6 -0
- package/lib/components/switch/__internal__/switch-slider.style.js +0 -10
- package/lib/components/switch/index.d.ts +2 -1
- package/lib/components/switch/switch.component.d.ts +31 -0
- package/lib/components/switch/switch.component.js +523 -127
- package/lib/components/switch/switch.style.d.ts +4 -0
- package/lib/components/switch/switch.style.js +0 -9
- package/lib/components/toast/toast.component.js +8 -3
- package/lib/components/toast/toast.style.js +5 -2
- package/package.json +1 -1
- package/esm/components/switch/switch.d.ts +0 -37
- 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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { margin } from "styled-system";
|
|
4
3
|
import baseTheme from "../../style/themes/base";
|
|
5
4
|
import FieldHelpStyle from "../../__internal__/field-help/field-help.style";
|
|
@@ -150,13 +149,6 @@ const StyledSwitch = styled.div`
|
|
|
150
149
|
`}
|
|
151
150
|
`}
|
|
152
151
|
`;
|
|
153
|
-
StyledSwitch.propTypes = {
|
|
154
|
-
disabled: PropTypes.bool,
|
|
155
|
-
fieldHelpInline: PropTypes.bool,
|
|
156
|
-
labelInline: PropTypes.bool,
|
|
157
|
-
reverse: PropTypes.bool,
|
|
158
|
-
size: PropTypes.string
|
|
159
|
-
};
|
|
160
152
|
StyledSwitch.defaultProps = {
|
|
161
153
|
theme: baseTheme
|
|
162
154
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
|
-
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
5
|
import { TransitionGroup, CSSTransition } from "react-transition-group";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
@@ -32,6 +32,7 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
32
32
|
const toastContentNodeRef = useRef();
|
|
33
33
|
const closeIconRef = useRef();
|
|
34
34
|
const focusedElementBeforeOpening = useRef();
|
|
35
|
+
const [tabIndex, setTabIndex] = useState(0);
|
|
35
36
|
const refToPass = ref || toastRef;
|
|
36
37
|
const componentClasses = useMemo(() => {
|
|
37
38
|
return classNames(className);
|
|
@@ -53,15 +54,16 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
53
54
|
timer.current = setTimeout(() => onDismiss(), timeout);
|
|
54
55
|
}, [onDismiss, open, timeout]);
|
|
55
56
|
useEffect(() => {
|
|
56
|
-
if (
|
|
57
|
+
if (!disableAutoFocus) {
|
|
57
58
|
if (open) {
|
|
58
|
-
var
|
|
59
|
+
var _toastContentNodeRef$;
|
|
59
60
|
|
|
60
61
|
focusedElementBeforeOpening.current = document.activeElement;
|
|
61
|
-
(
|
|
62
|
+
(_toastContentNodeRef$ = toastContentNodeRef.current) === null || _toastContentNodeRef$ === void 0 ? void 0 : _toastContentNodeRef$.focus();
|
|
62
63
|
} else if (focusedElementBeforeOpening.current) {
|
|
63
64
|
focusedElementBeforeOpening.current.focus();
|
|
64
65
|
focusedElementBeforeOpening.current = undefined;
|
|
66
|
+
setTabIndex(0);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}, [open, onDismiss, disableAutoFocus]);
|
|
@@ -107,6 +109,9 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
107
109
|
className: componentClasses
|
|
108
110
|
}, tagComponent(restProps["data-component"] || "toast", restProps), toastProps, {
|
|
109
111
|
ref: toastContentNodeRef
|
|
112
|
+
}, !disableAutoFocus && {
|
|
113
|
+
tabIndex,
|
|
114
|
+
onBlur: () => setTabIndex(undefined)
|
|
110
115
|
}), !isNotice && /*#__PURE__*/React.createElement(TypeIcon, {
|
|
111
116
|
variant: toastProps.variant
|
|
112
117
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -50,8 +50,11 @@ const ToastStyle = styled(MessageStyle)`
|
|
|
50
50
|
margin-right: ${isCenter ? "auto" : "30px"};
|
|
51
51
|
`}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
:focus {
|
|
54
|
+
outline: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&${animationName}-appear, &${animationName}-enter {
|
|
55
58
|
opacity: 0;
|
|
56
59
|
transform: scale(0.5);
|
|
57
60
|
}
|
|
@@ -160,7 +160,7 @@ const StyledAccordionTitleContainer = _styledComponents.default.div`
|
|
|
160
160
|
|
|
161
161
|
${!hasButtonProps && (0, _styledComponents.css)`
|
|
162
162
|
${StyledAccordionHeadingsContainer} {
|
|
163
|
-
margin-left: ${iconAlign === "right" ? "
|
|
163
|
+
margin-left: ${iconAlign === "right" ? "var(--spacing300)" : "var(--spacing100)"};
|
|
164
164
|
}
|
|
165
165
|
`}
|
|
166
166
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SwitchProps } from "../switch.component";
|
|
2
|
+
export interface SwitchSliderPanelProps {
|
|
3
|
+
isLoading?: boolean;
|
|
4
|
+
size?: SwitchProps["size"];
|
|
5
|
+
}
|
|
6
|
+
declare const SwitchSliderPanel: import("styled-components").StyledComponent<"div", any, SwitchSliderPanelProps, never>;
|
|
7
|
+
export default SwitchSliderPanel;
|
|
@@ -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 _loader = _interopRequireDefault(require("../../loader/loader.style"));
|
|
13
11
|
|
|
14
12
|
var _loaderSquare = _interopRequireDefault(require("../../loader/loader-square.style"));
|
|
@@ -76,9 +74,5 @@ const SwitchSliderPanel = _styledComponents.default.div`
|
|
|
76
74
|
`}
|
|
77
75
|
`}
|
|
78
76
|
`;
|
|
79
|
-
SwitchSliderPanel.propTypes = {
|
|
80
|
-
isLoading: _propTypes.default.bool,
|
|
81
|
-
size: _propTypes.default.string
|
|
82
|
-
};
|
|
83
77
|
var _default = SwitchSliderPanel;
|
|
84
78
|
exports.default = _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ValidationProps } from "../../../__internal__/validations";
|
|
3
|
+
export interface SwitchSliderProps extends ValidationProps {
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
size?: "small" | "large";
|
|
8
|
+
useValidationIcon?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const SwitchSlider: ({ checked, disabled, loading, size, error, warning, info, useValidationIcon, }: SwitchSliderProps) => JSX.Element;
|
|
11
|
+
export default SwitchSlider;
|
|
@@ -66,14 +66,14 @@ const SwitchSlider = ({
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
SwitchSlider.propTypes = {
|
|
69
|
-
checked: _propTypes.default.bool,
|
|
70
|
-
disabled: _propTypes.default.bool,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
"checked": _propTypes.default.bool,
|
|
70
|
+
"disabled": _propTypes.default.bool,
|
|
71
|
+
"error": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
72
|
+
"info": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
73
|
+
"loading": _propTypes.default.bool,
|
|
74
|
+
"size": _propTypes.default.oneOf(["large", "small"]),
|
|
75
|
+
"useValidationIcon": _propTypes.default.bool,
|
|
76
|
+
"warning": _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
|
|
77
77
|
};
|
|
78
78
|
var _default = SwitchSlider;
|
|
79
79
|
exports.default = _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SwitchSliderProps } from "./switch-slider.component";
|
|
2
|
+
interface StyledSwitchSliderProps extends Pick<SwitchSliderProps, "checked" | "disabled" | "size" | "error" | "warning"> {
|
|
3
|
+
isLoading?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const StyledSwitchSlider: import("styled-components").StyledComponent<"span", any, StyledSwitchSliderProps, never>;
|
|
6
|
+
export default StyledSwitchSlider;
|
|
@@ -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 _switchSliderPanel = _interopRequireDefault(require("./switch-slider-panel.style"));
|
|
13
11
|
|
|
14
12
|
var _validationIcon = _interopRequireDefault(require("../../../__internal__/validations/validation-icon.style"));
|
|
@@ -124,13 +122,5 @@ const StyledSwitchSlider = _styledComponents.default.span`
|
|
|
124
122
|
}
|
|
125
123
|
`}
|
|
126
124
|
`;
|
|
127
|
-
StyledSwitchSlider.propTypes = {
|
|
128
|
-
checked: _propTypes.default.bool,
|
|
129
|
-
disabled: _propTypes.default.bool,
|
|
130
|
-
size: _propTypes.default.string,
|
|
131
|
-
isLoading: _propTypes.default.bool,
|
|
132
|
-
error: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool]),
|
|
133
|
-
warning: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.bool])
|
|
134
|
-
};
|
|
135
125
|
var _default = StyledSwitchSlider;
|
|
136
126
|
exports.default = _default;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./switch";
|
|
1
|
+
export { default } from "./switch.component";
|
|
2
|
+
export type { SwitchProps } from "./switch.component";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { CommonCheckableInputProps } from "../../__internal__/checkable-input";
|
|
4
|
+
export interface SwitchProps extends CommonCheckableInputProps, MarginProps {
|
|
5
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
6
|
+
"data-component"?: string;
|
|
7
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
|
+
"data-element"?: string;
|
|
9
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
10
|
+
"data-role"?: string;
|
|
11
|
+
/** Breakpoint for adaptive label (inline labels change to top aligned). Enables the adaptive behaviour when set */
|
|
12
|
+
adaptiveLabelBreakpoint?: number;
|
|
13
|
+
/** Set the default value of the Switch if component is meant to be used as uncontrolled */
|
|
14
|
+
defaultChecked?: boolean;
|
|
15
|
+
/** Text alignment of the label */
|
|
16
|
+
labelAlign?: "left" | "right";
|
|
17
|
+
/** When true label is inline */
|
|
18
|
+
labelInline?: boolean;
|
|
19
|
+
/** Triggers loading animation */
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
/** When true, validation icon will be placed on label instead of being placed on the input */
|
|
22
|
+
validationOnLabel?: boolean;
|
|
23
|
+
/** The value of the switch, passed on form submit */
|
|
24
|
+
value?: string;
|
|
25
|
+
/** Overrides the default tooltip position */
|
|
26
|
+
tooltipPosition?: "top" | "bottom" | "left" | "right";
|
|
27
|
+
/** Aria label for rendered help component */
|
|
28
|
+
helpAriaLabel?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const Switch: ({ autoFocus, id, label, onChange, onBlur, onFocus, value, checked, defaultChecked, disabled, loading, reverse, validationOnLabel, labelInline, labelSpacing, labelHelp, fieldHelpInline, size, name, adaptiveLabelBreakpoint, tooltipPosition, error, warning, info, "data-component": dataComponent, "data-element": dataElement, "data-role": dataRole, helpAriaLabel, ...rest }: SwitchProps) => JSX.Element;
|
|
31
|
+
export default Switch;
|