carbon-react 141.4.3 → 142.0.0
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/file-input/__internal__/file-upload-status/file-upload-status.component.js +12 -4
- package/esm/components/loader/loader.component.js +2 -1
- package/esm/components/message/{message-content → __internal__/message-content}/message-content.component.d.ts +0 -4
- package/esm/components/message/{message-content → __internal__/message-content}/message-content.component.js +2 -2
- package/{lib/components/message → esm/components/message/__internal__}/type-icon/type-icon.component.d.ts +2 -4
- package/esm/components/message/{type-icon → __internal__/type-icon}/type-icon.component.js +3 -3
- package/{lib/components/message → esm/components/message/__internal__}/type-icon/type-icon.style.d.ts +1 -3
- package/esm/components/message/message.component.js +2 -2
- package/esm/components/numeral-date/numeral-date.component.js +2 -1
- package/esm/components/progress-tracker/progress-tracker.component.d.ts +4 -21
- package/esm/components/progress-tracker/progress-tracker.component.js +12 -51
- package/esm/components/progress-tracker/progress-tracker.style.d.ts +2 -2
- package/esm/components/progress-tracker/progress-tracker.style.js +2 -4
- package/esm/components/switch/__internal__/switch-slider-panel.style.js +5 -2
- package/esm/components/switch/__internal__/switch-slider.component.js +17 -5
- package/esm/components/switch/__internal__/switch-slider.style.d.ts +9 -1
- package/esm/components/switch/__internal__/switch-slider.style.js +56 -49
- package/esm/components/switch/switch.style.js +15 -5
- package/esm/components/toast/toast.style.d.ts +1 -1
- package/esm/components/toast/toast.style.js +1 -1
- package/lib/components/file-input/__internal__/file-upload-status/file-upload-status.component.js +12 -4
- package/lib/components/loader/loader.component.js +2 -1
- package/lib/components/message/{message-content → __internal__/message-content}/message-content.component.d.ts +0 -4
- package/lib/components/message/{message-content → __internal__/message-content}/message-content.component.js +2 -2
- package/{esm/components/message → lib/components/message/__internal__}/type-icon/type-icon.component.d.ts +2 -4
- package/lib/components/message/{type-icon → __internal__/type-icon}/type-icon.component.js +3 -3
- package/{esm/components/message → lib/components/message/__internal__}/type-icon/type-icon.style.d.ts +1 -3
- package/lib/components/message/message.component.js +2 -2
- package/lib/components/numeral-date/numeral-date.component.js +2 -1
- package/lib/components/progress-tracker/progress-tracker.component.d.ts +4 -21
- package/lib/components/progress-tracker/progress-tracker.component.js +12 -53
- package/lib/components/progress-tracker/progress-tracker.style.d.ts +2 -2
- package/lib/components/progress-tracker/progress-tracker.style.js +2 -4
- package/lib/components/switch/__internal__/switch-slider-panel.style.js +5 -2
- package/lib/components/switch/__internal__/switch-slider.component.js +17 -5
- package/lib/components/switch/__internal__/switch-slider.style.d.ts +9 -1
- package/lib/components/switch/__internal__/switch-slider.style.js +56 -50
- package/lib/components/switch/switch.style.js +15 -5
- package/lib/components/toast/toast.style.d.ts +1 -1
- package/lib/components/toast/toast.style.js +1 -1
- package/package.json +1 -1
- /package/esm/components/message/{message-content → __internal__/message-content}/message-content.style.d.ts +0 -0
- /package/esm/components/message/{message-content → __internal__/message-content}/message-content.style.js +0 -0
- /package/esm/components/message/{type-icon → __internal__/type-icon}/type-icon.style.js +0 -0
- /package/lib/components/message/{message-content → __internal__/message-content}/message-content.style.d.ts +0 -0
- /package/lib/components/message/{message-content → __internal__/message-content}/message-content.style.js +0 -0
- /package/lib/components/message/{type-icon → __internal__/type-icon}/type-icon.style.js +0 -0
package/esm/components/file-input/__internal__/file-upload-status/file-upload-status.component.js
CHANGED
|
@@ -3,7 +3,7 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import Link from "../../../link";
|
|
4
4
|
import ButtonMinor from "../../../button-minor";
|
|
5
5
|
import StyledTypography from "../../../typography/typography.style";
|
|
6
|
-
import
|
|
6
|
+
import { StyledProgressBar, InnerBar } from "../../../progress-tracker/progress-tracker.style";
|
|
7
7
|
import LoaderBar from "../../../loader-bar";
|
|
8
8
|
import Icon from "../../../icon";
|
|
9
9
|
import { StyledFileUploadStatus, StyledFileUploadStatusRow, StyledFileLinkContainer } from "./file-upload-status.style";
|
|
@@ -24,10 +24,18 @@ export const FileUploadStatus = ({
|
|
|
24
24
|
switch (status) {
|
|
25
25
|
case "uploading":
|
|
26
26
|
buttonText = locale.fileInput.actions.cancel();
|
|
27
|
-
progressBar = statusProps.progress === undefined ? /*#__PURE__*/React.createElement(LoaderBar, null) : /*#__PURE__*/React.createElement(
|
|
27
|
+
progressBar = statusProps.progress === undefined ? /*#__PURE__*/React.createElement(LoaderBar, null) : /*#__PURE__*/React.createElement(StyledProgressBar, {
|
|
28
|
+
"data-element": "progress-tracker-bar",
|
|
29
|
+
"data-role": "progress-tracker-bar",
|
|
28
30
|
progress: statusProps.progress,
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
+
"aria-hidden": "true"
|
|
32
|
+
}, /*#__PURE__*/React.createElement(InnerBar, {
|
|
33
|
+
"data-element": "inner-bar",
|
|
34
|
+
"data-role": "inner-bar",
|
|
35
|
+
size: "medium",
|
|
36
|
+
progress: statusProps.progress,
|
|
37
|
+
error: false
|
|
38
|
+
}));
|
|
31
39
|
break;
|
|
32
40
|
case "previously":
|
|
33
41
|
case "completed":
|
|
@@ -29,8 +29,9 @@ export const Loader = ({
|
|
|
29
29
|
"aria-label": ariaLabel || l.loader.loading(),
|
|
30
30
|
role: "progressbar"
|
|
31
31
|
}, tagComponent("loader", rest), filterStyledSystemMarginProps(rest)), reduceMotion ? l.loader.loading() : /*#__PURE__*/React.createElement(React.Fragment, null, ["#13A038", "#0092DB", "#8F49FE"].map(color => /*#__PURE__*/React.createElement(StyledLoaderSquare, _extends({
|
|
32
|
+
"data-role": "loader-square",
|
|
32
33
|
key: color,
|
|
33
|
-
backgroundColor: variant === "gradient" ? color : "var(--colorsActionMajor500)"
|
|
34
|
+
backgroundColor: variant === "gradient" ? /* istanbul ignore next */color : "var(--colorsActionMajor500)"
|
|
34
35
|
}, loaderSquareProps)))));
|
|
35
36
|
};
|
|
36
37
|
export default Loader;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface MessageContentProps {
|
|
3
|
-
/** set message title */
|
|
4
3
|
title?: React.ReactNode;
|
|
5
|
-
/** set content to component */
|
|
6
4
|
children?: React.ReactNode;
|
|
7
|
-
/** determines if the close icon is shown */
|
|
8
5
|
showCloseIcon?: boolean;
|
|
9
|
-
/** @ignore @private used to reduce the left-padding for the transparent variant */
|
|
10
6
|
reduceLeftPadding?: boolean;
|
|
11
7
|
}
|
|
12
8
|
declare const MessageContent: ({ title, children, showCloseIcon, reduceLeftPadding, }: MessageContentProps) => React.JSX.Element;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
|
-
import Content from "
|
|
3
|
+
import Content from "../../../content";
|
|
4
4
|
import MessageContentStyle from "./message-content.style";
|
|
5
5
|
const MessageContent = ({
|
|
6
6
|
title,
|
|
7
7
|
children,
|
|
8
8
|
showCloseIcon,
|
|
9
|
-
reduceLeftPadding
|
|
9
|
+
reduceLeftPadding
|
|
10
10
|
}) => {
|
|
11
11
|
return /*#__PURE__*/React.createElement(MessageContentStyle, {
|
|
12
12
|
showCloseIcon: showCloseIcon,
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { MessageVariant } from "
|
|
2
|
+
import { MessageVariant } from "../../message.component";
|
|
3
3
|
export interface TypeIconProps {
|
|
4
|
-
/** set background to be invisible */
|
|
5
4
|
transparent?: boolean;
|
|
6
|
-
|
|
7
|
-
variant?: MessageVariant;
|
|
5
|
+
variant: MessageVariant;
|
|
8
6
|
}
|
|
9
7
|
declare const TypeIcon: ({ variant, transparent }: TypeIconProps) => React.JSX.Element;
|
|
10
8
|
export default TypeIcon;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import TypeIconStyle from "./type-icon.style";
|
|
4
|
-
import Icon from "
|
|
4
|
+
import Icon from "../../../icon";
|
|
5
5
|
const TypeIcon = ({
|
|
6
|
-
variant
|
|
7
|
-
transparent
|
|
6
|
+
variant,
|
|
7
|
+
transparent
|
|
8
8
|
}) => {
|
|
9
9
|
function iconToRender() {
|
|
10
10
|
if (variant === "neutral") return "info";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { MessageVariant } from "
|
|
1
|
+
import { MessageVariant } from "../../message.component";
|
|
2
2
|
declare type TypeIconStyleProps = {
|
|
3
|
-
/** set background to be invisible */
|
|
4
3
|
transparent?: boolean;
|
|
5
|
-
/** set type of message based on new DLS standard */
|
|
6
4
|
variant: MessageVariant;
|
|
7
5
|
};
|
|
8
6
|
declare const TypeIconStyle: import("styled-components").StyledComponent<"div", any, TypeIconStyleProps, never>;
|
|
@@ -2,8 +2,8 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
2
2
|
import React, { useRef } from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import MessageStyle from "./message.style";
|
|
5
|
-
import TypeIcon from "./type-icon/type-icon.component";
|
|
6
|
-
import MessageContent from "./message-content/message-content.component";
|
|
5
|
+
import TypeIcon from "./__internal__/type-icon/type-icon.component";
|
|
6
|
+
import MessageContent from "./__internal__/message-content/message-content.component";
|
|
7
7
|
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
8
8
|
import Icon from "../icon";
|
|
9
9
|
import IconButton from "../icon-button";
|
|
@@ -264,7 +264,8 @@ export const NumeralDate = ({
|
|
|
264
264
|
marginBottom: undefined
|
|
265
265
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
266
266
|
mb: "4px",
|
|
267
|
-
id: labelId
|
|
267
|
+
id: labelId,
|
|
268
|
+
"data-role": "numeral-date-input-text"
|
|
268
269
|
}, getDateLabel(datePart, locale)), /*#__PURE__*/React.createElement(Textbox, _extends({}, index === 0 && {
|
|
269
270
|
id: uniqueId
|
|
270
271
|
}, {
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MarginProps } from "styled-system";
|
|
3
3
|
export interface ProgressTrackerProps extends MarginProps {
|
|
4
|
-
/** (Deprecated) Specifies an aria label to the component */
|
|
5
|
-
"aria-label"?: string;
|
|
6
|
-
/** (Deprecated) Specifies the aria describedby for the component */
|
|
7
|
-
"aria-describedby"?: string;
|
|
8
|
-
/** (Deprecated) The value of progress to be read out to the user. */
|
|
9
|
-
"aria-valuenow"?: number;
|
|
10
|
-
/** (Deprecated) The minimum value of the progress tracker */
|
|
11
|
-
"aria-valuemin"?: number;
|
|
12
|
-
/** (Deprecated) The maximum value of the progress tracker */
|
|
13
|
-
"aria-valuemax"?: number;
|
|
14
|
-
/** (Deprecated) Prop to define the human readable text alternative of aria-valuenow
|
|
15
|
-
* if aria-valuenow is not a number
|
|
16
|
-
*/
|
|
17
|
-
"aria-valuetext"?: string;
|
|
18
4
|
/** Size of the progress bar. */
|
|
19
5
|
size?: "small" | "medium" | "large";
|
|
20
6
|
/** Length of the component, any valid css string. */
|
|
21
7
|
length?: string;
|
|
22
8
|
/** Current progress (percentage). */
|
|
23
9
|
progress?: number;
|
|
24
|
-
/**
|
|
10
|
+
/** Flag to control error state. */
|
|
25
11
|
error?: boolean;
|
|
26
|
-
/** Flag to control whether the default value labels (as percentages) should be rendered. */
|
|
27
|
-
description?: string;
|
|
28
12
|
/** Value to add a description to the label */
|
|
29
|
-
|
|
13
|
+
description?: string;
|
|
30
14
|
/** Value to display as current progress. */
|
|
31
15
|
currentProgressLabel?: string;
|
|
32
16
|
/** Value to display as the maximum progress limit. */
|
|
@@ -35,14 +19,13 @@ export interface ProgressTrackerProps extends MarginProps {
|
|
|
35
19
|
customValuePreposition?: string;
|
|
36
20
|
/**
|
|
37
21
|
* The position the value label are rendered in.
|
|
38
|
-
* Top/bottom apply to horizontal and left applies to vertical orientation.
|
|
39
22
|
*/
|
|
40
23
|
labelsPosition?: "top" | "bottom" | "left";
|
|
41
|
-
/** Label width */
|
|
24
|
+
/** Label width when position is "left" */
|
|
42
25
|
labelWidth?: string;
|
|
43
26
|
}
|
|
44
27
|
declare const ProgressTracker: {
|
|
45
|
-
({
|
|
28
|
+
({ size, length, error, progress, description, currentProgressLabel, customValuePreposition, maxProgressLabel, labelsPosition, labelWidth, ...rest }: ProgressTrackerProps): React.JSX.Element;
|
|
46
29
|
displayName: string;
|
|
47
30
|
};
|
|
48
31
|
export default ProgressTracker;
|
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React
|
|
2
|
+
import React from "react";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
5
5
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
6
6
|
import { StyledProgressBar, InnerBar, StyledValuesLabel, StyledProgressTracker, StyledValue, StyledDescription } from "./progress-tracker.style";
|
|
7
|
-
import useResizeObserver from "../../hooks/__internal__/useResizeObserver";
|
|
8
|
-
import Logger from "../../__internal__/utils/logger";
|
|
9
|
-
let deprecatedAriaTagsWarnTriggered = false;
|
|
10
7
|
const ProgressTracker = ({
|
|
11
|
-
"aria-label": ariaLabel,
|
|
12
|
-
"aria-describedby": ariaDescribedBy,
|
|
13
|
-
"aria-valuenow": ariaValueNow,
|
|
14
|
-
"aria-valuemin": ariaValueMin,
|
|
15
|
-
"aria-valuemax": ariaValueMax,
|
|
16
|
-
"aria-valuetext": ariaValueText,
|
|
17
8
|
size = "medium",
|
|
18
9
|
length = "256px",
|
|
19
10
|
error = false,
|
|
20
11
|
progress = 0,
|
|
21
12
|
description,
|
|
22
|
-
showDefaultLabels = false,
|
|
23
13
|
currentProgressLabel,
|
|
24
14
|
customValuePreposition,
|
|
25
15
|
maxProgressLabel,
|
|
@@ -27,40 +17,22 @@ const ProgressTracker = ({
|
|
|
27
17
|
labelWidth,
|
|
28
18
|
...rest
|
|
29
19
|
}) => {
|
|
30
|
-
if ((ariaLabel || ariaDescribedBy || ariaValueNow || ariaValueMax || ariaValueMin || ariaValueText) && !deprecatedAriaTagsWarnTriggered) {
|
|
31
|
-
deprecatedAriaTagsWarnTriggered = true;
|
|
32
|
-
Logger.deprecate("The 'aria-' attribute props in `ProgressTracker` have been deprecated and will soon be removed.");
|
|
33
|
-
}
|
|
34
20
|
const l = useLocale();
|
|
35
|
-
const barRef = useRef(null);
|
|
36
|
-
const [barLength, setBarLength] = useState("0px");
|
|
37
21
|
const prefixLabels = labelsPosition !== "bottom";
|
|
38
|
-
const updateBarLength = useCallback(() => {
|
|
39
|
-
setBarLength(`${barRef.current?.offsetWidth}px`);
|
|
40
|
-
}, []);
|
|
41
|
-
useLayoutEffect(() => {
|
|
42
|
-
updateBarLength();
|
|
43
|
-
}, [updateBarLength]);
|
|
44
|
-
useResizeObserver(barRef, () => {
|
|
45
|
-
updateBarLength();
|
|
46
|
-
});
|
|
47
22
|
const renderValueLabels = () => {
|
|
48
|
-
|
|
49
|
-
|
|
23
|
+
let displayedCurrentProgressLabel, displayedMaxProgressLabel;
|
|
24
|
+
if (currentProgressLabel) {
|
|
25
|
+
displayedCurrentProgressLabel = currentProgressLabel;
|
|
26
|
+
displayedMaxProgressLabel = maxProgressLabel || undefined;
|
|
27
|
+
} else {
|
|
28
|
+
displayedCurrentProgressLabel = `${progress}%`;
|
|
29
|
+
displayedMaxProgressLabel = "100%";
|
|
50
30
|
}
|
|
51
|
-
const label = (value, defaultValue) => {
|
|
52
|
-
if (value) {
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
55
|
-
return showDefaultLabels ? defaultValue : undefined;
|
|
56
|
-
};
|
|
57
|
-
const displayedCurrentProgressLabel = label(currentProgressLabel, `${progress}%`);
|
|
58
|
-
const displayedMaxProgressLabel = label(maxProgressLabel, "100%");
|
|
59
31
|
return /*#__PURE__*/React.createElement(StyledValuesLabel, {
|
|
60
32
|
labelsPosition: labelsPosition,
|
|
61
33
|
size: size,
|
|
62
34
|
labelWidth: labelWidth
|
|
63
|
-
},
|
|
35
|
+
}, /*#__PURE__*/React.createElement(StyledValue, {
|
|
64
36
|
"data-element": "current-progress-label"
|
|
65
37
|
}, displayedCurrentProgressLabel), displayedMaxProgressLabel && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
66
38
|
"data-element": "custom-preposition"
|
|
@@ -70,29 +42,18 @@ const ProgressTracker = ({
|
|
|
70
42
|
"data-element": "progress-tracker-description"
|
|
71
43
|
}, description));
|
|
72
44
|
};
|
|
73
|
-
const valueMin = ariaValueMin === undefined ? 0 : ariaValueMin;
|
|
74
|
-
const valueMax = ariaValueMax === undefined ? 100 : ariaValueMax;
|
|
75
|
-
const defaultValueNow = valueMin + (valueMax - valueMin) * progress / 100;
|
|
76
45
|
return /*#__PURE__*/React.createElement(StyledProgressTracker, _extends({
|
|
77
46
|
length: length
|
|
78
47
|
}, rest, tagComponent("progress-bar", rest), {
|
|
79
|
-
role: "progressbar",
|
|
80
|
-
"aria-label": ariaLabel || "progress tracker",
|
|
81
|
-
"aria-describedby": ariaDescribedBy,
|
|
82
|
-
"aria-valuenow": ariaValueNow === undefined ? defaultValueNow : ariaValueNow,
|
|
83
|
-
"aria-valuemin": ariaValueMin,
|
|
84
|
-
"aria-valuemax": ariaValueMax,
|
|
85
|
-
"aria-valuetext": ariaValueText,
|
|
86
48
|
labelsPosition: labelsPosition
|
|
87
49
|
}), prefixLabels && renderValueLabels(), /*#__PURE__*/React.createElement(StyledProgressBar, {
|
|
88
|
-
size: size,
|
|
89
|
-
ref: barRef,
|
|
90
50
|
progress: progress,
|
|
91
|
-
error: error
|
|
51
|
+
error: error,
|
|
52
|
+
"aria-hidden": "true"
|
|
92
53
|
}, /*#__PURE__*/React.createElement(InnerBar, {
|
|
93
54
|
"data-element": "inner-bar",
|
|
55
|
+
"data-role": "inner-bar",
|
|
94
56
|
size: size,
|
|
95
|
-
length: barLength,
|
|
96
57
|
progress: progress,
|
|
97
58
|
error: error
|
|
98
59
|
})), !prefixLabels && renderValueLabels());
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ProgressTrackerProps } from "./progress-tracker.component";
|
|
2
2
|
declare const StyledProgressTracker: import("styled-components").StyledComponent<"div", any, Pick<ProgressTrackerProps, "length" | "margin" | "labelsPosition">, never>;
|
|
3
|
-
declare const StyledProgressBar: import("styled-components").StyledComponent<"span", any, Pick<ProgressTrackerProps, "error" | "progress"
|
|
3
|
+
declare const StyledProgressBar: import("styled-components").StyledComponent<"span", any, Pick<ProgressTrackerProps, "error" | "progress">, never>;
|
|
4
4
|
declare const StyledValue: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
5
5
|
declare const StyledDescription: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
6
6
|
declare const StyledValuesLabel: import("styled-components").StyledComponent<"span", any, Pick<ProgressTrackerProps, "labelWidth" | "size" | "labelsPosition">, never>;
|
|
7
|
-
declare const InnerBar: import("styled-components").StyledComponent<"span", any, Pick<ProgressTrackerProps, "error" | "progress" | "
|
|
7
|
+
declare const InnerBar: import("styled-components").StyledComponent<"span", any, Required<Pick<ProgressTrackerProps, "error" | "progress" | "size">>, never>;
|
|
8
8
|
export { StyledProgressBar, InnerBar, StyledProgressTracker, StyledValuesLabel, StyledValue, StyledDescription, };
|
|
@@ -46,7 +46,6 @@ const StyledProgressTracker = styled.div`
|
|
|
46
46
|
`;
|
|
47
47
|
const StyledProgressBar = styled.span`
|
|
48
48
|
${({
|
|
49
|
-
size,
|
|
50
49
|
progress,
|
|
51
50
|
error,
|
|
52
51
|
theme
|
|
@@ -108,8 +107,7 @@ const StyledValuesLabel = styled.span`
|
|
|
108
107
|
const InnerBar = styled.span`
|
|
109
108
|
${({
|
|
110
109
|
progress,
|
|
111
|
-
size
|
|
112
|
-
length,
|
|
110
|
+
size,
|
|
113
111
|
error,
|
|
114
112
|
theme
|
|
115
113
|
}) => css`
|
|
@@ -120,7 +118,7 @@ const InnerBar = styled.span`
|
|
|
120
118
|
error
|
|
121
119
|
})};
|
|
122
120
|
border-radius: ${theme.roundedCornersOptOut ? "25px" : "var(--borderRadius400)"};
|
|
123
|
-
width:
|
|
121
|
+
width: ${progress}%;
|
|
124
122
|
min-width: 2px;
|
|
125
123
|
height: ${getHeight(size)};
|
|
126
124
|
`}
|
|
@@ -9,15 +9,18 @@ const SwitchSliderPanel = styled.div`
|
|
|
9
9
|
border: 0;
|
|
10
10
|
color: var(--colorsActionMinorYang100);
|
|
11
11
|
margin: auto;
|
|
12
|
-
|
|
12
|
+
position: absolute;
|
|
13
|
+
left: 0;
|
|
13
14
|
|
|
14
15
|
&[type="on"] {
|
|
15
16
|
margin-left: 9px;
|
|
17
|
+
padding-right: ${size === "large" ? "43px" : "27px"};
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
&[type="off"] {
|
|
19
21
|
color: var(--colorsActionMinor500);
|
|
20
|
-
margin-right:
|
|
22
|
+
margin-right: 9px;
|
|
23
|
+
padding-left: ${size === "large" ? "43px" : "27px"};
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
${isLoading && css`
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
1
2
|
import React from "react";
|
|
2
3
|
import PropTypes from "prop-types";
|
|
3
4
|
import Loader from "../../loader/loader.component";
|
|
4
|
-
import StyledSwitchSlider from "./switch-slider.style";
|
|
5
|
+
import { StyledSwitchSlider, HiddenContent } from "./switch-slider.style";
|
|
5
6
|
import SwitchSliderPanel from "./switch-slider-panel.style";
|
|
6
7
|
import ValidationIcon from "../../../__internal__/validations/validation-icon.component";
|
|
7
8
|
import useLocale from "../../../hooks/__internal__/useLocale";
|
|
@@ -15,8 +16,14 @@ const SwitchSlider = ({
|
|
|
15
16
|
info,
|
|
16
17
|
useValidationIcon
|
|
17
18
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
19
|
+
const locale = useLocale();
|
|
20
|
+
const onText = locale.switch.on();
|
|
21
|
+
const offText = locale.switch.off();
|
|
22
|
+
|
|
23
|
+
// Need to convert to uppercase to ensure hidden element
|
|
24
|
+
// has same computed width as the visual text that's rendered
|
|
25
|
+
const longestText = onText.length > offText.length ? onText.toUpperCase() : offText.toUpperCase();
|
|
26
|
+
const panelContent = checked ? onText : offText;
|
|
20
27
|
const switchSliderStyleProps = {
|
|
21
28
|
isLoading: loading,
|
|
22
29
|
checked,
|
|
@@ -38,12 +45,17 @@ const SwitchSlider = ({
|
|
|
38
45
|
size
|
|
39
46
|
};
|
|
40
47
|
const sliderContent = /*#__PURE__*/React.createElement(SwitchSliderPanel, sliderPanelStyleProps, loading ? /*#__PURE__*/React.createElement(Loader, loaderProps) : panelContent);
|
|
41
|
-
return /*#__PURE__*/React.createElement(
|
|
48
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(HiddenContent, {
|
|
49
|
+
size: size,
|
|
50
|
+
"aria-hidden": true
|
|
51
|
+
}, longestText), /*#__PURE__*/React.createElement(StyledSwitchSlider, _extends({
|
|
52
|
+
"data-component": "slider"
|
|
53
|
+
}, switchSliderStyleProps), sliderContent, useValidationIcon && /*#__PURE__*/React.createElement(ValidationIcon, {
|
|
42
54
|
error: error,
|
|
43
55
|
warning: warning,
|
|
44
56
|
info: info,
|
|
45
57
|
size: size,
|
|
46
58
|
tooltipFlipOverrides: ["top", "bottom"]
|
|
47
|
-
}));
|
|
59
|
+
})));
|
|
48
60
|
};
|
|
49
61
|
export default SwitchSlider;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { SwitchSliderProps } from "./switch-slider.component";
|
|
2
|
+
import { ThemeObject } from "../../../style/themes/base";
|
|
3
|
+
interface StyledSwitchSliderProps extends Pick<SwitchSliderProps, "checked" | "disabled" | "size" | "error" | "warning"> {
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
theme?: Partial<ThemeObject>;
|
|
6
|
+
}
|
|
7
|
+
declare const StyledSwitchSlider: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
8
|
+
declare const HiddenContent: import("styled-components").StyledComponent<"div", any, Pick<StyledSwitchSliderProps, "size">, never>;
|
|
9
|
+
export { StyledSwitchSlider, HiddenContent };
|
|
2
10
|
export default StyledSwitchSlider;
|
|
@@ -2,7 +2,7 @@ import styled, { css } from "styled-components";
|
|
|
2
2
|
import SwitchSliderPanel from "./switch-slider-panel.style";
|
|
3
3
|
import StyledValidationIcon from "../../../__internal__/validations/validation-icon.style";
|
|
4
4
|
import baseTheme from "../../../style/themes/base";
|
|
5
|
-
const StyledSwitchSlider = styled.
|
|
5
|
+
const StyledSwitchSlider = styled.div`
|
|
6
6
|
${({
|
|
7
7
|
checked,
|
|
8
8
|
isLoading,
|
|
@@ -18,90 +18,87 @@ const StyledSwitchSlider = styled.span`
|
|
|
18
18
|
height: 28px;
|
|
19
19
|
left: 0;
|
|
20
20
|
letter-spacing: 1px;
|
|
21
|
-
position:
|
|
21
|
+
position: relative;
|
|
22
22
|
text-transform: uppercase;
|
|
23
23
|
top: 0;
|
|
24
|
-
width:
|
|
25
|
-
min-width: fit-content;
|
|
24
|
+
width: 100%
|
|
26
25
|
z-index: 2;
|
|
27
26
|
border-radius: ${theme?.roundedCornersOptOut ? "90px" : "var(--borderRadius400)"};
|
|
28
27
|
border-style: solid;
|
|
29
28
|
border-color: var(--colorsActionMinor400);
|
|
30
29
|
border-width: var(--borderWidth200);
|
|
31
30
|
box-sizing: border-box;
|
|
31
|
+
margin-top: ${size === "large" ? "-47px" : "-28px"};
|
|
32
|
+
align-items: center;
|
|
32
33
|
|
|
33
34
|
&::before {
|
|
34
35
|
background-color: var(--colorsActionMinor400);
|
|
35
36
|
bottom: 4px;
|
|
36
37
|
content: "";
|
|
37
|
-
height:
|
|
38
|
+
height: ${size === "large" ? "var(--spacing400)" : "var(--spacing200)"};
|
|
38
39
|
position: absolute;
|
|
39
40
|
left: 4px;
|
|
40
|
-
transition:
|
|
41
|
-
width:
|
|
41
|
+
transition: margin-left 0.4s;
|
|
42
|
+
width: ${size === "large" ? "var(--spacing400)" : "var(--spacing200)"};
|
|
42
43
|
z-index: 1;
|
|
43
44
|
border-radius: 50%;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
${checked && `
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
&::before {
|
|
51
|
-
transform: translateX(36px);
|
|
52
|
-
background-color: var(--colorsActionMinorYang100);
|
|
53
|
-
}
|
|
47
|
+
${checked && css`
|
|
48
|
+
background-color: var(--colorsActionMinor500);
|
|
49
|
+
border-color: var(--colorsActionMinorTransparent);
|
|
54
50
|
|
|
55
|
-
|
|
51
|
+
&::before {
|
|
52
|
+
margin-left: calc(
|
|
53
|
+
100% -
|
|
54
|
+
${size === "large" ? "var(--spacing500)" : "var(--spacing300)"}
|
|
55
|
+
);
|
|
56
|
+
background-color: var(--colorsActionMinorYang100);
|
|
57
|
+
}
|
|
58
|
+
`}
|
|
56
59
|
|
|
57
60
|
${disabled && !isLoading && css`
|
|
58
|
-
|
|
61
|
+
border-color: var(--colorsActionDisabled600);
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
&::before {
|
|
64
|
+
background-color: var(--colorsActionDisabled600);
|
|
65
|
+
}
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
${SwitchSliderPanel} {
|
|
68
|
+
color: var(--colorsUtilityYin030);
|
|
69
|
+
}
|
|
67
70
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
${checked && css`
|
|
72
|
+
background-color: var(--colorsActionDisabled500);
|
|
73
|
+
border-color: var(--colorsActionMinorTransparent);
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
&::before {
|
|
76
|
+
background-color: var(--colorsActionMinorYang100);
|
|
77
|
+
}
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
${SwitchSliderPanel} {
|
|
80
|
+
color: var(--colorsUtilityYin030);
|
|
81
|
+
}
|
|
82
|
+
`}
|
|
77
83
|
`}
|
|
78
|
-
`}
|
|
79
84
|
|
|
80
85
|
${size === "large" && css`
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
height: 32px;
|
|
84
|
-
width: 32px;
|
|
85
|
-
|
|
86
|
-
${checked && `
|
|
87
|
-
transform: translateX(38px);
|
|
88
|
-
`}
|
|
89
|
-
}
|
|
90
|
-
`}
|
|
86
|
+
${theme?.roundedCornersOptOut ? "border-radius: 30px;" : ""}
|
|
87
|
+
`}
|
|
91
88
|
|
|
92
89
|
${isLoading && css`
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
&::before {
|
|
91
|
+
display: none;
|
|
92
|
+
}
|
|
93
|
+
`}
|
|
97
94
|
|
|
98
95
|
${warning && !disabled && css`
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
border-color: var(--colorsSemanticCaution500);
|
|
97
|
+
`}
|
|
101
98
|
|
|
102
99
|
${error && !disabled && css`
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
border-color: var(--colorsSemanticNegative500);
|
|
101
|
+
`}
|
|
105
102
|
|
|
106
103
|
${StyledValidationIcon} {
|
|
107
104
|
position: absolute;
|
|
@@ -110,7 +107,17 @@ const StyledSwitchSlider = styled.span`
|
|
|
110
107
|
}
|
|
111
108
|
`}
|
|
112
109
|
`;
|
|
110
|
+
const HiddenContent = styled.div`
|
|
111
|
+
${({
|
|
112
|
+
size
|
|
113
|
+
}) => css`
|
|
114
|
+
visibility: hidden;
|
|
115
|
+
height: 0px;
|
|
116
|
+
padding-left: ${size === "large" ? "var(--spacing700)" : "var(--spacing500)"};
|
|
117
|
+
`}
|
|
118
|
+
`;
|
|
113
119
|
StyledSwitchSlider.defaultProps = {
|
|
114
120
|
theme: baseTheme
|
|
115
121
|
};
|
|
122
|
+
export { StyledSwitchSlider, HiddenContent };
|
|
116
123
|
export default StyledSwitchSlider;
|
|
@@ -43,21 +43,32 @@ const StyledSwitch = styled.div`
|
|
|
43
43
|
${margin}
|
|
44
44
|
${FieldLineStyle} {
|
|
45
45
|
display: flex;
|
|
46
|
-
flex-flow: row wrap;
|
|
46
|
+
flex-flow: ${labelInline ? "row wrap" : "column wrap"};
|
|
47
|
+
|
|
48
|
+
${!labelInline && fieldHelpInline && css`
|
|
49
|
+
display: grid;
|
|
50
|
+
grid-template-columns: max-content max-content;
|
|
51
|
+
`}
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
${StyledCheckableInput}, ${HiddenCheckableInputStyle} {
|
|
50
55
|
border: none;
|
|
51
56
|
box-sizing: border-box;
|
|
52
57
|
height: 24px;
|
|
53
|
-
width: 60px;
|
|
54
|
-
min-width: fit-content;
|
|
55
58
|
flex-basis: 100%;
|
|
56
59
|
margin-left: 0;
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
${HiddenCheckableInputStyle} {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
${StyledCheckableInput} {
|
|
67
|
+
width: min-content;
|
|
68
|
+
}
|
|
69
|
+
|
|
59
70
|
${HiddenCheckableInputStyle}:not([disabled]) {
|
|
60
|
-
&:focus
|
|
71
|
+
&:focus ~ ${StyledSwitchSlider} {
|
|
61
72
|
${!theme.focusRedesignOptOut ? addFocusStyling() : /* istanbul ignore next */oldFocusStyling}
|
|
62
73
|
}
|
|
63
74
|
}
|
|
@@ -150,7 +161,6 @@ const StyledSwitch = styled.div`
|
|
|
150
161
|
${size === "large" && css`
|
|
151
162
|
${StyledCheckableInput}, ${HiddenCheckableInputStyle}, ${StyledSwitchSlider} {
|
|
152
163
|
height: 44px;
|
|
153
|
-
width: 82px;
|
|
154
164
|
min-width: fit-content;
|
|
155
165
|
}
|
|
156
166
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import TypeIcon from "../message/type-icon/type-icon.style";
|
|
2
|
+
import TypeIcon from "../message/__internal__/type-icon/type-icon.style";
|
|
3
3
|
import { MessageVariant } from "../message/message.component";
|
|
4
4
|
declare const StyledPortal: import("styled-components").StyledComponent<({ children, className, id, onReposition, inertOptOut, }: import("../portal/portal").PortalProps) => import("react").JSX.Element, any, {
|
|
5
5
|
align?: "left" | "right" | "center" | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import TypeIcon from "../message/type-icon/type-icon.style";
|
|
2
|
+
import TypeIcon from "../message/__internal__/type-icon/type-icon.style";
|
|
3
3
|
import StyledIconButton from "../icon-button/icon-button.style";
|
|
4
4
|
import Portal from "../portal/portal";
|
|
5
5
|
import baseTheme from "../../style/themes/base";
|