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-7 to 0.0.1-8

30

dist/index.d.ts
import * as React from "react";
import { LockProps } from "@interop-ui/react-lock";
import { DismissableLayerProps } from "@interop-ui/react-dismissable-layer";
import { FocusScopeProps } from "@interop-ui/react-focus-scope";
interface DialogStaticProps {

@@ -34,23 +35,22 @@ Trigger: typeof DialogTrigger;

/**
* A ref to an element to focus on inside the Dialog after it is opened.
* (default: first focusable element inside the Dialog)
* (fallback: first focusable element inside the Dialog, then the Dialog's content container)
* Event handler called when auto-focusing on open.
* Can be prevented.
*/
refToFocusOnOpen?: LockProps['refToFocusOnActivation'];
onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];
/**
* A ref to an element to focus on outside the Dialog after it is closed.
* (default: last focused element before the Dialog was opened)
* (fallback: none)
* Event handler called when auto-focusing on close.
* Can be prevented.
*/
refToFocusOnClose?: LockProps['refToFocusOnDeactivation'];
onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
/**
* Whether pressing the `Escape` key should close the Dialog
* (default: `true`)
* Event handler called when the escape key is down.
* Can be prevented.
*/
shouldCloseOnEscape?: LockProps['shouldDeactivateOnEscape'];
onEscapeKeyDown?: DismissableLayerProps['onEscapeKeyDown'];
/**
* Whether clicking outside the Dialog should close it
* (default: `true`)
* Event handler called when an interaction happened outside the `Dialog`.
* Specifically, when focus leaves the `Dialog` or a pointer event happens outside it.
* Can be prevented.
*/
shouldCloseOnOutsideClick?: LockProps['shouldDeactivateOnOutsideClick'];
onInteractOutside?: DismissableLayerProps['onInteractOutside'];
};

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

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

