@reach/dialog
Advanced tools
Comparing version 0.8.0 to 0.8.2
@@ -253,2 +253,3 @@ 'use strict'; | ||
var rootNodes = []; | ||
var ownerDocument = utils.getOwnerDocument(dialogNode) || document; | ||
@@ -263,3 +264,3 @@ if (!dialogNode) { | ||
Array.prototype.forEach.call(document.querySelectorAll("body > *"), function (node) { | ||
Array.prototype.forEach.call(ownerDocument.querySelectorAll("body > *"), function (node) { | ||
var _dialogNode$parentNod, _dialogNode$parentNod2; | ||
@@ -306,3 +307,3 @@ | ||
return new Error("You provided both `aria-label` and `aria-labelledby` props to a <" + compName + ">. If the a label for this component is visible on the screen, that label's component should be given a unique ID prop, and that ID should be passed as the `aria-labelledby` prop into <" + compName + ">. If the label cannot be determined programmatically from the content of the element, an alternative label should be provided as the `aria-label` prop, which will be used as an `aria-label` on the HTML tag." + details); | ||
} else if (props[propName] != null && typeof props[propName] !== "string") { | ||
} else if (props[propName] != null && !utils.isString(props[propName])) { | ||
return new Error("Invalid prop `" + propName + "` supplied to `" + compName + "`. Expected `string`, received `" + (Array.isArray(propFullName) ? "array" : typeof propFullName) + "`."); | ||
@@ -309,0 +310,0 @@ } |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),o=e(n),r=e(require("@reach/portal")),t=require("@reach/utils"),i=e(require("react-focus-lock")),a=require("react-remove-scroll");function u(e,n){if(null==e)return{};var o,r,t={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(o=i[r])>=0||(t[o]=e[o]);return t}require("prop-types");var c=n.forwardRef((function(e,i){var a=e.isOpen,c=void 0===a||a,s=u(e,["isOpen"]);return n.useEffect((function(){return t.checkStyles("dialog")}),[]),c?o.createElement(r,{"data-reach-dialog-wrapper":""},o.createElement(l,Object.assign({ref:i},s))):null})),l=n.forwardRef((function(e,r){var c=e.allowPinchZoom,l=e.initialFocusRef,s=e.onClick,f=e.onDismiss,d=void 0===f?t.noop:f,p=e.onMouseDown,v=e.onKeyDown,m=u(e,["allowPinchZoom","initialFocusRef","onClick","onDismiss","onMouseDown","onKeyDown"]),g=n.useRef(null),w=n.useRef(null),h=t.useForkedRef(w,r),E=n.useCallback((function(){l&&l.current&&l.current.focus()}),[l]);return n.useEffect((function(){return w.current?(n=[],o=[],(e=w.current)?(Array.prototype.forEach.call(document.querySelectorAll("body > *"),(function(r){var t,i;if(r!==(null===(t=e.parentNode)||void 0===t?void 0:null===(i=t.parentNode)||void 0===i?void 0:i.parentNode)){var a=r.getAttribute("aria-hidden");null!==a&&"false"!==a||(n.push(a),o.push(r),r.setAttribute("aria-hidden","true"))}})),function(){o.forEach((function(e,o){var r=n[o];null===r?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r)}))}):t.noop):void 0;var e,n,o}),[]),o.createElement(i,{autoFocus:!0,returnFocus:!0,onActivation:E},o.createElement(a.RemoveScroll,{allowPinchZoom:c},o.createElement("div",Object.assign({},m,{ref:h,"data-reach-dialog-overlay":"",onClick:t.wrapEvent(s,(function(e){g.current===e.target&&(e.stopPropagation(),d(e))})),onKeyDown:t.wrapEvent(v,(function(e){"Escape"===e.key&&(e.stopPropagation(),d(e))})),onMouseDown:t.wrapEvent(p,(function(e){g.current=e.target}))}))))})),s=n.forwardRef((function(e,n){var r=e.onClick,i=u(e,["onClick","onKeyDown"]);return o.createElement("div",Object.assign({"aria-modal":"true",role:"dialog",tabIndex:-1},i,{ref:n,"data-reach-dialog-content":"",onClick:t.wrapEvent(r,(function(e){e.stopPropagation()}))}))})),f=n.forwardRef((function(e,n){var r=e.isOpen,i=e.onDismiss,a=void 0===i?t.noop:i,l=e.initialFocusRef,f=u(e,["isOpen","onDismiss","initialFocusRef"]);return o.createElement(c,{initialFocusRef:l,isOpen:r,onDismiss:a},o.createElement(s,Object.assign({ref:n},f)))}));exports.Dialog=f,exports.DialogContent=s,exports.DialogOverlay=c,exports.default=f; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),o=e(n),r=e(require("@reach/portal")),t=require("@reach/utils"),i=e(require("react-focus-lock")),a=require("react-remove-scroll");function u(e,n){if(null==e)return{};var o,r,t={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(o=i[r])>=0||(t[o]=e[o]);return t}require("prop-types");var c=n.forwardRef((function(e,i){var a=e.isOpen,c=void 0===a||a,s=u(e,["isOpen"]);return n.useEffect((function(){return t.checkStyles("dialog")}),[]),c?o.createElement(r,{"data-reach-dialog-wrapper":""},o.createElement(l,Object.assign({ref:i},s))):null})),l=n.forwardRef((function(e,r){var c=e.allowPinchZoom,l=e.initialFocusRef,s=e.onClick,f=e.onDismiss,d=void 0===f?t.noop:f,p=e.onMouseDown,v=e.onKeyDown,m=u(e,["allowPinchZoom","initialFocusRef","onClick","onDismiss","onMouseDown","onKeyDown"]),g=n.useRef(null),w=n.useRef(null),h=t.useForkedRef(w,r),E=n.useCallback((function(){l&&l.current&&l.current.focus()}),[l]);return n.useEffect((function(){return w.current?(n=[],o=[],r=t.getOwnerDocument(e=w.current)||document,e?(Array.prototype.forEach.call(r.querySelectorAll("body > *"),(function(r){var t,i;if(r!==(null===(t=e.parentNode)||void 0===t?void 0:null===(i=t.parentNode)||void 0===i?void 0:i.parentNode)){var a=r.getAttribute("aria-hidden");null!==a&&"false"!==a||(n.push(a),o.push(r),r.setAttribute("aria-hidden","true"))}})),function(){o.forEach((function(e,o){var r=n[o];null===r?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r)}))}):t.noop):void 0;var e,n,o,r}),[]),o.createElement(i,{autoFocus:!0,returnFocus:!0,onActivation:E},o.createElement(a.RemoveScroll,{allowPinchZoom:c},o.createElement("div",Object.assign({},m,{ref:h,"data-reach-dialog-overlay":"",onClick:t.wrapEvent(s,(function(e){g.current===e.target&&(e.stopPropagation(),d(e))})),onKeyDown:t.wrapEvent(v,(function(e){"Escape"===e.key&&(e.stopPropagation(),d(e))})),onMouseDown:t.wrapEvent(p,(function(e){g.current=e.target}))}))))})),s=n.forwardRef((function(e,n){var r=e.onClick,i=u(e,["onClick","onKeyDown"]);return o.createElement("div",Object.assign({"aria-modal":"true",role:"dialog",tabIndex:-1},i,{ref:n,"data-reach-dialog-content":"",onClick:t.wrapEvent(r,(function(e){e.stopPropagation()}))}))})),f=n.forwardRef((function(e,n){var r=e.isOpen,i=e.onDismiss,a=void 0===i?t.noop:i,l=e.initialFocusRef,f=u(e,["isOpen","onDismiss","initialFocusRef"]);return o.createElement(c,{initialFocusRef:l,isOpen:r,onDismiss:a},o.createElement(s,Object.assign({ref:n},f)))}));exports.Dialog=f,exports.DialogContent=s,exports.DialogOverlay=c,exports.default=f; | ||
//# sourceMappingURL=dialog.cjs.production.min.js.map |
import React, { forwardRef, useEffect, useRef, useCallback } from 'react'; | ||
import Portal from '@reach/portal'; | ||
import { checkStyles, useForkedRef, wrapEvent, noop } from '@reach/utils'; | ||
import { checkStyles, useForkedRef, wrapEvent, getOwnerDocument, noop, isString } from '@reach/utils'; | ||
import FocusLock from 'react-focus-lock'; | ||
@@ -246,2 +246,3 @@ import { RemoveScroll } from 'react-remove-scroll'; | ||
var rootNodes = []; | ||
var ownerDocument = getOwnerDocument(dialogNode) || document; | ||
@@ -256,3 +257,3 @@ if (!dialogNode) { | ||
Array.prototype.forEach.call(document.querySelectorAll("body > *"), function (node) { | ||
Array.prototype.forEach.call(ownerDocument.querySelectorAll("body > *"), function (node) { | ||
var _dialogNode$parentNod, _dialogNode$parentNod2; | ||
@@ -299,3 +300,3 @@ | ||
return new Error("You provided both `aria-label` and `aria-labelledby` props to a <" + compName + ">. If the a label for this component is visible on the screen, that label's component should be given a unique ID prop, and that ID should be passed as the `aria-labelledby` prop into <" + compName + ">. If the label cannot be determined programmatically from the content of the element, an alternative label should be provided as the `aria-label` prop, which will be used as an `aria-label` on the HTML tag." + details); | ||
} else if (props[propName] != null && typeof props[propName] !== "string") { | ||
} else if (props[propName] != null && !isString(props[propName])) { | ||
return new Error("Invalid prop `" + propName + "` supplied to `" + compName + "`. Expected `string`, received `" + (Array.isArray(propFullName) ? "array" : typeof propFullName) + "`."); | ||
@@ -302,0 +303,0 @@ } |
{ | ||
"name": "@reach/dialog", | ||
"version": "0.8.0", | ||
"version": "0.8.2", | ||
"description": "Accessible React Modal Dialog.", | ||
@@ -13,3 +13,3 @@ "author": "React Training <hello@reacttraining.com>", | ||
"scripts": { | ||
"build": "yarn clean && cross-env NODE_ENV=production tsdx build --format=cjs,esm --tsconfig tsconfig.build.json", | ||
"build": "yarn clean && yarn compile", | ||
"clean": "rm -rf ./dist", | ||
@@ -19,7 +19,8 @@ "compile": "cross-env NODE_ENV=production tsdx build --format=cjs,esm --tsconfig tsconfig.build.json" | ||
"dependencies": { | ||
"@reach/portal": "^0.8.0", | ||
"@reach/utils": "^0.8.0", | ||
"@reach/portal": "^0.8.2", | ||
"@reach/utils": "^0.8.2", | ||
"prop-types": "^15.7.2", | ||
"react-focus-lock": "^2.2.1", | ||
"react-remove-scroll": "^2.2.0" | ||
"react-remove-scroll": "^2.2.0", | ||
"tslib": "^1.10.0" | ||
}, | ||
@@ -38,3 +39,3 @@ "peerDependencies": { | ||
], | ||
"gitHead": "7702c46373c7f11adc21184e7def9977203e9326" | ||
"gitHead": "ed24a5bb43a87adc36179283ca1de2c5af4ea26e" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80470
741
8
12
+ Addedtslib@^1.10.0
Updated@reach/portal@^0.8.2
Updated@reach/utils@^0.8.2