@spear-ai/spectral 1.17.3 → 1.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Drawer.js +1 -1
- package/dist/Drawer.js.map +1 -1
- package/package.json +1 -1
package/dist/Drawer.js
CHANGED
|
@@ -60,7 +60,7 @@ const Drawer = ({ children, className, defaultOpen = false, description, directi
|
|
|
60
60
|
}), /* @__PURE__ */ jsx(Drawer$1.Content, {
|
|
61
61
|
asChild: true,
|
|
62
62
|
"aria-label": !hasTitle && !hasDescription ? "Drawer" : void 0,
|
|
63
|
-
className: cn("z-
|
|
63
|
+
className: cn("z-50 flex flex-col overscroll-contain bg-drawer-bg focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent **:box-border", directionClassName, className),
|
|
64
64
|
style,
|
|
65
65
|
"data-testid": "spectral-drawer-content",
|
|
66
66
|
children: /* @__PURE__ */ jsxs("div", {
|
package/dist/Drawer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","names":["DrawerBase"],"sources":["../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import { SpectralProvider } from '@components/SpectralProvider/SpectralProvider'\nimport { cn } from '@utils/twUtils'\nimport { Fragment, isValidElement, type ReactNode } from 'react'\nimport { Drawer as DrawerBase } from 'vaul'\n\nexport interface DrawerProps {\n className?: string\n children?: ReactNode\n defaultOpen?: boolean\n description?: ReactNode\n direction?: 'left' | 'right' | 'top' | 'bottom'\n dismissible?: boolean\n dragBehavior?: 'surface' | 'handle' | 'none'\n modal?: boolean\n onOpenChange?: (open: boolean) => void\n open?: boolean\n size?: string\n title?: ReactNode\n trigger: ReactNode\n}\n\nconst hasRenderableText = (value: ReactNode) => (typeof value === 'string' ? value.trim().length > 0 : typeof value === 'number')\n\nconst hasRenderableContent = (value: ReactNode) => {\n if (hasRenderableText(value)) {\n return true\n }\n\n if (value === null || value === undefined || typeof value === 'boolean' || typeof value === 'string') {\n return false\n }\n\n return true\n}\n\nconst isElementAndNotFragment = (element: ReactNode) => isValidElement(element) && element.type !== Fragment\n\nexport const Drawer = ({\n children,\n className,\n defaultOpen = false,\n description, direction = 'right',\n dismissible = true,\n dragBehavior = 'surface',\n modal = true,\n onOpenChange,\n open,\n size = '380px',\n title,\n trigger,\n}: DrawerProps) => {\n const baseStyles = 'font-sans! fixed'\n const hasTitle = hasRenderableContent(title)\n const hasDescription = hasRenderableContent(description)\n const isTextTitle = hasRenderableText(title)\n const isTextDescription = hasRenderableText(description)\n const isCustomTitleElement = isElementAndNotFragment(title)\n const isCustomDescriptionElement = isElementAndNotFragment(description)\n const handleOnly = dragBehavior === 'handle' || dragBehavior === 'none'\n const shouldRenderHandle = dragBehavior === 'handle'\n\n const directionStyles = {\n left: {\n className: cn(baseStyles, 'top-0 bottom-0 left-0 shadow-[20px_0_20px_var(--color-black-40)]'),\n style: { width: size },\n },\n right: {\n className: cn(baseStyles, 'top-0 bottom-0 right-0 shadow-[-20px_0_20px_var(--color-black-40)]'),\n style: { width: size },\n },\n top: {\n className: cn(baseStyles, 'top-0 left-0 right-0 shadow-[0_20px_20px_var(--color-black-40)]'),\n style: { height: size },\n },\n bottom: {\n className: cn(baseStyles, 'bottom-0 left-0 right-0 shadow-[0_-20px_20px_var(--color-black-40)]'),\n style: { height: size },\n },\n }\n\n const { className: directionClassName, style } = directionStyles[direction]\n\n return (\n <SpectralProvider>\n <DrawerBase.Root data-testid='spectral-drawer' defaultOpen={defaultOpen} direction={direction} dismissible={dismissible} handleOnly={handleOnly} modal={modal} onOpenChange={onOpenChange} open={open}>\n <DrawerBase.Trigger asChild data-testid='spectral-drawer-trigger'>\n {trigger}\n </DrawerBase.Trigger>\n <DrawerBase.Portal>\n <DrawerBase.Overlay className='inset-0 fixed bg-transparent' data-testid='spectral-drawer-overlay' />\n <DrawerBase.Content\n asChild\n aria-label={!hasTitle && !hasDescription ? 'Drawer' : undefined}\n className={cn(\n 'z-
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["DrawerBase"],"sources":["../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import { SpectralProvider } from '@components/SpectralProvider/SpectralProvider'\nimport { cn } from '@utils/twUtils'\nimport { Fragment, isValidElement, type ReactNode } from 'react'\nimport { Drawer as DrawerBase } from 'vaul'\n\nexport interface DrawerProps {\n className?: string\n children?: ReactNode\n defaultOpen?: boolean\n description?: ReactNode\n direction?: 'left' | 'right' | 'top' | 'bottom'\n dismissible?: boolean\n dragBehavior?: 'surface' | 'handle' | 'none'\n modal?: boolean\n onOpenChange?: (open: boolean) => void\n open?: boolean\n size?: string\n title?: ReactNode\n trigger: ReactNode\n}\n\nconst hasRenderableText = (value: ReactNode) => (typeof value === 'string' ? value.trim().length > 0 : typeof value === 'number')\n\nconst hasRenderableContent = (value: ReactNode) => {\n if (hasRenderableText(value)) {\n return true\n }\n\n if (value === null || value === undefined || typeof value === 'boolean' || typeof value === 'string') {\n return false\n }\n\n return true\n}\n\nconst isElementAndNotFragment = (element: ReactNode) => isValidElement(element) && element.type !== Fragment\n\nexport const Drawer = ({\n children,\n className,\n defaultOpen = false,\n description, direction = 'right',\n dismissible = true,\n dragBehavior = 'surface',\n modal = true,\n onOpenChange,\n open,\n size = '380px',\n title,\n trigger,\n}: DrawerProps) => {\n const baseStyles = 'font-sans! fixed'\n const hasTitle = hasRenderableContent(title)\n const hasDescription = hasRenderableContent(description)\n const isTextTitle = hasRenderableText(title)\n const isTextDescription = hasRenderableText(description)\n const isCustomTitleElement = isElementAndNotFragment(title)\n const isCustomDescriptionElement = isElementAndNotFragment(description)\n const handleOnly = dragBehavior === 'handle' || dragBehavior === 'none'\n const shouldRenderHandle = dragBehavior === 'handle'\n\n const directionStyles = {\n left: {\n className: cn(baseStyles, 'top-0 bottom-0 left-0 shadow-[20px_0_20px_var(--color-black-40)]'),\n style: { width: size },\n },\n right: {\n className: cn(baseStyles, 'top-0 bottom-0 right-0 shadow-[-20px_0_20px_var(--color-black-40)]'),\n style: { width: size },\n },\n top: {\n className: cn(baseStyles, 'top-0 left-0 right-0 shadow-[0_20px_20px_var(--color-black-40)]'),\n style: { height: size },\n },\n bottom: {\n className: cn(baseStyles, 'bottom-0 left-0 right-0 shadow-[0_-20px_20px_var(--color-black-40)]'),\n style: { height: size },\n },\n }\n\n const { className: directionClassName, style } = directionStyles[direction]\n\n return (\n <SpectralProvider>\n <DrawerBase.Root data-testid='spectral-drawer' defaultOpen={defaultOpen} direction={direction} dismissible={dismissible} handleOnly={handleOnly} modal={modal} onOpenChange={onOpenChange} open={open}>\n <DrawerBase.Trigger asChild data-testid='spectral-drawer-trigger'>\n {trigger}\n </DrawerBase.Trigger>\n <DrawerBase.Portal>\n <DrawerBase.Overlay className='inset-0 fixed bg-transparent' data-testid='spectral-drawer-overlay' />\n <DrawerBase.Content\n asChild\n aria-label={!hasTitle && !hasDescription ? 'Drawer' : undefined}\n className={cn(\n 'z-50 flex flex-col overscroll-contain bg-drawer-bg focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent **:box-border',\n directionClassName,\n className,\n )}\n style={style}\n data-testid='spectral-drawer-content'\n >\n <div className='flex h-full min-h-0 flex-col'>\n <DrawerBase.Close />\n {shouldRenderHandle && <DrawerBase.Handle data-testid='spectral-drawer-handle' />}\n {hasTitle && (\n <>\n {isTextTitle && (\n <DrawerBase.Title className='px-3 pt-4 text-xl font-semibold text-text-primary' data-testid='spectral-drawer-title'>\n {title}\n </DrawerBase.Title>\n )}\n {!isTextTitle && isCustomTitleElement && (\n <DrawerBase.Title asChild data-testid='spectral-drawer-title'>\n {title}\n </DrawerBase.Title>\n )}\n {!isTextTitle && !isCustomTitleElement && (\n <DrawerBase.Title data-testid='spectral-drawer-title'>\n {title}\n </DrawerBase.Title>\n )}\n </>\n )}\n {hasDescription && (\n <>\n {isTextDescription && (\n <DrawerBase.Description className='mb-2 px-3 text-xs! text-text-secondary! uppercase' data-testid='spectral-drawer-description'>\n {description}\n </DrawerBase.Description>\n )}\n {!isTextDescription && isCustomDescriptionElement && (\n <DrawerBase.Description asChild data-testid='spectral-drawer-description'>\n {description}\n </DrawerBase.Description>\n )}\n {!isTextDescription && !isCustomDescriptionElement && (\n <DrawerBase.Description data-testid='spectral-drawer-description'>\n {description}\n </DrawerBase.Description>\n )}\n </>\n )}\n <div className='py-2 px-3 min-w-0 [&>*]:min-w-0 [&_*]:min-w-0 flex-1 min-h-0 overflow-y-auto overflow-x-hidden overscroll-contain *:box-border' data-testid='spectral-drawer-body'>\n {children}\n </div>\n </div>\n </DrawerBase.Content>\n </DrawerBase.Portal>\n </DrawerBase.Root>\n </SpectralProvider>\n )\n}\n"],"mappings":";;;;;;;;AAqBA,MAAM,qBAAqB,UAAsB,OAAO,UAAU,WAAW,MAAM,MAAM,CAAC,SAAS,IAAI,OAAO,UAAU;AAExH,MAAM,wBAAwB,UAAqB;AACjD,KAAI,kBAAkB,MAAM,CAC1B,QAAO;AAGT,KAAI,UAAU,QAAQ,UAAU,UAAa,OAAO,UAAU,aAAa,OAAO,UAAU,SAC1F,QAAO;AAGT,QAAO;;AAGT,MAAM,2BAA2B,YAAuB,eAAe,QAAQ,IAAI,QAAQ,SAAS;AAEpG,MAAa,UAAU,EACrB,UACA,WACA,cAAc,OACd,aAAa,YAAY,SACzB,cAAc,MACd,eAAe,WACf,QAAQ,MACR,cACA,MACA,OAAO,SACP,OACA,cACiB;CACjB,MAAM,aAAa;CACnB,MAAM,WAAW,qBAAqB,MAAM;CAC5C,MAAM,iBAAiB,qBAAqB,YAAY;CACxD,MAAM,cAAc,kBAAkB,MAAM;CAC5C,MAAM,oBAAoB,kBAAkB,YAAY;CACxD,MAAM,uBAAuB,wBAAwB,MAAM;CAC3D,MAAM,6BAA6B,wBAAwB,YAAY;CACvE,MAAM,aAAa,iBAAiB,YAAY,iBAAiB;CACjE,MAAM,qBAAqB,iBAAiB;CAqB5C,MAAM,EAAE,WAAW,oBAAoB,UAAU;EAlB/C,MA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