var e,t,r=require("@interop-ui/react-portal").Portal,n=require("react-remove-scroll").RemoveScroll,o=require("@interop-ui/react-lock").Lock,i=require("@interop-ui/react-debug-context").useDebugContext,a=require("@interop-ui/utils"),l=a.cssReset,u=a.makeId,c=require("@interop-ui/react-utils"),s=c.forwardRef,f=c.createStyleObj,p=c.createContext,d=c.useComposedRefs,O=c.composeEventHandlers,g=c.useControlledState,v=c.useId,y=(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 b(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 m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){C(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function h(){return(h=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 j(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 D(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 a,l=e[Symbol.iterator]();!(n=(a=l.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==l.return||l.return()}finally{if(o)throw i}}return r}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return E(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 E(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 E(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=D(p("DialogContext","Dialog"),2),P=k[0],w=k[1],S=function(e){var t=e.children,r=e.id,n=e.isOpen,o=e.defaultIsOpen,i=e.onIsOpenChange,a=y.useRef(null),l=u("dialog",v()),c=r||l,s=D(g({prop:n,defaultProp:o,onChange:i}),2),f=s[0],p=void 0!==f&&f,d=s[1],O=y.useMemo((function(){return{triggerRef:a,id:c,isOpen:p,setIsOpen:d}}),[c,p,d]);return y.createElement(P.Provider,{value:O},t)};exports.Dialog=S;var x=s((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=j(e,["as","onClick"]),a=w("Dialog.Trigger"),l=d(t,a.triggerRef);return y.createElement(n,h({},M("trigger"),{ref:l,type:"button"===n?"button":void 0,"aria-haspopup":"dialog","aria-expanded":a.isOpen,"aria-controls":a.id,onClick:O(o,(function(){return a.setIsOpen(!0)}))},i))})),I=s((function(e,t){return w("Dialog.Overlay").isOpen?y.createElement(T,h({ref:t},e)):null})),T=s((function(e,t){var n=e.as,o=void 0===n?"div":n,i=j(e,["as"]);return y.createElement(r,null,y.createElement(o,h({},M("overlay"),{ref:t},i)))})),R=s((function(e,t){return w("Dialog.Content").isOpen?y.createElement(q,h({ref:t},e)):null})),q=s((function(e,t){var a=e.as,l=void 0===a?"div":a,u=e.refToFocusOnOpen,c=e.refToFocusOnClose,s=e.shouldCloseOnEscape,f=void 0===s||s,p=e.shouldCloseOnOutsideClick,d=void 0===p||p,O=j(e,["as","refToFocusOnOpen","refToFocusOnClose","shouldCloseOnEscape","shouldCloseOnOutsideClick"]),g=w("Dialog.Content"),v=i().disableLock?y.Fragment:n;return y.createElement(r,null,y.createElement(v,null,y.createElement(o,{onDeactivate:function(){return g.setIsOpen(!1)},refToFocusOnActivation:u,refToFocusOnDeactivation:null!=c?c:g.triggerRef,shouldDeactivateOnEscape:f,shouldDeactivateOnOutsideClick:d,shouldPreventOutsideClick:!0},y.createElement(l,h({},M("content"),{ref:t,role:"dialog","aria-modal":!0},O,{id:g.id})))))})),A=s((function(e,t){var r=e.as,n=void 0===r?"button":r,o=e.onClick,i=j(e,["as","onClick"]),a=w("Dialog.Close");return y.createElement(n,h({},M("close"),{ref:t,type:"button"===n?"button":void 0},i,{onClick:O(o,(function(){return a.setIsOpen(!1)}))}))}));S.Trigger=x,S.Overlay=I,S.Content=R,S.Close=A,S.displayName="Dialog",S.Trigger.displayName="Dialog.Trigger",S.Overlay.displayName="Dialog.Overlay",S.Content.displayName="Dialog.Content",S.Close.displayName="Dialog.Close";var F=D(f("Dialog",{root:{},trigger:m({},l("button")),overlay:m(m({},l("div")),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:m(m({},l("div")),{},{position:"fixed",top:0,left:0}),close:m({},l("button"))}),2),N=F[0],M=F[1];exports.styles=N;
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;
//# sourceMappingURL=index.js.map

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

import{Portal as e}from"@interop-ui/react-portal";import{RemoveScroll as t}from"react-remove-scroll";import{Lock as o}from"@interop-ui/react-lock";import{useDebugContext as r}from"@interop-ui/react-debug-context";import{cssReset as n,makeId as i}from"@interop-ui/utils";import{forwardRef as l,createStyleObj as a,createContext as c,useComposedRefs as s,composeEventHandlers as u,useControlledState as p,useId as g}from"@interop-ui/react-utils";import*as f from"react";function O(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?O(Object(o),!0).forEach((function(t){m(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):O(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function m(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function y(){return(y=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 b(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[v,D]=c("DialogContext","Dialog");export const Dialog=function(e){const{children:t,id:o,isOpen:r,defaultIsOpen:n,onIsOpenChange:l}=e,a=f.useRef(null),c=i("dialog",g()),s=o||c,[u=!1,O]=p({prop:r,defaultProp:n,onChange:l}),d=f.useMemo((()=>({triggerRef:a,id:s,isOpen:u,setIsOpen:O})),[s,u,O]);return f.createElement(v.Provider,{value:d},t)};const C="button",h=l(((e,t)=>{const{as:o=C,onClick:r}=e,n=b(e,["as","onClick"]),i=D("Dialog.Trigger"),l=s(t,i.triggerRef);return f.createElement(o,y({},N("trigger"),{ref:l,type:o===C?"button":void 0,"aria-haspopup":"dialog","aria-expanded":i.isOpen,"aria-controls":i.id,onClick:u(r,(()=>i.setIsOpen(!0)))},n))})),j="div",E=l((function(e,t){return D("Dialog.Overlay").isOpen?f.createElement(P,y({ref:t},e)):null})),P=l((function(t,o){const{as:r=j}=t,n=b(t,["as"]);return f.createElement(e,null,f.createElement(r,y({},N("overlay"),{ref:o},n)))})),k="div",w=l((function(e,t){return D("Dialog.Content").isOpen?f.createElement(T,y({ref:t},e)):null})),T=l((function(n,i){const{as:l=k,refToFocusOnOpen:a,refToFocusOnClose:c,shouldCloseOnEscape:s=!0,shouldCloseOnOutsideClick:u=!0}=n,p=b(n,["as","refToFocusOnOpen","refToFocusOnClose","shouldCloseOnEscape","shouldCloseOnOutsideClick"]),g=D("Dialog.Content"),O=r().disableLock?f.Fragment:t;return f.createElement(e,null,f.createElement(O,null,f.createElement(o,{onDeactivate:()=>g.setIsOpen(!1),refToFocusOnActivation:a,refToFocusOnDeactivation:null!=c?c:g.triggerRef,shouldDeactivateOnEscape:s,shouldDeactivateOnOutsideClick:u,shouldPreventOutsideClick:!0},f.createElement(l,y({},N("content"),{ref:i,role:"dialog","aria-modal":!0},p,{id:g.id})))))})),x="button",F=l(((e,t)=>{const{as:o=x,onClick:r}=e,n=b(e,["as","onClick"]),i=D("Dialog.Close");return f.createElement(o,y({},N("close"),{ref:t,type:o===x?"button":void 0},n,{onClick:u(r,(()=>i.setIsOpen(!1)))}))}));Dialog.Trigger=h,Dialog.Overlay=E,Dialog.Content=w,Dialog.Close=F,Dialog.displayName="Dialog",Dialog.Trigger.displayName="Dialog.Trigger",Dialog.Overlay.displayName="Dialog.Overlay",Dialog.Content.displayName="Dialog.Content",Dialog.Close.displayName="Dialog.Close";const[I,N]=a("Dialog",{root:{},trigger:d({},n(C)),overlay:d(d({},n(j)),{},{position:"fixed",top:0,right:0,bottom:0,left:0,pointerEvents:"none"}),content:d(d({},n(k)),{},{position:"fixed",top:0,left:0}),close:d({},n(x))});export{I as styles};
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};
//# sourceMappingURL=index.module.js.map
{
"name": "@interop-ui/react-dialog",
"version": "0.0.1-7",
"version": "0.0.1-8",
"license": "MIT",

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

"dependencies": {
"@interop-ui/react-debug-context": "0.0.1-7",
"@interop-ui/react-lock": "0.0.1-7",
"@interop-ui/react-portal": "0.0.1-7",
"@interop-ui/react-utils": "0.0.1-7",
"@interop-ui/react-debug-context": "0.0.1-8",
"@interop-ui/react-dismissable-layer": "0.0.1-0",
"@interop-ui/react-focus-scope": "0.0.1-0",
"@interop-ui/react-portal": "0.0.1-8",
"@interop-ui/react-utils": "0.0.1-8",
"@interop-ui/utils": "0.0.1-3",
"react-remove-scroll": "^2.3.0"
"aria-hidden": "^1.1.1",
"react-remove-scroll": "^2.4.0"
},

@@ -29,0 +31,0 @@ "devDependencies": {

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