Socket
Socket
Sign inDemoInstall

@reach/alert-dialog

Package Overview
Dependencies
Maintainers
4
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/alert-dialog - npm Package Compare versions

Comparing version 0.11.2 to 0.12.0

75

dist/alert-dialog.cjs.development.js

@@ -14,3 +14,2 @@ 'use strict';

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);

@@ -48,3 +47,3 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);

var AlertDialogOverlay = /*#__PURE__*/React.forwardRef(function AlertDialogOverlay(_ref, forwardedRef) {
var AlertDialogOverlay = /*#__PURE__*/utils.forwardRefWithAs(function AlertDialogOverlay(_ref, forwardedRef) {
var leastDestructiveRef = _ref.leastDestructiveRef,

@@ -58,3 +57,3 @@ props = _objectWithoutPropertiesLoose(_ref, ["leastDestructiveRef"]);

var descriptionId = id ? utils.makeId("alert-dialog-description", id) : undefined;
return React__default['default'].createElement(AlertDialogContext.Provider, {
return React.createElement(AlertDialogContext.Provider, {
value: {

@@ -66,3 +65,3 @@ labelId: labelId,

}
}, React__default['default'].createElement(dialog.DialogOverlay, Object.assign({}, props, {
}, React.createElement(dialog.DialogOverlay, Object.assign({}, props, {
ref: ref,

@@ -102,14 +101,14 @@ "data-reach-alert-dialog-overlay": true,

var AlertDialogContent = /*#__PURE__*/React.forwardRef(function AlertDialogContent(_ref2, forwardRef) {
var AlertDialogContent = /*#__PURE__*/utils.forwardRefWithAs(function AlertDialogContent(_ref2, forwardedRef) {
var children = _ref2.children,
props = _objectWithoutPropertiesLoose(_ref2, ["children"]);
var _useContext = React.useContext(AlertDialogContext),
descriptionId = _useContext.descriptionId,
labelId = _useContext.labelId,
leastDestructiveRef = _useContext.leastDestructiveRef,
overlayRef = _useContext.overlayRef;
var _React$useContext = React.useContext(AlertDialogContext),
descriptionId = _React$useContext.descriptionId,
labelId = _React$useContext.labelId,
leastDestructiveRef = _React$useContext.leastDestructiveRef,
overlayRef = _React$useContext.overlayRef;
React.useEffect(function () {
var ownerDocument = utils.getOwnerDocument(overlayRef.current) || document;
var ownerDocument = utils.getOwnerDocument(overlayRef.current);

@@ -122,3 +121,3 @@ if (labelId) {

}, [labelId, leastDestructiveRef]);
return React__default['default'].createElement(dialog.DialogContent // The element that contains all elements of the dialog, including the
return React.createElement(dialog.DialogContent // The element that contains all elements of the dialog, including the
// alert message and any dialog buttons, has role alertdialog.

@@ -134,3 +133,3 @@ // https://www.w3.org/TR/wai-aria-practices-1.2/#alertdialog

}, props, {
ref: forwardRef,
ref: forwardedRef,
"data-reach-alert-dialong-content": true,

@@ -161,11 +160,16 @@ "data-reach-alert-dialog-content": true

var AlertDialogLabel = function AlertDialogLabel(props) {
var _useContext2 = React.useContext(AlertDialogContext),
labelId = _useContext2.labelId;
var AlertDialogLabel = /*#__PURE__*/utils.forwardRefWithAs(function (_ref3, forwardedRef) {
var _ref3$as = _ref3.as,
Comp = _ref3$as === void 0 ? "div" : _ref3$as,
props = _objectWithoutPropertiesLoose(_ref3, ["as"]);
return React__default['default'].createElement("div", Object.assign({}, props, {
var _React$useContext2 = React.useContext(AlertDialogContext),
labelId = _React$useContext2.labelId;
return React.createElement(Comp, Object.assign({}, props, {
ref: forwardedRef,
id: labelId,
"data-reach-alert-dialog-label": true
}));
};
});

@@ -188,11 +192,16 @@ {

var AlertDialogDescription = function AlertDialogDescription(props) {
var _useContext3 = React.useContext(AlertDialogContext),
descriptionId = _useContext3.descriptionId;
var AlertDialogDescription = /*#__PURE__*/utils.forwardRefWithAs(function AlertDialogDescription(_ref4, forwardedRef) {
var _ref4$as = _ref4.as,
Comp = _ref4$as === void 0 ? "div" : _ref4$as,
props = _objectWithoutPropertiesLoose(_ref4, ["as"]);
return React__default['default'].createElement("div", Object.assign({}, props, {
var _React$useContext3 = React.useContext(AlertDialogContext),
descriptionId = _React$useContext3.descriptionId;
return React.createElement(Comp, Object.assign({}, props, {
ref: forwardedRef,
id: descriptionId,
"data-reach-alert-dialog-description": true
}));
};
});

@@ -213,10 +222,10 @@ {

var AlertDialog = function AlertDialog(_ref3) {
var id = _ref3.id,
isOpen = _ref3.isOpen,
onDismiss = _ref3.onDismiss,
leastDestructiveRef = _ref3.leastDestructiveRef,
props = _objectWithoutPropertiesLoose(_ref3, ["id", "isOpen", "onDismiss", "leastDestructiveRef"]);
var AlertDialog = /*#__PURE__*/utils.forwardRefWithAs(function AlertDialog(_ref5, forwardedRef) {
var id = _ref5.id,
isOpen = _ref5.isOpen,
onDismiss = _ref5.onDismiss,
leastDestructiveRef = _ref5.leastDestructiveRef,
props = _objectWithoutPropertiesLoose(_ref5, ["id", "isOpen", "onDismiss", "leastDestructiveRef"]);
return React__default['default'].createElement(AlertDialogOverlay, Object.assign({}, {
return React.createElement(AlertDialogOverlay, Object.assign({}, {
isOpen: isOpen,

@@ -226,4 +235,6 @@ onDismiss: onDismiss,

id: id
}), React__default['default'].createElement(AlertDialogContent, Object.assign({}, props)));
};
}), React.createElement(AlertDialogContent, Object.assign({
ref: forwardedRef
}, props)));
});

@@ -230,0 +241,0 @@ {

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@reach/dialog"),r=require("@reach/auto-id"),a=require("@reach/utils"),i=require("invariant");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("prop-types");var n=l(e),o=l(i);function d(e,t){if(null==e)return{};var r,a,i={},l=Object.keys(e);for(a=0;a<l.length;a++)t.indexOf(r=l[a])>=0||(i[r]=e[r]);return i}var s=a.createNamedContext("AlertDialogContext",{}),u=e.forwardRef((function(i,l){var o=i.leastDestructiveRef,u=d(i,["leastDestructiveRef"]),c=e.useRef(null),f=a.useForkedRef(l,c),v=r.useId(u.id),g=v?a.makeId("alert-dialog",v):void 0,p=v?a.makeId("alert-dialog-description",v):void 0;return n.default.createElement(s.Provider,{value:{labelId:g,descriptionId:p,overlayRef:c,leastDestructiveRef:o}},n.default.createElement(t.DialogOverlay,Object.assign({},u,{ref:f,"data-reach-alert-dialog-overlay":!0,initialFocusRef:o})))})),c=e.forwardRef((function(r,i){var l=r.children,u=d(r,["children"]),c=e.useContext(s),f=c.descriptionId,v=c.labelId,g=c.leastDestructiveRef,p=c.overlayRef;return e.useEffect((function(){var e=a.getOwnerDocument(p.current)||document;v&&(e.getElementById(v)||o.default(!1)),g||o.default(!1)}),[v,g]),n.default.createElement(t.DialogContent,Object.assign({role:"alertdialog","aria-describedby":f,"aria-labelledby":u["aria-label"]?void 0:v},u,{ref:i,"data-reach-alert-dialong-content":!0,"data-reach-alert-dialog-content":!0}),l)}));exports.AlertDialog=function(e){var t=e.id,r=e.isOpen,a=e.onDismiss,i=e.leastDestructiveRef,l=d(e,["id","isOpen","onDismiss","leastDestructiveRef"]);return n.default.createElement(u,Object.assign({},{isOpen:r,onDismiss:a,leastDestructiveRef:i,id:t}),n.default.createElement(c,Object.assign({},l)))},exports.AlertDialogContent=c,exports.AlertDialogDescription=function(t){var r=e.useContext(s);return n.default.createElement("div",Object.assign({},t,{id:r.descriptionId,"data-reach-alert-dialog-description":!0}))},exports.AlertDialogLabel=function(t){var r=e.useContext(s);return n.default.createElement("div",Object.assign({},t,{id:r.labelId,"data-reach-alert-dialog-label":!0}))},exports.AlertDialogOverlay=u;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@reach/dialog"),r=require("@reach/auto-id"),a=require("@reach/utils"),i=require("invariant");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("prop-types");var n=l(i);function o(e,t){if(null==e)return{};var r,a,i={},l=Object.keys(e);for(a=0;a<l.length;a++)t.indexOf(r=l[a])>=0||(i[r]=e[r]);return i}var s=a.createNamedContext("AlertDialogContext",{}),d=a.forwardRefWithAs((function(i,l){var n=i.leastDestructiveRef,d=o(i,["leastDestructiveRef"]),c=e.useRef(null),u=a.useForkedRef(l,c),f=r.useId(d.id),v=f?a.makeId("alert-dialog",f):void 0,g=f?a.makeId("alert-dialog-description",f):void 0;return e.createElement(s.Provider,{value:{labelId:v,descriptionId:g,overlayRef:c,leastDestructiveRef:n}},e.createElement(t.DialogOverlay,Object.assign({},d,{ref:u,"data-reach-alert-dialog-overlay":!0,initialFocusRef:n})))})),c=a.forwardRefWithAs((function(r,i){var l=r.children,d=o(r,["children"]),c=e.useContext(s),u=c.descriptionId,f=c.labelId,v=c.leastDestructiveRef,g=c.overlayRef;return e.useEffect((function(){var e=a.getOwnerDocument(g.current);f&&(e.getElementById(f)||n.default(!1)),v||n.default(!1)}),[f,v]),e.createElement(t.DialogContent,Object.assign({role:"alertdialog","aria-describedby":u,"aria-labelledby":d["aria-label"]?void 0:f},d,{ref:i,"data-reach-alert-dialong-content":!0,"data-reach-alert-dialog-content":!0}),l)})),u=a.forwardRefWithAs((function(t,r){var a=t.as,i=void 0===a?"div":a,l=o(t,["as"]),n=e.useContext(s);return e.createElement(i,Object.assign({},l,{ref:r,id:n.labelId,"data-reach-alert-dialog-label":!0}))})),f=a.forwardRefWithAs((function(t,r){var a=t.as,i=void 0===a?"div":a,l=o(t,["as"]),n=e.useContext(s);return e.createElement(i,Object.assign({},l,{ref:r,id:n.descriptionId,"data-reach-alert-dialog-description":!0}))}));exports.AlertDialog=a.forwardRefWithAs((function(t,r){var a=t.id,i=t.isOpen,l=t.onDismiss,n=t.leastDestructiveRef,s=o(t,["id","isOpen","onDismiss","leastDestructiveRef"]);return e.createElement(d,Object.assign({},{isOpen:i,onDismiss:l,leastDestructiveRef:n,id:a}),e.createElement(c,Object.assign({ref:r},s)))})),exports.AlertDialogContent=c,exports.AlertDialogDescription=f,exports.AlertDialogLabel=u,exports.AlertDialogOverlay=d;
//# sourceMappingURL=alert-dialog.cjs.production.min.js.map

@@ -1,5 +0,5 @@

import React, { forwardRef, useRef, useContext, useEffect } from 'react';
import { useRef, createElement, useContext, useEffect } from 'react';
import { DialogOverlay, DialogContent } from '@reach/dialog';
import { useId } from '@reach/auto-id';
import { useForkedRef, makeId, getOwnerDocument, createNamedContext } from '@reach/utils';
import { forwardRefWithAs, useForkedRef, makeId, getOwnerDocument, createNamedContext } from '@reach/utils';
import invariant from 'invariant';

@@ -37,3 +37,3 @@ import PropTypes from 'prop-types';

var AlertDialogOverlay = /*#__PURE__*/forwardRef(function AlertDialogOverlay(_ref, forwardedRef) {
var AlertDialogOverlay = /*#__PURE__*/forwardRefWithAs(function AlertDialogOverlay(_ref, forwardedRef) {
var leastDestructiveRef = _ref.leastDestructiveRef,

@@ -47,3 +47,3 @@ props = _objectWithoutPropertiesLoose(_ref, ["leastDestructiveRef"]);

var descriptionId = id ? makeId("alert-dialog-description", id) : undefined;
return React.createElement(AlertDialogContext.Provider, {
return createElement(AlertDialogContext.Provider, {
value: {

@@ -55,3 +55,3 @@ labelId: labelId,

}
}, React.createElement(DialogOverlay, Object.assign({}, props, {
}, createElement(DialogOverlay, Object.assign({}, props, {
ref: ref,

@@ -91,14 +91,14 @@ "data-reach-alert-dialog-overlay": true,

var AlertDialogContent = /*#__PURE__*/forwardRef(function AlertDialogContent(_ref2, forwardRef) {
var AlertDialogContent = /*#__PURE__*/forwardRefWithAs(function AlertDialogContent(_ref2, forwardedRef) {
var children = _ref2.children,
props = _objectWithoutPropertiesLoose(_ref2, ["children"]);
var _useContext = useContext(AlertDialogContext),
descriptionId = _useContext.descriptionId,
labelId = _useContext.labelId,
leastDestructiveRef = _useContext.leastDestructiveRef,
overlayRef = _useContext.overlayRef;
var _React$useContext = useContext(AlertDialogContext),
descriptionId = _React$useContext.descriptionId,
labelId = _React$useContext.labelId,
leastDestructiveRef = _React$useContext.leastDestructiveRef,
overlayRef = _React$useContext.overlayRef;
useEffect(function () {
var ownerDocument = getOwnerDocument(overlayRef.current) || document;
var ownerDocument = getOwnerDocument(overlayRef.current);

@@ -111,3 +111,3 @@ if (labelId) {

}, [labelId, leastDestructiveRef]);
return React.createElement(DialogContent // The element that contains all elements of the dialog, including the
return createElement(DialogContent // The element that contains all elements of the dialog, including the
// alert message and any dialog buttons, has role alertdialog.

@@ -123,3 +123,3 @@ // https://www.w3.org/TR/wai-aria-practices-1.2/#alertdialog

}, props, {
ref: forwardRef,
ref: forwardedRef,
"data-reach-alert-dialong-content": true,

@@ -150,11 +150,16 @@ "data-reach-alert-dialog-content": true

var AlertDialogLabel = function AlertDialogLabel(props) {
var _useContext2 = useContext(AlertDialogContext),
labelId = _useContext2.labelId;
var AlertDialogLabel = /*#__PURE__*/forwardRefWithAs(function (_ref3, forwardedRef) {
var _ref3$as = _ref3.as,
Comp = _ref3$as === void 0 ? "div" : _ref3$as,
props = _objectWithoutPropertiesLoose(_ref3, ["as"]);
return React.createElement("div", Object.assign({}, props, {
var _React$useContext2 = useContext(AlertDialogContext),
labelId = _React$useContext2.labelId;
return createElement(Comp, Object.assign({}, props, {
ref: forwardedRef,
id: labelId,
"data-reach-alert-dialog-label": true
}));
};
});

@@ -177,11 +182,16 @@ if (process.env.NODE_ENV !== "production") {

var AlertDialogDescription = function AlertDialogDescription(props) {
var _useContext3 = useContext(AlertDialogContext),
descriptionId = _useContext3.descriptionId;
var AlertDialogDescription = /*#__PURE__*/forwardRefWithAs(function AlertDialogDescription(_ref4, forwardedRef) {
var _ref4$as = _ref4.as,
Comp = _ref4$as === void 0 ? "div" : _ref4$as,
props = _objectWithoutPropertiesLoose(_ref4, ["as"]);
return React.createElement("div", Object.assign({}, props, {
var _React$useContext3 = useContext(AlertDialogContext),
descriptionId = _React$useContext3.descriptionId;
return createElement(Comp, Object.assign({}, props, {
ref: forwardedRef,
id: descriptionId,
"data-reach-alert-dialog-description": true
}));
};
});

@@ -202,10 +212,10 @@ if (process.env.NODE_ENV !== "production") {

var AlertDialog = function AlertDialog(_ref3) {
var id = _ref3.id,
isOpen = _ref3.isOpen,
onDismiss = _ref3.onDismiss,
leastDestructiveRef = _ref3.leastDestructiveRef,
props = _objectWithoutPropertiesLoose(_ref3, ["id", "isOpen", "onDismiss", "leastDestructiveRef"]);
var AlertDialog = /*#__PURE__*/forwardRefWithAs(function AlertDialog(_ref5, forwardedRef) {
var id = _ref5.id,
isOpen = _ref5.isOpen,
onDismiss = _ref5.onDismiss,
leastDestructiveRef = _ref5.leastDestructiveRef,
props = _objectWithoutPropertiesLoose(_ref5, ["id", "isOpen", "onDismiss", "leastDestructiveRef"]);
return React.createElement(AlertDialogOverlay, Object.assign({}, {
return createElement(AlertDialogOverlay, Object.assign({}, {
isOpen: isOpen,

@@ -215,4 +225,6 @@ onDismiss: onDismiss,

id: id
}), React.createElement(AlertDialogContent, Object.assign({}, props)));
};
}), createElement(AlertDialogContent, Object.assign({
ref: forwardedRef
}, props)));
});

@@ -219,0 +231,0 @@ if (process.env.NODE_ENV !== "production") {

@@ -29,7 +29,7 @@ /**

* @see Docs https://reach.tech/alert-dialog
* @see Source https://github.com/reach/reach-ui/tree/main/packages/alert-dialog
* @see Source https://github.com/reach/reach-ui/tree/main/packages/alert-dialog
* @see WAI-ARIA https://www.w3.org/TR/wai-aria-practices-1.2/#alertdialog
*/
import React from "react";
import { DialogProps, DialogContentProps } from "@reach/dialog";
import * as React from "react";
import type { DialogProps, DialogContentProps } from "@reach/dialog";
/**

@@ -46,40 +46,3 @@ * AlertDialogOverlay

*/
export declare const AlertDialogOverlay: React.ForwardRefExoticComponent<{
/**
* Controls whether the dialog is open or not.
*
* @see Docs: https://reach.tech/alert-dialog#alertdialog-isopen
*/
isOpen?: boolean | undefined;
/**
* When the user clicks outside the modal or hits the escape key,
* this function will be called. If you want the modal to close,
* you’ll need to set state.
*
* @see Docs: https://reach.tech/alert-dialog#alertdialog-ondismiss
*/
onDismiss?: ((event?: React.SyntheticEvent<Element, Event> | undefined) => void) | undefined;
/**
* To prevent accidental data loss, an alert dialog should focus the least
* destructive action button when it opens.
*
* @see Docs: https://reach.tech/alert-dialog#alertdialog-leastdestructiveref
*/
leastDestructiveRef?: React.RefObject<HTMLElement> | undefined;
/**
* Accepts any renderable content but should generally be restricted to
* `AlertDialogLabel`, `AlertDialogDescription` and action buttons, other
* content might not be announced to the user by the screen reader.
*
* @see Docs: https://reach.tech/alert-dialog#alertdialog-children
*/
children: React.ReactNode;
} & {
allowPinchZoom?: boolean | undefined;
children?: React.ReactNode;
initialFocusRef?: React.RefObject<any> | undefined;
isOpen?: boolean | undefined;
onDismiss?: ((event?: React.SyntheticEvent<Element, Event> | undefined) => void) | undefined;
unstable_lockFocusAcrossFrames?: boolean | undefined;
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
declare const AlertDialogOverlay: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", AlertDialogProps>;
/**

@@ -99,18 +62,7 @@ * AlertDialogContent

*/
export declare const AlertDialogContent: React.ForwardRefExoticComponent<{
/**
* Accepts any renderable content but should generally be restricted to
* `AlertDialogLabel`, `AlertDialogDescription` and action buttons, other
* content might not be announced to the user by the screen reader.
*
* @see Docs https://reach.tech/alert-dialog#alertdialogcontent-children
*/
children: React.ReactNode;
} & {
children?: React.ReactNode;
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
declare const AlertDialogContent: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", AlertDialogContentProps>;
/**
* @see Docs https://reach.tech/alert-dialog#alertdialogcontent-props
*/
export declare type AlertDialogContentProps = {
declare type AlertDialogContentProps = {
/**

@@ -136,3 +88,4 @@ * Accepts any renderable content but should generally be restricted to

*/
export declare const AlertDialogLabel: React.FC<React.HTMLAttributes<HTMLDivElement>>;
declare const AlertDialogLabel: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", AlertDialogLabelProps>;
declare type AlertDialogLabelProps = {};
/**

@@ -148,3 +101,4 @@ * AlertDialogDescription

*/
export declare const AlertDialogDescription: React.FC<React.HTMLAttributes<HTMLDivElement>>;
declare const AlertDialogDescription: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", AlertDialogDescriptionProps>;
declare type AlertDialogDescriptionProps = {};
/**

@@ -158,7 +112,8 @@ * AlertDialog

*/
export declare const AlertDialog: React.FC<AlertDialogProps>;
declare const AlertDialog: import("@reach/utils").ForwardRefExoticComponentWithAs<"div", AlertDialogProps>;
/**
* @see Docs https://reach.tech/alert-dialog#alertdialog-props
*/
export declare type AlertDialogProps = {
declare type AlertDialogProps = {
id?: string;
/**

@@ -194,1 +149,3 @@ * Controls whether the dialog is open or not.

} & DialogProps;
export type { AlertDialogContentProps, AlertDialogDescriptionProps, AlertDialogLabelProps, AlertDialogProps, };
export { AlertDialog, AlertDialogContent, AlertDialogDescription, AlertDialogLabel, AlertDialogOverlay, };
{
"name": "@reach/alert-dialog",
"version": "0.11.2",
"version": "0.12.0",
"description": "Accessible React Alert Dialog.",

@@ -16,5 +16,5 @@ "author": "React Training <hello@reacttraining.com>",

"dependencies": {
"@reach/auto-id": "0.11.2",
"@reach/dialog": "0.11.2",
"@reach/utils": "0.11.2",
"@reach/auto-id": "0.12.0",
"@reach/dialog": "0.12.0",
"@reach/utils": "0.12.0",
"invariant": "^2.2.4",

@@ -35,3 +35,3 @@ "prop-types": "^15.7.2",

],
"gitHead": "2aa6f03c5eed8c2b7525a29db1c69fe6bc540e5d"
"gitHead": "09eeccda6e4597d21545982c53db5c42beddce6b"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc