react-clear-modal
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
import { HTMLAttributes, ReactNode } from 'react'; | ||
import React, { HTMLAttributes, ReactNode } from 'react'; | ||
export declare type ReactClearModalProps = { | ||
@@ -15,3 +15,3 @@ isOpen: boolean; | ||
declare function ReactClearModal({ isOpen, onRequestClose, closeTimeout, preRender, contentProps, children, disableFocusOnContent, disableCloseOnEsc, disableCloseOnBgClick, disableBodyScrollOnOpen, ...wrapperProps }: ReactClearModalProps): JSX.Element | null; | ||
declare const _default: import("react").MemoExoticComponent<typeof ReactClearModal>; | ||
declare const _default: React.MemoExoticComponent<typeof ReactClearModal>; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
import{memo as e,useRef as t,useCallback as n,useEffect as r}from"react";function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var s=["isOpen","onRequestClose","closeTimeout","preRender","contentProps","children","disableFocusOnContent","disableCloseOnEsc","disableCloseOnBgClick","disableBodyScrollOnOpen"];function a(e){var o=e.isOpen,c=e.onRequestClose,a=e.closeTimeout,f=e.preRender,d=void 0!==f&&f,b=e.contentProps,p=void 0===b?{}:b,O=e.children,y=e.disableFocusOnContent,v=e.disableCloseOnEsc,g=e.disableCloseOnBgClick,m=e.disableBodyScrollOnOpen,j=u(e,s),w=t(null),C=t(null),P=n((function(e){var t;j.onClick&&j.onClick(e),!c||g||e.target===C.current||null!==(t=C.current)&&void 0!==t&&t.contains(e.target)||c()}),[j,c,g]),h=n((function(e){p.onKeyDown&&p.onKeyDown(e),!c||v||"Escape"!==e.code&&27!==e.keyCode||c()}),[p,c,v]);return r((function(){return a&&c&&(w.current=setTimeout(c,a)),function(){clearTimeout(w.current)}}),[a,c]),r((function(){var e;o&&!y&&(null===(e=C.current)||void 0===e||e.focus())}),[o,y]),r((function(){var e=document.body.style.overflow;return o&&m&&(document.body.style.overflow="hidden"),function(){document.body.style.overflow=e}}),[o,m]),o||d?React.createElement("div",i({},j,{style:l({alignItems:"center",bottom:0,display:o?"flex":"none",left:0,overflow:"auto",position:"fixed",right:0,top:0,zIndex:999},j.style),onClick:P}),React.createElement("div",i({},p,{style:l({margin:"auto",position:"relative",zIndex:1},p.style),onKeyDown:h,role:"dialog",tabIndex:-1,ref:C}),O)):null}var f=e(a);export{f as default}; | ||
import e,{memo as n,useRef as t,useCallback as r,useEffect as o}from"react";function l(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?l(Object(t),!0).forEach((function(n){c(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function c(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function u(){return u=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},u.apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)t=l[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var a=["isOpen","onRequestClose","closeTimeout","preRender","contentProps","children","disableFocusOnContent","disableCloseOnEsc","disableCloseOnBgClick","disableBodyScrollOnOpen"];function f(n){var l=n.isOpen,c=n.onRequestClose,f=n.closeTimeout,d=n.preRender,b=void 0!==d&&d,p=n.contentProps,O=void 0===p?{}:p,y=n.children,v=n.disableFocusOnContent,g=n.disableCloseOnEsc,m=n.disableCloseOnBgClick,j=n.disableBodyScrollOnOpen,w=s(n,a),C=t(null),P=t(null),h=r((function(e){var n;w.onClick&&w.onClick(e),!c||m||e.target===P.current||null!==(n=P.current)&&void 0!==n&&n.contains(e.target)||c()}),[w,c,m]),k=r((function(e){O.onKeyDown&&O.onKeyDown(e),!c||g||"Escape"!==e.code&&27!==e.keyCode||c()}),[O,c,g]);return o((function(){return f&&c&&(C.current=setTimeout(c,f)),function(){clearTimeout(C.current)}}),[f,c]),o((function(){var e;l&&!v&&(null===(e=P.current)||void 0===e||e.focus())}),[l,v]),o((function(){var e=document.body.style.overflow;return l&&j&&(document.body.style.overflow="hidden"),function(){document.body.style.overflow=e}}),[l,j]),l||b?e.createElement("div",u({},w,{style:i({alignItems:"center",bottom:0,display:l?"flex":"none",left:0,overflow:"auto",position:"fixed",right:0,top:0,zIndex:999},w.style),onClick:h}),e.createElement("div",u({},O,{style:i({margin:"auto",position:"relative",zIndex:1},O.style),onKeyDown:k,role:"dialog",tabIndex:-1,ref:P}),y)):null}var d=n(f);export{d as default}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactClearModal=t(e.React)}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r.apply(this,arguments)}function l(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},l=Object.keys(e);for(o=0;o<l.length;o++)n=l[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)n=l[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var c=["isOpen","onRequestClose","closeTimeout","preRender","contentProps","children","disableFocusOnContent","disableCloseOnEsc","disableCloseOnBgClick","disableBodyScrollOnOpen"];function i(t){var o=t.isOpen,i=t.onRequestClose,u=t.closeTimeout,s=t.preRender,a=void 0!==s&&s,f=t.contentProps,d=void 0===f?{}:f,b=t.children,p=t.disableFocusOnContent,y=t.disableCloseOnEsc,O=t.disableCloseOnBgClick,v=t.disableBodyScrollOnOpen,g=l(t,c),m=e.useRef(null),j=e.useRef(null),w=e.useCallback((function(e){var t;g.onClick&&g.onClick(e),!i||O||e.target===j.current||null!==(t=j.current)&&void 0!==t&&t.contains(e.target)||i()}),[g,i,O]),C=e.useCallback((function(e){d.onKeyDown&&d.onKeyDown(e),!i||y||"Escape"!==e.code&&27!==e.keyCode||i()}),[d,i,y]);return e.useEffect((function(){return u&&i&&(m.current=setTimeout(i,u)),function(){clearTimeout(m.current)}}),[u,i]),e.useEffect((function(){var e;o&&!p&&(null===(e=j.current)||void 0===e||e.focus())}),[o,p]),e.useEffect((function(){var e=document.body.style.overflow;return o&&v&&(document.body.style.overflow="hidden"),function(){document.body.style.overflow=e}}),[o,v]),o||a?React.createElement("div",r({},g,{style:n({alignItems:"center",bottom:0,display:o?"flex":"none",left:0,overflow:"auto",position:"fixed",right:0,top:0,zIndex:999},g.style),onClick:w}),React.createElement("div",r({},d,{style:n({margin:"auto",position:"relative",zIndex:1},d.style),onKeyDown:C,role:"dialog",tabIndex:-1,ref:j}),b)):null}return e.memo(i)})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReactClearModal=t(e.React)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i.apply(this,arguments)}function c(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},l=Object.keys(e);for(o=0;o<l.length;o++)n=l[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)n=l[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var u=["isOpen","onRequestClose","closeTimeout","preRender","contentProps","children","disableFocusOnContent","disableCloseOnEsc","disableCloseOnBgClick","disableBodyScrollOnOpen"];function s(t){var o=t.isOpen,l=t.onRequestClose,s=t.closeTimeout,f=t.preRender,a=void 0!==f&&f,d=t.contentProps,b=void 0===d?{}:d,p=t.children,y=t.disableFocusOnContent,O=t.disableCloseOnEsc,v=t.disableCloseOnBgClick,g=t.disableBodyScrollOnOpen,m=c(t,u),j=e.useRef(null),w=e.useRef(null),C=e.useCallback((function(e){var t;m.onClick&&m.onClick(e),!l||v||e.target===w.current||null!==(t=w.current)&&void 0!==t&&t.contains(e.target)||l()}),[m,l,v]),h=e.useCallback((function(e){b.onKeyDown&&b.onKeyDown(e),!l||O||"Escape"!==e.code&&27!==e.keyCode||l()}),[b,l,O]);return e.useEffect((function(){return s&&l&&(j.current=setTimeout(l,s)),function(){clearTimeout(j.current)}}),[s,l]),e.useEffect((function(){var e;o&&!y&&(null===(e=w.current)||void 0===e||e.focus())}),[o,y]),e.useEffect((function(){var e=document.body.style.overflow;return o&&g&&(document.body.style.overflow="hidden"),function(){document.body.style.overflow=e}}),[o,g]),o||a?n.default.createElement("div",i({},m,{style:r({alignItems:"center",bottom:0,display:o?"flex":"none",left:0,overflow:"auto",position:"fixed",right:0,top:0,zIndex:999},m.style),onClick:C}),n.default.createElement("div",i({},b,{style:r({margin:"auto",position:"relative",zIndex:1},b.style),onKeyDown:h,role:"dialog",tabIndex:-1,ref:w}),p)):null}return e.memo(s)})); |
{ | ||
"name": "react-clear-modal", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Simple and lightweight modal component for React.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -51,2 +51,4 @@ # react-clear-modal | ||
<div> | ||
<button type="button" title="Open" onClick={openModal}>Open</button> | ||
<ReactClearModal | ||
@@ -59,3 +61,3 @@ {/* here you can also pass any other element attributes. */} | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Id beatae quia, neque modi libero quidem ipsum architecto, incidunt molestias culpa, totam accusantium reprehenderit animi voluptas magni alias error commodi ut. | ||
<div> | ||
</div> | ||
@@ -62,0 +64,0 @@ <button type="button" title="Close" onClick={closeModal}>Close</button> |
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
13915
40
83