Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@interop-ui/react-dialog

Package Overview
Dependencies
Maintainers
4
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@interop-ui/react-dialog - npm Package Compare versions

Comparing version 0.0.1-10 to 0.0.1-11

5

dist/index.d.ts

@@ -50,7 +50,6 @@ import * as React from "react";

/**
* Event handler called when an interaction happened outside the `Dialog`.
* Specifically, when focus leaves the `Dialog` or a pointer event happens outside it.
* Event handler called when the a pointer event happens outside of the `Dialog`.
* Can be prevented.
*/
onInteractOutside?: DismissableLayerProps['onInteractOutside'];
onPointerDownOutside?: DismissableLayerProps['onPointerDownOutside'];
};

@@ -57,0 +56,0 @@ export type DialogContentProps = DialogContentDOMProps & DialogContentOwnProps;

2

dist/index.js

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

var e,t,r=require("aria-hidden").hideOthers,n=require("react-remove-scroll").RemoveScroll,o=require("@interop-ui/react-portal").Portal,i=require("@interop-ui/react-focus-scope").FocusScope,u=require("@interop-ui/react-dismissable-layer").DismissableLayer,a=require("@interop-ui/react-debug-context").useDebugContext,l=require("@interop-ui/utils"),c=l.cssReset,s=l.makeId,p=require("@interop-ui/react-utils"),f=p.forwardRef,d=p.createStyleObj,y=p.createContext,g=p.useComposedRefs,b=p.composeEventHandlers,v=p.useControlledState,O=p.useId,m=p.composeRefs,C=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function D(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){j(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(){return(E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function w(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function P(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return S(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var k=P(y("DialogContext","Dialog"),2),F=k[0],I=k[1],x=function(e){var t=e.children,r=e.id,n=e.isOpen,o=e.defaultIsOpen,i=e.onIsOpenChange,u=C.useRef(null),a=s("dialog",O()),l=r||a,c=P(v({prop:n,defaultProp:o,onChange:i}),2),p=c[0],f=void 0!==p&&p,d=c[1],y=C.useMemo((function(){return{triggerRef:u,id:l,isOpen:f,setIsOpen:d}}),[l,f,d]);return C.createElement(F.Provider,{value:y},t)};exports.Dialog=x;var A=f((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=w(e,["as","onClick"]),u=I("Dialog.Trigger"),a=g(t,u.triggerRef);return C.createElement(n,E({},L("trigger"),{ref:a,type:"button"===n?"button":void 0,"aria-haspopup":"dialog","aria-expanded":u.isOpen,"aria-controls":u.id,onClick:b(o,(function(){return u.setIsOpen(!0)}))},i))})),q=f((function(e,t){return I("Dialog.Overlay").isOpen?C.createElement(R,E({ref:t},e)):null})),R=f((function(e,t){var r=e.as,n=void 0===r?"div":r,i=w(e,["as"]);return C.createElement(o,null,C.createElement(n,E({},L("overlay"),{ref:t},i)))})),T=f((function(e,t){return I("Dialog.Content").isOpen?C.createElement(M,E({ref:t},e)):null})),M=f((function(e,t){var l=e.as,c=void 0===l?"div":l,s=e.onOpenAutoFocus,p=e.onCloseAutoFocus,f=e.onEscapeKeyDown,d=e.onInteractOutside,y=w(e,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onInteractOutside"]),g=I("Dialog.Content"),v=a().disableLock?C.Fragment:n,O=C.useRef(null);return C.useEffect((function(){var e=O.current;if(e)return r(e)}),[]),C.createElement(o,null,C.createElement(v,null,C.createElement(i,{trapped:!0,onMountAutoFocus:s,onUnmountAutoFocus:p},(function(e){return C.createElement(u,{disableOutsidePointerEvents:!0,onEscapeKeyDown:f,onInteractOutside:d,onDismiss:function(){return g.setIsOpen(!1)}},(function(r){return C.createElement(c,E({},L("content"),{role:"dialog","aria-modal":!0},y,{ref:m(t,O,e.ref,r.ref),id:g.id,style:D(D({},r.style),y.style),onBlurCapture:b(y.onBlurCapture,r.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:b(y.onFocusCapture,r.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:b(y.onMouseDownCapture,r.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:b(y.onTouchStartCapture,r.onTouchStartCapture,{checkForDefaultPrevented:!1})}))}))}))))})),N=f((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=w(e,["as","onClick"]),u=I("Dialog.Close");return C.createElement(n,E({},L("close"),{ref:t,type:"button"===n?"button":void 0},i,{onClick:b(o,(function(){return u.setIsOpen(!1)}))}))}));x.Trigger=A,x.Overlay=q,x.Content=T,x.Close=N,x.displayName="Dialog",x.Trigger.displayName="Dialog.Trigger",x.Overlay.displayName="Dialog.Overlay",x.Content.displayName="Dialog.Content",x.Close.displayName="Dialog.Close";var B=P(d("Dialog",{root:{},trigger:D({},c("button")),overlay:D(D({},c("div")),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:D(D({},c("div")),{},{position:"fixed",top:0,left:0}),close:D({},c("button"))}),2),K=B[0],L=B[1];exports.styles=K;
var e,t,r=require("aria-hidden").hideOthers,n=require("react-remove-scroll").RemoveScroll,o=require("@interop-ui/react-focus-guards").useFocusGuards,i=require("@interop-ui/react-portal").Portal,u=require("@interop-ui/react-focus-scope").FocusScope,a=require("@interop-ui/react-dismissable-layer").DismissableLayer,l=require("@interop-ui/react-debug-context").useDebugContext,c=require("@interop-ui/utils"),s=c.cssReset,p=c.makeId,f=require("@interop-ui/react-utils"),d=f.forwardRef,y=f.createStyleObj,g=f.createContext,v=f.useComposedRefs,b=f.composeEventHandlers,O=f.useControlledState,m=f.useId,C=f.composeRefs,h=(e={},t=require("react"),Object.keys(t).forEach((function(r){"default"!==r&&"__esModule"!==r&&Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})),e);function D(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function j(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?D(Object(r),!0).forEach((function(t){w(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):D(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function w(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function E(){return(E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function P(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==a.return||a.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return F(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var k=S(g("DialogContext","Dialog"),2),x=k[0],A=k[1],I=function(e){var t=e.children,r=e.id,n=e.isOpen,o=e.defaultIsOpen,i=e.onIsOpenChange,u=h.useRef(null),a=p("dialog",m()),l=r||a,c=S(O({prop:n,defaultProp:o,onChange:i}),2),s=c[0],f=void 0!==s&&s,d=c[1],y=h.useMemo((function(){return{triggerRef:u,id:l,isOpen:f,setIsOpen:d}}),[l,f,d]);return h.createElement(x.Provider,{value:y},t)};exports.Dialog=I;var q=d((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=P(e,["as","onClick"]),u=A("Dialog.Trigger"),a=v(t,u.triggerRef);return h.createElement(n,E({},U("trigger"),{ref:a,type:"button"===n?"button":void 0,"aria-haspopup":"dialog","aria-expanded":u.isOpen,"aria-controls":u.id,onClick:b(o,(function(){return u.setIsOpen(!0)}))},i))})),R=d((function(e,t){return A("Dialog.Overlay").isOpen?h.createElement(T,E({ref:t},e)):null})),T=d((function(e,t){var r=e.as,n=void 0===r?"div":r,o=P(e,["as"]);return h.createElement(i,null,h.createElement(n,E({},U("overlay"),{ref:t},o)))})),M=d((function(e,t){return A("Dialog.Content").isOpen?h.createElement(N,E({ref:t},e)):null})),N=d((function(e,t){var c=e.as,s=void 0===c?"div":c,p=e.onOpenAutoFocus,f=e.onCloseAutoFocus,d=e.onEscapeKeyDown,y=e.onPointerDownOutside,g=P(e,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside"]),v=A("Dialog.Content"),O=l().disableLock?h.Fragment:n;o();var m=h.useRef(null);return h.useEffect((function(){var e=m.current;if(e)return r(e)}),[]),h.createElement(i,null,h.createElement(O,null,h.createElement(u,{trapped:!0,onMountAutoFocus:p,onUnmountAutoFocus:f},(function(e){return h.createElement(a,{disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:y,onDismiss:function(){return v.setIsOpen(!1)}},(function(r){return h.createElement(s,E({},U("content"),{role:"dialog","aria-modal":!0},g,{ref:C(t,m,e.ref,r.ref),id:v.id,style:j(j({},r.style),g.style),onBlurCapture:b(g.onBlurCapture,r.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:b(g.onFocusCapture,r.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:b(g.onMouseDownCapture,r.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:b(g.onTouchStartCapture,r.onTouchStartCapture,{checkForDefaultPrevented:!1})}))}))}))))})),B=d((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=P(e,["as","onClick"]),u=A("Dialog.Close");return h.createElement(n,E({},U("close"),{ref:t,type:"button"===n?"button":void 0},i,{onClick:b(o,(function(){return u.setIsOpen(!1)}))}))}));I.Trigger=q,I.Overlay=R,I.Content=M,I.Close=B,I.displayName="Dialog",I.Trigger.displayName="Dialog.Trigger",I.Overlay.displayName="Dialog.Overlay",I.Content.displayName="Dialog.Content",I.Close.displayName="Dialog.Close";var K=S(y("Dialog",{root:{},trigger:j({},s("button")),overlay:j(j({},s("div")),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:j(j({},s("div")),{},{position:"fixed",top:0,left:0}),close:j({},s("button"))}),2),L=K[0],U=K[1];exports.styles=L;
//# sourceMappingURL=index.js.map

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

import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{Portal as o}from"@interop-ui/react-portal";import{FocusScope as r}from"@interop-ui/react-focus-scope";import{DismissableLayer as n}from"@interop-ui/react-dismissable-layer";import{useDebugContext as i}from"@interop-ui/react-debug-context";import{cssReset as a,makeId as l}from"@interop-ui/utils";import{forwardRef as u,createStyleObj as c,createContext as s,useComposedRefs as p,composeEventHandlers as f,useControlledState as g,useId as m,composeRefs as O}from"@interop-ui/react-utils";import*as d from"react";function y(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function D(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?y(Object(o),!0).forEach((function(t){b(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):y(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function b(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function C(){return(C=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function v(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}const[h,E]=s("DialogContext","Dialog");export const Dialog=function(e){const{children:t,id:o,isOpen:r,defaultIsOpen:n,onIsOpenChange:i}=e,a=d.useRef(null),u=l("dialog",m()),c=o||u,[s=!1,p]=g({prop:r,defaultProp:n,onChange:i}),f=d.useMemo((()=>({triggerRef:a,id:c,isOpen:s,setIsOpen:p})),[c,s,p]);return d.createElement(h.Provider,{value:f},t)};const P="button",j=u(((e,t)=>{const{as:o=P,onClick:r}=e,n=v(e,["as","onClick"]),i=E("Dialog.Trigger"),a=p(t,i.triggerRef);return d.createElement(o,C({},N("trigger"),{ref:a,type:o===P?"button":void 0,"aria-haspopup":"dialog","aria-expanded":i.isOpen,"aria-controls":i.id,onClick:f(r,(()=>i.setIsOpen(!0)))},n))})),w="div",F=u((function(e,t){return E("Dialog.Overlay").isOpen?d.createElement(k,C({ref:t},e)):null})),k=u((function(e,t){const{as:r=w}=e,n=v(e,["as"]);return d.createElement(o,null,d.createElement(r,C({},N("overlay"),{ref:t},n)))})),I="div",x=u((function(e,t){return E("Dialog.Content").isOpen?d.createElement(S,C({ref:t},e)):null})),S=u((function(a,l){const{as:u=I,onOpenAutoFocus:c,onCloseAutoFocus:s,onEscapeKeyDown:p,onInteractOutside:g}=a,m=v(a,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onInteractOutside"]),y=E("Dialog.Content"),b=i().disableLock?d.Fragment:t,h=d.useRef(null);return d.useEffect((()=>{const t=h.current;if(t)return e(t)}),[]),d.createElement(o,null,d.createElement(b,null,d.createElement(r,{trapped:!0,onMountAutoFocus:c,onUnmountAutoFocus:s},(e=>d.createElement(n,{disableOutsidePointerEvents:!0,onEscapeKeyDown:p,onInteractOutside:g,onDismiss:()=>y.setIsOpen(!1)},(t=>d.createElement(u,C({},N("content"),{role:"dialog","aria-modal":!0},m,{ref:O(l,h,e.ref,t.ref),id:y.id,style:D(D({},t.style),m.style),onBlurCapture:f(m.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:f(m.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:f(m.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:f(m.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1})}))))))))})),T="button",A=u(((e,t)=>{const{as:o=T,onClick:r}=e,n=v(e,["as","onClick"]),i=E("Dialog.Close");return d.createElement(o,C({},N("close"),{ref:t,type:o===T?"button":void 0},n,{onClick:f(r,(()=>i.setIsOpen(!1)))}))}));Dialog.Trigger=j,Dialog.Overlay=F,Dialog.Content=x,Dialog.Close=A,Dialog.displayName="Dialog",Dialog.Trigger.displayName="Dialog.Trigger",Dialog.Overlay.displayName="Dialog.Overlay",Dialog.Content.displayName="Dialog.Content",Dialog.Close.displayName="Dialog.Close";const[M,N]=c("Dialog",{root:{},trigger:D({},a(P)),overlay:D(D({},a(w)),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:D(D({},a(I)),{},{position:"fixed",top:0,left:0}),close:D({},a(T))});export{M as styles};
import{hideOthers as e}from"aria-hidden";import{RemoveScroll as t}from"react-remove-scroll";import{useFocusGuards as o}from"@interop-ui/react-focus-guards";import{Portal as r}from"@interop-ui/react-portal";import{FocusScope as n}from"@interop-ui/react-focus-scope";import{DismissableLayer as i}from"@interop-ui/react-dismissable-layer";import{useDebugContext as a}from"@interop-ui/react-debug-context";import{cssReset as l,makeId as u}from"@interop-ui/utils";import{forwardRef as c,createStyleObj as s,createContext as p,useComposedRefs as f,composeEventHandlers as g,useControlledState as m,useId as O,composeRefs as d}from"@interop-ui/react-utils";import*as y from"react";function D(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function b(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?D(Object(o),!0).forEach((function(t){C(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):D(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function C(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e}).apply(this,arguments)}function h(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}const[P,E]=p("DialogContext","Dialog");export const Dialog=function(e){const{children:t,id:o,isOpen:r,defaultIsOpen:n,onIsOpenChange:i}=e,a=y.useRef(null),l=u("dialog",O()),c=o||l,[s=!1,p]=m({prop:r,defaultProp:n,onChange:i}),f=y.useMemo((()=>({triggerRef:a,id:c,isOpen:s,setIsOpen:p})),[c,s,p]);return y.createElement(P.Provider,{value:f},t)};const w="button",j=c(((e,t)=>{const{as:o=w,onClick:r}=e,n=h(e,["as","onClick"]),i=E("Dialog.Trigger"),a=f(t,i.triggerRef);return y.createElement(o,v({},R("trigger"),{ref:a,type:o===w?"button":void 0,"aria-haspopup":"dialog","aria-expanded":i.isOpen,"aria-controls":i.id,onClick:g(r,(()=>i.setIsOpen(!0)))},n))})),F="div",k=c((function(e,t){return E("Dialog.Overlay").isOpen?y.createElement(x,v({ref:t},e)):null})),x=c((function(e,t){const{as:o=F}=e,n=h(e,["as"]);return y.createElement(r,null,y.createElement(o,v({},R("overlay"),{ref:t},n)))})),I="div",S=c((function(e,t){return E("Dialog.Content").isOpen?y.createElement(T,v({ref:t},e)):null})),T=c((function(l,u){const{as:c=I,onOpenAutoFocus:s,onCloseAutoFocus:p,onEscapeKeyDown:f,onPointerDownOutside:m}=l,O=h(l,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside"]),D=E("Dialog.Content"),C=a().disableLock?y.Fragment:t;o();const P=y.useRef(null);return y.useEffect((()=>{const t=P.current;if(t)return e(t)}),[]),y.createElement(r,null,y.createElement(C,null,y.createElement(n,{trapped:!0,onMountAutoFocus:s,onUnmountAutoFocus:p},(e=>y.createElement(i,{disableOutsidePointerEvents:!0,onEscapeKeyDown:f,onPointerDownOutside:m,onDismiss:()=>D.setIsOpen(!1)},(t=>y.createElement(c,v({},R("content"),{role:"dialog","aria-modal":!0},O,{ref:d(u,P,e.ref,t.ref),id:D.id,style:b(b({},t.style),O.style),onBlurCapture:g(O.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:g(O.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:g(O.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:g(O.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1})}))))))))})),A="button",M=c(((e,t)=>{const{as:o=A,onClick:r}=e,n=h(e,["as","onClick"]),i=E("Dialog.Close");return y.createElement(o,v({},R("close"),{ref:t,type:o===A?"button":void 0},n,{onClick:g(r,(()=>i.setIsOpen(!1)))}))}));Dialog.Trigger=j,Dialog.Overlay=k,Dialog.Content=S,Dialog.Close=M,Dialog.displayName="Dialog",Dialog.Trigger.displayName="Dialog.Trigger",Dialog.Overlay.displayName="Dialog.Overlay",Dialog.Content.displayName="Dialog.Content",Dialog.Close.displayName="Dialog.Close";const[N,R]=s("Dialog",{root:{},trigger:b({},l(w)),overlay:b(b({},l(F)),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:b(b({},l(I)),{},{position:"fixed",top:0,left:0}),close:b({},l(A))});export{N as styles};
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-dialog",
"version": "0.0.1-10",
"version": "0.0.1-11",
"license": "MIT",

@@ -21,7 +21,7 @@ "source": "src/index.ts",

"dependencies": {
"@interop-ui/react-debug-context": "0.0.1-10",
"@interop-ui/react-dismissable-layer": "0.0.1-1",
"@interop-ui/react-focus-scope": "0.0.1-1",
"@interop-ui/react-portal": "0.0.1-10",
"@interop-ui/react-utils": "0.0.1-10",
"@interop-ui/react-debug-context": "0.0.1-11",
"@interop-ui/react-dismissable-layer": "0.0.1-2",
"@interop-ui/react-focus-scope": "0.0.1-2",
"@interop-ui/react-portal": "0.0.1-11",
"@interop-ui/react-utils": "0.0.1-11",
"@interop-ui/utils": "0.0.1-3",

@@ -35,4 +35,4 @@ "aria-hidden": "^1.1.1",

"peerDependencies": {
"react": ">=16"
"react": "^16.8 || ^17.0"
}
}

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