@interop-ui/react-dialog
Advanced tools
Comparing version 0.0.1-12 to 0.0.1-13
@@ -66,4 +66,3 @@ import * as React from "react"; | ||
}; | ||
export const styles: import("@interop-ui/react-utils").PrimitiveStyles<"root" | "trigger" | "overlay" | "content" | "close">; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
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; | ||
var e,r,t=require("aria-hidden").hideOthers,n=require("react-remove-scroll").RemoveScroll,o=require("@interop-ui/react-focus-guards").useFocusGuards,a=require("@interop-ui/react-portal").Portal,u=require("@interop-ui/react-focus-scope").FocusScope,i=require("@interop-ui/react-dismissable-layer").DismissableLayer,l=require("@interop-ui/react-debug-context").useDebugContext,c=require("@interop-ui/utils"),s=c.getPartDataAttrObj,f=c.makeId,p=require("@interop-ui/react-utils"),d=p.forwardRef,g=p.createContext,y=p.useComposedRefs,O=p.composeEventHandlers,b=p.useControlledState,v=p.useId,m=p.composeRefs,C=(e={},r=require("react"),Object.keys(r).forEach((function(t){"default"!==t&&"__esModule"!==t&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return r[t]}})})),e);function D(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function h(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?D(Object(t),!0).forEach((function(r){j(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function j(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function P(){return(P=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function w(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function E(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(t.push(u.value),!r||t.length!==r);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return t}(e,r)||function(e,r){if(!e)return;if("string"==typeof e)return F(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return F(e,r)}(e,r)||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,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var S=E(g("DialogContext","Dialog"),2),k=S[0],A=S[1],I=function(e){var r=e.children,t=e.id,n=e.isOpen,o=e.defaultIsOpen,a=e.onIsOpenChange,u=C.useRef(null),i=f("dialog",v()),l=t||i,c=E(b({prop:n,defaultProp:o,onChange:a}),2),s=c[0],p=void 0!==s&&s,d=c[1],g=C.useMemo((function(){return{triggerRef:u,id:l,isOpen:p,setIsOpen:d}}),[l,p,d]);return C.createElement(k.Provider,{value:g},r)};exports.Dialog=I;var q=d((function(e,r){var t=e.as,n=void 0===t?"button":t,o=e.onClick,a=w(e,["as","onClick"]),u=A("Dialog.Trigger"),i=y(r,u.triggerRef);return C.createElement(n,P({},s("Dialog.Trigger"),{ref:i,type:"button","aria-haspopup":"dialog","aria-expanded":u.isOpen,"aria-controls":u.id,onClick:O(o,(function(){return u.setIsOpen(!0)}))},a))})),x=d((function(e,r){return A("Dialog.Overlay").isOpen?C.createElement(T,P({ref:r},e)):null})),T=d((function(e,r){var t=e.as,n=void 0===t?"div":t,o=w(e,["as"]);return C.createElement(a,null,C.createElement(n,P({},s("Dialog.Overlay"),{ref:r},o)))})),R=d((function(e,r){return A("Dialog.Content").isOpen?C.createElement(M,P({ref:r},e)):null})),M=d((function(e,r){var c=e.as,f=void 0===c?"div":c,p=e.onOpenAutoFocus,d=e.onCloseAutoFocus,g=e.onEscapeKeyDown,y=e.onPointerDownOutside,b=w(e,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside"]),v=A("Dialog.Content"),D=l().disableLock?C.Fragment:n;o();var j=C.useRef(null);return C.useEffect((function(){var e=j.current;if(e)return t(e)}),[]),C.createElement(a,null,C.createElement(D,null,C.createElement(u,{trapped:!0,onMountAutoFocus:p,onUnmountAutoFocus:d},(function(e){return C.createElement(i,{disableOutsidePointerEvents:!0,onEscapeKeyDown:g,onPointerDownOutside:y,onDismiss:function(){return v.setIsOpen(!1)}},(function(t){return C.createElement(f,P({},s("Dialog.Content"),{role:"dialog","aria-modal":!0},b,{ref:m(r,j,e.ref,t.ref),id:v.id,style:h(h({},t.style),b.style),onBlurCapture:O(b.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:O(b.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:O(b.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:O(b.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1})}))}))}))))})),N=d((function(e,r){var t=e.as,n=void 0===t?"button":t,o=e.onClick,a=w(e,["as","onClick"]),u=A("Dialog.Close");return C.createElement(n,P({},s("Dialog.Close"),{ref:r,type:"button"},a,{onClick:O(o,(function(){return u.setIsOpen(!1)}))}))}));I.Trigger=q,I.Overlay=x,I.Content=R,I.Close=N,I.displayName="Dialog",I.Trigger.displayName="Dialog.Trigger",I.Overlay.displayName="Dialog.Overlay",I.Content.displayName="Dialog.Content",I.Close.displayName="Dialog.Close"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
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}; | ||
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 a}from"@interop-ui/react-dismissable-layer";import{useDebugContext as i}from"@interop-ui/react-debug-context";import{getPartDataAttrObj as l,makeId as u}from"@interop-ui/utils";import{forwardRef 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 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 y(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){b(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 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={},a=Object.keys(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)o=a[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}const[P,h]=s("DialogContext","Dialog");export const Dialog=function(e){const{children:t,id:o,isOpen:r,defaultIsOpen:n,onIsOpenChange:a}=e,i=D.useRef(null),l=u("dialog",m()),c=o||l,[s=!1,p]=g({prop:r,defaultProp:n,onChange:a}),f=D.useMemo((()=>({triggerRef:i,id:c,isOpen:s,setIsOpen:p})),[c,s,p]);return D.createElement(P.Provider,{value:f},t)};const E="button",w=c(((e,t)=>{const{as:o=E,onClick:r}=e,n=v(e,["as","onClick"]),a=h("Dialog.Trigger"),i=p(t,a.triggerRef);return D.createElement(o,C({},l("Dialog.Trigger"),{ref:i,type:"button","aria-haspopup":"dialog","aria-expanded":a.isOpen,"aria-controls":a.id,onClick:f(r,(()=>a.setIsOpen(!0)))},n))})),j="div",F=c((function(e,t){return h("Dialog.Overlay").isOpen?D.createElement(k,C({ref:t},e)):null})),k=c((function(e,t){const{as:o=j}=e,n=v(e,["as"]);return D.createElement(r,null,D.createElement(o,C({},l("Dialog.Overlay"),{ref:t},n)))})),T="div",I=c((function(e,t){return h("Dialog.Content").isOpen?D.createElement(S,C({ref:t},e)):null})),S=c((function(u,c){const{as:s=T,onOpenAutoFocus:p,onCloseAutoFocus:g,onEscapeKeyDown:m,onPointerDownOutside:d}=u,b=v(u,["as","onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside"]),P=h("Dialog.Content"),E=i().disableLock?D.Fragment:t;o();const w=D.useRef(null);return D.useEffect((()=>{const t=w.current;if(t)return e(t)}),[]),D.createElement(r,null,D.createElement(E,null,D.createElement(n,{trapped:!0,onMountAutoFocus:p,onUnmountAutoFocus:g},(e=>D.createElement(a,{disableOutsidePointerEvents:!0,onEscapeKeyDown:m,onPointerDownOutside:d,onDismiss:()=>P.setIsOpen(!1)},(t=>D.createElement(s,C({},l("Dialog.Content"),{role:"dialog","aria-modal":!0},b,{ref:O(c,w,e.ref,t.ref),id:P.id,style:y(y({},t.style),b.style),onBlurCapture:f(b.onBlurCapture,t.onBlurCapture,{checkForDefaultPrevented:!1}),onFocusCapture:f(b.onFocusCapture,t.onFocusCapture,{checkForDefaultPrevented:!1}),onMouseDownCapture:f(b.onMouseDownCapture,t.onMouseDownCapture,{checkForDefaultPrevented:!1}),onTouchStartCapture:f(b.onTouchStartCapture,t.onTouchStartCapture,{checkForDefaultPrevented:!1})}))))))))})),x="button",A=c(((e,t)=>{const{as:o=x,onClick:r}=e,n=v(e,["as","onClick"]),a=h("Dialog.Close");return D.createElement(o,C({},l("Dialog.Close"),{ref:t,type:"button"},n,{onClick:f(r,(()=>a.setIsOpen(!1)))}))}));Dialog.Trigger=w,Dialog.Overlay=F,Dialog.Content=I,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"; | ||
//# sourceMappingURL=index.module.js.map |
{ | ||
"name": "@interop-ui/react-dialog", | ||
"version": "0.0.1-12", | ||
"version": "0.0.1-13", | ||
"license": "MIT", | ||
@@ -14,4 +14,3 @@ "source": "src/index.ts", | ||
"scripts": { | ||
"build": "parcel build src/index.ts --no-cache && yarn build:styles", | ||
"build:styles": "node ../../../scripts/build-styles dialog", | ||
"build": "parcel build src/index.ts --no-cache", | ||
"clean": "rm -rf dist", | ||
@@ -22,9 +21,9 @@ "version": "yarn version", | ||
"dependencies": { | ||
"@interop-ui/react-debug-context": "0.0.1-11", | ||
"@interop-ui/react-dismissable-layer": "0.0.1-2", | ||
"@interop-ui/react-focus-guards": "0.0.1-0", | ||
"@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", | ||
"@interop-ui/react-debug-context": "0.0.1-12", | ||
"@interop-ui/react-dismissable-layer": "0.0.1-3", | ||
"@interop-ui/react-focus-guards": "0.0.1-1", | ||
"@interop-ui/react-focus-scope": "0.0.1-3", | ||
"@interop-ui/react-portal": "0.0.1-12", | ||
"@interop-ui/react-utils": "0.0.1-12", | ||
"@interop-ui/utils": "0.0.1-4", | ||
"aria-hidden": "^1.1.1", | ||
@@ -31,0 +30,0 @@ "react-remove-scroll": "^2.4.0" |
@@ -15,12 +15,12 @@ # `react-dialog` | ||
import * as React from 'react'; | ||
import { Dialog, styles } from '@interop-ui/react-dialog'; | ||
import { Dialog } from '@interop-ui/react-dialog'; | ||
function MyComponent(props) { | ||
function MyComponent() { | ||
return ( | ||
<Dialog> | ||
<Dialog.Trigger style={styles.trigger}>Open the dialog</Dialog.Trigger> | ||
<Dialog.Overlay style={styles.overlay} /> | ||
<Dialog.Content style={styles.content}> | ||
<Dialog.Trigger>Open the dialog</Dialog.Trigger> | ||
<Dialog.Overlay /> | ||
<Dialog.Content> | ||
<p>Some really cool dialog content!</p> | ||
<Dialog.Close style={styles.close}>Close the dialog</Dialog.Close> | ||
<Dialog.Close>Close the dialog</Dialog.Close> | ||
</Dialog.Content> | ||
@@ -27,0 +27,0 @@ </Dialog> |
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
64186
8
159
+ Added@interop-ui/react-debug-context@0.0.1-12(transitive)
+ Added@interop-ui/react-dismissable-layer@0.0.1-3(transitive)
+ Added@interop-ui/react-focus-guards@0.0.1-1(transitive)
+ Added@interop-ui/react-focus-scope@0.0.1-3(transitive)
+ Added@interop-ui/react-portal@0.0.1-12(transitive)
+ Added@interop-ui/react-utils@0.0.1-12(transitive)
+ Added@interop-ui/utils@0.0.1-4(transitive)
- Removed@interop-ui/react-debug-context@0.0.1-11(transitive)
- Removed@interop-ui/react-dismissable-layer@0.0.1-2(transitive)
- Removed@interop-ui/react-focus-guards@0.0.1-0(transitive)
- Removed@interop-ui/react-focus-scope@0.0.1-2(transitive)
- Removed@interop-ui/react-portal@0.0.1-11(transitive)
- Removed@interop-ui/react-utils@0.0.1-11(transitive)
- Removed@interop-ui/utils@0.0.1-3(transitive)
- Removedlodash.camelcase@4.3.0(transitive)
- Removedlodash.kebabcase@4.1.1(transitive)
Updated@interop-ui/utils@0.0.1-4