@deque/cauldron-react 7.1.0-canary.b7d2a9c6 → 7.1.0-canary.fc8c0765
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/lib/components/Toast/index.d.ts +4 -4
- package/lib/index.js +3 -11
- package/package.json +1 -1
|
@@ -3,9 +3,6 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
3
3
|
type: 'confirmation' | 'caution' | 'error' | 'action-needed' | 'info';
|
|
4
4
|
onDismiss?: () => void;
|
|
5
5
|
dismissText?: string;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use the forwarded `ref` instead. Will be removed in the next major version.
|
|
8
|
-
*/
|
|
9
6
|
toastRef?: React.Ref<HTMLDivElement>;
|
|
10
7
|
focus?: boolean;
|
|
11
8
|
show?: boolean;
|
|
@@ -15,5 +12,8 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
15
12
|
/**
|
|
16
13
|
* The cauldron toast notification component
|
|
17
14
|
*/
|
|
18
|
-
declare const Toast:
|
|
15
|
+
declare const Toast: {
|
|
16
|
+
({ type, children, onDismiss, dismissText, toastRef, focus, show, dismissible, className, ...otherProps }: ToastProps): React.JSX.Element;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
19
19
|
export default Toast;
|
package/lib/index.js
CHANGED
|
@@ -2243,22 +2243,14 @@ var useDidUpdate = function (effect, dependencies) {
|
|
|
2243
2243
|
/**
|
|
2244
2244
|
* The cauldron toast notification component
|
|
2245
2245
|
*/
|
|
2246
|
-
var Toast =
|
|
2246
|
+
var Toast = function (_a) {
|
|
2247
2247
|
var type = _a.type, children = _a.children, _b = _a.onDismiss, onDismiss = _b === void 0 ? function () {
|
|
2248
2248
|
// noop
|
|
2249
2249
|
} : _b, _c = _a.dismissText, dismissText = _c === void 0 ? 'Dismiss' : _c, toastRef = _a.toastRef, _d = _a.focus, focus = _d === void 0 ? true : _d, _e = _a.show, show = _e === void 0 ? false : _e, _f = _a.dismissible, dismissible = _f === void 0 ? true : _f, className = _a.className, otherProps = tslib.__rest(_a, ["type", "children", "onDismiss", "dismissText", "toastRef", "focus", "show", "dismissible", "className"]);
|
|
2250
|
-
var elRef = useSharedRef(
|
|
2250
|
+
var elRef = useSharedRef(toastRef !== null && toastRef !== void 0 ? toastRef : null);
|
|
2251
2251
|
var isolatorRef = React.useRef(null);
|
|
2252
2252
|
var timeoutsRef = React.useRef(new Set());
|
|
2253
2253
|
var _g = tslib.__read(React.useState(show ? 'FadeIn--flex' : 'is--hidden'), 2), animationClass = _g[0], setAnimationClass = _g[1];
|
|
2254
|
-
// Backwards-compat: propagate to the deprecated toastRef prop as well
|
|
2255
|
-
React.useEffect(function () {
|
|
2256
|
-
var _a;
|
|
2257
|
-
if (!toastRef)
|
|
2258
|
-
return;
|
|
2259
|
-
setRef(toastRef, (_a = elRef.current) !== null && _a !== void 0 ? _a : null);
|
|
2260
|
-
return function () { return setRef(toastRef, null); };
|
|
2261
|
-
}, [toastRef]);
|
|
2262
2254
|
// Timeout because CSS display: none/block and opacity:
|
|
2263
2255
|
// 0/1 properties cannot be toggled in the same tick
|
|
2264
2256
|
// see: https://codepen.io/isnerms/pen/eyQaLP
|
|
@@ -2332,7 +2324,7 @@ var Toast = React.forwardRef(function (_a, ref) {
|
|
|
2332
2324
|
type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: "Toast__dismiss", "aria-label": dismissText, onClick: dismissToast },
|
|
2333
2325
|
React__default["default"].createElement(Icon, { type: "close" })))),
|
|
2334
2326
|
scrim));
|
|
2335
|
-
}
|
|
2327
|
+
};
|
|
2336
2328
|
Toast.displayName = 'Toast';
|
|
2337
2329
|
|
|
2338
2330
|
var Link = React.forwardRef(function (_a, ref) {
|
package/package.json
CHANGED