@stokelp/ui 2.118.0 → 2.119.1

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";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utils/slots.cjs"),n=require("../icon-button/IconButton.cjs"),r=require("../drawer/Drawer.cjs");let i=require("@ark-ui/react"),a=require("@stokelp/styled-system/jsx"),o=require("@stokelp/styled-system/recipes"),s=require("react"),c=require("react/jsx-runtime"),l=require("usehooks-ts"),u=require("@stokelp/styled-system/tokens");var d=e.__exportAll({Backdrop:()=>h,Body:()=>x,CloseTrigger:()=>g,Content:()=>v,Footer:()=>S,Header:()=>b,Positioner:()=>C,Root:()=>m,Title:()=>w,Trigger:()=>T}),{withProvider:f,withContext:p}=t.createStyleContext(o.dialog,{dataAttr:!0}),m=f(i.Dialog.Root,void 0,{defaultProps:{lazyMount:!0,unmountOnExit:!0}}),h=p((0,a.styled)(i.Dialog.Backdrop),`backdrop`),g=p((0,a.styled)(i.Dialog.CloseTrigger),`closeTrigger`),_=(0,s.forwardRef)(({children:e,...t},n)=>{let r=(0,l.useMediaQuery)(`(max-width: ${(0,u.token)(`breakpoints.md`)})`,{defaultValue:!1}),{open:a,getContentProps:o}=(0,i.useDialogContext)();return(0,s.useLayoutEffect)(()=>{if(!a)return;let{id:e}=o();e&&setTimeout(()=>{let t=document.getElementById(e);if(t){let e=t.querySelector(`footer`);e&&(r?t.style.setProperty(`--footer-height`,`${Math.ceil(e.clientHeight)}px`):t.style.setProperty(`--footer-height`,`70px`))}},0)},[a,r]),(0,c.jsxs)(i.Portal,{children:[(0,c.jsx)(h,{}),(0,c.jsx)(C,{children:(0,c.jsx)(i.Dialog.Content,{ref:n,...t,children:e})})]})});_.displayName=i.Dialog.Content.displayName;var v=p((0,a.styled)(_),`content`),y=(0,s.forwardRef)(({children:e,showCloseTrigger:t=!0,...a},o)=>(0,c.jsxs)(i.ark.header,{...a,ref:o,children:[e,t&&(0,c.jsx)(r.DrawerCloseTrigger,{asChild:!0,children:(0,c.jsx)(n.IconButton,{ml:`auto`,"aria-label":`close`,variant:`tertiary`,children:(0,c.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,c.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`})})})})]}));y.displayName=`DialogHeader`;var b=p((0,a.styled)(y),`header`),x=p((0,a.styled)(i.ark.main),`body`),S=p((0,a.styled)(i.ark.footer),`footer`),C=p((0,a.styled)(i.Dialog.Positioner),`positioner`),w=p((0,a.styled)(i.Dialog.Title),`title`),T=p((0,a.styled)(i.Dialog.Trigger),`trigger`);Object.defineProperty(exports,"styled_exports",{enumerable:!0,get:function(){return d}});
1
+ "use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utils/slots.cjs"),n=require("../../utils/overlay-lock-cleanup.cjs"),r=require("../icon-button/IconButton.cjs"),i=require("../drawer/Drawer.cjs");let a=require("@ark-ui/react"),o=require("@stokelp/styled-system/jsx"),s=require("@stokelp/styled-system/recipes"),c=require("react"),l=require("react/jsx-runtime"),u=require("usehooks-ts"),d=require("@stokelp/styled-system/tokens");var f=e.__exportAll({Backdrop:()=>g,Body:()=>S,CloseTrigger:()=>_,Content:()=>y,Footer:()=>C,Header:()=>x,Positioner:()=>w,Root:()=>h,Title:()=>T,Trigger:()=>E}),{withProvider:p,withContext:m}=t.createStyleContext(s.dialog,{dataAttr:!0}),h=p(a.Dialog.Root,void 0,{defaultProps:{lazyMount:!0,unmountOnExit:!0}}),g=m((0,o.styled)(a.Dialog.Backdrop),`backdrop`),_=m((0,o.styled)(a.Dialog.CloseTrigger),`closeTrigger`),v=(0,c.forwardRef)(({children:e,...t},r)=>{let i=(0,u.useMediaQuery)(`(max-width: ${(0,d.token)(`breakpoints.md`)})`,{defaultValue:!1}),{open:o,getContentProps:s}=(0,a.useDialogContext)();return n.useReleaseStaleOverlayLocks(o),(0,c.useLayoutEffect)(()=>{if(!o)return;let{id:e}=s();e&&setTimeout(()=>{let t=document.getElementById(e);if(t){let e=t.querySelector(`footer`);e&&(i?t.style.setProperty(`--footer-height`,`${Math.ceil(e.clientHeight)}px`):t.style.setProperty(`--footer-height`,`70px`))}},0)},[o,i]),(0,l.jsxs)(a.Portal,{children:[(0,l.jsx)(g,{}),(0,l.jsx)(w,{children:(0,l.jsx)(a.Dialog.Content,{ref:r,...t,children:e})})]})});v.displayName=a.Dialog.Content.displayName;var y=m((0,o.styled)(v),`content`),b=(0,c.forwardRef)(({children:e,showCloseTrigger:t=!0,...n},o)=>(0,l.jsxs)(a.ark.header,{...n,ref:o,children:[e,t&&(0,l.jsx)(i.DrawerCloseTrigger,{asChild:!0,children:(0,l.jsx)(r.IconButton,{ml:`auto`,"aria-label":`close`,variant:`tertiary`,children:(0,l.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,l.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`})})})})]}));b.displayName=`DialogHeader`;var x=m((0,o.styled)(b),`header`),S=m((0,o.styled)(a.ark.main),`body`),C=m((0,o.styled)(a.ark.footer),`footer`),w=m((0,o.styled)(a.Dialog.Positioner),`positioner`),T=m((0,o.styled)(a.Dialog.Title),`title`),E=m((0,o.styled)(a.Dialog.Trigger),`trigger`);Object.defineProperty(exports,"styled_exports",{enumerable:!0,get:function(){return f}});
2
2
  //# sourceMappingURL=styled.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.cjs","names":[],"sources":["../../../src/components/dialog/styled.tsx"],"sourcesContent":["import { ark, Dialog as ArkDialog, Portal, useDialogContext } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { dialog } from '@stokelp/styled-system/recipes'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\nimport { DrawerCloseTrigger } from '~/components'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { token } from '@stokelp/styled-system/tokens'\n\nconst { withProvider, withContext } = createStyleContext(dialog, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(ArkDialog.Root, undefined, {\n defaultProps: {\n lazyMount: true,\n unmountOnExit: true,\n },\n})\nexport const Backdrop = withContext(styled(ArkDialog.Backdrop), 'backdrop')\nexport const CloseTrigger = withContext(styled(ArkDialog.CloseTrigger), 'closeTrigger')\n\nconst InternalContent = forwardRef<\n ElementRef<typeof ArkDialog.Content>,\n ComponentPropsWithoutRef<typeof ArkDialog.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 setTimeout(() => {\n const $content = document.getElementById(id)\n\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, 0)\n }, [open, isMobile])\n\n return (\n <Portal>\n <Backdrop />\n <Positioner>\n <ArkDialog.Content ref={ref} {...props}>\n {children}\n </ArkDialog.Content>\n </Positioner>\n </Portal>\n )\n})\nInternalContent.displayName = ArkDialog.Content.displayName\n\nexport const Content = withContext(styled(InternalContent), 'content')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\nconst InternalHeader = 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)\nInternalHeader.displayName = 'DialogHeader'\n\nexport const Header = withContext(styled(InternalHeader), 'header')\nexport const Body = withContext(styled(ark.main), 'body')\nexport const Footer = withContext(styled(ark.footer), 'footer')\nexport const Positioner = withContext(styled(ArkDialog.Positioner), 'positioner')\nexport const Title = withContext(styled(ArkDialog.Title), 'title')\nexport const Trigger = withContext(styled(ArkDialog.Trigger), 'trigger')\n\nexport interface DialogProps extends ComponentProps<typeof Root> {}\nexport interface DialogBackdropProps extends ComponentProps<typeof Backdrop> {}\nexport interface DialogCloseTriggerProps extends ComponentProps<typeof CloseTrigger> {}\nexport interface DialogContentProps extends ComponentProps<typeof Content> {}\nexport interface DialogHeaderProps extends ComponentProps<typeof Header> {}\nexport interface DialogBodyProps extends ComponentProps<typeof Body> {}\nexport interface DialogFooterProps extends ComponentProps<typeof Footer> {}\nexport interface DialogPositionerProps extends ComponentProps<typeof Positioner> {}\nexport interface DialogTitleProps extends ComponentProps<typeof Title> {}\nexport interface DialogTriggerProps extends ComponentProps<typeof Trigger> {}\n"],"mappings":"gkBAUM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,OAAQ,CAC/D,SAAU,EACZ,CAAC,EAEY,EAAO,EAAa,EAAA,OAAU,KAAM,IAAA,GAAW,CAC1D,aAAc,CACZ,UAAW,GACX,cAAe,EACjB,CACF,CAAC,EACY,EAAW,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,QAAQ,EAAG,UAAU,EAC7D,EAAe,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,YAAY,EAAG,cAAc,EAEhF,GAAA,EAAA,EAAA,aAGH,CAAE,WAAU,GAAG,GAAS,IAAQ,CACjC,IAAM,GAAA,EAAA,EAAA,eA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A,KAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,4fACF,KAAK,cACN,CAAA,CACE,CAAA,CACK,CAAA,CACM,CAAA,CAEZ,GAEhB,EACA,EAAe,YAAc,eAE7B,IAAa,EAAS,GAAA,EAAA,EAAA,QAAmB,CAAc,EAAG,QAAQ,EACrD,EAAO,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,IAAI,EAAG,MAAM,EAC3C,EAAS,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,MAAM,EAAG,QAAQ,EACjD,EAAa,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,UAAU,EAAG,YAAY,EACnE,EAAQ,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,KAAK,EAAG,OAAO,EACpD,EAAU,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,OAAO,EAAG,SAAS"}
