@betterinternship/components 3.1.3 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown-menu.js","sources":["../../src/components/dropdown-menu.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction DropdownMenu({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {\n return <DropdownMenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n}\n\nfunction DropdownMenuPortal({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {\n return (\n <DropdownMenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n );\n}\n\nfunction DropdownMenuTrigger({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {\n return (\n <DropdownMenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n sideOffset={sideOffset}\n className={cn(\n // z-[1100] (not the default z-50) — the shared modal system's\n // backdrop is z-[1000] (app/providers/modal-provider.tsx), and\n // this portals to document.body as a sibling of it, so it needs\n // to clear that to render above a modal. Matches the same fix\n // already applied to SelectContent (components/select.tsx).\n 'bg-popover text-popover-foreground data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1100] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border shadow-card',\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {\n return (\n <DropdownMenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n variant?: 'default' | 'destructive';\n}) {\n return (\n <DropdownMenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"focus:bg-muted focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-pointer select-none items-center gap-2 px-4 py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-10 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex w-full cursor-pointer items-center gap-2 py-2 pr-4 pl-10 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-4 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {\n return (\n <DropdownMenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {\n return (\n <DropdownMenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex w-full cursor-pointer items-center gap-2 py-2 pr-4 pl-10 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-4 flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleIcon className=\"size-2 fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.Label\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n 'px-4 py-2 text-sm font-semibold text-foreground data-[inset]:pl-10',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {\n return (\n <DropdownMenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn('bg-border h-px', className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-muted-foreground ml-auto text-xs tracking-widest',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {\n return <DropdownMenuPrimitive.Sub data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n 'focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground flex cursor-pointer items-center gap-2 px-4 py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[inset]:pl-10',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto size-4 text-muted-foreground\" />\n </DropdownMenuPrimitive.SubTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {\n return (\n <DropdownMenuPrimitive.SubContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n // z-[1100] — see the matching note on DropdownMenuContent above.\n 'bg-popover text-popover-foreground data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1100] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-control-lg border border-border shadow-card',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"names":["_jsx","_jsxs"],"mappings":"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"}
1
+ {"version":3,"file":"dropdown-menu.js","sources":["../../src/components/dropdown-menu.tsx"],"sourcesContent":["import * as React from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';\n\nimport { cn } from '@/utils';\n\nfunction DropdownMenu({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {\n return <DropdownMenuPrimitive.Root data-slot=\"dropdown-menu\" {...props} />;\n}\n\nfunction DropdownMenuPortal({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {\n return (\n <DropdownMenuPrimitive.Portal data-slot=\"dropdown-menu-portal\" {...props} />\n );\n}\n\nfunction DropdownMenuTrigger({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {\n return (\n <DropdownMenuPrimitive.Trigger\n data-slot=\"dropdown-menu-trigger\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuContent({\n className,\n sideOffset = 4,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.Content\n data-slot=\"dropdown-menu-content\"\n sideOffset={sideOffset}\n className={cn(\n // z-[1100] (not the default z-50) — the shared modal system's\n // backdrop is z-[1000] (app/providers/modal-provider.tsx), and\n // this portals to document.body as a sibling of it, so it needs\n // to clear that to render above a modal. Matches the same fix\n // already applied to SelectContent (components/select.tsx).\n 'bg-popover text-popover-foreground data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1100] max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n );\n}\n\nfunction DropdownMenuGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {\n return (\n <DropdownMenuPrimitive.Group data-slot=\"dropdown-menu-group\" {...props} />\n );\n}\n\nfunction DropdownMenuItem({\n className,\n inset,\n variant = 'default',\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {\n inset?: boolean;\n variant?: 'default' | 'destructive';\n}) {\n return (\n <DropdownMenuPrimitive.Item\n data-slot=\"dropdown-menu-item\"\n data-inset={inset}\n data-variant={variant}\n className={cn(\n \"focus:bg-muted focus:text-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-9 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuCheckboxItem({\n className,\n children,\n checked,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {\n return (\n <DropdownMenuPrimitive.CheckboxItem\n data-slot=\"dropdown-menu-checkbox-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n checked={checked}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n}\n\nfunction DropdownMenuRadioGroup({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {\n return (\n <DropdownMenuPrimitive.RadioGroup\n data-slot=\"dropdown-menu-radio-group\"\n {...props}\n />\n );\n}\n\nfunction DropdownMenuRadioItem({\n className,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {\n return (\n <DropdownMenuPrimitive.RadioItem\n data-slot=\"dropdown-menu-radio-item\"\n className={cn(\n \"focus:bg-muted focus:text-foreground relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm py-2 pr-option-x pl-9 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n className,\n )}\n {...props}\n >\n <span className=\"pointer-events-none absolute left-option-x flex size-4 items-center justify-center\">\n <DropdownMenuPrimitive.ItemIndicator>\n <CircleIcon className=\"size-2 fill-current\" />\n </DropdownMenuPrimitive.ItemIndicator>\n </span>\n {children}\n </DropdownMenuPrimitive.RadioItem>\n );\n}\n\nfunction DropdownMenuLabel({\n className,\n inset,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.Label\n data-slot=\"dropdown-menu-label\"\n data-inset={inset}\n className={cn(\n 'px-option-x py-2 text-sm font-semibold text-foreground data-[inset]:pl-9',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSeparator({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {\n return (\n <DropdownMenuPrimitive.Separator\n data-slot=\"dropdown-menu-separator\"\n className={cn('bg-border -mx-option-inset my-1 h-px', className)}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuShortcut({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n <span\n data-slot=\"dropdown-menu-shortcut\"\n className={cn(\n 'text-muted-foreground ml-auto text-xs tracking-widest',\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction DropdownMenuSub({\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {\n return <DropdownMenuPrimitive.Sub data-slot=\"dropdown-menu-sub\" {...props} />;\n}\n\nfunction DropdownMenuSubTrigger({\n className,\n inset,\n children,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {\n inset?: boolean;\n}) {\n return (\n <DropdownMenuPrimitive.SubTrigger\n data-slot=\"dropdown-menu-sub-trigger\"\n data-inset={inset}\n className={cn(\n 'focus:bg-muted focus:text-foreground data-[state=open]:bg-muted data-[state=open]:text-foreground flex min-h-option-row cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pointer-coarse:min-h-11 text-sm text-muted-foreground transition-colors duration-state hover:bg-muted motion-reduce:transition-none outline-hidden select-none data-[inset]:pl-9',\n className,\n )}\n {...props}\n >\n {children}\n <ChevronRightIcon className=\"ml-auto size-4 text-muted-foreground\" />\n </DropdownMenuPrimitive.SubTrigger>\n );\n}\n\nfunction DropdownMenuSubContent({\n className,\n ...props\n}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {\n return (\n <DropdownMenuPrimitive.SubContent\n data-slot=\"dropdown-menu-sub-content\"\n className={cn(\n // z-[1100] — see the matching note on DropdownMenuContent above.\n 'bg-popover text-popover-foreground data-[state=open]:animate-in motion-reduce:animate-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-[1100] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-control-lg border border-border p-option-inset shadow-card',\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {\n DropdownMenu,\n DropdownMenuPortal,\n DropdownMenuTrigger,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuLabel,\n DropdownMenuItem,\n DropdownMenuCheckboxItem,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuSeparator,\n DropdownMenuShortcut,\n DropdownMenuSub,\n DropdownMenuSubTrigger,\n DropdownMenuSubContent,\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;AAMA,SAAS,YAAY,CAAC,EACpB,GAAG,KAAK,EACgD,EAAA;IACxD,OAAOA,GAAA,CAAC,qBAAqB,CAAC,IAAI,iBAAW,eAAe,EAAA,GAAK,KAAK,EAAA,CAAI;AAC5E;AAEA,SAAS,kBAAkB,CAAC,EAC1B,GAAG,KAAK,EACkD,EAAA;IAC1D,QACEA,GAAA,CAAC,qBAAqB,CAAC,MAAM,EAAA,EAAA,WAAA,EAAW,sBAAsB,EAAA,GAAK,KAAK,EAAA,CAAI;AAEhF;AAEA,SAAS,mBAAmB,CAAC,EAC3B,GAAG,KAAK,EACmD,EAAA;IAC3D,QACEA,GAAA,CAAC,qBAAqB,CAAC,OAAO,EAAA,EAAA,WAAA,EAClB,uBAAuB,EAAA,GAC7B,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,mBAAmB,CAAC,EAC3B,SAAS,EACT,UAAU,GAAG,CAAC,EACd,GAAG,KAAK,EACmD,EAAA;AAC3D,IAAA,QACEA,GAAA,CAAC,qBAAqB,CAAC,MAAM,EAAA,EAAA,QAAA,EAC3BA,IAAC,qBAAqB,CAAC,OAAO,EAAA,EAAA,WAAA,EAClB,uBAAuB,EACjC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,EAAE;;;;;;YAMX,0nBAA0nB,EAC1nB,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT,EAAA,CAC2B;AAEnC;AAEA,SAAS,iBAAiB,CAAC,EACzB,GAAG,KAAK,EACiD,EAAA;IACzD,QACEA,GAAA,CAAC,qBAAqB,CAAC,KAAK,EAAA,EAAA,WAAA,EAAW,qBAAqB,EAAA,GAAK,KAAK,EAAA,CAAI;AAE9E;AAEA,SAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,KAAK,EACL,OAAO,GAAG,SAAS,EACnB,GAAG,KAAK,EAIT,EAAA;IACC,QACEA,GAAA,CAAC,qBAAqB,CAAC,IAAI,iBACf,oBAAoB,EAAA,YAAA,EAClB,KAAK,EAAA,cAAA,EACH,OAAO,EACrB,SAAS,EAAE,EAAE,CACX,swBAAswB,EACtwB,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,wBAAwB,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,OAAO,EACP,GAAG,KAAK,EACwD,EAAA;IAChE,QACEC,KAAC,qBAAqB,CAAC,YAAY,EAAA,EAAA,WAAA,EACvB,6BAA6B,EACvC,SAAS,EAAE,EAAE,CACX,ucAAuc,EACvc,SAAS,CACV,EACD,OAAO,EAAE,OAAO,EAAA,GACZ,KAAK,EAAA,QAAA,EAAA,CAETD,cAAM,SAAS,EAAC,oFAAoF,EAAA,QAAA,EAClGA,GAAA,CAAC,qBAAqB,CAAC,aAAa,cAClCA,GAAA,CAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,EAAA,CAAG,EAAA,CACI,GACjC,EACN,QAAQ,CAAA,EAAA,CAC0B;AAEzC;AAEA,SAAS,sBAAsB,CAAC,EAC9B,GAAG,KAAK,EACsD,EAAA;IAC9D,QACEA,GAAA,CAAC,qBAAqB,CAAC,UAAU,EAAA,EAAA,WAAA,EACrB,2BAA2B,EAAA,GACjC,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,qBAAqB,CAAC,EAC7B,SAAS,EACT,QAAQ,EACR,GAAG,KAAK,EACqD,EAAA;AAC7D,IAAA,QACEC,IAAA,CAAC,qBAAqB,CAAC,SAAS,EAAA,EAAA,WAAA,EACpB,0BAA0B,EACpC,SAAS,EAAE,EAAE,CACX,ucAAuc,EACvc,SAAS,CACV,EAAA,GACG,KAAK,aAETD,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,oFAAoF,YAClGA,GAAA,CAAC,qBAAqB,CAAC,aAAa,EAAA,EAAA,QAAA,EAClCA,IAAC,UAAU,EAAA,EAAC,SAAS,EAAC,qBAAqB,GAAG,EAAA,CACV,EAAA,CACjC,EACN,QAAQ,CAAA,EAAA,CACuB;AAEtC;AAEA,SAAS,iBAAiB,CAAC,EACzB,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EAGT,EAAA;IACC,QACEA,IAAC,qBAAqB,CAAC,KAAK,EAAA,EAAA,WAAA,EAChB,qBAAqB,EAAA,YAAA,EACnB,KAAK,EACjB,SAAS,EAAE,EAAE,CACX,0EAA0E,EAC1E,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,qBAAqB,CAAC,EAC7B,SAAS,EACT,GAAG,KAAK,EACqD,EAAA;IAC7D,QACEA,IAAC,qBAAqB,CAAC,SAAS,EAAA,EAAA,WAAA,EACpB,yBAAyB,EACnC,SAAS,EAAE,EAAE,CAAC,sCAAsC,EAAE,SAAS,CAAC,KAC5D,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,oBAAoB,CAAC,EAC5B,SAAS,EACT,GAAG,KAAK,EACqB,EAAA;AAC7B,IAAA,QACEA,GAAA,CAAA,MAAA,EAAA,EAAA,WAAA,EACY,wBAAwB,EAClC,SAAS,EAAE,EAAE,CACX,uDAAuD,EACvD,SAAS,CACV,EAAA,GACG,KAAK,EAAA,CACT;AAEN;AAEA,SAAS,eAAe,CAAC,EACvB,GAAG,KAAK,EAC+C,EAAA;IACvD,OAAOA,GAAA,CAAC,qBAAqB,CAAC,GAAG,iBAAW,mBAAmB,EAAA,GAAK,KAAK,EAAA,CAAI;AAC/E;AAEA,SAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,KAAK,EAGT,EAAA;AACC,IAAA,QACEC,IAAA,CAAC,qBAAqB,CAAC,UAAU,EAAA,EAAA,WAAA,EACrB,2BAA2B,EAAA,YAAA,EACzB,KAAK,EACjB,SAAS,EAAE,EAAE,CACX,gXAAgX,EAChX,SAAS,CACV,EAAA,GACG,KAAK,EAAA,QAAA,EAAA,CAER,QAAQ,EACTD,GAAA,CAAC,gBAAgB,EAAA,EAAC,SAAS,EAAC,sCAAsC,EAAA,CAAG,CAAA,EAAA,CACpC;AAEvC;AAEA,SAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACsD,EAAA;IAC9D,QACEA,GAAA,CAAC,qBAAqB,CAAC,UAAU,iBACrB,2BAA2B,EACrC,SAAS,EAAE,EAAE;;AAEX,QAAA,ijBAAijB,EACjjB,SAAS,CACV,KACG,KAAK,EAAA,CACT;AAEN;;;;"}
@@ -59,7 +59,7 @@ const DropdownOptionButton = ({ children, set_is_open, size = "xs", }) => {
59
59
  }, [onTouchStart]);
60
60
  return (jsx("button", {
61
61
  // @ts-ignore
62
- ref: dropdown_button_ref, className: cn("w-full cursor-pointer text-left px-4 py-2 text-muted-foreground hover:bg-muted transition-colors flex items-center gap-2", is_mobile ? "min-h-12 py-3 active:bg-muted touch-manipulation" : "", `text-${size}`, children.props.highlighted ? "bg-primary-tint" : ""), onClick: (e) => !scrolling && handleClick(e), children: jsx("div", { className: "w-full", children: children }) }));
62
+ ref: dropdown_button_ref, className: cn("flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-muted-foreground transition-colors hover:bg-muted", is_mobile ? "min-h-12 py-3 active:bg-muted touch-manipulation" : "", `text-${size}`, children.props.highlighted ? "bg-primary-tint" : ""), onClick: (e) => !scrolling && handleClick(e), children: jsx("div", { className: "w-full", children: children }) }));
63
63
  };
64
64
  /**
65
65
  * This component creates a context provider for dropdowns inside it to use.
@@ -167,7 +167,7 @@ const GroupableRadioDropdown = ({ name, options, onChange, disabled, defaultValu
167
167
  ? Math.min(sheetViewport.height, 640)
168
168
  : "80dvh",
169
169
  }
170
- : undefined, children: [isMobile && (jsxs("div", { className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4", children: [jsx("h2", { className: "text-base font-semibold text-foreground", children: fallback }), jsx("button", { ref: sheetCloseRef, type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onClick: closeSheet, children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] })), jsx("div", { role: "listbox", className: cn("relative overflow-y-auto overscroll-contain touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]", isMobile ? "min-h-0 flex-1" : "max-h-[400px]"), children: options.map((option, index) => (jsx(DropdownOptionButton, { set_is_open: setIsOpen, size: size, children: jsx(DropdownOption, { highlighted: value === option.id, on_click: () => handleChange(option.id), children: jsx("span", { className: "block whitespace-normal wrap-break-word pr-2", children: option.name }) }) }, index))) })] })] }))] }));
170
+ : undefined, children: [isMobile && (jsxs("div", { className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4", children: [jsx("h2", { className: "text-base font-semibold text-foreground", children: fallback }), jsx("button", { ref: sheetCloseRef, type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onClick: closeSheet, children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] })), jsx("div", { role: "listbox", className: cn("relative flex flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]", isMobile ? "min-h-0 flex-1" : "max-h-[400px]"), children: options.map((option, index) => (jsx(DropdownOptionButton, { set_is_open: setIsOpen, size: size, children: jsx(DropdownOption, { highlighted: value === option.id, on_click: () => handleChange(option.id), children: jsx("span", { className: "block whitespace-normal wrap-break-word pr-2", children: option.name }) }) }, index))) })] })] }))] }));
171
171
  };
172
172
  /**
173
173
  * This creates a dropdown menu for navigating with improved mobile support.
@@ -253,7 +253,7 @@ const GroupableNavDropdown = ({ display, content, children, className = "", show
253
253
  set_is_open(!is_open);
254
254
  }, [is_open]);
255
255
  return (jsxs("div", { className: cn("relative z-[100]", className), ref: dropdownRef, children: [jsxs(Button, { ref: buttonRef, type: "button", variant: "ghost", className: "relative flex items-center gap-2 h-12 px-3 z-[1000]", onClick: handleButtonClick, onTouchEnd: (e) => e.stopPropagation(), children: [display, showArrow && (jsx(ChevronDown, { className: cn("w-4 h-4 text-muted-foreground transition-transform", is_open ? "rotate-180" : "") }))] }), is_open && (jsx("div", { className: cn("absolute right-0 mt-2 bg-background border border-border rounded-control-lg overflow-hidden shadow-card z-[1000]", is_mobile ? "w-56" : "w-48", // Slightly wider on mobile for better touch targets
256
- className), onClick: handleDropdownInteraction, onTouchStart: handleDropdownInteraction, onTouchEnd: handleDropdownInteraction, children: jsxs("div", { className: cn("relative z-[1000] max-h-64 overflow-y-auto overscroll-contain [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]", is_mobile ? "max-h-80" : "max-h-64"), children: [content, Children.map(children, (child, index) => {
256
+ className), onClick: handleDropdownInteraction, onTouchStart: handleDropdownInteraction, onTouchEnd: handleDropdownInteraction, children: jsxs("div", { className: cn("relative z-[1000] flex max-h-64 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]", is_mobile ? "max-h-80" : "max-h-64"), children: [content, Children.map(children, (child, index) => {
257
257
  return (jsx(DropdownOptionButton, { set_is_open: set_is_open, children: child ? child : jsx(Fragment, {}) }, index));
258
258
  })] }) }))] }));
259
259
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sources":["../../src/components/dropdown.tsx"],"sourcesContent":["'use client';\n\n/**\n * @ Author: BetterInternship\n * @ Create Time: 2025-06-14 23:30:09\n * @ Modified time: 2025-10-31 18:13:16\n * @ Description:\n *\n * Stateful dropdown group component.\n */\n\nimport { Button } from \"./button\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\nimport { MobileSheetPortal } from \"./mobile-sheet-portal\";\nimport { cn } from \"@/utils\";\nimport { fieldTriggerClassName } from \"@/hooks/use-field-focus\";\nimport { ChevronDown, X } from \"lucide-react\";\nimport { useRouter } from \"next/navigation\";\nimport React, {\n Children,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\n\n/**\n * The group context interface.\n * What's available in the group context to other components.\n */\ninterface IDropdownGroupContext {\n activeDropdown: string;\n setActiveDropdown: (dropdown: string) => void;\n}\nconst DropdownGroupContext = createContext<IDropdownGroupContext>(\n {} as IDropdownGroupContext,\n);\n\n/**\n * A wrapper around the contents of a dropdown option.\n *\n * @component\n */\ntype IDropdownOptionProps = {\n children?: React.ReactNode;\n highlighted?: boolean;\n disabled?: boolean;\n href?: string;\n on_click?: () => void;\n};\nexport const DropdownOption = ({ children }: IDropdownOptionProps) => {\n return <>{children}</>;\n};\n\n/**\n * Creates a standard button dropdowns must use with mobile optimization.\n * Not meant to be used elsewhere.\n *\n * @component\n */\nconst DropdownOptionButton = ({\n children,\n set_is_open,\n size = \"xs\",\n}: {\n children: React.ReactElement<IDropdownOptionProps>;\n set_is_open: (is_open: boolean) => void;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n}) => {\n const router = useRouter();\n const is_mobile = useMobile();\n const [scrolling, setScrolling] = useState(false);\n const dropdown_button_ref = useRef<HTMLInputElement>({} as HTMLInputElement);\n\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(false);\n children.props.on_click && children.props.on_click();\n children.props.href && router.push(children.props.href);\n },\n [children.props, router, set_is_open],\n );\n\n const onTouchStart = (e: any) => {\n e.stopPropagation();\n setScrolling(true);\n };\n\n const onTouchEnd = (e: any) => {\n e.stopPropagation();\n setScrolling(false);\n };\n\n useEffect(() => {\n const dropdown_button = dropdown_button_ref.current;\n if (!dropdown_button) return;\n\n // Attach passive touchstart handler\n dropdown_button.addEventListener(\"touchstart\", onTouchStart, {\n passive: true,\n });\n\n dropdown_button.addEventListener(\"touchend\", onTouchEnd, {\n passive: true,\n });\n\n // Cleanup on unmount\n return () => {\n dropdown_button.removeEventListener(\"touchstart\", onTouchStart);\n dropdown_button.removeEventListener(\"touchend\", onTouchEnd);\n };\n }, [onTouchStart]);\n\n return (\n <button\n // @ts-ignore\n ref={dropdown_button_ref}\n className={cn(\n \"w-full cursor-pointer text-left px-4 py-2 text-muted-foreground hover:bg-muted transition-colors flex items-center gap-2\",\n is_mobile ? \"min-h-12 py-3 active:bg-muted touch-manipulation\" : \"\",\n `text-${size}`,\n children.props.highlighted ? \"bg-primary-tint\" : \"\",\n )}\n onClick={(e) => !scrolling && handleClick(e)}\n >\n <div className=\"w-full\">{children}</div>\n </button>\n );\n};\n\n/**\n * This component creates a context provider for dropdowns inside it to use.\n * The dropdowns inside can modify the active dropdown when they're clicked.\n * This way, only one dropdown in the group is active at a time.\n *\n * @component\n */\nexport const DropdownGroup = ({ children }: { children: React.ReactNode }) => {\n const [activeDropdown, setActiveDropdown] = useState(\"\");\n const group_dropdown_context: IDropdownGroupContext = {\n activeDropdown,\n setActiveDropdown,\n };\n\n return (\n <DropdownGroupContext value={group_dropdown_context}>\n {children}\n </DropdownGroupContext>\n );\n};\n\ninterface IRadioDropdownOption<ID> {\n id: ID;\n name: string;\n}\n\n/**\n * This represents a single dropdown inside the group with mobile optimization.\n * Inherits the provided context (if there is none, that's fine).\n *\n * @component\n */\nexport const GroupableRadioDropdown = <ID extends number | string>({\n name,\n options,\n onChange,\n disabled,\n defaultValue = null,\n size = \"sm\",\n className = \"\",\n fallback = \"Select option\",\n}: {\n name: string;\n options: IRadioDropdownOption<ID>[];\n onChange: (option: ID) => void;\n defaultValue?: ID | ID[] | null;\n disabled?: boolean | undefined;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n className?: string;\n fallback?: string;\n}) => {\n const isMobile = useMobile();\n const { activeDropdown, setActiveDropdown } =\n useContext(DropdownGroupContext);\n const [isOpen, setIsOpen] = useState(false);\n const sheetViewport = useMobileSheetViewport(isOpen && isMobile);\n const [value, setValue] = useState(defaultValue);\n const ref = useDetectClickOutside({ onTriggered: () => setIsOpen(false) });\n const triggerRef = useRef<HTMLButtonElement>(null);\n const sheetRef = useRef<HTMLDivElement>(null);\n const sheetCloseRef = useRef<HTMLButtonElement>(null);\n const useSheet = isOpen && isMobile;\n\n const closeSheet = useCallback(() => {\n setIsOpen(false);\n triggerRef.current?.focus();\n }, []);\n\n // While the mobile sheet is open: lock page scroll and move focus into it.\n useEffect(() => {\n if (!useSheet) return;\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n const frame = window.requestAnimationFrame(() =>\n sheetCloseRef.current?.focus(),\n );\n return () => {\n window.cancelAnimationFrame(frame);\n document.body.style.overflow = overflow;\n };\n }, [useSheet]);\n\n // Just so it's not stuck at the first default when the default changes\n useEffect(() => {\n setValue(defaultValue);\n }, [defaultValue]);\n\n /**\n * Activates dropdown\n */\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n setIsOpen(!isOpen);\n setActiveDropdown(name);\n },\n [isOpen, name, setActiveDropdown],\n );\n\n /**\n * Changes dropdown value\n */\n const handleChange = useCallback(\n (option: ID) => {\n setValue(option);\n onChange(option);\n setIsOpen(false);\n },\n [onChange],\n );\n\n // Check if it's still the active dropdown\n useEffect(() => {\n if (activeDropdown !== name) setIsOpen(false);\n }, [activeDropdown, name]);\n\n const selected =\n value || value === 0 ? options.find((o) => o.id === value) : undefined;\n\n return (\n <div\n className={cn(\"relative w-full max-w-svw min-w-0\", className)}\n ref={ref}\n >\n <Button\n ref={triggerRef}\n type=\"button\"\n variant=\"outline\"\n disabled={disabled}\n size={size}\n onClick={handleClick}\n onTouchEnd={(e) => e.stopPropagation()}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n className={cn(\n \"w-full max-w-full min-w-0\",\n \"h-auto py-1\",\n fieldTriggerClassName,\n \"flex items-center justify-between gap-2\",\n )}\n >\n {/* shrinkable text container */}\n <span className=\"flex-1 min-w-0 text-left pr-2 leading-relaxed\">\n {selected ? (\n <span className=\"block whitespace-normal wrap-break-word\">\n {selected.name}\n </span>\n ) : (\n <span className=\"text-muted-foreground/40 font-normal\">\n {fallback}\n </span>\n )}\n </span>\n\n <ChevronDown\n className={cn(\n \"shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen ? \"rotate-180\" : \"\",\n )}\n />\n </Button>\n\n {isOpen && (\n <MobileSheetPortal enabled={isMobile}>\n {isMobile && (\n <button\n type=\"button\"\n aria-label=\"Close options\"\n tabIndex={-1}\n className=\"fixed inset-0 z-[1090] bg-black/25 backdrop-blur-[1px]\"\n onClick={closeSheet}\n />\n )}\n <div\n ref={isMobile ? sheetRef : undefined}\n role={isMobile ? \"dialog\" : undefined}\n aria-modal={isMobile ? true : undefined}\n aria-label={isMobile ? fallback : undefined}\n onKeyDown={\n isMobile\n ? (event) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeSheet();\n }\n if (event.key !== \"Tab\") return;\n const focusable =\n sheetRef.current?.querySelectorAll<HTMLElement>(\n \"button:not([disabled]):not([tabindex='-1'])\",\n );\n if (!focusable?.length) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (\n !event.shiftKey &&\n document.activeElement === last\n ) {\n event.preventDefault();\n first.focus();\n }\n }\n : undefined\n }\n className={cn(\n \"border border-border bg-background shadow-card\",\n isMobile\n ? \"fixed left-0 right-0 z-[1100] flex flex-col overflow-hidden rounded-t-control-lg border-b-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\n : \"absolute left-0 right-0 top-full z-[9999] mt-1 max-w-full overflow-hidden rounded-control-lg\",\n )}\n style={\n isMobile\n ? {\n bottom: sheetViewport?.bottom ?? 0,\n maxHeight: sheetViewport\n ? Math.min(sheetViewport.height, 640)\n : \"80dvh\",\n }\n : undefined\n }\n >\n {isMobile && (\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {fallback}\n </h2>\n <button\n ref={sheetCloseRef}\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onClick={closeSheet}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n <div\n role=\"listbox\"\n className={cn(\n \"relative overflow-y-auto overscroll-contain touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n isMobile ? \"min-h-0 flex-1\" : \"max-h-[400px]\",\n )}\n >\n {options.map((option, index) => (\n <DropdownOptionButton\n key={index}\n set_is_open={setIsOpen}\n size={size}\n >\n <DropdownOption\n highlighted={value === option.id}\n on_click={() => handleChange(option.id)}\n >\n <span className=\"block whitespace-normal wrap-break-word pr-2\">\n {option.name}\n </span>\n </DropdownOption>\n </DropdownOptionButton>\n ))}\n </div>\n </div>\n </MobileSheetPortal>\n )}\n </div>\n );\n};\n\n/**\n * This creates a dropdown menu for navigating with improved mobile support.\n *\n * @component\n */\nexport const GroupableNavDropdown = ({\n display,\n content,\n children,\n className = \"\",\n showArrow = true,\n}: {\n display?: React.ReactNode;\n content?: React.ReactNode;\n children?:\n | React.ReactElement<IDropdownOptionProps>\n | React.ReactElement<IDropdownOptionProps>[];\n className?: string;\n showArrow?: boolean;\n}) => {\n const is_mobile = useMobile();\n const [is_open, set_is_open] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const touchStartRef = useRef<{\n x: number;\n y: number;\n target: EventTarget | null;\n } | null>(null);\n\n // Close dropdown handler\n const closeDropdown = useCallback(() => {\n set_is_open(false);\n }, []);\n\n // Handle clicks outside dropdown\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n !is_mobile &&\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node) &&\n buttonRef.current &&\n !buttonRef.current.contains(event.target as Node)\n ) {\n closeDropdown();\n }\n };\n\n if (is_open && !is_mobile) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () =>\n document.removeEventListener(\"mousedown\", handleClickOutside);\n }\n }, [is_open, is_mobile, closeDropdown]);\n\n // Mobile touch handlers\n const handleTouchStart = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open) return;\n\n const touch = e.touches[0];\n touchStartRef.current = {\n x: touch.clientX,\n y: touch.clientY,\n target: e.target,\n };\n },\n [is_mobile, is_open],\n );\n\n const handleTouchEnd = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open || !touchStartRef.current) return;\n\n const touch = e.changedTouches[0];\n const startTouch = touchStartRef.current;\n\n // Calculate touch movement\n const deltaX = Math.abs(touch.clientX - startTouch.x);\n const deltaY = Math.abs(touch.clientY - startTouch.y);\n const isSwipe = deltaX > 10 || deltaY > 10;\n\n // Check if touch is outside dropdown area\n const target = e.target as Element;\n const isOutsideDropdown =\n dropdownRef.current &&\n !dropdownRef.current.contains(target) &&\n buttonRef.current &&\n !buttonRef.current.contains(target);\n\n // Close if touch ended outside and wasn't a swipe\n if (!isSwipe && isOutsideDropdown) {\n closeDropdown();\n }\n\n touchStartRef.current = null;\n },\n [is_mobile, is_open, closeDropdown],\n );\n\n // Set up mobile touch listeners\n useEffect(() => {\n if (is_mobile && is_open) {\n document.addEventListener(\"touchstart\", handleTouchStart);\n document.addEventListener(\"touchend\", handleTouchEnd);\n\n return () => {\n document.removeEventListener(\"touchstart\", handleTouchStart);\n document.removeEventListener(\"touchend\", handleTouchEnd);\n };\n }\n }, [is_mobile, is_open, handleTouchStart, handleTouchEnd]);\n\n // Prevent event propagation for dropdown content\n const handleDropdownInteraction = useCallback(\n (e: React.MouseEvent | React.TouchEvent) => {\n e.stopPropagation();\n },\n [],\n );\n\n // Toggle dropdown\n const handleButtonClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(!is_open);\n },\n [is_open],\n );\n\n return (\n <div className={cn(\"relative z-[100]\", className)} ref={dropdownRef}>\n <Button\n ref={buttonRef}\n type=\"button\"\n variant=\"ghost\"\n className=\"relative flex items-center gap-2 h-12 px-3 z-[1000]\"\n onClick={handleButtonClick}\n onTouchEnd={(e) => e.stopPropagation()}\n >\n {display}\n {showArrow && (\n <ChevronDown\n className={cn(\n \"w-4 h-4 text-muted-foreground transition-transform\",\n is_open ? \"rotate-180\" : \"\",\n )}\n />\n )}\n </Button>\n\n {is_open && (\n <div\n className={cn(\n \"absolute right-0 mt-2 bg-background border border-border rounded-control-lg overflow-hidden shadow-card z-[1000]\",\n is_mobile ? \"w-56\" : \"w-48\", // Slightly wider on mobile for better touch targets\n className,\n )}\n onClick={handleDropdownInteraction}\n onTouchStart={handleDropdownInteraction}\n onTouchEnd={handleDropdownInteraction}\n >\n <div\n className={cn(\n \"relative z-[1000] max-h-64 overflow-y-auto overscroll-contain [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n is_mobile ? \"max-h-80\" : \"max-h-64\",\n )}\n >\n {content}\n\n {Children.map(children, (child, index) => {\n return (\n <DropdownOptionButton key={index} set_is_open={set_is_open}>\n {child ? child : <></>}\n </DropdownOptionButton>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsCA;;;AAkBA;AAEA;;;;;AAKG;AACH;AASE;AACA;;AAEA;AAEA;;;;AAKI;;AAKJ;;;AAGA;AAEA;;;AAGA;;AAGE;AACA;;;AAGA;AACE;AACD;AAED;AACE;AACD;;AAGD;AACE;AACA;AACF;AACF;AAEA;;AAGI;AAYN;AAEA;;;;;;AAMG;;;AAGD;;;;;AAUF;AAOA;;;;;AAKG;AACI;AAmBL;;;;;AAMA;AACA;AACA;AACA;AACA;AAEA;;AAEE;;;;AAKA;;;;AAGA;AAGA;AACE;;AAEF;AACF;;;;AAKA;AAEA;;AAEG;AACH;;AAGI;;;AAMJ;;AAEG;AACH;;;;AAKE;;;;;AAOF;AAEA;;AAgEc;AACI;;AAEE;;AAEF;;;;;AAMA;;;;;;;AAOE;;;;;;AAWN;AACA;AAIA;AACI;AACA;;AAEE;AACH;AACH;AAgDhB;AAEA;;;;AAIG;;AAgBD;;AAEA;AACA;AACA;;AAOA;;;;;AAME;AACE;AAEE;;AAEA;;AAGA;;AAEJ;AAEA;AACE;;;;;AAOJ;AAEI;;;;;;;;AAQF;AAIF;;;;AAKI;;AAGA;AACA;;;AAIA;AACA;AAEE;AACA;;;AAIF;AACE;;AAGF;;;;AAOF;AACE;AACA;AAEA;AACE;AACA;AACF;;;;AAKJ;;;;AAQA;;AAGI;AACF;;;;AAkDQ;AAMZ;;"}
1
+ {"version":3,"file":"dropdown.js","sources":["../../src/components/dropdown.tsx"],"sourcesContent":["'use client';\n\n/**\n * @ Author: BetterInternship\n * @ Create Time: 2025-06-14 23:30:09\n * @ Modified time: 2025-10-31 18:13:16\n * @ Description:\n *\n * Stateful dropdown group component.\n */\n\nimport { Button } from \"./button\";\nimport { useMobile } from \"@/hooks/use-mobile\";\nimport { useMobileSheetViewport } from \"@/hooks/use-mobile-sheet-viewport\";\nimport { MobileSheetPortal } from \"./mobile-sheet-portal\";\nimport { cn } from \"@/utils\";\nimport { fieldTriggerClassName } from \"@/hooks/use-field-focus\";\nimport { ChevronDown, X } from \"lucide-react\";\nimport { useRouter } from \"next/navigation\";\nimport React, {\n Children,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { useDetectClickOutside } from '@/hooks/use-detect-click-outside';\n\n/**\n * The group context interface.\n * What's available in the group context to other components.\n */\ninterface IDropdownGroupContext {\n activeDropdown: string;\n setActiveDropdown: (dropdown: string) => void;\n}\nconst DropdownGroupContext = createContext<IDropdownGroupContext>(\n {} as IDropdownGroupContext,\n);\n\n/**\n * A wrapper around the contents of a dropdown option.\n *\n * @component\n */\ntype IDropdownOptionProps = {\n children?: React.ReactNode;\n highlighted?: boolean;\n disabled?: boolean;\n href?: string;\n on_click?: () => void;\n};\nexport const DropdownOption = ({ children }: IDropdownOptionProps) => {\n return <>{children}</>;\n};\n\n/**\n * Creates a standard button dropdowns must use with mobile optimization.\n * Not meant to be used elsewhere.\n *\n * @component\n */\nconst DropdownOptionButton = ({\n children,\n set_is_open,\n size = \"xs\",\n}: {\n children: React.ReactElement<IDropdownOptionProps>;\n set_is_open: (is_open: boolean) => void;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n}) => {\n const router = useRouter();\n const is_mobile = useMobile();\n const [scrolling, setScrolling] = useState(false);\n const dropdown_button_ref = useRef<HTMLInputElement>({} as HTMLInputElement);\n\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(false);\n children.props.on_click && children.props.on_click();\n children.props.href && router.push(children.props.href);\n },\n [children.props, router, set_is_open],\n );\n\n const onTouchStart = (e: any) => {\n e.stopPropagation();\n setScrolling(true);\n };\n\n const onTouchEnd = (e: any) => {\n e.stopPropagation();\n setScrolling(false);\n };\n\n useEffect(() => {\n const dropdown_button = dropdown_button_ref.current;\n if (!dropdown_button) return;\n\n // Attach passive touchstart handler\n dropdown_button.addEventListener(\"touchstart\", onTouchStart, {\n passive: true,\n });\n\n dropdown_button.addEventListener(\"touchend\", onTouchEnd, {\n passive: true,\n });\n\n // Cleanup on unmount\n return () => {\n dropdown_button.removeEventListener(\"touchstart\", onTouchStart);\n dropdown_button.removeEventListener(\"touchend\", onTouchEnd);\n };\n }, [onTouchStart]);\n\n return (\n <button\n // @ts-ignore\n ref={dropdown_button_ref}\n className={cn(\n \"flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 text-left text-muted-foreground transition-colors hover:bg-muted\",\n is_mobile ? \"min-h-12 py-3 active:bg-muted touch-manipulation\" : \"\",\n `text-${size}`,\n children.props.highlighted ? \"bg-primary-tint\" : \"\",\n )}\n onClick={(e) => !scrolling && handleClick(e)}\n >\n <div className=\"w-full\">{children}</div>\n </button>\n );\n};\n\n/**\n * This component creates a context provider for dropdowns inside it to use.\n * The dropdowns inside can modify the active dropdown when they're clicked.\n * This way, only one dropdown in the group is active at a time.\n *\n * @component\n */\nexport const DropdownGroup = ({ children }: { children: React.ReactNode }) => {\n const [activeDropdown, setActiveDropdown] = useState(\"\");\n const group_dropdown_context: IDropdownGroupContext = {\n activeDropdown,\n setActiveDropdown,\n };\n\n return (\n <DropdownGroupContext value={group_dropdown_context}>\n {children}\n </DropdownGroupContext>\n );\n};\n\ninterface IRadioDropdownOption<ID> {\n id: ID;\n name: string;\n}\n\n/**\n * This represents a single dropdown inside the group with mobile optimization.\n * Inherits the provided context (if there is none, that's fine).\n *\n * @component\n */\nexport const GroupableRadioDropdown = <ID extends number | string>({\n name,\n options,\n onChange,\n disabled,\n defaultValue = null,\n size = \"sm\",\n className = \"\",\n fallback = \"Select option\",\n}: {\n name: string;\n options: IRadioDropdownOption<ID>[];\n onChange: (option: ID) => void;\n defaultValue?: ID | ID[] | null;\n disabled?: boolean | undefined;\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\";\n className?: string;\n fallback?: string;\n}) => {\n const isMobile = useMobile();\n const { activeDropdown, setActiveDropdown } =\n useContext(DropdownGroupContext);\n const [isOpen, setIsOpen] = useState(false);\n const sheetViewport = useMobileSheetViewport(isOpen && isMobile);\n const [value, setValue] = useState(defaultValue);\n const ref = useDetectClickOutside({ onTriggered: () => setIsOpen(false) });\n const triggerRef = useRef<HTMLButtonElement>(null);\n const sheetRef = useRef<HTMLDivElement>(null);\n const sheetCloseRef = useRef<HTMLButtonElement>(null);\n const useSheet = isOpen && isMobile;\n\n const closeSheet = useCallback(() => {\n setIsOpen(false);\n triggerRef.current?.focus();\n }, []);\n\n // While the mobile sheet is open: lock page scroll and move focus into it.\n useEffect(() => {\n if (!useSheet) return;\n const overflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n const frame = window.requestAnimationFrame(() =>\n sheetCloseRef.current?.focus(),\n );\n return () => {\n window.cancelAnimationFrame(frame);\n document.body.style.overflow = overflow;\n };\n }, [useSheet]);\n\n // Just so it's not stuck at the first default when the default changes\n useEffect(() => {\n setValue(defaultValue);\n }, [defaultValue]);\n\n /**\n * Activates dropdown\n */\n const handleClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n setIsOpen(!isOpen);\n setActiveDropdown(name);\n },\n [isOpen, name, setActiveDropdown],\n );\n\n /**\n * Changes dropdown value\n */\n const handleChange = useCallback(\n (option: ID) => {\n setValue(option);\n onChange(option);\n setIsOpen(false);\n },\n [onChange],\n );\n\n // Check if it's still the active dropdown\n useEffect(() => {\n if (activeDropdown !== name) setIsOpen(false);\n }, [activeDropdown, name]);\n\n const selected =\n value || value === 0 ? options.find((o) => o.id === value) : undefined;\n\n return (\n <div\n className={cn(\"relative w-full max-w-svw min-w-0\", className)}\n ref={ref}\n >\n <Button\n ref={triggerRef}\n type=\"button\"\n variant=\"outline\"\n disabled={disabled}\n size={size}\n onClick={handleClick}\n onTouchEnd={(e) => e.stopPropagation()}\n aria-haspopup=\"listbox\"\n aria-expanded={isOpen}\n className={cn(\n \"w-full max-w-full min-w-0\",\n \"h-auto py-1\",\n fieldTriggerClassName,\n \"flex items-center justify-between gap-2\",\n )}\n >\n {/* shrinkable text container */}\n <span className=\"flex-1 min-w-0 text-left pr-2 leading-relaxed\">\n {selected ? (\n <span className=\"block whitespace-normal wrap-break-word\">\n {selected.name}\n </span>\n ) : (\n <span className=\"text-muted-foreground/40 font-normal\">\n {fallback}\n </span>\n )}\n </span>\n\n <ChevronDown\n className={cn(\n \"shrink-0 w-4 h-4 text-muted-foreground transition-transform duration-interactive ease-out-strong motion-reduce:transition-none\",\n isOpen ? \"rotate-180\" : \"\",\n )}\n />\n </Button>\n\n {isOpen && (\n <MobileSheetPortal enabled={isMobile}>\n {isMobile && (\n <button\n type=\"button\"\n aria-label=\"Close options\"\n tabIndex={-1}\n className=\"fixed inset-0 z-[1090] bg-black/25 backdrop-blur-[1px]\"\n onClick={closeSheet}\n />\n )}\n <div\n ref={isMobile ? sheetRef : undefined}\n role={isMobile ? \"dialog\" : undefined}\n aria-modal={isMobile ? true : undefined}\n aria-label={isMobile ? fallback : undefined}\n onKeyDown={\n isMobile\n ? (event) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeSheet();\n }\n if (event.key !== \"Tab\") return;\n const focusable =\n sheetRef.current?.querySelectorAll<HTMLElement>(\n \"button:not([disabled]):not([tabindex='-1'])\",\n );\n if (!focusable?.length) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (\n !event.shiftKey &&\n document.activeElement === last\n ) {\n event.preventDefault();\n first.focus();\n }\n }\n : undefined\n }\n className={cn(\n \"border border-border bg-background shadow-card\",\n isMobile\n ? \"fixed left-0 right-0 z-[1100] flex flex-col overflow-hidden rounded-t-control-lg border-b-0 pb-[max(0.75rem,env(safe-area-inset-bottom))]\"\n : \"absolute left-0 right-0 top-full z-[9999] mt-1 max-w-full overflow-hidden rounded-control-lg\",\n )}\n style={\n isMobile\n ? {\n bottom: sheetViewport?.bottom ?? 0,\n maxHeight: sheetViewport\n ? Math.min(sheetViewport.height, 640)\n : \"80dvh\",\n }\n : undefined\n }\n >\n {isMobile && (\n <div className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-2 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">\n {fallback}\n </h2>\n <button\n ref={sheetCloseRef}\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onClick={closeSheet}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n <div\n role=\"listbox\"\n className={cn(\n \"relative flex flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset touch-pan-y [-webkit-overflow-scrolling:touch] [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n isMobile ? \"min-h-0 flex-1\" : \"max-h-[400px]\",\n )}\n >\n {options.map((option, index) => (\n <DropdownOptionButton\n key={index}\n set_is_open={setIsOpen}\n size={size}\n >\n <DropdownOption\n highlighted={value === option.id}\n on_click={() => handleChange(option.id)}\n >\n <span className=\"block whitespace-normal wrap-break-word pr-2\">\n {option.name}\n </span>\n </DropdownOption>\n </DropdownOptionButton>\n ))}\n </div>\n </div>\n </MobileSheetPortal>\n )}\n </div>\n );\n};\n\n/**\n * This creates a dropdown menu for navigating with improved mobile support.\n *\n * @component\n */\nexport const GroupableNavDropdown = ({\n display,\n content,\n children,\n className = \"\",\n showArrow = true,\n}: {\n display?: React.ReactNode;\n content?: React.ReactNode;\n children?:\n | React.ReactElement<IDropdownOptionProps>\n | React.ReactElement<IDropdownOptionProps>[];\n className?: string;\n showArrow?: boolean;\n}) => {\n const is_mobile = useMobile();\n const [is_open, set_is_open] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const touchStartRef = useRef<{\n x: number;\n y: number;\n target: EventTarget | null;\n } | null>(null);\n\n // Close dropdown handler\n const closeDropdown = useCallback(() => {\n set_is_open(false);\n }, []);\n\n // Handle clicks outside dropdown\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n !is_mobile &&\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node) &&\n buttonRef.current &&\n !buttonRef.current.contains(event.target as Node)\n ) {\n closeDropdown();\n }\n };\n\n if (is_open && !is_mobile) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () =>\n document.removeEventListener(\"mousedown\", handleClickOutside);\n }\n }, [is_open, is_mobile, closeDropdown]);\n\n // Mobile touch handlers\n const handleTouchStart = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open) return;\n\n const touch = e.touches[0];\n touchStartRef.current = {\n x: touch.clientX,\n y: touch.clientY,\n target: e.target,\n };\n },\n [is_mobile, is_open],\n );\n\n const handleTouchEnd = useCallback(\n (e: TouchEvent) => {\n if (!is_mobile || !is_open || !touchStartRef.current) return;\n\n const touch = e.changedTouches[0];\n const startTouch = touchStartRef.current;\n\n // Calculate touch movement\n const deltaX = Math.abs(touch.clientX - startTouch.x);\n const deltaY = Math.abs(touch.clientY - startTouch.y);\n const isSwipe = deltaX > 10 || deltaY > 10;\n\n // Check if touch is outside dropdown area\n const target = e.target as Element;\n const isOutsideDropdown =\n dropdownRef.current &&\n !dropdownRef.current.contains(target) &&\n buttonRef.current &&\n !buttonRef.current.contains(target);\n\n // Close if touch ended outside and wasn't a swipe\n if (!isSwipe && isOutsideDropdown) {\n closeDropdown();\n }\n\n touchStartRef.current = null;\n },\n [is_mobile, is_open, closeDropdown],\n );\n\n // Set up mobile touch listeners\n useEffect(() => {\n if (is_mobile && is_open) {\n document.addEventListener(\"touchstart\", handleTouchStart);\n document.addEventListener(\"touchend\", handleTouchEnd);\n\n return () => {\n document.removeEventListener(\"touchstart\", handleTouchStart);\n document.removeEventListener(\"touchend\", handleTouchEnd);\n };\n }\n }, [is_mobile, is_open, handleTouchStart, handleTouchEnd]);\n\n // Prevent event propagation for dropdown content\n const handleDropdownInteraction = useCallback(\n (e: React.MouseEvent | React.TouchEvent) => {\n e.stopPropagation();\n },\n [],\n );\n\n // Toggle dropdown\n const handleButtonClick = useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n set_is_open(!is_open);\n },\n [is_open],\n );\n\n return (\n <div className={cn(\"relative z-[100]\", className)} ref={dropdownRef}>\n <Button\n ref={buttonRef}\n type=\"button\"\n variant=\"ghost\"\n className=\"relative flex items-center gap-2 h-12 px-3 z-[1000]\"\n onClick={handleButtonClick}\n onTouchEnd={(e) => e.stopPropagation()}\n >\n {display}\n {showArrow && (\n <ChevronDown\n className={cn(\n \"w-4 h-4 text-muted-foreground transition-transform\",\n is_open ? \"rotate-180\" : \"\",\n )}\n />\n )}\n </Button>\n\n {is_open && (\n <div\n className={cn(\n \"absolute right-0 mt-2 bg-background border border-border rounded-control-lg overflow-hidden shadow-card z-[1000]\",\n is_mobile ? \"w-56\" : \"w-48\", // Slightly wider on mobile for better touch targets\n className,\n )}\n onClick={handleDropdownInteraction}\n onTouchStart={handleDropdownInteraction}\n onTouchEnd={handleDropdownInteraction}\n >\n <div\n className={cn(\n \"relative z-[1000] flex max-h-64 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset [scrollbar-width:thin] [scrollbar-color:var(--color-border-hover)_var(--muted)]\",\n is_mobile ? \"max-h-80\" : \"max-h-64\",\n )}\n >\n {content}\n\n {Children.map(children, (child, index) => {\n return (\n <DropdownOptionButton key={index} set_is_open={set_is_open}>\n {child ? child : <></>}\n </DropdownOptionButton>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAsCA;;;AAkBA;AAEA;;;;;AAKG;AACH;AASE;AACA;;AAEA;AAEA;;;;AAKI;;AAKJ;;;AAGA;AAEA;;;AAGA;;AAGE;AACA;;;AAGA;AACE;AACD;AAED;AACE;AACD;;AAGD;AACE;AACA;AACF;AACF;AAEA;;AAGI;AAYN;AAEA;;;;;;AAMG;;;AAGD;;;;;AAUF;AAOA;;;;;AAKG;AACI;AAmBL;;;;;AAMA;AACA;AACA;AACA;AACA;AAEA;;AAEE;;;;AAKA;;;;AAGA;AAGA;AACE;;AAEF;AACF;;;;AAKA;AAEA;;AAEG;AACH;;AAGI;;;AAMJ;;AAEG;AACH;;;;AAKE;;;;;AAOF;AAEA;;AAgEc;AACI;;AAEE;;AAEF;;;;;AAMA;;;;;;;AAOE;;;;;;AAWN;AACA;AAIA;AACI;AACA;;AAEE;AACH;AACH;AAgDhB;AAEA;;;;AAIG;;AAgBD;;AAEA;AACA;AACA;;AAOA;;;;;AAME;AACE;AAEE;;AAEA;;AAGA;;AAEJ;AAEA;AACE;;;;;AAOJ;AAEI;;;;;;;;AAQF;AAIF;;;;AAKI;;AAGA;AACA;;;AAIA;AACA;AAEE;AACA;;;AAIF;AACE;;AAGF;;;;AAOF;AACE;AACA;AAEA;AACE;AACA;AACF;;;;AAKJ;;;;AAQA;;AAGI;AACF;;;;AAkDQ;AAMZ;;"}
@@ -0,0 +1,40 @@
1
+ import * as React from "react";
2
+ /** Padding + row gap for a list of options inside a popover or sheet. */
3
+ export declare const optionListClassName = "flex flex-col gap-option-gap p-option-inset";
4
+ /** One option row. Pair with a hover/focus or selected state as needed. */
5
+ export declare const optionRowClassName = "relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-foreground outline-none transition-colors duration-state hover:bg-muted focus-visible:bg-muted motion-reduce:transition-none max-md:min-h-11";
6
+ export type CheckboxListItem = {
7
+ label: React.ReactNode;
8
+ checked: boolean;
9
+ onCheckedChange: (checked: boolean) => void;
10
+ /** Indents the row under a group heading row. */
11
+ indent?: boolean;
12
+ /** Bolder label, e.g. a group's "All …" row. */
13
+ strong?: boolean;
14
+ disabled?: boolean;
15
+ };
16
+ /** A list of checkbox rows in the shared option style. */
17
+ export declare function CheckboxList({ items, className, "aria-label": label, }: {
18
+ items: CheckboxListItem[];
19
+ className?: string;
20
+ "aria-label"?: string;
21
+ }): import("react/jsx-runtime").JSX.Element;
22
+ export type FilterMenuOption = {
23
+ label: React.ReactNode;
24
+ value: string;
25
+ };
26
+ /**
27
+ * A filter chip that opens a checklist: each tick applies immediately, and
28
+ * the chip shows how many are on (in the selected, secondary style).
29
+ */
30
+ export declare function FilterMenu({ label, options, value, onValueChange, size, align, className, contentClassName, }: {
31
+ label: React.ReactNode;
32
+ options: FilterMenuOption[];
33
+ /** The selected option values. */
34
+ value: string[];
35
+ onValueChange: (value: string[]) => void;
36
+ size?: "xs" | "sm" | "md";
37
+ align?: "start" | "center" | "end";
38
+ className?: string;
39
+ contentClassName?: string;
40
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { ChevronDown } from 'lucide-react';
4
+ import { cn } from '../utils.js';
5
+ import { Checkbox } from './checkbox.js';
6
+ import { FilterChip } from './filter-chip.js';
7
+ import { Popover, PopoverTrigger, PopoverContent } from './popover.js';
8
+
9
+ /*
10
+ * The shared look for every list of options (menus, selects, dropdowns,
11
+ * autocomplete, filter menus): the list is inset from its container's edge,
12
+ * and each row is its own rounded box with a little space between rows, so
13
+ * hover and selection read as distinct pills rather than full-bleed stripes.
14
+ */
15
+ /** Padding + row gap for a list of options inside a popover or sheet. */
16
+ const optionListClassName = "flex flex-col gap-option-gap p-option-inset";
17
+ /** One option row. Pair with a hover/focus or selected state as needed. */
18
+ const optionRowClassName = "relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-foreground outline-none transition-colors duration-state hover:bg-muted focus-visible:bg-muted motion-reduce:transition-none max-md:min-h-11";
19
+ /** A list of checkbox rows in the shared option style. */
20
+ function CheckboxList({ items, className, "aria-label": label, }) {
21
+ return (jsx("ul", { "aria-label": label, className: cn("m-0 list-none", optionListClassName, className), children: items.map((item, index) => (jsx("li", { children: jsxs("label", { className: cn(optionRowClassName, item.indent && "pl-8", item.strong && "font-medium", item.disabled && "pointer-events-none opacity-50"), children: [jsx(Checkbox, { checked: item.checked, disabled: item.disabled, onCheckedChange: (checked) => item.onCheckedChange(checked === true) }), jsx("span", { className: "min-w-0 flex-1", children: item.label })] }) }, index))) }));
22
+ }
23
+ /**
24
+ * A filter chip that opens a checklist: each tick applies immediately, and
25
+ * the chip shows how many are on (in the selected, secondary style).
26
+ */
27
+ function FilterMenu({ label, options, value, onValueChange, size = "sm", align = "start", className, contentClassName, }) {
28
+ const count = value.length;
29
+ return (jsxs(Popover, { children: [jsx(PopoverTrigger, { asChild: true, children: jsxs(FilterChip, { size: size, selected: count > 0, count: count || undefined, className: className, children: [label, jsx(ChevronDown, { size: 14, "aria-hidden": "true", className: "-mr-1" })] }) }), jsx(PopoverContent, { align: align, className: cn("w-56 p-0", contentClassName), children: jsx(CheckboxList, { "aria-label": typeof label === "string" ? label : undefined, items: options.map((option) => ({
30
+ label: option.label,
31
+ checked: value.includes(option.value),
32
+ onCheckedChange: (on) => onValueChange(on
33
+ ? [...value, option.value]
34
+ : value.filter((item) => item !== option.value)),
35
+ })) }) })] }));
36
+ }
37
+
38
+ export { CheckboxList, FilterMenu, optionListClassName, optionRowClassName };
39
+ //# sourceMappingURL=option-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-list.js","sources":["../../src/components/option-list.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { ChevronDown } from \"lucide-react\";\n\nimport { cn } from \"@/utils\";\nimport { Checkbox } from \"./checkbox\";\nimport { FilterChip } from \"./filter-chip\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover\";\n\n/*\n * The shared look for every list of options (menus, selects, dropdowns,\n * autocomplete, filter menus): the list is inset from its container's edge,\n * and each row is its own rounded box with a little space between rows, so\n * hover and selection read as distinct pills rather than full-bleed stripes.\n */\n\n/** Padding + row gap for a list of options inside a popover or sheet. */\nexport const optionListClassName = \"flex flex-col gap-option-gap p-option-inset\";\n\n/** One option row. Pair with a hover/focus or selected state as needed. */\nexport const optionRowClassName =\n \"relative flex min-h-option-row w-full cursor-pointer select-none items-center gap-3 rounded-control-sm px-option-x py-2 text-left text-sm text-foreground outline-none transition-colors duration-state hover:bg-muted focus-visible:bg-muted motion-reduce:transition-none max-md:min-h-11\";\n\nexport type CheckboxListItem = {\n label: React.ReactNode;\n checked: boolean;\n onCheckedChange: (checked: boolean) => void;\n /** Indents the row under a group heading row. */\n indent?: boolean;\n /** Bolder label, e.g. a group's \"All …\" row. */\n strong?: boolean;\n disabled?: boolean;\n};\n\n/** A list of checkbox rows in the shared option style. */\nexport function CheckboxList({\n items,\n className,\n \"aria-label\": label,\n}: {\n items: CheckboxListItem[];\n className?: string;\n \"aria-label\"?: string;\n}) {\n return (\n <ul\n aria-label={label}\n className={cn(\"m-0 list-none\", optionListClassName, className)}\n >\n {items.map((item, index) => (\n <li key={index}>\n <label\n className={cn(\n optionRowClassName,\n item.indent && \"pl-8\",\n item.strong && \"font-medium\",\n item.disabled && \"pointer-events-none opacity-50\",\n )}\n >\n <Checkbox\n checked={item.checked}\n disabled={item.disabled}\n onCheckedChange={(checked) =>\n item.onCheckedChange(checked === true)\n }\n />\n <span className=\"min-w-0 flex-1\">{item.label}</span>\n </label>\n </li>\n ))}\n </ul>\n );\n}\n\nexport type FilterMenuOption = { label: React.ReactNode; value: string };\n\n/**\n * A filter chip that opens a checklist: each tick applies immediately, and\n * the chip shows how many are on (in the selected, secondary style).\n */\nexport function FilterMenu({\n label,\n options,\n value,\n onValueChange,\n size = \"sm\",\n align = \"start\",\n className,\n contentClassName,\n}: {\n label: React.ReactNode;\n options: FilterMenuOption[];\n /** The selected option values. */\n value: string[];\n onValueChange: (value: string[]) => void;\n size?: \"xs\" | \"sm\" | \"md\";\n align?: \"start\" | \"center\" | \"end\";\n className?: string;\n contentClassName?: string;\n}) {\n const count = value.length;\n return (\n <Popover>\n <PopoverTrigger asChild>\n <FilterChip\n size={size}\n selected={count > 0}\n count={count || undefined}\n className={className}\n >\n {label}\n <ChevronDown size={14} aria-hidden=\"true\" className=\"-mr-1\" />\n </FilterChip>\n </PopoverTrigger>\n <PopoverContent\n align={align}\n className={cn(\"w-56 p-0\", contentClassName)}\n >\n <CheckboxList\n aria-label={typeof label === \"string\" ? label : undefined}\n items={options.map((option) => ({\n label: option.label,\n checked: value.includes(option.value),\n onCheckedChange: (on) =>\n onValueChange(\n on\n ? [...value, option.value]\n : value.filter((item) => item !== option.value),\n ),\n }))}\n />\n </PopoverContent>\n </Popover>\n );\n}\n"],"names":[],"mappings":";;;;;;;;AAUA;;;;;AAKG;AAEH;AACO;AAEP;AACO;AAcP;AACM;;AAqCN;AAIA;;;AAGG;AACG;AAoBJ;;;;;;AA2BgB;AAEP;AAKX;;"}
@@ -37,12 +37,12 @@ const SelectContent = React.forwardRef(({ className, children, position = 'poppe
37
37
  : 'z-50 max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95', className), position: mobile ? 'popper' : position, sideOffset: 4, style: {
38
38
  ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),
39
39
  ...style,
40
- }, ...props, children: [mobile && (jsxs("div", { role: "presentation", className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4", children: [jsx("h2", { className: "text-base font-semibold text-foreground", children: title }), jsx("button", { type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onPointerDown: (event) => event.stopPropagation(), onClick: () => setOpen(false), children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] })), !mobile && jsx(SelectScrollUpButton, {}), jsx(SelectPrimitive.Viewport, { className: cn('min-h-0 overflow-y-auto overscroll-contain', mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]'), children: children }), !mobile && jsx(SelectScrollDownButton, {})] })] }) }));
40
+ }, ...props, children: [mobile && (jsxs("div", { role: "presentation", className: "flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4", children: [jsx("h2", { className: "text-base font-semibold text-foreground", children: title }), jsx("button", { type: "button", "aria-label": "Close options", className: "-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted", onPointerDown: (event) => event.stopPropagation(), onClick: () => setOpen(false), children: jsx(X, { className: "h-5 w-5", "aria-hidden": "true" }) })] })), !mobile && jsx(SelectScrollUpButton, {}), jsx(SelectPrimitive.Viewport, { className: cn('flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset', mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]'), children: children }), !mobile && jsx(SelectScrollDownButton, {})] })] }) }));
41
41
  });
42
42
  SelectContent.displayName = SelectPrimitive.Content.displayName;
43
- const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (jsx(SelectPrimitive.Label, { ref: ref, className: cn('py-2 pr-4 pl-8 text-sm font-semibold text-foreground', className), ...props })));
43
+ const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (jsx(SelectPrimitive.Label, { ref: ref, className: cn('px-option-x py-2 text-sm font-semibold text-foreground', className), ...props })));
44
44
  SelectLabel.displayName = SelectPrimitive.Label.displayName;
45
- const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (jsxs(SelectPrimitive.Item, { ref: ref, className: cn('relative flex w-full cursor-pointer items-center gap-2 px-4 py-2 pr-10 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12', className), ...props, children: [jsx("span", { className: "absolute right-4 flex h-4 w-4 items-center justify-center", children: jsx(SelectPrimitive.ItemIndicator, { children: jsx(Check, { className: "h-4 w-4" }) }) }), jsx(SelectPrimitive.ItemText, { children: children })] })));
45
+ const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (jsxs(SelectPrimitive.Item, { ref: ref, className: cn('relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pr-9 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12', className), ...props, children: [jsx("span", { className: "absolute right-option-x flex h-4 w-4 items-center justify-center", children: jsx(SelectPrimitive.ItemIndicator, { children: jsx(Check, { className: "h-4 w-4" }) }) }), jsx(SelectPrimitive.ItemText, { children: children })] })));
46
46
  SelectItem.displayName = SelectPrimitive.Item.displayName;
47
47
  const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (jsx(SelectPrimitive.Separator, { ref: ref, className: cn('bg-border h-px', className), ...props })));
48
48
  SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\nimport { useMobile } from '@/hooks/use-mobile';\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\n\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\n\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? internalOpen;\n const setOpen = (next: boolean) => {\n if (controlledOpen === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <SelectContext.Provider value={{ open, setOpen }}>\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\n {children}\n </SelectPrimitive.Root>\n </SelectContext.Provider>\n );\n}\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\n fieldInteractionClassName,\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName =\n SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\n>(({ className, children, position = 'popper', title = 'Choose an option', style, ...props }, ref) => {\n const mobile = useMobile();\n const { open, setOpen } = React.useContext(SelectContext);\n const viewport = useMobileSheetViewport(open && mobile);\n\n return (\n <SelectPrimitive.Portal>\n <div\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-[1100] [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined}\n style={{ '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` } as React.CSSProperties}\n >\n {mobile && open && (\n <div aria-hidden=\"true\" className=\"fixed inset-0 z-[1090] bg-black/25 backdrop-blur-[1px]\" />\n )}\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none',\n mobile\n ? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'\n : 'z-50 max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n position={mobile ? 'popper' : position}\n sideOffset={4}\n style={{\n ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),\n ...style,\n }}\n {...props}\n >\n {mobile && (\n <div role=\"presentation\" className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">{title}</h2>\n <button\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onPointerDown={(event) => event.stopPropagation()}\n onClick={() => setOpen(false)}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n {!mobile && <SelectScrollUpButton />}\n <SelectPrimitive.Viewport\n className={cn(\n 'min-h-0 overflow-y-auto overscroll-contain',\n mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n {!mobile && <SelectScrollDownButton />}\n </SelectPrimitive.Content>\n </div>\n </SelectPrimitive.Portal>\n );\n});\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('py-2 pr-4 pl-8 text-sm font-semibold text-foreground', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex w-full cursor-pointer items-center gap-2 px-4 py-2 pr-10 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-4 flex h-4 w-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('bg-border h-px', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"names":[],"mappings":";;;;;;;;;;AAWA;AAEA;AACE;AACA;AACA;;;AAEE;AACF;AAEA;AAOF;AAEA;AAEA;AAEA;AAoBA;AAEA;AAeA;AAEA;AAeA;AACE;AAEF;AAIE;AACA;;AAGA;AAcQ;;AAOF;AACA;;AAgCR;AACA;AAEA;AAUA;AAEA;AAqBA;AAEA;AAUA;;"}
1
+ {"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport * as SelectPrimitive from '@radix-ui/react-select';\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\n\nimport { cn } from '@/utils';\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\nimport { useMobile } from '@/hooks/use-mobile';\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\n\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\n\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\n const open = controlledOpen ?? internalOpen;\n const setOpen = (next: boolean) => {\n if (controlledOpen === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n };\n\n return (\n <SelectContext.Provider value={{ open, setOpen }}>\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\n {children}\n </SelectPrimitive.Root>\n </SelectContext.Provider>\n );\n}\n\nconst SelectGroup = SelectPrimitive.Group;\n\nconst SelectValue = SelectPrimitive.Value;\n\nconst SelectTrigger = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Trigger>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Trigger\n ref={ref}\n className={cn(\n 'group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\n fieldInteractionClassName,\n className,\n )}\n {...props}\n >\n {children}\n <SelectPrimitive.Icon asChild>\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n));\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\n\nconst SelectScrollUpButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollUpButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronUp className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollUpButton>\n));\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\n\nconst SelectScrollDownButton = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.ScrollDownButton\n ref={ref}\n className={cn(\n 'flex cursor-default items-center justify-center py-1',\n className,\n )}\n {...props}\n >\n <ChevronDown className=\"h-4 w-4\" />\n </SelectPrimitive.ScrollDownButton>\n));\nSelectScrollDownButton.displayName =\n SelectPrimitive.ScrollDownButton.displayName;\n\nconst SelectContent = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\n>(({ className, children, position = 'popper', title = 'Choose an option', style, ...props }, ref) => {\n const mobile = useMobile();\n const { open, setOpen } = React.useContext(SelectContext);\n const viewport = useMobileSheetViewport(open && mobile);\n\n return (\n <SelectPrimitive.Portal>\n <div\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-[1100] [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined}\n style={{ '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` } as React.CSSProperties}\n >\n {mobile && open && (\n <div aria-hidden=\"true\" className=\"fixed inset-0 z-[1090] bg-black/25 backdrop-blur-[1px]\" />\n )}\n <SelectPrimitive.Content\n ref={ref}\n className={cn(\n 'relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none',\n mobile\n ? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'\n : 'z-50 max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\n className,\n )}\n position={mobile ? 'popper' : position}\n sideOffset={4}\n style={{\n ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),\n ...style,\n }}\n {...props}\n >\n {mobile && (\n <div role=\"presentation\" className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4\">\n <h2 className=\"text-base font-semibold text-foreground\">{title}</h2>\n <button\n type=\"button\"\n aria-label=\"Close options\"\n className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\n onPointerDown={(event) => event.stopPropagation()}\n onClick={() => setOpen(false)}\n >\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\n </button>\n </div>\n )}\n {!mobile && <SelectScrollUpButton />}\n <SelectPrimitive.Viewport\n className={cn(\n 'flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset',\n mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]',\n )}\n >\n {children}\n </SelectPrimitive.Viewport>\n {!mobile && <SelectScrollDownButton />}\n </SelectPrimitive.Content>\n </div>\n </SelectPrimitive.Portal>\n );\n});\nSelectContent.displayName = SelectPrimitive.Content.displayName;\n\nconst SelectLabel = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Label>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Label\n ref={ref}\n className={cn('px-option-x py-2 text-sm font-semibold text-foreground', className)}\n {...props}\n />\n));\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\n\nconst SelectItem = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\n>(({ className, children, ...props }, ref) => (\n <SelectPrimitive.Item\n ref={ref}\n className={cn(\n 'relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pr-9 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12',\n className,\n )}\n {...props}\n >\n <span className=\"absolute right-option-x flex h-4 w-4 items-center justify-center\">\n <SelectPrimitive.ItemIndicator>\n <Check className=\"h-4 w-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n));\nSelectItem.displayName = SelectPrimitive.Item.displayName;\n\nconst SelectSeparator = React.forwardRef<\n React.ElementRef<typeof SelectPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <SelectPrimitive.Separator\n ref={ref}\n className={cn('bg-border h-px', className)}\n {...props}\n />\n));\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n};\n"],"names":[],"mappings":";;;;;;;;;;AAWA;AAEA;AACE;AACA;AACA;;;AAEE;AACF;AAEA;AAOF;AAEA;AAEA;AAEA;AAoBA;AAEA;AAeA;AAEA;AAeA;AACE;AAEF;AAIE;AACA;;AAGA;AAcQ;;AAOF;AACA;;AAgCR;AACA;AAEA;AAUA;AAEA;AAqBA;AAEA;AAUA;;"}
@@ -29,7 +29,7 @@ function ResourceFilterPanel({ groups, draftValue, draftActiveCount, toggleOptio
29
29
  return (jsxs(Fragment, { children: [jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-gray-200 px-3 py-2", children: [jsx("span", { className: "text-sm font-semibold text-gray-900", children: "Filters" }), draftActiveCount > 0 && (jsx("button", { type: "button", onClick: clearDraft, className: "shrink-0 text-sm font-medium text-gray-600 hover:text-primary", children: "Clear all" }))] }), jsx("div", { className: "min-h-0 flex-1 space-y-3 overflow-y-auto p-3", children: groups.map((group) => {
30
30
  const activeValues = draftValue[group.id] ?? [];
31
31
  const allSelected = activeValues.length === group.options.length;
32
- return (jsxs("section", { className: "overflow-hidden rounded-[0.33em] border border-gray-200 bg-white", children: [jsxs("div", { className: "flex items-center justify-between border-b border-gray-200 px-4 py-2.5", children: [jsx("span", { className: "text-sm font-semibold text-gray-800", children: group.label }), jsx("button", { type: "button", onClick: () => toggleGroup(group.id), className: "text-sm font-medium text-gray-600 hover:text-primary", children: allSelected ? "Clear" : "Select all" })] }), group.options.map((option) => (jsxs("label", { className: "flex cursor-pointer items-center gap-3 px-4 py-2.5 text-sm text-gray-800 hover:bg-gray-50 active:bg-gray-100", children: [jsx("span", { className: "flex-1", children: option.label }), typeof option.count === "number" && (jsx("span", { className: "text-muted-foreground", children: option.count })), jsx(Checkbox, { checked: activeValues.includes(option.value), onCheckedChange: (checked) => toggleOption(group.id, option.value, checked === true) })] }, option.value)))] }, group.id));
32
+ return (jsxs("section", { className: "overflow-hidden rounded-control-lg border border-border bg-background", children: [jsxs("div", { className: "flex items-center justify-between border-b border-border px-4 py-2.5", children: [jsx("span", { className: "text-sm font-semibold text-foreground", children: group.label }), jsx("button", { type: "button", onClick: () => toggleGroup(group.id), className: "text-sm font-medium text-muted-foreground hover:text-primary", children: allSelected ? "Clear" : "Select all" })] }), jsx("div", { className: "flex flex-col gap-option-gap p-option-inset", children: group.options.map((option) => (jsxs("label", { className: "flex min-h-option-row cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-sm text-foreground transition-colors hover:bg-muted active:bg-muted", children: [jsx("span", { className: "flex-1", children: option.label }), typeof option.count === "number" && (jsx("span", { className: "text-muted-foreground", children: option.count })), jsx(Checkbox, { checked: activeValues.includes(option.value), onCheckedChange: (checked) => toggleOption(group.id, option.value, checked === true) })] }, option.value))) })] }, group.id));
33
33
  }) }), jsxs("div", { className: "flex items-center justify-end gap-2 border-t bg-white px-3 py-2.5", children: [jsx(Button, { variant: "outline", onClick: cancel, children: "Cancel" }), jsx(Button, { onClick: apply, children: "Apply" })] })] }));
34
34
  }
35
35
  function ResourceTable({ table, columns = table.columns, renderMobileRow, emptyState, noResultsState, rowLabelSingular, rowLabelPlural, className, contentClassName, listClassName, paginationClassName, toolbarStart, toolbarLeading, showSelectionRatio = true, selectionColumnClassName, rowSelectionCheckboxClassName, rowSelectionUnavailableClassName, getRowSelectionUnavailableReason, selectionIndicatorClassName, headerSelectionCheckboxClassName, onRowClick, getRowClassName, }) {
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","sources":["../../src/components/table.tsx"],"sourcesContent":["// REVIEW SNAPSHOT: bi-iom/IOM-Client/components/ui/resource-table.tsx\n// Source SHA-256: 9772e5fbce1e3adc3af1e8bf8184c4ef3546a0608cce43154aeecad56ca58fd6\n// Generated by playground/review/snapshot.mjs; import paths normalized for isolated review.\n\"use client\";\n\nimport { type ReactNode } from \"react\";\nimport {\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n ChevronUp,\n ChevronsUpDown,\n Filter,\n Search,\n X,\n} from \"lucide-react\";\n\nimport { Button } from \"@/components/button\";\nimport { Checkbox } from \"@/components/checkbox\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/popover\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/select\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/tooltip\";\nimport { cn } from \"@/utils\";\nimport type {\n ResourceFilterGroup,\n ResourceTableColumn,\n ResourceTableState,\n} from \"@/hooks/use-resource-table\";\n\nexport type { ResourceTableColumn } from \"@/hooks/use-resource-table\";\n\ntype ResourceEmptyState = {\n title: string;\n description?: ReactNode;\n action?: ReactNode;\n};\n\n// Sized up from the Checkbox default (size-4) and given a visible hover cue\n// — these sit in a dense, easy-to-miss leading column. UnselectableMark\n// matches the same size so a column of checkboxes stays aligned.\nconst SELECTION_CHECKBOX_CLASS =\n \"size-5 border-gray-400 hover:border-primary hover:ring-2 hover:ring-primary/15\";\n\n/**\n * Stands in for the selection checkbox on rows the caller marked\n * unselectable. A disabled Radix checkbox only fades — with no indicator\n * shown, it reads as barely-there. This is always visibly crossed out\n * instead, so \"you can't pick this row\" doesn't depend on noticing a\n * subtle opacity change.\n */\nfunction UnselectableMark({\n className,\n reason = \"Not selectable\",\n}: {\n className?: string;\n reason?: ReactNode;\n}) {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <span\n className={cn(\n \"flex size-5 shrink-0 items-center justify-center rounded-[4px] border border-gray-300 bg-gray-100\",\n className,\n )}\n role=\"img\"\n tabIndex={0}\n aria-label=\"Not selectable\"\n >\n <X\n className=\"size-3.5 text-gray-400\"\n strokeWidth={3}\n aria-hidden=\"true\"\n />\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"right\" sideOffset={6}>\n {reason}\n </TooltipContent>\n </Tooltip>\n );\n}\n\n\n\nfunction ResourceFilterPanel({\n groups,\n draftValue,\n draftActiveCount,\n toggleOption,\n toggleGroup,\n clearDraft,\n cancel,\n apply,\n}: {\n groups: ResourceFilterGroup[];\n draftValue: Record<string, string[]>;\n draftActiveCount: number;\n toggleOption: (\n groupId: string,\n optionValue: string,\n checked: boolean,\n ) => void;\n toggleGroup: (groupId: string) => void;\n clearDraft: () => void;\n cancel: () => void;\n apply: () => void;\n}) {\n return (\n <>\n <div className=\"flex items-center justify-between gap-3 border-b border-gray-200 px-3 py-2\">\n <span className=\"text-sm font-semibold text-gray-900\">Filters</span>\n {draftActiveCount > 0 && (\n <button\n type=\"button\"\n onClick={clearDraft}\n className=\"shrink-0 text-sm font-medium text-gray-600 hover:text-primary\"\n >\n Clear all\n </button>\n )}\n </div>\n\n <div className=\"min-h-0 flex-1 space-y-3 overflow-y-auto p-3\">\n {groups.map((group) => {\n const activeValues = draftValue[group.id] ?? [];\n const allSelected = activeValues.length === group.options.length;\n\n return (\n <section\n key={group.id}\n className=\"overflow-hidden rounded-[0.33em] border border-gray-200 bg-white\"\n >\n <div className=\"flex items-center justify-between border-b border-gray-200 px-4 py-2.5\">\n <span className=\"text-sm font-semibold text-gray-800\">\n {group.label}\n </span>\n <button\n type=\"button\"\n onClick={() => toggleGroup(group.id)}\n className=\"text-sm font-medium text-gray-600 hover:text-primary\"\n >\n {allSelected ? \"Clear\" : \"Select all\"}\n </button>\n </div>\n {group.options.map((option) => (\n <label\n key={option.value}\n className=\"flex cursor-pointer items-center gap-3 px-4 py-2.5 text-sm text-gray-800 hover:bg-gray-50 active:bg-gray-100\"\n >\n <span className=\"flex-1\">{option.label}</span>\n {typeof option.count === \"number\" && (\n <span className=\"text-muted-foreground\">\n {option.count}\n </span>\n )}\n <Checkbox\n checked={activeValues.includes(option.value)}\n onCheckedChange={(checked) =>\n toggleOption(group.id, option.value, checked === true)\n }\n />\n </label>\n ))}\n </section>\n );\n })}\n </div>\n\n <div className=\"flex items-center justify-end gap-2 border-t bg-white px-3 py-2.5\">\n <Button variant=\"outline\" onClick={cancel}>\n Cancel\n </Button>\n <Button onClick={apply}>Apply</Button>\n </div>\n </>\n );\n}\n\nexport function ResourceTable<TData>({\n table,\n columns = table.columns,\n renderMobileRow,\n emptyState,\n noResultsState,\n rowLabelSingular,\n rowLabelPlural,\n className,\n contentClassName,\n listClassName,\n paginationClassName,\n toolbarStart,\n toolbarLeading,\n showSelectionRatio = true,\n selectionColumnClassName,\n rowSelectionCheckboxClassName,\n rowSelectionUnavailableClassName,\n getRowSelectionUnavailableReason,\n selectionIndicatorClassName,\n headerSelectionCheckboxClassName,\n onRowClick,\n getRowClassName,\n}: {\n table: ResourceTableState<TData>;\n columns?: Array<ResourceTableColumn<TData>>;\n renderMobileRow: (row: TData) => ReactNode;\n emptyState: ResourceEmptyState;\n noResultsState?: ResourceEmptyState;\n rowLabelSingular: string;\n rowLabelPlural: string;\n className?: string;\n contentClassName?: string;\n listClassName?: string;\n paginationClassName?: string;\n toolbarStart?: ReactNode;\n toolbarLeading?: ReactNode;\n showSelectionRatio?: boolean;\n selectionColumnClassName?: string;\n rowSelectionCheckboxClassName?: string;\n rowSelectionUnavailableClassName?: string;\n getRowSelectionUnavailableReason?: (row: TData) => ReactNode;\n selectionIndicatorClassName?: string;\n headerSelectionCheckboxClassName?: string;\n onRowClick?: (row: TData) => void;\n getRowClassName?: (row: TData) => string | undefined;\n}) {\n const hasToolbar =\n !!toolbarStart || !!toolbarLeading || !!table.search || !!table.filters;\n const hasRows = table.pagedRows.length > 0;\n const hasAnyData = table.dataCount > 0;\n const hasDesktopTable = !!columns?.length;\n const resolvedEmptyState = hasAnyData\n ? (noResultsState ?? emptyState)\n : emptyState;\n\n const selection = table.selection;\n const selectablePageRows = selection\n ? table.pagedRows.filter(selection.isRowSelectable)\n : [];\n const headerCheckedState = selection\n ? selection.isAllPageSelected\n ? true\n : selectablePageRows.some((row) => selection.isSelected(row))\n ? \"indeterminate\"\n : false\n : false;\n const showSelectAllMatchingBanner =\n !!selection &&\n hasRows &&\n selection.isAllPageSelected &&\n selection.selectableMatchingCount > selection.selectablePageCount;\n const showAllMatchingSelectedBanner =\n !!selection &&\n hasRows &&\n selection.isAllMatchingSelected &&\n selection.selectableMatchingCount > selection.selectablePageCount;\n\n const renderHeaderCell = (column: ResourceTableColumn<TData>) => {\n const sortColumn = table.sort?.columns.find(\n (item) => item.id === column.id,\n );\n const isSortable =\n !!table.sort && column.sortable !== false && !!sortColumn;\n const isActive = table.sort?.column === column.id;\n const isDesc = isActive && table.sort?.direction === \"desc\";\n\n return (\n <th\n key={column.id}\n className={cn(\n \"px-5 py-3 font-medium\",\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n column.width,\n )}\n >\n {isSortable ? (\n <button\n type=\"button\"\n className={cn(\n \"inline-flex cursor-pointer items-center gap-1.5 text-left hover:text-gray-900\",\n column.align === \"center\" && \"justify-center\",\n column.align === \"right\" && \"justify-end\",\n isActive && \"text-primary\",\n )}\n onClick={() =>\n table.sort?.setSort(column.id, column.defaultSortDirection)\n }\n >\n {column.header}\n {isDesc ? (\n <ChevronDown className=\"h-3.5 w-3.5\" />\n ) : isActive ? (\n <ChevronUp className=\"h-3.5 w-3.5\" />\n ) : (\n <ChevronsUpDown className=\"text-muted-foreground/60 h-3.5 w-3.5\" />\n )}\n </button>\n ) : (\n column.header\n )}\n </th>\n );\n };\n\n return (\n <div className={cn(\"space-y-5\", className)}>\n {hasToolbar && (\n <div\n className={cn(\n \"flex flex-wrap items-center gap-2\",\n toolbarStart && \"min-w-0 lg:flex-nowrap\",\n )}\n >\n {toolbarStart && (\n <div className=\"min-w-0 max-w-full overflow-hidden\">\n {toolbarStart}\n </div>\n )}\n\n <div\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-2\",\n toolbarStart && \"w-full justify-end lg:ml-auto lg:w-auto\",\n )}\n >\n {table.search && (\n <div\n className={cn(\n \"relative min-w-0 flex-1\",\n toolbarStart ? \"lg:w-80 lg:flex-none\" : \"w-full max-w-xl\",\n )}\n >\n <Search className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-4 z-20 h-4 w-4 -translate-y-1/2\" />\n <input\n type=\"search\"\n value={table.search.value}\n onChange={(event) =>\n table.search?.setValue(event.target.value)\n }\n placeholder={table.search.placeholder}\n aria-label={table.search.ariaLabel}\n className=\"placeholder:text-muted-foreground/60 focus:border-primary h-11 w-full rounded-[0.33em] border border-gray-200 bg-white pr-4 pl-11 text-sm outline-none transition-colors focus:ring-2 focus:ring-primary/10\"\n />\n </div>\n )}\n\n {table.filters && (\n <Popover\n open={table.filters.open}\n onOpenChange={table.filters.setOpen}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className={cn(\n \"relative h-11 w-11 shrink-0 border-gray-200 bg-white text-gray-600 hover:text-primary\",\n table.filters.activeCount > 0 && \"text-primary\",\n )}\n aria-label=\"Filter results\"\n aria-expanded={table.filters.open}\n >\n <Filter />\n {table.filters.activeCount > 0 && (\n <span className=\"bg-primary text-primary-foreground absolute top-0 right-0 inline-flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-[11px] font-semibold\">\n {table.filters.activeCount}\n </span>\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n sideOffset={6}\n className=\"flex max-h-[70vh] w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-[0.33em] border border-gray-200 bg-white p-0 shadow-lg sm:w-[445px]\"\n >\n <ResourceFilterPanel\n groups={table.filters.groups}\n draftValue={table.filters.draftValue}\n draftActiveCount={table.filters.draftActiveCount}\n toggleOption={table.filters.toggleDraftOption}\n toggleGroup={table.filters.toggleDraftGroup}\n clearDraft={table.filters.clearDraft}\n cancel={table.filters.cancel}\n apply={table.filters.apply}\n />\n </PopoverContent>\n </Popover>\n )}\n\n {toolbarLeading}\n </div>\n </div>\n )}\n\n {hasRows ? (\n <div\n className={cn(\n \"overflow-hidden rounded-[0.33em] border border-gray-200 bg-white\",\n contentClassName,\n )}\n >\n {(showSelectAllMatchingBanner || showAllMatchingSelectedBanner) && (\n <div className=\"bg-primary/5 flex items-center justify-center gap-2 border-b border-gray-200 px-4 py-2 text-sm text-gray-700\">\n {showAllMatchingSelectedBanner ? (\n <>\n <span>\n All {selection!.selectableMatchingCount} matching rows are\n selected.\n </span>\n <button\n type=\"button\"\n onClick={selection!.clear}\n className=\"text-primary cursor-pointer font-medium hover:underline\"\n >\n Clear selection\n </button>\n </>\n ) : (\n <>\n <span>\n All {selection!.selectablePageCount} on this page are\n selected.\n </span>\n <button\n type=\"button\"\n onClick={selection!.selectAllMatching}\n className=\"text-primary cursor-pointer font-medium hover:underline\"\n >\n Select all {selection!.selectableMatchingCount} matching\n rows\n </button>\n </>\n )}\n </div>\n )}\n\n {hasDesktopTable && (\n <div className=\"hidden overflow-x-auto md:block\">\n <table className=\"w-full table-fixed border-collapse text-left\">\n <thead className=\"bg-gray-50 text-sm font-medium text-gray-700\">\n <tr className=\"border-b border-gray-200\">\n {selection && (\n <th\n className={cn(\n \"w-16 px-3 py-3\",\n selectionColumnClassName,\n )}\n >\n <div className=\"flex flex-col items-start gap-0.5\">\n <Checkbox\n checked={headerCheckedState}\n onCheckedChange={() =>\n selection.isAllPageSelected\n ? selection.deselectPage()\n : selection.selectPage()\n }\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n selectionIndicatorClassName,\n headerSelectionCheckboxClassName,\n )}\n aria-label=\"Select all rows on this page\"\n />\n {showSelectionRatio &&\n selection.selectablePageCount <\n table.pagedRows.length && (\n <span className=\"text-muted-foreground text-[10px] leading-tight font-normal\">\n {selection.selectablePageCount}/\n {table.pagedRows.length}\n </span>\n )}\n </div>\n </th>\n )}\n {columns.map(renderHeaderCell)}\n </tr>\n </thead>\n <tbody>\n {table.pagedRows.map((row) => {\n const rowSelectable =\n selection?.isRowSelectable(row) ?? true;\n return (\n <tr\n key={table.getRowId(row)}\n className={cn(\n \"group border-b border-gray-200 transition-colors last:border-b-0 hover:bg-primary/[0.035] focus-within:bg-primary/[0.035]\",\n onRowClick && \"cursor-pointer\",\n getRowClassName?.(row),\n )}\n onClick={onRowClick ? () => onRowClick(row) : undefined}\n >\n {selection && (\n <td\n className={cn(\n \"px-3 py-4\",\n selectionColumnClassName,\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {rowSelectable ? (\n <span className=\"flex size-5 items-center justify-center\">\n <Checkbox\n checked={selection.isSelected(row)}\n onCheckedChange={() => selection.toggle(row)}\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n rowSelectionCheckboxClassName,\n selectionIndicatorClassName,\n )}\n aria-label=\"Select row\"\n />\n </span>\n ) : (\n <UnselectableMark\n reason={getRowSelectionUnavailableReason?.(row)}\n className={cn(\n selectionIndicatorClassName,\n rowSelectionUnavailableClassName,\n )}\n />\n )}\n </td>\n )}\n {columns.map((column) => (\n <td\n key={column.id}\n className={cn(\n \"px-5 py-4\",\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n )}\n >\n {column.render(row)}\n </td>\n ))}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n\n <div\n className={cn(\n \"divide-y divide-gray-200\",\n hasDesktopTable && \"md:hidden\",\n listClassName,\n )}\n >\n {table.pagedRows.map((row) => {\n const rowSelectable = selection?.isRowSelectable(row) ?? true;\n return (\n <div key={table.getRowId(row)} className=\"flex items-start\">\n {selection && (\n <div\n className=\"flex shrink-0 items-center self-stretch pl-4\"\n onClick={(event) => event.stopPropagation()}\n >\n {rowSelectable ? (\n <span className=\"flex size-5 items-center justify-center\">\n <Checkbox\n checked={selection.isSelected(row)}\n onCheckedChange={() => selection.toggle(row)}\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n rowSelectionCheckboxClassName,\n selectionIndicatorClassName,\n )}\n aria-label=\"Select row\"\n />\n </span>\n ) : (\n <UnselectableMark\n reason={getRowSelectionUnavailableReason?.(row)}\n className={cn(\n selectionIndicatorClassName,\n rowSelectionUnavailableClassName,\n )}\n />\n )}\n </div>\n )}\n <div className=\"min-w-0 flex-1\">{renderMobileRow(row)}</div>\n </div>\n );\n })}\n </div>\n\n <div\n className={cn(\n \"flex flex-col items-center justify-between gap-3 border-t border-gray-200 px-5 py-4 sm:flex-row\",\n paginationClassName,\n )}\n >\n <p className=\"text-muted-foreground text-sm\">\n Showing {table.pageStart + 1} to {table.pageEnd} of{\" \"}\n {table.totalCount}{\" \"}\n {table.totalCount === 1 ? rowLabelSingular : rowLabelPlural}\n </p>\n <div className=\"flex flex-wrap items-center justify-center gap-3\">\n <label className=\"text-muted-foreground flex items-center gap-2 text-sm whitespace-nowrap\">\n Rows per page\n <Select\n value={String(table.pagination.pageSize)}\n onValueChange={(value) =>\n table.pagination.setPageSize(Number(value))\n }\n >\n <SelectTrigger className=\"w-20\" aria-label=\"Rows per page\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent align=\"end\">\n {table.pagination.pageSizeOptions.map((pageSize) => (\n <SelectItem key={pageSize} value={String(pageSize)}>\n {pageSize}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </label>\n\n {table.pageCount > 1 && (\n <div\n className=\"flex items-center gap-1\"\n aria-label=\"Pagination\"\n >\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={table.page === 1}\n onClick={() => table.pagination.setPage(table.page - 1)}\n aria-label=\"Previous page\"\n >\n <ChevronLeft />\n </Button>\n {Array.from(\n { length: table.pageCount },\n (_, index) => index + 1,\n )\n .filter(\n (page) =>\n page === 1 ||\n page === table.pageCount ||\n Math.abs(page - table.page) <= 1,\n )\n .map((page, index, pages) => (\n <span key={page} className=\"flex items-center gap-1\">\n {index > 0 && page - pages[index - 1] > 1 && (\n <span className=\"text-muted-foreground px-1\">\n ...\n </span>\n )}\n <Button\n variant={page === table.page ? \"outline\" : \"ghost\"}\n scheme={page === table.page ? \"primary\" : undefined}\n size=\"sm\"\n className=\"h-9 w-9\"\n onClick={() => table.pagination.setPage(page)}\n aria-label={`Page ${page}`}\n aria-current={\n page === table.page ? \"page\" : undefined\n }\n >\n {page}\n </Button>\n </span>\n ))}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={table.page === table.pageCount}\n onClick={() => table.pagination.setPage(table.page + 1)}\n aria-label=\"Next page\"\n >\n <ChevronRight />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"rounded-[0.33em] border border-dashed border-gray-300 bg-white px-6 py-12 text-center\">\n <p className=\"text-sm font-medium text-gray-700\">\n {resolvedEmptyState.title}\n </p>\n {resolvedEmptyState.description && (\n <p className=\"text-muted-foreground mt-1 text-sm\">\n {resolvedEmptyState.description}\n </p>\n )}\n {resolvedEmptyState.action && (\n <div className=\"mt-4\">{resolvedEmptyState.action}</div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport const Table = ResourceTable;\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AAiDA;AACA;AACA;AACA;AAGA;;;;;;AAMG;AACH;AAOE;AAwBF;AAIA;;;;AA2CU;AAsCF;AAWR;AAEM;;;AAkDJ;AACA;;AAEE;;AAGF;;;;;;AAMI;AACA;AACE;AACA;;AAEN;;AAGE;AACA;AACF;;AAGE;AACA;AAEF;;AAIE;;;AAKA;AAqCF;;AAuJ8B;;AAWJ;;;;AAyEV;;;;;;;;AAkKlB;AAEO;;"}
1
+ {"version":3,"file":"table.js","sources":["../../src/components/table.tsx"],"sourcesContent":["// REVIEW SNAPSHOT: bi-iom/IOM-Client/components/ui/resource-table.tsx\n// Source SHA-256: 9772e5fbce1e3adc3af1e8bf8184c4ef3546a0608cce43154aeecad56ca58fd6\n// Generated by playground/review/snapshot.mjs; import paths normalized for isolated review.\n\"use client\";\n\nimport { type ReactNode } from \"react\";\nimport {\n ChevronDown,\n ChevronLeft,\n ChevronRight,\n ChevronUp,\n ChevronsUpDown,\n Filter,\n Search,\n X,\n} from \"lucide-react\";\n\nimport { Button } from \"@/components/button\";\nimport { Checkbox } from \"@/components/checkbox\";\nimport {\n Popover,\n PopoverContent,\n PopoverTrigger,\n} from \"@/components/popover\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/select\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/tooltip\";\nimport { cn } from \"@/utils\";\nimport type {\n ResourceFilterGroup,\n ResourceTableColumn,\n ResourceTableState,\n} from \"@/hooks/use-resource-table\";\n\nexport type { ResourceTableColumn } from \"@/hooks/use-resource-table\";\n\ntype ResourceEmptyState = {\n title: string;\n description?: ReactNode;\n action?: ReactNode;\n};\n\n// Sized up from the Checkbox default (size-4) and given a visible hover cue\n// — these sit in a dense, easy-to-miss leading column. UnselectableMark\n// matches the same size so a column of checkboxes stays aligned.\nconst SELECTION_CHECKBOX_CLASS =\n \"size-5 border-gray-400 hover:border-primary hover:ring-2 hover:ring-primary/15\";\n\n/**\n * Stands in for the selection checkbox on rows the caller marked\n * unselectable. A disabled Radix checkbox only fades — with no indicator\n * shown, it reads as barely-there. This is always visibly crossed out\n * instead, so \"you can't pick this row\" doesn't depend on noticing a\n * subtle opacity change.\n */\nfunction UnselectableMark({\n className,\n reason = \"Not selectable\",\n}: {\n className?: string;\n reason?: ReactNode;\n}) {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <span\n className={cn(\n \"flex size-5 shrink-0 items-center justify-center rounded-[4px] border border-gray-300 bg-gray-100\",\n className,\n )}\n role=\"img\"\n tabIndex={0}\n aria-label=\"Not selectable\"\n >\n <X\n className=\"size-3.5 text-gray-400\"\n strokeWidth={3}\n aria-hidden=\"true\"\n />\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"right\" sideOffset={6}>\n {reason}\n </TooltipContent>\n </Tooltip>\n );\n}\n\n\n\nfunction ResourceFilterPanel({\n groups,\n draftValue,\n draftActiveCount,\n toggleOption,\n toggleGroup,\n clearDraft,\n cancel,\n apply,\n}: {\n groups: ResourceFilterGroup[];\n draftValue: Record<string, string[]>;\n draftActiveCount: number;\n toggleOption: (\n groupId: string,\n optionValue: string,\n checked: boolean,\n ) => void;\n toggleGroup: (groupId: string) => void;\n clearDraft: () => void;\n cancel: () => void;\n apply: () => void;\n}) {\n return (\n <>\n <div className=\"flex items-center justify-between gap-3 border-b border-gray-200 px-3 py-2\">\n <span className=\"text-sm font-semibold text-gray-900\">Filters</span>\n {draftActiveCount > 0 && (\n <button\n type=\"button\"\n onClick={clearDraft}\n className=\"shrink-0 text-sm font-medium text-gray-600 hover:text-primary\"\n >\n Clear all\n </button>\n )}\n </div>\n\n <div className=\"min-h-0 flex-1 space-y-3 overflow-y-auto p-3\">\n {groups.map((group) => {\n const activeValues = draftValue[group.id] ?? [];\n const allSelected = activeValues.length === group.options.length;\n\n return (\n <section\n key={group.id}\n className=\"overflow-hidden rounded-control-lg border border-border bg-background\"\n >\n <div className=\"flex items-center justify-between border-b border-border px-4 py-2.5\">\n <span className=\"text-sm font-semibold text-foreground\">\n {group.label}\n </span>\n <button\n type=\"button\"\n onClick={() => toggleGroup(group.id)}\n className=\"text-sm font-medium text-muted-foreground hover:text-primary\"\n >\n {allSelected ? \"Clear\" : \"Select all\"}\n </button>\n </div>\n <div className=\"flex flex-col gap-option-gap p-option-inset\">\n {group.options.map((option) => (\n <label\n key={option.value}\n className=\"flex min-h-option-row cursor-pointer items-center gap-3 rounded-control-sm px-option-x py-2 text-sm text-foreground transition-colors hover:bg-muted active:bg-muted\"\n >\n <span className=\"flex-1\">{option.label}</span>\n {typeof option.count === \"number\" && (\n <span className=\"text-muted-foreground\">\n {option.count}\n </span>\n )}\n <Checkbox\n checked={activeValues.includes(option.value)}\n onCheckedChange={(checked) =>\n toggleOption(group.id, option.value, checked === true)\n }\n />\n </label>\n ))}\n </div>\n </section>\n );\n })}\n </div>\n\n <div className=\"flex items-center justify-end gap-2 border-t bg-white px-3 py-2.5\">\n <Button variant=\"outline\" onClick={cancel}>\n Cancel\n </Button>\n <Button onClick={apply}>Apply</Button>\n </div>\n </>\n );\n}\n\nexport function ResourceTable<TData>({\n table,\n columns = table.columns,\n renderMobileRow,\n emptyState,\n noResultsState,\n rowLabelSingular,\n rowLabelPlural,\n className,\n contentClassName,\n listClassName,\n paginationClassName,\n toolbarStart,\n toolbarLeading,\n showSelectionRatio = true,\n selectionColumnClassName,\n rowSelectionCheckboxClassName,\n rowSelectionUnavailableClassName,\n getRowSelectionUnavailableReason,\n selectionIndicatorClassName,\n headerSelectionCheckboxClassName,\n onRowClick,\n getRowClassName,\n}: {\n table: ResourceTableState<TData>;\n columns?: Array<ResourceTableColumn<TData>>;\n renderMobileRow: (row: TData) => ReactNode;\n emptyState: ResourceEmptyState;\n noResultsState?: ResourceEmptyState;\n rowLabelSingular: string;\n rowLabelPlural: string;\n className?: string;\n contentClassName?: string;\n listClassName?: string;\n paginationClassName?: string;\n toolbarStart?: ReactNode;\n toolbarLeading?: ReactNode;\n showSelectionRatio?: boolean;\n selectionColumnClassName?: string;\n rowSelectionCheckboxClassName?: string;\n rowSelectionUnavailableClassName?: string;\n getRowSelectionUnavailableReason?: (row: TData) => ReactNode;\n selectionIndicatorClassName?: string;\n headerSelectionCheckboxClassName?: string;\n onRowClick?: (row: TData) => void;\n getRowClassName?: (row: TData) => string | undefined;\n}) {\n const hasToolbar =\n !!toolbarStart || !!toolbarLeading || !!table.search || !!table.filters;\n const hasRows = table.pagedRows.length > 0;\n const hasAnyData = table.dataCount > 0;\n const hasDesktopTable = !!columns?.length;\n const resolvedEmptyState = hasAnyData\n ? (noResultsState ?? emptyState)\n : emptyState;\n\n const selection = table.selection;\n const selectablePageRows = selection\n ? table.pagedRows.filter(selection.isRowSelectable)\n : [];\n const headerCheckedState = selection\n ? selection.isAllPageSelected\n ? true\n : selectablePageRows.some((row) => selection.isSelected(row))\n ? \"indeterminate\"\n : false\n : false;\n const showSelectAllMatchingBanner =\n !!selection &&\n hasRows &&\n selection.isAllPageSelected &&\n selection.selectableMatchingCount > selection.selectablePageCount;\n const showAllMatchingSelectedBanner =\n !!selection &&\n hasRows &&\n selection.isAllMatchingSelected &&\n selection.selectableMatchingCount > selection.selectablePageCount;\n\n const renderHeaderCell = (column: ResourceTableColumn<TData>) => {\n const sortColumn = table.sort?.columns.find(\n (item) => item.id === column.id,\n );\n const isSortable =\n !!table.sort && column.sortable !== false && !!sortColumn;\n const isActive = table.sort?.column === column.id;\n const isDesc = isActive && table.sort?.direction === \"desc\";\n\n return (\n <th\n key={column.id}\n className={cn(\n \"px-5 py-3 font-medium\",\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n column.width,\n )}\n >\n {isSortable ? (\n <button\n type=\"button\"\n className={cn(\n \"inline-flex cursor-pointer items-center gap-1.5 text-left hover:text-gray-900\",\n column.align === \"center\" && \"justify-center\",\n column.align === \"right\" && \"justify-end\",\n isActive && \"text-primary\",\n )}\n onClick={() =>\n table.sort?.setSort(column.id, column.defaultSortDirection)\n }\n >\n {column.header}\n {isDesc ? (\n <ChevronDown className=\"h-3.5 w-3.5\" />\n ) : isActive ? (\n <ChevronUp className=\"h-3.5 w-3.5\" />\n ) : (\n <ChevronsUpDown className=\"text-muted-foreground/60 h-3.5 w-3.5\" />\n )}\n </button>\n ) : (\n column.header\n )}\n </th>\n );\n };\n\n return (\n <div className={cn(\"space-y-5\", className)}>\n {hasToolbar && (\n <div\n className={cn(\n \"flex flex-wrap items-center gap-2\",\n toolbarStart && \"min-w-0 lg:flex-nowrap\",\n )}\n >\n {toolbarStart && (\n <div className=\"min-w-0 max-w-full overflow-hidden\">\n {toolbarStart}\n </div>\n )}\n\n <div\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-2\",\n toolbarStart && \"w-full justify-end lg:ml-auto lg:w-auto\",\n )}\n >\n {table.search && (\n <div\n className={cn(\n \"relative min-w-0 flex-1\",\n toolbarStart ? \"lg:w-80 lg:flex-none\" : \"w-full max-w-xl\",\n )}\n >\n <Search className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-4 z-20 h-4 w-4 -translate-y-1/2\" />\n <input\n type=\"search\"\n value={table.search.value}\n onChange={(event) =>\n table.search?.setValue(event.target.value)\n }\n placeholder={table.search.placeholder}\n aria-label={table.search.ariaLabel}\n className=\"placeholder:text-muted-foreground/60 focus:border-primary h-11 w-full rounded-[0.33em] border border-gray-200 bg-white pr-4 pl-11 text-sm outline-none transition-colors focus:ring-2 focus:ring-primary/10\"\n />\n </div>\n )}\n\n {table.filters && (\n <Popover\n open={table.filters.open}\n onOpenChange={table.filters.setOpen}\n >\n <PopoverTrigger asChild>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className={cn(\n \"relative h-11 w-11 shrink-0 border-gray-200 bg-white text-gray-600 hover:text-primary\",\n table.filters.activeCount > 0 && \"text-primary\",\n )}\n aria-label=\"Filter results\"\n aria-expanded={table.filters.open}\n >\n <Filter />\n {table.filters.activeCount > 0 && (\n <span className=\"bg-primary text-primary-foreground absolute top-0 right-0 inline-flex h-5 min-w-5 items-center justify-center rounded-full px-1 text-[11px] font-semibold\">\n {table.filters.activeCount}\n </span>\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n sideOffset={6}\n className=\"flex max-h-[70vh] w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-[0.33em] border border-gray-200 bg-white p-0 shadow-lg sm:w-[445px]\"\n >\n <ResourceFilterPanel\n groups={table.filters.groups}\n draftValue={table.filters.draftValue}\n draftActiveCount={table.filters.draftActiveCount}\n toggleOption={table.filters.toggleDraftOption}\n toggleGroup={table.filters.toggleDraftGroup}\n clearDraft={table.filters.clearDraft}\n cancel={table.filters.cancel}\n apply={table.filters.apply}\n />\n </PopoverContent>\n </Popover>\n )}\n\n {toolbarLeading}\n </div>\n </div>\n )}\n\n {hasRows ? (\n <div\n className={cn(\n \"overflow-hidden rounded-[0.33em] border border-gray-200 bg-white\",\n contentClassName,\n )}\n >\n {(showSelectAllMatchingBanner || showAllMatchingSelectedBanner) && (\n <div className=\"bg-primary/5 flex items-center justify-center gap-2 border-b border-gray-200 px-4 py-2 text-sm text-gray-700\">\n {showAllMatchingSelectedBanner ? (\n <>\n <span>\n All {selection!.selectableMatchingCount} matching rows are\n selected.\n </span>\n <button\n type=\"button\"\n onClick={selection!.clear}\n className=\"text-primary cursor-pointer font-medium hover:underline\"\n >\n Clear selection\n </button>\n </>\n ) : (\n <>\n <span>\n All {selection!.selectablePageCount} on this page are\n selected.\n </span>\n <button\n type=\"button\"\n onClick={selection!.selectAllMatching}\n className=\"text-primary cursor-pointer font-medium hover:underline\"\n >\n Select all {selection!.selectableMatchingCount} matching\n rows\n </button>\n </>\n )}\n </div>\n )}\n\n {hasDesktopTable && (\n <div className=\"hidden overflow-x-auto md:block\">\n <table className=\"w-full table-fixed border-collapse text-left\">\n <thead className=\"bg-gray-50 text-sm font-medium text-gray-700\">\n <tr className=\"border-b border-gray-200\">\n {selection && (\n <th\n className={cn(\n \"w-16 px-3 py-3\",\n selectionColumnClassName,\n )}\n >\n <div className=\"flex flex-col items-start gap-0.5\">\n <Checkbox\n checked={headerCheckedState}\n onCheckedChange={() =>\n selection.isAllPageSelected\n ? selection.deselectPage()\n : selection.selectPage()\n }\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n selectionIndicatorClassName,\n headerSelectionCheckboxClassName,\n )}\n aria-label=\"Select all rows on this page\"\n />\n {showSelectionRatio &&\n selection.selectablePageCount <\n table.pagedRows.length && (\n <span className=\"text-muted-foreground text-[10px] leading-tight font-normal\">\n {selection.selectablePageCount}/\n {table.pagedRows.length}\n </span>\n )}\n </div>\n </th>\n )}\n {columns.map(renderHeaderCell)}\n </tr>\n </thead>\n <tbody>\n {table.pagedRows.map((row) => {\n const rowSelectable =\n selection?.isRowSelectable(row) ?? true;\n return (\n <tr\n key={table.getRowId(row)}\n className={cn(\n \"group border-b border-gray-200 transition-colors last:border-b-0 hover:bg-primary/[0.035] focus-within:bg-primary/[0.035]\",\n onRowClick && \"cursor-pointer\",\n getRowClassName?.(row),\n )}\n onClick={onRowClick ? () => onRowClick(row) : undefined}\n >\n {selection && (\n <td\n className={cn(\n \"px-3 py-4\",\n selectionColumnClassName,\n )}\n onClick={(event) => event.stopPropagation()}\n >\n {rowSelectable ? (\n <span className=\"flex size-5 items-center justify-center\">\n <Checkbox\n checked={selection.isSelected(row)}\n onCheckedChange={() => selection.toggle(row)}\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n rowSelectionCheckboxClassName,\n selectionIndicatorClassName,\n )}\n aria-label=\"Select row\"\n />\n </span>\n ) : (\n <UnselectableMark\n reason={getRowSelectionUnavailableReason?.(row)}\n className={cn(\n selectionIndicatorClassName,\n rowSelectionUnavailableClassName,\n )}\n />\n )}\n </td>\n )}\n {columns.map((column) => (\n <td\n key={column.id}\n className={cn(\n \"px-5 py-4\",\n column.align === \"center\" && \"text-center\",\n column.align === \"right\" && \"text-right\",\n )}\n >\n {column.render(row)}\n </td>\n ))}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n )}\n\n <div\n className={cn(\n \"divide-y divide-gray-200\",\n hasDesktopTable && \"md:hidden\",\n listClassName,\n )}\n >\n {table.pagedRows.map((row) => {\n const rowSelectable = selection?.isRowSelectable(row) ?? true;\n return (\n <div key={table.getRowId(row)} className=\"flex items-start\">\n {selection && (\n <div\n className=\"flex shrink-0 items-center self-stretch pl-4\"\n onClick={(event) => event.stopPropagation()}\n >\n {rowSelectable ? (\n <span className=\"flex size-5 items-center justify-center\">\n <Checkbox\n checked={selection.isSelected(row)}\n onCheckedChange={() => selection.toggle(row)}\n className={cn(\n SELECTION_CHECKBOX_CLASS,\n rowSelectionCheckboxClassName,\n selectionIndicatorClassName,\n )}\n aria-label=\"Select row\"\n />\n </span>\n ) : (\n <UnselectableMark\n reason={getRowSelectionUnavailableReason?.(row)}\n className={cn(\n selectionIndicatorClassName,\n rowSelectionUnavailableClassName,\n )}\n />\n )}\n </div>\n )}\n <div className=\"min-w-0 flex-1\">{renderMobileRow(row)}</div>\n </div>\n );\n })}\n </div>\n\n <div\n className={cn(\n \"flex flex-col items-center justify-between gap-3 border-t border-gray-200 px-5 py-4 sm:flex-row\",\n paginationClassName,\n )}\n >\n <p className=\"text-muted-foreground text-sm\">\n Showing {table.pageStart + 1} to {table.pageEnd} of{\" \"}\n {table.totalCount}{\" \"}\n {table.totalCount === 1 ? rowLabelSingular : rowLabelPlural}\n </p>\n <div className=\"flex flex-wrap items-center justify-center gap-3\">\n <label className=\"text-muted-foreground flex items-center gap-2 text-sm whitespace-nowrap\">\n Rows per page\n <Select\n value={String(table.pagination.pageSize)}\n onValueChange={(value) =>\n table.pagination.setPageSize(Number(value))\n }\n >\n <SelectTrigger className=\"w-20\" aria-label=\"Rows per page\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent align=\"end\">\n {table.pagination.pageSizeOptions.map((pageSize) => (\n <SelectItem key={pageSize} value={String(pageSize)}>\n {pageSize}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </label>\n\n {table.pageCount > 1 && (\n <div\n className=\"flex items-center gap-1\"\n aria-label=\"Pagination\"\n >\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={table.page === 1}\n onClick={() => table.pagination.setPage(table.page - 1)}\n aria-label=\"Previous page\"\n >\n <ChevronLeft />\n </Button>\n {Array.from(\n { length: table.pageCount },\n (_, index) => index + 1,\n )\n .filter(\n (page) =>\n page === 1 ||\n page === table.pageCount ||\n Math.abs(page - table.page) <= 1,\n )\n .map((page, index, pages) => (\n <span key={page} className=\"flex items-center gap-1\">\n {index > 0 && page - pages[index - 1] > 1 && (\n <span className=\"text-muted-foreground px-1\">\n ...\n </span>\n )}\n <Button\n variant={page === table.page ? \"outline\" : \"ghost\"}\n scheme={page === table.page ? \"primary\" : undefined}\n size=\"sm\"\n className=\"h-9 w-9\"\n onClick={() => table.pagination.setPage(page)}\n aria-label={`Page ${page}`}\n aria-current={\n page === table.page ? \"page\" : undefined\n }\n >\n {page}\n </Button>\n </span>\n ))}\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={table.page === table.pageCount}\n onClick={() => table.pagination.setPage(table.page + 1)}\n aria-label=\"Next page\"\n >\n <ChevronRight />\n </Button>\n </div>\n )}\n </div>\n </div>\n </div>\n ) : (\n <div className=\"rounded-[0.33em] border border-dashed border-gray-300 bg-white px-6 py-12 text-center\">\n <p className=\"text-sm font-medium text-gray-700\">\n {resolvedEmptyState.title}\n </p>\n {resolvedEmptyState.description && (\n <p className=\"text-muted-foreground mt-1 text-sm\">\n {resolvedEmptyState.description}\n </p>\n )}\n {resolvedEmptyState.action && (\n <div className=\"mt-4\">{resolvedEmptyState.action}</div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport const Table = ResourceTable;\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AAiDA;AACA;AACA;AACA;AAGA;;;;;;AAMG;AACH;AAOE;AAwBF;AAIA;;;;AA2CU;AAwCF;AAWR;AAEM;;;AAkDJ;AACA;;AAEE;;AAGF;;;;;;AAMI;AACA;AACE;AACA;;AAEN;;AAGE;AACA;AACF;;AAGE;AACA;AAEF;;AAIE;;;AAKA;AAqCF;;AAuJ8B;;AAWJ;;;;AAyEV;;;;;;;;AAkKlB;AAEO;;"}
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export * from './components/dialog';
22
22
  export * from './components/dropdown-menu';
23
23
  export * from './components/file-upload';
24
24
  export * from './components/filter-chip';
25
+ export * from './components/option-list';
25
26
  export * from './components/select';
26
27
  export * from './components/label';
27
28
  export * from './components/form-field';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ export { Dialog, DialogBottomSheet, DialogClose, DialogContent, DialogDescriptio
19
19
  export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from './components/dropdown-menu.js';
20
20
  export { FileUpload } from './components/file-upload.js';
21
21
  export { FilterChip, FilterChipGroup } from './components/filter-chip.js';
22
+ export { CheckboxList, FilterMenu, optionListClassName, optionRowClassName } from './components/option-list.js';
22
23
  export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from './components/select.js';
23
24
  export { FieldLabel, Label } from './components/label.js';
24
25
  export { FormField } from './components/form-field.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterinternship/components",
3
- "version": "3.1.3",
3
+ "version": "3.2.0",
4
4
  "workspaces": [
5
5
  "playground"
6
6
  ],
@@ -106,6 +106,10 @@
106
106
  "import": "./dist/components/filter-chip.js",
107
107
  "types": "./dist/components/filter-chip.d.ts"
108
108
  },
109
+ "./option-list": {
110
+ "import": "./dist/components/option-list.js",
111
+ "types": "./dist/components/option-list.d.ts"
112
+ },
109
113
  "./select": {
110
114
  "import": "./dist/components/select.js",
111
115
  "types": "./dist/components/select.d.ts"