@telegraph/modal 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @telegraph/modal
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#100](https://github.com/knocklabs/telegraph/pull/100) [`3bd1027`](https://github.com/knocklabs/telegraph/commit/3bd102788a44385cd9c5804511bd1610f4f57b6a) Thanks [@kylemcd](https://github.com/kylemcd)! - update modal button sizes to match design system correctly
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#98](https://github.com/knocklabs/telegraph/pull/98) [`1e06a4e`](https://github.com/knocklabs/telegraph/commit/1e06a4e505ec5a2d6bdebf3d6355fa9c7f8d12fa) Thanks [@kylemcd](https://github.com/kylemcd)! - updates to modal component for production use
14
+
15
+ - Updated dependencies [[`1e06a4e`](https://github.com/knocklabs/telegraph/commit/1e06a4e505ec5a2d6bdebf3d6355fa9c7f8d12fa)]:
16
+ - @telegraph/layout@0.0.9
17
+ - @telegraph/icon@0.0.9
18
+ - @telegraph/button@0.0.16
19
+
3
20
  ## 0.0.2
4
21
 
5
22
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),y=require("@radix-ui/react-dialog"),s=require("@telegraph/layout"),u=require("clsx"),c=require("framer-motion"),l=require("react");function m(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const a=m(y),x=l.forwardRef(({portal:r={enabled:!0},open:e,onOpenChange:t,className:o,...n},f)=>{const b=r.enabled?a.Portal:l.Fragment;return i.jsx(a.Root,{open:e,onOpenChange:t,children:i.jsx(c.AnimatePresence,{children:e&&i.jsxs(b,{...r,forceMount:!0,children:[i.jsx(a.Overlay,{asChild:!0,children:i.jsx(s.Box,{as:c.motion.div,onClick:()=>t==null?void 0:t(!1),initial:{backdropFilter:"blur(0px)",opacity:0},animate:{backdropFilter:"blur(4px)",opacity:1},exit:{backdropFilter:"blur(0px)",opacity:0},transition:{duration:.3,bounce:0,type:"spring"},className:"fixed inset-0 bg-alpha-black-4 z-overlay"})}),i.jsx(a.Content,{onEscapeKeyDown:()=>t==null?void 0:t(!1),onPointerDownOutside:()=>t==null?void 0:t(!1),ref:f,asChild:!0,children:i.jsx(s.Stack,{className:u("absolute z-modal top-0 left-1/2 transform -translate-x-1/2 max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1",o),direction:"column",as:c.motion.div,bg:"surface-1",rounded:"4",my:"16",initial:{scale:.8,opacity:0,y:-20},animate:{scale:1,opacity:1,y:0},exit:{scale:.8,opacity:0,y:-20},transition:{duration:.2,bounce:0,type:"spring"},border:!0,children:n.children})})]})})})}),j=l.forwardRef(({p:r="4",className:e,...t},o)=>i.jsx(s.Box,{className:u(e,"overflow-y-auto"),p:r,...t,ref:o})),d={};Object.assign(d,{Root:x,Content:j});exports.Modal=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),b=require("@radix-ui/react-dialog"),j=require("@radix-ui/react-visually-hidden"),m=require("@telegraph/button"),g=require("@telegraph/icon"),c=require("@telegraph/layout"),h=require("clsx"),l=require("framer-motion"),n=require("react");function d(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,i.get?i:{enumerable:!0,get:()=>t[e]})}}return o.default=t,Object.freeze(o)}const a=d(b),w=d(j),k=n.forwardRef(({defaultOpen:t,open:o,onOpenChange:e,a11yTitle:i,a11yDescription:u,className:x,children:p,...s},y)=>r.jsxs(a.Root,{open:o,onOpenChange:e,defaultOpen:t,children:[r.jsxs(w.Root,{children:[r.jsx(a.Title,{children:i}),u&&r.jsx(a.Description,{children:u})]}),r.jsx(l.AnimatePresence,{children:o&&r.jsxs(r.Fragment,{children:[r.jsx(a.Overlay,{asChild:!0,children:r.jsx(c.Box,{as:l.motion.div,onClick:()=>e==null?void 0:e(!1),initial:{backdropFilter:"blur(0px)",opacity:0},animate:{backdropFilter:"blur(4px)",opacity:1},exit:{backdropFilter:"blur(0px)",opacity:0},transition:{duration:.3,bounce:0,type:"spring"},className:"fixed inset-0 bg-alpha-black-4 z-overlay"})}),r.jsx(c.Stack,{className:h("absolute z-modal top-0 left-1/2 -translate-x-1/2","max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1",x),direction:"column",as:l.motion.div,my:"16",initial:{scale:.8,opacity:0,y:-20,x:"-50%"},animate:{scale:1,opacity:1,y:0,x:"-50%"},exit:{scale:.8,opacity:0,y:-20,x:"-50%"},transition:{duration:.2,bounce:0,type:"spring"},maxW:s.maxW??"140",w:s.w??"full",bg:"surface-1",border:!0,rounded:"4",...s,ref:y,children:p})]})})]})),R=n.forwardRef(({children:t,...o},e)=>r.jsx(a.Content,{ref:e,...o,asChild:!0,children:r.jsx(c.Stack,{direction:"column",children:t})})),q=n.forwardRef(({size:t="1",variant:o="ghost",...e},i)=>r.jsx(a.Close,{asChild:!0,children:r.jsx(m.Button,{icon:{icon:g.Lucide.X,alt:"Close Modal"},variant:o,size:t,...e,ref:i})})),S=n.forwardRef(({children:t,...o},e)=>r.jsx(c.Stack,{direction:"column",px:"6",py:"4",...o,ref:e,children:t})),v=n.forwardRef(({children:t,...o},e)=>r.jsx(c.Stack,{direction:"row",justify:"space-between",align:"center",px:"6",py:"4",borderBottom:!0,...o,ref:e,children:t})),M=n.forwardRef(({children:t,...o},e)=>r.jsx(c.Stack,{direction:"row",align:"center",justify:"end",gap:"2",px:"6",py:"4",borderTop:!0,...o,ref:e,children:t})),f={};Object.assign(f,{Root:k,Content:R,Close:q,Body:S,Header:v,Footer:M});exports.Modal=f;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["import * as Dialog from \"@radix-ui/react-dialog\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport clsx from \"clsx\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof Stack> & {\n portal?: {\n enabled?: boolean;\n container?: HTMLElement;\n };\n };\n\ntype RootRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n { portal = { enabled: true }, open, onOpenChange, className, ...props },\n forwardedRef,\n ) => {\n const Portal = portal.enabled ? Dialog.Portal : React.Fragment;\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <AnimatePresence>\n {open && (\n <Portal {...portal} forceMount>\n <Dialog.Overlay asChild>\n <Box\n as={motion.div}\n onClick={() => onOpenChange?.(false)}\n initial={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n animate={{ backdropFilter: \"blur(4px)\", opacity: 1 }}\n exit={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n className=\"fixed inset-0 bg-alpha-black-4 z-overlay\"\n />\n </Dialog.Overlay>\n <Dialog.Content\n onEscapeKeyDown={() => onOpenChange?.(false)}\n onPointerDownOutside={() => onOpenChange?.(false)}\n ref={forwardedRef}\n asChild\n >\n <Stack\n className={clsx(\n \"absolute z-modal top-0 left-1/2 transform -translate-x-1/2 max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1\",\n className,\n )}\n direction=\"column\"\n as={motion.div}\n bg=\"surface-1\"\n rounded=\"4\"\n my=\"16\"\n initial={{ scale: 0.8, opacity: 0, y: -20 }}\n animate={{ scale: 1, opacity: 1, y: 0 }}\n exit={{ scale: 0.8, opacity: 0, y: -20 }}\n transition={{ duration: 0.2, bounce: 0, type: \"spring\" }}\n border\n >\n {props.children}\n </Stack>\n </Dialog.Content>\n </Portal>\n )}\n </AnimatePresence>\n </Dialog.Root>\n );\n },\n);\n\ntype ContentProps = React.ComponentProps<typeof Box>;\ntype ContentRef = React.ElementRef<typeof Box>;\n\nconst Content: React.FC<typeof Box> = React.forwardRef<\n ContentRef,\n ContentProps\n>(({ p = \"4\", className, ...props }, forwardedRef) => {\n return (\n <Box\n className={clsx(className, \"overflow-y-auto\")}\n p={p}\n {...props}\n ref={forwardedRef}\n />\n );\n});\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n});\n\nexport { Modal };\n"],"names":["Root","React","portal","open","onOpenChange","className","props","forwardedRef","Portal","Dialog","jsx","AnimatePresence","jsxs","Box","motion","Stack","clsx","Content","p","Modal"],"mappings":"khBAmBMA,EAAOC,EAAM,WACjB,CACE,CAAE,OAAAC,EAAS,CAAE,QAAS,EAAQ,EAAA,KAAAC,EAAM,aAAAC,EAAc,UAAAC,EAAW,GAAGC,CAAA,EAChEC,IACG,CACH,MAAMC,EAASN,EAAO,QAAUO,EAAO,OAASR,EAAM,SACtD,OACGS,EAAA,IAAAD,EAAO,KAAP,CAAY,KAAAN,EAAY,aAAAC,EACvB,SAAAM,EAAAA,IAACC,EACE,gBAAA,CAAA,SAAAR,GACES,EAAA,KAAAJ,EAAA,CAAQ,GAAGN,EAAQ,WAAU,GAC5B,SAAA,CAAAQ,EAAA,IAACD,EAAO,QAAP,CAAe,QAAO,GACrB,SAAAC,EAAA,IAACG,EAAA,IAAA,CACC,GAAIC,EAAO,OAAA,IACX,QAAS,IAAMV,GAAA,YAAAA,EAAe,IAC9B,QAAS,CAAE,eAAgB,YAAa,QAAS,CAAE,EACnD,QAAS,CAAE,eAAgB,YAAa,QAAS,CAAE,EACnD,KAAM,CAAE,eAAgB,YAAa,QAAS,CAAE,EAChD,WAAY,CAAE,SAAU,GAAK,OAAQ,EAAG,KAAM,QAAS,EACvD,UAAU,0CAAA,CAAA,EAEd,EACAM,EAAA,IAACD,EAAO,QAAP,CACC,gBAAiB,IAAML,GAAA,YAAAA,EAAe,IACtC,qBAAsB,IAAMA,GAAA,YAAAA,EAAe,IAC3C,IAAKG,EACL,QAAO,GAEP,SAAAG,EAAA,IAACK,EAAA,MAAA,CACC,UAAWC,EACT,iHACAX,CACF,EACA,UAAU,SACV,GAAIS,EAAO,OAAA,IACX,GAAG,YACH,QAAQ,IACR,GAAG,KACH,QAAS,CAAE,MAAO,GAAK,QAAS,EAAG,EAAG,GAAI,EAC1C,QAAS,CAAE,MAAO,EAAG,QAAS,EAAG,EAAG,CAAE,EACtC,KAAM,CAAE,MAAO,GAAK,QAAS,EAAG,EAAG,GAAI,EACvC,WAAY,CAAE,SAAU,GAAK,OAAQ,EAAG,KAAM,QAAS,EACvD,OAAM,GAEL,SAAMR,EAAA,QAAA,CACT,CAAA,CACF,CAAA,EACF,EAEJ,CACF,CAAA,CAEJ,CACF,EAKMW,EAAgChB,EAAM,WAG1C,CAAC,CAAE,EAAAiB,EAAI,IAAK,UAAAb,EAAW,GAAGC,CAAM,EAAGC,IAEjCG,EAAA,IAACG,EAAA,IAAA,CACC,UAAWG,EAAKX,EAAW,iBAAiB,EAC5C,EAAAa,EACC,GAAGZ,EACJ,IAAKC,CAAA,CAAA,CAGV,EAEKY,EAAQ,CAAC,EAKf,OAAO,OAAOA,EAAO,CACnB,KAAAnB,EACA,QAAAiB,CACF,CAAC"}
1
+ {"version":3,"file":"index.js","sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["import * as Dialog from \"@radix-ui/react-dialog\";\nimport * as VisuallyHidden from \"@radix-ui/react-visually-hidden\";\nimport { Button } from \"@telegraph/button\";\nimport { Lucide } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport clsx from \"clsx\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof Stack> & {\n a11yTitle: string;\n a11yDescription?: string;\n };\n\ntype RootRef = HTMLDivElement;\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n {\n defaultOpen,\n open,\n onOpenChange,\n a11yTitle,\n a11yDescription,\n className,\n children,\n ...props\n },\n forwardedRef,\n ) => {\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={defaultOpen}\n >\n <VisuallyHidden.Root>\n <Dialog.Title>{a11yTitle}</Dialog.Title>\n {a11yDescription && (\n <Dialog.Description>{a11yDescription}</Dialog.Description>\n )}\n </VisuallyHidden.Root>\n <AnimatePresence>\n {open && (\n <>\n <Dialog.Overlay asChild>\n <Box\n as={motion.div}\n onClick={() => onOpenChange?.(false)}\n initial={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n animate={{ backdropFilter: \"blur(4px)\", opacity: 1 }}\n exit={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n className=\"fixed inset-0 bg-alpha-black-4 z-overlay\"\n />\n </Dialog.Overlay>\n <Stack\n className={clsx(\n \"absolute z-modal top-0 left-1/2 -translate-x-1/2\",\n \"max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1\",\n className,\n )}\n direction=\"column\"\n as={motion.div}\n my=\"16\"\n initial={{ scale: 0.8, opacity: 0, y: -20, x: \"-50%\" }}\n animate={{ scale: 1, opacity: 1, y: 0, x: \"-50%\" }}\n exit={{ scale: 0.8, opacity: 0, y: -20, x: \"-50%\" }}\n transition={{ duration: 0.2, bounce: 0, type: \"spring\" }}\n maxW={props.maxW ?? \"140\"}\n w={props.w ?? \"full\"}\n bg=\"surface-1\"\n border\n rounded=\"4\"\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n </>\n )}\n </AnimatePresence>\n </Dialog.Root>\n );\n },\n);\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content>;\ntype ContentRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Dialog.Content ref={forwardedRef} {...props} asChild>\n <Stack direction=\"column\">{children}</Stack>\n </Dialog.Content>\n );\n },\n);\n\ntype CloseProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Close>,\n \"color\"\n> &\n React.ComponentPropsWithoutRef<typeof Button>;\ntype CloseRef = React.ElementRef<typeof Button>;\n\nconst Close = React.forwardRef<CloseRef, CloseProps>(\n ({ size = \"1\", variant = \"ghost\", ...props }, forwardedRef) => {\n return (\n <Dialog.Close asChild>\n <Button\n icon={{ icon: Lucide.X, alt: \"Close Modal\" }}\n variant={variant}\n size={size}\n {...props}\n ref={forwardedRef}\n />\n </Dialog.Close>\n );\n },\n);\n\ntype BodyProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype BodyRef = React.ElementRef<typeof Stack>;\n\nconst Body: React.FC<BodyProps> = React.forwardRef<BodyRef, BodyProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack direction=\"column\" px=\"6\" py=\"4\" {...props} ref={forwardedRef}>\n {children}\n </Stack>\n );\n },\n);\n\ntype HeaderProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype HeaderRef = React.ElementRef<typeof Stack>;\n\nconst Header: React.FC<HeaderProps> = React.forwardRef<HeaderRef, HeaderProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack\n direction=\"row\"\n justify=\"space-between\"\n align=\"center\"\n px=\"6\"\n py=\"4\"\n borderBottom\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n );\n },\n);\n\ntype FooterProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype FooterRef = React.ElementRef<typeof Stack>;\n\nconst Footer: React.FC<FooterProps> = React.forwardRef<FooterRef, FooterProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack\n direction=\"row\"\n align=\"center\"\n justify=\"end\"\n gap=\"2\"\n px=\"6\"\n py=\"4\"\n borderTop\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n );\n },\n);\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n Close: typeof Close;\n Body: typeof Body;\n Header: typeof Header;\n Footer: typeof Footer;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n Close,\n Body,\n Header,\n Footer,\n});\n\nexport { Modal };\n"],"names":["Root","React","defaultOpen","open","onOpenChange","a11yTitle","a11yDescription","className","children","props","forwardedRef","jsxs","Dialog","VisuallyHidden","jsx","AnimatePresence","Fragment","Box","motion","Stack","clsx","Content","Close","size","variant","Button","Lucide","Body","Header","Footer","Modal"],"mappings":"koBAoBMA,EAAOC,EAAM,WACjB,CACE,CACE,YAAAC,EACA,KAAAC,EACA,aAAAC,EACA,UAAAC,EACA,gBAAAC,EACA,UAAAC,EACA,SAAAC,EACA,GAAGC,GAELC,IAGEC,EAAA,KAACC,EAAO,KAAP,CACC,KAAAT,EACA,aAAAC,EACA,YAAAF,EAEA,SAAA,CAACS,EAAAA,KAAAE,EAAe,KAAf,CACC,SAAA,CAACC,EAAAA,IAAAF,EAAO,MAAP,CAAc,SAAUP,CAAA,CAAA,EACxBC,GACCQ,EAAA,IAACF,EAAO,YAAP,CAAoB,SAAgBN,EAAA,CAAA,EAEzC,EACAQ,EAAA,IAACC,EACE,gBAAA,CAAA,SAAAZ,GAEGQ,OAAAK,EAAAA,SAAA,CAAA,SAAA,CAAAF,EAAA,IAACF,EAAO,QAAP,CAAe,QAAO,GACrB,SAAAE,EAAA,IAACG,EAAA,IAAA,CACC,GAAIC,EAAO,OAAA,IACX,QAAS,IAAMd,GAAA,YAAAA,EAAe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,IAAK,aAAc,EAC3C,QAAAF,EACA,KAAAD,EACC,GAAGd,EACJ,IAAKC,CAAA,CAET,CAAA,CAAA,CAGN,EAKMiB,EAA4B1B,EAAM,WACtC,CAAC,CAAE,SAAAO,EAAU,GAAGC,CAAA,EAASC,IAEpBI,EAAAA,IAAAK,EAAAA,MAAA,CAAM,UAAU,SAAS,GAAG,IAAI,GAAG,IAAK,GAAGV,EAAO,IAAKC,EACrD,SAAAF,CACH,CAAA,CAGN,EAKMoB,EAAgC3B,EAAM,WAC1C,CAAC,CAAE,SAAAO,EAAU,GAAGC,CAAA,EAASC,IAErBI,EAAA,IAACK,EAAA,MAAA,CACC,UAAU,MACV,QAAQ,gBACR,MAAM,SACN,GAAG,IACH,GAAG,IACH,aAAY,GACX,GAAGV,EACJ,IAAKC,EAEJ,SAAAF,CAAA,CAAA,CAIT,EAKMqB,EAAgC5B,EAAM,WAC1C,CAAC,CAAE,SAAAO,EAAU,GAAGC,CAAA,EAASC,IAErBI,EAAA,IAACK,EAAA,MAAA,CACC,UAAU,MACV,MAAM,SACN,QAAQ,MACR,IAAI,IACJ,GAAG,IACH,GAAG,IACH,UAAS,GACR,GAAGV,EACJ,IAAKC,EAEJ,SAAAF,CAAA,CAAA,CAIT,EAEMsB,EAAQ,CAAC,EASf,OAAO,OAAOA,EAAO,CACnB,KAAA9B,EACA,QAAAqB,EACA,MAAAC,EACA,KAAAK,EACA,OAAAC,EACA,OAAAC,CACF,CAAC"}
@@ -1 +1 @@
1
- .tgph :is(.fixed){position:fixed}.tgph :is(.absolute){position:absolute}.tgph :is(.inset-0){inset:var(--tgph-spacing-0)}.tgph :is(.left-1\/2){left:50%}.tgph :is(.top-0){top:var(--tgph-spacing-0)}.tgph :is(.z-modal){z-index:var(--tgph-zIndex-modal)}.tgph :is(.z-overlay){z-index:var(--tgph-zIndex-overlay)}.tgph :is(.max-h-\[calc\(100vh-var\(--tgph-spacing-32\)\)\]){max-height:calc(100vh - var(--tgph-spacing-32))}.tgph :is(.-translate-x-1\/2){--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.tgph :is(.transform){transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.tgph :is(.overflow-y-auto){overflow-y:auto}.tgph :is(.border){border-width:1px}.tgph :is(.bg-alpha-black-4){background-color:var(--tgph-alpha-black-4)}.tgph :is(.shadow-1){--tw-shadow: var(--tgph-shadow-1);--tw-shadow-colored: var(--tgph-shadow-1);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.tgph :is(.blur){--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.tgph :is(.transition){transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}
1
+ .tgph :is(.fixed){position:fixed}.tgph :is(.absolute){position:absolute}.tgph :is(.inset-0){inset:var(--tgph-spacing-0)}.tgph :is(.left-1\/2){left:50%}.tgph :is(.top-0){top:var(--tgph-spacing-0)}.tgph :is(.z-modal){z-index:var(--tgph-zIndex-modal)}.tgph :is(.z-overlay){z-index:var(--tgph-zIndex-overlay)}.tgph :is(.max-h-\[calc\(100vh-var\(--tgph-spacing-32\)\)\]){max-height:calc(100vh - var(--tgph-spacing-32))}.tgph :is(.-translate-x-1\/2){--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.tgph :is(.border){border-width:1px}.tgph :is(.bg-alpha-black-4){background-color:var(--tgph-alpha-black-4)}.tgph :is(.shadow-1){--tw-shadow: var(--tgph-shadow-1);--tw-shadow-colored: var(--tgph-shadow-1);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.tgph :is(.outline){outline-style:solid}.tgph :is(.blur){--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.tgph :is(.transition){transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}
@@ -1,70 +1,131 @@
1
- import { jsx as t, jsxs as b } from "react/jsx-runtime";
2
- import * as o from "@radix-ui/react-dialog";
3
- import { Box as e, Stack as y } from "@telegraph/layout";
4
- import d from "clsx";
5
- import { AnimatePresence as x, motion as s } from "framer-motion";
6
- import c from "react";
7
- const p = c.forwardRef(
8
- ({ portal: i = { enabled: !0 }, open: a, onOpenChange: r, className: l, ...m }, f) => {
9
- const u = i.enabled ? o.Portal : c.Fragment;
10
- return /* @__PURE__ */ t(o.Root, { open: a, onOpenChange: r, children: /* @__PURE__ */ t(x, { children: a && /* @__PURE__ */ b(u, { ...i, forceMount: !0, children: [
11
- /* @__PURE__ */ t(o.Overlay, { asChild: !0, children: /* @__PURE__ */ t(
12
- e,
13
- {
14
- as: s.div,
15
- onClick: () => r == null ? void 0 : r(!1),
16
- initial: { backdropFilter: "blur(0px)", opacity: 0 },
17
- animate: { backdropFilter: "blur(4px)", opacity: 1 },
18
- exit: { backdropFilter: "blur(0px)", opacity: 0 },
19
- transition: { duration: 0.3, bounce: 0, type: "spring" },
20
- className: "fixed inset-0 bg-alpha-black-4 z-overlay"
21
- }
22
- ) }),
23
- /* @__PURE__ */ t(
24
- o.Content,
25
- {
26
- onEscapeKeyDown: () => r == null ? void 0 : r(!1),
27
- onPointerDownOutside: () => r == null ? void 0 : r(!1),
28
- ref: f,
29
- asChild: !0,
30
- children: /* @__PURE__ */ t(
31
- y,
1
+ import { jsxs as d, jsx as t, Fragment as x } from "react/jsx-runtime";
2
+ import * as i from "@radix-ui/react-dialog";
3
+ import * as y from "@radix-ui/react-visually-hidden";
4
+ import { Button as b } from "@telegraph/button";
5
+ import { Lucide as h } from "@telegraph/icon";
6
+ import { Box as w, Stack as c } from "@telegraph/layout";
7
+ import R from "clsx";
8
+ import { AnimatePresence as g, motion as f } from "framer-motion";
9
+ import a from "react";
10
+ const k = a.forwardRef(
11
+ ({
12
+ defaultOpen: e,
13
+ open: o,
14
+ onOpenChange: r,
15
+ a11yTitle: l,
16
+ a11yDescription: s,
17
+ className: m,
18
+ children: u,
19
+ ...n
20
+ }, p) => /* @__PURE__ */ d(
21
+ i.Root,
22
+ {
23
+ open: o,
24
+ onOpenChange: r,
25
+ defaultOpen: e,
26
+ children: [
27
+ /* @__PURE__ */ d(y.Root, { children: [
28
+ /* @__PURE__ */ t(i.Title, { children: l }),
29
+ s && /* @__PURE__ */ t(i.Description, { children: s })
30
+ ] }),
31
+ /* @__PURE__ */ t(g, { children: o && /* @__PURE__ */ d(x, { children: [
32
+ /* @__PURE__ */ t(i.Overlay, { asChild: !0, children: /* @__PURE__ */ t(
33
+ w,
32
34
  {
33
- className: d(
34
- "absolute z-modal top-0 left-1/2 transform -translate-x-1/2 max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1",
35
- l
35
+ as: f.div,
36
+ onClick: () => r == null ? void 0 : r(!1),
37
+ initial: { backdropFilter: "blur(0px)", opacity: 0 },
38
+ animate: { backdropFilter: "blur(4px)", opacity: 1 },
39
+ exit: { backdropFilter: "blur(0px)", opacity: 0 },
40
+ transition: { duration: 0.3, bounce: 0, type: "spring" },
41
+ className: "fixed inset-0 bg-alpha-black-4 z-overlay"
42
+ }
43
+ ) }),
44
+ /* @__PURE__ */ t(
45
+ c,
46
+ {
47
+ className: R(
48
+ "absolute z-modal top-0 left-1/2 -translate-x-1/2",
49
+ "max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1",
50
+ m
36
51
  ),
37
52
  direction: "column",
38
- as: s.div,
39
- bg: "surface-1",
40
- rounded: "4",
53
+ as: f.div,
41
54
  my: "16",
42
- initial: { scale: 0.8, opacity: 0, y: -20 },
43
- animate: { scale: 1, opacity: 1, y: 0 },
44
- exit: { scale: 0.8, opacity: 0, y: -20 },
55
+ initial: { scale: 0.8, opacity: 0, y: -20, x: "-50%" },
56
+ animate: { scale: 1, opacity: 1, y: 0, x: "-50%" },
57
+ exit: { scale: 0.8, opacity: 0, y: -20, x: "-50%" },
45
58
  transition: { duration: 0.2, bounce: 0, type: "spring" },
59
+ maxW: n.maxW ?? "140",
60
+ w: n.w ?? "full",
61
+ bg: "surface-1",
46
62
  border: !0,
47
- children: m.children
63
+ rounded: "4",
64
+ ...n,
65
+ ref: p,
66
+ children: u
48
67
  }
49
68
  )
50
- }
51
- )
52
- ] }) }) });
53
- }
54
- ), v = c.forwardRef(({ p: i = "4", className: a, ...r }, l) => /* @__PURE__ */ t(
55
- e,
56
- {
57
- className: d(a, "overflow-y-auto"),
58
- p: i,
59
- ...r,
60
- ref: l
61
- }
62
- )), k = {};
63
- Object.assign(k, {
64
- Root: p,
65
- Content: v
69
+ ] }) })
70
+ ]
71
+ }
72
+ )
73
+ ), v = a.forwardRef(
74
+ ({ children: e, ...o }, r) => /* @__PURE__ */ t(i.Content, { ref: r, ...o, asChild: !0, children: /* @__PURE__ */ t(c, { direction: "column", children: e }) })
75
+ ), j = a.forwardRef(
76
+ ({ size: e = "1", variant: o = "ghost", ...r }, l) => /* @__PURE__ */ t(i.Close, { asChild: !0, children: /* @__PURE__ */ t(
77
+ b,
78
+ {
79
+ icon: { icon: h.X, alt: "Close Modal" },
80
+ variant: o,
81
+ size: e,
82
+ ...r,
83
+ ref: l
84
+ }
85
+ ) })
86
+ ), F = a.forwardRef(
87
+ ({ children: e, ...o }, r) => /* @__PURE__ */ t(c, { direction: "column", px: "6", py: "4", ...o, ref: r, children: e })
88
+ ), B = a.forwardRef(
89
+ ({ children: e, ...o }, r) => /* @__PURE__ */ t(
90
+ c,
91
+ {
92
+ direction: "row",
93
+ justify: "space-between",
94
+ align: "center",
95
+ px: "6",
96
+ py: "4",
97
+ borderBottom: !0,
98
+ ...o,
99
+ ref: r,
100
+ children: e
101
+ }
102
+ )
103
+ ), C = a.forwardRef(
104
+ ({ children: e, ...o }, r) => /* @__PURE__ */ t(
105
+ c,
106
+ {
107
+ direction: "row",
108
+ align: "center",
109
+ justify: "end",
110
+ gap: "2",
111
+ px: "6",
112
+ py: "4",
113
+ borderTop: !0,
114
+ ...o,
115
+ ref: r,
116
+ children: e
117
+ }
118
+ )
119
+ ), z = {};
120
+ Object.assign(z, {
121
+ Root: k,
122
+ Content: v,
123
+ Close: j,
124
+ Body: F,
125
+ Header: B,
126
+ Footer: C
66
127
  });
67
128
  export {
68
- k as Modal
129
+ z as Modal
69
130
  };
70
131
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["import * as Dialog from \"@radix-ui/react-dialog\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport clsx from \"clsx\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof Stack> & {\n portal?: {\n enabled?: boolean;\n container?: HTMLElement;\n };\n };\n\ntype RootRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n { portal = { enabled: true }, open, onOpenChange, className, ...props },\n forwardedRef,\n ) => {\n const Portal = portal.enabled ? Dialog.Portal : React.Fragment;\n return (\n <Dialog.Root open={open} onOpenChange={onOpenChange}>\n <AnimatePresence>\n {open && (\n <Portal {...portal} forceMount>\n <Dialog.Overlay asChild>\n <Box\n as={motion.div}\n onClick={() => onOpenChange?.(false)}\n initial={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n animate={{ backdropFilter: \"blur(4px)\", opacity: 1 }}\n exit={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n className=\"fixed inset-0 bg-alpha-black-4 z-overlay\"\n />\n </Dialog.Overlay>\n <Dialog.Content\n onEscapeKeyDown={() => onOpenChange?.(false)}\n onPointerDownOutside={() => onOpenChange?.(false)}\n ref={forwardedRef}\n asChild\n >\n <Stack\n className={clsx(\n \"absolute z-modal top-0 left-1/2 transform -translate-x-1/2 max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1\",\n className,\n )}\n direction=\"column\"\n as={motion.div}\n bg=\"surface-1\"\n rounded=\"4\"\n my=\"16\"\n initial={{ scale: 0.8, opacity: 0, y: -20 }}\n animate={{ scale: 1, opacity: 1, y: 0 }}\n exit={{ scale: 0.8, opacity: 0, y: -20 }}\n transition={{ duration: 0.2, bounce: 0, type: \"spring\" }}\n border\n >\n {props.children}\n </Stack>\n </Dialog.Content>\n </Portal>\n )}\n </AnimatePresence>\n </Dialog.Root>\n );\n },\n);\n\ntype ContentProps = React.ComponentProps<typeof Box>;\ntype ContentRef = React.ElementRef<typeof Box>;\n\nconst Content: React.FC<typeof Box> = React.forwardRef<\n ContentRef,\n ContentProps\n>(({ p = \"4\", className, ...props }, forwardedRef) => {\n return (\n <Box\n className={clsx(className, \"overflow-y-auto\")}\n p={p}\n {...props}\n ref={forwardedRef}\n />\n );\n});\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n});\n\nexport { Modal };\n"],"names":["Root","React","portal","open","onOpenChange","className","props","forwardedRef","Portal","Dialog","jsx","AnimatePresence","jsxs","Box","motion","Stack","clsx","Content","p","Modal"],"mappings":";;;;;;AAmBA,MAAMA,IAAOC,EAAM;AAAA,EACjB,CACE,EAAE,QAAAC,IAAS,EAAE,SAAS,GAAQ,GAAA,MAAAC,GAAM,cAAAC,GAAc,WAAAC,GAAW,GAAGC,EAAA,GAChEC,MACG;AACH,UAAMC,IAASN,EAAO,UAAUO,EAAO,SAASR,EAAM;AACtD,WACG,gBAAAS,EAAAD,EAAO,MAAP,EAAY,MAAAN,GAAY,cAAAC,GACvB,UAAA,gBAAAM,EAACC,GACE,EAAA,UAAAR,KACE,gBAAAS,EAAAJ,GAAA,EAAQ,GAAGN,GAAQ,YAAU,IAC5B,UAAA;AAAA,MAAA,gBAAAQ,EAACD,EAAO,SAAP,EAAe,SAAO,IACrB,UAAA,gBAAAC;AAAA,QAACG;AAAA,QAAA;AAAA,UACC,IAAIC,EAAO;AAAA,UACX,SAAS,MAAMV,KAAA,gBAAAA,EAAe;AAAA,UAC9B,SAAS,EAAE,gBAAgB,aAAa,SAAS,EAAE;AAAA,UACnD,SAAS,EAAE,gBAAgB,aAAa,SAAS,EAAE;AAAA,UACnD,MAAM,EAAE,gBAAgB,aAAa,SAAS,EAAE;AAAA,UAChD,YAAY,EAAE,UAAU,KAAK,QAAQ,GAAG,MAAM,SAAS;AAAA,UACvD,WAAU;AAAA,QAAA;AAAA,MAAA,GAEd;AAAA,MACA,gBAAAM;AAAA,QAACD,EAAO;AAAA,QAAP;AAAA,UACC,iBAAiB,MAAML,KAAA,gBAAAA,EAAe;AAAA,UACtC,sBAAsB,MAAMA,KAAA,gBAAAA,EAAe;AAAA,UAC3C,KAAKG;AAAA,UACL,SAAO;AAAA,UAEP,UAAA,gBAAAG;AAAA,YAACK;AAAA,YAAA;AAAA,cACC,WAAWC;AAAA,gBACT;AAAA,gBACAX;AAAA,cACF;AAAA,cACA,WAAU;AAAA,cACV,IAAIS,EAAO;AAAA,cACX,IAAG;AAAA,cACH,SAAQ;AAAA,cACR,IAAG;AAAA,cACH,SAAS,EAAE,OAAO,KAAK,SAAS,GAAG,GAAG,IAAI;AAAA,cAC1C,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,GAAG,EAAE;AAAA,cACtC,MAAM,EAAE,OAAO,KAAK,SAAS,GAAG,GAAG,IAAI;AAAA,cACvC,YAAY,EAAE,UAAU,KAAK,QAAQ,GAAG,MAAM,SAAS;AAAA,cACvD,QAAM;AAAA,cAEL,UAAMR,EAAA;AAAA,YAAA;AAAA,UACT;AAAA,QAAA;AAAA,MACF;AAAA,IAAA,GACF,GAEJ,EACF,CAAA;AAAA,EAEJ;AACF,GAKMW,IAAgChB,EAAM,WAG1C,CAAC,EAAE,GAAAiB,IAAI,KAAK,WAAAb,GAAW,GAAGC,EAAM,GAAGC,MAEjC,gBAAAG;AAAA,EAACG;AAAA,EAAA;AAAA,IACC,WAAWG,EAAKX,GAAW,iBAAiB;AAAA,IAC5C,GAAAa;AAAA,IACC,GAAGZ;AAAA,IACJ,KAAKC;AAAA,EAAA;AAAA,CAGV,GAEKY,IAAQ,CAAC;AAKf,OAAO,OAAOA,GAAO;AAAA,EACnB,MAAAnB;AAAA,EACA,SAAAiB;AACF,CAAC;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../src/Modal/Modal.tsx"],"sourcesContent":["import * as Dialog from \"@radix-ui/react-dialog\";\nimport * as VisuallyHidden from \"@radix-ui/react-visually-hidden\";\nimport { Button } from \"@telegraph/button\";\nimport { Lucide } from \"@telegraph/icon\";\nimport { Box, Stack } from \"@telegraph/layout\";\nimport clsx from \"clsx\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport React from \"react\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.ComponentPropsWithoutRef<typeof Stack> & {\n a11yTitle: string;\n a11yDescription?: string;\n };\n\ntype RootRef = HTMLDivElement;\n\nconst Root = React.forwardRef<RootRef, RootProps>(\n (\n {\n defaultOpen,\n open,\n onOpenChange,\n a11yTitle,\n a11yDescription,\n className,\n children,\n ...props\n },\n forwardedRef,\n ) => {\n return (\n <Dialog.Root\n open={open}\n onOpenChange={onOpenChange}\n defaultOpen={defaultOpen}\n >\n <VisuallyHidden.Root>\n <Dialog.Title>{a11yTitle}</Dialog.Title>\n {a11yDescription && (\n <Dialog.Description>{a11yDescription}</Dialog.Description>\n )}\n </VisuallyHidden.Root>\n <AnimatePresence>\n {open && (\n <>\n <Dialog.Overlay asChild>\n <Box\n as={motion.div}\n onClick={() => onOpenChange?.(false)}\n initial={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n animate={{ backdropFilter: \"blur(4px)\", opacity: 1 }}\n exit={{ backdropFilter: \"blur(0px)\", opacity: 0 }}\n transition={{ duration: 0.3, bounce: 0, type: \"spring\" }}\n className=\"fixed inset-0 bg-alpha-black-4 z-overlay\"\n />\n </Dialog.Overlay>\n <Stack\n className={clsx(\n \"absolute z-modal top-0 left-1/2 -translate-x-1/2\",\n \"max-h-[calc(100vh-var(--tgph-spacing-32))] shadow-1\",\n className,\n )}\n direction=\"column\"\n as={motion.div}\n my=\"16\"\n initial={{ scale: 0.8, opacity: 0, y: -20, x: \"-50%\" }}\n animate={{ scale: 1, opacity: 1, y: 0, x: \"-50%\" }}\n exit={{ scale: 0.8, opacity: 0, y: -20, x: \"-50%\" }}\n transition={{ duration: 0.2, bounce: 0, type: \"spring\" }}\n maxW={props.maxW ?? \"140\"}\n w={props.w ?? \"full\"}\n bg=\"surface-1\"\n border\n rounded=\"4\"\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n </>\n )}\n </AnimatePresence>\n </Dialog.Root>\n );\n },\n);\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content>;\ntype ContentRef = React.ElementRef<typeof Dialog.Content>;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Dialog.Content ref={forwardedRef} {...props} asChild>\n <Stack direction=\"column\">{children}</Stack>\n </Dialog.Content>\n );\n },\n);\n\ntype CloseProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Close>,\n \"color\"\n> &\n React.ComponentPropsWithoutRef<typeof Button>;\ntype CloseRef = React.ElementRef<typeof Button>;\n\nconst Close = React.forwardRef<CloseRef, CloseProps>(\n ({ size = \"1\", variant = \"ghost\", ...props }, forwardedRef) => {\n return (\n <Dialog.Close asChild>\n <Button\n icon={{ icon: Lucide.X, alt: \"Close Modal\" }}\n variant={variant}\n size={size}\n {...props}\n ref={forwardedRef}\n />\n </Dialog.Close>\n );\n },\n);\n\ntype BodyProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype BodyRef = React.ElementRef<typeof Stack>;\n\nconst Body: React.FC<BodyProps> = React.forwardRef<BodyRef, BodyProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack direction=\"column\" px=\"6\" py=\"4\" {...props} ref={forwardedRef}>\n {children}\n </Stack>\n );\n },\n);\n\ntype HeaderProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype HeaderRef = React.ElementRef<typeof Stack>;\n\nconst Header: React.FC<HeaderProps> = React.forwardRef<HeaderRef, HeaderProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack\n direction=\"row\"\n justify=\"space-between\"\n align=\"center\"\n px=\"6\"\n py=\"4\"\n borderBottom\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n );\n },\n);\n\ntype FooterProps = React.ComponentPropsWithoutRef<typeof Stack>;\ntype FooterRef = React.ElementRef<typeof Stack>;\n\nconst Footer: React.FC<FooterProps> = React.forwardRef<FooterRef, FooterProps>(\n ({ children, ...props }, forwardedRef) => {\n return (\n <Stack\n direction=\"row\"\n align=\"center\"\n justify=\"end\"\n gap=\"2\"\n px=\"6\"\n py=\"4\"\n borderTop\n {...props}\n ref={forwardedRef}\n >\n {children}\n </Stack>\n );\n },\n);\n\nconst Modal = {} as {\n Root: typeof Root;\n Content: typeof Content;\n Close: typeof Close;\n Body: typeof Body;\n Header: typeof Header;\n Footer: typeof Footer;\n};\n\nObject.assign(Modal, {\n Root,\n Content,\n Close,\n Body,\n Header,\n Footer,\n});\n\nexport { Modal };\n"],"names":["Root","React","defaultOpen","open","onOpenChange","a11yTitle","a11yDescription","className","children","props","forwardedRef","jsxs","Dialog","VisuallyHidden","jsx","AnimatePresence","Fragment","Box","motion","Stack","clsx","Content","Close","size","variant","Button","Lucide","Body","Header","Footer","Modal"],"mappings":";;;;;;;;;AAoBA,MAAMA,IAAOC,EAAM;AAAA,EACjB,CACE;AAAA,IACE,aAAAC;AAAA,IACA,MAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,GAAGC;AAAA,KAELC,MAGE,gBAAAC;AAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MACC,MAAAT;AAAA,MACA,cAAAC;AAAA,MACA,aAAAF;AAAA,MAEA,UAAA;AAAA,QAAC,gBAAAS,EAAAE,EAAe,MAAf,EACC,UAAA;AAAA,UAAC,gBAAAC,EAAAF,EAAO,OAAP,EAAc,UAAUP,EAAA,CAAA;AAAA,UACxBC,KACC,gBAAAQ,EAACF,EAAO,aAAP,EAAoB,UAAgBN,GAAA;AAAA,QAAA,GAEzC;AAAA,QACA,gBAAAQ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AAA,MACV,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,KAAI;AAAA,MACJ,IAAG;AAAA,MACH,IAAG;AAAA,MACH,WAAS;AAAA,MACR,GAAGV;AAAA,MACJ,KAAKC;AAAA,MAEJ,UAAAF;AAAA,IAAA;AAAA,EAAA;AAIT,GAEMsB,IAAQ,CAAC;AASf,OAAO,OAAOA,GAAO;AAAA,EACnB,MAAA9B;AAAA,EACA,SAAAqB;AAAA,EACA,OAAAC;AAAA,EACA,MAAAK;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC;AACF,CAAC;"}
@@ -1,17 +1,69 @@
1
1
  import * as Dialog from "@radix-ui/react-dialog";
2
- import { Box, Stack } from "@telegraph/layout";
2
+ import { Lucide } from "@telegraph/icon";
3
+ import { Stack } from "@telegraph/layout";
3
4
  import React from "react";
4
5
  type RootProps = Omit<React.ComponentPropsWithoutRef<typeof Dialog.Root>, "modal"> & React.ComponentPropsWithoutRef<typeof Stack> & {
5
- portal?: {
6
- enabled?: boolean;
7
- container?: HTMLElement;
8
- };
6
+ a11yTitle: string;
7
+ a11yDescription?: string;
9
8
  };
10
9
  declare const Root: React.ForwardRefExoticComponent<Omit<RootProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
- declare const Content: React.FC<typeof Box>;
10
+ declare const Content: React.ForwardRefExoticComponent<Omit<Dialog.DialogContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
11
+ declare const Close: React.ForwardRefExoticComponent<(Omit<Omit<Omit<Dialog.DialogCloseProps & React.RefAttributes<HTMLButtonElement>, "ref">, "color"> & Omit<import("@telegraph/helpers").AsProp<React.ElementType<any, keyof React.JSX.IntrinsicElements>> & Omit<any, "as"> & {
12
+ leadingIcon?: ({
13
+ icon: React.ForwardRefExoticComponent<Omit<Lucide.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
14
+ alt: string;
15
+ size?: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
16
+ variant?: "primary" | "secondary" | undefined;
17
+ color?: "white" | "disabled" | "default" | "gray" | "accent" | "beige" | "blue" | "green" | "yellow" | "purple" | "red" | undefined;
18
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<SVGSVGElement>) | undefined;
19
+ trailingIcon?: ({
20
+ icon: React.ForwardRefExoticComponent<Omit<Lucide.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
21
+ alt: string;
22
+ size?: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
23
+ variant?: "primary" | "secondary" | undefined;
24
+ color?: "white" | "disabled" | "default" | "gray" | "accent" | "beige" | "blue" | "green" | "yellow" | "purple" | "red" | undefined;
25
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<SVGSVGElement>) | undefined;
26
+ icon?: undefined;
27
+ } & {
28
+ variant?: "ghost" | "solid" | "soft" | "outline" | undefined;
29
+ size?: "1" | "2" | "3" | undefined;
30
+ color?: "gray" | "accent" | "blue" | "green" | "yellow" | "purple" | "red" | undefined;
31
+ state?: "disabled" | "loading" | "default" | "error" | "success" | "warning" | undefined;
32
+ active?: boolean | undefined;
33
+ } & {
34
+ ref?: (string | React.Ref<HTMLButtonElement>) | undefined;
35
+ }, "ref">, "ref"> | Omit<Omit<Omit<Dialog.DialogCloseProps & React.RefAttributes<HTMLButtonElement>, "ref">, "color"> & Omit<import("@telegraph/helpers").AsProp<React.ElementType<any, keyof React.JSX.IntrinsicElements>> & Omit<any, "as"> & {
36
+ icon?: ({
37
+ icon: React.ForwardRefExoticComponent<Omit<Lucide.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
38
+ alt: string;
39
+ size?: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | undefined;
40
+ variant?: "primary" | "secondary" | undefined;
41
+ color?: "white" | "disabled" | "default" | "gray" | "accent" | "beige" | "blue" | "green" | "yellow" | "purple" | "red" | undefined;
42
+ } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<SVGSVGElement>) | undefined;
43
+ leadingIcon?: undefined;
44
+ trailingIcon?: undefined;
45
+ } & {
46
+ variant?: "ghost" | "solid" | "soft" | "outline" | undefined;
47
+ size?: "1" | "2" | "3" | undefined;
48
+ color?: "gray" | "accent" | "blue" | "green" | "yellow" | "purple" | "red" | undefined;
49
+ state?: "disabled" | "loading" | "default" | "error" | "success" | "warning" | undefined;
50
+ active?: boolean | undefined;
51
+ } & {
52
+ ref?: (string | React.Ref<HTMLButtonElement>) | undefined;
53
+ }, "ref">, "ref">) & React.RefAttributes<HTMLButtonElement>>;
54
+ type BodyProps = React.ComponentPropsWithoutRef<typeof Stack>;
55
+ declare const Body: React.FC<BodyProps>;
56
+ type HeaderProps = React.ComponentPropsWithoutRef<typeof Stack>;
57
+ declare const Header: React.FC<HeaderProps>;
58
+ type FooterProps = React.ComponentPropsWithoutRef<typeof Stack>;
59
+ declare const Footer: React.FC<FooterProps>;
12
60
  declare const Modal: {
13
61
  Root: typeof Root;
14
62
  Content: typeof Content;
63
+ Close: typeof Close;
64
+ Body: typeof Body;
65
+ Header: typeof Header;
66
+ Footer: typeof Footer;
15
67
  };
16
68
  export { Modal };
17
69
  //# sourceMappingURL=Modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,SAAS,GAAG,IAAI,CACnB,KAAK,CAAC,wBAAwB,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,EAClD,OAAO,CACR,GACC,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,GAAG;IAC7C,MAAM,CAAC,EAAE;QACP,OAAO,C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AAC,EAAE,CAAC,WAAW,CAiBjC,CAAC;AAEF,KAAK,WAAW,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,CAAC;AAGhE,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAkBjC,CAAC;AAEF,QAAA,MAAM,KAAK;UACH,WAAW;aACR,cAAc;WAChB,YAAY;UACb,WAAW;YACT,aAAa;YACb,aAAa;CACtB,CAAC;AAWF,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Modal as TelegraphModal } from "./Modal";
3
+ declare const meta: Meta<typeof TelegraphModal.Root>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof TelegraphModal.Root>;
6
+ export declare const Modal: Story;
7
+ //# sourceMappingURL=Modal.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.stories.d.ts","sourceRoot":"","sources":["../../../src/Modal/Modal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,SAAS,CAAC;AAElD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,cAAc,CAAC,IAAI,CAG1C,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAElD,eAAO,MAAM,KAAK,EAAE,KA6BnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telegraph/modal",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "repository": "https://github.com/knocklabs/telegraph/tree/main/packages/modal",
5
5
  "author": "@knocklabs",
6
6
  "license": "MIT",
@@ -35,7 +35,10 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@radix-ui/react-dialog": "^1.0.5",
38
- "@telegraph/layout": "^0.0.8",
38
+ "@radix-ui/react-visually-hidden": "^1.0.3",
39
+ "@telegraph/button": "^0.0.16",
40
+ "@telegraph/icon": "^0.0.9",
41
+ "@telegraph/layout": "^0.0.9",
39
42
  "clsx": "^2.1.0",
40
43
  "framer-motion": "^11.1.9"
41
44
  },
@@ -43,9 +46,9 @@
43
46
  "@knocklabs/eslint-config": "^0.0.3",
44
47
  "@knocklabs/prettier-config": "^0.0.1",
45
48
  "@knocklabs/typescript-config": "^0.0.2",
46
- "@telegraph/postcss-config": "^0.0.13",
49
+ "@telegraph/postcss-config": "^0.0.14",
47
50
  "@telegraph/tailwind-config": "^0.0.11",
48
- "@telegraph/vite-config": "^0.0.8",
51
+ "@telegraph/vite-config": "^0.0.9",
49
52
  "@telegraph/vitest-config": "^0.0.6",
50
53
  "@types/react": "^18.2.48",
51
54
  "eslint": "^8.56.0",