@deque/cauldron-react 7.1.0-canary.3dc1ee55 → 7.1.0-canary.733aecb0

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.
@@ -3,6 +3,9 @@ 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
+ */
6
9
  toastRef?: React.Ref<HTMLDivElement>;
7
10
  focus?: boolean;
8
11
  show?: boolean;
@@ -12,8 +15,5 @@ export interface ToastProps extends React.HTMLAttributes<HTMLDivElement> {
12
15
  /**
13
16
  * The cauldron toast notification component
14
17
  */
15
- declare const Toast: {
16
- ({ type, children, onDismiss, dismissText, toastRef, focus, show, dismissible, className, ...otherProps }: ToastProps): React.JSX.Element;
17
- displayName: string;
18
- };
18
+ declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLDivElement>>;
19
19
  export default Toast;
package/lib/index.js CHANGED
@@ -2243,14 +2243,22 @@ var useDidUpdate = function (effect, dependencies) {
2243
2243
  /**
2244
2244
  * The cauldron toast notification component
2245
2245
  */
2246
- var Toast = function (_a) {
2246
+ var Toast = React.forwardRef(function (_a, ref) {
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(toastRef !== null && toastRef !== void 0 ? toastRef : null);
2250
+ var elRef = useSharedRef(ref);
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]);
2254
2262
  // Timeout because CSS display: none/block and opacity:
2255
2263
  // 0/1 properties cannot be toggled in the same tick
2256
2264
  // see: https://codepen.io/isnerms/pen/eyQaLP
@@ -2324,7 +2332,7 @@ var Toast = function (_a) {
2324
2332
  type !== 'action-needed' && dismissible && (React__default["default"].createElement("button", { type: "button", className: "Toast__dismiss", "aria-label": dismissText, onClick: dismissToast },
2325
2333
  React__default["default"].createElement(Icon, { type: "close" })))),
2326
2334
  scrim));
2327
- };
2335
+ });
2328
2336
  Toast.displayName = 'Toast';
2329
2337
 
2330
2338
  var Link = React.forwardRef(function (_a, ref) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "7.1.0-canary.3dc1ee55",
3
+ "version": "7.1.0-canary.733aecb0",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",