1
+ {"version":3,"file":"styled.cjs","names":[],"sources":["../../../src/components/dialog/styled.tsx"],"sourcesContent":["import { ark, Dialog as ArkDialog, Portal, useDialogContext } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { dialog } from '@stokelp/styled-system/recipes'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\nimport { createStyleContext } from '~/utils/slots'\nimport { useReleaseStaleOverlayLocks } from '~/utils/overlay-lock-cleanup'\nimport { IconButton } from '~/components/icon-button'\nimport { DrawerCloseTrigger } from '~/components'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { token } from '@stokelp/styled-system/tokens'\n\nconst { withProvider, withContext } = createStyleContext(dialog, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(ArkDialog.Root, undefined, {\n defaultProps: {\n lazyMount: true,\n unmountOnExit: true,\n },\n})\nexport const Backdrop = withContext(styled(ArkDialog.Backdrop), 'backdrop')\nexport const CloseTrigger = withContext(styled(ArkDialog.CloseTrigger), 'closeTrigger')\n\nconst InternalContent = forwardRef<\n ElementRef<typeof ArkDialog.Content>,\n ComponentPropsWithoutRef<typeof ArkDialog.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 // Release body locks (scroll lock + pointer-events / inert) that @zag-js can\n // leak when a consumer force-unmounts the Dialog on close. See\n // useReleaseStaleOverlayLocks for the full explanation.\n useReleaseStaleOverlayLocks(open)\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n setTimeout(() => {\n const $content = document.getElementById(id)\n\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, 0)\n }, [open, isMobile])\n\n return (\n <Portal>\n <Backdrop />\n <Positioner>\n <ArkDialog.Content ref={ref} {...props}>\n {children}\n </ArkDialog.Content>\n </Positioner>\n </Portal>\n )\n})\nInternalContent.displayName = ArkDialog.Content.displayName\n\nexport const Content = withContext(styled(InternalContent), 'content')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\nconst InternalHeader = 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)\nInternalHeader.displayName = 'DialogHeader'\n\nexport const Header = withContext(styled(InternalHeader), 'header')\nexport const Body = withContext(styled(ark.main), 'body')\nexport const Footer = withContext(styled(ark.footer), 'footer')\nexport const Positioner = withContext(styled(ArkDialog.Positioner), 'positioner')\nexport const Title = withContext(styled(ArkDialog.Title), 'title')\nexport const Trigger = withContext(styled(ArkDialog.Trigger), 'trigger')\n\nexport interface DialogProps extends ComponentProps<typeof Root> {}\nexport interface DialogBackdropProps extends ComponentProps<typeof Backdrop> {}\nexport interface DialogCloseTriggerProps extends ComponentProps<typeof CloseTrigger> {}\nexport interface DialogContentProps extends ComponentProps<typeof Content> {}\nexport interface DialogHeaderProps extends ComponentProps<typeof Header> {}\nexport interface DialogBodyProps extends ComponentProps<typeof Body> {}\nexport interface DialogFooterProps extends ComponentProps<typeof Footer> {}\nexport interface DialogPositionerProps extends ComponentProps<typeof Positioner> {}\nexport interface DialogTitleProps extends ComponentProps<typeof Title> {}\nexport interface DialogTriggerProps extends ComponentProps<typeof Trigger> {}\n"],"mappings":"knBAWM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,OAAQ,CAC/D,SAAU,EACZ,CAAC,EAEY,EAAO,EAAa,EAAA,OAAU,KAAM,IAAA,GAAW,CAC1D,aAAc,CACZ,UAAW,GACX,cAAe,EACjB,CACF,CAAC,EACY,EAAW,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,QAAQ,EAAG,UAAU,EAC7D,EA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ClB,EAAA,EAAA,KAAC,EAAA,WAAD,CAAY,GAAG,OAAO,aAAW,QAAQ,QAAQ,qBAC/C,EAAA,EAAA,KAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,uCAChE,EAAA,EAAA,KAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,4fACF,KAAK,cACN,CAAA,CACE,CAAA,CACK,CAAA,CACM,CAAA,CAEZ,GAEhB,EACA,EAAe,YAAc,eAE7B,IAAa,EAAS,GAAA,EAAA,EAAA,QAAmB,CAAc,EAAG,QAAQ,EACrD,EAAO,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,IAAI,EAAG,MAAM,EAC3C,EAAS,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,MAAM,EAAG,QAAQ,EACjD,EAAa,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,UAAU,EAAG,YAAY,EACnE,EAAQ,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,KAAK,EAAG,OAAO,EACpD,EAAU,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,OAAO,EAAG,SAAS"}
@@ -1,65 +1,66 @@
1
1
  "use client";
2
2
  import { __exportAll as e } from "../../_virtual/_rolldown/runtime.js";
3
3
  import { createStyleContext as t } from "../../utils/slots.js";
4
- import { IconButton as n } from "../icon-button/IconButton.js";
5
- import { DrawerCloseTrigger as r } from "../drawer/Drawer.js";
6
- import { Dialog as i, Portal as a, ark as o, useDialogContext as s } from "@ark-ui/react";
7
- import { styled as c } from "@stokelp/styled-system/jsx";
8
- import { dialog as l } from "@stokelp/styled-system/recipes";
9
- import { forwardRef as u, useLayoutEffect as d } from "react";
10
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
11
- import { useMediaQuery as m } from "usehooks-ts";
12
- import { token as h } from "@stokelp/styled-system/tokens";
4
+ import { useReleaseStaleOverlayLocks as n } from "../../utils/overlay-lock-cleanup.js";
5
+ import { IconButton as r } from "../icon-button/IconButton.js";
6
+ import { DrawerCloseTrigger as i } from "../drawer/Drawer.js";
7
+ import { Dialog as a, Portal as o, ark as s, useDialogContext as c } from "@ark-ui/react";
8
+ import { styled as l } from "@stokelp/styled-system/jsx";
9
+ import { dialog as u } from "@stokelp/styled-system/recipes";
10
+ import { forwardRef as d, useLayoutEffect as f } from "react";
11
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
+ import { useMediaQuery as h } from "usehooks-ts";
13
+ import { token as g } from "@stokelp/styled-system/tokens";
13
14
  //#region src/components/dialog/styled.tsx
