@stokelp/ui 2.101.0 → 2.102.0
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),e=require("@ark-ui/react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),e=require("@ark-ui/react"),x=require("usehooks-ts"),o=require("@stokelp/styled-system/jsx"),p=require("@stokelp/styled-system/recipes"),m=require("@stokelp/styled-system/tokens"),d=require("react"),j=require("../../utils/slots.cjs"),v=require("../icon-button/IconButton.cjs"),{withProvider:T,withContext:t}=j.createStyleContext(p.drawer),b=T(e.Dialog.Root,void 0,{defaultProps:{unmountOnExit:!0,lazyMount:!0}}),k=t(o.styled(e.ark.main),"body"),y=t(o.styled(e.Dialog.CloseTrigger),"closeTrigger"),q=t(o.styled(e.ark.footer),"footer"),C=d.forwardRef(({children:s,showCloseTrigger:i=!0,...a},n)=>r.jsxs(e.ark.header,{...a,ref:n,children:[s,i&&r.jsx(y,{asChild:!0,children:r.jsx(v.IconButton,{ml:"auto","aria-label":"close",variant:"tertiary",children:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z",fill:"currentColor"})})})})]}));C.displayName="DrawerHeader";const L=t(C,"header"),B=t(o.styled(e.Dialog.Title),"title"),R=t(o.styled(e.Dialog.Trigger),"trigger"),P=t(o.styled(e.Dialog.Positioner),"positioner"),M=t(o.styled(e.Dialog.Backdrop),"backdrop"),f=d.forwardRef(({children:s,...i},a)=>{const n=x.useMediaQuery(`(max-width: ${m.token("breakpoints.md")})`,{defaultValue:!1}),{open:u,getContentProps:h}=e.useDialogContext();return d.useLayoutEffect(()=>{if(!u)return;const{id:g}=h();if(!g)return;const l=document.getElementById(g);if(!l)return;const c=l.querySelector("footer");if(!c)return;const w=()=>{l.style.setProperty("--footer-height",`${Math.ceil(c.clientHeight)}px`)};if(w(),n)return;const D=new ResizeObserver(w);return D.observe(c),()=>D.disconnect()},[u,n]),r.jsxs(r.Fragment,{children:[r.jsx(M,{}),r.jsx(P,{children:r.jsx(e.Dialog.Content,{ref:a,...i,children:s})})]})});f.displayName=e.Dialog.Content.displayName;const H=t(o.styled(f),"content"),S=e.Dialog.Context;exports.Drawer=b;exports.DrawerBody=k;exports.DrawerCloseTrigger=y;exports.DrawerContent=H;exports.DrawerContext=S;exports.DrawerFooter=q;exports.DrawerHeader=L;exports.DrawerTitle=B;exports.DrawerTrigger=R;
|
|
2
2
|
//# sourceMappingURL=Drawer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.cjs","sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label=\"close\" variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n ),\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if (
|
|
1
|
+
{"version":3,"file":"Drawer.cjs","sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label=\"close\" variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n ),\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if (!$content) return\n const $footer = $content.querySelector('footer')\n if (!$footer) return\n const update = () => {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n }\n update()\n if (isMobile) return\n const observer = new ResizeObserver(update)\n observer.observe($footer)\n return () => observer.disconnect()\n }, [open, isMobile])\n\n return (\n <>\n <DrawerBackdrop />\n <DrawerPositioner>\n <ArkDrawer.Content ref={ref} {...props}>\n {children}\n </ArkDrawer.Content>\n </DrawerPositioner>\n </>\n )\n },\n)\nContent.displayName = ArkDrawer.Content.displayName\n\nexport const DrawerContent = withContext(styled(Content), 'content')\nexport const DrawerContext = ArkDrawer.Context\n\nexport interface DrawerProps extends ComponentProps<typeof Drawer> {}\nexport interface DrawerBackdropProps extends ComponentProps<typeof DrawerBackdrop> {}\nexport interface DrawerBodyProps extends ComponentProps<typeof DrawerBody> {}\nexport interface DrawerCloseTriggerProps extends ComponentProps<typeof DrawerCloseTrigger> {}\nexport interface DrawerContentProps extends ComponentProps<typeof DrawerContent> {}\nexport interface DrawerFooterProps extends ComponentProps<typeof DrawerFooter> {}\nexport interface DrawerHeaderProps extends ComponentProps<typeof DrawerHeader> {}\nexport interface DrawerPositionerProps extends ComponentProps<typeof DrawerPositioner> {}\nexport interface DrawerTitleProps extends ComponentProps<typeof DrawerTitle> {}\nexport interface DrawerTriggerProps extends ComponentProps<typeof DrawerTrigger> {}\nexport interface DrawerContextProps extends ComponentProps<typeof DrawerContext> {}\n"],"names":["withProvider","withContext","createStyleContext","drawer","Drawer","ArkDrawer","DrawerBody","styled","ark","DrawerCloseTrigger","DrawerFooter","Header","forwardRef","children","showCloseTrigger","props","ref","jsx","IconButton","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","useMediaQuery","token","open","getContentProps","useDialogContext","useLayoutEffect","id","$content","$footer","update","observer","jsxs","Fragment","DrawerContent","DrawerContext"],"mappings":"sZAUM,CAAE,aAAAA,EAAc,YAAAC,GAAgBC,EAAAA,mBAAmBC,EAAAA,MAAM,EAElDC,EAASJ,EAAaK,SAAU,KAAM,OAAW,CAC5D,aAAc,CACZ,cAAe,GACf,UAAW,EA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IAAK,CACxE,aAAc,EAAA,CACf,EACK,CAAE,KAAAC,EAAM,gBAAAC,CAAA,EAAoBC,mBAAA,EAElCC,OAAAA,EAAAA,gBAAgB,IAAM,CACpB,GAAI,CAACH,EAAM,OACX,KAAM,CAAE,GAAAI,CAAA,EAAOH,EAAA,EACf,GAAI,CAACG,EAAI,OACT,MAAMC,EAAW,SAAS,eAAeD,CAAE,EAC3C,GAAI,CAACC,EAAU,OACf,MAAMC,EAAUD,EAAS,cAAc,QAAQ,EAC/C,GAAI,CAACC,EAAS,OACd,MAAMC,EAAS,IAAM,CACnBF,EAAS,MAAM,YAAY,kBAAmB,GAAG,KAAK,KAAKC,EAAQ,YAAY,CAAC,IAAI,CACtF,EAEA,GADAC,EAAA,EACIV,EAAU,OACd,MAAMW,EAAW,IAAI,eAAeD,CAAM,EAC1C,OAAAC,EAAS,QAAQF,CAAO,EACjB,IAAME,EAAS,WAAA,CACxB,EAAG,CAACR,EAAMH,CAAQ,CAAC,EAGjBY,EAAAA,KAAAC,WAAA,CACE,SAAA,CAAArB,EAAAA,IAACM,EAAA,EAAe,EAChBN,EAAAA,IAACK,EAAA,CACC,SAAAL,EAAAA,IAACZ,EAAAA,OAAU,QAAV,CAAkB,IAAAW,EAAW,GAAGD,EAC9B,SAAAF,CAAA,CACH,CAAA,CACF,CAAA,EACF,CAEJ,CACF,EACAW,EAAQ,YAAcnB,SAAU,QAAQ,YAEjC,MAAMkC,EAAgBtC,EAAYM,SAAOiB,CAAO,EAAG,SAAS,EACtDgB,EAAgBnC,EAAAA,OAAU"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { Dialog as e, ark as
|
|
4
|
-
import { useMediaQuery as
|
|
5
|
-
import { styled as
|
|
6
|
-
import { drawer as
|
|
7
|
-
import { token as
|
|
8
|
-
import { forwardRef as
|
|
9
|
-
import { createStyleContext as
|
|
10
|
-
import { IconButton as
|
|
11
|
-
const { withProvider:
|
|
2
|
+
import { jsxs as w, Fragment as D, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog as e, ark as d, useDialogContext as x } from "@ark-ui/react";
|
|
4
|
+
import { useMediaQuery as v } from "usehooks-ts";
|
|
5
|
+
import { styled as t } from "@stokelp/styled-system/jsx";
|
|
6
|
+
import { drawer as L } from "@stokelp/styled-system/recipes";
|
|
7
|
+
import { token as b } from "@stokelp/styled-system/tokens";
|
|
8
|
+
import { forwardRef as g, useLayoutEffect as T } from "react";
|
|
9
|
+
import { createStyleContext as k } from "../../utils/slots.js";
|
|
10
|
+
import { IconButton as B } from "../icon-button/IconButton.js";
|
|
11
|
+
const { withProvider: P, withContext: r } = k(L), q = P(e.Root, void 0, {
|
|
12
12
|
defaultProps: {
|
|
13
13
|
unmountOnExit: !0,
|
|
14
14
|
lazyMount: !0
|
|
15
15
|
}
|
|
16
|
-
}),
|
|
17
|
-
({ children:
|
|
18
|
-
|
|
19
|
-
s && /* @__PURE__ */ o(
|
|
16
|
+
}), Q = r(t(d.main), "body"), M = r(t(e.CloseTrigger), "closeTrigger"), V = r(t(d.footer), "footer"), C = g(
|
|
17
|
+
({ children: i, showCloseTrigger: s = !0, ...a }, n) => /* @__PURE__ */ w(d.header, { ...a, ref: n, children: [
|
|
18
|
+
i,
|
|
19
|
+
s && /* @__PURE__ */ o(M, { asChild: !0, children: /* @__PURE__ */ o(B, { ml: "auto", "aria-label": "close", variant: "tertiary", children: /* @__PURE__ */ o("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ o(
|
|
20
20
|
"path",
|
|
21
21
|
{
|
|
22
22
|
fillRule: "evenodd",
|
|
@@ -27,38 +27,43 @@ const { withProvider: k, withContext: t } = P(D), q = k(e.Root, void 0, {
|
|
|
27
27
|
) }) }) })
|
|
28
28
|
] })
|
|
29
29
|
);
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
({ children:
|
|
33
|
-
const n =
|
|
30
|
+
C.displayName = "DrawerHeader";
|
|
31
|
+
const Z = r(C, "header"), A = r(t(e.Title), "title"), G = r(t(e.Trigger), "trigger"), R = r(t(e.Positioner), "positioner"), H = r(t(e.Backdrop), "backdrop"), h = g(
|
|
32
|
+
({ children: i, ...s }, a) => {
|
|
33
|
+
const n = v(`(max-width: ${b("breakpoints.md")})`, {
|
|
34
34
|
defaultValue: !1
|
|
35
|
-
}), { open:
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
const { id:
|
|
39
|
-
if (!
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
}), { open: u, getContentProps: y } = x();
|
|
36
|
+
return T(() => {
|
|
37
|
+
if (!u) return;
|
|
38
|
+
const { id: m } = y();
|
|
39
|
+
if (!m) return;
|
|
40
|
+
const l = document.getElementById(m);
|
|
41
|
+
if (!l) return;
|
|
42
|
+
const c = l.querySelector("footer");
|
|
43
|
+
if (!c) return;
|
|
44
|
+
const f = () => {
|
|
45
|
+
l.style.setProperty("--footer-height", `${Math.ceil(c.clientHeight)}px`);
|
|
46
|
+
};
|
|
47
|
+
if (f(), n) return;
|
|
48
|
+
const p = new ResizeObserver(f);
|
|
49
|
+
return p.observe(c), () => p.disconnect();
|
|
50
|
+
}, [u, n]), /* @__PURE__ */ w(D, { children: [
|
|
51
|
+
/* @__PURE__ */ o(H, {}),
|
|
52
|
+
/* @__PURE__ */ o(R, { children: /* @__PURE__ */ o(e.Content, { ref: a, ...s, children: i }) })
|
|
48
53
|
] });
|
|
49
54
|
}
|
|
50
55
|
);
|
|
51
56
|
h.displayName = e.Content.displayName;
|
|
52
|
-
const
|
|
57
|
+
const J = r(t(h), "content"), K = e.Context;
|
|
53
58
|
export {
|
|
54
59
|
q as Drawer,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
Q as DrawerBody,
|
|
61
|
+
M as DrawerCloseTrigger,
|
|
62
|
+
J as DrawerContent,
|
|
63
|
+
K as DrawerContext,
|
|
64
|
+
V as DrawerFooter,
|
|
65
|
+
Z as DrawerHeader,
|
|
66
|
+
A as DrawerTitle,
|
|
67
|
+
G as DrawerTrigger
|
|
63
68
|
};
|
|
64
69
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label=\"close\" variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n ),\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if (
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["import { ark, Dialog as ArkDrawer, useDialogContext } from '@ark-ui/react'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { drawer } from '@stokelp/styled-system/recipes'\nimport { token } from '@stokelp/styled-system/tokens'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\n\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\n\nconst { withProvider, withContext } = createStyleContext(drawer)\n\nexport const Drawer = withProvider(ArkDrawer.Root, undefined, {\n defaultProps: {\n unmountOnExit: true,\n lazyMount: true,\n },\n})\nexport const DrawerBody = withContext(styled(ark.main), 'body')\nexport const DrawerCloseTrigger = withContext(styled(ArkDrawer.CloseTrigger), 'closeTrigger')\nexport const DrawerFooter = withContext(styled(ark.footer), 'footer')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\n\nconst Header = forwardRef<ElementRef<typeof ark.header>, HeaderProps>(\n ({ children, showCloseTrigger = true, ...props }, ref) => (\n <ark.header {...props} ref={ref}>\n {children}\n {showCloseTrigger && (\n <DrawerCloseTrigger asChild>\n <IconButton ml=\"auto\" aria-label=\"close\" variant=\"tertiary\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M3.64645 3.64645C3.84171 3.45118 4.15829 3.45118 4.35355 3.64645L8 7.29289L11.6464 3.64645C11.8417 3.45118 12.1583 3.45118 12.3536 3.64645C12.5488 3.84171 12.5488 4.15829 12.3536 4.35355L8.70711 8L12.3536 11.6464C12.5488 11.8417 12.5488 12.1583 12.3536 12.3536C12.1583 12.5488 11.8417 12.5488 11.6464 12.3536L8 8.70711L4.35355 12.3536C4.15829 12.5488 3.84171 12.5488 3.64645 12.3536C3.45118 12.1583 3.45118 11.8417 3.64645 11.6464L7.29289 8L3.64645 4.35355C3.45118 4.15829 3.45118 3.84171 3.64645 3.64645Z\"\n fill=\"currentColor\"\n />\n </svg>\n </IconButton>\n </DrawerCloseTrigger>\n )}\n </ark.header>\n ),\n)\nHeader.displayName = 'DrawerHeader'\n\nexport const DrawerHeader = withContext(Header, 'header')\nexport const DrawerTitle = withContext(styled(ArkDrawer.Title), 'title')\nexport const DrawerTrigger = withContext(styled(ArkDrawer.Trigger), 'trigger')\n\nconst DrawerPositioner = withContext(styled(ArkDrawer.Positioner), 'positioner')\nconst DrawerBackdrop = withContext(styled(ArkDrawer.Backdrop), 'backdrop')\n\nconst Content = forwardRef<ElementRef<typeof ArkDrawer.Content>, ComponentPropsWithoutRef<typeof ArkDrawer.Content>>(\n ({ children, ...props }, ref) => {\n const isMobile = useMediaQuery(`(max-width: ${token('breakpoints.md')})`, {\n defaultValue: false,\n })\n const { open, getContentProps } = useDialogContext()\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n const $content = document.getElementById(id)\n if (!$content) return\n const $footer = $content.querySelector('footer')\n if (!$footer) return\n const update = () => {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n }\n update()\n if (isMobile) return\n const observer = new ResizeObserver(update)\n observer.observe($footer)\n return () => observer.disconnect()\n }, [open, isMobile])\n\n return (\n <>\n <DrawerBackdrop />\n <DrawerPositioner>\n <ArkDrawer.Content ref={ref} {...props}>\n {children}\n </ArkDrawer.Content>\n </DrawerPositioner>\n </>\n )\n },\n)\nContent.displayName = ArkDrawer.Content.displayName\n\nexport const DrawerContent = withContext(styled(Content), 'content')\nexport const DrawerContext = ArkDrawer.Context\n\nexport interface DrawerProps extends ComponentProps<typeof Drawer> {}\nexport interface DrawerBackdropProps extends ComponentProps<typeof DrawerBackdrop> {}\nexport interface DrawerBodyProps extends ComponentProps<typeof DrawerBody> {}\nexport interface DrawerCloseTriggerProps extends ComponentProps<typeof DrawerCloseTrigger> {}\nexport interface DrawerContentProps extends ComponentProps<typeof DrawerContent> {}\nexport interface DrawerFooterProps extends ComponentProps<typeof DrawerFooter> {}\nexport interface DrawerHeaderProps extends ComponentProps<typeof DrawerHeader> {}\nexport interface DrawerPositionerProps extends ComponentProps<typeof DrawerPositioner> {}\nexport interface DrawerTitleProps extends ComponentProps<typeof DrawerTitle> {}\nexport interface DrawerTriggerProps extends ComponentProps<typeof DrawerTrigger> {}\nexport interface DrawerContextProps extends ComponentProps<typeof DrawerContext> {}\n"],"names":["withProvider","withContext","createStyleContext","drawer","Drawer","ArkDrawer","DrawerBody","styled","ark","DrawerCloseTrigger","DrawerFooter","Header","forwardRef","children","showCloseTrigger","props","ref","jsx","IconButton","DrawerHeader","DrawerTitle","DrawerTrigger","DrawerPositioner","DrawerBackdrop","Content","isMobile","useMediaQuery","token","open","getContentProps","useDialogContext","useLayoutEffect","id","$content","$footer","update","observer","jsxs","Fragment","DrawerContent","DrawerContext"],"mappings":";;;;;;;;;;AAUA,MAAM,EAAE,cAAAA,GAAc,aAAAC,MAAgBC,EAAmBC,CAAM,GAElDC,IAASJ,EAAaK,EAAU,MAAM,QAAW;AAAA,EAC5D,cAAc;AAAA,IACZ,eAAe;AAAA,IACf,WAAW;AAAA,EAAA;AAEf,CAAC,GACYC,IAAaL,EAAYM,EAAOC,EAAI,IAAI,GAAG,MAAM,GACjDC,IAAqBR,EAAYM,EAAOF,EAAU,YAAY,GAAG,cAAc,GAC/EK,IAAeT,EAAYM,EAAOC,EAAI,MAAM,GAAG,QAAQ,GAM9DG,IAASC;AAAA,EACb,CAAC,EAAE,UAAAC,GAAU,kBAAAC,IAAmB,IAAM,GAAGC,EAAA,GAASC,wBAC/CR,EAAI,QAAJ,EAAY,GAAGO,GAAO,KAAAC,GACpB,UAAA;AAAA,IAAAH;AAAA,IACAC,KACC,gBAAAG,EAACR,GAAA,EAAmB,SAAO,IACzB,4BAACS,GAAA,EAAW,IAAG,QAAO,cAAW,SAAQ,SAAQ,YAC/C,UAAA,gBAAAD,EAAC,OAAA,EAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,OAAM,8BAChE,UAAA,gBAAAA;AAAA,MAAC;A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