carbon-react 134.2.0 → 135.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/portal/portal.js +1 -0
- package/esm/components/toast/toast.component.d.ts +0 -2
- package/esm/components/toast/toast.component.js +7 -15
- package/esm/components/toast/toast.style.d.ts +0 -3
- package/esm/components/toast/toast.style.js +4 -21
- package/lib/components/portal/portal.js +1 -0
- package/lib/components/toast/toast.component.d.ts +0 -2
- package/lib/components/toast/toast.component.js +7 -15
- package/lib/components/toast/toast.style.d.ts +0 -3
- package/lib/components/toast/toast.style.js +4 -21
- package/package.json +1 -1
- package/esm/components/carousel/carousel.component.d.ts +0 -25
- package/esm/components/carousel/carousel.component.js +0 -125
- package/esm/components/carousel/carousel.style.d.ts +0 -20
- package/esm/components/carousel/carousel.style.js +0 -154
- package/esm/components/carousel/index.d.ts +0 -4
- package/esm/components/carousel/index.js +0 -2
- package/esm/components/carousel/slide/index.d.ts +0 -2
- package/esm/components/carousel/slide/index.js +0 -1
- package/esm/components/carousel/slide/slide.component.d.ts +0 -12
- package/esm/components/carousel/slide/slide.component.js +0 -9
- package/esm/components/carousel/slide/slide.style.d.ts +0 -2
- package/esm/components/carousel/slide/slide.style.js +0 -32
- package/esm/components/carousel/slide.config.d.ts +0 -3
- package/esm/components/carousel/slide.config.js +0 -80
- package/esm/components/step-sequence/index.d.ts +0 -4
- package/esm/components/step-sequence/index.js +0 -2
- package/esm/components/step-sequence/step-sequence-item/index.d.ts +0 -2
- package/esm/components/step-sequence/step-sequence-item/index.js +0 -1
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.component.d.ts +0 -19
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.component.js +0 -43
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.style.d.ts +0 -6
- package/esm/components/step-sequence/step-sequence-item/step-sequence-item.style.js +0 -96
- package/esm/components/step-sequence/step-sequence.component.d.ts +0 -13
- package/esm/components/step-sequence/step-sequence.component.js +0 -29
- package/esm/components/step-sequence/step-sequence.config.d.ts +0 -2
- package/esm/components/step-sequence/step-sequence.config.js +0 -2
- package/esm/components/step-sequence/step-sequence.style.d.ts +0 -4
- package/esm/components/step-sequence/step-sequence.style.js +0 -21
- package/lib/components/carousel/carousel.component.d.ts +0 -25
- package/lib/components/carousel/carousel.component.js +0 -135
- package/lib/components/carousel/carousel.style.d.ts +0 -20
- package/lib/components/carousel/carousel.style.js +0 -162
- package/lib/components/carousel/index.d.ts +0 -4
- package/lib/components/carousel/index.js +0 -20
- package/lib/components/carousel/package.json +0 -6
- package/lib/components/carousel/slide/index.d.ts +0 -2
- package/lib/components/carousel/slide/index.js +0 -13
- package/lib/components/carousel/slide/package.json +0 -6
- package/lib/components/carousel/slide/slide.component.d.ts +0 -12
- package/lib/components/carousel/slide/slide.component.js +0 -16
- package/lib/components/carousel/slide/slide.style.d.ts +0 -2
- package/lib/components/carousel/slide/slide.style.js +0 -39
- package/lib/components/carousel/slide.config.d.ts +0 -3
- package/lib/components/carousel/slide.config.js +0 -85
- package/lib/components/step-sequence/index.d.ts +0 -4
- package/lib/components/step-sequence/index.js +0 -20
- package/lib/components/step-sequence/package.json +0 -6
- package/lib/components/step-sequence/step-sequence-item/index.d.ts +0 -2
- package/lib/components/step-sequence/step-sequence-item/index.js +0 -13
- package/lib/components/step-sequence/step-sequence-item/package.json +0 -6
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.component.d.ts +0 -19
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.component.js +0 -53
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.style.d.ts +0 -6
- package/lib/components/step-sequence/step-sequence-item/step-sequence-item.style.js +0 -105
- package/lib/components/step-sequence/step-sequence.component.d.ts +0 -13
- package/lib/components/step-sequence/step-sequence.component.js +0 -37
- package/lib/components/step-sequence/step-sequence.config.d.ts +0 -2
- package/lib/components/step-sequence/step-sequence.config.js +0 -8
- package/lib/components/step-sequence/step-sequence.style.d.ts +0 -4
- package/lib/components/step-sequence/step-sequence.style.js +0 -29
|
@@ -60,6 +60,7 @@ export const Portal = ({
|
|
|
60
60
|
node = document.createElement("div");
|
|
61
61
|
node.classList.add(portalClassName);
|
|
62
62
|
node.setAttribute("data-portal-exit", uniqueId);
|
|
63
|
+
node.setAttribute("data-role", "carbon-portal-exit");
|
|
63
64
|
if (id !== undefined) {
|
|
64
65
|
node.setAttribute("id", id);
|
|
65
66
|
}
|
|
@@ -26,8 +26,6 @@ export interface ToastProps {
|
|
|
26
26
|
closeButtonDataProps?: Pick<TagProps, "data-role" | "data-element">;
|
|
27
27
|
/** Time for Toast to remain on screen */
|
|
28
28
|
timeout?: string | number;
|
|
29
|
-
/** Centers the Toast on the screen */
|
|
30
|
-
isCenter?: boolean;
|
|
31
29
|
/** Target Portal ID where the Toast will render */
|
|
32
30
|
targetPortalId?: string;
|
|
33
31
|
/** Maximum toast width */
|
|
@@ -9,15 +9,12 @@ import IconButton from "../icon-button";
|
|
|
9
9
|
import Events from "../../__internal__/utils/helpers/events";
|
|
10
10
|
import useLocale from "../../hooks/__internal__/useLocale";
|
|
11
11
|
import useModalManager from "../../hooks/__internal__/useModalManager";
|
|
12
|
-
import Logger from "../../__internal__/utils/logger";
|
|
13
|
-
let isDeprecationWarningTriggered = false;
|
|
14
12
|
const Toast = /*#__PURE__*/React.forwardRef(({
|
|
15
|
-
align,
|
|
13
|
+
align = "center",
|
|
16
14
|
alignY,
|
|
17
15
|
children,
|
|
18
16
|
className,
|
|
19
17
|
id,
|
|
20
|
-
isCenter = true,
|
|
21
18
|
maxWidth,
|
|
22
19
|
onDismiss,
|
|
23
20
|
open = true,
|
|
@@ -41,10 +38,6 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
41
38
|
if (ref && typeof ref === "object" && "current" in ref) {
|
|
42
39
|
refToPass = ref;
|
|
43
40
|
}
|
|
44
|
-
if (isCenter !== undefined && !isDeprecationWarningTriggered) {
|
|
45
|
-
isDeprecationWarningTriggered = true;
|
|
46
|
-
Logger.deprecate(`isCenter prop in ${Toast.displayName} is being deprecated in favour of the align prop.`);
|
|
47
|
-
}
|
|
48
41
|
const dismissToast = useCallback(ev => {
|
|
49
42
|
if (onDismiss && Events.isEscKey(ev)) {
|
|
50
43
|
ev.stopImmediatePropagation();
|
|
@@ -131,7 +124,6 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
131
124
|
isNotification: isNotification,
|
|
132
125
|
className: className
|
|
133
126
|
}, tagComponent(restProps["data-component"] || "toast", restProps), {
|
|
134
|
-
isCenter: isCenter,
|
|
135
127
|
variant: toastVariant,
|
|
136
128
|
id: id,
|
|
137
129
|
maxWidth: maxWidth,
|
|
@@ -140,25 +132,26 @@ const Toast = /*#__PURE__*/React.forwardRef(({
|
|
|
140
132
|
tabIndex,
|
|
141
133
|
onBlur: () => setTabIndex(undefined)
|
|
142
134
|
}), !isNotice && /*#__PURE__*/React.createElement(TypeIcon, {
|
|
143
|
-
variant: isNotification ? "info" : variant
|
|
135
|
+
variant: isNotification ? "info" : variant,
|
|
136
|
+
"data-role": "toast-type-icon"
|
|
144
137
|
}, /*#__PURE__*/React.createElement(Icon, {
|
|
145
138
|
type: toastIcon
|
|
146
139
|
})), /*#__PURE__*/React.createElement(StyledToastContent, {
|
|
147
140
|
isNotice: isNotice,
|
|
148
|
-
isDismiss: !!onDismiss
|
|
141
|
+
isDismiss: !!onDismiss,
|
|
142
|
+
"data-role": "toast-content"
|
|
149
143
|
}, children), renderCloseIcon()));
|
|
150
144
|
}
|
|
151
145
|
return /*#__PURE__*/React.createElement(StyledPortal, {
|
|
152
146
|
id: targetPortalId,
|
|
153
147
|
align: align,
|
|
154
148
|
alignY: alignY,
|
|
155
|
-
isCenter: isCenter,
|
|
156
149
|
isNotice: isNotice
|
|
157
150
|
}, /*#__PURE__*/React.createElement(ToastWrapper, {
|
|
158
151
|
align: align,
|
|
159
|
-
isCenter: isCenter,
|
|
160
152
|
ref: refToPass,
|
|
161
|
-
isNotice: isNotice
|
|
153
|
+
isNotice: isNotice,
|
|
154
|
+
"data-role": "toast-wrapper"
|
|
162
155
|
}, /*#__PURE__*/React.createElement(TransitionGroup, null, renderToastContent())));
|
|
163
156
|
});
|
|
164
157
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -174,7 +167,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
174
167
|
"data-component": PropTypes.string,
|
|
175
168
|
"disableAutoFocus": PropTypes.bool,
|
|
176
169
|
"id": PropTypes.string,
|
|
177
|
-
"isCenter": PropTypes.bool,
|
|
178
170
|
"maxWidth": PropTypes.string,
|
|
179
171
|
"onDismiss": PropTypes.func,
|
|
180
172
|
"open": PropTypes.bool,
|
|
@@ -4,7 +4,6 @@ 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;
|
|
6
6
|
alignY?: "bottom" | "top" | "center" | undefined;
|
|
7
|
-
isCenter?: boolean | undefined;
|
|
8
7
|
isNotice?: boolean | undefined;
|
|
9
8
|
}, never>;
|
|
10
9
|
declare type ToastVariants = MessageVariant;
|
|
@@ -12,7 +11,6 @@ declare type ToastStyleProps = {
|
|
|
12
11
|
align?: "left" | "center" | "right";
|
|
13
12
|
alignY?: "top" | "center" | "bottom";
|
|
14
13
|
maxWidth?: string;
|
|
15
|
-
isCenter?: boolean;
|
|
16
14
|
isNotice?: boolean;
|
|
17
15
|
isNotification?: boolean;
|
|
18
16
|
variant: ToastVariants;
|
|
@@ -24,7 +22,6 @@ declare const StyledToastContent: import("styled-components").StyledComponent<"d
|
|
|
24
22
|
}, never>;
|
|
25
23
|
declare const ToastWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
26
24
|
align?: "left" | "right" | "center" | undefined;
|
|
27
|
-
isCenter?: boolean | undefined;
|
|
28
25
|
isNotice?: boolean | undefined;
|
|
29
26
|
}, never>;
|
|
30
27
|
export { StyledPortal, StyledToast, TypeIcon, StyledToastContent, ToastWrapper, };
|
|
@@ -7,7 +7,6 @@ import StyledIcon from "../icon/icon.style";
|
|
|
7
7
|
const StyledPortal = styled(Portal)`
|
|
8
8
|
${({
|
|
9
9
|
theme,
|
|
10
|
-
isCenter,
|
|
11
10
|
isNotice,
|
|
12
11
|
align,
|
|
13
12
|
alignY
|
|
@@ -16,11 +15,6 @@ const StyledPortal = styled(Portal)`
|
|
|
16
15
|
top: 0;
|
|
17
16
|
z-index: ${theme.zIndex.notification};
|
|
18
17
|
|
|
19
|
-
${isCenter && css`
|
|
20
|
-
margin-left: 50%;
|
|
21
|
-
transform: translateX(-50%);
|
|
22
|
-
`}
|
|
23
|
-
|
|
24
18
|
${align === "left" && css`
|
|
25
19
|
left: 0;
|
|
26
20
|
transform: translateX(50%);
|
|
@@ -82,7 +76,6 @@ const iconPositionStyles = css`
|
|
|
82
76
|
const StyledToast = styled.div`
|
|
83
77
|
${({
|
|
84
78
|
maxWidth,
|
|
85
|
-
isCenter,
|
|
86
79
|
align,
|
|
87
80
|
isNotification,
|
|
88
81
|
alignY,
|
|
@@ -113,8 +106,8 @@ const StyledToast = styled.div`
|
|
|
113
106
|
margin-bottom: ${alignY === "bottom" && !isNotice ? "30px" : "0"};
|
|
114
107
|
max-width: ${!maxWidth ? "300px" : maxWidth};
|
|
115
108
|
position: relative;
|
|
116
|
-
margin-right: ${
|
|
117
|
-
margin-left: ${
|
|
109
|
+
margin-right: ${align === "center" || align === "right" ? "auto" : "30px"};
|
|
110
|
+
margin-left: ${align === "center" || align === "left" ? "auto" : "30px"};
|
|
118
111
|
|
|
119
112
|
${isNotification && css`
|
|
120
113
|
border: 1px solid var(--colorsSemanticInfo500);
|
|
@@ -134,8 +127,8 @@ const StyledToast = styled.div`
|
|
|
134
127
|
&${animationName}-enter${animationName}-enter-active {
|
|
135
128
|
opacity: 1;
|
|
136
129
|
transform: ${({
|
|
137
|
-
|
|
138
|
-
}) =>
|
|
130
|
+
align
|
|
131
|
+
}) => align === "center" ? " scale(1) translateY(0)" : "scale(1)"};
|
|
139
132
|
transition: all 300ms cubic-bezier(0.25, 0.25, 0, 1.5);
|
|
140
133
|
}
|
|
141
134
|
|
|
@@ -225,16 +218,6 @@ const ToastWrapper = styled.div`
|
|
|
225
218
|
display: flex;
|
|
226
219
|
`}
|
|
227
220
|
|
|
228
|
-
${({
|
|
229
|
-
isCenter
|
|
230
|
-
}) => isCenter && css`
|
|
231
|
-
position: relative;
|
|
232
|
-
width: auto;
|
|
233
|
-
height: auto;
|
|
234
|
-
justify-content: center;
|
|
235
|
-
display: flex;
|
|
236
|
-
`}
|
|
237
|
-
|
|
238
221
|
${({
|
|
239
222
|
isNotice
|
|
240
223
|
}) => isNotice && css`
|
|
@@ -69,6 +69,7 @@ const Portal = ({
|
|
|
69
69
|
node = document.createElement("div");
|
|
70
70
|
node.classList.add(portalClassName);
|
|
71
71
|
node.setAttribute("data-portal-exit", uniqueId);
|
|
72
|
+
node.setAttribute("data-role", "carbon-portal-exit");
|
|
72
73
|
if (id !== undefined) {
|
|
73
74
|
node.setAttribute("id", id);
|
|
74
75
|
}
|
|
@@ -26,8 +26,6 @@ export interface ToastProps {
|
|
|
26
26
|
closeButtonDataProps?: Pick<TagProps, "data-role" | "data-element">;
|
|
27
27
|
/** Time for Toast to remain on screen */
|
|
28
28
|
timeout?: string | number;
|
|
29
|
-
/** Centers the Toast on the screen */
|
|
30
|
-
isCenter?: boolean;
|
|
31
29
|
/** Target Portal ID where the Toast will render */
|
|
32
30
|
targetPortalId?: string;
|
|
33
31
|
/** Maximum toast width */
|
|
@@ -14,19 +14,16 @@ var _iconButton = _interopRequireDefault(require("../icon-button"));
|
|
|
14
14
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
15
15
|
var _useLocale = _interopRequireDefault(require("../../hooks/__internal__/useLocale"));
|
|
16
16
|
var _useModalManager = _interopRequireDefault(require("../../hooks/__internal__/useModalManager"));
|
|
17
|
-
var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
21
20
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
22
|
-
let isDeprecationWarningTriggered = false;
|
|
23
21
|
const Toast = exports.Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
24
|
-
align,
|
|
22
|
+
align = "center",
|
|
25
23
|
alignY,
|
|
26
24
|
children,
|
|
27
25
|
className,
|
|
28
26
|
id,
|
|
29
|
-
isCenter = true,
|
|
30
27
|
maxWidth,
|
|
31
28
|
onDismiss,
|
|
32
29
|
open = true,
|
|
@@ -50,10 +47,6 @@ const Toast = exports.Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
50
47
|
if (ref && typeof ref === "object" && "current" in ref) {
|
|
51
48
|
refToPass = ref;
|
|
52
49
|
}
|
|
53
|
-
if (isCenter !== undefined && !isDeprecationWarningTriggered) {
|
|
54
|
-
isDeprecationWarningTriggered = true;
|
|
55
|
-
_logger.default.deprecate(`isCenter prop in ${Toast.displayName} is being deprecated in favour of the align prop.`);
|
|
56
|
-
}
|
|
57
50
|
const dismissToast = (0, _react.useCallback)(ev => {
|
|
58
51
|
if (onDismiss && _events.default.isEscKey(ev)) {
|
|
59
52
|
ev.stopImmediatePropagation();
|
|
@@ -140,7 +133,6 @@ const Toast = exports.Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
140
133
|
isNotification: isNotification,
|
|
141
134
|
className: className
|
|
142
135
|
}, (0, _tags.default)(restProps["data-component"] || "toast", restProps), {
|
|
143
|
-
isCenter: isCenter,
|
|
144
136
|
variant: toastVariant,
|
|
145
137
|
id: id,
|
|
146
138
|
maxWidth: maxWidth,
|
|
@@ -149,25 +141,26 @@ const Toast = exports.Toast = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
149
141
|
tabIndex,
|
|
150
142
|
onBlur: () => setTabIndex(undefined)
|
|
151
143
|
}), !isNotice && /*#__PURE__*/_react.default.createElement(_toast.TypeIcon, {
|
|
152
|
-
variant: isNotification ? "info" : variant
|
|
144
|
+
variant: isNotification ? "info" : variant,
|
|
145
|
+
"data-role": "toast-type-icon"
|
|
153
146
|
}, /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
154
147
|
type: toastIcon
|
|
155
148
|
})), /*#__PURE__*/_react.default.createElement(_toast.StyledToastContent, {
|
|
156
149
|
isNotice: isNotice,
|
|
157
|
-
isDismiss: !!onDismiss
|
|
150
|
+
isDismiss: !!onDismiss,
|
|
151
|
+
"data-role": "toast-content"
|
|
158
152
|
}, children), renderCloseIcon()));
|
|
159
153
|
}
|
|
160
154
|
return /*#__PURE__*/_react.default.createElement(_toast.StyledPortal, {
|
|
161
155
|
id: targetPortalId,
|
|
162
156
|
align: align,
|
|
163
157
|
alignY: alignY,
|
|
164
|
-
isCenter: isCenter,
|
|
165
158
|
isNotice: isNotice
|
|
166
159
|
}, /*#__PURE__*/_react.default.createElement(_toast.ToastWrapper, {
|
|
167
160
|
align: align,
|
|
168
|
-
isCenter: isCenter,
|
|
169
161
|
ref: refToPass,
|
|
170
|
-
isNotice: isNotice
|
|
162
|
+
isNotice: isNotice,
|
|
163
|
+
"data-role": "toast-wrapper"
|
|
171
164
|
}, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, renderToastContent())));
|
|
172
165
|
});
|
|
173
166
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -183,7 +176,6 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
183
176
|
"data-component": _propTypes.default.string,
|
|
184
177
|
"disableAutoFocus": _propTypes.default.bool,
|
|
185
178
|
"id": _propTypes.default.string,
|
|
186
|
-
"isCenter": _propTypes.default.bool,
|
|
187
179
|
"maxWidth": _propTypes.default.string,
|
|
188
180
|
"onDismiss": _propTypes.default.func,
|
|
189
181
|
"open": _propTypes.default.bool,
|
|
@@ -4,7 +4,6 @@ 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;
|
|
6
6
|
alignY?: "bottom" | "top" | "center" | undefined;
|
|
7
|
-
isCenter?: boolean | undefined;
|
|
8
7
|
isNotice?: boolean | undefined;
|
|
9
8
|
}, never>;
|
|
10
9
|
declare type ToastVariants = MessageVariant;
|
|
@@ -12,7 +11,6 @@ declare type ToastStyleProps = {
|
|
|
12
11
|
align?: "left" | "center" | "right";
|
|
13
12
|
alignY?: "top" | "center" | "bottom";
|
|
14
13
|
maxWidth?: string;
|
|
15
|
-
isCenter?: boolean;
|
|
16
14
|
isNotice?: boolean;
|
|
17
15
|
isNotification?: boolean;
|
|
18
16
|
variant: ToastVariants;
|
|
@@ -24,7 +22,6 @@ declare const StyledToastContent: import("styled-components").StyledComponent<"d
|
|
|
24
22
|
}, never>;
|
|
25
23
|
declare const ToastWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
26
24
|
align?: "left" | "right" | "center" | undefined;
|
|
27
|
-
isCenter?: boolean | undefined;
|
|
28
25
|
isNotice?: boolean | undefined;
|
|
29
26
|
}, never>;
|
|
30
27
|
export { StyledPortal, StyledToast, TypeIcon, StyledToastContent, ToastWrapper, };
|
|
@@ -22,7 +22,6 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
22
22
|
const StyledPortal = exports.StyledPortal = (0, _styledComponents.default)(_portal.default)`
|
|
23
23
|
${({
|
|
24
24
|
theme,
|
|
25
|
-
isCenter,
|
|
26
25
|
isNotice,
|
|
27
26
|
align,
|
|
28
27
|
alignY
|
|
@@ -31,11 +30,6 @@ const StyledPortal = exports.StyledPortal = (0, _styledComponents.default)(_port
|
|
|
31
30
|
top: 0;
|
|
32
31
|
z-index: ${theme.zIndex.notification};
|
|
33
32
|
|
|
34
|
-
${isCenter && (0, _styledComponents.css)`
|
|
35
|
-
margin-left: 50%;
|
|
36
|
-
transform: translateX(-50%);
|
|
37
|
-
`}
|
|
38
|
-
|
|
39
33
|
${align === "left" && (0, _styledComponents.css)`
|
|
40
34
|
left: 0;
|
|
41
35
|
transform: translateX(50%);
|
|
@@ -97,7 +91,6 @@ const iconPositionStyles = (0, _styledComponents.css)`
|
|
|
97
91
|
const StyledToast = exports.StyledToast = _styledComponents.default.div`
|
|
98
92
|
${({
|
|
99
93
|
maxWidth,
|
|
100
|
-
isCenter,
|
|
101
94
|
align,
|
|
102
95
|
isNotification,
|
|
103
96
|
alignY,
|
|
@@ -128,8 +121,8 @@ const StyledToast = exports.StyledToast = _styledComponents.default.div`
|
|
|
128
121
|
margin-bottom: ${alignY === "bottom" && !isNotice ? "30px" : "0"};
|
|
129
122
|
max-width: ${!maxWidth ? "300px" : maxWidth};
|
|
130
123
|
position: relative;
|
|
131
|
-
margin-right: ${
|
|
132
|
-
margin-left: ${
|
|
124
|
+
margin-right: ${align === "center" || align === "right" ? "auto" : "30px"};
|
|
125
|
+
margin-left: ${align === "center" || align === "left" ? "auto" : "30px"};
|
|
133
126
|
|
|
134
127
|
${isNotification && (0, _styledComponents.css)`
|
|
135
128
|
border: 1px solid var(--colorsSemanticInfo500);
|
|
@@ -149,8 +142,8 @@ const StyledToast = exports.StyledToast = _styledComponents.default.div`
|
|
|
149
142
|
&${animationName}-enter${animationName}-enter-active {
|
|
150
143
|
opacity: 1;
|
|
151
144
|
transform: ${({
|
|
152
|
-
|
|
153
|
-
}) =>
|
|
145
|
+
align
|
|
146
|
+
}) => align === "center" ? " scale(1) translateY(0)" : "scale(1)"};
|
|
154
147
|
transition: all 300ms cubic-bezier(0.25, 0.25, 0, 1.5);
|
|
155
148
|
}
|
|
156
149
|
|
|
@@ -240,16 +233,6 @@ const ToastWrapper = exports.ToastWrapper = _styledComponents.default.div`
|
|
|
240
233
|
display: flex;
|
|
241
234
|
`}
|
|
242
235
|
|
|
243
|
-
${({
|
|
244
|
-
isCenter
|
|
245
|
-
}) => isCenter && (0, _styledComponents.css)`
|
|
246
|
-
position: relative;
|
|
247
|
-
width: auto;
|
|
248
|
-
height: auto;
|
|
249
|
-
justify-content: center;
|
|
250
|
-
display: flex;
|
|
251
|
-
`}
|
|
252
|
-
|
|
253
236
|
${({
|
|
254
237
|
isNotice
|
|
255
238
|
}) => isNotice && (0, _styledComponents.css)`
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { TagProps } from "../../__internal__/utils/helpers/tags/tags";
|
|
3
|
-
export interface CarouselProps extends TagProps {
|
|
4
|
-
/** Individual tabs */
|
|
5
|
-
children?: React.ReactNode;
|
|
6
|
-
/** [legacy] Custom className */
|
|
7
|
-
className?: string;
|
|
8
|
-
/** Enables the next button */
|
|
9
|
-
enableNextButton?: boolean;
|
|
10
|
-
/** Enables the previous button */
|
|
11
|
-
enablePreviousButton?: boolean;
|
|
12
|
-
/** Enables the slide selector */
|
|
13
|
-
enableSlideSelector?: boolean;
|
|
14
|
-
/** The selected tab on page load */
|
|
15
|
-
initialSlideIndex?: number | string;
|
|
16
|
-
/** Action to be called on slide change */
|
|
17
|
-
onSlideChange?: (index: number, transitionDirection: string) => void;
|
|
18
|
-
/** The selected slide */
|
|
19
|
-
slideIndex?: number | string;
|
|
20
|
-
}
|
|
21
|
-
export declare const Carousel: {
|
|
22
|
-
({ children, className, enableSlideSelector, enablePreviousButton, enableNextButton, initialSlideIndex, onSlideChange, slideIndex, ...props }: CarouselProps): React.JSX.Element;
|
|
23
|
-
displayName: string;
|
|
24
|
-
};
|
|
25
|
-
export default Carousel;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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
|
-
import React, { useCallback, useEffect, useRef, useState, useMemo } from "react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import Logger from "../../__internal__/utils/logger";
|
|
5
|
-
import tagComponent from "../../__internal__/utils/helpers/tags/tags";
|
|
6
|
-
import { CarouselPreviousButtonWrapperStyle, CarouselNextButtonWrapperStyle, CarouselButtonStyle, CarouselStyledIconRight, CarouselStyledIconLeft, CarouselSelectorWrapperStyle, CarouselSelectorInputWrapperStyle, CarouselSelectorInputStyle, CarouselSelectorLabelStyle, CarouselWrapperStyle, CarouselSliderWrapper } from "./carousel.style";
|
|
7
|
-
import guid from "../../__internal__/utils/helpers/guid";
|
|
8
|
-
let deprecateWarnTriggered = false;
|
|
9
|
-
const NEXT = "next";
|
|
10
|
-
const PREVIOUS = "previous";
|
|
11
|
-
export const Carousel = ({
|
|
12
|
-
children,
|
|
13
|
-
className,
|
|
14
|
-
enableSlideSelector = true,
|
|
15
|
-
enablePreviousButton = true,
|
|
16
|
-
enableNextButton = true,
|
|
17
|
-
initialSlideIndex = 0,
|
|
18
|
-
onSlideChange,
|
|
19
|
-
slideIndex,
|
|
20
|
-
...props
|
|
21
|
-
}) => {
|
|
22
|
-
if (!deprecateWarnTriggered) {
|
|
23
|
-
deprecateWarnTriggered = true;
|
|
24
|
-
Logger.deprecate("The Carousel component is deprecated and will soon be removed.");
|
|
25
|
-
}
|
|
26
|
-
const [selectedSlideIndex, setSelectedSlideIndex] = useState(Number(slideIndex) || Number(initialSlideIndex));
|
|
27
|
-
const transitionDirection = useRef(NEXT);
|
|
28
|
-
const lastSlideIndexProp = useRef(slideIndex);
|
|
29
|
-
const id = useMemo(() => guid(), []);
|
|
30
|
-
const numOfSlides = useMemo(() => {
|
|
31
|
-
return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child)).length;
|
|
32
|
-
}, [children]);
|
|
33
|
-
const handleSlideChange = useCallback(newIndex => {
|
|
34
|
-
setSelectedSlideIndex(newIndex);
|
|
35
|
-
if (onSlideChange) {
|
|
36
|
-
onSlideChange(newIndex, transitionDirection.current);
|
|
37
|
-
}
|
|
38
|
-
}, [onSlideChange]);
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const newIndex = slideIndex;
|
|
41
|
-
const isNewIndexUndefined = typeof newIndex === "undefined";
|
|
42
|
-
const isTheSameIndex = newIndex === lastSlideIndexProp.current || newIndex === selectedSlideIndex;
|
|
43
|
-
if (isNewIndexUndefined || isTheSameIndex) return;
|
|
44
|
-
if (Number(newIndex) > Number(selectedSlideIndex)) {
|
|
45
|
-
transitionDirection.current = NEXT;
|
|
46
|
-
} else {
|
|
47
|
-
transitionDirection.current = PREVIOUS;
|
|
48
|
-
}
|
|
49
|
-
lastSlideIndexProp.current = newIndex;
|
|
50
|
-
handleSlideChange(newIndex);
|
|
51
|
-
}, [handleSlideChange, slideIndex, selectedSlideIndex]);
|
|
52
|
-
function onPreviousClick() {
|
|
53
|
-
const newIndex = selectedSlideIndex - 1;
|
|
54
|
-
transitionDirection.current = PREVIOUS;
|
|
55
|
-
handleSlideChange(newIndex);
|
|
56
|
-
}
|
|
57
|
-
function onNextClick() {
|
|
58
|
-
const newIndex = selectedSlideIndex + 1;
|
|
59
|
-
transitionDirection.current = NEXT;
|
|
60
|
-
handleSlideChange(newIndex);
|
|
61
|
-
}
|
|
62
|
-
function onSlideSelection(ev) {
|
|
63
|
-
const newSlideSelection = Number(ev.target.value);
|
|
64
|
-
transitionDirection.current = newSlideSelection > selectedSlideIndex ? NEXT : PREVIOUS;
|
|
65
|
-
handleSlideChange(newSlideSelection);
|
|
66
|
-
}
|
|
67
|
-
function slideSelector() {
|
|
68
|
-
if (!enableSlideSelector) return null;
|
|
69
|
-
const buttons = [];
|
|
70
|
-
for (let i = 0; i < numOfSlides; i++) {
|
|
71
|
-
buttons.push( /*#__PURE__*/React.createElement(CarouselSelectorInputWrapperStyle, {
|
|
72
|
-
key: i,
|
|
73
|
-
"data-element": "selector-inputs"
|
|
74
|
-
}, /*#__PURE__*/React.createElement(CarouselSelectorInputStyle, {
|
|
75
|
-
"data-element": "selector-input",
|
|
76
|
-
name: `carousel-slide-${id}`,
|
|
77
|
-
id: `carousel-slide-${i}-${id}`,
|
|
78
|
-
type: "radio",
|
|
79
|
-
value: i,
|
|
80
|
-
onChange: onSlideSelection,
|
|
81
|
-
checked: selectedSlideIndex === i
|
|
82
|
-
}), /*#__PURE__*/React.createElement(CarouselSelectorLabelStyle, {
|
|
83
|
-
"data-element": "selector-label",
|
|
84
|
-
htmlFor: `carousel-slide-${i}-${id}`
|
|
85
|
-
})));
|
|
86
|
-
}
|
|
87
|
-
return /*#__PURE__*/React.createElement(CarouselSelectorWrapperStyle, {
|
|
88
|
-
"data-element": "slide-selector"
|
|
89
|
-
}, buttons);
|
|
90
|
-
}
|
|
91
|
-
function previousButton() {
|
|
92
|
-
if (!enablePreviousButton) return null;
|
|
93
|
-
const isDisabled = selectedSlideIndex === 0;
|
|
94
|
-
return /*#__PURE__*/React.createElement(CarouselPreviousButtonWrapperStyle, null, /*#__PURE__*/React.createElement(CarouselButtonStyle, {
|
|
95
|
-
onClick: onPreviousClick,
|
|
96
|
-
"data-element": "previous",
|
|
97
|
-
"aria-label": "previous",
|
|
98
|
-
disabled: isDisabled
|
|
99
|
-
}, /*#__PURE__*/React.createElement(CarouselStyledIconLeft, {
|
|
100
|
-
type: "chevron_down"
|
|
101
|
-
})));
|
|
102
|
-
}
|
|
103
|
-
function nextButton() {
|
|
104
|
-
if (!enableNextButton) return null;
|
|
105
|
-
const isDisabled = numOfSlides === selectedSlideIndex + 1;
|
|
106
|
-
return /*#__PURE__*/React.createElement(CarouselNextButtonWrapperStyle, null, /*#__PURE__*/React.createElement(CarouselButtonStyle, {
|
|
107
|
-
onClick: onNextClick,
|
|
108
|
-
"data-element": "next",
|
|
109
|
-
"aria-label": "next",
|
|
110
|
-
type: "button",
|
|
111
|
-
disabled: isDisabled
|
|
112
|
-
}, /*#__PURE__*/React.createElement(CarouselStyledIconRight, {
|
|
113
|
-
type: "chevron_down"
|
|
114
|
-
})));
|
|
115
|
-
}
|
|
116
|
-
return /*#__PURE__*/React.createElement(CarouselWrapperStyle, _extends({
|
|
117
|
-
className: className
|
|
118
|
-
}, tagComponent("carousel", props)), /*#__PURE__*/React.createElement("div", {
|
|
119
|
-
className: "carbon-carousel__content"
|
|
120
|
-
}, previousButton(), /*#__PURE__*/React.createElement(CarouselSliderWrapper, {
|
|
121
|
-
elementIndex: selectedSlideIndex
|
|
122
|
-
}, children), nextButton()), slideSelector());
|
|
123
|
-
};
|
|
124
|
-
Carousel.displayName = "Carousel";
|
|
125
|
-
export default Carousel;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
declare const CarouselNavigationStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
-
declare const CarouselPreviousButtonWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
-
declare const CarouselNextButtonWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
-
declare const CarouselStyledIcon: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
6
|
-
declare const CarouselStyledIconLeft: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
7
|
-
declare const CarouselStyledIconRight: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../icon").IconProps & import("react").RefAttributes<HTMLSpanElement>>, any, {}, never>;
|
|
8
|
-
declare const CarouselButtonStyle: import("styled-components").StyledComponent<"button", any, {
|
|
9
|
-
type: "button";
|
|
10
|
-
}, "type">;
|
|
11
|
-
declare const CarouselSelectorInputStyle: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
12
|
-
declare const CarouselSelectorLabelStyle: import("styled-components").StyledComponent<"label", any, {}, never>;
|
|
13
|
-
declare const CarouselSelectorWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
14
|
-
declare const CarouselSelectorInputWrapperStyle: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
15
|
-
interface CarouselSliderWrapperProps {
|
|
16
|
-
elementIndex: number;
|
|
17
|
-
}
|
|
18
|
-
declare const CarouselSliderWrapper: import("styled-components").StyledComponent<"div", any, CarouselSliderWrapperProps, never>;
|
|
19
|
-
declare const CarouselWrapperStyle: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
20
|
-
export { CarouselNavigationStyle, CarouselNextButtonWrapperStyle, CarouselPreviousButtonWrapperStyle, CarouselButtonStyle, CarouselStyledIcon, CarouselStyledIconLeft, CarouselStyledIconRight, CarouselSelectorWrapperStyle, CarouselSelectorInputWrapperStyle, CarouselSelectorInputStyle, CarouselSelectorLabelStyle, CarouselWrapperStyle, CarouselSliderWrapper, };
|