@spark-ui/components 18.1.1 → 18.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DialogContent.styles-ClKRO43s.mjs → DialogContent.styles-BVyH8M3z.mjs} +5 -5
- package/dist/{DialogContent.styles-ClKRO43s.mjs.map → DialogContent.styles-BVyH8M3z.mjs.map} +1 -1
- package/dist/{DialogContent.styles-FnwXayCC.js → DialogContent.styles-Bh6DymkD.js} +2 -2
- package/dist/{DialogContent.styles-FnwXayCC.js.map → DialogContent.styles-Bh6DymkD.js.map} +1 -1
- package/dist/{FormFieldRequiredIndicator-DY3STDp1.js → FormFieldRequiredIndicator-BxZgeZ9H.js} +2 -2
- package/dist/{FormFieldRequiredIndicator-DY3STDp1.js.map → FormFieldRequiredIndicator-BxZgeZ9H.js.map} +1 -1
- package/dist/{FormFieldRequiredIndicator-COKYxTNs.mjs → FormFieldRequiredIndicator-CfE6AOta.mjs} +2 -2
- package/dist/{FormFieldRequiredIndicator-COKYxTNs.mjs.map → FormFieldRequiredIndicator-CfE6AOta.mjs.map} +1 -1
- package/dist/accordion/index.js +1 -1
- package/dist/accordion/index.js.map +1 -1
- package/dist/accordion/index.mjs +45 -50
- package/dist/accordion/index.mjs.map +1 -1
- package/dist/alert-dialog/AlertDialogAction.d.ts +1 -1
- package/dist/alert-dialog/AlertDialogCancel.d.ts +1 -1
- package/dist/alert-dialog/AlertDialogTrigger.d.ts +1 -1
- package/dist/alert-dialog/index.js +1 -1
- package/dist/alert-dialog/index.js.map +1 -1
- package/dist/alert-dialog/index.mjs +53 -56
- package/dist/alert-dialog/index.mjs.map +1 -1
- package/dist/avatar/index.js +1 -1
- package/dist/avatar/index.mjs +2 -2
- package/dist/badge/BadgeItem.styles.d.ts +1 -1
- package/dist/badge/index.js +1 -1
- package/dist/badge/index.mjs +13 -13
- package/dist/breadcrumb/index.js +1 -1
- package/dist/breadcrumb/index.mjs +1 -1
- package/dist/button/Button.styles.d.ts +1 -1
- package/dist/button/index.js +1 -1
- package/dist/button/index.mjs +1 -1
- package/dist/{button-D0s-21qo.js → button-3vvMrf1L.js} +2 -2
- package/dist/{button-D0s-21qo.js.map → button-3vvMrf1L.js.map} +1 -1
- package/dist/{button-DwLTXeJX.mjs → button-DBNjh3Bi.mjs} +76 -76
- package/dist/{button-DwLTXeJX.mjs.map → button-DBNjh3Bi.mjs.map} +1 -1
- package/dist/card/Backdrop.d.ts +1 -1
- package/dist/card/Card.styles.d.ts +1 -1
- package/dist/card/Content.styles.d.ts +1 -1
- package/dist/card/Type.d.ts +1 -1
- package/dist/card/index.js +1 -1
- package/dist/card/index.mjs +53 -53
- package/dist/carousel/index.js +1 -1
- package/dist/carousel/index.mjs +2 -2
- package/dist/checkbox/CheckboxInput.styles.d.ts +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/checkbox/index.mjs +1 -1
- package/dist/{checkbox-uSINHQYe.mjs → checkbox-BEo9AVSB.mjs} +26 -26
- package/dist/{checkbox-uSINHQYe.mjs.map → checkbox-BEo9AVSB.mjs.map} +1 -1
- package/dist/{checkbox-Cbewcw6G.js → checkbox-Cr60_jql.js} +2 -2
- package/dist/{checkbox-Cbewcw6G.js.map → checkbox-Cr60_jql.js.map} +1 -1
- package/dist/chip/Chip.styles.d.ts +1 -1
- package/dist/chip/index.js +1 -1
- package/dist/chip/index.mjs +86 -86
- package/dist/collapsible/index.js +1 -1
- package/dist/collapsible/index.js.map +1 -1
- package/dist/collapsible/index.mjs +18 -24
- package/dist/collapsible/index.mjs.map +1 -1
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.mjs +4 -4
- package/dist/dialog/DialogClose.d.ts +1 -1
- package/dist/dialog/DialogTrigger.d.ts +1 -1
- package/dist/dialog/index.js +1 -1
- package/dist/dialog/index.js.map +1 -1
- package/dist/dialog/index.mjs +14 -12
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/divider/index.js +1 -1
- package/dist/divider/index.mjs +26 -26
- package/dist/drawer/DrawerClose.d.ts +1 -1
- package/dist/drawer/DrawerTrigger.d.ts +1 -1
- package/dist/drawer/index.js +1 -1
- package/dist/drawer/index.js.map +1 -1
- package/dist/drawer/index.mjs +13 -11
- package/dist/drawer/index.mjs.map +1 -1
- package/dist/dropdown/index.js +1 -1
- package/dist/dropdown/index.mjs +2 -2
- package/dist/file-upload/index.js +1 -1
- package/dist/file-upload/index.mjs +3 -3
- package/dist/form-field/index.js +1 -1
- package/dist/form-field/index.mjs +1 -1
- package/dist/{form-field-B38U0zp8.js → form-field-DMHwopHt.js} +2 -2
- package/dist/{form-field-B38U0zp8.js.map → form-field-DMHwopHt.js.map} +1 -1
- package/dist/{form-field-DCKyhBmv.mjs → form-field-Doq4zLEX.mjs} +4 -4
- package/dist/{form-field-DCKyhBmv.mjs.map → form-field-Doq4zLEX.mjs.map} +1 -1
- package/dist/icon/Icon.styles.d.ts +1 -1
- package/dist/icon/index.js +1 -1
- package/dist/icon/index.mjs +1 -1
- package/dist/icon-CfEsla9z.js +2 -0
- package/dist/{icon-DY4l9nsc.js.map → icon-CfEsla9z.js.map} +1 -1
- package/dist/{icon-Bs-39J-H.mjs → icon-VM_Ys9Xn.mjs} +11 -11
- package/dist/{icon-Bs-39J-H.mjs.map → icon-VM_Ys9Xn.mjs.map} +1 -1
- package/dist/icon-button/index.js +1 -1
- package/dist/icon-button/index.mjs +1 -1
- package/dist/icon-button-B2TM0Xby.js +2 -0
- package/dist/{icon-button-DRFf308H.js.map → icon-button-B2TM0Xby.js.map} +1 -1
- package/dist/icon-button-CexCkoV0.mjs +29 -0
- package/dist/{icon-button-C1ThqdK1.mjs.map → icon-button-CexCkoV0.mjs.map} +1 -1
- package/dist/input/index.js +1 -1
- package/dist/input/index.mjs +1 -1
- package/dist/{input-BoxJZira.js → input-CADvgFpY.js} +2 -2
- package/dist/{input-BoxJZira.js.map → input-CADvgFpY.js.map} +1 -1
- package/dist/{input-Du9YSgAt.mjs → input-CmlNZ4Bo.mjs} +2 -2
- package/dist/{input-Du9YSgAt.mjs.map → input-CmlNZ4Bo.mjs.map} +1 -1
- package/dist/label/index.js +1 -1
- package/dist/label/index.mjs +1 -1
- package/dist/{label-DO48yda7.js → label-B085X0Sg.js} +2 -2
- package/dist/{label-DO48yda7.js.map → label-B085X0Sg.js.map} +1 -1
- package/dist/{label-RKaPen31.mjs → label-BqWu-wLT.mjs} +6 -6
- package/dist/{label-RKaPen31.mjs.map → label-BqWu-wLT.mjs.map} +1 -1
- package/dist/menu/MenuItemStyles.d.ts +1 -1
- package/dist/menu/index.js +1 -1
- package/dist/menu/index.js.map +1 -1
- package/dist/menu/index.mjs +131 -140
- package/dist/menu/index.mjs.map +1 -1
- package/dist/meter/MeterTrack.styles.d.ts +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/pagination/index.mjs +3 -3
- package/dist/popover/PopoverContent.styles.d.ts +1 -1
- package/dist/popover/index.js +1 -1
- package/dist/popover/index.mjs +1 -1
- package/dist/{popover-DVz0JvON.js → popover-B-mcHcLF.js} +2 -2
- package/dist/{popover-DVz0JvON.js.map → popover-B-mcHcLF.js.map} +1 -1
- package/dist/{popover-CGhSHQzb.mjs → popover-COqbFikI.mjs} +17 -17
- package/dist/{popover-CGhSHQzb.mjs.map → popover-COqbFikI.mjs.map} +1 -1
- package/dist/progress/ProgressIndicator.d.ts +1 -1
- package/dist/progress-tracker/index.js +1 -1
- package/dist/progress-tracker/index.mjs +1 -1
- package/dist/radio-group/RadioIndicator.styles.d.ts +1 -1
- package/dist/radio-group/RadioInput.styles.d.ts +1 -1
- package/dist/radio-group/index.js +1 -1
- package/dist/radio-group/index.mjs +37 -37
- package/dist/rating/index.js +1 -1
- package/dist/rating/index.mjs +2 -2
- package/dist/rating-display/index.js +1 -1
- package/dist/rating-display/index.mjs +1 -1
- package/dist/scrolling-list/index.js +1 -1
- package/dist/scrolling-list/index.mjs +3 -3
- package/dist/select/index.js +1 -1
- package/dist/select/index.mjs +1 -1
- package/dist/slider/SliderThumb.styles.d.ts +1 -1
- package/dist/slider/SliderTrack.styles.d.ts +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/slider/index.mjs +2 -2
- package/dist/slot/index.js +1 -1
- package/dist/slot/index.mjs +3 -3
- package/dist/spinner/Spinner.styles.d.ts +1 -1
- package/dist/spinner/index.js +1 -1
- package/dist/spinner/index.mjs +1 -1
- package/dist/{spinner-CmPypfJR.js → spinner-BAreohbs.js} +2 -2
- package/dist/{spinner-CmPypfJR.js.map → spinner-BAreohbs.js.map} +1 -1
- package/dist/{spinner-TfGcjNm3.mjs → spinner-DnrZf01S.mjs} +9 -9
- package/dist/{spinner-TfGcjNm3.mjs.map → spinner-DnrZf01S.mjs.map} +1 -1
- package/dist/stepper/index.js +1 -1
- package/dist/stepper/index.mjs +3 -3
- package/dist/switch/SwitchInput.d.ts +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/switch/index.js.map +1 -1
- package/dist/switch/index.mjs +43 -44
- package/dist/switch/index.mjs.map +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/index.mjs +3 -3
- package/dist/tabs/index.js +1 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +144 -153
- package/dist/tabs/index.mjs.map +1 -1
- package/dist/tag/Tag.styles.d.ts +1 -1
- package/dist/tag/index.js +1 -1
- package/dist/tag/index.mjs +37 -37
- package/dist/text-link/TextLink.d.ts +1 -1
- package/dist/textarea/index.js +1 -1
- package/dist/textarea/index.mjs +1 -1
- package/dist/toast/Toast.styles.d.ts +1 -1
- package/dist/toast/index.js +1 -1
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/index.mjs +4 -4
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toggle-group/index.js +1 -1
- package/dist/toggle-group/index.js.map +1 -1
- package/dist/toggle-group/index.mjs +16 -21
- package/dist/toggle-group/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/accordion/useRenderSlot.d.ts +0 -3
- package/dist/alert-dialog/useRenderSlot.d.ts +0 -3
- package/dist/collapsible/useRenderSlot.d.ts +0 -3
- package/dist/drawer/useRenderSlot.d.ts +0 -3
- package/dist/icon-DY4l9nsc.js +0 -2
- package/dist/icon-button-C1ThqdK1.mjs +0 -29
- package/dist/icon-button-DRFf308H.js +0 -2
- package/dist/menu/useRenderSlot.d.ts +0 -1
- package/dist/tabs/useRenderSlot.d.ts +0 -1
- package/dist/toast/useRenderSlot.d.ts +0 -3
- package/dist/toggle-group/useRenderSlot.d.ts +0 -1
- package/dist/useRenderSlot-5CPC9Lkj.mjs +0 -11
- package/dist/useRenderSlot-5CPC9Lkj.mjs.map +0 -1
- package/dist/useRenderSlot-DHV0CegV.js +0 -2
- package/dist/useRenderSlot-DHV0CegV.js.map +0 -1
package/dist/drawer/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../icon-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../icon-CfEsla9z.js"),t=require("../icon-button-B2TM0Xby.js");let n=require("@spark-ui/internal-utils"),r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/hooks/use-merge-refs"),s=require("@spark-ui/hooks/use-scroll-overflow"),c=require("@spark-ui/icons/Close"),l=require("@base-ui/react/dialog");var u=(0,i.createContext)(null),d=({children:e,withFade:t=!1})=>(0,a.jsx)(u,{value:{withFade:t},children:e}),f=()=>{let e=(0,i.useContext)(u);if(!e)throw Error(`useDrawer must be used within a Drawer provider`);return e},p=({onOpenChange:e,withFade:t=!1,...n})=>{let r=e?(t,n)=>{e(t)}:void 0;return(0,a.jsx)(d,{withFade:t,children:(0,a.jsx)(l.Dialog.Root,{"data-spark-component":`drawer`,onOpenChange:r,...n})})};p.displayName=`Drawer.Root`;var m=(0,r.cva)([`grow`,`overflow-y-auto`,`outline-hidden`,`focus-visible:u-outline`],{variants:{inset:{true:``,false:`px-xl py-lg`}},defaultVariants:{inset:!1}}),h=({children:e,inset:t=!1,className:n,ref:r,...c})=>{let l=(0,i.useRef)(null),u=(0,o.useMergeRefs)(r,l),{withFade:d}=f(),{overflow:p}=(0,s.useScrollOverflow)(l);return(0,a.jsx)(`div`,{"data-spark-component":`drawer-body`,ref:u,className:m({inset:t,className:n}),style:{...d&&{maskImage:`linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))`,maskSize:`100% calc(100% + ${p.top?`0px`:`44px`} + ${p.bottom?`0px`:`44px`})`,maskPosition:`0 ${p.top?`0px`:`-44px`}`}},...c,children:e})};h.displayName=`Drawer.Body`;var g=({asChild:e=!1,children:t,...r})=>{let{renderProp:i,innerChildren:o}=(0,n.createRenderSlot)(e,t);return(0,a.jsx)(l.Dialog.Close,{"data-spark-component":`drawer-close`,render:i,...r,children:o})};g.displayName=`Drawer.Close`;var _=({"aria-label":n,className:i,size:o=`md`,intent:s=`neutral`,design:l=`ghost`,children:u=(0,a.jsx)(c.Close,{}),ref:d,...f})=>(0,a.jsx)(g,{"data-spark-component":`drawer-close-button`,ref:d,className:(0,r.cx)([`absolute`,`top-sm`,`right-xl`],i),asChild:!0,...f,children:(0,a.jsx)(t.t,{intent:s,size:o,design:l,"aria-label":n,children:(0,a.jsx)(e.t,{children:u})})});_.displayName=`Drawer.CloseButton`;var v=(0,r.cva)([`fixed z-modal flex flex-col bg-surface shadow-md`,`data-open:animation-duration-400 data-closed:animation-duration-200`,`data-nested-dialog-open:after:pointer-events-none`,`after:bg-transparent`,`after:transition-all`,`after:duration-200`,`data-nested-dialog-open:after:inset-0`,`data-nested-dialog-open:after:absolute`,`data-nested-dialog-open:after:rounded-[inherit]`,`data-nested-dialog-open:after:bg-overlay/dim-3`],{variants:{size:{sm:``,md:``,lg:``,fluid:``,fullscreen:`h-screen w-screen`},side:{right:[`inset-y-0 right-0`,`data-open:animate-slide-in-right `,`data-closed:animate-slide-out-right`],left:[`inset-y-0 left-0`,`data-open:animate-slide-in-left`,`data-closed:animate-slide-out-left`],top:[`top-0 left-0`,`w-screen`,`data-open:animate-slide-in-top`,`data-closed:animate-slide-out-top`],bottom:[`bottom-0 left-0`,`w-screen`,`data-open:animate-slide-in-bottom`,`data-closed:animate-slide-out-bottom`]}},compoundVariants:[{side:[`right`,`left`],size:`sm`,class:[`w-sz-480`,`max-w-full`]},{side:[`right`,`left`],size:`md`,class:[`w-sz-672`,`max-w-full`]},{side:[`right`,`left`],size:`lg`,class:[`w-sz-864`,`max-w-full`]},{side:[`left`,`right`],size:`fluid`,class:[`w-auto`,`max-w-full`]},{side:[`top`,`bottom`],size:`sm`,class:[`h-sz-480`,`max-h-full`]},{side:[`top`,`bottom`],size:`md`,class:[`h-sz-672`,`max-h-full`]},{side:[`top`,`bottom`],size:`lg`,class:[`h-sz-864`,`max-h-full`]},{side:[`top`,`bottom`],size:`fluid`,class:[`h-auto`,`max-h-full`]}],defaultVariants:{side:`right`,size:`md`}}),y=({className:e,size:t=`md`,side:n=`right`,ref:i,...o})=>(0,a.jsx)(l.Dialog.Popup,{ref:i,"data-spark-component":`drawer-content`,role:`dialog`,className:i=>(0,r.cx)(v({size:t,side:n,className:typeof e==`function`?e(i):e})),...o});y.displayName=`Drawer.Content`;var b=e=>(0,a.jsx)(l.Dialog.Description,{"data-spark-component":`drawer-description`,...e});b.displayName=`Drawer.Description`;var x=({className:e,ref:t,...n})=>(0,a.jsx)(`footer`,{"data-spark-component":`drawer-footer`,ref:t,className:(0,r.cx)([`px-xl`,`py-lg`],e),...n});x.displayName=`Drawer.Footer`;var S=({children:e,className:t,ref:n,...i})=>(0,a.jsx)(`header`,{"data-spark-component":`drawer-header`,ref:n,className:(0,r.cx)([`px-xl`,`py-lg`],t),...i,children:e});S.displayName=`Dialog.Header`;var C=({className:e,...t})=>(0,a.jsx)(l.Dialog.Backdrop,{"data-spark-component":`drawer-overlay`,className:t=>(0,r.cx)(`z-overlay fixed top-0 left-0 h-screen w-screen`,`bg-overlay/dim-1`,`data-starting-style:animate-fade-in`,`data-ending-style:animate-fade-out`,typeof e==`function`?e(t):e),...t});C.displayName=`Drawer.Overlay`;var w=({className:e,...t})=>(0,a.jsx)(l.Dialog.Portal,{"data-spark-component":`drawer-portal`,className:(0,r.cx)(e,`z-modal absolute`),...t});w.displayName=`Drawer.Portal`;var T=({className:e,...t})=>(0,a.jsx)(l.Dialog.Title,{"data-spark-component":`drawer-title`,className:(0,r.cx)(`text-headline-2 text-on-surface`,e),...t});T.displayName=`Drawer.Title`;var E=({asChild:e=!1,children:t,...r})=>{let{renderProp:i,innerChildren:o}=(0,n.createRenderSlot)(e,t);return(0,a.jsx)(l.Dialog.Trigger,{"data-spark-component":`drawer-trigger`,render:i,...r,children:o})};E.displayName=`Drawer.Trigger`;var D=Object.assign(p,{Trigger:E,Portal:w,Overlay:C,Content:y,Header:S,Body:h,Footer:x,Close:g,CloseButton:_,Title:T,Description:b});D.displayName=`Drawer`,E.displayName=`Drawer.Trigger`,w.displayName=`Drawer.Portal`,C.displayName=`Drawer.Overlay`,y.displayName=`Drawer.Content`,S.displayName=`Drawer.Header`,h.displayName=`Drawer.Body`,x.displayName=`Drawer.Footer`,g.displayName=`Drawer.Close`,_.displayName=`Drawer.CloseButton`,T.displayName=`Drawer.Title`,b.displayName=`Drawer.Description`,exports.Drawer=D;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/drawer/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/drawer/DrawerContext.tsx","../../src/drawer/Drawer.tsx","../../src/drawer/DrawerBody.styles.ts","../../src/drawer/DrawerBody.tsx","../../src/drawer/DrawerClose.tsx","../../src/drawer/DrawerCloseButton.tsx","../../src/drawer/DrawerContent.styles.tsx","../../src/drawer/DrawerContent.tsx","../../src/drawer/DrawerDescription.tsx","../../src/drawer/DrawerFooter.tsx","../../src/drawer/DrawerHeader.tsx","../../src/drawer/DrawerOverlay.tsx","../../src/drawer/DrawerPortal.tsx","../../src/drawer/DrawerTitle.tsx","../../src/drawer/DrawerTrigger.tsx","../../src/drawer/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react'\n\nexport interface DrawerContextState {\n withFade: boolean\n}\n\nconst DrawerContext = createContext<DrawerContextState | null>(null)\n\nexport const DrawerProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n return (\n <DrawerContext\n value={{\n withFade,\n }}\n >\n {childrenProp}\n </DrawerContext>\n )\n}\n\nexport const useDrawer = () => {\n const context = useContext(DrawerContext)\n\n if (!context) {\n throw Error('useDrawer must be used within a Drawer provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DrawerProvider } from './DrawerContext'\n\nexport interface DrawerProps extends Omit<\n ComponentProps<typeof BaseDialog.Root>,\n 'onOpenChange' | 'render'\n> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the drawer should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Drawer = ({ onOpenChange, withFade = false, ...props }: DrawerProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DrawerProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"drawer\" onOpenChange={handleOpenChange} {...props} />\n </DrawerProvider>\n )\n}\n\nDrawer.displayName = 'Drawer.Root'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerBodyStyles = cva(\n ['grow', 'overflow-y-auto', 'outline-hidden', 'focus-visible:u-outline'],\n {\n variants: {\n inset: {\n true: '',\n false: 'px-xl py-lg',\n },\n },\n defaultVariants: {\n inset: false,\n },\n }\n)\n\nexport type DrawerBodyStylesProps = VariantProps<typeof drawerBodyStyles>\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { type ReactNode, Ref, useRef } from 'react'\n\nimport { drawerBodyStyles, type DrawerBodyStylesProps } from './DrawerBody.styles'\nimport { useDrawer } from './DrawerContext'\n\nexport interface DrawerBodyProps extends DrawerBodyStylesProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The scrollable body section of the drawer. Renders a <div> element.\n */\nexport const DrawerBody = ({\n children,\n inset = false,\n className,\n ref: forwardedRef,\n ...rest\n}: DrawerBodyProps) => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDrawer()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"drawer-body\"\n ref={ref}\n className={drawerBodyStyles({ inset, className })}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nDrawerBody.displayName = 'Drawer.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface DrawerCloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that closes the drawer. Renders a <button> element.\n */\nexport const DrawerClose = ({ asChild = false, ...props }: DrawerCloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"drawer-close\" render={renderSlot} {...props} />\n}\n\nDrawerClose.displayName = 'Drawer.Close'\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { DrawerClose, type DrawerCloseProps } from './DrawerClose'\n\nexport type DrawerCloseButtonProps = DrawerCloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\n/**\n * A styled close button positioned in the drawer header. Renders a <button> element.\n */\nexport const DrawerCloseButton = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: DrawerCloseButtonProps) => (\n <DrawerClose\n data-spark-component=\"drawer-close-button\"\n ref={ref}\n className={cx(['absolute', 'top-sm', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </DrawerClose>\n)\n\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerContentStyles = cva(\n [\n 'fixed z-modal flex flex-col bg-surface shadow-md',\n // Base UI uses data-open and data-closed for transitions\n 'data-open:animation-duration-400 data-closed:animation-duration-200',\n // Nested dialog effect\n 'data-nested-dialog-open:after:pointer-events-none',\n 'after:bg-transparent',\n 'after:transition-all',\n 'after:duration-200',\n 'data-nested-dialog-open:after:inset-0',\n 'data-nested-dialog-open:after:absolute',\n 'data-nested-dialog-open:after:rounded-[inherit]',\n 'data-nested-dialog-open:after:bg-overlay/dim-3',\n ],\n {\n variants: {\n size: {\n sm: '',\n md: '',\n lg: '',\n fluid: '',\n fullscreen: 'h-screen w-screen',\n },\n side: {\n right: [\n 'inset-y-0 right-0',\n 'data-open:animate-slide-in-right ',\n 'data-closed:animate-slide-out-right',\n ],\n left: [\n 'inset-y-0 left-0',\n 'data-open:animate-slide-in-left',\n 'data-closed:animate-slide-out-left',\n ],\n top: [\n 'top-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-top',\n 'data-closed:animate-slide-out-top',\n ],\n bottom: [\n 'bottom-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-bottom',\n 'data-closed:animate-slide-out-bottom',\n ],\n },\n },\n compoundVariants: [\n {\n side: ['right', 'left'],\n size: 'sm',\n class: ['w-sz-480', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'md',\n class: ['w-sz-672', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'lg',\n class: ['w-sz-864', 'max-w-full'],\n },\n {\n side: ['left', 'right'],\n size: 'fluid',\n class: ['w-auto', 'max-w-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'sm',\n class: ['h-sz-480', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'md',\n class: ['h-sz-672', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'lg',\n class: ['h-sz-864', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'fluid',\n class: ['h-auto', 'max-h-full'],\n },\n ],\n defaultVariants: {\n side: 'right',\n size: 'md',\n },\n }\n)\n\nexport type DrawerContentStylesProps = VariantProps<typeof drawerContentStyles>\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { drawerContentStyles, type DrawerContentStylesProps } from './DrawerContent.styles'\n\nexport interface DrawerContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>, DrawerContentStylesProps {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The popup element that contains the drawer content. Renders a <div> element.\n */\nexport const DrawerContent = ({\n className,\n size = 'md',\n side = 'right',\n ref,\n ...rest\n}: DrawerContentProps) => {\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"drawer-content\"\n role=\"dialog\"\n className={state =>\n cx(\n drawerContentStyles({\n size,\n side,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nDrawerContent.displayName = 'Drawer.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerDescriptionProps extends Omit<\n ComponentProps<typeof BaseDialog.Description>,\n 'render'\n> {\n ref?: Ref<HTMLParagraphElement>\n}\n\n/**\n * A paragraph with additional information about the drawer. Renders a <p> element.\n */\nexport const DrawerDescription = (props: DrawerDescriptionProps) => {\n return <BaseDialog.Description data-spark-component=\"drawer-description\" {...props} />\n}\n\nDrawerDescription.displayName = 'Drawer.Description'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, type ReactElement, Ref } from 'react'\n\nexport type DrawerFooterProps = ComponentPropsWithoutRef<'footer'> & {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The footer section of the drawer, typically containing action buttons. Renders a <footer> element.\n */\nexport const DrawerFooter = ({ className, ref, ...rest }: DrawerFooterProps): ReactElement => (\n <footer\n data-spark-component=\"drawer-footer\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n />\n)\n\nDrawerFooter.displayName = 'Drawer.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface DrawerHeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The header section of the drawer. Renders a <header> element.\n */\nexport const DrawerHeader = ({\n children,\n className,\n ref,\n ...rest\n}: DrawerHeaderProps): ReactElement => (\n <header\n data-spark-component=\"drawer-header\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n >\n {children}\n </header>\n)\n\nDrawerHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerOverlayProps extends Omit<\n ComponentProps<typeof BaseDialog.Backdrop>,\n 'render'\n> {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The backdrop element that dims the rest of the page. Renders a <div> element.\n */\nexport const DrawerOverlay = ({ className, ...props }: DrawerOverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"drawer-overlay\"\n className={state =>\n cx(\n 'z-overlay fixed top-0 left-0 h-screen w-screen',\n 'bg-overlay/dim-1',\n // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nDrawerOverlay.displayName = 'Drawer.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type DrawerPortalProps = ComponentProps<typeof BaseDialog.Portal>\n\n/**\n * A portal that renders the drawer in a different part of the DOM. Renders a <div> element.\n */\nexport const DrawerPortal = ({ className, ...props }: DrawerPortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"drawer-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nDrawerPortal.displayName = 'Drawer.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTitleProps extends Omit<ComponentProps<typeof BaseDialog.Title>, 'render'> {\n ref?: Ref<HTMLHeadingElement>\n}\n\n/**\n * The title of the drawer, announced to assistive technology. Renders an <h2> element.\n */\nexport const DrawerTitle = ({ className, ...props }: DrawerTitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"drawer-title\"\n className={cx('text-headline-2 text-on-surface', className)}\n {...props}\n />\n )\n}\n\nDrawerTitle.displayName = 'Drawer.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface DrawerTriggerProps extends Omit<\n ComponentProps<typeof BaseDialog.Trigger>,\n 'render'\n> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that opens the drawer. Renders a <button> element.\n */\nexport const DrawerTrigger = ({ asChild = false, ...props }: DrawerTriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"drawer-trigger\" render={renderSlot} {...props} />\n}\n\nDrawerTrigger.displayName = 'Drawer.Trigger'\n","import { Drawer as Root } from './Drawer'\nimport { DrawerBody } from './DrawerBody'\nimport { DrawerClose } from './DrawerClose'\nimport { DrawerCloseButton } from './DrawerCloseButton'\nimport { DrawerContent } from './DrawerContent'\nimport { DrawerDescription } from './DrawerDescription' // aria-describedby\nimport { DrawerFooter } from './DrawerFooter'\nimport { DrawerHeader } from './DrawerHeader'\nimport { DrawerOverlay } from './DrawerOverlay'\nimport { DrawerPortal } from './DrawerPortal'\nimport { DrawerTitle } from './DrawerTitle'\nimport { DrawerTrigger } from './DrawerTrigger'\n\n/**\n * A panel that slides in from the edge of the screen, typically used for navigation or displaying additional content.\n */\nexport const Drawer: typeof Root & {\n Trigger: typeof DrawerTrigger\n Portal: typeof DrawerPortal\n Overlay: typeof DrawerOverlay\n Content: typeof DrawerContent\n Header: typeof DrawerHeader\n Body: typeof DrawerBody\n Footer: typeof DrawerFooter\n Close: typeof DrawerClose\n CloseButton: typeof DrawerCloseButton\n Title: typeof DrawerTitle\n Description: typeof DrawerDescription\n} = Object.assign(Root, {\n Trigger: DrawerTrigger,\n Portal: DrawerPortal,\n Overlay: DrawerOverlay,\n Content: DrawerContent,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n Close: DrawerClose,\n CloseButton: DrawerCloseButton,\n Title: DrawerTitle,\n Description: DrawerDescription,\n})\n\nDrawer.displayName = 'Drawer'\nDrawerTrigger.displayName = 'Drawer.Trigger'\nDrawerPortal.displayName = 'Drawer.Portal'\nDrawerOverlay.displayName = 'Drawer.Overlay'\nDrawerContent.displayName = 'Drawer.Content'\nDrawerHeader.displayName = 'Drawer.Header'\nDrawerBody.displayName = 'Drawer.Body'\nDrawerFooter.displayName = 'Drawer.Footer'\nDrawerClose.displayName = 'Drawer.Close'\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\nDrawerTitle.displayName = 'Drawer.Title'\nDrawerDescription.displayName = 'Drawer.Description'\n\nexport { type DrawerProps } from './Drawer'\nexport { type DrawerContentProps } from './DrawerContent'\nexport { type DrawerHeaderProps } from './DrawerHeader'\nexport { type DrawerBodyProps } from './DrawerBody'\nexport { type DrawerFooterProps } from './DrawerFooter'\nexport { type DrawerTriggerProps } from './DrawerTrigger'\nexport { type DrawerOverlayProps } from './DrawerOverlay'\nexport { type DrawerPortalProps } from './DrawerPortal'\nexport { type DrawerTitleProps } from './DrawerTitle'\nexport { type DrawerDescriptionProps } from './DrawerDescription'\nexport { type DrawerCloseProps } from './DrawerClose'\nexport { type DrawerCloseButtonProps } from './DrawerCloseButton'\n"],"mappings":"2bAMA,IAAM,GAAA,EAAA,EAAA,cAAA,CAAyD,IAAI,EAEtD,GAAkB,CAC7B,SAAU,EACV,WAAW,OAMT,EAAA,EAAA,IAAA,CAAC,EAAD,CACE,MAAO,CACL,UACF,WAEC,CACY,CAAA,EAIN,MAAkB,CAC7B,IAAM,GAAA,EAAA,EAAA,WAAA,CAAqB,CAAa,EAExC,GAAI,CAA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BAC3B,EAAW,YAAc,cACzB,EAAa,YAAc,gBAC3B,EAAY,YAAc,eAC1B,EAAkB,YAAc,qBAChC,EAAY,YAAc,eAC1B,EAAkB,YAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/drawer/DrawerContext.tsx","../../src/drawer/Drawer.tsx","../../src/drawer/DrawerBody.styles.ts","../../src/drawer/DrawerBody.tsx","../../src/drawer/DrawerClose.tsx","../../src/drawer/DrawerCloseButton.tsx","../../src/drawer/DrawerContent.styles.tsx","../../src/drawer/DrawerContent.tsx","../../src/drawer/DrawerDescription.tsx","../../src/drawer/DrawerFooter.tsx","../../src/drawer/DrawerHeader.tsx","../../src/drawer/DrawerOverlay.tsx","../../src/drawer/DrawerPortal.tsx","../../src/drawer/DrawerTitle.tsx","../../src/drawer/DrawerTrigger.tsx","../../src/drawer/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react'\n\nexport interface DrawerContextState {\n withFade: boolean\n}\n\nconst DrawerContext = createContext<DrawerContextState | null>(null)\n\nexport const DrawerProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n return (\n <DrawerContext\n value={{\n withFade,\n }}\n >\n {childrenProp}\n </DrawerContext>\n )\n}\n\nexport const useDrawer = () => {\n const context = useContext(DrawerContext)\n\n if (!context) {\n throw Error('useDrawer must be used within a Drawer provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DrawerProvider } from './DrawerContext'\n\nexport interface DrawerProps extends Omit<\n ComponentProps<typeof BaseDialog.Root>,\n 'onOpenChange' | 'render'\n> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the drawer should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Drawer = ({ onOpenChange, withFade = false, ...props }: DrawerProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DrawerProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"drawer\" onOpenChange={handleOpenChange} {...props} />\n </DrawerProvider>\n )\n}\n\nDrawer.displayName = 'Drawer.Root'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerBodyStyles = cva(\n ['grow', 'overflow-y-auto', 'outline-hidden', 'focus-visible:u-outline'],\n {\n variants: {\n inset: {\n true: '',\n false: 'px-xl py-lg',\n },\n },\n defaultVariants: {\n inset: false,\n },\n }\n)\n\nexport type DrawerBodyStylesProps = VariantProps<typeof drawerBodyStyles>\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { type ReactNode, Ref, useRef } from 'react'\n\nimport { drawerBodyStyles, type DrawerBodyStylesProps } from './DrawerBody.styles'\nimport { useDrawer } from './DrawerContext'\n\nexport interface DrawerBodyProps extends DrawerBodyStylesProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The scrollable body section of the drawer. Renders a <div> element.\n */\nexport const DrawerBody = ({\n children,\n inset = false,\n className,\n ref: forwardedRef,\n ...rest\n}: DrawerBodyProps) => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDrawer()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"drawer-body\"\n ref={ref}\n className={drawerBodyStyles({ inset, className })}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nDrawerBody.displayName = 'Drawer.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { createRenderSlot } from '@spark-ui/internal-utils'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerCloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that closes the drawer. Renders a <button> element.\n */\nexport const DrawerClose = ({ asChild = false, children, ...props }: DrawerCloseProps) => {\n const { renderProp, innerChildren } = createRenderSlot(asChild, children)\n\n return (\n <BaseDialog.Close data-spark-component=\"drawer-close\" render={renderProp} {...props}>\n {innerChildren}\n </BaseDialog.Close>\n )\n}\n\nDrawerClose.displayName = 'Drawer.Close'\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { DrawerClose, type DrawerCloseProps } from './DrawerClose'\n\nexport type DrawerCloseButtonProps = DrawerCloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\n/**\n * A styled close button positioned in the drawer header. Renders a <button> element.\n */\nexport const DrawerCloseButton = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: DrawerCloseButtonProps) => (\n <DrawerClose\n data-spark-component=\"drawer-close-button\"\n ref={ref}\n className={cx(['absolute', 'top-sm', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </DrawerClose>\n)\n\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerContentStyles = cva(\n [\n 'fixed z-modal flex flex-col bg-surface shadow-md',\n // Base UI uses data-open and data-closed for transitions\n 'data-open:animation-duration-400 data-closed:animation-duration-200',\n // Nested dialog effect\n 'data-nested-dialog-open:after:pointer-events-none',\n 'after:bg-transparent',\n 'after:transition-all',\n 'after:duration-200',\n 'data-nested-dialog-open:after:inset-0',\n 'data-nested-dialog-open:after:absolute',\n 'data-nested-dialog-open:after:rounded-[inherit]',\n 'data-nested-dialog-open:after:bg-overlay/dim-3',\n ],\n {\n variants: {\n size: {\n sm: '',\n md: '',\n lg: '',\n fluid: '',\n fullscreen: 'h-screen w-screen',\n },\n side: {\n right: [\n 'inset-y-0 right-0',\n 'data-open:animate-slide-in-right ',\n 'data-closed:animate-slide-out-right',\n ],\n left: [\n 'inset-y-0 left-0',\n 'data-open:animate-slide-in-left',\n 'data-closed:animate-slide-out-left',\n ],\n top: [\n 'top-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-top',\n 'data-closed:animate-slide-out-top',\n ],\n bottom: [\n 'bottom-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-bottom',\n 'data-closed:animate-slide-out-bottom',\n ],\n },\n },\n compoundVariants: [\n {\n side: ['right', 'left'],\n size: 'sm',\n class: ['w-sz-480', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'md',\n class: ['w-sz-672', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'lg',\n class: ['w-sz-864', 'max-w-full'],\n },\n {\n side: ['left', 'right'],\n size: 'fluid',\n class: ['w-auto', 'max-w-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'sm',\n class: ['h-sz-480', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'md',\n class: ['h-sz-672', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'lg',\n class: ['h-sz-864', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'fluid',\n class: ['h-auto', 'max-h-full'],\n },\n ],\n defaultVariants: {\n side: 'right',\n size: 'md',\n },\n }\n)\n\nexport type DrawerContentStylesProps = VariantProps<typeof drawerContentStyles>\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { drawerContentStyles, type DrawerContentStylesProps } from './DrawerContent.styles'\n\nexport interface DrawerContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>, DrawerContentStylesProps {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The popup element that contains the drawer content. Renders a <div> element.\n */\nexport const DrawerContent = ({\n className,\n size = 'md',\n side = 'right',\n ref,\n ...rest\n}: DrawerContentProps) => {\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"drawer-content\"\n role=\"dialog\"\n className={state =>\n cx(\n drawerContentStyles({\n size,\n side,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nDrawerContent.displayName = 'Drawer.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerDescriptionProps extends Omit<\n ComponentProps<typeof BaseDialog.Description>,\n 'render'\n> {\n ref?: Ref<HTMLParagraphElement>\n}\n\n/**\n * A paragraph with additional information about the drawer. Renders a <p> element.\n */\nexport const DrawerDescription = (props: DrawerDescriptionProps) => {\n return <BaseDialog.Description data-spark-component=\"drawer-description\" {...props} />\n}\n\nDrawerDescription.displayName = 'Drawer.Description'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, type ReactElement, Ref } from 'react'\n\nexport type DrawerFooterProps = ComponentPropsWithoutRef<'footer'> & {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The footer section of the drawer, typically containing action buttons. Renders a <footer> element.\n */\nexport const DrawerFooter = ({ className, ref, ...rest }: DrawerFooterProps): ReactElement => (\n <footer\n data-spark-component=\"drawer-footer\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n />\n)\n\nDrawerFooter.displayName = 'Drawer.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface DrawerHeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The header section of the drawer. Renders a <header> element.\n */\nexport const DrawerHeader = ({\n children,\n className,\n ref,\n ...rest\n}: DrawerHeaderProps): ReactElement => (\n <header\n data-spark-component=\"drawer-header\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n >\n {children}\n </header>\n)\n\nDrawerHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerOverlayProps extends Omit<\n ComponentProps<typeof BaseDialog.Backdrop>,\n 'render'\n> {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The backdrop element that dims the rest of the page. Renders a <div> element.\n */\nexport const DrawerOverlay = ({ className, ...props }: DrawerOverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"drawer-overlay\"\n className={state =>\n cx(\n 'z-overlay fixed top-0 left-0 h-screen w-screen',\n 'bg-overlay/dim-1',\n // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nDrawerOverlay.displayName = 'Drawer.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type DrawerPortalProps = ComponentProps<typeof BaseDialog.Portal>\n\n/**\n * A portal that renders the drawer in a different part of the DOM. Renders a <div> element.\n */\nexport const DrawerPortal = ({ className, ...props }: DrawerPortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"drawer-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nDrawerPortal.displayName = 'Drawer.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTitleProps extends Omit<ComponentProps<typeof BaseDialog.Title>, 'render'> {\n ref?: Ref<HTMLHeadingElement>\n}\n\n/**\n * The title of the drawer, announced to assistive technology. Renders an <h2> element.\n */\nexport const DrawerTitle = ({ className, ...props }: DrawerTitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"drawer-title\"\n className={cx('text-headline-2 text-on-surface', className)}\n {...props}\n />\n )\n}\n\nDrawerTitle.displayName = 'Drawer.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { createRenderSlot } from '@spark-ui/internal-utils'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTriggerProps extends Omit<\n ComponentProps<typeof BaseDialog.Trigger>,\n 'render'\n> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that opens the drawer. Renders a <button> element.\n */\nexport const DrawerTrigger = ({ asChild = false, children, ...props }: DrawerTriggerProps) => {\n const { renderProp, innerChildren } = createRenderSlot(asChild, children)\n\n return (\n <BaseDialog.Trigger data-spark-component=\"drawer-trigger\" render={renderProp} {...props}>\n {innerChildren}\n </BaseDialog.Trigger>\n )\n}\n\nDrawerTrigger.displayName = 'Drawer.Trigger'\n","import { Drawer as Root } from './Drawer'\nimport { DrawerBody } from './DrawerBody'\nimport { DrawerClose } from './DrawerClose'\nimport { DrawerCloseButton } from './DrawerCloseButton'\nimport { DrawerContent } from './DrawerContent'\nimport { DrawerDescription } from './DrawerDescription' // aria-describedby\nimport { DrawerFooter } from './DrawerFooter'\nimport { DrawerHeader } from './DrawerHeader'\nimport { DrawerOverlay } from './DrawerOverlay'\nimport { DrawerPortal } from './DrawerPortal'\nimport { DrawerTitle } from './DrawerTitle'\nimport { DrawerTrigger } from './DrawerTrigger'\n\n/**\n * A panel that slides in from the edge of the screen, typically used for navigation or displaying additional content.\n */\nexport const Drawer: typeof Root & {\n Trigger: typeof DrawerTrigger\n Portal: typeof DrawerPortal\n Overlay: typeof DrawerOverlay\n Content: typeof DrawerContent\n Header: typeof DrawerHeader\n Body: typeof DrawerBody\n Footer: typeof DrawerFooter\n Close: typeof DrawerClose\n CloseButton: typeof DrawerCloseButton\n Title: typeof DrawerTitle\n Description: typeof DrawerDescription\n} = Object.assign(Root, {\n Trigger: DrawerTrigger,\n Portal: DrawerPortal,\n Overlay: DrawerOverlay,\n Content: DrawerContent,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n Close: DrawerClose,\n CloseButton: DrawerCloseButton,\n Title: DrawerTitle,\n Description: DrawerDescription,\n})\n\nDrawer.displayName = 'Drawer'\nDrawerTrigger.displayName = 'Drawer.Trigger'\nDrawerPortal.displayName = 'Drawer.Portal'\nDrawerOverlay.displayName = 'Drawer.Overlay'\nDrawerContent.displayName = 'Drawer.Content'\nDrawerHeader.displayName = 'Drawer.Header'\nDrawerBody.displayName = 'Drawer.Body'\nDrawerFooter.displayName = 'Drawer.Footer'\nDrawerClose.displayName = 'Drawer.Close'\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\nDrawerTitle.displayName = 'Drawer.Title'\nDrawerDescription.displayName = 'Drawer.Description'\n\nexport { type DrawerProps } from './Drawer'\nexport { type DrawerContentProps } from './DrawerContent'\nexport { type DrawerHeaderProps } from './DrawerHeader'\nexport { type DrawerBodyProps } from './DrawerBody'\nexport { type DrawerFooterProps } from './DrawerFooter'\nexport { type DrawerTriggerProps } from './DrawerTrigger'\nexport { type DrawerOverlayProps } from './DrawerOverlay'\nexport { type DrawerPortalProps } from './DrawerPortal'\nexport { type DrawerTitleProps } from './DrawerTitle'\nexport { type DrawerDescriptionProps } from './DrawerDescription'\nexport { type DrawerCloseProps } from './DrawerClose'\nexport { type DrawerCloseButtonProps } from './DrawerCloseButton'\n"],"mappings":"ubAMA,IAAM,GAAA,EAAA,EAAA,cAAA,CAAyD,IAAI,EAEtD,GAAkB,CAC7B,SAAU,EACV,WAAW,OAMT,EAAA,EAAA,IAAA,CAAC,EAAD,CACE,MAAO,CACL,UACF,WAEC,CACY,CAAA,EAIN,MAAkB,CAC7B,IAAM,GAAA,EAAA,EAAA,WAAA,CAAqB,CAAa,EAExC,GAAI,CAAC,EACH,MAAM,MAAM,iDAAiD,EAG/D,OAAO,CACT,ECCa,GAAU,CAAE,eAAc,WAAW,GAAO,GAAG,KAAuC,CACjG,IAAM,EAAmB,GACpB,EAAe,IAA2B,CACzC,EAAa,CAAI,CACnB,EACA,IAAA,GAEJ,OACE,EAAA,EAAA,IAAA,CAAC,EAAD,CAA0B,qBACxB,EAAA,EAAA,IAAA,CAAC,EAAA,OAAW,KAAZ,CAAiB,uBAAqB,SAAS,aAAc,EAAkB,GAAI,CAAQ,CAAA,CAC7E,CAAA,CAEpB,EAEA,EAAO,YAAc,cC/CrB,IAAa,GAAA,EAAA,EAAA,IAAA,CACX,CAAC,OAAQ,kBAAmB,iBAAkB,yBAAyB,EACvE,CACE,SAAU,CACR,MAAO,CACL,KAAM,GACN,MAAO,aACT,CACF,EACA,gBAAiB,CACf,MAAO,EACT,CACF,CACF,ECCa,GAAc,CACzB,WACA,QAAQ,GACR,YACA,IAAK,EACL,GAAG,KACkB,CACrB,IAAM,GAAA,EAAA,EAAA,OAAA,CAAuC,IAAI,EAC3C,GAAA,EAAA,EAAA,aAAA,CAAmB,EAAc,CAAa,EAE9C,CAAE,YAAa,EAAU,EA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EAIL,EAAY,YAAc,eCH1B,IAAa,GAAiB,CAAE,UAAU,GAAO,WAAU,GAAG,KAAgC,CAC5F,GAAM,CAAE,aAAY,kBAAA,EAAA,EAAA,iBAAA,CAAmC,EAAS,CAAQ,EAExE,OACE,EAAA,EAAA,IAAA,CAAC,EAAA,OAAW,QAAZ,CAAoB,uBAAqB,iBAAiB,OAAQ,EAAY,GAAI,WAC/E,CACiB,CAAA,CAExB,EAEA,EAAc,YAAc,iBCZ5B,IAAa,EAYT,OAAO,OAAO,EAAM,CACtB,QAAS,EACT,OAAQ,EACR,QAAS,EACT,QAAS,EACT,OAAQ,EACR,KAAM,EACN,OAAQ,EACR,MAAO,EACP,YAAa,EACb,MAAO,EACP,YAAa,CACf,CAAC,EAED,EAAO,YAAc,SACrB,EAAc,YAAc,iBAC5B,EAAa,YAAc,gBAC3B,EAAc,YAAc,iBAC5B,EAAc,YAAc,iBAC5B,EAAa,YAAc,gBAC3B,EAAW,YAAc,cACzB,EAAa,YAAc,gBAC3B,EAAY,YAAc,eAC1B,EAAkB,YAAc,qBAChC,EAAY,YAAc,eAC1B,EAAkB,YAAc"}
|
package/dist/drawer/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "../icon-
|
|
2
|
-
import { t } from "../icon-button-
|
|
3
|
-
import {
|
|
1
|
+
import { t as e } from "../icon-VM_Ys9Xn.mjs";
|
|
2
|
+
import { t } from "../icon-button-CexCkoV0.mjs";
|
|
3
|
+
import { createRenderSlot as n } from "@spark-ui/internal-utils";
|
|
4
4
|
import { cva as r, cx as i } from "class-variance-authority";
|
|
5
5
|
import { createContext as a, useContext as o, useRef as s } from "react";
|
|
6
6
|
import { jsx as c } from "react/jsx-runtime";
|
|
@@ -64,12 +64,13 @@ var _ = r([
|
|
|
64
64
|
v.displayName = "Drawer.Body";
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/drawer/DrawerClose.tsx
|
|
67
|
-
var y = ({ asChild: e = !1,
|
|
68
|
-
let
|
|
67
|
+
var y = ({ asChild: e = !1, children: t, ...r }) => {
|
|
68
|
+
let { renderProp: i, innerChildren: a } = n(e, t);
|
|
69
69
|
return /* @__PURE__ */ c(f.Close, {
|
|
70
70
|
"data-spark-component": "drawer-close",
|
|
71
|
-
render:
|
|
72
|
-
...
|
|
71
|
+
render: i,
|
|
72
|
+
...r,
|
|
73
|
+
children: a
|
|
73
74
|
});
|
|
74
75
|
};
|
|
75
76
|
y.displayName = "Drawer.Close";
|
|
@@ -251,12 +252,13 @@ var O = ({ className: e, ...t }) => /* @__PURE__ */ c(f.Title, {
|
|
|
251
252
|
O.displayName = "Drawer.Title";
|
|
252
253
|
//#endregion
|
|
253
254
|
//#region src/drawer/DrawerTrigger.tsx
|
|
254
|
-
var k = ({ asChild: e = !1,
|
|
255
|
-
let
|
|
255
|
+
var k = ({ asChild: e = !1, children: t, ...r }) => {
|
|
256
|
+
let { renderProp: i, innerChildren: a } = n(e, t);
|
|
256
257
|
return /* @__PURE__ */ c(f.Trigger, {
|
|
257
258
|
"data-spark-component": "drawer-trigger",
|
|
258
|
-
render:
|
|
259
|
-
...
|
|
259
|
+
render: i,
|
|
260
|
+
...r,
|
|
261
|
+
children: a
|
|
260
262
|
});
|
|
261
263
|
};
|
|
262
264
|
k.displayName = "Drawer.Trigger";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/drawer/DrawerContext.tsx","../../src/drawer/Drawer.tsx","../../src/drawer/DrawerBody.styles.ts","../../src/drawer/DrawerBody.tsx","../../src/drawer/DrawerClose.tsx","../../src/drawer/DrawerCloseButton.tsx","../../src/drawer/DrawerContent.styles.tsx","../../src/drawer/DrawerContent.tsx","../../src/drawer/DrawerDescription.tsx","../../src/drawer/DrawerFooter.tsx","../../src/drawer/DrawerHeader.tsx","../../src/drawer/DrawerOverlay.tsx","../../src/drawer/DrawerPortal.tsx","../../src/drawer/DrawerTitle.tsx","../../src/drawer/DrawerTrigger.tsx","../../src/drawer/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react'\n\nexport interface DrawerContextState {\n withFade: boolean\n}\n\nconst DrawerContext = createContext<DrawerContextState | null>(null)\n\nexport const DrawerProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n return (\n <DrawerContext\n value={{\n withFade,\n }}\n >\n {childrenProp}\n </DrawerContext>\n )\n}\n\nexport const useDrawer = () => {\n const context = useContext(DrawerContext)\n\n if (!context) {\n throw Error('useDrawer must be used within a Drawer provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DrawerProvider } from './DrawerContext'\n\nexport interface DrawerProps extends Omit<\n ComponentProps<typeof BaseDialog.Root>,\n 'onOpenChange' | 'render'\n> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the drawer should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Drawer = ({ onOpenChange, withFade = false, ...props }: DrawerProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DrawerProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"drawer\" onOpenChange={handleOpenChange} {...props} />\n </DrawerProvider>\n )\n}\n\nDrawer.displayName = 'Drawer.Root'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerBodyStyles = cva(\n ['grow', 'overflow-y-auto', 'outline-hidden', 'focus-visible:u-outline'],\n {\n variants: {\n inset: {\n true: '',\n false: 'px-xl py-lg',\n },\n },\n defaultVariants: {\n inset: false,\n },\n }\n)\n\nexport type DrawerBodyStylesProps = VariantProps<typeof drawerBodyStyles>\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { type ReactNode, Ref, useRef } from 'react'\n\nimport { drawerBodyStyles, type DrawerBodyStylesProps } from './DrawerBody.styles'\nimport { useDrawer } from './DrawerContext'\n\nexport interface DrawerBodyProps extends DrawerBodyStylesProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The scrollable body section of the drawer. Renders a <div> element.\n */\nexport const DrawerBody = ({\n children,\n inset = false,\n className,\n ref: forwardedRef,\n ...rest\n}: DrawerBodyProps) => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDrawer()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"drawer-body\"\n ref={ref}\n className={drawerBodyStyles({ inset, className })}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nDrawerBody.displayName = 'Drawer.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface DrawerCloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that closes the drawer. Renders a <button> element.\n */\nexport const DrawerClose = ({ asChild = false, ...props }: DrawerCloseProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Close data-spark-component=\"drawer-close\" render={renderSlot} {...props} />\n}\n\nDrawerClose.displayName = 'Drawer.Close'\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { DrawerClose, type DrawerCloseProps } from './DrawerClose'\n\nexport type DrawerCloseButtonProps = DrawerCloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\n/**\n * A styled close button positioned in the drawer header. Renders a <button> element.\n */\nexport const DrawerCloseButton = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: DrawerCloseButtonProps) => (\n <DrawerClose\n data-spark-component=\"drawer-close-button\"\n ref={ref}\n className={cx(['absolute', 'top-sm', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </DrawerClose>\n)\n\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerContentStyles = cva(\n [\n 'fixed z-modal flex flex-col bg-surface shadow-md',\n // Base UI uses data-open and data-closed for transitions\n 'data-open:animation-duration-400 data-closed:animation-duration-200',\n // Nested dialog effect\n 'data-nested-dialog-open:after:pointer-events-none',\n 'after:bg-transparent',\n 'after:transition-all',\n 'after:duration-200',\n 'data-nested-dialog-open:after:inset-0',\n 'data-nested-dialog-open:after:absolute',\n 'data-nested-dialog-open:after:rounded-[inherit]',\n 'data-nested-dialog-open:after:bg-overlay/dim-3',\n ],\n {\n variants: {\n size: {\n sm: '',\n md: '',\n lg: '',\n fluid: '',\n fullscreen: 'h-screen w-screen',\n },\n side: {\n right: [\n 'inset-y-0 right-0',\n 'data-open:animate-slide-in-right ',\n 'data-closed:animate-slide-out-right',\n ],\n left: [\n 'inset-y-0 left-0',\n 'data-open:animate-slide-in-left',\n 'data-closed:animate-slide-out-left',\n ],\n top: [\n 'top-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-top',\n 'data-closed:animate-slide-out-top',\n ],\n bottom: [\n 'bottom-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-bottom',\n 'data-closed:animate-slide-out-bottom',\n ],\n },\n },\n compoundVariants: [\n {\n side: ['right', 'left'],\n size: 'sm',\n class: ['w-sz-480', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'md',\n class: ['w-sz-672', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'lg',\n class: ['w-sz-864', 'max-w-full'],\n },\n {\n side: ['left', 'right'],\n size: 'fluid',\n class: ['w-auto', 'max-w-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'sm',\n class: ['h-sz-480', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'md',\n class: ['h-sz-672', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'lg',\n class: ['h-sz-864', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'fluid',\n class: ['h-auto', 'max-h-full'],\n },\n ],\n defaultVariants: {\n side: 'right',\n size: 'md',\n },\n }\n)\n\nexport type DrawerContentStylesProps = VariantProps<typeof drawerContentStyles>\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { drawerContentStyles, type DrawerContentStylesProps } from './DrawerContent.styles'\n\nexport interface DrawerContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>, DrawerContentStylesProps {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The popup element that contains the drawer content. Renders a <div> element.\n */\nexport const DrawerContent = ({\n className,\n size = 'md',\n side = 'right',\n ref,\n ...rest\n}: DrawerContentProps) => {\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"drawer-content\"\n role=\"dialog\"\n className={state =>\n cx(\n drawerContentStyles({\n size,\n side,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nDrawerContent.displayName = 'Drawer.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerDescriptionProps extends Omit<\n ComponentProps<typeof BaseDialog.Description>,\n 'render'\n> {\n ref?: Ref<HTMLParagraphElement>\n}\n\n/**\n * A paragraph with additional information about the drawer. Renders a <p> element.\n */\nexport const DrawerDescription = (props: DrawerDescriptionProps) => {\n return <BaseDialog.Description data-spark-component=\"drawer-description\" {...props} />\n}\n\nDrawerDescription.displayName = 'Drawer.Description'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, type ReactElement, Ref } from 'react'\n\nexport type DrawerFooterProps = ComponentPropsWithoutRef<'footer'> & {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The footer section of the drawer, typically containing action buttons. Renders a <footer> element.\n */\nexport const DrawerFooter = ({ className, ref, ...rest }: DrawerFooterProps): ReactElement => (\n <footer\n data-spark-component=\"drawer-footer\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n />\n)\n\nDrawerFooter.displayName = 'Drawer.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface DrawerHeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The header section of the drawer. Renders a <header> element.\n */\nexport const DrawerHeader = ({\n children,\n className,\n ref,\n ...rest\n}: DrawerHeaderProps): ReactElement => (\n <header\n data-spark-component=\"drawer-header\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n >\n {children}\n </header>\n)\n\nDrawerHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerOverlayProps extends Omit<\n ComponentProps<typeof BaseDialog.Backdrop>,\n 'render'\n> {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The backdrop element that dims the rest of the page. Renders a <div> element.\n */\nexport const DrawerOverlay = ({ className, ...props }: DrawerOverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"drawer-overlay\"\n className={state =>\n cx(\n 'z-overlay fixed top-0 left-0 h-screen w-screen',\n 'bg-overlay/dim-1',\n // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nDrawerOverlay.displayName = 'Drawer.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type DrawerPortalProps = ComponentProps<typeof BaseDialog.Portal>\n\n/**\n * A portal that renders the drawer in a different part of the DOM. Renders a <div> element.\n */\nexport const DrawerPortal = ({ className, ...props }: DrawerPortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"drawer-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nDrawerPortal.displayName = 'Drawer.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTitleProps extends Omit<ComponentProps<typeof BaseDialog.Title>, 'render'> {\n ref?: Ref<HTMLHeadingElement>\n}\n\n/**\n * The title of the drawer, announced to assistive technology. Renders an <h2> element.\n */\nexport const DrawerTitle = ({ className, ...props }: DrawerTitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"drawer-title\"\n className={cx('text-headline-2 text-on-surface', className)}\n {...props}\n />\n )\n}\n\nDrawerTitle.displayName = 'Drawer.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nimport { useRenderSlot } from './useRenderSlot'\n\nexport interface DrawerTriggerProps extends Omit<\n ComponentProps<typeof BaseDialog.Trigger>,\n 'render'\n> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that opens the drawer. Renders a <button> element.\n */\nexport const DrawerTrigger = ({ asChild = false, ...props }: DrawerTriggerProps) => {\n const renderSlot = useRenderSlot(asChild, 'button')\n\n return <BaseDialog.Trigger data-spark-component=\"drawer-trigger\" render={renderSlot} {...props} />\n}\n\nDrawerTrigger.displayName = 'Drawer.Trigger'\n","import { Drawer as Root } from './Drawer'\nimport { DrawerBody } from './DrawerBody'\nimport { DrawerClose } from './DrawerClose'\nimport { DrawerCloseButton } from './DrawerCloseButton'\nimport { DrawerContent } from './DrawerContent'\nimport { DrawerDescription } from './DrawerDescription' // aria-describedby\nimport { DrawerFooter } from './DrawerFooter'\nimport { DrawerHeader } from './DrawerHeader'\nimport { DrawerOverlay } from './DrawerOverlay'\nimport { DrawerPortal } from './DrawerPortal'\nimport { DrawerTitle } from './DrawerTitle'\nimport { DrawerTrigger } from './DrawerTrigger'\n\n/**\n * A panel that slides in from the edge of the screen, typically used for navigation or displaying additional content.\n */\nexport const Drawer: typeof Root & {\n Trigger: typeof DrawerTrigger\n Portal: typeof DrawerPortal\n Overlay: typeof DrawerOverlay\n Content: typeof DrawerContent\n Header: typeof DrawerHeader\n Body: typeof DrawerBody\n Footer: typeof DrawerFooter\n Close: typeof DrawerClose\n CloseButton: typeof DrawerCloseButton\n Title: typeof DrawerTitle\n Description: typeof DrawerDescription\n} = Object.assign(Root, {\n Trigger: DrawerTrigger,\n Portal: DrawerPortal,\n Overlay: DrawerOverlay,\n Content: DrawerContent,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n Close: DrawerClose,\n CloseButton: DrawerCloseButton,\n Title: DrawerTitle,\n Description: DrawerDescription,\n})\n\nDrawer.displayName = 'Drawer'\nDrawerTrigger.displayName = 'Drawer.Trigger'\nDrawerPortal.displayName = 'Drawer.Portal'\nDrawerOverlay.displayName = 'Drawer.Overlay'\nDrawerContent.displayName = 'Drawer.Content'\nDrawerHeader.displayName = 'Drawer.Header'\nDrawerBody.displayName = 'Drawer.Body'\nDrawerFooter.displayName = 'Drawer.Footer'\nDrawerClose.displayName = 'Drawer.Close'\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\nDrawerTitle.displayName = 'Drawer.Title'\nDrawerDescription.displayName = 'Drawer.Description'\n\nexport { type DrawerProps } from './Drawer'\nexport { type DrawerContentProps } from './DrawerContent'\nexport { type DrawerHeaderProps } from './DrawerHeader'\nexport { type DrawerBodyProps } from './DrawerBody'\nexport { type DrawerFooterProps } from './DrawerFooter'\nexport { type DrawerTriggerProps } from './DrawerTrigger'\nexport { type DrawerOverlayProps } from './DrawerOverlay'\nexport { type DrawerPortalProps } from './DrawerPortal'\nexport { type DrawerTitleProps } from './DrawerTitle'\nexport { type DrawerDescriptionProps } from './DrawerDescription'\nexport { type DrawerCloseProps } from './DrawerClose'\nexport { type DrawerCloseButtonProps } from './DrawerCloseButton'\n"],"mappings":";;;;;;;;;;;AAMA,IAAM,IAAgB,EAAyC,IAAI,GAEtD,KAAkB,EAC7B,UAAU,GACV,cAAW,SAMT,kBAAC,GAAD;CACE,OAAO,EACL,YACF;WAEC;AACY,CAAA,GAIN,UAAkB;CAC7B,IAAM,IAAU,EAAW,CAAa;CAExC,IAAI,CAAC,GACH,MAAM,MAAM,iDAAiD;CAG/D,OAAO;AACT,GCCa,KAAU,EAAE,iBAAc,cAAW,IAAO,GAAG,QAAuC;CACjG,IAAM,IAAmB,KACpB,GAAe,MAA2B;EACzC,E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AAY,cAAc;;;ACF1B,IAAa,KAAiB,EAAE,aAAU,IAAO,GAAG,QAAgC;CAClF,IAAM,IAAa,EAAc,GAAS,QAAQ;CAElD,OAAO,kBAAC,EAAW,SAAZ;EAAoB,wBAAqB;EAAiB,QAAQ;EAAY,GAAI;CAAQ,CAAA;AACnG;AAEA,EAAc,cAAc;;;ACT5B,IAAa,IAYT,OAAO,OAAO,GAAM;CACtB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf,CAAC;AAED,EAAO,cAAc,UACrB,EAAc,cAAc,kBAC5B,EAAa,cAAc,iBAC3B,EAAc,cAAc,kBAC5B,EAAc,cAAc,kBAC5B,EAAa,cAAc,iBAC3B,EAAW,cAAc,eACzB,EAAa,cAAc,iBAC3B,EAAY,cAAc,gBAC1B,EAAkB,cAAc,sBAChC,EAAY,cAAc,gBAC1B,EAAkB,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/drawer/DrawerContext.tsx","../../src/drawer/Drawer.tsx","../../src/drawer/DrawerBody.styles.ts","../../src/drawer/DrawerBody.tsx","../../src/drawer/DrawerClose.tsx","../../src/drawer/DrawerCloseButton.tsx","../../src/drawer/DrawerContent.styles.tsx","../../src/drawer/DrawerContent.tsx","../../src/drawer/DrawerDescription.tsx","../../src/drawer/DrawerFooter.tsx","../../src/drawer/DrawerHeader.tsx","../../src/drawer/DrawerOverlay.tsx","../../src/drawer/DrawerPortal.tsx","../../src/drawer/DrawerTitle.tsx","../../src/drawer/DrawerTrigger.tsx","../../src/drawer/index.ts"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react'\n\nexport interface DrawerContextState {\n withFade: boolean\n}\n\nconst DrawerContext = createContext<DrawerContextState | null>(null)\n\nexport const DrawerProvider = ({\n children: childrenProp,\n withFade = false,\n}: {\n children: ReactNode\n withFade?: boolean\n}) => {\n return (\n <DrawerContext\n value={{\n withFade,\n }}\n >\n {childrenProp}\n </DrawerContext>\n )\n}\n\nexport const useDrawer = () => {\n const context = useContext(DrawerContext)\n\n if (!context) {\n throw Error('useDrawer must be used within a Drawer provider')\n }\n\n return context\n}\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, type ReactElement } from 'react'\n\nimport { DrawerProvider } from './DrawerContext'\n\nexport interface DrawerProps extends Omit<\n ComponentProps<typeof BaseDialog.Root>,\n 'onOpenChange' | 'render'\n> {\n /**\n * Specifies if the dialog is open or not.\n */\n open?: boolean\n /**\n * Default open state.\n */\n defaultOpen?: boolean\n /**\n * Handler executed on every dialog open state change.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Specifies if the dialog is a modal.\n */\n modal?: boolean\n /**\n * Specifies if the drawer should have a fade animation on its body (in case it is scrollable).\n */\n withFade?: boolean\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n}\n\nexport const Drawer = ({ onOpenChange, withFade = false, ...props }: DrawerProps): ReactElement => {\n const handleOpenChange = onOpenChange\n ? (open: boolean, _eventDetails: unknown) => {\n onOpenChange(open)\n }\n : undefined\n\n return (\n <DrawerProvider withFade={withFade}>\n <BaseDialog.Root data-spark-component=\"drawer\" onOpenChange={handleOpenChange} {...props} />\n </DrawerProvider>\n )\n}\n\nDrawer.displayName = 'Drawer.Root'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerBodyStyles = cva(\n ['grow', 'overflow-y-auto', 'outline-hidden', 'focus-visible:u-outline'],\n {\n variants: {\n inset: {\n true: '',\n false: 'px-xl py-lg',\n },\n },\n defaultVariants: {\n inset: false,\n },\n }\n)\n\nexport type DrawerBodyStylesProps = VariantProps<typeof drawerBodyStyles>\n","import { useMergeRefs } from '@spark-ui/hooks/use-merge-refs'\nimport { useScrollOverflow } from '@spark-ui/hooks/use-scroll-overflow'\nimport { type ReactNode, Ref, useRef } from 'react'\n\nimport { drawerBodyStyles, type DrawerBodyStylesProps } from './DrawerBody.styles'\nimport { useDrawer } from './DrawerContext'\n\nexport interface DrawerBodyProps extends DrawerBodyStylesProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The scrollable body section of the drawer. Renders a <div> element.\n */\nexport const DrawerBody = ({\n children,\n inset = false,\n className,\n ref: forwardedRef,\n ...rest\n}: DrawerBodyProps) => {\n const scrollAreaRef = useRef<HTMLDivElement>(null)\n const ref = useMergeRefs(forwardedRef, scrollAreaRef)\n\n const { withFade } = useDrawer()\n\n const { overflow } = useScrollOverflow(scrollAreaRef)\n\n return (\n <div\n data-spark-component=\"drawer-body\"\n ref={ref}\n className={drawerBodyStyles({ inset, className })}\n style={{\n ...(withFade && {\n maskImage:\n 'linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 1) 44px, rgba(0, 0, 0, 1) calc(100% - 44px), rgba(0, 0, 0, 0))',\n maskSize: `100% calc(100% + ${overflow.top ? '0px' : '44px'} + ${overflow.bottom ? '0px' : '44px'})`,\n maskPosition: `0 ${overflow.top ? '0px' : '-44px'}`,\n }),\n }}\n {...rest}\n >\n {children}\n </div>\n )\n}\n\nDrawerBody.displayName = 'Drawer.Body'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { createRenderSlot } from '@spark-ui/internal-utils'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerCloseProps extends Omit<ComponentProps<typeof BaseDialog.Close>, 'render'> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that closes the drawer. Renders a <button> element.\n */\nexport const DrawerClose = ({ asChild = false, children, ...props }: DrawerCloseProps) => {\n const { renderProp, innerChildren } = createRenderSlot(asChild, children)\n\n return (\n <BaseDialog.Close data-spark-component=\"drawer-close\" render={renderProp} {...props}>\n {innerChildren}\n </BaseDialog.Close>\n )\n}\n\nDrawerClose.displayName = 'Drawer.Close'\n","import { Close as CloseSVG } from '@spark-ui/icons/Close'\nimport { cx } from 'class-variance-authority'\n\nimport { Icon } from '../icon'\nimport { IconButton, type IconButtonProps } from '../icon-button'\nimport { DrawerClose, type DrawerCloseProps } from './DrawerClose'\n\nexport type DrawerCloseButtonProps = DrawerCloseProps &\n Pick<IconButtonProps, 'size' | 'intent' | 'design' | 'aria-label'>\n\n/**\n * A styled close button positioned in the drawer header. Renders a <button> element.\n */\nexport const DrawerCloseButton = ({\n 'aria-label': ariaLabel,\n className,\n size = 'md',\n intent = 'neutral',\n design = 'ghost',\n children = <CloseSVG />,\n ref,\n ...rest\n}: DrawerCloseButtonProps) => (\n <DrawerClose\n data-spark-component=\"drawer-close-button\"\n ref={ref}\n className={cx(['absolute', 'top-sm', 'right-xl'], className)}\n asChild\n {...rest}\n >\n <IconButton intent={intent} size={size} design={design} aria-label={ariaLabel}>\n <Icon>{children}</Icon>\n </IconButton>\n </DrawerClose>\n)\n\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\n","import { cva, VariantProps } from 'class-variance-authority'\n\nexport const drawerContentStyles = cva(\n [\n 'fixed z-modal flex flex-col bg-surface shadow-md',\n // Base UI uses data-open and data-closed for transitions\n 'data-open:animation-duration-400 data-closed:animation-duration-200',\n // Nested dialog effect\n 'data-nested-dialog-open:after:pointer-events-none',\n 'after:bg-transparent',\n 'after:transition-all',\n 'after:duration-200',\n 'data-nested-dialog-open:after:inset-0',\n 'data-nested-dialog-open:after:absolute',\n 'data-nested-dialog-open:after:rounded-[inherit]',\n 'data-nested-dialog-open:after:bg-overlay/dim-3',\n ],\n {\n variants: {\n size: {\n sm: '',\n md: '',\n lg: '',\n fluid: '',\n fullscreen: 'h-screen w-screen',\n },\n side: {\n right: [\n 'inset-y-0 right-0',\n 'data-open:animate-slide-in-right ',\n 'data-closed:animate-slide-out-right',\n ],\n left: [\n 'inset-y-0 left-0',\n 'data-open:animate-slide-in-left',\n 'data-closed:animate-slide-out-left',\n ],\n top: [\n 'top-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-top',\n 'data-closed:animate-slide-out-top',\n ],\n bottom: [\n 'bottom-0 left-0',\n 'w-screen',\n 'data-open:animate-slide-in-bottom',\n 'data-closed:animate-slide-out-bottom',\n ],\n },\n },\n compoundVariants: [\n {\n side: ['right', 'left'],\n size: 'sm',\n class: ['w-sz-480', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'md',\n class: ['w-sz-672', 'max-w-full'],\n },\n {\n side: ['right', 'left'],\n size: 'lg',\n class: ['w-sz-864', 'max-w-full'],\n },\n {\n side: ['left', 'right'],\n size: 'fluid',\n class: ['w-auto', 'max-w-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'sm',\n class: ['h-sz-480', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'md',\n class: ['h-sz-672', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'lg',\n class: ['h-sz-864', 'max-h-full'],\n },\n {\n side: ['top', 'bottom'],\n size: 'fluid',\n class: ['h-auto', 'max-h-full'],\n },\n ],\n defaultVariants: {\n side: 'right',\n size: 'md',\n },\n }\n)\n\nexport type DrawerContentStylesProps = VariantProps<typeof drawerContentStyles>\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nimport { drawerContentStyles, type DrawerContentStylesProps } from './DrawerContent.styles'\n\nexport interface DrawerContentProps\n extends Omit<ComponentProps<typeof BaseDialog.Popup>, 'render'>, DrawerContentStylesProps {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The popup element that contains the drawer content. Renders a <div> element.\n */\nexport const DrawerContent = ({\n className,\n size = 'md',\n side = 'right',\n ref,\n ...rest\n}: DrawerContentProps) => {\n return (\n <BaseDialog.Popup\n ref={ref}\n data-spark-component=\"drawer-content\"\n role=\"dialog\"\n className={state =>\n cx(\n drawerContentStyles({\n size,\n side,\n className: typeof className === 'function' ? className(state) : className,\n })\n )\n }\n {...rest}\n />\n )\n}\n\nDrawerContent.displayName = 'Drawer.Content'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerDescriptionProps extends Omit<\n ComponentProps<typeof BaseDialog.Description>,\n 'render'\n> {\n ref?: Ref<HTMLParagraphElement>\n}\n\n/**\n * A paragraph with additional information about the drawer. Renders a <p> element.\n */\nexport const DrawerDescription = (props: DrawerDescriptionProps) => {\n return <BaseDialog.Description data-spark-component=\"drawer-description\" {...props} />\n}\n\nDrawerDescription.displayName = 'Drawer.Description'\n","import { cx } from 'class-variance-authority'\nimport { ComponentPropsWithoutRef, type ReactElement, Ref } from 'react'\n\nexport type DrawerFooterProps = ComponentPropsWithoutRef<'footer'> & {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The footer section of the drawer, typically containing action buttons. Renders a <footer> element.\n */\nexport const DrawerFooter = ({ className, ref, ...rest }: DrawerFooterProps): ReactElement => (\n <footer\n data-spark-component=\"drawer-footer\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n />\n)\n\nDrawerFooter.displayName = 'Drawer.Footer'\n","import { cx } from 'class-variance-authority'\nimport { type ReactElement, type ReactNode, Ref } from 'react'\n\nexport interface DrawerHeaderProps {\n children: ReactNode\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The header section of the drawer. Renders a <header> element.\n */\nexport const DrawerHeader = ({\n children,\n className,\n ref,\n ...rest\n}: DrawerHeaderProps): ReactElement => (\n <header\n data-spark-component=\"drawer-header\"\n ref={ref}\n className={cx(['px-xl', 'py-lg'], className)}\n {...rest}\n >\n {children}\n </header>\n)\n\nDrawerHeader.displayName = 'Dialog.Header'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerOverlayProps extends Omit<\n ComponentProps<typeof BaseDialog.Backdrop>,\n 'render'\n> {\n ref?: Ref<HTMLDivElement>\n}\n\n/**\n * The backdrop element that dims the rest of the page. Renders a <div> element.\n */\nexport const DrawerOverlay = ({ className, ...props }: DrawerOverlayProps) => {\n return (\n <BaseDialog.Backdrop\n data-spark-component=\"drawer-overlay\"\n className={state =>\n cx(\n 'z-overlay fixed top-0 left-0 h-screen w-screen',\n 'bg-overlay/dim-1',\n // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes\n 'data-starting-style:animate-fade-in',\n 'data-ending-style:animate-fade-out',\n typeof className === 'function' ? className(state) : className\n )\n }\n {...props}\n />\n )\n}\n\nDrawerOverlay.displayName = 'Drawer.Overlay'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps } from 'react'\n\nexport type DrawerPortalProps = ComponentProps<typeof BaseDialog.Portal>\n\n/**\n * A portal that renders the drawer in a different part of the DOM. Renders a <div> element.\n */\nexport const DrawerPortal = ({ className, ...props }: DrawerPortalProps) => {\n return (\n <BaseDialog.Portal\n data-spark-component=\"drawer-portal\"\n className={cx(className, 'z-modal absolute')}\n {...props}\n />\n )\n}\n\nDrawerPortal.displayName = 'Drawer.Portal'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { cx } from 'class-variance-authority'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTitleProps extends Omit<ComponentProps<typeof BaseDialog.Title>, 'render'> {\n ref?: Ref<HTMLHeadingElement>\n}\n\n/**\n * The title of the drawer, announced to assistive technology. Renders an <h2> element.\n */\nexport const DrawerTitle = ({ className, ...props }: DrawerTitleProps) => {\n return (\n <BaseDialog.Title\n data-spark-component=\"drawer-title\"\n className={cx('text-headline-2 text-on-surface', className)}\n {...props}\n />\n )\n}\n\nDrawerTitle.displayName = 'Drawer.Title'\n","import { Dialog as BaseDialog } from '@base-ui/react/dialog'\nimport { createRenderSlot } from '@spark-ui/internal-utils'\nimport { ComponentProps, Ref } from 'react'\n\nexport interface DrawerTriggerProps extends Omit<\n ComponentProps<typeof BaseDialog.Trigger>,\n 'render'\n> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild?: boolean\n ref?: Ref<HTMLButtonElement>\n}\n\n/**\n * A button that opens the drawer. Renders a <button> element.\n */\nexport const DrawerTrigger = ({ asChild = false, children, ...props }: DrawerTriggerProps) => {\n const { renderProp, innerChildren } = createRenderSlot(asChild, children)\n\n return (\n <BaseDialog.Trigger data-spark-component=\"drawer-trigger\" render={renderProp} {...props}>\n {innerChildren}\n </BaseDialog.Trigger>\n )\n}\n\nDrawerTrigger.displayName = 'Drawer.Trigger'\n","import { Drawer as Root } from './Drawer'\nimport { DrawerBody } from './DrawerBody'\nimport { DrawerClose } from './DrawerClose'\nimport { DrawerCloseButton } from './DrawerCloseButton'\nimport { DrawerContent } from './DrawerContent'\nimport { DrawerDescription } from './DrawerDescription' // aria-describedby\nimport { DrawerFooter } from './DrawerFooter'\nimport { DrawerHeader } from './DrawerHeader'\nimport { DrawerOverlay } from './DrawerOverlay'\nimport { DrawerPortal } from './DrawerPortal'\nimport { DrawerTitle } from './DrawerTitle'\nimport { DrawerTrigger } from './DrawerTrigger'\n\n/**\n * A panel that slides in from the edge of the screen, typically used for navigation or displaying additional content.\n */\nexport const Drawer: typeof Root & {\n Trigger: typeof DrawerTrigger\n Portal: typeof DrawerPortal\n Overlay: typeof DrawerOverlay\n Content: typeof DrawerContent\n Header: typeof DrawerHeader\n Body: typeof DrawerBody\n Footer: typeof DrawerFooter\n Close: typeof DrawerClose\n CloseButton: typeof DrawerCloseButton\n Title: typeof DrawerTitle\n Description: typeof DrawerDescription\n} = Object.assign(Root, {\n Trigger: DrawerTrigger,\n Portal: DrawerPortal,\n Overlay: DrawerOverlay,\n Content: DrawerContent,\n Header: DrawerHeader,\n Body: DrawerBody,\n Footer: DrawerFooter,\n Close: DrawerClose,\n CloseButton: DrawerCloseButton,\n Title: DrawerTitle,\n Description: DrawerDescription,\n})\n\nDrawer.displayName = 'Drawer'\nDrawerTrigger.displayName = 'Drawer.Trigger'\nDrawerPortal.displayName = 'Drawer.Portal'\nDrawerOverlay.displayName = 'Drawer.Overlay'\nDrawerContent.displayName = 'Drawer.Content'\nDrawerHeader.displayName = 'Drawer.Header'\nDrawerBody.displayName = 'Drawer.Body'\nDrawerFooter.displayName = 'Drawer.Footer'\nDrawerClose.displayName = 'Drawer.Close'\nDrawerCloseButton.displayName = 'Drawer.CloseButton'\nDrawerTitle.displayName = 'Drawer.Title'\nDrawerDescription.displayName = 'Drawer.Description'\n\nexport { type DrawerProps } from './Drawer'\nexport { type DrawerContentProps } from './DrawerContent'\nexport { type DrawerHeaderProps } from './DrawerHeader'\nexport { type DrawerBodyProps } from './DrawerBody'\nexport { type DrawerFooterProps } from './DrawerFooter'\nexport { type DrawerTriggerProps } from './DrawerTrigger'\nexport { type DrawerOverlayProps } from './DrawerOverlay'\nexport { type DrawerPortalProps } from './DrawerPortal'\nexport { type DrawerTitleProps } from './DrawerTitle'\nexport { type DrawerDescriptionProps } from './DrawerDescription'\nexport { type DrawerCloseProps } from './DrawerClose'\nexport { type DrawerCloseButtonProps } from './DrawerCloseButton'\n"],"mappings":";;;;;;;;;;;AAMA,IAAM,IAAgB,EAAyC,IAAI,GAEtD,KAAkB,EAC7B,UAAU,GACV,cAAW,SAMT,kBAAC,GAAD;CACE,OAAO,EACL,YACF;WAEC;AACY,CAAA,GAIN,UAAkB;CAC7B,IAAM,IAAU,EAAW,CAAa;CAExC,IAAI,CAAC,GACH,MAAM,MAAM,iDAAiD;CAG/D,OAAO;AACT,GCCa,KAAU,EAAE,iBAAc,cAAW,IAAO,GAAG,QAAuC;CACjG,IAAM,IAAmB,KACpB,GAAe,MAA2B;EACzC,EAAa,CAAI;CACnB,IACA,KAAA;CAEJ,OACE,kBAAC,GAAD;EAA0B;YACxB,kBAAC,EAAW,MAAZ;GAAiB,wBAAqB;GAAS,cAAc;GAAk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AY,qBAAkB,EAAiB,GAAS,CAAQ;CAExE,OACE,kBAAC,EAAW,SAAZ;EAAoB,wBAAqB;EAAiB,QAAQ;EAAY,GAAI;YAC/E;CACiB,CAAA;AAExB;AAEA,EAAc,cAAc;;;ACZ5B,IAAa,IAYT,OAAO,OAAO,GAAM;CACtB,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,MAAM;CACN,QAAQ;CACR,OAAO;CACP,aAAa;CACb,OAAO;CACP,aAAa;AACf,CAAC;AAED,EAAO,cAAc,UACrB,EAAc,cAAc,kBAC5B,EAAa,cAAc,iBAC3B,EAAc,cAAc,kBAC5B,EAAc,cAAc,kBAC5B,EAAa,cAAc,iBAC3B,EAAW,cAAc,eACzB,EAAa,cAAc,iBAC3B,EAAY,cAAc,gBAC1B,EAAkB,cAAc,sBAChC,EAAY,cAAc,gBAC1B,EAAkB,cAAc"}
|
package/dist/dropdown/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../visually-hidden/index.js"),t=require("../icon-DY4l9nsc.js"),n=require("../popover-DVz0JvON.js");let r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/icons/ArrowHorizontalDown"),s=require("@spark-ui/hooks/use-merge-refs"),c=require("@spark-ui/components/form-field"),l=require("@spark-ui/icons/Check"),u=require("downshift");var d=({itemsMap:e,defaultValue:t,value:n,onValueChange:r,open:i,onOpenChange:a,defaultOpen:o,multiple:s,id:c,labelId:l})=>{let d=[...e.values()],f=(0,u.useMultipleSelection)({selectedItems:n!=null&&s?d.filter(e=>s?n.includes(e.value):n===e.value):void 0,initialSelectedItems:t!=null&&s?d.filter(e=>s?t.includes(e.value):t===e.value):void 0,onSelectedItemsChange:({selectedItems:e})=>{e!=null&&s&&r?.(e.map(e=>e.value))}});return{...(0,u.useSelect)({items:d,isItemDisabled:e=>e.disabled,itemToString:e=>e?e.text:``,id:c,labelId:l,isOpen:i,onIsOpenChange:({isOpen:e})=>{e!=null&&a?.(e)},initialIsOpen:o??!1,stateReducer:(e,{changes:t,type:n})=>{if(!s)return t;let{selectedItems:r,removeSelectedItem:i,addSelectedItem:a}=f;switch(n){case u.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case u.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case u.useSelect.stateChangeTypes.ItemClick:return t.selectedItem!=null&&(r.some(e=>e.value===t.selectedItem?.value)?i(t.selectedItem):a(t.selectedItem)),{...t,isOpen:!0,highlightedIndex:e.highlightedIndex};default:return t}},selectedItem:n!=null&&!s?e.get(n)||null:void 0,initialSelectedItem:(t!=null||n!=null)&&!s?e.get(t)||null:void 0,onSelectedItemChange:({selectedItem:e})=>{e?.value!=null&&!s&&r?.(e?.value)},scrollIntoView:e=>{e&&e.scrollIntoView({block:`nearest`})}}),...f,selectedItems:[...new Set(f.selectedItems)]}};function f(e,t){let n=0;for(let[r]of e.entries()){if(r===t)return n;n++}return-1}var p=(e,t)=>{let n=0;for(let r of e.keys()){if(n===t)return r;n++}},m=(e,t)=>{let n=p(e,t);return n===void 0?void 0:e.get(n)},h=e=>e?e.type.displayName:``,g=(e,t=[])=>(i.Children.forEach(e,e=>{if((0,i.isValidElement)(e)){if(h(e)===`Dropdown.Item`){let n=e.props;t.push({value:n.value,disabled:!!n.disabled,text:_(n.children)})}e.props.children&&g(e.props.children,t)}}),t),_=(e,t=``)=>typeof e==`string`?e:(i.Children.forEach(e,e=>{(0,i.isValidElement)(e)&&(h(e)===`Dropdown.ItemText`&&(t=e.props.children),e.props.children&&_(e.props.children,t))}),t),v=e=>{let t=new Map;return g(e).forEach(e=>{t.set(e.value,e)}),t},y=(e,t)=>i.Children.toArray(e).some(e=>(0,i.isValidElement)(e)?h(e)===t?!0:e.props.children?y(e.props.children,t):!1:!1),b=(0,i.createContext)(null),x=`:dropdown`,S=({children:e,defaultValue:t,value:r,onValueChange:o,open:s,onOpenChange:l,defaultOpen:u,multiple:f=!1,disabled:p=!1,readOnly:h=!1,state:g})=>{let[_,S]=(0,i.useState)(v(e)),[C,w]=(0,i.useState)(y(e,`Dropdown.Popover`)),[T,E]=(0,i.useState)(`mouse`),D=(0,c.useFormFieldControl)(),O=D.state||g,k=`${x}-label-${(0,i.useId)()}`,A=`${x}-input-${(0,i.useId)()}`,j=D.id||A,M=D.labelId||k,N=D.disabled??p,P=D.readOnly??h,F=d({itemsMap:_,defaultValue:t,value:r,onValueChange:o,open:s,onOpenChange:l,defaultOpen:u,multiple:f,id:j,labelId:M});(0,i.useEffect)(()=>{let t=v(e),n=[..._.values()],r=[...t.values()];(n.length!==r.length||n.some((e,t)=>{let n=e.value!==r[t]?.value,i=e.text!==r[t]?.text;return n||i}))&&S(t)},[e]);let[I,L]=C?[n.t,{open:!0}]:[i.Fragment,{}];return(0,a.jsx)(b,{value:{multiple:f,disabled:N,readOnly:P,...F,itemsMap:_,highlightedItem:m(_,F.highlightedIndex),hasPopover:C,setHasPopover:w,state:O,lastInteractionType:T,setLastInteractionType:E},children:(0,a.jsx)(I,{...L,children:e})})},C=()=>{let e=(0,i.useContext)(b);if(!e)throw Error(`useDropdownContext must be used within a Dropdown provider`);return e},w=({children:e,...t})=>(0,a.jsx)(S,{...t,children:e});w.displayName=`Dropdown`;var T=({className:e,ref:t})=>(0,a.jsx)(`div`,{ref:t,className:(0,r.cx)(`my-md border-b-sm border-outline`,e)});T.displayName=`Dropdown.Divider`;var E=(0,i.createContext)(null),D=({children:e})=>{let t=`${x}-group-label-${(0,i.useId)()}`;return(0,a.jsx)(E,{value:{labelId:t},children:e})},O=()=>{let e=(0,i.useContext)(E);if(!e)throw Error(`useDropdownGroupContext must be used within a DropdownGroup provider`);return e},k=({children:e,ref:t,...n})=>(0,a.jsx)(D,{children:(0,a.jsx)(A,{ref:t,...n,children:e})}),A=({children:e,className:t,ref:n})=>{let{labelId:i}=O();return(0,a.jsx)(`div`,{ref:n,role:`group`,"aria-labelledby":i,className:(0,r.cx)(t),children:e})};k.displayName=`Dropdown.Group`;var j=(0,i.createContext)(null),M=({value:e,disabled:t=!1,children:n})=>{let{multiple:r,itemsMap:o,selectedItem:s,selectedItems:c}=C(),[l,u]=(0,i.useState)(void 0),d=f(o,e),p={disabled:t,value:e,text:_(n)},m=r?c.some(t=>t.value===e):s?.value===e;return(0,a.jsx)(j,{value:{textId:l,setTextId:u,isSelected:m,itemData:p,index:d,disabled:t},children:n})},N=()=>{let e=(0,i.useContext)(j);if(!e)throw Error(`useDropdownItemContext must be used within a DropdownItem provider`);return e},P=({children:e,ref:t,...n})=>{let{value:r,disabled:i}=n;return(0,a.jsx)(M,{value:r,disabled:i,children:(0,a.jsx)(I,{ref:t,...n,children:e})})},F=(0,r.cva)(`px-lg py-md text-body-1`,{variants:{selected:{true:`font-bold`},disabled:{true:`opacity-dim-3 cursor-not-allowed`,false:`cursor-pointer`},highlighted:{true:``},interactionType:{mouse:``,keyboard:``}},compoundVariants:[{highlighted:!0,interactionType:`mouse`,class:`bg-surface-hovered`},{highlighted:!0,interactionType:`keyboard`,class:`u-outline`}]}),I=({className:e,disabled:t=!1,value:n,children:i,ref:o})=>{let{getItemProps:c,highlightedItem:l,lastInteractionType:u}=C(),{textId:d,index:f,itemData:p,isSelected:m}=N(),h=l?.value===n,{ref:g,..._}=c({item:p,index:f});return(0,a.jsx)(`li`,{ref:(0,s.useMergeRefs)(o,g),className:(0,r.cx)(F({selected:m,disabled:t,highlighted:h,interactionType:u,className:e})),..._,"aria-selected":m,"aria-labelledby":d,children:i},n)};P.displayName=`Dropdown.Item`;var L=({className:e,children:n,label:i,ref:o})=>{let{disabled:s,isSelected:c}=N(),u=n||(0,a.jsx)(t.t,{size:`sm`,children:(0,a.jsx)(l.Check,{"aria-label":i})});return(0,a.jsx)(`span`,{ref:o,className:(0,r.cx)(`min-h-sz-16 min-w-sz-16 flex`,s&&`opacity-dim-3`,e),children:c&&u})};L.displayName=`Dropdown.ItemIndicator`;var R=({children:e,className:t,ref:n,...o})=>{let{isOpen:c,getMenuProps:l,hasPopover:u,setLastInteractionType:d}=C(),{ref:f,...p}=l({onMouseMove:()=>{d(`mouse`)}}),m=(0,i.useRef)(null),h=(0,s.useMergeRefs)(n,f,m);return(0,i.useLayoutEffect)(()=>{u&&m.current&&m.current.parentElement&&(m.current.parentElement.style.pointerEvents=c?``:`none`,m.current.style.pointerEvents=c?``:`none`)},[c,u]),(0,a.jsx)(`ul`,{ref:h,className:(0,r.cx)(t,`flex flex-col`,c?`pointer-events-auto! block`:`pointer-events-none invisible absolute max-h-0 min-h-0 overflow-hidden opacity-0`,u&&c&&`p-lg`),...o,...p,"data-spark-component":`dropdown-items`,children:e})};R.displayName=`Dropdown.Items`;var z=({children:e,ref:t})=>{let n=`${x}-item-text-${(0,i.useId)()}`,{setTextId:o}=N();return(0,i.useEffect)(()=>(o(n),()=>o(void 0))),(0,a.jsx)(`span`,{id:n,className:(0,r.cx)(`inline`),ref:t,children:e})};z.displayName=`Dropdown.ItemText`;var B=({children:e,className:t,ref:n})=>{let{labelId:i}=O();return(0,a.jsx)(`div`,{ref:n,id:i,className:(0,r.cx)(`px-md py-sm text-body-2 text-neutral italic`,t),children:e})};B.displayName=`Dropdown.Label`;var V=({children:e})=>(0,a.jsx)(t.t,{size:`sm`,className:`shrink-0`,children:e});V.displayName=`Dropdown.LeadingIcon`;var H=({children:e,matchTriggerWidth:t=!0,sideOffset:o=4,className:s,elevation:c=`dropdown`,ref:l,...u})=>{let d=C();return(0,i.useEffect)(()=>(d.setHasPopover(!0),()=>d.setHasPopover(!1)),[]),(0,a.jsx)(n.t.Content,{ref:l,inset:!0,asChild:!0,matchTriggerWidth:t,elevation:c,className:(0,r.cx)(`relative`,s),sideOffset:o,onOpenAutoFocus:e=>{e.preventDefault()},...u,"data-spark-component":`dropdown-popover`,children:e})};H.displayName=`Dropdown.Popover`;var U=({children:e,...t})=>(0,a.jsx)(n.t.Portal,{...t,children:e});U.displayName=`Dropdown.Portal`;var W=(0,r.cva)([`flex w-full items-center justify-between`,`min-h-sz-44 rounded-input bg-surface text-on-surface px-lg`,`text-body-1`,`ring-1 outline-hidden ring-inset focus:ring-2 focus:ring-focus`],{variants:{state:{undefined:`ring-outline`,error:`ring-error`,alert:`ring-alert`,success:`ring-success`},disabled:{true:`disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3`},readOnly:{true:`disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3`}},compoundVariants:[{disabled:!1,state:void 0,class:`default:hover:ring-outline-high`}]}),G=({"aria-label":c,children:l,className:u,ref:d})=>{let{getToggleButtonProps:f,getDropdownProps:p,getLabelProps:m,hasPopover:h,disabled:g,readOnly:_,state:v,setLastInteractionType:y,isOpen:b}=C(),[x,S]=h?[n.t.Trigger,{asChild:!0}]:[i.Fragment,{}],{ref:w,...T}=f({...p(),onKeyDown:e=>{y(`keyboard`),e.key===`Escape`&&b&&e.stopPropagation()}}),E=T[`aria-expanded`],D=(0,s.useMergeRefs)(d,w);return(0,a.jsxs)(a.Fragment,{children:[c&&(0,a.jsx)(e.VisuallyHidden,{children:(0,a.jsx)(`label`,{...m(),children:c})}),(0,a.jsx)(x,{...S,children:(0,a.jsxs)(`button`,{type:`button`,ref:D,disabled:g||_,className:W({className:u,state:v,disabled:g,readOnly:_}),...T,"data-spark-component":`dropdown-trigger`,children:[(0,a.jsx)(`span`,{className:`gap-md flex items-center justify-start`,children:l}),(0,a.jsx)(t.t,{className:(0,r.cx)(`ml-md shrink-0 rotate-0 transition duration-100 ease-in`,{"rotate-180":E}),size:`sm`,children:(0,a.jsx)(o.ArrowHorizontalDown,{})})]})})]})};G.displayName=`Dropdown.Trigger`;var K=({children:e,className:t,placeholder:n,ref:i})=>{let{selectedItem:o,multiple:s,selectedItems:c}=C(),l=!!(s?c.length:o),u=s?c[0]?.text:o?.text,d=c.length>1?`, +${c.length-1}`:``;return(0,a.jsxs)(`span`,{ref:i,className:(0,r.cx)(`flex shrink items-center text-left`,t),children:[(0,a.jsx)(`span`,{className:(0,r.cx)(`line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis`,!l&&`text-on-surface/dim-1`),children:l?e||u:n}),d&&(0,a.jsx)(`span`,{children:d})]})};K.displayName=`Dropdown.Value`;var q=Object.assign(w,{Group:k,Item:P,Items:R,ItemText:z,ItemIndicator:L,Label:B,Popover:H,Divider:T,Trigger:G,Value:K,LeadingIcon:V,Portal:U});q.displayName=`Dropdown`,k.displayName=`Dropdown.Group`,R.displayName=`Dropdown.Items`,P.displayName=`Dropdown.Item`,z.displayName=`Dropdown.ItemText`,L.displayName=`Dropdown.ItemIndicator`,B.displayName=`Dropdown.Label`,H.displayName=`Dropdown.Popover`,T.displayName=`Dropdown.Divider`,G.displayName=`Dropdown.Trigger`,K.displayName=`Dropdown.Value`,V.displayName=`Dropdown.LeadingIcon`,U.displayName=`Dropdown.Portal`,exports.Dropdown=q,exports.DropdownProvider=S,exports.useDropdownContext=C;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../visually-hidden/index.js"),t=require("../icon-CfEsla9z.js"),n=require("../popover-B-mcHcLF.js");let r=require("class-variance-authority"),i=require("react"),a=require("react/jsx-runtime"),o=require("@spark-ui/icons/ArrowHorizontalDown"),s=require("@spark-ui/hooks/use-merge-refs"),c=require("@spark-ui/components/form-field"),l=require("@spark-ui/icons/Check"),u=require("downshift");var d=({itemsMap:e,defaultValue:t,value:n,onValueChange:r,open:i,onOpenChange:a,defaultOpen:o,multiple:s,id:c,labelId:l})=>{let d=[...e.values()],f=(0,u.useMultipleSelection)({selectedItems:n!=null&&s?d.filter(e=>s?n.includes(e.value):n===e.value):void 0,initialSelectedItems:t!=null&&s?d.filter(e=>s?t.includes(e.value):t===e.value):void 0,onSelectedItemsChange:({selectedItems:e})=>{e!=null&&s&&r?.(e.map(e=>e.value))}});return{...(0,u.useSelect)({items:d,isItemDisabled:e=>e.disabled,itemToString:e=>e?e.text:``,id:c,labelId:l,isOpen:i,onIsOpenChange:({isOpen:e})=>{e!=null&&a?.(e)},initialIsOpen:o??!1,stateReducer:(e,{changes:t,type:n})=>{if(!s)return t;let{selectedItems:r,removeSelectedItem:i,addSelectedItem:a}=f;switch(n){case u.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:case u.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:case u.useSelect.stateChangeTypes.ItemClick:return t.selectedItem!=null&&(r.some(e=>e.value===t.selectedItem?.value)?i(t.selectedItem):a(t.selectedItem)),{...t,isOpen:!0,highlightedIndex:e.highlightedIndex};default:return t}},selectedItem:n!=null&&!s?e.get(n)||null:void 0,initialSelectedItem:(t!=null||n!=null)&&!s?e.get(t)||null:void 0,onSelectedItemChange:({selectedItem:e})=>{e?.value!=null&&!s&&r?.(e?.value)},scrollIntoView:e=>{e&&e.scrollIntoView({block:`nearest`})}}),...f,selectedItems:[...new Set(f.selectedItems)]}};function f(e,t){let n=0;for(let[r]of e.entries()){if(r===t)return n;n++}return-1}var p=(e,t)=>{let n=0;for(let r of e.keys()){if(n===t)return r;n++}},m=(e,t)=>{let n=p(e,t);return n===void 0?void 0:e.get(n)},h=e=>e?e.type.displayName:``,g=(e,t=[])=>(i.Children.forEach(e,e=>{if((0,i.isValidElement)(e)){if(h(e)===`Dropdown.Item`){let n=e.props;t.push({value:n.value,disabled:!!n.disabled,text:_(n.children)})}e.props.children&&g(e.props.children,t)}}),t),_=(e,t=``)=>typeof e==`string`?e:(i.Children.forEach(e,e=>{(0,i.isValidElement)(e)&&(h(e)===`Dropdown.ItemText`&&(t=e.props.children),e.props.children&&_(e.props.children,t))}),t),v=e=>{let t=new Map;return g(e).forEach(e=>{t.set(e.value,e)}),t},y=(e,t)=>i.Children.toArray(e).some(e=>(0,i.isValidElement)(e)?h(e)===t?!0:e.props.children?y(e.props.children,t):!1:!1),b=(0,i.createContext)(null),x=`:dropdown`,S=({children:e,defaultValue:t,value:r,onValueChange:o,open:s,onOpenChange:l,defaultOpen:u,multiple:f=!1,disabled:p=!1,readOnly:h=!1,state:g})=>{let[_,S]=(0,i.useState)(v(e)),[C,w]=(0,i.useState)(y(e,`Dropdown.Popover`)),[T,E]=(0,i.useState)(`mouse`),D=(0,c.useFormFieldControl)(),O=D.state||g,k=`${x}-label-${(0,i.useId)()}`,A=`${x}-input-${(0,i.useId)()}`,j=D.id||A,M=D.labelId||k,N=D.disabled??p,P=D.readOnly??h,F=d({itemsMap:_,defaultValue:t,value:r,onValueChange:o,open:s,onOpenChange:l,defaultOpen:u,multiple:f,id:j,labelId:M});(0,i.useEffect)(()=>{let t=v(e),n=[..._.values()],r=[...t.values()];(n.length!==r.length||n.some((e,t)=>{let n=e.value!==r[t]?.value,i=e.text!==r[t]?.text;return n||i}))&&S(t)},[e]);let[I,L]=C?[n.t,{open:!0}]:[i.Fragment,{}];return(0,a.jsx)(b,{value:{multiple:f,disabled:N,readOnly:P,...F,itemsMap:_,highlightedItem:m(_,F.highlightedIndex),hasPopover:C,setHasPopover:w,state:O,lastInteractionType:T,setLastInteractionType:E},children:(0,a.jsx)(I,{...L,children:e})})},C=()=>{let e=(0,i.useContext)(b);if(!e)throw Error(`useDropdownContext must be used within a Dropdown provider`);return e},w=({children:e,...t})=>(0,a.jsx)(S,{...t,children:e});w.displayName=`Dropdown`;var T=({className:e,ref:t})=>(0,a.jsx)(`div`,{ref:t,className:(0,r.cx)(`my-md border-b-sm border-outline`,e)});T.displayName=`Dropdown.Divider`;var E=(0,i.createContext)(null),D=({children:e})=>{let t=`${x}-group-label-${(0,i.useId)()}`;return(0,a.jsx)(E,{value:{labelId:t},children:e})},O=()=>{let e=(0,i.useContext)(E);if(!e)throw Error(`useDropdownGroupContext must be used within a DropdownGroup provider`);return e},k=({children:e,ref:t,...n})=>(0,a.jsx)(D,{children:(0,a.jsx)(A,{ref:t,...n,children:e})}),A=({children:e,className:t,ref:n})=>{let{labelId:i}=O();return(0,a.jsx)(`div`,{ref:n,role:`group`,"aria-labelledby":i,className:(0,r.cx)(t),children:e})};k.displayName=`Dropdown.Group`;var j=(0,i.createContext)(null),M=({value:e,disabled:t=!1,children:n})=>{let{multiple:r,itemsMap:o,selectedItem:s,selectedItems:c}=C(),[l,u]=(0,i.useState)(void 0),d=f(o,e),p={disabled:t,value:e,text:_(n)},m=r?c.some(t=>t.value===e):s?.value===e;return(0,a.jsx)(j,{value:{textId:l,setTextId:u,isSelected:m,itemData:p,index:d,disabled:t},children:n})},N=()=>{let e=(0,i.useContext)(j);if(!e)throw Error(`useDropdownItemContext must be used within a DropdownItem provider`);return e},P=({children:e,ref:t,...n})=>{let{value:r,disabled:i}=n;return(0,a.jsx)(M,{value:r,disabled:i,children:(0,a.jsx)(I,{ref:t,...n,children:e})})},F=(0,r.cva)(`px-lg py-md text-body-1`,{variants:{selected:{true:`font-bold`},disabled:{true:`opacity-dim-3 cursor-not-allowed`,false:`cursor-pointer`},highlighted:{true:``},interactionType:{mouse:``,keyboard:``}},compoundVariants:[{highlighted:!0,interactionType:`mouse`,class:`bg-surface-hovered`},{highlighted:!0,interactionType:`keyboard`,class:`u-outline`}]}),I=({className:e,disabled:t=!1,value:n,children:i,ref:o})=>{let{getItemProps:c,highlightedItem:l,lastInteractionType:u}=C(),{textId:d,index:f,itemData:p,isSelected:m}=N(),h=l?.value===n,{ref:g,..._}=c({item:p,index:f});return(0,a.jsx)(`li`,{ref:(0,s.useMergeRefs)(o,g),className:(0,r.cx)(F({selected:m,disabled:t,highlighted:h,interactionType:u,className:e})),..._,"aria-selected":m,"aria-labelledby":d,children:i},n)};P.displayName=`Dropdown.Item`;var L=({className:e,children:n,label:i,ref:o})=>{let{disabled:s,isSelected:c}=N(),u=n||(0,a.jsx)(t.t,{size:`sm`,children:(0,a.jsx)(l.Check,{"aria-label":i})});return(0,a.jsx)(`span`,{ref:o,className:(0,r.cx)(`min-h-sz-16 min-w-sz-16 flex`,s&&`opacity-dim-3`,e),children:c&&u})};L.displayName=`Dropdown.ItemIndicator`;var R=({children:e,className:t,ref:n,...o})=>{let{isOpen:c,getMenuProps:l,hasPopover:u,setLastInteractionType:d}=C(),{ref:f,...p}=l({onMouseMove:()=>{d(`mouse`)}}),m=(0,i.useRef)(null),h=(0,s.useMergeRefs)(n,f,m);return(0,i.useLayoutEffect)(()=>{u&&m.current&&m.current.parentElement&&(m.current.parentElement.style.pointerEvents=c?``:`none`,m.current.style.pointerEvents=c?``:`none`)},[c,u]),(0,a.jsx)(`ul`,{ref:h,className:(0,r.cx)(t,`flex flex-col`,c?`pointer-events-auto! block`:`pointer-events-none invisible absolute max-h-0 min-h-0 overflow-hidden opacity-0`,u&&c&&`p-lg`),...o,...p,"data-spark-component":`dropdown-items`,children:e})};R.displayName=`Dropdown.Items`;var z=({children:e,ref:t})=>{let n=`${x}-item-text-${(0,i.useId)()}`,{setTextId:o}=N();return(0,i.useEffect)(()=>(o(n),()=>o(void 0))),(0,a.jsx)(`span`,{id:n,className:(0,r.cx)(`inline`),ref:t,children:e})};z.displayName=`Dropdown.ItemText`;var B=({children:e,className:t,ref:n})=>{let{labelId:i}=O();return(0,a.jsx)(`div`,{ref:n,id:i,className:(0,r.cx)(`px-md py-sm text-body-2 text-neutral italic`,t),children:e})};B.displayName=`Dropdown.Label`;var V=({children:e})=>(0,a.jsx)(t.t,{size:`sm`,className:`shrink-0`,children:e});V.displayName=`Dropdown.LeadingIcon`;var H=({children:e,matchTriggerWidth:t=!0,sideOffset:o=4,className:s,elevation:c=`dropdown`,ref:l,...u})=>{let d=C();return(0,i.useEffect)(()=>(d.setHasPopover(!0),()=>d.setHasPopover(!1)),[]),(0,a.jsx)(n.t.Content,{ref:l,inset:!0,asChild:!0,matchTriggerWidth:t,elevation:c,className:(0,r.cx)(`relative`,s),sideOffset:o,onOpenAutoFocus:e=>{e.preventDefault()},...u,"data-spark-component":`dropdown-popover`,children:e})};H.displayName=`Dropdown.Popover`;var U=({children:e,...t})=>(0,a.jsx)(n.t.Portal,{...t,children:e});U.displayName=`Dropdown.Portal`;var W=(0,r.cva)([`flex w-full items-center justify-between`,`min-h-sz-44 rounded-input bg-surface text-on-surface px-lg`,`text-body-1`,`ring-1 outline-hidden ring-inset focus:ring-2 focus:ring-focus`],{variants:{state:{undefined:`ring-outline`,error:`ring-error`,alert:`ring-alert`,success:`ring-success`},disabled:{true:`disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3`},readOnly:{true:`disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3`}},compoundVariants:[{disabled:!1,state:void 0,class:`default:hover:ring-outline-high`}]}),G=({"aria-label":c,children:l,className:u,ref:d})=>{let{getToggleButtonProps:f,getDropdownProps:p,getLabelProps:m,hasPopover:h,disabled:g,readOnly:_,state:v,setLastInteractionType:y,isOpen:b}=C(),[x,S]=h?[n.t.Trigger,{asChild:!0}]:[i.Fragment,{}],{ref:w,...T}=f({...p(),onKeyDown:e=>{y(`keyboard`),e.key===`Escape`&&b&&e.stopPropagation()}}),E=T[`aria-expanded`],D=(0,s.useMergeRefs)(d,w);return(0,a.jsxs)(a.Fragment,{children:[c&&(0,a.jsx)(e.VisuallyHidden,{children:(0,a.jsx)(`label`,{...m(),children:c})}),(0,a.jsx)(x,{...S,children:(0,a.jsxs)(`button`,{type:`button`,ref:D,disabled:g||_,className:W({className:u,state:v,disabled:g,readOnly:_}),...T,"data-spark-component":`dropdown-trigger`,children:[(0,a.jsx)(`span`,{className:`gap-md flex items-center justify-start`,children:l}),(0,a.jsx)(t.t,{className:(0,r.cx)(`ml-md shrink-0 rotate-0 transition duration-100 ease-in`,{"rotate-180":E}),size:`sm`,children:(0,a.jsx)(o.ArrowHorizontalDown,{})})]})})]})};G.displayName=`Dropdown.Trigger`;var K=({children:e,className:t,placeholder:n,ref:i})=>{let{selectedItem:o,multiple:s,selectedItems:c}=C(),l=!!(s?c.length:o),u=s?c[0]?.text:o?.text,d=c.length>1?`, +${c.length-1}`:``;return(0,a.jsxs)(`span`,{ref:i,className:(0,r.cx)(`flex shrink items-center text-left`,t),children:[(0,a.jsx)(`span`,{className:(0,r.cx)(`line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis`,!l&&`text-on-surface/dim-1`),children:l?e||u:n}),d&&(0,a.jsx)(`span`,{children:d})]})};K.displayName=`Dropdown.Value`;var q=Object.assign(w,{Group:k,Item:P,Items:R,ItemText:z,ItemIndicator:L,Label:B,Popover:H,Divider:T,Trigger:G,Value:K,LeadingIcon:V,Portal:U});q.displayName=`Dropdown`,k.displayName=`Dropdown.Group`,R.displayName=`Dropdown.Items`,P.displayName=`Dropdown.Item`,z.displayName=`Dropdown.ItemText`,L.displayName=`Dropdown.ItemIndicator`,B.displayName=`Dropdown.Label`,H.displayName=`Dropdown.Popover`,T.displayName=`Dropdown.Divider`,G.displayName=`Dropdown.Trigger`,K.displayName=`Dropdown.Value`,V.displayName=`Dropdown.LeadingIcon`,U.displayName=`Dropdown.Portal`,exports.Dropdown=q,exports.DropdownProvider=S,exports.useDropdownContext=C;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/dropdown/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VisuallyHidden as e } from "../visually-hidden/index.mjs";
|
|
2
|
-
import { t } from "../icon-
|
|
3
|
-
import { t as n } from "../popover-
|
|
2
|
+
import { t } from "../icon-VM_Ys9Xn.mjs";
|
|
3
|
+
import { t as n } from "../popover-COqbFikI.mjs";
|
|
4
4
|
import { cva as r, cx as i } from "class-variance-authority";
|
|
5
5
|
import { Children as a, Fragment as o, createContext as s, isValidElement as c, useContext as l, useEffect as u, useId as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
|
|
6
6
|
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-CMqjfN_6.js"),t=require("../slot/index.js"),n=require("../icon-DY4l9nsc.js"),r=require("../button-D0s-21qo.js"),i=require("../icon-button-DRFf308H.js"),a=require("../progress-B_zfJmtJ.js");let o=require("class-variance-authority"),s=require("react");s=e.t(s);let c=require("react/jsx-runtime"),l=require("@spark-ui/components/form-field"),u=require("@spark-ui/hooks/use-combined-state"),d=require("@spark-ui/icons/Close"),f=require("@spark-ui/icons/CvOutline"),p=require("@spark-ui/icons/FilePdfOutline"),m=require("@spark-ui/icons/ImageOutline"),h=require("@spark-ui/icons/PlayOutline"),g=require("@spark-ui/icons/WarningOutline");var _={TOO_MANY_FILES:`TOO_MANY_FILES`,FILE_INVALID_TYPE:`FILE_INVALID_TYPE`,FILE_TOO_LARGE:`FILE_TOO_LARGE`,FILE_TOO_SMALL:`FILE_TOO_SMALL`,FILE_INVALID:`FILE_INVALID`,FILE_EXISTS:`FILE_EXISTS`};function v(e,t){return!t||t.split(`,`).map(e=>e.trim()).some(t=>{if(t.includes(`/`)){if(t.endsWith(`/*`)){let n=t.slice(0,-2);return e.type.startsWith(n+`/`)}return e.type===t}if(t.startsWith(`.`)){let n=t.toLowerCase();return e.name.toLowerCase().endsWith(n)}let n=`.`+t.toLowerCase();return e.name.toLowerCase().endsWith(n)})}function y(e,t,n,r){let i=r||b();return t!==void 0&&e.size<t?{valid:!1,error:`File "${e.name}" is too small. Minimum size is ${x(t,i)}.`}:n!==void 0&&e.size>n?{valid:!1,error:`File "${e.name}" is too large. Maximum size is ${x(n,i)}.`}:{valid:!0}}function b(){return typeof navigator<`u`&&navigator.language?navigator.language:`en`}function x(e,t){let n=t||b(),r=n;if(n.length===2&&(r=n===`fr`?`fr-FR`:`en-US`),e===0)return new Intl.NumberFormat(r,{style:`unit`,unit:`byte`,unitDisplay:`long`,minimumFractionDigits:0,maximumFractionDigits:0}).format(0);let i=1024,a=Math.floor(Math.log(e)/Math.log(i)),o=[`byte`,`kilobyte`,`megabyte`,`gigabyte`][a]||`byte`,s=e/i**a,c=a===0?`long`:`short`;return new Intl.NumberFormat(r,{style:`unit`,unit:o,unitDisplay:c,minimumFractionDigits:0,maximumFractionDigits:2}).format(s)}function S(e){let t=e.type.toLowerCase(),n=e.name.toLowerCase();return t.startsWith(`image/`)||/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(n)?(0,s.createElement)(m.ImageOutline):t===`application/pdf`||n.endsWith(`.pdf`)?(0,s.createElement)(p.FilePdfOutline):t.startsWith(`video/`)||/\.(mp4|avi|mov|wmv|flv|webm|mkv)$/i.test(n)?(0,s.createElement)(h.PlayOutline):(0,s.createElement)(f.CvOutline)}function C(e){if(!e)return!1;if(e.tabIndex>=0)return!0;let t=String(e.contentEditable)===`true`;return e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLAnchorElement&&!!e.href||t}function w(e,t){for(let t of e)if(C(t))return t;return t.current?t.current:null}function T({defaultValue:e=[],value:t,onFileAccept:n,onFileReject:r,onFileChange:i,multiple:a=!0,accept:o,maxFiles:c,maxFileSize:l,minFileSize:d,disabled:f=!1,readOnly:p=!1,locale:m}){let h=m||(typeof navigator<`u`&&navigator.language?navigator.language:`en`),[g,b]=(0,u.useCombinedState)(t,e),x=g??[],S=b,[C,w]=(0,s.useState)([]);return{files:x,rejectedFiles:C,addFiles:e=>{if(f||p)return;w([]);let t=[],s=(e,t)=>t.some(t=>t.name===e.name&&t.size===e.size),u=(e,n)=>{let r=t.find(t=>t.file.name===e.name&&t.file.size===e.size);r?r.errors.includes(n)||r.errors.push(n):t.push({file:e,errors:[n]})};S(f=>{let p=f??[],m=c===void 0?void 0:c-p.length;m!==void 0&&m<=0&&e.forEach(e=>{u(e,_.TOO_MANY_FILES)});let g=e;o&&(e.filter(e=>!v(e,o)).forEach(e=>{u(e,_.FILE_INVALID_TYPE)}),g=e.filter(e=>v(e,o)));let b=g;(d!==void 0||l!==void 0)&&(b=g.filter(e=>y(e,d,l,h).valid?!0:(l!==void 0&&e.size>l?u(e,_.FILE_TOO_LARGE):d!==void 0&&e.size<d?u(e,_.FILE_TOO_SMALL):u(e,_.FILE_INVALID),!1)));let x=new Map,S=b.filter(e=>{let t=`${e.name}-${e.size}`;return s(e,p)||x.has(t)?(u(e,_.FILE_EXISTS),!1):(x.set(t,e),!0)}),C=a?S:S.slice(0,1);m!==void 0&&(m<=0?C=[]:C.length>m&&(C.forEach(e=>{u(e,_.TOO_MANY_FILES)}),C=[]));let T=a?[...p,...C]:C,E=[...t];return w(E),C.length>0&&n&&n({files:C}),E.length>0&&r&&r({files:E}),i&&i({acceptedFiles:T,rejectedFiles:E}),T})},removeFile:e=>{f||p||S(t=>{let n=(t??[]).filter((t,n)=>n!==e),r=C;return c!==void 0&&n.length<c&&(r=C.filter(e=>!e.errors.includes(_.TOO_MANY_FILES)),w(r)),i&&i({acceptedFiles:n,rejectedFiles:r}),n})},removeRejectedFile:e=>{f||p||w(t=>t.filter((t,n)=>n!==e))},clearFiles:()=>{f||p||(S([]),w([]),i&&i({acceptedFiles:[],rejectedFiles:[]}))},clearRejectedFiles:()=>{w([])},maxFilesReached:c!==void 0&&x.length>=c}}var E=(0,s.createContext)(null),D=`:file-upload`,O=({asChild:e=!1,children:t,defaultValue:n=[],value:r,onFileAccept:i,onFileReject:a,onFileChange:o,multiple:u=!0,accept:d,maxFiles:f,maxFileSize:p,minFileSize:m,disabled:h=!1,readOnly:g=!1,locale:_})=>{let v=(0,l.useFormFieldControl)(),y=(0,s.useId)(),b=v.id||`${D}-${y}`,x=v.name,S=(0,s.useRef)(null),C=(0,s.useRef)(null),w=(0,s.useRef)(null),O=(0,s.useRef)([]),k=(0,s.useRef)([]),A=v.disabled??h,j=v.readOnly??g,{files:M,rejectedFiles:N,addFiles:P,removeFile:F,removeRejectedFile:I,clearFiles:L,clearRejectedFiles:R,maxFilesReached:z}=T({defaultValue:n,value:r,onFileAccept:i,onFileReject:a,onFileChange:o,multiple:u,accept:d,maxFiles:f,maxFileSize:p,minFileSize:m,disabled:A,readOnly:j,locale:_});return(0,c.jsx)(E,{value:{inputRef:S,files:M,rejectedFiles:N,addFiles:P,removeFile:F,removeRejectedFile:I,clearFiles:()=>{L(),O.current=[]},clearRejectedFiles:()=>{R(),k.current=[]},triggerRef:C,dropzoneRef:w,deleteButtonRefs:O,rejectedFileDeleteButtonRefs:k,multiple:u,maxFiles:f,maxFilesReached:z,disabled:A,readOnly:j,locale:_||(typeof navigator<`u`&&navigator.language?navigator.language:`en`),description:v.description,isInvalid:v.isInvalid,isRequired:v.isRequired},children:(0,c.jsxs)(`div`,{className:`relative`,children:[t,(0,c.jsx)(`input`,{ref:S,type:`file`,tabIndex:-1,id:b,multiple:u,name:x,accept:d,disabled:A,readOnly:j&&!A,required:v.isRequired,"aria-invalid":v.isInvalid,"aria-describedby":v.description,"aria-label":v.labelId?void 0:`Upload files`,className:`sr-only`,onChange:e=>{if(e.target.files&&!A&&!j){P(Array.from(e.target.files));try{e.target.value=``}catch{}}}})]})})};O.displayName=`FileUpload`;var k=()=>{let e=(0,s.useContext)(E);if(!e)throw Error(`useFileUploadContext must be used within a FileUpload provider`);return e},A=({className:e,file:t,onClick:r,...a})=>{let{removeFile:l,triggerRef:u,dropzoneRef:f,deleteButtonRefs:p,inputRef:m,disabled:h,readOnly:g,files:_}=k(),v=(0,s.useRef)(null),y=_.findIndex(e=>e.name===t.name&&e.size===t.size);return(0,c.jsx)(i.t,{ref:e=>{if(v.current=e,e){for(;p.current.length<=y;)p.current.push(null);p.current[y]=e}else p.current[y]&&(p.current[y]=null)},"data-spark-component":`file-upload-item-delete-trigger`,className:(0,o.cx)(e),onClick:e=>{h||g||(l(y),requestAnimationFrame(()=>{let e=p.current.filter(Boolean);if(e.length>0){let t=e[Math.min(y,e.length-1)];t&&t.focus()}else{let e=w([u.current,f.current],m);e&&e.focus()}}),r?.(e))},disabled:h||g,size:`sm`,design:`contrast`,intent:`surface`,...a,children:(0,c.jsx)(n.t,{size:`sm`,children:(0,c.jsx)(d.Close,{})})})};A.displayName=`FileUpload.ItemDeleteTrigger`;var j=({className:e,file:t,uploadProgress:r,deleteButtonAriaLabel:i,progressAriaLabel:l,...u})=>{let{locale:d}=k(),[f,p]=(0,s.useState)(r!==void 0);(0,s.useEffect)(()=>{p(r!==void 0)},[r]);let m=(0,s.useCallback)(()=>{p(!1)},[]);return(0,c.jsxs)(`li`,{"data-spark-component":`file-upload-accepted-file`,className:(0,o.cx)(`relative`,`default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md`,`gap-md flex items-center justify-between default:w-full`,e),...u,children:[(0,c.jsx)(`div`,{className:`size-sz-36 bg-support-container flex items-center justify-center rounded-md`,children:(0,c.jsx)(n.t,{size:`md`,children:S(t)})}),(0,c.jsxs)(`div`,{className:`gap-md relative flex min-w-0 flex-1 flex-row items-center justify-between self-stretch`,children:[(0,c.jsx)(`p`,{className:`text-body-2 truncate font-medium`,children:t.name}),(0,c.jsx)(`p`,{className:`text-caption opacity-dim-1`,children:x(t.size,d)}),f&&r!==void 0&&(0,c.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full`,children:(0,c.jsx)(a.t,{value:r,max:100,"aria-label":l,onComplete:m})})]}),(0,c.jsx)(A,{"aria-label":i,file:t})]})};j.displayName=`FileUpload.AcceptedFile`;var M=({children:e})=>{let{files:t=[],rejectedFiles:n=[],locale:r}=k();return(0,c.jsx)(c.Fragment,{children:e({acceptedFiles:t,rejectedFiles:n,formatFileSize:x,locale:r})})};M.displayName=`FileUpload.Context`;var N=(0,s.createContext)(!1),P=()=>(0,s.useContext)(N);function F({children:e,className:t,unstyled:n=!1}){let r=k(),i=(0,s.useRef)(null);if(!r)throw Error(`FileUploadDropzone must be used inside <FileUpload>`);let a=e=>{if(e.preventDefault(),e.stopPropagation(),e.currentTarget.setAttribute(`data-drag-over`,`false`),r.disabled||r.readOnly)return;let t=e.dataTransfer.files,n=[];t&&(n=Array.isArray(t)?[...t]:Array.from(t)),n.length>0&&r.addFiles(n)},l=()=>{!r.disabled&&!r.readOnly&&r.inputRef.current?.click()},u=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),!r.disabled&&!r.readOnly&&r.inputRef.current?.click())},d=r.disabled||r.readOnly;return(0,c.jsx)(N,{value:!0,children:(0,c.jsx)(`div`,{ref:e=>{i.current=e,r.dropzoneRef&&(r.dropzoneRef.current=e)},role:`button`,tabIndex:d?-1:0,"aria-disabled":r.disabled?!0:void 0,"aria-describedby":r.description,"aria-invalid":r.isInvalid,"aria-required":r.isRequired,onClick:l,onKeyDown:u,onDrop:a,onDragOver:e=>{e.preventDefault()},className:n?t:(0,o.cx)(`default:bg-surface default:border-sm default:border-outline default:relative default:rounded-lg default:border-dashed`,`gap-lg flex flex-col items-center justify-center text-center`,`default:p-xl`,`transition-colors duration-200`,!d&&`default:hover:bg-surface-hovered`,`data-[drag-over=true]:border-outline-high data-[drag-over=true]:bg-surface-hovered data-[drag-over=true]:border-solid`,r.disabled&&`cursor-not-allowed opacity-50`,r.readOnly&&!r.disabled&&`cursor-default`,t),onDragEnter:e=>{d||e.currentTarget.setAttribute(`data-drag-over`,`true`)},onDragLeave:e=>{e.currentTarget.setAttribute(`data-drag-over`,`false`)},children:e})})}F.displayName=`FileUploadDropzone`;var I=({className:e,file:t,fallback:n=`📄`,...r})=>{let[i,a]=(0,s.useState)(!1),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),p=t.type.startsWith(`image/`);return(0,s.useEffect)(()=>{if(!p){f(null);return}let e=URL.createObjectURL(t);return f(e),()=>{URL.revokeObjectURL(e)}},[t,p]),!p||i?(0,c.jsx)(`div`,{"data-spark-component":`file-upload-preview-image`,className:(0,o.cx)(`bg-neutral-container flex items-center justify-center rounded-md`,e),...r,children:n}):(0,c.jsxs)(`div`,{"data-spark-component":`file-upload-preview-image`,className:(0,o.cx)(`bg-neutral-container overflow-hidden`,e),...r,children:[(0,c.jsx)(`img`,{src:d,alt:t.name,className:(0,o.cx)(`size-full object-cover`,!l&&`opacity-0`),onLoad:()=>u(!0),onError:()=>a(!0)}),!l&&(0,c.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:n})]})};I.displayName=`FileUpload.PreviewImage`;var L=({className:e,rejectedFile:t,onClick:r,...a})=>{let{removeRejectedFile:l,triggerRef:u,dropzoneRef:f,rejectedFileDeleteButtonRefs:p,inputRef:m,disabled:h,readOnly:g,rejectedFiles:_}=k(),v=(0,s.useRef)(null),y=_.findIndex(e=>e.file.name===t.file.name&&e.file.size===t.file.size);return(0,c.jsx)(i.t,{ref:e=>{if(v.current=e,e){for(;p.current.length<=y;)p.current.push(null);p.current[y]=e}else p.current[y]&&(p.current[y]=null)},"data-spark-component":`file-upload-rejected-file-delete-trigger`,className:(0,o.cx)(e),onClick:e=>{h||g||(l(y),requestAnimationFrame(()=>{let e=p.current.filter(Boolean);if(e.length>0){let t=e[Math.min(y,e.length-1)];t&&t.focus()}else{let e=w([u.current,f.current],m);e&&e.focus()}}),r?.(e))},disabled:h||g,size:`sm`,design:`contrast`,intent:`surface`,...a,children:(0,c.jsx)(n.t,{size:`sm`,children:(0,c.jsx)(d.Close,{})})})};L.displayName=`FileUpload.RejectedFileDeleteTrigger`;var R=({className:e,rejectedFile:t,renderError:r,deleteButtonAriaLabel:i,...a})=>{let{locale:s}=k();return(0,c.jsxs)(`li`,{"data-spark-component":`file-upload-rejected-file`,className:(0,o.cx)(`relative`,`default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md`,`gap-md flex items-center justify-between default:w-full`,`border-error border-md`,e),...a,children:[(0,c.jsx)(`div`,{className:`size-sz-36 bg-error-container flex items-center justify-center rounded-md`,children:(0,c.jsx)(n.t,{size:`md`,className:`text-error`,children:(0,c.jsx)(g.WarningOutline,{})})}),(0,c.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,c.jsxs)(`div`,{className:`gap-md flex flex-col`,children:[(0,c.jsxs)(`div`,{className:`gap-md flex flex-row items-center justify-between`,children:[(0,c.jsx)(`p`,{className:`text-body-2 truncate font-medium`,children:t.file.name}),(0,c.jsx)(`p`,{className:`text-caption opacity-dim-1`,children:x(t.file.size,s)})]}),(0,c.jsx)(`div`,{className:`gap-xs flex flex-col`,children:t.errors.map((e,t)=>(0,c.jsx)(`div`,{className:`text-caption text-error`,"data-error-code":e,children:r(e)},t))})]})}),(0,c.jsx)(L,{"aria-label":i,rejectedFile:t})]})};R.displayName=`FileUpload.RejectedFile`;var z=({className:e,children:n,asChild:i=!1,unstyled:a=!1,design:s=`filled`,intent:l=`support`,size:u=`md`,shape:d=`rounded`,ref:f,...p})=>{let{inputRef:m,triggerRef:h,disabled:g,readOnly:_,description:v,isInvalid:y,isRequired:b}=k(),x=P(),S=e=>{e.stopPropagation(),e.preventDefault(),!g&&!_&&m.current?.click()},C=e=>{h&&(h.current=e),f&&(typeof f==`function`?f(e):f.current=e)},w,T;return x?(w=`span`,T={ref:C,"data-spark-component":`file-upload-trigger`,className:a?e:r.n({design:s,intent:l,size:u,shape:d,disabled:g||_,className:e})}):(w=i?t.Slot:a?`button`:r.t,T={ref:C,type:`button`,design:s,intent:l,size:u,shape:d,"data-spark-component":`file-upload-trigger`,className:(0,o.cx)(e),disabled:g||_,onClick:S,"aria-describedby":v,"aria-invalid":y,"aria-required":b,...p}),(0,c.jsx)(w,{...T,children:n})};z.displayName=`FileUpload.Trigger`;var B=Object.assign(O,{Trigger:z,Dropzone:F,Context:M,AcceptedFile:j,RejectedFile:R,PreviewImage:I,ItemDeleteTrigger:A,RejectedFileDeleteTrigger:L});B.displayName=`FileUpload`,z.displayName=`FileUpload.Trigger`,F.displayName=`FileUpload.Dropzone`,M.displayName=`FileUpload.Context`,A.displayName=`FileUpload.ItemDeleteTrigger`,I.displayName=`FileUpload.PreviewImage`,j.displayName=`FileUpload.AcceptedFile`,R.displayName=`FileUpload.RejectedFile`,L.displayName=`FileUpload.RejectedFileDeleteTrigger`,exports.FILE_UPLOAD_ERRORS=_,exports.FileUpload=B;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-CMqjfN_6.js"),t=require("../slot/index.js"),n=require("../icon-CfEsla9z.js"),r=require("../button-3vvMrf1L.js"),i=require("../icon-button-B2TM0Xby.js"),a=require("../progress-B_zfJmtJ.js");let o=require("class-variance-authority"),s=require("react");s=e.t(s);let c=require("react/jsx-runtime"),l=require("@spark-ui/components/form-field"),u=require("@spark-ui/hooks/use-combined-state"),d=require("@spark-ui/icons/Close"),f=require("@spark-ui/icons/CvOutline"),p=require("@spark-ui/icons/FilePdfOutline"),m=require("@spark-ui/icons/ImageOutline"),h=require("@spark-ui/icons/PlayOutline"),g=require("@spark-ui/icons/WarningOutline");var _={TOO_MANY_FILES:`TOO_MANY_FILES`,FILE_INVALID_TYPE:`FILE_INVALID_TYPE`,FILE_TOO_LARGE:`FILE_TOO_LARGE`,FILE_TOO_SMALL:`FILE_TOO_SMALL`,FILE_INVALID:`FILE_INVALID`,FILE_EXISTS:`FILE_EXISTS`};function v(e,t){return!t||t.split(`,`).map(e=>e.trim()).some(t=>{if(t.includes(`/`)){if(t.endsWith(`/*`)){let n=t.slice(0,-2);return e.type.startsWith(n+`/`)}return e.type===t}if(t.startsWith(`.`)){let n=t.toLowerCase();return e.name.toLowerCase().endsWith(n)}let n=`.`+t.toLowerCase();return e.name.toLowerCase().endsWith(n)})}function y(e,t,n,r){let i=r||b();return t!==void 0&&e.size<t?{valid:!1,error:`File "${e.name}" is too small. Minimum size is ${x(t,i)}.`}:n!==void 0&&e.size>n?{valid:!1,error:`File "${e.name}" is too large. Maximum size is ${x(n,i)}.`}:{valid:!0}}function b(){return typeof navigator<`u`&&navigator.language?navigator.language:`en`}function x(e,t){let n=t||b(),r=n;if(n.length===2&&(r=n===`fr`?`fr-FR`:`en-US`),e===0)return new Intl.NumberFormat(r,{style:`unit`,unit:`byte`,unitDisplay:`long`,minimumFractionDigits:0,maximumFractionDigits:0}).format(0);let i=1024,a=Math.floor(Math.log(e)/Math.log(i)),o=[`byte`,`kilobyte`,`megabyte`,`gigabyte`][a]||`byte`,s=e/i**a,c=a===0?`long`:`short`;return new Intl.NumberFormat(r,{style:`unit`,unit:o,unitDisplay:c,minimumFractionDigits:0,maximumFractionDigits:2}).format(s)}function S(e){let t=e.type.toLowerCase(),n=e.name.toLowerCase();return t.startsWith(`image/`)||/\.(jpg|jpeg|png|gif|bmp|webp|svg|ico)$/i.test(n)?(0,s.createElement)(m.ImageOutline):t===`application/pdf`||n.endsWith(`.pdf`)?(0,s.createElement)(p.FilePdfOutline):t.startsWith(`video/`)||/\.(mp4|avi|mov|wmv|flv|webm|mkv)$/i.test(n)?(0,s.createElement)(h.PlayOutline):(0,s.createElement)(f.CvOutline)}function C(e){if(!e)return!1;if(e.tabIndex>=0)return!0;let t=String(e.contentEditable)===`true`;return e instanceof HTMLInputElement||e instanceof HTMLButtonElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLAnchorElement&&!!e.href||t}function w(e,t){for(let t of e)if(C(t))return t;return t.current?t.current:null}function T({defaultValue:e=[],value:t,onFileAccept:n,onFileReject:r,onFileChange:i,multiple:a=!0,accept:o,maxFiles:c,maxFileSize:l,minFileSize:d,disabled:f=!1,readOnly:p=!1,locale:m}){let h=m||(typeof navigator<`u`&&navigator.language?navigator.language:`en`),[g,b]=(0,u.useCombinedState)(t,e),x=g??[],S=b,[C,w]=(0,s.useState)([]);return{files:x,rejectedFiles:C,addFiles:e=>{if(f||p)return;w([]);let t=[],s=(e,t)=>t.some(t=>t.name===e.name&&t.size===e.size),u=(e,n)=>{let r=t.find(t=>t.file.name===e.name&&t.file.size===e.size);r?r.errors.includes(n)||r.errors.push(n):t.push({file:e,errors:[n]})};S(f=>{let p=f??[],m=c===void 0?void 0:c-p.length;m!==void 0&&m<=0&&e.forEach(e=>{u(e,_.TOO_MANY_FILES)});let g=e;o&&(e.filter(e=>!v(e,o)).forEach(e=>{u(e,_.FILE_INVALID_TYPE)}),g=e.filter(e=>v(e,o)));let b=g;(d!==void 0||l!==void 0)&&(b=g.filter(e=>y(e,d,l,h).valid?!0:(l!==void 0&&e.size>l?u(e,_.FILE_TOO_LARGE):d!==void 0&&e.size<d?u(e,_.FILE_TOO_SMALL):u(e,_.FILE_INVALID),!1)));let x=new Map,S=b.filter(e=>{let t=`${e.name}-${e.size}`;return s(e,p)||x.has(t)?(u(e,_.FILE_EXISTS),!1):(x.set(t,e),!0)}),C=a?S:S.slice(0,1);m!==void 0&&(m<=0?C=[]:C.length>m&&(C.forEach(e=>{u(e,_.TOO_MANY_FILES)}),C=[]));let T=a?[...p,...C]:C,E=[...t];return w(E),C.length>0&&n&&n({files:C}),E.length>0&&r&&r({files:E}),i&&i({acceptedFiles:T,rejectedFiles:E}),T})},removeFile:e=>{f||p||S(t=>{let n=(t??[]).filter((t,n)=>n!==e),r=C;return c!==void 0&&n.length<c&&(r=C.filter(e=>!e.errors.includes(_.TOO_MANY_FILES)),w(r)),i&&i({acceptedFiles:n,rejectedFiles:r}),n})},removeRejectedFile:e=>{f||p||w(t=>t.filter((t,n)=>n!==e))},clearFiles:()=>{f||p||(S([]),w([]),i&&i({acceptedFiles:[],rejectedFiles:[]}))},clearRejectedFiles:()=>{w([])},maxFilesReached:c!==void 0&&x.length>=c}}var E=(0,s.createContext)(null),D=`:file-upload`,O=({asChild:e=!1,children:t,defaultValue:n=[],value:r,onFileAccept:i,onFileReject:a,onFileChange:o,multiple:u=!0,accept:d,maxFiles:f,maxFileSize:p,minFileSize:m,disabled:h=!1,readOnly:g=!1,locale:_})=>{let v=(0,l.useFormFieldControl)(),y=(0,s.useId)(),b=v.id||`${D}-${y}`,x=v.name,S=(0,s.useRef)(null),C=(0,s.useRef)(null),w=(0,s.useRef)(null),O=(0,s.useRef)([]),k=(0,s.useRef)([]),A=v.disabled??h,j=v.readOnly??g,{files:M,rejectedFiles:N,addFiles:P,removeFile:F,removeRejectedFile:I,clearFiles:L,clearRejectedFiles:R,maxFilesReached:z}=T({defaultValue:n,value:r,onFileAccept:i,onFileReject:a,onFileChange:o,multiple:u,accept:d,maxFiles:f,maxFileSize:p,minFileSize:m,disabled:A,readOnly:j,locale:_});return(0,c.jsx)(E,{value:{inputRef:S,files:M,rejectedFiles:N,addFiles:P,removeFile:F,removeRejectedFile:I,clearFiles:()=>{L(),O.current=[]},clearRejectedFiles:()=>{R(),k.current=[]},triggerRef:C,dropzoneRef:w,deleteButtonRefs:O,rejectedFileDeleteButtonRefs:k,multiple:u,maxFiles:f,maxFilesReached:z,disabled:A,readOnly:j,locale:_||(typeof navigator<`u`&&navigator.language?navigator.language:`en`),description:v.description,isInvalid:v.isInvalid,isRequired:v.isRequired},children:(0,c.jsxs)(`div`,{className:`relative`,children:[t,(0,c.jsx)(`input`,{ref:S,type:`file`,tabIndex:-1,id:b,multiple:u,name:x,accept:d,disabled:A,readOnly:j&&!A,required:v.isRequired,"aria-invalid":v.isInvalid,"aria-describedby":v.description,"aria-label":v.labelId?void 0:`Upload files`,className:`sr-only`,onChange:e=>{if(e.target.files&&!A&&!j){P(Array.from(e.target.files));try{e.target.value=``}catch{}}}})]})})};O.displayName=`FileUpload`;var k=()=>{let e=(0,s.useContext)(E);if(!e)throw Error(`useFileUploadContext must be used within a FileUpload provider`);return e},A=({className:e,file:t,onClick:r,...a})=>{let{removeFile:l,triggerRef:u,dropzoneRef:f,deleteButtonRefs:p,inputRef:m,disabled:h,readOnly:g,files:_}=k(),v=(0,s.useRef)(null),y=_.findIndex(e=>e.name===t.name&&e.size===t.size);return(0,c.jsx)(i.t,{ref:e=>{if(v.current=e,e){for(;p.current.length<=y;)p.current.push(null);p.current[y]=e}else p.current[y]&&(p.current[y]=null)},"data-spark-component":`file-upload-item-delete-trigger`,className:(0,o.cx)(e),onClick:e=>{h||g||(l(y),requestAnimationFrame(()=>{let e=p.current.filter(Boolean);if(e.length>0){let t=e[Math.min(y,e.length-1)];t&&t.focus()}else{let e=w([u.current,f.current],m);e&&e.focus()}}),r?.(e))},disabled:h||g,size:`sm`,design:`contrast`,intent:`surface`,...a,children:(0,c.jsx)(n.t,{size:`sm`,children:(0,c.jsx)(d.Close,{})})})};A.displayName=`FileUpload.ItemDeleteTrigger`;var j=({className:e,file:t,uploadProgress:r,deleteButtonAriaLabel:i,progressAriaLabel:l,...u})=>{let{locale:d}=k(),[f,p]=(0,s.useState)(r!==void 0);(0,s.useEffect)(()=>{p(r!==void 0)},[r]);let m=(0,s.useCallback)(()=>{p(!1)},[]);return(0,c.jsxs)(`li`,{"data-spark-component":`file-upload-accepted-file`,className:(0,o.cx)(`relative`,`default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md`,`gap-md flex items-center justify-between default:w-full`,e),...u,children:[(0,c.jsx)(`div`,{className:`size-sz-36 bg-support-container flex items-center justify-center rounded-md`,children:(0,c.jsx)(n.t,{size:`md`,children:S(t)})}),(0,c.jsxs)(`div`,{className:`gap-md relative flex min-w-0 flex-1 flex-row items-center justify-between self-stretch`,children:[(0,c.jsx)(`p`,{className:`text-body-2 truncate font-medium`,children:t.name}),(0,c.jsx)(`p`,{className:`text-caption opacity-dim-1`,children:x(t.size,d)}),f&&r!==void 0&&(0,c.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full`,children:(0,c.jsx)(a.t,{value:r,max:100,"aria-label":l,onComplete:m})})]}),(0,c.jsx)(A,{"aria-label":i,file:t})]})};j.displayName=`FileUpload.AcceptedFile`;var M=({children:e})=>{let{files:t=[],rejectedFiles:n=[],locale:r}=k();return(0,c.jsx)(c.Fragment,{children:e({acceptedFiles:t,rejectedFiles:n,formatFileSize:x,locale:r})})};M.displayName=`FileUpload.Context`;var N=(0,s.createContext)(!1),P=()=>(0,s.useContext)(N);function F({children:e,className:t,unstyled:n=!1}){let r=k(),i=(0,s.useRef)(null);if(!r)throw Error(`FileUploadDropzone must be used inside <FileUpload>`);let a=e=>{if(e.preventDefault(),e.stopPropagation(),e.currentTarget.setAttribute(`data-drag-over`,`false`),r.disabled||r.readOnly)return;let t=e.dataTransfer.files,n=[];t&&(n=Array.isArray(t)?[...t]:Array.from(t)),n.length>0&&r.addFiles(n)},l=()=>{!r.disabled&&!r.readOnly&&r.inputRef.current?.click()},u=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),!r.disabled&&!r.readOnly&&r.inputRef.current?.click())},d=r.disabled||r.readOnly;return(0,c.jsx)(N,{value:!0,children:(0,c.jsx)(`div`,{ref:e=>{i.current=e,r.dropzoneRef&&(r.dropzoneRef.current=e)},role:`button`,tabIndex:d?-1:0,"aria-disabled":r.disabled?!0:void 0,"aria-describedby":r.description,"aria-invalid":r.isInvalid,"aria-required":r.isRequired,onClick:l,onKeyDown:u,onDrop:a,onDragOver:e=>{e.preventDefault()},className:n?t:(0,o.cx)(`default:bg-surface default:border-sm default:border-outline default:relative default:rounded-lg default:border-dashed`,`gap-lg flex flex-col items-center justify-center text-center`,`default:p-xl`,`transition-colors duration-200`,!d&&`default:hover:bg-surface-hovered`,`data-[drag-over=true]:border-outline-high data-[drag-over=true]:bg-surface-hovered data-[drag-over=true]:border-solid`,r.disabled&&`cursor-not-allowed opacity-50`,r.readOnly&&!r.disabled&&`cursor-default`,t),onDragEnter:e=>{d||e.currentTarget.setAttribute(`data-drag-over`,`true`)},onDragLeave:e=>{e.currentTarget.setAttribute(`data-drag-over`,`false`)},children:e})})}F.displayName=`FileUploadDropzone`;var I=({className:e,file:t,fallback:n=`📄`,...r})=>{let[i,a]=(0,s.useState)(!1),[l,u]=(0,s.useState)(!1),[d,f]=(0,s.useState)(null),p=t.type.startsWith(`image/`);return(0,s.useEffect)(()=>{if(!p){f(null);return}let e=URL.createObjectURL(t);return f(e),()=>{URL.revokeObjectURL(e)}},[t,p]),!p||i?(0,c.jsx)(`div`,{"data-spark-component":`file-upload-preview-image`,className:(0,o.cx)(`bg-neutral-container flex items-center justify-center rounded-md`,e),...r,children:n}):(0,c.jsxs)(`div`,{"data-spark-component":`file-upload-preview-image`,className:(0,o.cx)(`bg-neutral-container overflow-hidden`,e),...r,children:[(0,c.jsx)(`img`,{src:d,alt:t.name,className:(0,o.cx)(`size-full object-cover`,!l&&`opacity-0`),onLoad:()=>u(!0),onError:()=>a(!0)}),!l&&(0,c.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:n})]})};I.displayName=`FileUpload.PreviewImage`;var L=({className:e,rejectedFile:t,onClick:r,...a})=>{let{removeRejectedFile:l,triggerRef:u,dropzoneRef:f,rejectedFileDeleteButtonRefs:p,inputRef:m,disabled:h,readOnly:g,rejectedFiles:_}=k(),v=(0,s.useRef)(null),y=_.findIndex(e=>e.file.name===t.file.name&&e.file.size===t.file.size);return(0,c.jsx)(i.t,{ref:e=>{if(v.current=e,e){for(;p.current.length<=y;)p.current.push(null);p.current[y]=e}else p.current[y]&&(p.current[y]=null)},"data-spark-component":`file-upload-rejected-file-delete-trigger`,className:(0,o.cx)(e),onClick:e=>{h||g||(l(y),requestAnimationFrame(()=>{let e=p.current.filter(Boolean);if(e.length>0){let t=e[Math.min(y,e.length-1)];t&&t.focus()}else{let e=w([u.current,f.current],m);e&&e.focus()}}),r?.(e))},disabled:h||g,size:`sm`,design:`contrast`,intent:`surface`,...a,children:(0,c.jsx)(n.t,{size:`sm`,children:(0,c.jsx)(d.Close,{})})})};L.displayName=`FileUpload.RejectedFileDeleteTrigger`;var R=({className:e,rejectedFile:t,renderError:r,deleteButtonAriaLabel:i,...a})=>{let{locale:s}=k();return(0,c.jsxs)(`li`,{"data-spark-component":`file-upload-rejected-file`,className:(0,o.cx)(`relative`,`default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md`,`gap-md flex items-center justify-between default:w-full`,`border-error border-md`,e),...a,children:[(0,c.jsx)(`div`,{className:`size-sz-36 bg-error-container flex items-center justify-center rounded-md`,children:(0,c.jsx)(n.t,{size:`md`,className:`text-error`,children:(0,c.jsx)(g.WarningOutline,{})})}),(0,c.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,c.jsxs)(`div`,{className:`gap-md flex flex-col`,children:[(0,c.jsxs)(`div`,{className:`gap-md flex flex-row items-center justify-between`,children:[(0,c.jsx)(`p`,{className:`text-body-2 truncate font-medium`,children:t.file.name}),(0,c.jsx)(`p`,{className:`text-caption opacity-dim-1`,children:x(t.file.size,s)})]}),(0,c.jsx)(`div`,{className:`gap-xs flex flex-col`,children:t.errors.map((e,t)=>(0,c.jsx)(`div`,{className:`text-caption text-error`,"data-error-code":e,children:r(e)},t))})]})}),(0,c.jsx)(L,{"aria-label":i,rejectedFile:t})]})};R.displayName=`FileUpload.RejectedFile`;var z=({className:e,children:n,asChild:i=!1,unstyled:a=!1,design:s=`filled`,intent:l=`support`,size:u=`md`,shape:d=`rounded`,ref:f,...p})=>{let{inputRef:m,triggerRef:h,disabled:g,readOnly:_,description:v,isInvalid:y,isRequired:b}=k(),x=P(),S=e=>{e.stopPropagation(),e.preventDefault(),!g&&!_&&m.current?.click()},C=e=>{h&&(h.current=e),f&&(typeof f==`function`?f(e):f.current=e)},w,T;return x?(w=`span`,T={ref:C,"data-spark-component":`file-upload-trigger`,className:a?e:r.n({design:s,intent:l,size:u,shape:d,disabled:g||_,className:e})}):(w=i?t.Slot:a?`button`:r.t,T={ref:C,type:`button`,design:s,intent:l,size:u,shape:d,"data-spark-component":`file-upload-trigger`,className:(0,o.cx)(e),disabled:g||_,onClick:S,"aria-describedby":v,"aria-invalid":y,"aria-required":b,...p}),(0,c.jsx)(w,{...T,children:n})};z.displayName=`FileUpload.Trigger`;var B=Object.assign(O,{Trigger:z,Dropzone:F,Context:M,AcceptedFile:j,RejectedFile:R,PreviewImage:I,ItemDeleteTrigger:A,RejectedFileDeleteTrigger:L});B.displayName=`FileUpload`,z.displayName=`FileUpload.Trigger`,F.displayName=`FileUpload.Dropzone`,M.displayName=`FileUpload.Context`,A.displayName=`FileUpload.ItemDeleteTrigger`,I.displayName=`FileUpload.PreviewImage`,j.displayName=`FileUpload.AcceptedFile`,R.displayName=`FileUpload.RejectedFile`,L.displayName=`FileUpload.RejectedFileDeleteTrigger`,exports.FILE_UPLOAD_ERRORS=_,exports.FileUpload=B;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Slot as e } from "../slot/index.mjs";
|
|
2
|
-
import { t } from "../icon-
|
|
3
|
-
import { n, t as r } from "../button-
|
|
4
|
-
import { t as i } from "../icon-button-
|
|
2
|
+
import { t } from "../icon-VM_Ys9Xn.mjs";
|
|
3
|
+
import { n, t as r } from "../button-DBNjh3Bi.mjs";
|
|
4
|
+
import { t as i } from "../icon-button-CexCkoV0.mjs";
|
|
5
5
|
import { t as a } from "../progress-xbOXCGXi.mjs";
|
|
6
6
|
import { cx as o } from "class-variance-authority";
|
|
7
7
|
import { createContext as s, createElement as c, useCallback as l, useContext as u, useEffect as d, useId as f, useRef as p, useState as m } from "react";
|
package/dist/form-field/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../form-field-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../form-field-DMHwopHt.js");exports.FormField=e.t,exports.useFormFieldControl=e.n;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "../form-field-
|
|
1
|
+
import { n as e, t } from "../form-field-Doq4zLEX.mjs";
|
|
2
2
|
export { t as FormField, e as useFormFieldControl };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./slot/index.js"),t=require("./icon-
|
|
2
|
-
//# sourceMappingURL=form-field-
|
|
1
|
+
const e=require("./slot/index.js"),t=require("./icon-CfEsla9z.js"),n=require("./label-B085X0Sg.js"),r=require("./FormFieldRequiredIndicator-BxZgeZ9H.js");let i=require("class-variance-authority"),a=require("react"),o=require("react/jsx-runtime"),s=require("@spark-ui/icons/Check"),c=require("@spark-ui/icons/WarningOutline"),l=require("@spark-ui/icons/AlertOutline");var u=(0,a.createContext)(null),d=`:form-field`,f=()=>{let e=(0,a.useContext)(u);if(!e)throw Error(`useFormField must be used within a FormField provider`);return e},p=({id:e,name:t,disabled:n=!1,readOnly:r=!1,state:i,isRequired:s,children:c})=>{let l=`${d}-label-${(0,a.useId)()}`,[f,p]=(0,a.useState)([]),m=f.length>0?f.join(` `):void 0,h=(0,a.useCallback)(e=>{p(t=>[...t,e])},[]),g=(0,a.useCallback)(e=>{p(t=>t.filter(t=>t!==e))},[]);return(0,o.jsx)(u,{value:(0,a.useMemo)(()=>({id:e,labelId:l,name:t,disabled:n,readOnly:r,state:i,isRequired:s,isInvalid:i===`error`,description:m,onMessageIdAdd:h,onMessageIdRemove:g}),[e,l,t,n,r,m,i,s,h,g]),children:c})};p.displayName=`FormFieldProvider`;var m=({className:t,disabled:n=!1,readOnly:r=!1,name:s,state:c,isRequired:l=!1,asChild:u=!1,ref:f,...m})=>(0,o.jsx)(p,{id:`${d}-${(0,a.useId)()}`,name:s,isRequired:l,disabled:n,readOnly:r,state:c,children:(0,o.jsx)(u?e.Slot:`div`,{ref:f,"data-spark-component":`form-field`,className:(0,i.cx)(t,`gap-md flex flex-col`),...m})});m.displayName=`FormField`;var h=({id:e,className:t,ref:n,...r})=>{let{onMessageIdAdd:s,onMessageIdRemove:c}=f(),l=`${d}-message-${(0,a.useId)()}`,u=e||l;return(0,a.useEffect)(()=>(s(u),()=>{c(u)}),[u,s,c]),(0,o.jsx)(`span`,{ref:n,id:u,"data-spark-component":`form-field-message`,className:(0,i.cx)(t,`default:text-caption`),...r})};h.displayName=`FormField.Message`;var g=({className:e,state:n,children:r,ref:a,...u})=>f().state===n?(0,o.jsxs)(h,{ref:a,"data-spark-component":`form-field-state-message`,className:(0,i.cx)(`gap-sm flex items-center`,n===`error`?`text-error`:`text-on-surface/dim-1`,e),...u,children:[n===`alert`&&(0,o.jsx)(t.t,{size:`sm`,children:(0,o.jsx)(c.WarningOutline,{})}),n===`error`&&(0,o.jsx)(t.t,{size:`sm`,intent:`error`,children:(0,o.jsx)(l.AlertOutline,{})}),n===`success`&&(0,o.jsx)(t.t,{size:`sm`,children:(0,o.jsx)(s.Check,{})}),r]}):null;g.displayName=`FormField.StateMessage`;var _=({ref:e,...t})=>(0,o.jsx)(g,{ref:e,"data-spark-component":`form-field-alert-message`,state:`alert`,...t});_.displayName=`FormField.AlertMessage`;var v=({className:e,value:t=``,maxLength:n,description:r,liveAnnouncement:s,ref:c,...l})=>{let[u,d]=(0,a.useState)(t);return(0,a.useEffect)(()=>{let e=setTimeout(()=>{d(t)},1e3);return()=>clearTimeout(e)},[t]),(0,o.jsxs)(`span`,{className:`ml-auto self-start`,children:[r&&(0,o.jsx)(h,{className:`default:sr-only`,children:r}),(0,o.jsx)(`span`,{ref:c,"aria-hidden":!0,"data-spark-component":`form-field-characters-count`,className:(0,i.cx)(e,`text-caption`,`text-neutral`),...l,children:`${t.length}/${n}`}),s&&(0,o.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:s({remainingChars:n-u.length})})]})};v.displayName=`FormField.CharactersCount`;var y=()=>{let{id:e,name:t,description:n,disabled:r,readOnly:i,state:o,labelId:s,isInvalid:c,isRequired:l}=(0,a.useContext)(u)||{};return{id:e,name:t,description:n,disabled:r,readOnly:i,state:o,labelId:s,isInvalid:c,isRequired:l}},b=({children:e})=>(0,o.jsx)(o.Fragment,{children:e(y())});b.displayName=`FormField.Control`;var x=({className:e,ref:t,...n})=>(0,o.jsx)(h,{ref:t,"data-spark-component":`form-field-description`,className:(0,i.cx)(`text-on-surface/dim-1 text-body-2`,e),...n});x.displayName=`FormField.Description`;var S=({ref:e,...t})=>(0,o.jsx)(g,{ref:e,"data-spark-component":`form-field-error-message`,state:`error`,...t});S.displayName=`FormField.ErrorMessage`;var C=({className:e,ref:t,...n})=>(0,o.jsx)(h,{ref:t,"data-spark-component":`form-field-helper-message`,className:(0,i.cx)(`text-on-surface/dim-1`,e),...n});C.displayName=`FormField.HelperMessage`;var w=({htmlFor:t,className:a,children:s,requiredIndicator:c=(0,o.jsx)(r.t,{}),asChild:l,ref:u,...d})=>{let p=f(),{disabled:m,labelId:h,isRequired:g}=p;return(0,o.jsx)(n.t,{ref:u,id:h,"data-spark-component":`form-field-label`,htmlFor:l?void 0:t||p.id,className:(0,i.cx)(`default:font-medium`,a,m?`text-on-surface/dim-3 pointer-events-none`:void 0),asChild:l,...d,children:(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(e.Slottable,{children:s}),g&&c]})})};w.displayName=`FormField.Label`;var T=({ref:e,...t})=>(0,o.jsx)(g,{ref:e,"data-spark-component":`form-field-success-message`,state:`success`,...t});T.displayName=`FormField.SuccessMessage`;var E=Object.assign(m,{Label:w,Description:x,Control:b,StateMessage:g,SuccessMessage:T,AlertMessage:_,ErrorMessage:S,HelperMessage:C,RequiredIndicator:r.t,CharactersCount:v});E.displayName=`FormField`,w.displayName=`FormField.Label`,x.displayName=`FormField.Description`,b.displayName=`FormField.Control`,g.displayName=`FormField.StateMessage`,T.displayName=`FormField.SuccessMessage`,_.displayName=`FormField.AlertMessage`,S.displayName=`FormField.ErrorMessage`,C.displayName=`FormField.HelperMessage`,r.t.displayName=`FormField.RequiredIndicator`,v.displayName=`FormField.CharactersCount`,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return E}});
|
|
2
|
+
//# sourceMappingURL=form-field-DMHwopHt.js.map
|