@interop-ui/react-dialog
Advanced tools
Comparing version 0.0.1-5 to 0.0.1-6
@@ -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{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}; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@interop-ui/react-dialog", | ||
"version": "0.0.1-5", | ||
"version": "0.0.1-6", | ||
"license": "MIT", | ||
@@ -21,6 +21,6 @@ "source": "src/index.ts", | ||
"dependencies": { | ||
"@interop-ui/react-debug-context": "0.0.1-5", | ||
"@interop-ui/react-lock": "0.0.1-5", | ||
"@interop-ui/react-portal": "0.0.1-5", | ||
"@interop-ui/react-utils": "0.0.1-5", | ||
"@interop-ui/react-debug-context": "0.0.1-6", | ||
"@interop-ui/react-lock": "0.0.1-6", | ||
"@interop-ui/react-portal": "0.0.1-6", | ||
"@interop-ui/react-utils": "0.0.1-6", | ||
"@interop-ui/utils": "0.0.1-3", | ||
@@ -27,0 +27,0 @@ "react-remove-scroll": "^2.3.0" |
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
61170
+ Added@interop-ui/react-debug-context@0.0.1-6(transitive)
+ Added@interop-ui/react-lock@0.0.1-6(transitive)
+ Added@interop-ui/react-portal@0.0.1-6(transitive)
+ Added@interop-ui/react-utils@0.0.1-6(transitive)
- Removed@interop-ui/react-debug-context@0.0.1-5(transitive)
- Removed@interop-ui/react-lock@0.0.1-5(transitive)
- Removed@interop-ui/react-portal@0.0.1-5(transitive)
- Removed@interop-ui/react-utils@0.0.1-5(transitive)