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;
|
|
@@ -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 (
|
|
81
|
+
if (!disableAutoFocus) {
|
|
81
82
|
if (open) {
|
|
82
|
-
var
|
|
83
|
+
var _toastContentNodeRef$;
|
|
83
84
|
|
|
84
85
|
focusedElementBeforeOpening.current = document.activeElement;
|
|
85
|
-
(
|
|
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
|
-
|
|
82
|
-
|
|
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,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;
|