14
- var g = /* @__PURE__ */ e({
15
- Backdrop: () => b,
16
- Body: () => E,
17
- CloseTrigger: () => x,
18
- Content: () => C,
19
- Footer: () => D,
20
- Header: () => T,
21
- Positioner: () => O,
22
- Root: () => y,
23
- Title: () => k,
24
- Trigger: () => A
25
- }), { withProvider: _, withContext: v } = t(l, { dataAttr: !0 }), y = _(i.Root, void 0, { defaultProps: {
15
+ var _ = /* @__PURE__ */ e({
16
+ Backdrop: () => x,
17
+ Body: () => D,
18
+ CloseTrigger: () => S,
19
+ Content: () => w,
20
+ Footer: () => O,
21
+ Header: () => E,
22
+ Positioner: () => k,
23
+ Root: () => b,
24
+ Title: () => A,
25
+ Trigger: () => j
26
+ }), { withProvider: v, withContext: y } = t(u, { dataAttr: !0 }), b = v(a.Root, void 0, { defaultProps: {
26
27
  lazyMount: !0,
27
28
  unmountOnExit: !0
28
- } }), b = v(c(i.Backdrop), "backdrop"), x = v(c(i.CloseTrigger), "closeTrigger"), S = u(({ children: e, ...t }, n) => {
29
- let r = m(`(max-width: ${h("breakpoints.md")})`, { defaultValue: !1 }), { open: o, getContentProps: c } = s();
30
- return d(() => {
31
- if (!o) return;
32
- let { id: e } = c();
29
+ } }), x = y(l(a.Backdrop), "backdrop"), S = y(l(a.CloseTrigger), "closeTrigger"), C = d(({ children: e, ...t }, r) => {
30
+ let i = h(`(max-width: ${g("breakpoints.md")})`, { defaultValue: !1 }), { open: s, getContentProps: l } = c();
31
+ return n(s), f(() => {
32
+ if (!s) return;
33
+ let { id: e } = l();
33
34
  e && setTimeout(() => {
34
35
  let t = document.getElementById(e);
35
36
  if (t) {
36
37
  let e = t.querySelector("footer");
37
- e && (r ? t.style.setProperty("--footer-height", `${Math.ceil(e.clientHeight)}px`) : t.style.setProperty("--footer-height", "70px"));
38
+ e && (i ? t.style.setProperty("--footer-height", `${Math.ceil(e.clientHeight)}px`) : t.style.setProperty("--footer-height", "70px"));
38
39
  }
39
40
  }, 0);
40
- }, [o, r]), /* @__PURE__ */ p(a, { children: [/* @__PURE__ */ f(b, {}), /* @__PURE__ */ f(O, { children: /* @__PURE__ */ f(i.Content, {
41
- ref: n,
41
+ }, [s, i]), /* @__PURE__ */ m(o, { children: [/* @__PURE__ */ p(x, {}), /* @__PURE__ */ p(k, { children: /* @__PURE__ */ p(a.Content, {
42
+ ref: r,
42
43
  ...t,
43
44
  children: e
44
45
  }) })] });
45
46
  });
46
- S.displayName = i.Content.displayName;
47
- var C = v(c(S), "content"), w = u(({ children: e, showCloseTrigger: t = !0, ...i }, a) => /* @__PURE__ */ p(o.header, {
48
- ...i,
47
+ C.displayName = a.Content.displayName;
48
+ var w = y(l(C), "content"), T = d(({ children: e, showCloseTrigger: t = !0, ...n }, a) => /* @__PURE__ */ m(s.header, {
49
+ ...n,
49
50
  ref: a,
50
- children: [e, t && /* @__PURE__ */ f(r, {
51
+ children: [e, t && /* @__PURE__ */ p(i, {
51
52
  asChild: !0,
52
- children: /* @__PURE__ */ f(n, {
53
+ children: /* @__PURE__ */ p(r, {
53
54
  ml: "auto",
54
55
  "aria-label": "close",
55
56
  variant: "tertiary",
56
- children: /* @__PURE__ */ f("svg", {
57
+ children: /* @__PURE__ */ p("svg", {
57
58
  width: "16",
58
59
  height: "16",
59
60
  viewBox: "0 0 16 16",
60
61
  fill: "none",
61
62
  xmlns: "http://www.w3.org/2000/svg",
62
- children: /* @__PURE__ */ f("path", {
63
+ children: /* @__PURE__ */ p("path", {
63
64
  fillRule: "evenodd",
64
65
  clipRule: "evenodd",
65
66
  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",
@@ -69,9 +70,9 @@ var C = v(c(S), "content"), w = u(({ children: e, showCloseTrigger: t = !0, ...i
69
70
  })
70
71
  })]
71
72
  }));
72
- w.displayName = "DialogHeader";
73
- var T = v(c(w), "header"), E = v(c(o.main), "body"), D = v(c(o.footer), "footer"), O = v(c(i.Positioner), "positioner"), k = v(c(i.Title), "title"), A = v(c(i.Trigger), "trigger");
73
+ T.displayName = "DialogHeader";
74
+ var E = y(l(T), "header"), D = y(l(s.main), "body"), O = y(l(s.footer), "footer"), k = y(l(a.Positioner), "positioner"), A = y(l(a.Title), "title"), j = y(l(a.Trigger), "trigger");
74
75
  //#endregion
75
- export { g as styled_exports };
76
+ export { _ as styled_exports };
76
77
 
77
78
  //# sourceMappingURL=styled.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styled.js","names":[],"sources":["../../../src/components/dialog/styled.tsx"],"sourcesContent":["import { ark, Dialog as ArkDialog, Portal, useDialogContext } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { dialog } from '@stokelp/styled-system/recipes'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\nimport { createStyleContext } from '~/utils/slots'\nimport { IconButton } from '~/components/icon-button'\nimport { DrawerCloseTrigger } from '~/components'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { token } from '@stokelp/styled-system/tokens'\n\nconst { withProvider, withContext } = createStyleContext(dialog, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(ArkDialog.Root, undefined, {\n defaultProps: {\n lazyMount: true,\n unmountOnExit: true,\n },\n})\nexport const Backdrop = withContext(styled(ArkDialog.Backdrop), 'backdrop')\nexport const CloseTrigger = withContext(styled(ArkDialog.CloseTrigger), 'closeTrigger')\n\nconst InternalContent = forwardRef<\n ElementRef<typeof ArkDialog.Content>,\n ComponentPropsWithoutRef<typeof ArkDialog.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 setTimeout(() => {\n const $content = document.getElementById(id)\n\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, 0)\n }, [open, isMobile])\n\n return (\n <Portal>\n <Backdrop />\n <Positioner>\n <ArkDialog.Content ref={ref} {...props}>\n {children}\n </ArkDialog.Content>\n </Positioner>\n </Portal>\n )\n})\nInternalContent.displayName = ArkDialog.Content.displayName\n\nexport const Content = withContext(styled(InternalContent), 'content')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\nconst InternalHeader = 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)\nInternalHeader.displayName = 'DialogHeader'\n\nexport const Header = withContext(styled(InternalHeader), 'header')\nexport const Body = withContext(styled(ark.main), 'body')\nexport const Footer = withContext(styled(ark.footer), 'footer')\nexport const Positioner = withContext(styled(ArkDialog.Positioner), 'positioner')\nexport const Title = withContext(styled(ArkDialog.Title), 'title')\nexport const Trigger = withContext(styled(ArkDialog.Trigger), 'trigger')\n\nexport interface DialogProps extends ComponentProps<typeof Root> {}\nexport interface DialogBackdropProps extends ComponentProps<typeof Backdrop> {}\nexport interface DialogCloseTriggerProps extends ComponentProps<typeof CloseTrigger> {}\nexport interface DialogContentProps extends ComponentProps<typeof Content> {}\nexport interface DialogHeaderProps extends ComponentProps<typeof Header> {}\nexport interface DialogBodyProps extends ComponentProps<typeof Body> {}\nexport interface DialogFooterProps extends ComponentProps<typeof Footer> {}\nexport interface DialogPositionerProps extends ComponentProps<typeof Positioner> {}\nexport interface DialogTitleProps extends ComponentProps<typeof Title> {}\nexport interface DialogTriggerProps extends ComponentProps<typeof Trigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;IAUM,EAAE,iBAA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AY,IAAG;GAAO,cAAW;GAAQ,SAAQ;aAC/C,kBAAC,OAAD;IAAK,OAAM;IAAK,QAAO;IAAK,SAAQ;IAAY,MAAK;IAAO,OAAM;cAChE,kBAAC,QAAD;KACE,UAAS;KACT,UAAS;KACT,GAAE;KACF,MAAK;IACN,CAAA;GACE,CAAA;EACK,CAAA;CACM,CAAA,CAEZ;EAEhB;AACA,EAAe,cAAc;AAE7B,IAAa,IAAS,EAAY,EAAO,CAAc,GAAG,QAAQ,GACrD,IAAO,EAAY,EAAO,EAAI,IAAI,GAAG,MAAM,GAC3C,IAAS,EAAY,EAAO,EAAI,MAAM,GAAG,QAAQ,GACjD,IAAa,EAAY,EAAO,EAAU,UAAU,GAAG,YAAY,GACnE,IAAQ,EAAY,EAAO,EAAU,KAAK,GAAG,OAAO,GACpD,IAAU,EAAY,EAAO,EAAU,OAAO,GAAG,SAAS"}
1
+ {"version":3,"file":"styled.js","names":[],"sources":["../../../src/components/dialog/styled.tsx"],"sourcesContent":["import { ark, Dialog as ArkDialog, Portal, useDialogContext } from '@ark-ui/react'\nimport { styled } from '@stokelp/styled-system/jsx'\nimport { dialog } from '@stokelp/styled-system/recipes'\nimport { ComponentProps, ComponentPropsWithoutRef, ElementRef, forwardRef, useLayoutEffect } from 'react'\nimport { createStyleContext } from '~/utils/slots'\nimport { useReleaseStaleOverlayLocks } from '~/utils/overlay-lock-cleanup'\nimport { IconButton } from '~/components/icon-button'\nimport { DrawerCloseTrigger } from '~/components'\nimport { useMediaQuery } from 'usehooks-ts'\nimport { token } from '@stokelp/styled-system/tokens'\n\nconst { withProvider, withContext } = createStyleContext(dialog, {\n dataAttr: true,\n})\n\nexport const Root = withProvider(ArkDialog.Root, undefined, {\n defaultProps: {\n lazyMount: true,\n unmountOnExit: true,\n },\n})\nexport const Backdrop = withContext(styled(ArkDialog.Backdrop), 'backdrop')\nexport const CloseTrigger = withContext(styled(ArkDialog.CloseTrigger), 'closeTrigger')\n\nconst InternalContent = forwardRef<\n ElementRef<typeof ArkDialog.Content>,\n ComponentPropsWithoutRef<typeof ArkDialog.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 // Release body locks (scroll lock + pointer-events / inert) that @zag-js can\n // leak when a consumer force-unmounts the Dialog on close. See\n // useReleaseStaleOverlayLocks for the full explanation.\n useReleaseStaleOverlayLocks(open)\n\n useLayoutEffect(() => {\n if (!open) return\n const { id } = getContentProps()\n if (!id) return\n setTimeout(() => {\n const $content = document.getElementById(id)\n\n if ($content) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, 0)\n }, [open, isMobile])\n\n return (\n <Portal>\n <Backdrop />\n <Positioner>\n <ArkDialog.Content ref={ref} {...props}>\n {children}\n </ArkDialog.Content>\n </Positioner>\n </Portal>\n )\n})\nInternalContent.displayName = ArkDialog.Content.displayName\n\nexport const Content = withContext(styled(InternalContent), 'content')\n\ntype HeaderProps = ComponentPropsWithoutRef<typeof ark.header> & {\n showCloseTrigger?: boolean\n}\nconst InternalHeader = 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)\nInternalHeader.displayName = 'DialogHeader'\n\nexport const Header = withContext(styled(InternalHeader), 'header')\nexport const Body = withContext(styled(ark.main), 'body')\nexport const Footer = withContext(styled(ark.footer), 'footer')\nexport const Positioner = withContext(styled(ArkDialog.Positioner), 'positioner')\nexport const Title = withContext(styled(ArkDialog.Title), 'title')\nexport const Trigger = withContext(styled(ArkDialog.Trigger), 'trigger')\n\nexport interface DialogProps extends ComponentProps<typeof Root> {}\nexport interface DialogBackdropProps extends ComponentProps<typeof Backdrop> {}\nexport interface DialogCloseTriggerProps extends ComponentProps<typeof CloseTrigger> {}\nexport interface DialogContentProps extends ComponentProps<typeof Content> {}\nexport interface DialogHeaderProps extends ComponentProps<typeof Header> {}\nexport interface DialogBodyProps extends ComponentProps<typeof Body> {}\nexport interface DialogFooterProps extends ComponentProps<typeof Footer> {}\nexport interface DialogPositionerProps extends ComponentProps<typeof Positioner> {}\nexport interface DialogTitleProps extends ComponentProps<typeof Title> {}\nexport interface DialogTriggerProps extends ComponentProps<typeof Trigger> {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAWM,EAAE,iBAAc,mBAAgB,EAAmB,GAAQ,EAC/D,UAAU,GACZ,CAAC,GAEY,IAAO,EAAa,EAAU,MAAM,KAAA,GAAW,EAC1D,cAAc;CACZ,WAAW;CACX,eAAe;AACjB,EACF,CAAC,GACY,IAAW,EAAY,EAAO,EAAU,QAAQ,GAAG,UAAU,GAC7D,I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IACN,CAAA;GACE,CAAA;EACK,CAAA;CACM,CAAA,CAEZ;EAEhB;AACA,EAAe,cAAc;AAE7B,IAAa,IAAS,EAAY,EAAO,CAAc,GAAG,QAAQ,GACrD,IAAO,EAAY,EAAO,EAAI,IAAI,GAAG,MAAM,GAC3C,IAAS,EAAY,EAAO,EAAI,MAAM,GAAG,QAAQ,GACjD,IAAa,EAAY,EAAO,EAAU,UAAU,GAAG,YAAY,GACnE,IAAQ,EAAY,EAAO,EAAU,KAAK,GAAG,OAAO,GACpD,IAAU,EAAY,EAAO,EAAU,OAAO,GAAG,SAAS"}
@@ -1,2 +1,2 @@
1
- "use client";const e=require("../../utils/slots.cjs"),t=require("../icon-button/IconButton.cjs");let n=require("@ark-ui/react"),r=require("@stokelp/styled-system/jsx"),i=require("@stokelp/styled-system/recipes"),a=require("react"),o=require("react/jsx-runtime"),s=require("usehooks-ts"),c=require("@stokelp/styled-system/tokens");var{withProvider:l,withContext:u}=e.createStyleContext(i.drawer),d=l(n.Dialog.Root,void 0,{defaultProps:{unmountOnExit:!0,lazyMount:!0}}),f=u((0,r.styled)(n.ark.main),`body`),p=u((0,r.styled)(n.Dialog.CloseTrigger),`closeTrigger`),m=u((0,r.styled)(n.ark.footer),`footer`),h=(0,a.forwardRef)(({children:e,showCloseTrigger:r=!0,...i},a)=>(0,o.jsxs)(n.ark.header,{...i,ref:a,children:[e,r&&(0,o.jsx)(p,{asChild:!0,children:(0,o.jsx)(t.IconButton,{ml:`auto`,"aria-label":`close`,variant:`tertiary`,children:(0,o.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,o.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`})})})})]}));h.displayName=`DrawerHeader`;var g=u(h,`header`),_=u((0,r.styled)(n.Dialog.Title),`title`),v=u((0,r.styled)(n.Dialog.Trigger),`trigger`),y=u((0,r.styled)(n.Dialog.Positioner),`positioner`),b=u((0,r.styled)(n.Dialog.Backdrop),`backdrop`),x=(0,a.forwardRef)(({children:e,...t},r)=>{let i=(0,s.useMediaQuery)(`(max-width: ${(0,c.token)(`breakpoints.md`)})`,{defaultValue:!1}),{open:l,getContentProps:u}=(0,n.useDialogContext)();return(0,a.useLayoutEffect)(()=>{if(!l)return;let{id:e}=u();if(!e)return;let t=document.getElementById(e);if(t){let e=t.querySelector(`footer`);e&&(i?t.style.setProperty(`--footer-height`,`${Math.ceil(e.clientHeight)}px`):t.style.setProperty(`--footer-height`,`70px`))}},[l,i]),(0,a.useEffect)(()=>{if(process.env.NODE_ENV===`production`)return;let e=()=>window.setTimeout(()=>{let e=document.body;document.querySelector(`[data-scope="dialog"][data-state="open"]`)||(e.style.pointerEvents===`none`&&(e.style.pointerEvents=``),e.hasAttribute(`data-inert`)&&e.removeAttribute(`data-inert`),e.getAttribute(`style`)===``&&e.removeAttribute(`style`))},350);return l||e(),()=>{e()}},[l]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(b,{}),(0,o.jsx)(y,{children:(0,o.jsx)(n.Dialog.Content,{ref:r,...t,children:e})})]})});x.displayName=n.Dialog.Content.displayName;var S=u((0,r.styled)(x),`content`),C=n.Dialog.Context;exports.Drawer=d,exports.DrawerBody=f,exports.DrawerCloseTrigger=p,exports.DrawerContent=S,exports.DrawerContext=C,exports.DrawerFooter=m,exports.DrawerHeader=g,exports.DrawerTitle=_,exports.DrawerTrigger=v;
1
+ "use client";const e=require("../../utils/slots.cjs"),t=require("../../utils/overlay-lock-cleanup.cjs"),n=require("../icon-button/IconButton.cjs");let r=require("@ark-ui/react"),i=require("@stokelp/styled-system/jsx"),a=require("@stokelp/styled-system/recipes"),o=require("react"),s=require("react/jsx-runtime"),c=require("usehooks-ts"),l=require("@stokelp/styled-system/tokens");var{withProvider:u,withContext:d}=e.createStyleContext(a.drawer),f=u(r.Dialog.Root,void 0,{defaultProps:{unmountOnExit:!0,lazyMount:!0}}),p=d((0,i.styled)(r.ark.main),`body`),m=d((0,i.styled)(r.Dialog.CloseTrigger),`closeTrigger`),h=d((0,i.styled)(r.ark.footer),`footer`),g=(0,o.forwardRef)(({children:e,showCloseTrigger:t=!0,...i},a)=>(0,s.jsxs)(r.ark.header,{...i,ref:a,children:[e,t&&(0,s.jsx)(m,{asChild:!0,children:(0,s.jsx)(n.IconButton,{ml:`auto`,"aria-label":`close`,variant:`tertiary`,children:(0,s.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,s.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`})})})})]}));g.displayName=`DrawerHeader`;var _=d(g,`header`),v=d((0,i.styled)(r.Dialog.Title),`title`),y=d((0,i.styled)(r.Dialog.Trigger),`trigger`),b=d((0,i.styled)(r.Dialog.Positioner),`positioner`),x=d((0,i.styled)(r.Dialog.Backdrop),`backdrop`),S=(0,o.forwardRef)(({children:e,...n},i)=>{let a=(0,c.useMediaQuery)(`(max-width: ${(0,l.token)(`breakpoints.md`)})`,{defaultValue:!1}),{open:u,getContentProps:d}=(0,r.useDialogContext)();return(0,o.useLayoutEffect)(()=>{if(!u)return;let{id:e}=d();if(!e)return;let t=document.getElementById(e);if(t){let e=t.querySelector(`footer`);e&&(a?t.style.setProperty(`--footer-height`,`${Math.ceil(e.clientHeight)}px`):t.style.setProperty(`--footer-height`,`70px`))}},[u,a]),t.useReleaseStaleOverlayLocks(u),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x,{}),(0,s.jsx)(b,{children:(0,s.jsx)(r.Dialog.Content,{ref:i,...n,children:e})})]})});S.displayName=r.Dialog.Content.displayName;var C=d((0,i.styled)(S),`content`),w=r.Dialog.Context;exports.Drawer=f,exports.DrawerBody=p,exports.DrawerCloseTrigger=m,exports.DrawerContent=C,exports.DrawerContext=w,exports.DrawerFooter=h,exports.DrawerHeader=_,exports.DrawerTitle=v,exports.DrawerTrigger=y;
2
2
  //# sourceMappingURL=Drawer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.cjs","names":[],"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, useEffect, 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) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n // Workaround: @zag-js/dismissable's disablePointerEventsOutside can leave\n // `<body>` with `pointer-events: none` / `data-inert`, freezing the page\n // after close. Two triggers we've hit:\n // 1. React StrictMode (Next.js dev) double-invokes the dismissable\n // effect, and its module-level `originalBodyPointerEvents` singleton\n // can be poisoned to `'none'` (worsened by nested dialogs).\n // 2. A consumer conditionally renders the Drawer Root and unmounts it on\n // close, so `open` never transitions to false within a mounted Content\n // — the close-path branch below never runs.\n // Gated inside the effect body so consumer bundlers DCE it in production.\n // The timer is fire-and-forget: React does NOT cancel a setTimeout queued\n // from an effect or its cleanup, so the restore still runs after Content\n // unmounts. The restore is idempotent and the stillOpen guard prevents it\n // from clobbering a dialog that is genuinely open.\n useEffect(() => {\n if (process.env.NODE_ENV === 'production') return\n const restorePointerEvents = () =>\n window.setTimeout(() => {\n const body = document.body\n const stillOpen = document.querySelector('[data-scope=\"dialog\"][data-state=\"open\"]')\n if (stillOpen) return\n if (body.style.pointerEvents === 'none') body.style.pointerEvents = ''\n if (body.hasAttribute('data-inert')) body.removeAttribute('data-inert')\n if (body.getAttribute('style') === '') body.removeAttribute('style')\n }, 350)\n // Normal close path: the Drawer stays mounted and `open` flips to false.\n if (!open) restorePointerEvents()\n // Unmount path: consumer yanked the Drawer Root while it was still open.\n return () => {\n restorePointerEvents()\n }\n }, [open])\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"],"mappings":"0UAUA,GAAM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,MAAM,EAElD,EAAS,EAAa,EAAA,OAAU,KAAM,IAAA,GAAW,CAC5D,aAAc,CACZ,cAAe,GACf,UAAW,EACb,CACF,CAAC,EACY,EAAa,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,IAAI,EAAG,MAAM,EACjD,EAAqB,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,YAAY,EAAG,cAAc,EAC/E,EAAe,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,MAAM,EAAG,QAAQ,EAM9D,GAAA,EAAA,EAAA,aACH,CAAE,WAAU,mBAAmB,GAAM,GAAG,GAAS,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KAAK,EAAQ,YAAY,EAAE,GAAG,EAEpF,EAAS,MAAM,YAAY,kBAAmB,MAAM,EAG1D,CACF,EAAG,CAAC,EAAM,CAAQ,CAAC,GAgBnB,EAAA,EAAA,eAAgB,CACd,GAAA,QAAA,IAAA,WAA6B,aAAc,OAC3C,IAAM,MACJ,OAAO,eAAiB,CACtB,IAAM,EAAO,SAAS,KACJ,SAAS,cAAc,0CACrC,IACA,EAAK,MAAM,gBAAkB,SAAQ,EAAK,MAAM,cAAgB,IAChE,EAAK,aAAa,YAAY,GAAG,EAAK,gBAAgB,YAAY,EAClE,EAAK,aAAa,OAAO,IAAM,IAAI,EAAK,gBAAgB,OAAO,EACrE,EAAG,GAAG,EAIR,OAFK,GAAM,EAAqB,MAEnB,CACX,EAAqB,CACvB,CACF,EAAG,CAAC,CAAI,CAAC,GAGP,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,EACE,EAAA,EAAA,KAAC,EAAD,CAAiB,CAAA,GACjB,EAAA,EAAA,KAAC,EAAD,CAAA,UACE,EAAA,EAAA,KAAC,EAAA,OAAU,QAAX,CAAwB,MAAK,GAAI,EAC9B,UACgB,CAAA,CACH,CAAA,CAClB,CAAA,CAAA,CAEN,CACF,EACA,EAAQ,YAAc,EAAA,OAAU,QAAQ,YAExC,IAAa,EAAgB,GAAA,EAAA,EAAA,QAAmB,CAAO,EAAG,SAAS,EACtD,EAAgB,EAAA,OAAU"}
1
+ {"version":3,"file":"Drawer.cjs","names":[],"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 { useReleaseStaleOverlayLocks } from '~/utils/overlay-lock-cleanup'\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) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n // Release body locks (scroll lock + pointer-events / inert) that @zag-js can\n // leak when a consumer force-unmounts the Drawer on close. See\n // useReleaseStaleOverlayLocks for the full explanation.\n useReleaseStaleOverlayLocks(open)\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"],"mappings":"4XAWA,GAAM,CAAE,eAAc,eAAgB,EAAA,mBAAmB,EAAA,MAAM,EAElD,EAAS,EAAa,EAAA,OAAU,KAAM,IAAA,GAAW,CAC5D,aAAc,CACZ,cAAe,GACf,UAAW,EACb,CACF,CAAC,EACY,EAAa,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,IAAI,EAAG,MAAM,EACjD,EAAqB,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,YAAY,EAAG,cAAc,EAC/E,EAAe,GAAA,EAAA,EAAA,QAAmB,EAAA,IAAI,MAAM,EAAG,QAAQ,EAM9D,GAAA,EAAA,EAAA,aACH,CAAE,WAAU,mBAAmB,GAAM,GAAG,GAAS,KAChD,EAAA,EAAA,MAAC,EAAA,IAAI,OAAL,CAAY,GAAI,EAAY,eAA5B,CACG,EACA,IACC,EAAA,EAAA,KAAC,EAAD,CAAoB,QAAA,aAClB,EAAA,EAAA,KAAC,EAAA,WAAD,CAAY,GAAG,OAAO,aAAW,QAAQ,QAAQ,qBAC/C,EAAA,EAAA,KAAC,MAAD,CAAK,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,uCAChE,EAAA,EAAA,KAAC,OAAD,CACE,SAAS,UACT,SAAS,UACT,EAAE,4fACF,KAAK,cACN,CAAA,CACE,CAAA,CACK,CAAA,CACM,CAAA,CAEZ,GAEhB,EACA,EAAO,YAAc,eAErB,IAAa,EAAe,EAAY,EAAQ,QAAQ,EAC3C,EAAc,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,KAAK,EAAG,OAAO,EAC1D,EAAgB,GAAA,EAAA,EAAA,QAAmB,EAAA,OAAU,OAA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icon-button/IconButton.js";
4
- import { Dialog as n, ark as r, useDialogContext as i } from "@ark-ui/react";
5
- import { styled as a } from "@stokelp/styled-system/jsx";
6
- import { drawer as o } from "@stokelp/styled-system/recipes";
7
- import { forwardRef as s, useEffect as c, useLayoutEffect as l } from "react";
3
+ import { useReleaseStaleOverlayLocks as t } from "../../utils/overlay-lock-cleanup.js";
4
+ import { IconButton as n } from "../icon-button/IconButton.js";
5
+ import { Dialog as r, ark as i, useDialogContext as a } from "@ark-ui/react";
6
+ import { styled as o } from "@stokelp/styled-system/jsx";
7
+ import { drawer as s } from "@stokelp/styled-system/recipes";
8
+ import { forwardRef as c, useLayoutEffect as l } from "react";
8
9
  import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
9
10
  import { useMediaQuery as p } from "usehooks-ts";
10
11
  import { token as m } from "@stokelp/styled-system/tokens";
11
12
  //#region src/components/drawer/Drawer.tsx
12
- var { withProvider: h, withContext: g } = e(o), _ = h(n.Root, void 0, { defaultProps: {
13
+ var { withProvider: h, withContext: g } = e(s), _ = h(r.Root, void 0, { defaultProps: {
13
14
  unmountOnExit: !0,
14
15
  lazyMount: !0
15
- } }), v = g(a(r.main), "body"), y = g(a(n.CloseTrigger), "closeTrigger"), b = g(a(r.footer), "footer"), x = s(({ children: e, showCloseTrigger: n = !0, ...i }, a) => /* @__PURE__ */ f(r.header, {
16
- ...i,
16
+ } }), v = g(o(i.main), "body"), y = g(o(r.CloseTrigger), "closeTrigger"), b = g(o(i.footer), "footer"), x = c(({ children: e, showCloseTrigger: t = !0, ...r }, a) => /* @__PURE__ */ f(i.header, {
17
+ ...r,
17
18
  ref: a,
18
- children: [e, n && /* @__PURE__ */ d(y, {
19
+ children: [e, t && /* @__PURE__ */ d(y, {
19
20
  asChild: !0,
20
- children: /* @__PURE__ */ d(t, {
21
+ children: /* @__PURE__ */ d(n, {
21
22
  ml: "auto",
22
23
  "aria-label": "close",
23
24
  variant: "tertiary",
@@ -38,34 +39,25 @@ var { withProvider: h, withContext: g } = e(o), _ = h(n.Root, void 0, { defaultP
38
39
  })]
39
40
  }));
40
41
  x.displayName = "DrawerHeader";
41
- var S = g(x, "header"), C = g(a(n.Title), "title"), w = g(a(n.Trigger), "trigger"), T = g(a(n.Positioner), "positioner"), E = g(a(n.Backdrop), "backdrop"), D = s(({ children: e, ...t }, r) => {
42
- let a = p(`(max-width: ${m("breakpoints.md")})`, { defaultValue: !1 }), { open: o, getContentProps: s } = i();
42
+ var S = g(x, "header"), C = g(o(r.Title), "title"), w = g(o(r.Trigger), "trigger"), T = g(o(r.Positioner), "positioner"), E = g(o(r.Backdrop), "backdrop"), D = c(({ children: e, ...n }, i) => {
43
+ let o = p(`(max-width: ${m("breakpoints.md")})`, { defaultValue: !1 }), { open: s, getContentProps: c } = a();
43
44
  return l(() => {
44
- if (!o) return;
45
- let { id: e } = s();
45
+ if (!s) return;
46
+ let { id: e } = c();
46
47
  if (!e) return;
47
48
  let t = document.getElementById(e);
48
49
  if (t) {
49
50
  let e = t.querySelector("footer");
50
- e && (a ? t.style.setProperty("--footer-height", `${Math.ceil(e.clientHeight)}px`) : t.style.setProperty("--footer-height", "70px"));
51
+ e && (o ? t.style.setProperty("--footer-height", `${Math.ceil(e.clientHeight)}px`) : t.style.setProperty("--footer-height", "70px"));
51
52
  }
52
- }, [o, a]), c(() => {
53
- if (process.env.NODE_ENV === "production") return;
54
- let e = () => window.setTimeout(() => {
55
- let e = document.body;
56
- document.querySelector("[data-scope=\"dialog\"][data-state=\"open\"]") || (e.style.pointerEvents === "none" && (e.style.pointerEvents = ""), e.hasAttribute("data-inert") && e.removeAttribute("data-inert"), e.getAttribute("style") === "" && e.removeAttribute("style"));
57
- }, 350);
58
- return o || e(), () => {
59
- e();
60
- };
61
- }, [o]), /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(E, {}), /* @__PURE__ */ d(T, { children: /* @__PURE__ */ d(n.Content, {
62
- ref: r,
63
- ...t,
53
+ }, [s, o]), t(s), /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(E, {}), /* @__PURE__ */ d(T, { children: /* @__PURE__ */ d(r.Content, {
54
+ ref: i,
55
+ ...n,
64
56
  children: e
65
57
  }) })] });
66
58
  });
67
- D.displayName = n.Content.displayName;
68
- var O = g(a(D), "content"), k = n.Context;
59
+ D.displayName = r.Content.displayName;
60
+ var O = g(o(D), "content"), k = r.Context;
69
61
  //#endregion
70
62
  export { _ as Drawer, v as DrawerBody, y as DrawerCloseTrigger, O as DrawerContent, k as DrawerContext, b as DrawerFooter, S as DrawerHeader, C as DrawerTitle, w as DrawerTrigger };
71
63
 
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.js","names":[],"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, useEffect, 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) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n // Workaround: @zag-js/dismissable's disablePointerEventsOutside can leave\n // `<body>` with `pointer-events: none` / `data-inert`, freezing the page\n // after close. Two triggers we've hit:\n // 1. React StrictMode (Next.js dev) double-invokes the dismissable\n // effect, and its module-level `originalBodyPointerEvents` singleton\n // can be poisoned to `'none'` (worsened by nested dialogs).\n // 2. A consumer conditionally renders the Drawer Root and unmounts it on\n // close, so `open` never transitions to false within a mounted Content\n // — the close-path branch below never runs.\n // Gated inside the effect body so consumer bundlers DCE it in production.\n // The timer is fire-and-forget: React does NOT cancel a setTimeout queued\n // from an effect or its cleanup, so the restore still runs after Content\n // unmounts. The restore is idempotent and the stillOpen guard prevents it\n // from clobbering a dialog that is genuinely open.\n useEffect(() => {\n if (process.env.NODE_ENV === 'production') return\n const restorePointerEvents = () =>\n window.setTimeout(() => {\n const body = document.body\n const stillOpen = document.querySelector('[data-scope=\"dialog\"][data-state=\"open\"]')\n if (stillOpen) return\n if (body.style.pointerEvents === 'none') body.style.pointerEvents = ''\n if (body.hasAttribute('data-inert')) body.removeAttribute('data-inert')\n if (body.getAttribute('style') === '') body.removeAttribute('style')\n }, 350)\n // Normal close path: the Drawer stays mounted and `open` flips to false.\n if (!open) restorePointerEvents()\n // Unmount path: consumer yanked the Drawer Root while it was still open.\n return () => {\n restorePointerEvents()\n }\n }, [open])\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"],"mappings":";;;;;;;;;;;AAUA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAM,GAElD,IAAS,EAAa,EAAU,MAAM,KAAA,GAAW,EAC5D,cAAc;CACZ,eAAe;CACf,WAAW;AACb,EACF,CAAC,GACY,IAAa,EAAY,EAAO,EAAI,IAAI,GAAG,MAAM,GACjD,IAAqB,EAAY,EAAO,EAAU,YAAY,GAAG,cAAc,GAC/E,IAAe,EAAY,EAAO,EAAI,MAAM,GAAG,QAAQ,GAM9D,IAAS,GACZ,EAAE,aAAU,sBAAmB,IAAM,GAAG,KAAS,MAChD,kBAAC,EAAI,QAAL;CAAY,GAAI;CAAY;WAA5B,CACG,GACA,KACC,kBAAC,GAAD;EAAoB,SAAA;YAClB,kBAAC,GAAD;GAAY,IAAG;GAAO,cAAW;GAAQ,SAAQ;aAC/C,kBAAC,OAAD;IAAK,OAAM;IAAK,QAAO;IAAK,SAAQ;IAAY,MAAK;IAAO,OAAM;cAChE,kBAAC,QAAD;KACE,UAAS;KACT,UAAS;KACT,GAAE;KACF,MAAK;IACN,CAAA;GACE,CAAA;EACK,CAAA;CACM,CAAA,CAEZ;EAEhB;AACA,EAAO,cAAc;AAErB,IAAa,IAAe,EAAY,GAAQ,QAAQ,GAC3C,IAAc,EAAY,EAAO,EAAU,KAAK,GAAG,OAAO,GAC1D,IAAgB,EAAY,EAAO,EAAU,OAAO,GAAG,SAAS,GAEvE,IAAmB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;AAExC,IAAa,IAAgB,EAAY,EAAO,CAAO,GAAG,SAAS,GACtD,IAAgB,EAAU"}
1
+ {"version":3,"file":"Drawer.js","names":[],"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 { useReleaseStaleOverlayLocks } from '~/utils/overlay-lock-cleanup'\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) {\n const $footer = $content.querySelector('footer')\n if ($footer) {\n if (isMobile) {\n $content.style.setProperty('--footer-height', `${Math.ceil($footer.clientHeight)}px`)\n } else {\n $content.style.setProperty('--footer-height', `70px`)\n }\n }\n }\n }, [open, isMobile])\n\n // Release body locks (scroll lock + pointer-events / inert) that @zag-js can\n // leak when a consumer force-unmounts the Drawer on close. See\n // useReleaseStaleOverlayLocks for the full explanation.\n useReleaseStaleOverlayLocks(open)\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"],"mappings":";;;;;;;;;;;;AAWA,IAAM,EAAE,iBAAc,mBAAgB,EAAmB,CAAM,GAElD,IAAS,EAAa,EAAU,MAAM,KAAA,GAAW,EAC5D,cAAc;CACZ,eAAe;CACf,WAAW;AACb,EACF,CAAC,GACY,IAAa,EAAY,EAAO,EAAI,IAAI,GAAG,MAAM,GACjD,IAAqB,EAAY,EAAO,EAAU,YAAY,GAAG,cAAc,GAC/E,IAAe,EAAY,EAAO,EAAI,MAAM,GAAG,QAAQ,GAM9D,IAAS,GACZ,EAAE,aAAU,sBAAmB,IAAM,GAAG,KAAS,MAChD,kBAAC,EAAI,QAAL;CAAY,GAAI;CAAY;WAA5B,CACG,GACA,KACC,kBAAC,GAAD;EAAoB,SAAA;YAClB,kBAAC,GAAD;GAAY,IAAG;GAAO,cAAW;GAAQ,SAAQ;aAC/C,kBAAC,OAAD;IAAK,OAAM;IAAK,QAAO;IAAK,SAAQ;IAAY,MAAK;IAAO,OAAM;cAChE,kBAAC,QAAD;KACE,UAAS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Text.cjs"),t=require("../icon/Icon.cjs"),n=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs"),r=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs");let i=require("@stokelp/styled-system/jsx"),a=require("react/jsx-runtime");var o=5,s={title:`Note fournisseur`,insufficientData:`Non noté`,componentsTitle:`Détail de la note`,completionTitle:`Complétion du compte`,notAvailable:`—`,units:{minutes:`min`,hours:`h`,days:`j`},components:{responseRate:`Taux de réponse`,responseDelay:`Délai de réponse`,completion:`Complétion du compte`},completion:{profile:`Profil (photo et description)`,locationContacts:`Localisation et contact`,legalBanking:`Coordonnées légales et bancaires`,sector:`Secteur d'activité`,certificate:`Certificat`,productInterest:`Intérêt produit`}},c=[`profile`,`locationContacts`,`legalBanking`,`sector`,`certificate`,`productInterest`];function l(e){return e.toFixed(1).replace(`.`,`,`)}function u(e,t){if(e<60)return`${Math.round(e)} ${t.minutes}`;let n=e/60;return n<48?`${Math.round(n)} ${t.hours}`:`${(n/24).toFixed(1).replace(`.`,`,`)} ${t.days}`}function d(e){let t=e/5;return t>=.7?`#3B6D11`:t>=.4?`#854F0B`:`#A32D2D`}function f(e){return e>=70?`#639922`:e>=40?`#BA7517`:`#E24B4A`}var p=({rating:o,responseRate:p,labels:m})=>{let h={...s,...m,units:{...s.units,...m?.units},components:{...s.components,...m?.components},completion:{...s.completion,...m?.completion}},g=p!=null,_=o.responseDelayMinutes!=null,v=o.responseDelayScore==null?null:Math.round(o.responseDelayScore*100),y=Math.round(o.completionScore*100),b=[{key:`responseRate`,value:g?`${Math.round(p)} %`:h.notAvailable,barPercent:g?Math.round(p):null,color:g?f(Math.round(p)):void 0},{key:`responseDelay`,value:_?u(o.responseDelayMinutes,h.units):h.notAvailable,barPercent:v,color:v==null?void 0:f(v)},{key:`completion`,value:`${y} %`,barPercent:y,color:f(y)}];return(0,a.jsxs)(i.Box,{bg:`white`,borderRadius:`radius-8`,p:`space-16`,minW:`240px`,maxW:`260px`,css:{"& *":{fontFamily:`inherit`}},children:[(0,a.jsxs)(i.HStack,{justify:`space-between`,alignItems:`baseline`,mb:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.md`,fontWeight:`bold`,children:h.title}),o.insufficientData||o.overall==null?(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,color:`grey.400`,children:h.insufficientData}):(0,a.jsxs)(e.Text,{as:`span`,fontSize:`body.lg`,fontWeight:`medium`,style:{color:d(o.overall)},children:[l(o.overall),` / `,5,` ★`]})]}),(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-8`,mb:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:h.componentsTitle}),b.map(t=>(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-2`,children:[(0,a.jsxs)(i.HStack,{justify:`space-between`,alignItems:`baseline`,gap:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:`grey.500`,children:h.components[t.key]}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,whiteSpace:`nowrap`,style:{color:t.color},color:t.color?void 0:`grey.300`,children:t.value})]}),(0,a.jsx)(i.Box,{h:`3px`,bg:`grey.100`,borderRadius:`full`,overflow:`hidden`,children:(0,a.jsx)(i.Box,{h:`100%`,borderRadius:`full`,style:{width:t.barPercent==null?`0%`:`${t.barPercent}%`,background:t.color??`transparent`}})})]},t.key))]}),(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-4`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:h.completionTitle}),c.map(s=>{let c=o.completion[s];return(0,a.jsxs)(i.HStack,{alignItems:`center`,gap:`space-8`,children:[(0,a.jsx)(t.Icon,{size:`sm`,color:c?`success.500`:`grey.300`,flexShrink:`0`,children:c?(0,a.jsx)(n.default,{}):(0,a.jsx)(r.default,{})}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:c?`grey.500`:`grey.400`,children:h.completion[s]})]},s)})]}),h.footer&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mt:`space-8`,mb:`space-8`}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`9px`,color:`grey.300`,style:{lineHeight:1},children:h.footer})]})]})};exports.DEFAULT_SUPPLIER_RATING_LABELS=s,exports.SUPPLIER_RATING_MAX=o,exports.SupplierRatingBreakdown=p,exports.formatOverall=l,exports.formatResponseDelay=u,exports.getHeadlineColor=d;
1
+ "use client";const e=require("../text/Text.cjs"),t=require("../icon/Icon.cjs"),n=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/CheckCircleIcon.cjs"),r=require("../../node_modules/.pnpm/@heroicons_react@2.2.0_react@19.2.6/node_modules/@heroicons/react/24/outline/esm/XCircleIcon.cjs");let i=require("@stokelp/styled-system/jsx"),a=require("react/jsx-runtime");var o=5,s={title:`Note fournisseur`,insufficientData:`Non noté`,componentsTitle:`Détail de la note`,completionTitle:`Complétion du compte`,notAvailable:`—`,units:{minutes:`min`,hours:`h`,days:`j`},components:{responseRate:`Taux de réponse`,responseDelay:`Délai de réponse`,completion:`Complétion du compte`},completion:{profile:`Profil (photo et description)`,location:`Localisation`,contacts:`Contact`,legalBanking:`Coordonnées légales et bancaires`,sector:`Secteur d'activité`,certificate:`Certificat`}},c=[`profile`,`location`,`contacts`,`legalBanking`,`sector`,`certificate`];function l(e){return e.toFixed(1).replace(`.`,`,`)}function u(e,t){if(e<60)return`${Math.round(e)} ${t.minutes}`;let n=e/60;return n<48?`${Math.round(n)} ${t.hours}`:`${(n/24).toFixed(1).replace(`.`,`,`)} ${t.days}`}function d(e){let t=e/5;return t>=.7?`#3B6D11`:t>=.4?`#854F0B`:`#A32D2D`}function f(e){return e>=70?`#639922`:e>=40?`#BA7517`:`#E24B4A`}var p=({rating:o,responseRate:p,labels:m})=>{let h={...s,...m,units:{...s.units,...m?.units},components:{...s.components,...m?.components},completion:{...s.completion,...m?.completion}},g=p!=null,_=o.responseDelayMinutes!=null,v=o.responseDelayScore==null?null:Math.round(o.responseDelayScore*100),y=Math.round(o.completionScore*100),b=[{key:`responseRate`,value:g?`${Math.round(p)} %`:h.notAvailable,barPercent:g?Math.round(p):null,color:g?f(Math.round(p)):void 0},{key:`responseDelay`,value:_?u(o.responseDelayMinutes,h.units):h.notAvailable,barPercent:v,color:v==null?void 0:f(v)},{key:`completion`,value:`${y} %`,barPercent:y,color:f(y)}];return(0,a.jsxs)(i.Box,{bg:`white`,borderRadius:`radius-8`,p:`space-16`,minW:`240px`,maxW:`260px`,css:{"& *":{fontFamily:`inherit`}},children:[(0,a.jsxs)(i.HStack,{justify:`space-between`,alignItems:`baseline`,mb:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.md`,fontWeight:`bold`,children:h.title}),o.insufficientData||o.overall==null?(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,color:`grey.400`,children:h.insufficientData}):(0,a.jsxs)(e.Text,{as:`span`,fontSize:`body.lg`,fontWeight:`medium`,style:{color:d(o.overall)},children:[l(o.overall),` / `,5,` ★`]})]}),(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-8`,mb:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:h.componentsTitle}),b.map(t=>(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-2`,children:[(0,a.jsxs)(i.HStack,{justify:`space-between`,alignItems:`baseline`,gap:`space-8`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:`grey.500`,children:h.components[t.key]}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`medium`,whiteSpace:`nowrap`,style:{color:t.color},color:t.color?void 0:`grey.300`,children:t.value})]}),(0,a.jsx)(i.Box,{h:`3px`,bg:`grey.100`,borderRadius:`full`,overflow:`hidden`,children:(0,a.jsx)(i.Box,{h:`100%`,borderRadius:`full`,style:{width:t.barPercent==null?`0%`:`${t.barPercent}%`,background:t.color??`transparent`}})})]},t.key))]}),(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mb:`space-8`}),(0,a.jsxs)(i.VStack,{alignItems:`stretch`,gap:`space-4`,children:[(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,fontWeight:`bold`,color:`grey.400`,children:h.completionTitle}),c.map(s=>{let c=o.completion[s];return(0,a.jsxs)(i.HStack,{alignItems:`center`,gap:`space-8`,children:[(0,a.jsx)(t.Icon,{size:`sm`,color:c?`success.500`:`grey.300`,flexShrink:`0`,children:c?(0,a.jsx)(n.default,{}):(0,a.jsx)(r.default,{})}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`body.sm`,color:c?`grey.500`:`grey.400`,children:h.completion[s]})]},s)})]}),h.footer&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Box,{h:`1px`,bg:`grey.100`,mt:`space-8`,mb:`space-8`}),(0,a.jsx)(e.Text,{as:`span`,fontSize:`9px`,color:`grey.300`,style:{lineHeight:1},children:h.footer})]})]})};exports.DEFAULT_SUPPLIER_RATING_LABELS=s,exports.SUPPLIER_RATING_MAX=o,exports.SupplierRatingBreakdown=p,exports.formatOverall=l,exports.formatResponseDelay=u,exports.getHeadlineColor=d;
2
2
  //# sourceMappingURL=SupplierRatingBreakdown.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SupplierRatingBreakdown.cjs","names":[],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'locationContacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n | 'productInterest'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n locationContacts: 'Localisation et contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n productInterest: 'Intérêt produit',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'locationContacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n 'productInterest',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${days.toFixed(1).replace('.', ',')} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </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,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,WAAW,OAAO,MAAM,oBACxD,EAAO,eACJ,CAAA,EACL,EAAiB,IAAI,GAAO,CAC3B,IAAM,EAAO,EAAO,WAAW,GAC/B,OACE,EAAA,EAAA,MAAC,EAAA,OAAD,CAAkB,WAAW,SAAS,IAAI,mBAA1C,EACE,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,KAAK,KAAK,MAAO,EAAO,cAAgB,WAAY,WAAW,aAClE,GAAO,EAAA,EAAA,KAAC,EAAA,QAAD,CAAkB,CAAA,GAAI,EAAA,EAAA,KAAC,EAAA,QAAD,CAAc,CAAA,CACxC,CAAA,GACN,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,MAAO,EAAO,WAAa,oBAC3D,EAAO,WAAW,EACf,CAAA,CACA,GAPK,CAOL,CAEZ,CAAC,CACK,IAEP,EAAO,SACN,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,EACE,EAAA,EAAA,KAAC,EAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,WACpE,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,GAET"}
1
+ {"version":3,"file":"SupplierRatingBreakdown.cjs","names":[],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${days.toFixed(1).replace('.', ',')} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":"4aAKA,IAAa,EAAsB,EAgDtB,EAAuD,CAClE,MAAO,mBACP,iBAAkB,WAClB,gBAAiB,oBACjB,gBAAiB,uBACjB,aAAc,IACd,MAAO,CAAE,QAAS,MAAO,MAAO,IAAK,KAAM,GAAI,EAC/C,WAAY,CACV,aAAc,kBACd,cAAe,mBACf,WAAY,sBACd,EACA,WAAY,CACV,QAAS,gCACT,SAAU,eACV,SAAU,UACV,aAAc,mCACd,OAAQ,qBACR,YAAa,YACf,CACF,EAEM,EAAkD,CACtD,UACA,WACA,WACA,eACA,SACA,aACF,EAEA,SAAgB,EAAc,EAAyB,CACrD,OA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,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,UAAU,MAAO,EAAO,WAAa,oBAC3D,EAAO,WAAW,EACf,CAAA,CACA,GAPK,CAOL,CAEZ,CAAC,CACK,IAEP,EAAO,SACN,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,EACE,EAAA,EAAA,KAAC,EAAA,IAAD,CAAK,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAW,CAAA,GACtD,EAAA,EAAA,KAAC,EAAA,KAAD,CAAM,GAAG,OAAO,SAAS,MAAM,MAAM,WAAW,MAAO,CAAE,WAAY,CAAE,WACpE,EAAO,MACJ,CAAA,CACN,CAAA,CAAA,CAED,GAET"}
@@ -1,6 +1,6 @@
1
1
  export declare const SUPPLIER_RATING_MAX = 5;
2
2
  export type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion';
3
- export type SupplierRatingCompletionKey = 'profile' | 'locationContacts' | 'legalBanking' | 'sector' | 'certificate' | 'productInterest';
3
+ export type SupplierRatingCompletionKey = 'profile' | 'location' | 'contacts' | 'legalBanking' | 'sector' | 'certificate';
4
4
  export type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>;
5
5
  export type SupplierRating = {
6
6
  /** Overall note out of 5. Absent when insufficientData is true. */
@@ -24,19 +24,19 @@ var u = 5, d = {
24
24
  },
25
25
  completion: {
26
26
  profile: "Profil (photo et description)",
27
- locationContacts: "Localisation et contact",
27
+ location: "Localisation",
28
+ contacts: "Contact",
28
29
  legalBanking: "Coordonnées légales et bancaires",
29
30
  sector: "Secteur d'activité",
30
- certificate: "Certificat",
31
- productInterest: "Intérêt produit"
31
+ certificate: "Certificat"
32
32
  }
33
33
  }, f = [
34
34
  "profile",
35
- "locationContacts",
35
+ "location",
36
+ "contacts",
36
37
  "legalBanking",
37
38
  "sector",
38
- "certificate",
39
- "productInterest"
39
+ "certificate"
40
40
  ];
41
41
  function p(e) {
42
42
  return e.toFixed(1).replace(".", ",");
@@ -1 +1 @@
1
- {"version":3,"file":"SupplierRatingBreakdown.js","names":[],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'locationContacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n | 'productInterest'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n locationContacts: 'Localisation et contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n productInterest: 'Intérêt produit',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'locationContacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n 'productInterest',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${days.toFixed(1).replace('.', ',')} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\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AkB;MACxC,CAAA,GACN,kBAAC,GAAD;OAAM,IAAG;OAAO,UAAS;OAAU,OAAO,IAAO,aAAa;iBAC3D,EAAO,WAAW;MACf,CAAA,CACA;QAPK,CAOL;IAEZ,CAAC,CACK;;GAEP,EAAO,UACN,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAAC,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;cACpE,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
1
+ {"version":3,"file":"SupplierRatingBreakdown.js","names":[],"sources":["../../../src/components/supplier-rating-badge/SupplierRatingBreakdown.tsx"],"sourcesContent":["import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/outline'\nimport { Box, HStack, VStack } from '@stokelp/styled-system/jsx'\n\nimport { Icon, Text } from '~/components'\n\nexport const SUPPLIER_RATING_MAX = 5\n\nexport type SupplierRatingComponentKey = 'responseRate' | 'responseDelay' | 'completion'\n\nexport type SupplierRatingCompletionKey =\n | 'profile'\n | 'location'\n | 'contacts'\n | 'legalBanking'\n | 'sector'\n | 'certificate'\n\nexport type SupplierRatingCompletion = Record<SupplierRatingCompletionKey, boolean>\n\nexport type SupplierRating = {\n /** Overall note out of 5. Absent when insufficientData is true. */\n overall?: number\n /** Response-rate sub-score, 0..1 (note calc only). Absent when insufficientData is true. */\n responseRateScore?: number\n /** Response-delay sub-score, 0..1 (note calc + colours the delay row). Absent when insufficientData is true. */\n responseDelayScore?: number\n /** Average response delay in MINUTES, for display. Absent when insufficientData is true. */\n responseDelayMinutes?: number\n /** Account-completion sub-score, 0..1. Always present. */\n completionScore: number\n /** True when the supplier has too few interactions for a reliable note. */\n insufficientData: boolean\n /** Completion checklist shown in the breakdown. */\n completion: SupplierRatingCompletion\n}\n\nexport type SupplierRatingLabels = {\n title: string\n /** Neutral state shown instead of a note when data is insufficient. */\n insufficientData: string\n /** Section heading above the sub-scores. */\n componentsTitle: string\n /** Section heading above the completion checklist. */\n completionTitle: string\n /** Value shown when a component has no data yet (e.g. \"—\"). */\n notAvailable: string\n /** Unit suffixes for the average response-delay value. */\n units: { minutes: string; hours: string; days: string }\n components: Record<SupplierRatingComponentKey, string>\n completion: Record<SupplierRatingCompletionKey, string>\n footer?: string\n}\n\nexport const DEFAULT_SUPPLIER_RATING_LABELS: SupplierRatingLabels = {\n title: 'Note fournisseur',\n insufficientData: 'Non noté',\n componentsTitle: 'Détail de la note',\n completionTitle: 'Complétion du compte',\n notAvailable: '—',\n units: { minutes: 'min', hours: 'h', days: 'j' },\n components: {\n responseRate: 'Taux de réponse',\n responseDelay: 'Délai de réponse',\n completion: 'Complétion du compte',\n },\n completion: {\n profile: 'Profil (photo et description)',\n location: 'Localisation',\n contacts: 'Contact',\n legalBanking: 'Coordonnées légales et bancaires',\n sector: \"Secteur d'activité\",\n certificate: 'Certificat',\n },\n}\n\nconst COMPLETION_ORDER: SupplierRatingCompletionKey[] = [\n 'profile',\n 'location',\n 'contacts',\n 'legalBanking',\n 'sector',\n 'certificate',\n]\n\nexport function formatOverall(overall: number): string {\n return overall.toFixed(1).replace('.', ',')\n}\n\n/** Average response delay: minutes → \"45 min\" / \"18 h\" / \"2,5 j\". */\nexport function formatResponseDelay(minutes: number, units: SupplierRatingLabels['units']): string {\n if (minutes < 60) return `${Math.round(minutes)} ${units.minutes}`\n const hours = minutes / 60\n if (hours < 48) return `${Math.round(hours)} ${units.hours}`\n const days = hours / 24\n return `${days.toFixed(1).replace('.', ',')} ${units.days}`\n}\n\nexport function getHeadlineColor(overall: number): string {\n const ratio = overall / SUPPLIER_RATING_MAX\n if (ratio >= 0.7) return '#3B6D11'\n if (ratio >= 0.4) return '#854F0B'\n return '#A32D2D'\n}\n\nfunction getBarColor(ratioPercent: number): string {\n if (ratioPercent >= 70) return '#639922'\n if (ratioPercent >= 40) return '#BA7517'\n return '#E24B4A'\n}\n\ntype ComponentRow = {\n key: SupplierRatingComponentKey\n value: string\n /** 0..100 bar fill, or null when there is no data. */\n barPercent: number | null\n /** Bar/value colour, or undefined for the neutral (no-data) state. */\n color?: string\n}\n\ntype SupplierRatingBreakdownProps = {\n rating: SupplierRating\n /** Original response rate (0..100), displayed as the \"Taux de réponse\" value. */\n responseRate?: number\n labels?: Partial<SupplierRatingLabels>\n}\n\nexport const SupplierRatingBreakdown = ({ rating, responseRate, labels: labelsProp }: SupplierRatingBreakdownProps) => {\n const labels: SupplierRatingLabels = {\n ...DEFAULT_SUPPLIER_RATING_LABELS,\n ...labelsProp,\n units: { ...DEFAULT_SUPPLIER_RATING_LABELS.units, ...labelsProp?.units },\n components: { ...DEFAULT_SUPPLIER_RATING_LABELS.components, ...labelsProp?.components },\n completion: { ...DEFAULT_SUPPLIER_RATING_LABELS.completion, ...labelsProp?.completion },\n }\n\n const hasResponseRate = responseRate != null\n const hasDelay = rating.responseDelayMinutes != null\n const delayPercent = rating.responseDelayScore != null ? Math.round(rating.responseDelayScore * 100) : null\n const completionPercent = Math.round(rating.completionScore * 100)\n\n const rows: ComponentRow[] = [\n {\n key: 'responseRate',\n value: hasResponseRate ? `${Math.round(responseRate)} %` : labels.notAvailable,\n barPercent: hasResponseRate ? Math.round(responseRate) : null,\n color: hasResponseRate ? getBarColor(Math.round(responseRate)) : undefined,\n },\n {\n key: 'responseDelay',\n value: hasDelay ? formatResponseDelay(rating.responseDelayMinutes as number, labels.units) : labels.notAvailable,\n barPercent: delayPercent,\n color: delayPercent != null ? getBarColor(delayPercent) : undefined,\n },\n {\n key: 'completion',\n value: `${completionPercent} %`,\n barPercent: completionPercent,\n color: getBarColor(completionPercent),\n },\n ]\n\n return (\n <Box\n bg=\"white\"\n borderRadius=\"radius-8\"\n p=\"space-16\"\n minW=\"240px\"\n maxW=\"260px\"\n css={{ '& *': { fontFamily: 'inherit' } }}\n >\n <HStack justify=\"space-between\" alignItems=\"baseline\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.md\" fontWeight=\"bold\">\n {labels.title}\n </Text>\n {rating.insufficientData || rating.overall == null ? (\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"medium\" color=\"grey.400\">\n {labels.insufficientData}\n </Text>\n ) : (\n <Text as=\"span\" fontSize=\"body.lg\" fontWeight=\"medium\" style={{ color: getHeadlineColor(rating.overall) }}>\n {formatOverall(rating.overall)} / {SUPPLIER_RATING_MAX} ★\n </Text>\n )}\n </HStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-8\" mb=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.componentsTitle}\n </Text>\n {rows.map(row => (\n <VStack key={row.key} alignItems=\"stretch\" gap=\"space-2\">\n <HStack justify=\"space-between\" alignItems=\"baseline\" gap=\"space-8\">\n <Text as=\"span\" fontSize=\"body.sm\" color=\"grey.500\">\n {labels.components[row.key]}\n </Text>\n <Text\n as=\"span\"\n fontSize=\"body.sm\"\n fontWeight=\"medium\"\n whiteSpace=\"nowrap\"\n style={{ color: row.color }}\n color={row.color ? undefined : 'grey.300'}\n >\n {row.value}\n </Text>\n </HStack>\n <Box h=\"3px\" bg=\"grey.100\" borderRadius=\"full\" overflow=\"hidden\">\n <Box\n h=\"100%\"\n borderRadius=\"full\"\n style={{\n width: row.barPercent != null ? `${row.barPercent}%` : '0%',\n background: row.color ?? 'transparent',\n }}\n />\n </Box>\n </VStack>\n ))}\n </VStack>\n\n <Box h=\"1px\" bg=\"grey.100\" mb=\"space-8\" />\n\n <VStack alignItems=\"stretch\" gap=\"space-4\">\n <Text as=\"span\" fontSize=\"body.sm\" fontWeight=\"bold\" color=\"grey.400\">\n {labels.completionTitle}\n </Text>\n {COMPLETION_ORDER.map(key => {\n const done = rating.completion[key]\n return (\n <HStack key={key} alignItems=\"center\" gap=\"space-8\">\n <Icon size=\"sm\" color={done ? 'success.500' : 'grey.300'} flexShrink=\"0\">\n {done ? <CheckCircleIcon /> : <XCircleIcon />}\n </Icon>\n <Text as=\"span\" fontSize=\"body.sm\" color={done ? 'grey.500' : 'grey.400'}>\n {labels.completion[key]}\n </Text>\n </HStack>\n )\n })}\n </VStack>\n\n {labels.footer && (\n <>\n <Box h=\"1px\" bg=\"grey.100\" mt=\"space-8\" mb=\"space-8\" />\n <Text as=\"span\" fontSize=\"9px\" color=\"grey.300\" style={{ lineHeight: 1 }}>\n {labels.footer}\n </Text>\n </>\n )}\n </Box>\n )\n}\n"],"mappings":";;;;;;;;AAKA,IAAa,IAAsB,GAgDtB,IAAuD;CAClE,OAAO;CACP,kBAAkB;CAClB,iBAAiB;CACjB,iBAAiB;CACjB,cAAc;CACd,OAAO;EAAE,SAAS;EAAO,OAAO;EAAK,MAAM;CAAI;CAC/C,YAAY;EACV,cAAc;EACd,eAAe;EACf,YAAY;CACd;CACA,YAAY;EACV,SAAS;EACT,UAAU;EACV,UAAU;EACV,cAAc;EACd,QAAQ;EACR,aAAa;CACf;AACF,GAEM,IAAkD;CACtD;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAgB,EAAc,GAAyB;CACrD,OAAO,EAAQ,QAAQ,CAAC,EAAE,QAAQ,KAAK,GAAG;AAC5C;AAGA,SAAgB,EAAoB,GAAiB,GAA8C;CACjG,IAAI,IAAU,IAAI,OAAO,GAAG,KAAK,MAAM,CAAO,EAAE,GAAG,EAAM;CACzD,IAAM,IAAQ,IAAU;CAGxB,OAFI,IAAQ,KAAW,GAAG,KAAK,MAAM,CAAK,EAAE,GAAG,EAAM,UAE9C,IADM,IAAQ,IACN,QAAQ,CAAC,EAAE,QAAQ,KAAK,GAAG,EAAE,GAAG,EAAM;AACvD;AAEA,SAAgB,EAAiB,GAAyB;CACxD,IAAM,IAAQ,IAAA;CAGd,OAFI,KAAS,KAAY,YACrB,KAAS,KAAY,YAClB;AACT;AAEA,SAAS,EAA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,GAAD;IAAQ,YAAW;IAAU,KAAI;cAAjC,CACE,kBAAC,GAAD;KAAM,IAAG;KAAO,UAAS;KAAU,YAAW;KAAO,OAAM;eACxD,EAAO;IACJ,CAAA,GACL,EAAiB,KAAI,MAAO;KAC3B,IAAM,IAAO,EAAO,WAAW;KAC/B,OACE,kBAAC,GAAD;MAAkB,YAAW;MAAS,KAAI;gBAA1C,CACE,kBAAC,GAAD;OAAM,MAAK;OAAK,OAAO,IAAO,gBAAgB;OAAY,YAAW;iBAC3D,EAAP,IAAQ,IAAsB,GAAvB,CAAkB,CAAkB;MACxC,CAAA,GACN,kBAAC,GAAD;OAAM,IAAG;OAAO,UAAS;OAAU,OAAO,IAAO,aAAa;iBAC3D,EAAO,WAAW;MACf,CAAA,CACA;QAPK,CAOL;IAEZ,CAAC,CACK;;GAEP,EAAO,UACN,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;IAAK,GAAE;IAAM,IAAG;IAAW,IAAG;IAAU,IAAG;GAAW,CAAA,GACtD,kBAAC,GAAD;IAAM,IAAG;IAAO,UAAS;IAAM,OAAM;IAAW,OAAO,EAAE,YAAY,EAAE;cACpE,EAAO;GACJ,CAAA,CACN,EAAA,CAAA;EAED;;AAET"}
@@ -0,0 +1,2 @@
1
+ "use client";let e=require("react");var t=`[data-scope="dialog"][data-state="open"],[data-scope="popover"][data-state="open"]`,n=[`overflow`,`padding-right`,`padding-left`,`position`,`top`,`left`,`right`];function r(){let e=document.body;if(!document.querySelector(t)){if(e.style.pointerEvents===`none`&&(e.style.pointerEvents=``),e.hasAttribute(`data-inert`)&&e.removeAttribute(`data-inert`),e.hasAttribute(`data-scroll-lock`)){e.removeAttribute(`data-scroll-lock`);for(let t of n)e.style.removeProperty(t);document.documentElement.style.removeProperty(`--scrollbar-width`),document.querySelectorAll(`[data-aria-hidden]`).forEach(e=>{e.removeAttribute(`aria-hidden`),e.removeAttribute(`data-aria-hidden`)})}e.getAttribute(`style`)===``&&e.removeAttribute(`style`)}}function i(t){(0,e.useEffect)(()=>{if(process.env.NODE_ENV===`production`)return;let e=()=>window.setTimeout(r,350);return t||e(),()=>{e()}},[t])}exports.useReleaseStaleOverlayLocks=i;
2
+ //# sourceMappingURL=overlay-lock-cleanup.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-lock-cleanup.cjs","names":[],"sources":["../../src/utils/overlay-lock-cleanup.ts"],"sourcesContent":["import { useEffect } from 'react'\n\n// Any overlay that is still genuinely open owns its body locks; only clean up\n// when none remain. Dialogs and drawers both render `data-scope=\"dialog\"` (the\n// drawer is built on the dialog machine); popovers can lock scroll too.\nconst OPEN_OVERLAY_SELECTOR = '[data-scope=\"dialog\"][data-state=\"open\"],[data-scope=\"popover\"][data-state=\"open\"]'\nconst LOCKED_BODY_STYLES = ['overflow', 'padding-right', 'padding-left', 'position', 'top', 'left', 'right']\n\n// DEV-ONLY safety net. In React StrictMode (Next.js dev) the overlay effects are\n// double-invoked, which — combined with a consumer that force-unmounts the Root\n// on close (`{open && <Dialog open={open} />}`, `if (!open) return null`) — can\n// leave two independent body locks behind, because the Zag machine is torn out\n// before its own cleanup runs cleanly:\n// - @zag-js/dismissable: `pointer-events: none` + `data-inert` on <body>.\n// - @zag-js/remove-scroll: `data-scroll-lock` + `overflow: hidden` (plus\n// padding / position / `--scrollbar-width`) on <body>, and `aria-hidden` on\n// sibling elements. preventBodyScroll is re-entrancy guarded (`if (locked)\n// return`, no cleanup returned), so once it leaks no later overlay can\n// release it and the page stays unscrollable until a full reload.\n// A production build runs the effects once and its cleanup releases the locks\n// normally, so this is gated to dev (see useReleaseStaleOverlayLocks) and DCE'd\n// in prod. Idempotent and guarded: it never touches a lock while an overlay is\n// open, so legitimate locks are left alone.\nexport function releaseStaleOverlayLocks() {\n const body = document.body\n if (document.querySelector(OPEN_OVERLAY_SELECTOR)) return\n\n // @zag-js/dismissable leak.\n if (body.style.pointerEvents === 'none') body.style.pointerEvents = ''\n if (body.hasAttribute('data-inert')) body.removeAttribute('data-inert')\n\n // @zag-js/remove-scroll leak.\n if (body.hasAttribute('data-scroll-lock')) {\n body.removeAttribute('data-scroll-lock')\n for (const prop of LOCKED_BODY_STYLES) body.style.removeProperty(prop)\n document.documentElement.style.removeProperty('--scrollbar-width')\n document.querySelectorAll('[data-aria-hidden]').forEach(el => {\n el.removeAttribute('aria-hidden')\n el.removeAttribute('data-aria-hidden')\n })\n }\n\n if (body.getAttribute('style') === '') body.removeAttribute('style')\n}\n\n// Schedules the cleanup whenever the overlay closes AND on unmount, covering\n// both the normal close path (Content stays mounted, `open` flips to false) and\n// the force-unmount path (consumer yanks the Root while it is still open, so\n// `open` never transitions within a mounted Content). React does NOT cancel a\n// setTimeout queued from an effect cleanup, so the restore still runs after\n// Content unmounts. The delay clears the exit transition; the open-overlay guard\n// inside releaseStaleOverlayLocks keeps it from clobbering a live overlay.\nexport function useReleaseStaleOverlayLocks(open: boolean | undefined) {\n useEffect(() => {\n // Dev-only: production builds don't hit the StrictMode double-invoke that\n // leaks the locks, and the check is DCE'd by consumer bundlers in prod.\n if (process.env.NODE_ENV === 'production') return\n const schedule = () => window.setTimeout(releaseStaleOverlayLocks, 350)\n if (!open) schedule()\n return () => {\n schedule()\n }\n }, [open])\n}\n"],"mappings":"oCAKA,IAAM,EAAwB,qFACxB,EAAqB,CAAC,WAAY,gBAAiB,eAAgB,WAAY,MAAO,OAAQ,OAAO,EAiB3G,SAAgB,GAA2B,CACzC,IAAM,EAAO,SAAS,KAClB,aAAS,cAAc,CAAqB,EAOhD,IAJI,EAAK,MAAM,gBAAkB,SAAQ,EAAK,MAAM,cAAgB,IAChE,EAAK,aAAa,YAAY,GAAG,EAAK,gBAAgB,YAAY,EAGlE,EAAK,aAAa,kBAAkB,EAAG,CACzC,EAAK,gBAAgB,kBAAkB,EACvC,IAAK,IAAM,KAAQ,EAAoB,EAAK,MAAM,eAAe,CAAI,EACrE,SAAS,gBAAgB,MAAM,eAAe,mBAAmB,EACjE,SAAS,iBAAiB,oBAAoB,EAAE,QAAQ,GAAM,CAC5D,EAAG,gBAAgB,aAAa,EAChC,EAAG,gBAAgB,kBAAkB,CACvC,CAAC,CACH,CAEI,EAAK,aAAa,OAAO,IAAM,IAAI,EAAK,gBAAgB,OAAO,CAFnE,CAGF,CASA,SAAgB,EAA4B,EAA2B,EACrE,EAAA,EAAA,eAAgB,CAGd,GAAA,QAAA,IAAA,WAA6B,aAAc,OAC3C,IAAM,MAAiB,OAAO,WAAW,EAA0B,GAAG,EAEtE,OADK,GAAM,EAAS,MACP,CACX,EAAS,CACX,CACF,EAAG,CAAC,CAAI,CAAC,CACX"}
@@ -0,0 +1,2 @@
1
+ export declare function releaseStaleOverlayLocks(): void;
2
+ export declare function useReleaseStaleOverlayLocks(open: boolean | undefined): void;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { useEffect as e } from "react";
3
+ //#region src/utils/overlay-lock-cleanup.ts
4
+ var t = "[data-scope=\"dialog\"][data-state=\"open\"],[data-scope=\"popover\"][data-state=\"open\"]", n = [
5
+ "overflow",
6
+ "padding-right",
7
+ "padding-left",
8
+ "position",
9
+ "top",
10
+ "left",
11
+ "right"
12
+ ];
13
+ function r() {
14
+ let e = document.body;
15
+ if (!document.querySelector(t)) {
16
+ if (e.style.pointerEvents === "none" && (e.style.pointerEvents = ""), e.hasAttribute("data-inert") && e.removeAttribute("data-inert"), e.hasAttribute("data-scroll-lock")) {
17
+ e.removeAttribute("data-scroll-lock");
18
+ for (let t of n) e.style.removeProperty(t);
19
+ document.documentElement.style.removeProperty("--scrollbar-width"), document.querySelectorAll("[data-aria-hidden]").forEach((e) => {
20
+ e.removeAttribute("aria-hidden"), e.removeAttribute("data-aria-hidden");
21
+ });
22
+ }
23
+ e.getAttribute("style") === "" && e.removeAttribute("style");
24
+ }
25
+ }
26
+ function i(t) {
27
+ e(() => {
28
+ if (process.env.NODE_ENV === "production") return;
29
+ let e = () => window.setTimeout(r, 350);
30
+ return t || e(), () => {
31
+ e();
32
+ };
33
+ }, [t]);
34
+ }
35
+ //#endregion
36
+ export { i as useReleaseStaleOverlayLocks };
37
+
38
+ //# sourceMappingURL=overlay-lock-cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-lock-cleanup.js","names":[],"sources":["../../src/utils/overlay-lock-cleanup.ts"],"sourcesContent":["import { useEffect } from 'react'\n\n// Any overlay that is still genuinely open owns its body locks; only clean up\n// when none remain. Dialogs and drawers both render `data-scope=\"dialog\"` (the\n// drawer is built on the dialog machine); popovers can lock scroll too.\nconst OPEN_OVERLAY_SELECTOR = '[data-scope=\"dialog\"][data-state=\"open\"],[data-scope=\"popover\"][data-state=\"open\"]'\nconst LOCKED_BODY_STYLES = ['overflow', 'padding-right', 'padding-left', 'position', 'top', 'left', 'right']\n\n// DEV-ONLY safety net. In React StrictMode (Next.js dev) the overlay effects are\n// double-invoked, which — combined with a consumer that force-unmounts the Root\n// on close (`{open && <Dialog open={open} />}`, `if (!open) return null`) — can\n// leave two independent body locks behind, because the Zag machine is torn out\n// before its own cleanup runs cleanly:\n// - @zag-js/dismissable: `pointer-events: none` + `data-inert` on <body>.\n// - @zag-js/remove-scroll: `data-scroll-lock` + `overflow: hidden` (plus\n// padding / position / `--scrollbar-width`) on <body>, and `aria-hidden` on\n// sibling elements. preventBodyScroll is re-entrancy guarded (`if (locked)\n// return`, no cleanup returned), so once it leaks no later overlay can\n// release it and the page stays unscrollable until a full reload.\n// A production build runs the effects once and its cleanup releases the locks\n// normally, so this is gated to dev (see useReleaseStaleOverlayLocks) and DCE'd\n// in prod. Idempotent and guarded: it never touches a lock while an overlay is\n// open, so legitimate locks are left alone.\nexport function releaseStaleOverlayLocks() {\n const body = document.body\n if (document.querySelector(OPEN_OVERLAY_SELECTOR)) return\n\n // @zag-js/dismissable leak.\n if (body.style.pointerEvents === 'none') body.style.pointerEvents = ''\n if (body.hasAttribute('data-inert')) body.removeAttribute('data-inert')\n\n // @zag-js/remove-scroll leak.\n if (body.hasAttribute('data-scroll-lock')) {\n body.removeAttribute('data-scroll-lock')\n for (const prop of LOCKED_BODY_STYLES) body.style.removeProperty(prop)\n document.documentElement.style.removeProperty('--scrollbar-width')\n document.querySelectorAll('[data-aria-hidden]').forEach(el => {\n el.removeAttribute('aria-hidden')\n el.removeAttribute('data-aria-hidden')\n })\n }\n\n if (body.getAttribute('style') === '') body.removeAttribute('style')\n}\n\n// Schedules the cleanup whenever the overlay closes AND on unmount, covering\n// both the normal close path (Content stays mounted, `open` flips to false) and\n// the force-unmount path (consumer yanks the Root while it is still open, so\n// `open` never transitions within a mounted Content). React does NOT cancel a\n// setTimeout queued from an effect cleanup, so the restore still runs after\n// Content unmounts. The delay clears the exit transition; the open-overlay guard\n// inside releaseStaleOverlayLocks keeps it from clobbering a live overlay.\nexport function useReleaseStaleOverlayLocks(open: boolean | undefined) {\n useEffect(() => {\n // Dev-only: production builds don't hit the StrictMode double-invoke that\n // leaks the locks, and the check is DCE'd by consumer bundlers in prod.\n if (process.env.NODE_ENV === 'production') return\n const schedule = () => window.setTimeout(releaseStaleOverlayLocks, 350)\n if (!open) schedule()\n return () => {\n schedule()\n }\n }, [open])\n}\n"],"mappings":";;;AAKA,IAAM,IAAwB,8FACxB,IAAqB;CAAC;CAAY;CAAiB;CAAgB;CAAY;CAAO;CAAQ;AAAO;AAiB3G,SAAgB,IAA2B;CACzC,IAAM,IAAO,SAAS;CAClB,cAAS,cAAc,CAAqB,GAOhD;MAJI,EAAK,MAAM,kBAAkB,WAAQ,EAAK,MAAM,gBAAgB,KAChE,EAAK,aAAa,YAAY,KAAG,EAAK,gBAAgB,YAAY,GAGlE,EAAK,aAAa,kBAAkB,GAAG;GACzC,EAAK,gBAAgB,kBAAkB;GACvC,KAAK,IAAM,KAAQ,GAAoB,EAAK,MAAM,eAAe,CAAI;GAErE,AADA,SAAS,gBAAgB,MAAM,eAAe,mBAAmB,GACjE,SAAS,iBAAiB,oBAAoB,EAAE,SAAQ,MAAM;IAE5D,AADA,EAAG,gBAAgB,aAAa,GAChC,EAAG,gBAAgB,kBAAkB;GACvC,CAAC;EACH;EAEA,AAAI,EAAK,aAAa,OAAO,MAAM,MAAI,EAAK,gBAAgB,OAAO;CAFnE;AAGF;AASA,SAAgB,EAA4B,GAA2B;CACrE,QAAgB;EAGd,IAAA,QAAA,IAAA,aAA6B,cAAc;EAC3C,IAAM,UAAiB,OAAO,WAAW,GAA0B,GAAG;EAEtE,OADK,KAAM,EAAS,SACP;GACX,EAAS;EACX;CACF,GAAG,CAAC,CAAI,CAAC;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stokelp/ui",
3
- "version": "2.118.0",
3
+ "version": "2.119.1",
4
4
  "description": "Stokelp UI React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",