@gerege-systems/ui 0.13.1 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/component-styles.css +14 -0
- package/dist-lib/components/ui/Accordion.js +1 -1
- package/dist-lib/components/ui/Accordion.js.map +1 -1
- package/dist-lib/components/ui/Alert.js +1 -1
- package/dist-lib/components/ui/Alert.js.map +1 -1
- package/dist-lib/components/ui/Breadcrumbs.js +6 -6
- package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
- package/dist-lib/components/ui/Button.js +20 -18
- package/dist-lib/components/ui/Button.js.map +1 -1
- package/dist-lib/components/ui/Calendar.js +3 -3
- package/dist-lib/components/ui/Calendar.js.map +1 -1
- package/dist-lib/components/ui/Card.js +7 -7
- package/dist-lib/components/ui/Card.js.map +1 -1
- package/dist-lib/components/ui/Carousel.js +1 -1
- package/dist-lib/components/ui/Carousel.js.map +1 -1
- package/dist-lib/components/ui/Chart.js +1 -1
- package/dist-lib/components/ui/Chart.js.map +1 -1
- package/dist-lib/components/ui/Checkbox.js +1 -1
- package/dist-lib/components/ui/Checkbox.js.map +1 -1
- package/dist-lib/components/ui/Combobox.js +12 -12
- package/dist-lib/components/ui/Combobox.js.map +1 -1
- package/dist-lib/components/ui/CommandPalette.js +8 -8
- package/dist-lib/components/ui/CommandPalette.js.map +1 -1
- package/dist-lib/components/ui/ContextMenu.js +1 -1
- package/dist-lib/components/ui/ContextMenu.js.map +1 -1
- package/dist-lib/components/ui/DatePicker.js +2 -2
- package/dist-lib/components/ui/DatePicker.js.map +1 -1
- package/dist-lib/components/ui/Dialog.js +1 -1
- package/dist-lib/components/ui/Dialog.js.map +1 -1
- package/dist-lib/components/ui/Drawer.js +18 -18
- package/dist-lib/components/ui/Drawer.js.map +1 -1
- package/dist-lib/components/ui/DropdownMenu.js +1 -1
- package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
- package/dist-lib/components/ui/FileUpload.js +1 -1
- package/dist-lib/components/ui/FileUpload.js.map +1 -1
- package/dist-lib/components/ui/IconButton.js +13 -13
- package/dist-lib/components/ui/IconButton.js.map +1 -1
- package/dist-lib/components/ui/Input.js +7 -7
- package/dist-lib/components/ui/Input.js.map +1 -1
- package/dist-lib/components/ui/MultiSelect.js +24 -24
- package/dist-lib/components/ui/MultiSelect.js.map +1 -1
- package/dist-lib/components/ui/Pagination.js +21 -21
- package/dist-lib/components/ui/Pagination.js.map +1 -1
- package/dist-lib/components/ui/Popover.js +4 -4
- package/dist-lib/components/ui/Popover.js.map +1 -1
- package/dist-lib/components/ui/RadioGroup.js +9 -9
- package/dist-lib/components/ui/RadioGroup.js.map +1 -1
- package/dist-lib/components/ui/ScrollArea.js +11 -11
- package/dist-lib/components/ui/ScrollArea.js.map +1 -1
- package/dist-lib/components/ui/Select.js +29 -29
- package/dist-lib/components/ui/Select.js.map +1 -1
- package/dist-lib/components/ui/Sheet.js +1 -1
- package/dist-lib/components/ui/Sheet.js.map +1 -1
- package/dist-lib/components/ui/Sidebar.js +64 -60
- package/dist-lib/components/ui/Sidebar.js.map +1 -1
- package/dist-lib/components/ui/Slider.js +1 -1
- package/dist-lib/components/ui/Slider.js.map +1 -1
- package/dist-lib/components/ui/Snackbar.js +28 -19
- package/dist-lib/components/ui/Snackbar.js.map +1 -1
- package/dist-lib/components/ui/Switch.js +7 -7
- package/dist-lib/components/ui/Switch.js.map +1 -1
- package/dist-lib/components/ui/Table.js +6 -6
- package/dist-lib/components/ui/Table.js.map +1 -1
- package/dist-lib/components/ui/Tabs.js +6 -6
- package/dist-lib/components/ui/Tabs.js.map +1 -1
- package/dist-lib/components/ui/TagInput.js +3 -3
- package/dist-lib/components/ui/TagInput.js.map +1 -1
- package/dist-lib/components/ui/Textarea.js +1 -1
- package/dist-lib/components/ui/Textarea.js.map +1 -1
- package/dist-lib/components/ui/Toast.js +8 -8
- package/dist-lib/components/ui/Toast.js.map +1 -1
- package/dist-lib/components/ui/TopNav.js +9 -9
- package/dist-lib/components/ui/TopNav.js.map +1 -1
- package/dist-lib/components/ui/Tree.js +2 -2
- package/dist-lib/components/ui/Tree.js.map +1 -1
- package/dist-lib/styles.css +1 -1
- package/dist-lib/theme.css +70 -28
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.js","sources":["../../../src/components/ui/ContextMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Right-click (or two-finger tap) menu. Visual surface mirrors DropdownMenu\n * for consistency.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild>\n * <div className=\"grid h-32 place-items-center rounded-lg border border-border\">\n * Right-click me\n * </div>\n * </ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem>Open</ContextMenuItem>\n * <ContextMenuSeparator />\n * <ContextMenuItem destructive>Delete</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n *\n * @do Mirror DropdownMenu items for the same surface — users expect the same\n * operations from both.\n * @dont Hide critical actions behind right-click — they must also exist in\n * a visible button or menu.\n */\nexport const ContextMenu = ContextMenuPrimitive.Root;\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\nexport const ContextMenuGroup = ContextMenuPrimitive.Group;\nexport const ContextMenuPortal = ContextMenuPrimitive.Portal;\nexport const ContextMenuSub = ContextMenuPrimitive.Sub;\nexport const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const ContextMenuSubTrigger = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }\n>(function ContextMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubTrigger\n data-slot=\"context-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </ContextMenuPrimitive.SubTrigger>\n );\n});\nContextMenuSubTrigger.displayName = 'ContextMenuSubTrigger';\n\nexport const ContextMenuSubContent = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(function ContextMenuSubContent({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuSubContent.displayName = 'ContextMenuSubContent';\n\nexport const ContextMenuContent = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(function ContextMenuContent({ className, ...props }, ref) {\n return (\n <ContextMenuPortal>\n <ContextMenuPrimitive.Content\n data-slot=\"context-menu-content\"\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n </ContextMenuPortal>\n );\n});\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport const ContextMenuItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function ContextMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuItem.displayName = 'ContextMenuItem';\n\nexport const ContextMenuCheckboxItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(function ContextMenuCheckboxItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n});\nContextMenuCheckboxItem.displayName = 'ContextMenuCheckboxItem';\n\nexport const ContextMenuRadioItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(function ContextMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n});\nContextMenuRadioItem.displayName = 'ContextMenuRadioItem';\n\nexport const ContextMenuLabel = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & { inset?: boolean }\n>(function ContextMenuLabel({ className, inset, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuLabel.displayName = 'ContextMenuLabel';\n\nexport const ContextMenuSeparator = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nContextMenuSeparator.displayName = 'ContextMenuSeparator';\n\nexport function ContextMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nContextMenuShortcut.displayName = 'ContextMenuShortcut';\n"],"names":["ContextMenu","ContextMenuPrimitive","ContextMenuTrigger","ContextMenuGroup","ContextMenuPortal","ContextMenuSub","ContextMenuRadioGroup","itemClasses","cn","ContextMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","ContextMenuSubContent","ContextMenuContent","ContextMenuItem","destructive","ContextMenuCheckboxItem","Check","ContextMenu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S;AAAA,MAC3C,GAAGG;AAAA,MAEJ,UAAA;AAAA,QAAA,gBAAAG,EAAC,QAAA,EAAK,WAAU,2DACd,UAAA,gBAAAA,EAAChB,EAAqB,eAArB,EACC,UAAA,gBAAAgB,EAACS,GAAA,EAAO,WAAU,kCAAiC,eAAW,GAAA,CAAC,GACjE,GACF;AAAA,QACCb;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;AACDY,EAAqB,cAAc;AAE5B,MAAME,IAAmBjB,EAG9B,SAA0B,EAAE,WAAAC,GAAW,OAAAC,GAAO,GAAGE,EAAA,GAASC,GAAK;AAC/D,SACE,gBAAAE;AAAA,IAAChB,EAAqB;AAAA,IAArB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP;AAAA,QACT;AAAA,QACAI,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDa,EAAiB,cAAc;AAExB,MAAMC,IAAuBlB,EAGlC,SAA8B,EAAE,WAAAC,GAAW,GAAGG,EAAA,GAASC,GAAK;AAC5D,SACE,gBAAAE;AAAA,IAAChB,EAAqB;AAAA,IAArB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP,EAAG,6BAA6BG,CAAS;AAAA,MACnD,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDc,EAAqB,cAAc;AAE5B,SAASC,EAAoB,EAAE,WAAAlB,GAAW,GAAGG,KAA0C;AAC5F,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAG,oEAAoEG,CAAS;AAAA,MAC1F,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAe,EAAoB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"ContextMenu.js","sources":["../../../src/components/ui/ContextMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as ContextMenuPrimitive from '@radix-ui/react-context-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/**\n * Right-click (or two-finger tap) menu. Visual surface mirrors DropdownMenu\n * for consistency.\n *\n * @example\n * <ContextMenu>\n * <ContextMenuTrigger asChild>\n * <div className=\"grid h-32 place-items-center rounded-lg border border-border\">\n * Right-click me\n * </div>\n * </ContextMenuTrigger>\n * <ContextMenuContent>\n * <ContextMenuItem>Open</ContextMenuItem>\n * <ContextMenuSeparator />\n * <ContextMenuItem destructive>Delete</ContextMenuItem>\n * </ContextMenuContent>\n * </ContextMenu>\n *\n * @do Mirror DropdownMenu items for the same surface — users expect the same\n * operations from both.\n * @dont Hide critical actions behind right-click — they must also exist in\n * a visible button or menu.\n */\nexport const ContextMenu = ContextMenuPrimitive.Root;\nexport const ContextMenuTrigger = ContextMenuPrimitive.Trigger;\nexport const ContextMenuGroup = ContextMenuPrimitive.Group;\nexport const ContextMenuPortal = ContextMenuPrimitive.Portal;\nexport const ContextMenuSub = ContextMenuPrimitive.Sub;\nexport const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-hidden',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const ContextMenuSubTrigger = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> & { inset?: boolean }\n>(function ContextMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubTrigger\n data-slot=\"context-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </ContextMenuPrimitive.SubTrigger>\n );\n});\nContextMenuSubTrigger.displayName = 'ContextMenuSubTrigger';\n\nexport const ContextMenuSubContent = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubContent>\n>(function ContextMenuSubContent({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuSubContent.displayName = 'ContextMenuSubContent';\n\nexport const ContextMenuContent = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>\n>(function ContextMenuContent({ className, ...props }, ref) {\n return (\n <ContextMenuPortal>\n <ContextMenuPrimitive.Content\n data-slot=\"context-menu-content\"\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n </ContextMenuPortal>\n );\n});\nContextMenuContent.displayName = 'ContextMenuContent';\n\nexport const ContextMenuItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function ContextMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuItem.displayName = 'ContextMenuItem';\n\nexport const ContextMenuCheckboxItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem>\n>(function ContextMenuCheckboxItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.CheckboxItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.CheckboxItem>\n );\n});\nContextMenuCheckboxItem.displayName = 'ContextMenuCheckboxItem';\n\nexport const ContextMenuRadioItem = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem>\n>(function ContextMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <ContextMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <ContextMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </ContextMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </ContextMenuPrimitive.RadioItem>\n );\n});\nContextMenuRadioItem.displayName = 'ContextMenuRadioItem';\n\nexport const ContextMenuLabel = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Label> & { inset?: boolean }\n>(function ContextMenuLabel({ className, inset, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nContextMenuLabel.displayName = 'ContextMenuLabel';\n\nexport const ContextMenuSeparator = forwardRef<\n ComponentRef<typeof ContextMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Separator>\n>(function ContextMenuSeparator({ className, ...props }, ref) {\n return (\n <ContextMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nContextMenuSeparator.displayName = 'ContextMenuSeparator';\n\nexport function ContextMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nContextMenuShortcut.displayName = 'ContextMenuShortcut';\n"],"names":["ContextMenu","ContextMenuPrimitive","ContextMenuTrigger","ContextMenuGroup","ContextMenuPortal","ContextMenuSub","ContextMenuRadioGroup","itemClasses","cn","ContextMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","ContextMenuSubContent","ContextMenuContent","ContextMenuItem","destructive","ContextMenuCheckboxItem","Check","ContextMenuRadioItem","Circle","ContextMenuLabel","ContextMenuSeparator","ContextMenuShortcut"],"mappings":";;;;;;AAmCO,MAAMA,IAAcC,EAAqB,MACnCC,IAAqBD,EAAqB,SAC1CE,IAAmBF,EAAqB,OACxCG,IAAoBH,EAAqB,QACzCI,IAAiBJ,EAAqB,KACtCK,IAAwBL,EAAqB,YAEpDM,IAAcC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF,GAEaC,IAAwBC,EAGn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AA0B,EAAE,WAAAC,GAAW,OAAAC,GAAO,GAAGE,EAAA,GAASC,GAAK;AAC/D,SACE,gBAAAE;AAAA,IAAChB,EAAqB;AAAA,IAArB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP;AAAA,QACT;AAAA,QACAI,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDa,EAAiB,cAAc;AAExB,MAAMC,IAAuBlB,EAGlC,SAA8B,EAAE,WAAAC,GAAW,GAAGG,EAAA,GAASC,GAAK;AAC5D,SACE,gBAAAE;AAAA,IAAChB,EAAqB;AAAA,IAArB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP,EAAG,6BAA6BG,CAAS;AAAA,MACnD,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDc,EAAqB,cAAc;AAE5B,SAASC,EAAoB,EAAE,WAAAlB,GAAW,GAAGG,KAA0C;AAC5F,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAG,oEAAoEG,CAAS;AAAA,MAC1F,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAe,EAAoB,cAAc;"}
|
|
@@ -42,6 +42,7 @@ function B({
|
|
|
42
42
|
/* @__PURE__ */ n(f.Trigger, { asChild: !0, children: /* @__PURE__ */ $(
|
|
43
43
|
"button",
|
|
44
44
|
{
|
|
45
|
+
"data-slot": "date-picker",
|
|
45
46
|
id: i,
|
|
46
47
|
type: "button",
|
|
47
48
|
role: "combobox",
|
|
@@ -55,7 +56,7 @@ function B({
|
|
|
55
56
|
className: C(
|
|
56
57
|
"bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm",
|
|
57
58
|
"transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]",
|
|
58
|
-
"focus-visible:ring-offset-background outline-
|
|
59
|
+
"focus-visible:ring-offset-background outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
59
60
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
60
61
|
s ? "border-danger focus-visible:border-danger focus-visible:ring-danger" : "border-border-input focus-visible:border-accent focus-visible:ring-ring",
|
|
61
62
|
!o && "text-foreground-subtle"
|
|
@@ -88,7 +89,6 @@ const T = O(function({
|
|
|
88
89
|
/* @__PURE__ */ n(
|
|
89
90
|
B,
|
|
90
91
|
{
|
|
91
|
-
"data-slot": "date-picker",
|
|
92
92
|
label: t,
|
|
93
93
|
placeholder: b,
|
|
94
94
|
hasValue: !!e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sources":["../../../src/components/ui/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useMemo, useState, type ReactNode } from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport type { DateRange, DayPickerProps, Matcher } from 'react-day-picker';\nimport { Calendar as CalendarIcon } from '@/icons';\nimport { Calendar } from './Calendar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\n/* -----------------------------------------------------------------------------\n * Two related components share the same trigger shell:\n *\n * <DatePicker value={date} onChange={setDate} /> // single date\n * <DateRangePicker value={range} onChange={setRange} /> // {from,to}\n * --------------------------------------------------------------------------- */\n\ntype CalendarLocale = DayPickerProps['locale'];\n\n/**\n * Default trigger text. With a date-fns `locale` the date is rendered in that\n * locale; without one it is the canonical `yyyy-MM-dd` — deterministic on\n * server and client, so SSR output never depends on the host's locale.\n */\nfunction defaultFormatDate(d: Date, locale?: CalendarLocale): string {\n if (locale?.code) {\n return d.toLocaleDateString(locale.code, { year: 'numeric', month: 'short', day: 'numeric' });\n }\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n}\n\n/** Merge the fromDate/toDate bounds with any consumer-supplied RDP matcher. */\nfunction useBounds(fromDate?: Date, toDate?: Date, disabled?: Matcher | Matcher[]) {\n return useMemo<Matcher[] | undefined>(() => {\n const list: Matcher[] = [];\n if (fromDate) list.push({ before: fromDate });\n if (toDate) list.push({ after: toDate });\n if (disabled) list.push(...(Array.isArray(disabled) ? disabled : [disabled]));\n return list.length ? list : undefined;\n }, [fromDate, toDate, disabled]);\n}\n\nfunction PickerTrigger({\n label,\n placeholder,\n hasValue,\n children,\n error,\n fieldId,\n disabled,\n open,\n}: {\n label?: ReactNode;\n placeholder: string;\n hasValue: boolean;\n children: ReactNode;\n error?: ReactNode;\n fieldId: string;\n disabled?: boolean;\n open: boolean;\n}) {\n const errorId = `${fieldId}-error`;\n const calendarId = `${fieldId}-calendar`;\n const text = hasValue ? children : placeholder;\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <label\n id={`${fieldId}-label`}\n htmlFor={fieldId}\n className=\"text-foreground text-sm font-medium\"\n >\n {label}\n </label>\n )}\n <PopoverPrimitive.Trigger asChild>\n <button\n id={fieldId}\n type=\"button\"\n // combobox-with-dialog pattern: lets the field carry aria-invalid like other inputs.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={calendarId}\n // role=combobox takes no name from content; expose the placeholder.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n disabled={disabled}\n aria-invalid={Boolean(error) || undefined}\n aria-describedby={error ? errorId : undefined}\n className={cn(\n 'bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error\n ? 'border-danger focus-visible:border-danger focus-visible:ring-danger'\n : 'border-border-input focus-visible:border-accent focus-visible:ring-ring',\n !hasValue && 'text-foreground-subtle',\n )}\n >\n <CalendarIcon className=\"text-foreground-subtle size-4\" aria-hidden />\n <span className=\"truncate\" title={typeof text === 'string' ? text : undefined}>\n {text}\n </span>\n </button>\n </PopoverPrimitive.Trigger>\n {error && (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n )}\n </div>\n );\n}\n\ninterface PickerCommonProps {\n label?: ReactNode;\n placeholder?: string;\n error?: ReactNode;\n disabled?: boolean;\n /** Restrict to a date range. Days outside are not selectable. */\n fromDate?: Date;\n toDate?: Date;\n /** Extra RDP matcher(s) for disabled days, merged with `fromDate`/`toDate`. */\n disabledDays?: Matcher | Matcher[];\n /** Custom display formatter for the trigger text. */\n formatDate?: (d: Date) => string;\n /** date-fns locale object passed through to react-day-picker. */\n locale?: CalendarLocale;\n className?: string;\n}\n\nexport interface DatePickerProps extends PickerCommonProps {\n value?: Date;\n onChange: (date: Date | undefined) => void;\n}\n\n/**\n * Single-date picker.\n *\n * @example\n * <DatePicker label=\"Date of birth\" value={dob} onChange={setDob} />\n *\n * @do Use locale-aware formatting via `formatDate` / `locale`.\n * @dont Roll a custom calendar — Radix Popover + react-day-picker handles a11y.\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickDate;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n data-slot=\"date-picker\"\n label={label}\n placeholder={placeholder}\n hasValue={Boolean(value)}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value ? formatDate(value) : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n // Radix gives the popover role=\"dialog\"; name it after the field.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"single\"\n selected={value}\n // RDP 9 ignores `selected` for the initial month; open on the value.\n defaultMonth={value}\n onSelect={(d) => {\n onChange(d ?? undefined);\n if (d) setOpen(false);\n }}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n});\nDatePicker.displayName = 'DatePicker';\n\nexport interface DateRangePickerProps extends PickerCommonProps {\n value?: DateRange;\n onChange: (range: DateRange | undefined) => void;\n}\n\n/**\n * Two-date range picker. `value` is `{from, to}`.\n *\n * @example\n * <DateRangePicker label=\"Reporting period\" value={range} onChange={setRange} />\n */\nexport const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(\n function DateRangePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n ) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickRange;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const hasValue = Boolean(value?.from);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={hasValue}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value?.from && value.to\n ? `${formatDate(value.from)} – ${formatDate(value.to)}`\n : value?.from\n ? formatDate(value.from)\n : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"range\"\n selected={value}\n defaultMonth={value?.from}\n onSelect={onChange}\n numberOfMonths={2}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n },\n);\nDateRangePicker.displayName = 'DateRangePicker';\n"],"names":["defaultFormatDate","d","locale","pad","n","useBounds","fromDate","toDate","disabled","useMemo","list","PickerTrigger","label","placeholder","hasValue","children","error","fieldId","open","errorId","calendarId","text","jsxs","jsx","PopoverPrimitive","cn","CalendarIcon","DatePicker","forwardRef","value","onChange","placeholderProp","disabledDays","formatDateProp","className","ref","strings","useStrings","formatDate","useId","setOpen","useState","bounds","Calendar","DateRangePicker"],"mappings":";;;;;;;;AAwBA,SAASA,EAAkBC,GAASC,GAAiC;AACnE,MAAIA,KAAA,QAAAA,EAAQ;AACV,WAAOD,EAAE,mBAAmBC,EAAO,MAAM,EAAE,MAAM,WAAW,OAAO,SAAS,KAAK,UAAA,CAAW;AAE9F,QAAMC,IAAM,CAACC,MAAc,OAAOA,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,SAAO,GAAGH,EAAE,YAAA,CAAa,IAAIE,EAAIF,EAAE,SAAA,IAAa,CAAC,CAAC,IAAIE,EAAIF,EAAE,QAAA,CAAS,CAAC;AACxE;AAGA,SAASI,EAAUC,GAAiBC,GAAeC,GAAgC;AACjF,SAAOC,EAA+B,MAAM;AAC1C,UAAMC,IAAkB,CAAA;AACxB,WAAIJ,KAAUI,EAAK,KAAK,EAAE,QAAQJ,GAAU,GACxCC,KAAQG,EAAK,KAAK,E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,WAAWV,EAAGS,CAAS,GACpC,UAAA,gBAAAZ,EAACE,EAAiB,MAAjB,EAAsB,MAAAN,GAAY,cAAcsB,GAC/C,UAAA;AAAA,MAAA,gBAAAjB;AAAA,QAACZ;AAAA,QAAA;AAAA,UACC,OAAAC;AAAA,UACA,aAAAC;AAAA,UACA,UAAAC;AAAA,UACA,OAAAE;AAAA,UACA,SAAAC;AAAA,UACA,UAAAT;AAAA,UACA,MAAAU;AAAA,UAEC,UAAAW,KAAA,QAAAA,EAAO,QAAQA,EAAM,KAClB,GAAGS,EAAWT,EAAM,IAAI,CAAC,MAAMS,EAAWT,EAAM,EAAE,CAAC,KACnDA,KAAA,QAAAA,EAAO,OACLS,EAAWT,EAAM,IAAI,IACrB;AAAA,QAAA;AAAA,MAAA;AAAA,MAER,gBAAAN,EAACC,EAAiB,QAAjB,EACC,UAAA,gBAAAD;AAAA,QAACC,EAAiB;AAAA,QAAjB;AAAA,UACC,IAAI,GAAGP,CAAO;AAAA,UACd,mBAAiBL,IAAQ,GAAGK,CAAO,WAAW;AAAA,UAC9C,cAAYL,IAAQ,SAAYC;AAAA,UAChC,OAAM;AAAA,UACN,YAAY;AAAA,UACZ,WAAU;AAAA,UAEV,UAAA,gBAAAU;AAAA,YAACoB;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAUd;AAAA,cACV,cAAcA,KAAA,gBAAAA,EAAO;AAAA,cACrB,UAAUC;AAAA,cACV,gBAAgB;AAAA,cAChB,YAAYxB;AAAA,cACZ,UAAUC;AAAA,cACV,UAAUmC;AAAA,cACV,QAAAxC;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA,EACF,CACF;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,EAEJ;AACF;AACA0C,EAAgB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../../../src/components/ui/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useMemo, useState, type ReactNode } from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport type { DateRange, DayPickerProps, Matcher } from 'react-day-picker';\nimport { Calendar as CalendarIcon } from '@/icons';\nimport { Calendar } from './Calendar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\n/* -----------------------------------------------------------------------------\n * Two related components share the same trigger shell:\n *\n * <DatePicker value={date} onChange={setDate} /> // single date\n * <DateRangePicker value={range} onChange={setRange} /> // {from,to}\n * --------------------------------------------------------------------------- */\n\ntype CalendarLocale = DayPickerProps['locale'];\n\n/**\n * Default trigger text. With a date-fns `locale` the date is rendered in that\n * locale; without one it is the canonical `yyyy-MM-dd` — deterministic on\n * server and client, so SSR output never depends on the host's locale.\n */\nfunction defaultFormatDate(d: Date, locale?: CalendarLocale): string {\n if (locale?.code) {\n return d.toLocaleDateString(locale.code, { year: 'numeric', month: 'short', day: 'numeric' });\n }\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n}\n\n/** Merge the fromDate/toDate bounds with any consumer-supplied RDP matcher. */\nfunction useBounds(fromDate?: Date, toDate?: Date, disabled?: Matcher | Matcher[]) {\n return useMemo<Matcher[] | undefined>(() => {\n const list: Matcher[] = [];\n if (fromDate) list.push({ before: fromDate });\n if (toDate) list.push({ after: toDate });\n if (disabled) list.push(...(Array.isArray(disabled) ? disabled : [disabled]));\n return list.length ? list : undefined;\n }, [fromDate, toDate, disabled]);\n}\n\nfunction PickerTrigger({\n label,\n placeholder,\n hasValue,\n children,\n error,\n fieldId,\n disabled,\n open,\n}: {\n label?: ReactNode;\n placeholder: string;\n hasValue: boolean;\n children: ReactNode;\n error?: ReactNode;\n fieldId: string;\n disabled?: boolean;\n open: boolean;\n}) {\n const errorId = `${fieldId}-error`;\n const calendarId = `${fieldId}-calendar`;\n const text = hasValue ? children : placeholder;\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <label\n id={`${fieldId}-label`}\n htmlFor={fieldId}\n className=\"text-foreground text-sm font-medium\"\n >\n {label}\n </label>\n )}\n <PopoverPrimitive.Trigger asChild>\n <button\n data-slot=\"date-picker\"\n id={fieldId}\n type=\"button\"\n // combobox-with-dialog pattern: lets the field carry aria-invalid like other inputs.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={calendarId}\n // role=combobox takes no name from content; expose the placeholder.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n disabled={disabled}\n aria-invalid={Boolean(error) || undefined}\n aria-describedby={error ? errorId : undefined}\n className={cn(\n 'bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-visible:ring-offset-background outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error\n ? 'border-danger focus-visible:border-danger focus-visible:ring-danger'\n : 'border-border-input focus-visible:border-accent focus-visible:ring-ring',\n !hasValue && 'text-foreground-subtle',\n )}\n >\n <CalendarIcon className=\"text-foreground-subtle size-4\" aria-hidden />\n <span className=\"truncate\" title={typeof text === 'string' ? text : undefined}>\n {text}\n </span>\n </button>\n </PopoverPrimitive.Trigger>\n {error && (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n )}\n </div>\n );\n}\n\ninterface PickerCommonProps {\n label?: ReactNode;\n placeholder?: string;\n error?: ReactNode;\n disabled?: boolean;\n /** Restrict to a date range. Days outside are not selectable. */\n fromDate?: Date;\n toDate?: Date;\n /** Extra RDP matcher(s) for disabled days, merged with `fromDate`/`toDate`. */\n disabledDays?: Matcher | Matcher[];\n /** Custom display formatter for the trigger text. */\n formatDate?: (d: Date) => string;\n /** date-fns locale object passed through to react-day-picker. */\n locale?: CalendarLocale;\n className?: string;\n}\n\nexport interface DatePickerProps extends PickerCommonProps {\n value?: Date;\n onChange: (date: Date | undefined) => void;\n}\n\n/**\n * Single-date picker.\n *\n * @example\n * <DatePicker label=\"Date of birth\" value={dob} onChange={setDob} />\n *\n * @do Use locale-aware formatting via `formatDate` / `locale`.\n * @dont Roll a custom calendar — Radix Popover + react-day-picker handles a11y.\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickDate;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={Boolean(value)}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value ? formatDate(value) : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n // Radix gives the popover role=\"dialog\"; name it after the field.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"single\"\n selected={value}\n // RDP 9 ignores `selected` for the initial month; open on the value.\n defaultMonth={value}\n onSelect={(d) => {\n onChange(d ?? undefined);\n if (d) setOpen(false);\n }}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n});\nDatePicker.displayName = 'DatePicker';\n\nexport interface DateRangePickerProps extends PickerCommonProps {\n value?: DateRange;\n onChange: (range: DateRange | undefined) => void;\n}\n\n/**\n * Two-date range picker. `value` is `{from, to}`.\n *\n * @example\n * <DateRangePicker label=\"Reporting period\" value={range} onChange={setRange} />\n */\nexport const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(\n function DateRangePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n ) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickRange;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const hasValue = Boolean(value?.from);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={hasValue}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value?.from && value.to\n ? `${formatDate(value.from)} – ${formatDate(value.to)}`\n : value?.from\n ? formatDate(value.from)\n : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"range\"\n selected={value}\n defaultMonth={value?.from}\n onSelect={onChange}\n numberOfMonths={2}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n },\n);\nDateRangePicker.displayName = 'DateRangePicker';\n"],"names":["defaultFormatDate","d","locale","pad","n","useBounds","fromDate","toDate","disabled","useMemo","list","PickerTrigger","label","placeholder","hasValue","children","error","fieldId","open","errorId","calendarId","text","jsxs","jsx","PopoverPrimitive","cn","CalendarIcon","DatePicker","forwardRef","value","onChange","placeholderProp","disabledDays","formatDateProp","className","ref","strings","useStrings","formatDate","useId","setOpen","useState","bounds","Calendar","DateRangePicker"],"mappings":";;;;;;;;AAwBA,SAASA,EAAkBC,GAASC,GAAiC;AACnE,MAAIA,KAAA,QAAAA,EAAQ;AACV,WAAOD,EAAE,mBAAmBC,EAAO,MAAM,EAAE,MAAM,WAAW,OAAO,SAAS,KAAK,UAAA,CAAW;AAE9F,QAAMC,IAAM,CAACC,MAAc,OAAOA,CAAC,EAAE,SAAS,GAAG,GAAG;AACpD,SAAO,GAAGH,EAAE,YAAA,CAAa,IAAIE,EAAIF,EAAE,SAAA,IAAa,CAAC,CAAC,IAAIE,EAAIF,EAAE,QAAA,CAAS,CAAC;AACxE;AAGA,SAASI,EAAUC,GAAiBC,GAAeC,GAAgC;AACjF,SAAOC,EAA+B,MAAM;AAC1C,UAAMC,IAAkB,CAAA;AACxB,WAAIJ,KAAUI,EAAK,KAAK,EAAE,QAAQJ,GAAU,GACxCC,KAAQG,EAAK,KAAK,EAAE,OAAOH,GAAQ,GACnCC,KAAUE,EAAK,KAAK,GAAI,MAAM,QAAQF,CAAQ,IAAIA,IAAW,CAACA,CAAQ,CAAE,GACrEE,EAAK,SAASA,IAAO;AAAA,EAC9B,GAAG,CAACJ,GAAUC,GAAQC,CAAQ,CAAC;AACjC;AAEA,SAASG,EAAc;AAAA,EACrB,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAT;AAAA,EACA,MAAAU;AACF,GASG;AACD,QAAMC,IAAU,GAAGF,CAAO,UACpBG,IAAa,GAAGH,CAAO,aACvBI,IAAOP,IAAWC,IAAWF;AACnC,SACE,gBAAAS,EAAC,OAAA,EAAI,WAAU,yBACZ,UA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EAACC,EAAiB,QAAjB,EACC,UAAA,gBAAAD;AAAA,QAACC,EAAiB;AAAA,QAAjB;AAAA,UACC,IAAI,GAAGP,CAAO;AAAA,UACd,mBAAiBL,IAAQ,GAAGK,CAAO,WAAW;AAAA,UAC9C,cAAYL,IAAQ,SAAYC;AAAA,UAChC,OAAM;AAAA,UACN,YAAY;AAAA,UACZ,WAAU;AAAA,UAEV,UAAA,gBAAAU;AAAA,YAACoB;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAUd;AAAA,cACV,cAAcA,KAAA,gBAAAA,EAAO;AAAA,cACrB,UAAUC;AAAA,cACV,gBAAgB;AAAA,cAChB,YAAYxB;AAAA,cACZ,UAAUC;AAAA,cACV,UAAUmC;AAAA,cACV,QAAAxC;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA,EACF,CACF;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,EAEJ;AACF;AACA0C,EAAgB,cAAc;"}
|
|
@@ -56,7 +56,7 @@ const z = c(function({ className: a, children: i, showClose: o = !0, size: l = "
|
|
|
56
56
|
className: r(
|
|
57
57
|
"text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md",
|
|
58
58
|
"hover:bg-background-muted hover:text-foreground",
|
|
59
|
-
"focus-visible:ring-ring focus-visible:ring-offset-card outline-
|
|
59
|
+
"focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
60
60
|
"transition-colors duration-[var(--duration-fast)]"
|
|
61
61
|
),
|
|
62
62
|
children: /* @__PURE__ */ e(S, { className: "size-4", "aria-hidden": !0 })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","sources":["../../../src/components/ui/Dialog.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Button, type ButtonProps } from './Button';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\nexport const Dialog = DialogPrimitive.Root;\nexport const DialogTrigger = DialogPrimitive.Trigger;\nexport const DialogPortal = DialogPrimitive.Portal;\nexport const DialogClose = DialogPrimitive.Close;\n\nexport const DialogOverlay = forwardRef<\n ComponentRef<typeof DialogPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(function DialogOverlay({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n ref={ref}\n className={cn(\n 'bg-overlay fixed inset-0 z-[var(--z-overlay)]',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n className,\n )}\n {...props}\n />\n );\n});\nDialogOverlay.displayName = 'DialogOverlay';\n\nexport interface DialogContentProps extends ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /** Show the default close (×) button in the top-right. */\n showClose?: boolean;\n /** Dialog width — `sm` 400 / `md` 520 / `lg` 720. */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DialogContent = forwardRef<\n ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(function DialogContent(\n { className, children, showClose = true, size = 'md', returnFocusTo, onCloseAutoFocus, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'fixed top-1/2 left-1/2 z-[var(--z-modal)] -translate-x-1/2 -translate-y-1/2',\n 'border-border bg-card text-card-foreground w-[calc(100%-2rem)] rounded-xl border shadow-lg',\n 'p-6',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n size === 'sm' && 'max-w-[400px]',\n size === 'md' && 'max-w-[520px]',\n size === 'lg' && 'max-w-[720px]',\n className,\n )}\n {...props}\n >\n {children}\n {showClose && (\n <DialogPrimitive.Close\n aria-label={strings.dialog.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n});\nDialogContent.displayName = 'DialogContent';\n\nexport function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('flex flex-col gap-1 pb-4', className)} {...props} />;\n}\nDialogHeader.displayName = 'DialogHeader';\n\nexport function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn('flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end', className)}\n {...props}\n />\n );\n}\nDialogFooter.displayName = 'DialogFooter';\n\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof DialogPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(function DialogTitle({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-foreground text-lg leading-tight font-semibold', className)}\n {...props}\n />\n );\n});\nDialogTitle.displayName = 'DialogTitle';\n\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof DialogPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(function DialogDescription({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDialogDescription.displayName = 'DialogDescription';\n\n/* -----------------------------------------------------------------------------\n * ConfirmationDialog — pre-composed pattern for destructive/important\n * confirmations. Use this when the body is a single sentence and the only\n * controls are Cancel + Confirm.\n * --------------------------------------------------------------------------- */\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n /** Label of the confirm button. */\n confirmLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Variant of the confirm button — typically `primary` or `destructive`. */\n confirmVariant?: ButtonProps['variant'];\n /**\n * Called when the user confirms. Awaited — the confirm button shows a\n * spinner while pending and a rejection is rendered inline (the dialog stays\n * open so the user can retry or cancel).\n */\n onConfirm: () => void | Promise<void>;\n /** Force the submitting state from outside (in addition to the awaited `onConfirm`). */\n loading?: boolean;\n /** Map a rejected `onConfirm` to the message shown. Defaults to `Error.message`. */\n formatError?: (err: unknown) => ReactNode;\n}\n\n/**\n * Confirmation dialog with title, description, cancel + confirm buttons.\n *\n * @example Destructive confirmation\n * <ConfirmationDialog\n * open={open} onOpenChange={setOpen}\n * title=\"Delete project?\"\n * description=\"This permanently deletes the project and all its data.\"\n * confirmLabel=\"Delete project\"\n * confirmVariant=\"destructive\"\n * onConfirm={handleDelete}\n * />\n *\n * @do Lead the title with the action: \"Delete project?\" not \"Are you sure?\".\n * State consequences in the description.\n * @dont Use for low-risk reversible actions — those don't need a dialog.\n */\nexport function ConfirmationDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmLabel,\n cancelLabel,\n confirmVariant = 'primary',\n onConfirm,\n loading,\n formatError = defaultFormatError,\n}: ConfirmationDialogProps) {\n const strings = useStrings();\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const busy = Boolean(loading) || pending;\n\n const handleConfirm = async () => {\n setFailure(null);\n setPending(true);\n try {\n await onConfirm();\n } catch (err) {\n setFailure(formatError(err));\n } finally {\n setPending(false);\n }\n };\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) setFailure(null);\n onOpenChange(next);\n }}\n >\n {/* No description → drop aria-describedby so Radix does not warn and AT is not pointed at nothing. */}\n <DialogContent size=\"sm\" {...(description ? {} : { 'aria-describedby': undefined })}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n {description && <DialogDescription>{description}</DialogDescription>}\n </DialogHeader>\n {failure && (\n <p role=\"alert\" className=\"text-danger-text text-sm\">\n {failure}\n </p>\n )}\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\" disabled={busy}>\n {cancelLabel ?? strings.confirmationDialog.cancel}\n </Button>\n </DialogClose>\n <Button variant={confirmVariant} loading={busy} onClick={handleConfirm}>\n {confirmLabel ?? strings.confirmationDialog.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction defaultFormatError(err: unknown): ReactNode {\n return err instanceof Error ? err.message : String(err);\n}\nConfirmationDialog.displayName = 'ConfirmationDialog';\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","forwardRef","className","props","ref","jsx","cn","DialogContent","children","showClose","size","returnFocusTo","onCloseAutoFocus","strings","useStrings","jsxs","withReturnFocus","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription","ConfirmationDialog","open","onOpenChange","title","description","confirmLabel","cancelLabel","confirmVariant","onConfirm","loading","formatError","defaultFormatError","pending","setPending","useState","failure","setFailure","busy","handleConfirm","err","next","Button"],"mappings":";;;;;;;;;AAiBO,MAAMA,IAASC,EAAgB,MACzBC,IAAgBD,EAAgB,SAChCE,IA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EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASoB,EAAmBQ,GAAyB;AACnD,SAAOA,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG;AACxD;AACAnB,EAAmB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Dialog.js","sources":["../../../src/components/ui/Dialog.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useState,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport * as DialogPrimitive from '@radix-ui/react-dialog';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { Button, type ButtonProps } from './Button';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\nexport const Dialog = DialogPrimitive.Root;\nexport const DialogTrigger = DialogPrimitive.Trigger;\nexport const DialogPortal = DialogPrimitive.Portal;\nexport const DialogClose = DialogPrimitive.Close;\n\nexport const DialogOverlay = forwardRef<\n ComponentRef<typeof DialogPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(function DialogOverlay({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Overlay\n data-slot=\"dialog-overlay\"\n ref={ref}\n className={cn(\n 'bg-overlay fixed inset-0 z-[var(--z-overlay)]',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n className,\n )}\n {...props}\n />\n );\n});\nDialogOverlay.displayName = 'DialogOverlay';\n\nexport interface DialogContentProps extends ComponentPropsWithoutRef<\n typeof DialogPrimitive.Content\n> {\n /** Show the default close (×) button in the top-right. */\n showClose?: boolean;\n /** Dialog width — `sm` 400 / `md` 520 / `lg` 720. */\n size?: 'sm' | 'md' | 'lg';\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DialogContent = forwardRef<\n ComponentRef<typeof DialogPrimitive.Content>,\n DialogContentProps\n>(function DialogContent(\n { className, children, showClose = true, size = 'md', returnFocusTo, onCloseAutoFocus, ...props },\n ref,\n) {\n const strings = useStrings();\n return (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n data-slot=\"dialog-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'fixed top-1/2 left-1/2 z-[var(--z-modal)] -translate-x-1/2 -translate-y-1/2',\n 'border-border bg-card text-card-foreground w-[calc(100%-2rem)] rounded-xl border shadow-lg',\n 'p-6',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n size === 'sm' && 'max-w-[400px]',\n size === 'md' && 'max-w-[520px]',\n size === 'lg' && 'max-w-[720px]',\n className,\n )}\n {...props}\n >\n {children}\n {showClose && (\n <DialogPrimitive.Close\n aria-label={strings.dialog.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DialogPrimitive.Close>\n )}\n </DialogPrimitive.Content>\n </DialogPortal>\n );\n});\nDialogContent.displayName = 'DialogContent';\n\nexport function DialogHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('flex flex-col gap-1 pb-4', className)} {...props} />;\n}\nDialogHeader.displayName = 'DialogHeader';\n\nexport function DialogFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn('flex flex-col-reverse gap-2 pt-6 sm:flex-row sm:justify-end', className)}\n {...props}\n />\n );\n}\nDialogFooter.displayName = 'DialogFooter';\n\nexport const DialogTitle = forwardRef<\n ComponentRef<typeof DialogPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(function DialogTitle({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Title\n ref={ref}\n className={cn('text-foreground text-lg leading-tight font-semibold', className)}\n {...props}\n />\n );\n});\nDialogTitle.displayName = 'DialogTitle';\n\nexport const DialogDescription = forwardRef<\n ComponentRef<typeof DialogPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(function DialogDescription({ className, ...props }, ref) {\n return (\n <DialogPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDialogDescription.displayName = 'DialogDescription';\n\n/* -----------------------------------------------------------------------------\n * ConfirmationDialog — pre-composed pattern for destructive/important\n * confirmations. Use this when the body is a single sentence and the only\n * controls are Cancel + Confirm.\n * --------------------------------------------------------------------------- */\n\nexport interface ConfirmationDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: ReactNode;\n description?: ReactNode;\n /** Label of the confirm button. */\n confirmLabel?: string;\n /** Label of the cancel button. */\n cancelLabel?: string;\n /** Variant of the confirm button — typically `primary` or `destructive`. */\n confirmVariant?: ButtonProps['variant'];\n /**\n * Called when the user confirms. Awaited — the confirm button shows a\n * spinner while pending and a rejection is rendered inline (the dialog stays\n * open so the user can retry or cancel).\n */\n onConfirm: () => void | Promise<void>;\n /** Force the submitting state from outside (in addition to the awaited `onConfirm`). */\n loading?: boolean;\n /** Map a rejected `onConfirm` to the message shown. Defaults to `Error.message`. */\n formatError?: (err: unknown) => ReactNode;\n}\n\n/**\n * Confirmation dialog with title, description, cancel + confirm buttons.\n *\n * @example Destructive confirmation\n * <ConfirmationDialog\n * open={open} onOpenChange={setOpen}\n * title=\"Delete project?\"\n * description=\"This permanently deletes the project and all its data.\"\n * confirmLabel=\"Delete project\"\n * confirmVariant=\"destructive\"\n * onConfirm={handleDelete}\n * />\n *\n * @do Lead the title with the action: \"Delete project?\" not \"Are you sure?\".\n * State consequences in the description.\n * @dont Use for low-risk reversible actions — those don't need a dialog.\n */\nexport function ConfirmationDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmLabel,\n cancelLabel,\n confirmVariant = 'primary',\n onConfirm,\n loading,\n formatError = defaultFormatError,\n}: ConfirmationDialogProps) {\n const strings = useStrings();\n const [pending, setPending] = useState(false);\n const [failure, setFailure] = useState<ReactNode>(null);\n const busy = Boolean(loading) || pending;\n\n const handleConfirm = async () => {\n setFailure(null);\n setPending(true);\n try {\n await onConfirm();\n } catch (err) {\n setFailure(formatError(err));\n } finally {\n setPending(false);\n }\n };\n\n return (\n <Dialog\n open={open}\n onOpenChange={(next) => {\n if (!next) setFailure(null);\n onOpenChange(next);\n }}\n >\n {/* No description → drop aria-describedby so Radix does not warn and AT is not pointed at nothing. */}\n <DialogContent size=\"sm\" {...(description ? {} : { 'aria-describedby': undefined })}>\n <DialogHeader>\n <DialogTitle>{title}</DialogTitle>\n {description && <DialogDescription>{description}</DialogDescription>}\n </DialogHeader>\n {failure && (\n <p role=\"alert\" className=\"text-danger-text text-sm\">\n {failure}\n </p>\n )}\n <DialogFooter>\n <DialogClose asChild>\n <Button variant=\"outline\" disabled={busy}>\n {cancelLabel ?? strings.confirmationDialog.cancel}\n </Button>\n </DialogClose>\n <Button variant={confirmVariant} loading={busy} onClick={handleConfirm}>\n {confirmLabel ?? strings.confirmationDialog.confirm}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction defaultFormatError(err: unknown): ReactNode {\n return err instanceof Error ? err.message : String(err);\n}\nConfirmationDialog.displayName = 'ConfirmationDialog';\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","forwardRef","className","props","ref","jsx","cn","DialogContent","children","showClose","size","returnFocusTo","onCloseAutoFocus","strings","useStrings","jsxs","withReturnFocus","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription","ConfirmationDialog","open","onOpenChange","title","description","confirmLabel","cancelLabel","confirmVariant","onConfirm","loading","formatError","defaultFormatError","pending","setPending","useState","failure","setFailure","busy","handleConfirm","err","next","Button"],"mappings":";;;;;;;;;AAiBO,MAAMA,IAASC,EAAgB,MACzBC,IAAgBD,EAAgB,SAChCE,IAAeF,EAAgB,QAC/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAG3B,SAAuB,EAAE,WAAAC,GAAW,GAAGC,EAAA,GAASC,GAAK;AACrD,SACE,gBAAAC;AAAA,IAACT,EAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,KAAAQ;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACAJ;AAAA,MAAA;AAAA,MAED,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDH,EAAc,cAAc;AAmBrB,MAAMO,IAAgBN,EAG3B,SACA,EAAE,WAAAC,GAAW,UAAAM,GAAU,WAAAC,IAAY,IAAM,MAAAC,IAAO,MAAM,eAAAC,GAAe,kBAAAC,GAAkB,GAAGT,EAAA,GAC1FC,GACA;AACA,QAAMS,IAAUC,EAAA;AAChB,2BACGhB,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAO,EAACL,GAAA,EAAc;AAAA,IACf,gBAAAe;AAAA,MAACnB,EAAgB;AAAA,MAAhB;AAAA,QACC,aAAU;AAAA,QACV,KAAAQ;AAAA,QACA,kBAAkBY,EAAgBL,GAAeC,CAAgB;AAAA,QACjE,WAAWN;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACAI,MAAS,QAAQ;AAAA,UACjBA,MAAS,QAAQ;AAAA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AK,SAAQ,WAAU,4BACvB,UAAAgC,GACH;AAAA,0BAEDlB,GAAA,EACC,UAAA;AAAA,UAAA,gBAAAd,EAACN,GAAA,EAAY,SAAO,IAClB,UAAA,gBAAAM,EAACsC,GAAA,EAAO,SAAQ,WAAU,UAAUJ,GACjC,UAAAX,KAAef,EAAQ,mBAAmB,QAC7C,GACF;AAAA,UACA,gBAAAR,EAACsC,GAAA,EAAO,SAASd,GAAgB,SAASU,GAAM,SAASC,GACtD,UAAAb,KAAgBd,EAAQ,mBAAmB,QAAA,CAC9C;AAAA,QAAA,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASoB,EAAmBQ,GAAyB;AACnD,SAAOA,aAAe,QAAQA,EAAI,UAAU,OAAOA,CAAG;AACxD;AACAnB,EAAmB,cAAc;"}
|
|
@@ -3,7 +3,7 @@ import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef as s, useContext as v, createContext as y } from "react";
|
|
4
4
|
import { Drawer as a } from "vaul";
|
|
5
5
|
import { X as N } from "../../icons/index.js";
|
|
6
|
-
import { cn as
|
|
6
|
+
import { cn as l } from "../../lib/utils.js";
|
|
7
7
|
import { useStrings as C } from "../../hooks/use-strings.js";
|
|
8
8
|
import { withReturnFocus as z } from "../../lib/return-focus.js";
|
|
9
9
|
const m = y("bottom"), T = ({
|
|
@@ -19,13 +19,13 @@ const m = y("bottom"), T = ({
|
|
|
19
19
|
}
|
|
20
20
|
) });
|
|
21
21
|
T.displayName = "Drawer";
|
|
22
|
-
const I = a.Trigger, F = a.Portal, J = a.Close, f = s(function({ className: e, ...o },
|
|
22
|
+
const I = a.Trigger, F = a.Portal, J = a.Close, f = s(function({ className: e, ...o }, n) {
|
|
23
23
|
return /* @__PURE__ */ r(
|
|
24
24
|
a.Overlay,
|
|
25
25
|
{
|
|
26
26
|
"data-slot": "drawer-overlay",
|
|
27
|
-
ref:
|
|
28
|
-
className:
|
|
27
|
+
ref: n,
|
|
28
|
+
className: l("bg-overlay fixed inset-0 z-[var(--z-overlay)]", e),
|
|
29
29
|
...o
|
|
30
30
|
}
|
|
31
31
|
);
|
|
@@ -44,7 +44,7 @@ const O = {
|
|
|
44
44
|
}, k = s(function({
|
|
45
45
|
className: e,
|
|
46
46
|
direction: o,
|
|
47
|
-
hideHandle:
|
|
47
|
+
hideHandle: n,
|
|
48
48
|
showClose: u = !0,
|
|
49
49
|
returnFocusTo: x,
|
|
50
50
|
onCloseAutoFocus: b,
|
|
@@ -60,7 +60,7 @@ const O = {
|
|
|
60
60
|
"data-slot": "drawer-content",
|
|
61
61
|
ref: g,
|
|
62
62
|
onCloseAutoFocus: z(x, b),
|
|
63
|
-
className:
|
|
63
|
+
className: l(
|
|
64
64
|
"bg-card fixed z-[var(--z-modal)]",
|
|
65
65
|
O[i],
|
|
66
66
|
d && "flex-row",
|
|
@@ -68,16 +68,16 @@ const O = {
|
|
|
68
68
|
),
|
|
69
69
|
...h,
|
|
70
70
|
children: [
|
|
71
|
-
!
|
|
72
|
-
/* @__PURE__ */ r("div", { className:
|
|
71
|
+
!n && /* @__PURE__ */ r("div", { "aria-hidden": !0, className: j[i] }),
|
|
72
|
+
/* @__PURE__ */ r("div", { className: l("min-h-0 min-w-0 flex-1", d && "flex flex-col"), children: w }),
|
|
73
73
|
u && /* @__PURE__ */ r(
|
|
74
74
|
a.Close,
|
|
75
75
|
{
|
|
76
76
|
"aria-label": D.drawer.close,
|
|
77
|
-
className:
|
|
77
|
+
className: l(
|
|
78
78
|
"text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md",
|
|
79
79
|
"hover:bg-background-muted hover:text-foreground",
|
|
80
|
-
"focus-visible:ring-ring focus-visible:ring-offset-card outline-
|
|
80
|
+
"focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
81
81
|
"transition-colors duration-[var(--duration-fast)]"
|
|
82
82
|
),
|
|
83
83
|
children: /* @__PURE__ */ r(N, { className: "size-4", "aria-hidden": !0 })
|
|
@@ -90,30 +90,30 @@ const O = {
|
|
|
90
90
|
});
|
|
91
91
|
k.displayName = "DrawerContent";
|
|
92
92
|
function H({ className: t, ...e }) {
|
|
93
|
-
return /* @__PURE__ */ r("div", { className:
|
|
93
|
+
return /* @__PURE__ */ r("div", { className: l("grid gap-1 p-4 text-center sm:text-left", t), ...e });
|
|
94
94
|
}
|
|
95
95
|
H.displayName = "DrawerHeader";
|
|
96
96
|
function P({ className: t, ...e }) {
|
|
97
|
-
return /* @__PURE__ */ r("div", { className:
|
|
97
|
+
return /* @__PURE__ */ r("div", { className: l("mt-auto flex flex-col gap-2 p-4", t), ...e });
|
|
98
98
|
}
|
|
99
99
|
P.displayName = "DrawerFooter";
|
|
100
|
-
const R = s(function({ className: e, ...o },
|
|
100
|
+
const R = s(function({ className: e, ...o }, n) {
|
|
101
101
|
return /* @__PURE__ */ r(
|
|
102
102
|
a.Title,
|
|
103
103
|
{
|
|
104
|
-
ref:
|
|
105
|
-
className:
|
|
104
|
+
ref: n,
|
|
105
|
+
className: l("text-lg font-semibold", e),
|
|
106
106
|
...o
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
109
|
});
|
|
110
110
|
R.displayName = "DrawerTitle";
|
|
111
|
-
const S = s(function({ className: e, ...o },
|
|
111
|
+
const S = s(function({ className: e, ...o }, n) {
|
|
112
112
|
return /* @__PURE__ */ r(
|
|
113
113
|
a.Description,
|
|
114
114
|
{
|
|
115
|
-
ref:
|
|
116
|
-
className:
|
|
115
|
+
ref: n,
|
|
116
|
+
className: l("text-foreground-muted text-sm", e),
|
|
117
117
|
...o
|
|
118
118
|
}
|
|
119
119
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.js","sources":["../../../src/components/ui/Drawer.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\ntype Direction = 'top' | 'right' | 'bottom' | 'left';\n\n// vaul needs `direction` on Root for its drag physics; DrawerContent reads it\n// back from here so the side only has to be declared once.\nconst DrawerDirectionContext = createContext<Direction>('bottom');\n\nexport const Drawer = ({\n shouldScaleBackground = true,\n direction = 'bottom',\n ...props\n}: ComponentPropsWithoutRef<typeof DrawerPrimitive.Root>) => (\n <DrawerDirectionContext.Provider value={direction}>\n <DrawerPrimitive.Root\n shouldScaleBackground={shouldScaleBackground}\n direction={direction}\n {...props}\n />\n </DrawerDirectionContext.Provider>\n);\nDrawer.displayName = 'Drawer';\n\nexport const DrawerTrigger = DrawerPrimitive.Trigger;\nexport const DrawerPortal = DrawerPrimitive.Portal;\nexport const DrawerClose = DrawerPrimitive.Close;\n\nexport const DrawerOverlay = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>\n>(function DrawerOverlay({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Overlay\n data-slot=\"drawer-overlay\"\n ref={ref}\n className={cn('bg-overlay fixed inset-0 z-[var(--z-overlay)]', className)}\n {...props}\n />\n );\n});\nDrawerOverlay.displayName = 'DrawerOverlay';\n\n// Edge-anchored sides pad by the matching safe-area inset (consumers set viewport-fit=cover).\nconst directionStyles: Record<Direction, string> = {\n bottom:\n 'inset-x-0 bottom-0 mt-24 flex h-auto max-h-[90dvh] flex-col rounded-t-xl border-t border-border pb-[env(safe-area-inset-bottom)]',\n top: 'inset-x-0 top-0 mb-24 flex h-auto max-h-[90dvh] flex-col rounded-b-xl border-b border-border',\n left: 'inset-y-0 left-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-r-xl border-r border-border pl-[env(safe-area-inset-left)]',\n right:\n 'inset-y-0 right-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-l-xl border-l border-border pr-[env(safe-area-inset-right)]',\n};\n\nconst handleStyles: Record<Direction, string> = {\n bottom: 'mx-auto mt-3 h-1.5 w-12 rounded-full bg-border',\n top: 'mx-auto mb-3 h-1.5 w-12 rounded-full bg-border order-last',\n left: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border order-last self-stretch shrink-0',\n right: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border shrink-0 self-stretch',\n};\n\nexport interface DrawerContentProps extends ComponentPropsWithoutRef<\n typeof DrawerPrimitive.Content\n> {\n /**\n * Side the drawer slides in from. Prefer setting `direction` on `<Drawer>`\n * (vaul needs it there for drag physics); this prop only overrides the\n * visual placement.\n */\n direction?: Direction;\n /** Hide the drag handle. */\n hideHandle?: boolean;\n /** Show the close (×) button. Default `true`. */\n showClose?: boolean;\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DrawerContent = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Content>,\n DrawerContentProps\n>(function DrawerContent(\n {\n className,\n direction: directionProp,\n hideHandle,\n showClose = true,\n returnFocusTo,\n onCloseAutoFocus,\n children,\n ...props\n },\n ref,\n) {\n const rootDirection = useContext(DrawerDirectionContext);\n const direction = directionProp ?? rootDirection;\n const strings = useStrings();\n const isHorizontal = direction === 'left' || direction === 'right';\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot=\"drawer-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'bg-card fixed z-[var(--z-modal)]',\n directionStyles[direction],\n isHorizontal && 'flex-row',\n className,\n )}\n {...props}\n >\n {!hideHandle && <div aria-hidden className={handleStyles[direction]} />}\n <div className={cn('min-h-0 min-w-0 flex-1', isHorizontal && 'flex flex-col')}>\n {children}\n </div>\n {showClose && (\n <DrawerPrimitive.Close\n aria-label={strings.drawer.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DrawerPrimitive.Close>\n )}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n );\n});\nDrawerContent.displayName = 'DrawerContent';\n\nexport function DrawerHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('grid gap-1 p-4 text-center sm:text-left', className)} {...props} />;\n}\nDrawerHeader.displayName = 'DrawerHeader';\n\nexport function DrawerFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\nDrawerFooter.displayName = 'DrawerFooter';\n\nexport const DrawerTitle = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>\n>(function DrawerTitle({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold', className)}\n {...props}\n />\n );\n});\nDrawerTitle.displayName = 'DrawerTitle';\n\nexport const DrawerDescription = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>\n>(function DrawerDescription({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDrawerDescription.displayName = 'DrawerDescription';\n"],"names":["DrawerDirectionContext","createContext","Drawer","shouldScaleBackground","direction","props","jsx","DrawerPrimitive","DrawerTrigger","DrawerPortal","DrawerClose","DrawerOverlay","forwardRef","className","ref","cn","directionStyles","handleStyles","DrawerContent","directionProp","hideHandle","showClose","returnFocusTo","onCloseAutoFocus","children","rootDirection","useContext","strings","useStrings","isHorizontal","jsxs","withReturnFocus","X","DrawerHeader","DrawerFooter","DrawerTitle","DrawerDescription"],"mappings":";;;;;;;;AAoBA,MAAMA,IAAyBC,EAAyB,QAAQ,GAEnDC,IAAS,CAAC;AAAA,EACrB,uBAAAC,IAAwB;AAAA,EACxB,WAAAC,IAAY;AAAA,EACZ,GAAGC;AACL,MACE,gBAAAC,EAACN,EAAuB,UAAvB,EAAgC,OAAOI,GACtC,UAAA,gBAAAE;AAAA,EAACC,EAAgB;AAAA,EAAhB;AAAA,IACC,uBAAAJ;AAAA,IACA,WAAAC;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,EAAA,CACF;AAEFH,EAAO,cAAc;AAEd,MAAMM,IAAgBD,EAAgB,SAChCE,IAAeF,EAAgB,QAC/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAG3B,SAAuB,EAAE,WAAAC,GAAW,GAAGR,EAAA,GAASS,GAAK;AACrD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,aAAU;AAAA,MACV,KAAAO;AAAA,MACA,WAAWC,EAAG,iDAAiDF,CAAS;AAAA,MACvE,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDM,EAAc,cAAc;AAG5B,MAAMK,IAA6C;AAAA,EACjD,QACE;AAAA,EACF,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OACE;AACJ,GAEMC,IAA0C;AAAA,EAC9C,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AACT,GAyBaC,IAAgBN,EAG3B,SACA;AAAA,EACE,WAAAC;AAAA,EAC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S,GAAI,GAAGR,GAAO;AAC9F;AACA4B,EAAa,cAAc;AAEpB,SAASC,EAAa,EAAE,WAAArB,GAAW,GAAGR,KAAyC;AACpF,SAAO,gBAAAC,EAAC,SAAI,WAAWS,EAAG,mCAAmCF,CAAS,GAAI,GAAGR,GAAO;AACtF;AACA6B,EAAa,cAAc;AAEpB,MAAMC,IAAcvB,EAGzB,SAAqB,EAAE,WAAAC,GAAW,GAAGR,EAAA,GAASS,GAAK;AACnD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAO;AAAA,MACA,WAAWC,EAAG,yBAAyBF,CAAS;AAAA,MAC/C,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD8B,EAAY,cAAc;AAEnB,MAAMC,IAAoBxB,EAG/B,SAA2B,EAAE,WAAAC,GAAW,GAAGR,EAAA,GAASS,GAAK;AACzD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAO;AAAA,MACA,WAAWC,EAAG,iCAAiCF,CAAS;AAAA,MACvD,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD+B,EAAkB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Drawer.js","sources":["../../../src/components/ui/Drawer.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n forwardRef,\n useContext,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport { Drawer as DrawerPrimitive } from 'vaul';\nimport { X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { withReturnFocus, type ReturnFocusRef } from '@/lib/return-focus';\n\ntype Direction = 'top' | 'right' | 'bottom' | 'left';\n\n// vaul needs `direction` on Root for its drag physics; DrawerContent reads it\n// back from here so the side only has to be declared once.\nconst DrawerDirectionContext = createContext<Direction>('bottom');\n\nexport const Drawer = ({\n shouldScaleBackground = true,\n direction = 'bottom',\n ...props\n}: ComponentPropsWithoutRef<typeof DrawerPrimitive.Root>) => (\n <DrawerDirectionContext.Provider value={direction}>\n <DrawerPrimitive.Root\n shouldScaleBackground={shouldScaleBackground}\n direction={direction}\n {...props}\n />\n </DrawerDirectionContext.Provider>\n);\nDrawer.displayName = 'Drawer';\n\nexport const DrawerTrigger = DrawerPrimitive.Trigger;\nexport const DrawerPortal = DrawerPrimitive.Portal;\nexport const DrawerClose = DrawerPrimitive.Close;\n\nexport const DrawerOverlay = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Overlay>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Overlay>\n>(function DrawerOverlay({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Overlay\n data-slot=\"drawer-overlay\"\n ref={ref}\n className={cn('bg-overlay fixed inset-0 z-[var(--z-overlay)]', className)}\n {...props}\n />\n );\n});\nDrawerOverlay.displayName = 'DrawerOverlay';\n\n// Edge-anchored sides pad by the matching safe-area inset (consumers set viewport-fit=cover).\nconst directionStyles: Record<Direction, string> = {\n bottom:\n 'inset-x-0 bottom-0 mt-24 flex h-auto max-h-[90dvh] flex-col rounded-t-xl border-t border-border pb-[env(safe-area-inset-bottom)]',\n top: 'inset-x-0 top-0 mb-24 flex h-auto max-h-[90dvh] flex-col rounded-b-xl border-b border-border',\n left: 'inset-y-0 left-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-r-xl border-r border-border pl-[env(safe-area-inset-left)]',\n right:\n 'inset-y-0 right-0 flex h-full w-full max-w-[min(26.25rem,90vw)] flex-col rounded-l-xl border-l border-border pr-[env(safe-area-inset-right)]',\n};\n\nconst handleStyles: Record<Direction, string> = {\n bottom: 'mx-auto mt-3 h-1.5 w-12 rounded-full bg-border',\n top: 'mx-auto mb-3 h-1.5 w-12 rounded-full bg-border order-last',\n left: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border order-last self-stretch shrink-0',\n right: 'mx-1.5 my-auto h-12 w-1.5 rounded-full bg-border shrink-0 self-stretch',\n};\n\nexport interface DrawerContentProps extends ComponentPropsWithoutRef<\n typeof DrawerPrimitive.Content\n> {\n /**\n * Side the drawer slides in from. Prefer setting `direction` on `<Drawer>`\n * (vaul needs it there for drag physics); this prop only overrides the\n * visual placement.\n */\n direction?: Direction;\n /** Hide the drag handle. */\n hideHandle?: boolean;\n /** Show the close (×) button. Default `true`. */\n showClose?: boolean;\n /**\n * Element to focus when the overlay closes. Overrides Radix's default\n * (the element focused when the content mounted), which is `<body>` for\n * controlled overlays opened from a pointer click on a non-focusable /\n * tooltip-wrapped trigger. A consumer `onCloseAutoFocus` runs first and\n * wins if it calls `preventDefault()`.\n */\n returnFocusTo?: ReturnFocusRef;\n}\n\nexport const DrawerContent = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Content>,\n DrawerContentProps\n>(function DrawerContent(\n {\n className,\n direction: directionProp,\n hideHandle,\n showClose = true,\n returnFocusTo,\n onCloseAutoFocus,\n children,\n ...props\n },\n ref,\n) {\n const rootDirection = useContext(DrawerDirectionContext);\n const direction = directionProp ?? rootDirection;\n const strings = useStrings();\n const isHorizontal = direction === 'left' || direction === 'right';\n return (\n <DrawerPortal>\n <DrawerOverlay />\n <DrawerPrimitive.Content\n data-slot=\"drawer-content\"\n ref={ref}\n onCloseAutoFocus={withReturnFocus(returnFocusTo, onCloseAutoFocus)}\n className={cn(\n 'bg-card fixed z-[var(--z-modal)]',\n directionStyles[direction],\n isHorizontal && 'flex-row',\n className,\n )}\n {...props}\n >\n {!hideHandle && <div aria-hidden className={handleStyles[direction]} />}\n <div className={cn('min-h-0 min-w-0 flex-1', isHorizontal && 'flex flex-col')}>\n {children}\n </div>\n {showClose && (\n <DrawerPrimitive.Close\n aria-label={strings.drawer.close}\n className={cn(\n 'text-foreground-subtle absolute top-4 right-4 inline-flex size-8 items-center justify-center rounded-md',\n 'hover:bg-background-muted hover:text-foreground',\n 'focus-visible:ring-ring focus-visible:ring-offset-card outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2',\n 'transition-colors duration-[var(--duration-fast)]',\n )}\n >\n <X className=\"size-4\" aria-hidden />\n </DrawerPrimitive.Close>\n )}\n </DrawerPrimitive.Content>\n </DrawerPortal>\n );\n});\nDrawerContent.displayName = 'DrawerContent';\n\nexport function DrawerHeader({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('grid gap-1 p-4 text-center sm:text-left', className)} {...props} />;\n}\nDrawerHeader.displayName = 'DrawerHeader';\n\nexport function DrawerFooter({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-2 p-4', className)} {...props} />;\n}\nDrawerFooter.displayName = 'DrawerFooter';\n\nexport const DrawerTitle = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Title>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Title>\n>(function DrawerTitle({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Title\n ref={ref}\n className={cn('text-lg font-semibold', className)}\n {...props}\n />\n );\n});\nDrawerTitle.displayName = 'DrawerTitle';\n\nexport const DrawerDescription = forwardRef<\n ComponentRef<typeof DrawerPrimitive.Description>,\n ComponentPropsWithoutRef<typeof DrawerPrimitive.Description>\n>(function DrawerDescription({ className, ...props }, ref) {\n return (\n <DrawerPrimitive.Description\n ref={ref}\n className={cn('text-foreground-muted text-sm', className)}\n {...props}\n />\n );\n});\nDrawerDescription.displayName = 'DrawerDescription';\n"],"names":["DrawerDirectionContext","createContext","Drawer","shouldScaleBackground","direction","props","jsx","DrawerPrimitive","DrawerTrigger","DrawerPortal","DrawerClose","DrawerOverlay","forwardRef","className","ref","cn","directionStyles","handleStyles","DrawerContent","directionProp","hideHandle","showClose","returnFocusTo","onCloseAutoFocus","children","rootDirection","useContext","strings","useStrings","isHorizontal","jsxs","withReturnFocus","X","DrawerHeader","DrawerFooter","DrawerTitle","DrawerDescription"],"mappings":";;;;;;;;AAoBA,MAAMA,IAAyBC,EAAyB,QAAQ,GAEnDC,I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KAAAO;AAAA,MACA,WAAWC,EAAG,yBAAyBF,CAAS;AAAA,MAC/C,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD8B,EAAY,cAAc;AAEnB,MAAMC,IAAoBxB,EAG/B,SAA2B,EAAE,WAAAC,GAAW,GAAGR,EAAA,GAASS,GAAK;AACzD,SACE,gBAAAR;AAAA,IAACC,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAO;AAAA,MACA,WAAWC,EAAG,iCAAiCF,CAAS;AAAA,MACvD,GAAGR;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACD+B,EAAkB,cAAc;"}
|
|
@@ -5,7 +5,7 @@ import * as o from "@radix-ui/react-dropdown-menu";
|
|
|
5
5
|
import { Check as c, Circle as m, ChevronRight as g } from "../../icons/index.js";
|
|
6
6
|
import { cn as d } from "../../lib/utils.js";
|
|
7
7
|
const k = o.Root, R = o.Trigger, T = o.Group, f = o.Portal, j = o.Sub, G = o.RadioGroup, p = d(
|
|
8
|
-
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-
|
|
8
|
+
"relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-hidden",
|
|
9
9
|
"data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground",
|
|
10
10
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
11
11
|
"transition-colors duration-[var(--duration-fast)]",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.js","sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-none',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"names":["DropdownMenu","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuGroup","DropdownMenuPortal","DropdownMenuSub","DropdownMenuRadioGroup","itemClasses","cn","DropdownMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","DropdownMenuSubContent","DropdownMenuContent","sideOffset","align","DropdownMenuItem","destructive","DropdownMenuCheckboxItem","checked","Check","DropdownMenuRadioItem","Circle","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuShortcut"],"mappings":";;;;;;AAiBO,MAAMA,IAAeC,EAAsB,MACrCC,IAAsBD,EAAsB,SAC5CE,IAAoBF,EAAsB,OAC1CG,IAAqBH,EAAsB,QAC3CI,IAAkBJ,EAAsB,KACxCK,IAAyBL,EAAsB,YAEtDM,IAAcC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF,GAEaC,IAAyBC,EAKpC,SAAgC,EAAE,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGC,EAAA,GAASC,GAAK;AAC/E,SACE,gBAAAC;AAAA,IAACf,EAAsB;AAAA,IAAtB;AAAA,MACC,aAAU;AAAA,MACV,KAAAc;AAAA,MACA,WAAWP;AAAA,QACTD;AAAA,QACA;AAAA,QACAK,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,MAEH,UAAA;AAAA,QAAAD;AAAA,QACD,gBAAAI,EAACC,GAAA,EAAa,WAAU,yCAAwC,eAAW,GAAA,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlF,CAAC;AACDT,EAAuB,cAAc;AAE9B,MAAMU,IAAyBT,EAGpC,SAAgC,EAAE,WAAAC,GAAW,GAAGG,EAAA,GAASC,GAAK;AAC9D,SACE,gBAAAE;AAAA,IAAChB,EAAsB;AAAA,IAAtB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACAG;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDK,EAAuB,cAAc;AAE9B,MAAMC,IAAsBV,EAMjC,SAA6B,EAAE,WAAAC,GAAW,YAAAU,IAAa,GAAG,OAAAC,IA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GG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAkB,EAAqB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"DropdownMenu.js","sources":["../../../src/components/ui/DropdownMenu.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type HTMLAttributes,\n} from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Check, ChevronRight, Circle } from '@/icons';\nimport { cn } from '@/lib/utils';\n\n/* -----------------------------------------------------------------------------\n * Full dropdown menu surface with submenu support, separators, checkbox /\n * radio items, and keyboard shortcut labels (Kbd).\n * --------------------------------------------------------------------------- */\n\nexport const DropdownMenu = DropdownMenuPrimitive.Root;\nexport const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;\nexport const DropdownMenuGroup = DropdownMenuPrimitive.Group;\nexport const DropdownMenuPortal = DropdownMenuPrimitive.Portal;\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\nexport const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;\n\nconst itemClasses = cn(\n 'relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-foreground outline-hidden',\n 'data-[highlighted]:bg-background-muted data-[highlighted]:text-foreground',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n 'transition-colors duration-[var(--duration-fast)]',\n // Leading icons in items default to 16px like Button/Sidebar/Command do —\n // a bare lucide icon is 24px and every consumer was sizing it by hand.\n '[&_svg]:size-4 [&_svg]:shrink-0',\n);\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubTrigger>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n }\n>(function DropdownMenuSubTrigger({ className, inset, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n ref={ref}\n className={cn(\n itemClasses,\n 'data-[state=open]:bg-background-muted',\n inset && 'pl-8',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRight className=\"text-foreground-subtle ml-auto size-4\" aria-hidden />\n </DropdownMenuPrimitive.SubTrigger>\n );\n});\nDropdownMenuSubTrigger.displayName = 'DropdownMenuSubTrigger';\n\nexport const DropdownMenuSubContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.SubContent>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>\n>(function DropdownMenuSubContent({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.SubContent\n ref={ref}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[8rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuSubContent.displayName = 'DropdownMenuSubContent';\n\nexport const DropdownMenuContent = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Content>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>\n // `align` defaults to 'end' (Radix default is 'center'): triggers are\n // usually right-aligned icon buttons in toolbars/table rows. Pass\n // `align=\"start\"` for left-anchored triggers.\n>(function DropdownMenuContent({ className, sideOffset = 4, align = 'end', ...props }, ref) {\n return (\n <DropdownMenuPortal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n ref={ref}\n sideOffset={sideOffset}\n align={align}\n className={cn(\n 'border-border bg-popover text-popover-foreground z-[var(--z-popover)] min-w-[12rem] overflow-hidden rounded-lg border p-1 shadow-md',\n 'data-[state=open]:animate-in data-[state=closed]:animate-out',\n 'data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',\n 'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n 'data-[side=bottom]:slide-in-from-top-1 data-[side=top]:slide-in-from-bottom-1',\n className,\n )}\n {...props}\n />\n </DropdownMenuPortal>\n );\n});\nDropdownMenuContent.displayName = 'DropdownMenuContent';\n\nexport const DropdownMenuItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Item>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n destructive?: boolean;\n }\n>(function DropdownMenuItem({ className, inset, destructive, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Item\n ref={ref}\n className={cn(\n itemClasses,\n inset && 'pl-8',\n destructive &&\n 'text-danger-text data-[highlighted]:bg-danger-soft data-[highlighted]:text-danger-text',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuItem.displayName = 'DropdownMenuItem';\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.CheckboxItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>\n>(function DropdownMenuCheckboxItem({ className, children, checked, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n ref={ref}\n checked={checked}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Check className=\"text-accent size-4\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n});\nDropdownMenuCheckboxItem.displayName = 'DropdownMenuCheckboxItem';\n\nexport const DropdownMenuRadioItem = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.RadioItem>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>\n>(function DropdownMenuRadioItem({ className, children, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.RadioItem\n ref={ref}\n className={cn(itemClasses, 'pl-8', className)}\n {...props}\n >\n <span className=\"absolute left-2 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <Circle className=\"fill-accent text-accent size-2\" aria-hidden />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n});\nDropdownMenuRadioItem.displayName = 'DropdownMenuRadioItem';\n\nexport const DropdownMenuLabel = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Label>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n }\n>(function DropdownMenuLabel({ className, inset, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Label\n ref={ref}\n className={cn(\n 'text-foreground-subtle px-2 py-1.5 text-xs font-medium',\n inset && 'pl-8',\n className,\n )}\n {...props}\n />\n );\n});\nDropdownMenuLabel.displayName = 'DropdownMenuLabel';\n\nexport const DropdownMenuSeparator = forwardRef<\n ComponentRef<typeof DropdownMenuPrimitive.Separator>,\n ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>\n>(function DropdownMenuSeparator({ className, ...props }, ref) {\n return (\n <DropdownMenuPrimitive.Separator\n ref={ref}\n className={cn('bg-border -mx-1 my-1 h-px', className)}\n {...props}\n />\n );\n});\nDropdownMenuSeparator.displayName = 'DropdownMenuSeparator';\n\n/**\n * Trailing right-aligned shortcut label inside a menu item. Pair with `<Kbd>`\n * inside the Kbd component file if you want stylised keys.\n */\nexport function DropdownMenuShortcut({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {\n return (\n <span\n className={cn('text-foreground-subtle ml-auto font-mono text-xs tracking-widest', className)}\n {...props}\n />\n );\n}\nDropdownMenuShortcut.displayName = 'DropdownMenuShortcut';\n\n/**\n * @example\n * <DropdownMenu>\n * <DropdownMenuTrigger asChild><IconButton aria-label=\"More\" icon={<MoreHorizontal />} /></DropdownMenuTrigger>\n * <DropdownMenuContent>\n * <DropdownMenuItem>Open<DropdownMenuShortcut>⌘O</DropdownMenuShortcut></DropdownMenuItem>\n * <DropdownMenuItem>Rename</DropdownMenuItem>\n * <DropdownMenuSeparator />\n * <DropdownMenuItem destructive>Delete</DropdownMenuItem>\n * </DropdownMenuContent>\n * </DropdownMenu>\n *\n * @do Group destructive items at the bottom with a separator.\n * @dont Mix link navigation and action items in the same menu — split into\n * two menus or two groups with labels.\n */\n"],"names":["DropdownMenu","DropdownMenuPrimitive","DropdownMenuTrigger","DropdownMenuGroup","DropdownMenuPortal","DropdownMenuSub","DropdownMenuRadioGroup","itemClasses","cn","DropdownMenuSubTrigger","forwardRef","className","inset","children","props","ref","jsxs","jsx","ChevronRight","DropdownMenuSubContent","DropdownMenuContent","sideOffset","align","DropdownMenuItem","destructive","DropdownMenuCheckboxItem","checked","Check","DropdownMenuRadioItem","Circle","DropdownMenuLabel","DropdownMenuSeparator","DropdownMenuShortcut"],"mappings":";;;;;;AAiBO,MAAMA,IAAeC,EAAsB,MACrCC,IAAsBD,EAAsB,SAC5CE,IAAoBF,EAAsB,OAC1CG,IAAqBH,EAAsB,QAC3CI,IAAkBJ,EAAsB,KACxCK,IAAyBL,EAAsB,YAEtDM,IAAcC;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AACF,GAEaC,IAAyBC,EAKpC,SAAgC,EAAE,WAAAC,GAAW,OAAAC,GAAO,UAAAC,GAAU,GAAGC,EAAA,GAASC,GAAK;AAC/E,SACE,gBAAAC;AAAA,IAACf,EAAsB;AAAA,IAAtB;AAAA,MACC,aAAU;AAAA,MACV,KAAAc;AAAA,MACA,WAAWP;AAAA,QACTD;AAAA,QACA;AAAA,QACAK,KAAS;AAAA,QACTD;AAAA,MAAA;AAAA,MAED,GAAGG;AAAA,MAEH,UAAA;AAAA,QAAAD;AAAA,QACD,gBAAAI,EAACC,GAAA,EAAa,WAAU,yCAAwC,eAAW,GAAA,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGlF,CAAC;AACDT,EAAuB,cAAc;AAE9B,MAAMU,IAAyBT,EAGpC,SAAg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G,EAAA,GAASC,GAAK;AAC7D,SACE,gBAAAE;AAAA,IAAChB,EAAsB;AAAA,IAAtB;AAAA,MACC,KAAAc;AAAA,MACA,WAAWP,EAAG,6BAA6BG,CAAS;AAAA,MACnD,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV,CAAC;AACDiB,EAAsB,cAAc;AAM7B,SAASC,EAAqB,EAAE,WAAArB,GAAW,GAAGG,KAA0C;AAC7F,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWT,EAAG,oEAAoEG,CAAS;AAAA,MAC1F,GAAGG;AAAA,IAAA;AAAA,EAAA;AAGV;AACAkB,EAAqB,cAAc;"}
|
|
@@ -94,7 +94,7 @@ const H = T(function({ accept: t, multiple: a, maxSize: d, value: l, onChange: r
|
|
|
94
94
|
{
|
|
95
95
|
type: "button",
|
|
96
96
|
onClick: () => O(o),
|
|
97
|
-
className: "text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-
|
|
97
|
+
className: "text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
98
98
|
"aria-label": h(b.fileUpload.remove, { name: e.name }),
|
|
99
99
|
children: /* @__PURE__ */ s(X, { className: "size-4", "aria-hidden": !0 })
|
|
100
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.js","sources":["../../../src/components/ui/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type DragEvent as ReactDragEvent,\n type ReactNode,\n} from 'react';\nimport { File as FileIcon, Upload, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\n\nexport type FileRejectReason = 'size' | 'type';\n\nexport interface FileUploadProps {\n /** Accepted file types, e.g. `image/*` or `.pdf,.docx`. */\n accept?: string;\n /** Allow multiple files. */\n multiple?: boolean;\n /** Max file size in bytes. Files larger than this are rejected. */\n maxSize?: number;\n /** Controlled file list. */\n value?: File[];\n /** Called when files are added or removed. */\n onChange?: (files: File[]) => void;\n /** Called with the files that were dropped because of `maxSize` or `accept`. */\n onReject?: (files: File[], reason: FileRejectReason) => void;\n /** Helper text inside the drop zone. */\n hint?: ReactNode;\n /** Disable the picker entirely. */\n disabled?: boolean;\n className?: string;\n}\n\nfunction formatSize(bytes: number, s: UiStrings['fileUpload']) {\n if (bytes < 1024) return formatString(s.bytes, { n: bytes });\n if (bytes < 1024 * 1024) return formatString(s.kilobytes, { n: (bytes / 1024).toFixed(1) });\n return formatString(s.megabytes, { n: (bytes / 1024 / 1024).toFixed(1) });\n}\n\n/** Mirror the browser's `accept` matching for dropped files (which skip the picker filter). */\nfunction matchesAccept(file: File, accept?: string): boolean {\n if (!accept) return true;\n const rules = accept\n .split(',')\n .map((r) => r.trim().toLowerCase())\n .filter(Boolean);\n if (!rules.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return rules.some((rule) => {\n if (rule.startsWith('.')) return name.endsWith(rule);\n if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n\n/**\n * Drag-and-drop file picker with an inline file list. Uncontrolled by default;\n * pass `value` + `onChange` to control externally.\n */\nexport const FileUpload = forwardRef<HTMLDivElement, FileUploadProps>(function FileUpload(\n { accept, multiple, maxSize, value, onChange, onReject, hint, disabled, className },\n ref,\n) {\n const strings = useStrings();\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const [internal, setInternal] = useState<File[]>([]);\n const [over, setOver] = useState(false);\n // dragenter/dragleave fire for every child element; count nesting depth so\n // the highlight does not flicker while the pointer crosses the label's children.\n const dragDepth = useRef(0);\n const files = value ?? internal;\n\n const update = useCallback(\n (next: File[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const addFiles = useCallback(\n (incoming: FileList | File[]) => {\n const accepted: File[] = [];\n const tooLarge: File[] = [];\n const wrongType: File[] = [];\n for (const f of Array.from(incoming)) {\n if (!matchesAccept(f, accept)) wrongType.push(f);\n else if (maxSize && f.size > maxSize) tooLarge.push(f);\n else accepted.push(f);\n }\n if (wrongType.length) onReject?.(wrongType, 'type');\n if (tooLarge.length) onReject?.(tooLarge, 'size');\n if (!accepted.length) return;\n update(multiple ? [...files, ...accepted] : accepted.slice(0, 1));\n },\n [accept, files, maxSize, multiple, onReject, update],\n );\n\n const remove = (idx: number) => update(files.filter((_, i) => i !== idx));\n\n const onDrop = (e: ReactDragEvent<HTMLLabelElement>) => {\n e.preventDefault();\n dragDepth.current = 0;\n setOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-3', className)}>\n <label\n data-slot=\"file-upload\"\n htmlFor={inputId}\n onDragEnter={() => {\n dragDepth.current += 1;\n if (!disabled) setOver(true);\n }}\n onDragOver={(e) => e.preventDefault()}\n onDragLeave={() => {\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) setOver(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'group relative flex cursor-pointer flex-col items-center justify-center gap-2',\n 'border-border-input bg-background-subtle rounded-md border border-dashed px-6 py-8',\n 'text-center transition-colors',\n 'hover:border-border-strong hover:bg-background-muted',\n 'focus-within:ring-ring focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n over && 'border-accent bg-accent-soft',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n <Upload className=\"text-foreground-muted size-5\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">{strings.fileUpload.drop}</p>\n {hint && <p className=\"text-foreground-muted text-xs\">{hint}</p>}\n </div>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n className=\"sr-only\"\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n // Allow re-selecting the same file after removing it.\n e.target.value = '';\n }}\n />\n </label>\n\n {files.length > 0 && (\n <ul className=\"flex flex-col gap-2\">\n {files.map((file, idx) => (\n <li\n key={`${file.name}-${file.size}-${file.lastModified}-${idx}`}\n className=\"border-border bg-card flex items-center gap-3 rounded-md border px-3 py-2\"\n >\n <FileIcon className=\"text-foreground-muted size-4 shrink-0\" aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm\" title={file.name}>\n {file.name}\n </p>\n <p className=\"text-foreground-muted text-xs\">\n {formatSize(file.size, strings.fileUpload)}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => remove(idx)}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n aria-label={formatString(strings.fileUpload.remove, { name: file.name })}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n});\nFileUpload.displayName = 'FileUpload';\n"],"names":["formatSize","bytes","s","formatString","matchesAccept","file","accept","rules","name","type","rule","FileUpload","forwardRef","multiple","maxSize","value","onChange","onReject","hint","disabled","className","ref","strings","useStrings","inputRef","useRef","inputId","useId","internal","setInternal","useState","over","setOver","dragDepth","files","update","useCallback","next","addFiles","incoming","accepted","tooLarge","wrongType","f","remove","idx","_","i","onDrop","cn","jsxs","jsx","Upload","FileIcon"],"mappings":";;;;;;;AAsCA,SAASA,EAAWC,GAAeC,GAA4B;AAC7D,SAAID,IAAQ,OAAaE,EAAaD,EAAE,OAAO,EAAED,GAAU,IACvDA,IAAQ,OAAO,OAAaE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,MAAM,QAAQ,CAAC,GAAG,IACnFE,EAAaD,EAAE,WAAW,EAAE,IAAID,IA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;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAMP,EAAOC,CAAG;AAAA,cACzB,WAAU;AAAA,cACV,cAAY1C,EAAamB,EAAQ,WAAW,QAAQ,EAAE,MAAMjB,EAAK,MAAM;AAAA,cAEvE,UAAA,gBAAA8C,EAAC,GAAA,EAAE,WAAU,UAAS,eAAW,GAAA,CAAC;AAAA,YAAA;AAAA,UAAA;AAAA,QACpC;AAAA,MAAA;AAAA,MAnBK,GAAG9C,EAAK,IAAI,IAAIA,EAAK,IAAI,IAAIA,EAAK,YAAY,IAAIwC,CAAG;AAAA,IAAA,CAqB7D,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ,CAAC;AACDlC,EAAW,cAAc;"}
|
|
1
|
+
{"version":3,"file":"FileUpload.js","sources":["../../../src/components/ui/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type DragEvent as ReactDragEvent,\n type ReactNode,\n} from 'react';\nimport { File as FileIcon, Upload, X } from '@/icons';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\nimport { formatString, type UiStrings } from '@/lib/strings';\n\nexport type FileRejectReason = 'size' | 'type';\n\nexport interface FileUploadProps {\n /** Accepted file types, e.g. `image/*` or `.pdf,.docx`. */\n accept?: string;\n /** Allow multiple files. */\n multiple?: boolean;\n /** Max file size in bytes. Files larger than this are rejected. */\n maxSize?: number;\n /** Controlled file list. */\n value?: File[];\n /** Called when files are added or removed. */\n onChange?: (files: File[]) => void;\n /** Called with the files that were dropped because of `maxSize` or `accept`. */\n onReject?: (files: File[], reason: FileRejectReason) => void;\n /** Helper text inside the drop zone. */\n hint?: ReactNode;\n /** Disable the picker entirely. */\n disabled?: boolean;\n className?: string;\n}\n\nfunction formatSize(bytes: number, s: UiStrings['fileUpload']) {\n if (bytes < 1024) return formatString(s.bytes, { n: bytes });\n if (bytes < 1024 * 1024) return formatString(s.kilobytes, { n: (bytes / 1024).toFixed(1) });\n return formatString(s.megabytes, { n: (bytes / 1024 / 1024).toFixed(1) });\n}\n\n/** Mirror the browser's `accept` matching for dropped files (which skip the picker filter). */\nfunction matchesAccept(file: File, accept?: string): boolean {\n if (!accept) return true;\n const rules = accept\n .split(',')\n .map((r) => r.trim().toLowerCase())\n .filter(Boolean);\n if (!rules.length) return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return rules.some((rule) => {\n if (rule.startsWith('.')) return name.endsWith(rule);\n if (rule.endsWith('/*')) return type.startsWith(rule.slice(0, -1));\n return type === rule;\n });\n}\n\n/**\n * Drag-and-drop file picker with an inline file list. Uncontrolled by default;\n * pass `value` + `onChange` to control externally.\n */\nexport const FileUpload = forwardRef<HTMLDivElement, FileUploadProps>(function FileUpload(\n { accept, multiple, maxSize, value, onChange, onReject, hint, disabled, className },\n ref,\n) {\n const strings = useStrings();\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n const [internal, setInternal] = useState<File[]>([]);\n const [over, setOver] = useState(false);\n // dragenter/dragleave fire for every child element; count nesting depth so\n // the highlight does not flicker while the pointer crosses the label's children.\n const dragDepth = useRef(0);\n const files = value ?? internal;\n\n const update = useCallback(\n (next: File[]) => {\n if (value === undefined) setInternal(next);\n onChange?.(next);\n },\n [onChange, value],\n );\n\n const addFiles = useCallback(\n (incoming: FileList | File[]) => {\n const accepted: File[] = [];\n const tooLarge: File[] = [];\n const wrongType: File[] = [];\n for (const f of Array.from(incoming)) {\n if (!matchesAccept(f, accept)) wrongType.push(f);\n else if (maxSize && f.size > maxSize) tooLarge.push(f);\n else accepted.push(f);\n }\n if (wrongType.length) onReject?.(wrongType, 'type');\n if (tooLarge.length) onReject?.(tooLarge, 'size');\n if (!accepted.length) return;\n update(multiple ? [...files, ...accepted] : accepted.slice(0, 1));\n },\n [accept, files, maxSize, multiple, onReject, update],\n );\n\n const remove = (idx: number) => update(files.filter((_, i) => i !== idx));\n\n const onDrop = (e: ReactDragEvent<HTMLLabelElement>) => {\n e.preventDefault();\n dragDepth.current = 0;\n setOver(false);\n if (disabled) return;\n addFiles(e.dataTransfer.files);\n };\n\n return (\n <div ref={ref} className={cn('flex flex-col gap-3', className)}>\n <label\n data-slot=\"file-upload\"\n htmlFor={inputId}\n onDragEnter={() => {\n dragDepth.current += 1;\n if (!disabled) setOver(true);\n }}\n onDragOver={(e) => e.preventDefault()}\n onDragLeave={() => {\n dragDepth.current = Math.max(0, dragDepth.current - 1);\n if (dragDepth.current === 0) setOver(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'group relative flex cursor-pointer flex-col items-center justify-center gap-2',\n 'border-border-input bg-background-subtle rounded-md border border-dashed px-6 py-8',\n 'text-center transition-colors',\n 'hover:border-border-strong hover:bg-background-muted',\n 'focus-within:ring-ring focus-within:ring-offset-background focus-within:ring-2 focus-within:ring-offset-2',\n over && 'border-accent bg-accent-soft',\n disabled && 'pointer-events-none opacity-50',\n )}\n >\n <Upload className=\"text-foreground-muted size-5\" aria-hidden />\n <div className=\"space-y-1\">\n <p className=\"text-sm font-medium\">{strings.fileUpload.drop}</p>\n {hint && <p className=\"text-foreground-muted text-xs\">{hint}</p>}\n </div>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n className=\"sr-only\"\n onChange={(e) => {\n if (e.target.files) addFiles(e.target.files);\n // Allow re-selecting the same file after removing it.\n e.target.value = '';\n }}\n />\n </label>\n\n {files.length > 0 && (\n <ul className=\"flex flex-col gap-2\">\n {files.map((file, idx) => (\n <li\n key={`${file.name}-${file.size}-${file.lastModified}-${idx}`}\n className=\"border-border bg-card flex items-center gap-3 rounded-md border px-3 py-2\"\n >\n <FileIcon className=\"text-foreground-muted size-4 shrink-0\" aria-hidden />\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm\" title={file.name}>\n {file.name}\n </p>\n <p className=\"text-foreground-muted text-xs\">\n {formatSize(file.size, strings.fileUpload)}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => remove(idx)}\n className=\"text-foreground-muted hover:bg-background-muted hover:text-foreground focus-visible:ring-ring focus-visible:ring-offset-background rounded-sm p-1 outline-hidden focus-visible:ring-2 focus-visible:ring-offset-2\"\n aria-label={formatString(strings.fileUpload.remove, { name: file.name })}\n >\n <X className=\"size-4\" aria-hidden />\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n});\nFileUpload.displayName = 'FileUpload';\n"],"names":["formatSize","bytes","s","formatString","matchesAccept","file","accept","rules","name","type","rule","FileUpload","forwardRef","multiple","maxSize","value","onChange","onReject","hint","disabled","className","ref","strings","useStrings","inputRef","useRef","inputId","useId","internal","setInternal","useState","over","setOver","dragDepth","files","update","useCallback","next","addFiles","incoming","accepted","tooLarge","wrongType","f","remove","idx","_","i","onDrop","cn","jsxs","jsx","Upload","FileIcon"],"mappings":";;;;;;;AAsCA,SAASA,EAAWC,GAAeC,GAA4B;AAC7D,SAAID,IAAQ,OAAaE,EAAaD,EAAE,OAAO,EAAED,GAAU,IACvDA,IAAQ,OAAO,OAAaE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,MAAM,QAAQ,CAAC,GAAG,IACnFE,EAAaD,EAAE,WAAW,EAAE,IAAID,IAAQ,OAAO,MAAM,QAAQ,CAAC,EAAA,CAAG;AAC1E;AAGA,SAASG,EAAcC,GAAYC,GAA0B;AAC3D,MAAI,CAACA,EAAQ,QAAO;AACpB,QAAMC,IAAQD,EACX,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,OAAO,YAAA,CAAa,EACjC,OAAO,OAAO;AACjB,MAAI,CAACC,EAAM,OAAQ,QAAO;AAC1B,QAAMC,IAAOH,EAAK,KAAK,YAAA,GACjBI,IAAOJ,EAAK,KAAK,YAAA;AACvB,SAAOE,EAAM,KAAK,CAACG,MACbA,EAAK,WAAW,GAAG,IAAUF,EAAK,SAASE,CAAI,IAC/CA,EAAK,SAAS,IAAI,IAAUD,EAAK,WAAWC,EAAK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