@alfadocs/ui-kit 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{balance-cell-renderer-BRWt3neo.js → balance-cell-renderer-BWm3knY9.js} +2 -2
- package/dist/_chunks/{balance-cell-renderer-BRWt3neo.js.map → balance-cell-renderer-BWm3knY9.js.map} +1 -1
- package/dist/_chunks/{chat-container-BZvQ3_yT.js → chat-container-Cm3SlR2p.js} +12 -12
- package/dist/_chunks/{chat-container-BZvQ3_yT.js.map → chat-container-Cm3SlR2p.js.map} +1 -1
- package/dist/_chunks/{chat-input-DsIrWM4f.js → chat-input-DreOPP8A.js} +36 -31
- package/dist/_chunks/chat-input-DreOPP8A.js.map +1 -0
- package/dist/_chunks/{dropdown-menu-JNo66A-j.js → dropdown-menu-Cw3EyPZv.js} +35 -31
- package/dist/_chunks/dropdown-menu-Cw3EyPZv.js.map +1 -0
- package/dist/_chunks/{leo-sidebar-Bh3dPDTQ.js → leo-sidebar-nbHib2D-.js} +97 -89
- package/dist/_chunks/leo-sidebar-nbHib2D-.js.map +1 -0
- package/dist/_chunks/{notification-tray-Bq-08ReD.js → notification-tray-B7U5YZYg.js} +5 -2
- package/dist/_chunks/notification-tray-B7U5YZYg.js.map +1 -0
- package/dist/_chunks/{patient-shell-DP54y6rc.js → patient-shell-7cXqIMFg.js} +2 -2
- package/dist/_chunks/{patient-shell-DP54y6rc.js.map → patient-shell-7cXqIMFg.js.map} +1 -1
- package/dist/_chunks/{popover-DvAtFOi-.js → popover-C3CTUsqh.js} +20 -16
- package/dist/_chunks/popover-C3CTUsqh.js.map +1 -0
- package/dist/_chunks/{privacy-lock-DS6QRo2N.js → privacy-lock-CQpgkLec.js} +23 -23
- package/dist/_chunks/{privacy-lock-DS6QRo2N.js.map → privacy-lock-CQpgkLec.js.map} +1 -1
- package/dist/_chunks/{suggestion-chip-6AB40rxz.js → suggestion-chip-BNJ2M8Os.js} +3 -3
- package/dist/_chunks/suggestion-chip-BNJ2M8Os.js.map +1 -0
- package/dist/_chunks/{theme-toggle-COHFwO2H.js → theme-toggle-BHiMMEQN.js} +2 -2
- package/dist/_chunks/{theme-toggle-COHFwO2H.js.map → theme-toggle-BHiMMEQN.js.map} +1 -1
- package/dist/_chunks/{workflow-map-DGJwVcO-.js → workflow-map-XeqHDFvp.js} +2 -2
- package/dist/_chunks/{workflow-map-DGJwVcO-.js.map → workflow-map-XeqHDFvp.js.map} +1 -1
- package/dist/agent-catalog.json +1 -1
- package/dist/components/chat-container/index.js +1 -1
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/index.js +1 -1
- package/dist/components/data-table/index.js +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -1
- package/dist/components/dropdown-menu/index.js +1 -1
- package/dist/components/notification-tray/index.js +1 -1
- package/dist/components/notification-tray/notification-tray.d.ts.map +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/privacy-lock/index.js +1 -1
- package/dist/components/suggestion-chip/index.js +1 -1
- package/dist/components/theme-toggle/index.js +1 -1
- package/dist/components/workflow/index.js +1 -1
- package/dist/index.js +12 -12
- package/dist/patterns/leo-assistant/index.js +1 -1
- package/dist/patterns/leo-assistant/leo-chat-surface.d.ts.map +1 -1
- package/dist/patterns/patient-shell/index.js +1 -1
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/chat-input-DsIrWM4f.js.map +0 -1
- package/dist/_chunks/dropdown-menu-JNo66A-j.js.map +0 -1
- package/dist/_chunks/leo-sidebar-Bh3dPDTQ.js.map +0 -1
- package/dist/_chunks/notification-tray-Bq-08ReD.js.map +0 -1
- package/dist/_chunks/popover-DvAtFOi-.js.map +0 -1
- package/dist/_chunks/suggestion-chip-6AB40rxz.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-container-BZvQ3_yT.js","sources":["../../src/components/chat-container/chat-container.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { ChevronDown } from 'lucide-react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport { FloatingActionButton } from '../floating-action-button/floating-action-button';\nimport { usePrefersReducedMotion } from '../../hooks';\n\nconst rootVariants = cva(\n 'ds:relative ds:flex ds:w-full ds:flex-col ds:overflow-hidden ds:bg-background',\n {\n variants: {\n density: {\n default: 'ds:gap-[var(--spacing-md)]',\n compact: 'ds:gap-[var(--spacing-sm)]',\n },\n },\n defaultVariants: { density: 'default' },\n },\n);\n\nconst scrollViewportVariants = cva(\n [\n 'ds:flex-1 ds:min-h-0 ds:overflow-y-auto ds:overflow-x-hidden',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:scroll-smooth ds:motion-reduce:scroll-auto ds:[.theme-accessible_&]:scroll-auto',\n // Edge fade — content near the scroll boundaries fades into the\n // container surface instead of clipping abruptly against the header\n // or composer, so avatars / bubbles don't look \"cut in half\" as they\n // pass the viewport edge. Fade width matches the viewport padding so\n // a row can slide fully behind the mask before disappearing.\n // Disabled under HCM (mask strips content), reduced motion (less\n // decoration when motion is off), and the accessible theme.\n 'ds:[mask-image:linear-gradient(to_bottom,transparent_0,black_var(--spacing-md),black_calc(100%-var(--spacing-md)),transparent_100%)]',\n 'ds:motion-reduce:[mask-image:none]',\n 'ds:[.theme-accessible_&]:[mask-image:none]',\n 'ds:forced-colors:[mask-image:none]',\n ].join(' '),\n);\n\nconst VIRTUALIZATION_THRESHOLD = 100;\n/** Pixel slack against the bottom edge that still counts as \"at bottom\". */\nconst BOTTOM_SLACK_PX = 48;\n\nexport interface ChatContainerHandle {\n scrollToBottom: (opts?: { smooth?: boolean }) => void;\n getScrollViewport: () => HTMLDivElement | null;\n}\n\nexport interface ChatContainerProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'children'>,\n VariantProps<typeof rootVariants> {\n /** Array of messages to render. When the array exceeds 100 items the\n * list is virtualised via @tanstack/react-virtual. */\n messages: Array<{ id: string; node: ReactNode }>;\n /** Composer slot pinned to the block-end. */\n composer?: ReactNode;\n /** Fires when the user's auto-scroll preference flips. */\n onAutoScrollChange?: (isAtBottom: boolean) => void;\n /**\n * When true, renders a \"scroll to latest\" FloatingActionButton in the\n * bottom-end of the scroll column whenever the user has scrolled\n * away from the newest message. Defaults to `false` because the\n * affordance is only useful in long-form chat surfaces (fullscreen\n * assistants, dedicated messaging views); in compact docks — e.g. the\n * Leo side-panel — conversations rarely exceed one screen and the FAB\n * just adds visual noise. Turn on for fullscreen chat surfaces.\n */\n showScrollToLatest?: boolean;\n}\n\nexport const ChatContainer = forwardRef<ChatContainerHandle, ChatContainerProps>(\n (\n {\n messages,\n composer,\n density = 'default',\n className,\n onAutoScrollChange,\n showScrollToLatest = false,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const sentinelRef = useRef<HTMLDivElement | null>(null);\n const [isAtBottom, setIsAtBottom] = useState(true);\n\n const prefersReducedMotion = usePrefersReducedMotion();\n\n const scrollToBottom = useCallback(\n (opts?: { smooth?: boolean }) => {\n const el = viewportRef.current;\n if (!el) return;\n const smooth = (opts?.smooth ?? true) && !prefersReducedMotion;\n el.scrollTo({ top: el.scrollHeight, behavior: smooth ? 'smooth' : 'auto' });\n },\n [prefersReducedMotion],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n scrollToBottom,\n getScrollViewport: () => viewportRef.current,\n }),\n [scrollToBottom],\n );\n\n /* ── Intersection observer: track \"at bottom\" via a sentinel ── */\n useEffect(() => {\n const root = viewportRef.current;\n const sentinel = sentinelRef.current;\n if (!root || !sentinel) return;\n const observer = new IntersectionObserver(\n (entries) => {\n const entry = entries[0];\n setIsAtBottom(entry.isIntersecting);\n onAutoScrollChange?.(entry.isIntersecting);\n },\n {\n root,\n // Fire when the sentinel is within BOTTOM_SLACK_PX of being visible.\n rootMargin: `0px 0px ${BOTTOM_SLACK_PX}px 0px`,\n threshold: 0,\n },\n );\n observer.observe(sentinel);\n return () => observer.disconnect();\n }, [onAutoScrollChange]);\n\n /* ── Auto-scroll on new messages when at bottom ── */\n const messagesLength = messages.length;\n useLayoutEffect(() => {\n // `smooth: false` — when we're already pinned to the bottom and a\n // new message appends, the user doesn't perceive any scroll motion\n // (the sentinel just slides a few px). But a smooth animation DOES\n // give the IntersectionObserver a window in which the sentinel is\n // temporarily outside the rootMargin zone — that's what causes the\n // scroll-to-latest FAB to flicker in and out on every new message.\n // Instant scroll settles in one frame; FAB state stays stable.\n // The user-initiated FAB click below still uses smooth because the\n // jump is large and the motion communicates the travel.\n if (isAtBottom) scrollToBottom({ smooth: false });\n // Intentionally watching only length — individual node updates (streaming)\n // are driven by their own scroll decisions.\n }, [messagesLength, isAtBottom, scrollToBottom]);\n\n const virtualized = messages.length > VIRTUALIZATION_THRESHOLD;\n\n const virtualizer = useVirtualizer({\n count: virtualized ? messages.length : 0,\n getScrollElement: () => viewportRef.current,\n estimateSize: () => 80,\n overscan: 6,\n getItemKey: (i) => messages[i]?.id ?? i,\n });\n\n return (\n <div className={rootVariants({ density, className })} data-component=\"chat-container\" {...rest}>\n {/* Scroll column wraps the viewport AND the FAB together so the\n FAB's absolute `bottom` is measured from the top of the\n composer (this wrapper's end edge), not from the root — which\n would drop the FAB inside the composer/suggestion-chip area. */}\n <div className=\"ds:relative ds:flex-1 ds:min-h-0 ds:flex ds:flex-col\">\n <div\n ref={viewportRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n aria-label={t('ui.chat.container')}\n tabIndex={0}\n className={scrollViewportVariants()}\n >\n {virtualized ? (\n <ol\n className=\"ds:relative ds:list-none ds:ps-0 ds:m-0\"\n // Inline style — permitted per 23-constraints\n // §Runtime-computed dimensions (virtualizer total size).\n style={{ blockSize: `${virtualizer.getTotalSize()}px` }}\n >\n {virtualizer.getVirtualItems().map((vi) => {\n const msg = messages[vi.index];\n if (!msg) return null;\n return (\n <li\n key={msg.id}\n data-index={vi.index}\n ref={virtualizer.measureElement}\n className=\"ds:absolute ds:start-0 ds:end-0 ds:top-0 ds:w-full\"\n // Inline style — permitted per 23-constraints\n // §Runtime-computed dimensions (virtualizer translateY).\n style={{ transform: `translateY(${vi.start}px)` }}\n >\n <div className=\"ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]\">\n {msg.node}\n </div>\n </li>\n );\n })}\n </ol>\n ) : (\n <ol className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:list-none ds:ps-0 ds:m-0\">\n {messages.map((m) => (\n <li key={m.id}>{m.node}</li>\n ))}\n </ol>\n )}\n <div ref={sentinelRef} aria-hidden=\"true\" className=\"ds:h-1 ds:w-full\" />\n </div>\n\n {showScrollToLatest && !isAtBottom ? (\n <div\n className={[\n 'ds:pointer-events-none ds:absolute ds:inset-inline-end-0',\n // `bottom` is measured from the bottom of the scroll\n // column (i.e. the top edge of the composer slot). A\n // small spacing-md gap keeps the FAB clear of the\n // divider border above the composer.\n 'ds:bottom-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n // Enter animation — fade + scale in from 95%. The FAB only\n // unmounts when the user returns to bottom, so an exit\n // animation isn't justified (abrupt disappearance reads as\n // \"task complete\" when they've scrolled back).\n 'ds:motion-safe:animate-in ds:motion-safe:fade-in-0 ds:motion-safe:zoom-in-95',\n 'ds:duration-[var(--animation-duration)] ds:ease-[var(--ease-out)]',\n ].join(' ')}\n >\n <div className=\"ds:pointer-events-auto\">\n <FloatingActionButton\n icon={<ChevronDown />}\n aria-label={t('ui.chat.scrollToLatest')}\n size=\"sm\"\n variant=\"secondary\"\n // `position=\"static\"` — the wrapper is already\n // absolutely-positioned. Without this, FAB's default\n // `bottom-end` variant applies `position: fixed` and\n // pins the button to the browser viewport corner,\n // escaping the container and appearing as an orphan\n // circle that stays put while the chat scrolls.\n position=\"static\"\n onClick={() => scrollToBottom({ smooth: true })}\n />\n </div>\n </div>\n ) : null}\n </div>\n\n {composer ? (\n <div className=\"ds:shrink-0 ds:border-t ds:border-border ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)] ds:bg-background\">\n {composer}\n </div>\n ) : null}\n </div>\n );\n },\n);\n\nChatContainer.displayName = 'ChatContainer';\n"],"names":["rootVariants","cva","scrollViewportVariants","VIRTUALIZATION_THRESHOLD","BOTTOM_SLACK_PX","ChatContainer","forwardRef","messages","composer","density","className","onAutoScrollChange","showScrollToLatest","rest","ref","t","useTranslation","viewportRef","useRef","sentinelRef","isAtBottom","setIsAtBottom","useState","prefersReducedMotion","usePrefersReducedMotion","scrollToBottom","useCallback","opts","el","smooth","useImperativeHandle","useEffect","root","sentinel","observer","entries","entry","messagesLength","useLayoutEffect","virtualized","virtualizer","useVirtualizer","i","_a","jsxs","jsx","vi","msg","m","FloatingActionButton","ChevronDown"],"mappings":";;;;;;;;AAkBA,MAAMA,IAAeC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IACX;AAAA,IAEF,iBAAiB,EAAE,SAAS,UAAA;AAAA,EAAU;AAE1C,GAEMC,IAAyBD;AAAA,EAC7B;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAA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WAAU,qKACZ,aACH,IACE;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AAEAxC,EAAc,cAAc;"}
|
|
1
|
+
{"version":3,"file":"chat-container-Cm3SlR2p.js","sources":["../../src/components/chat-container/chat-container.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { ChevronDown } from 'lucide-react';\nimport { useVirtualizer } from '@tanstack/react-virtual';\nimport { FloatingActionButton } from '../floating-action-button/floating-action-button';\nimport { usePrefersReducedMotion } from '../../hooks';\n\nconst rootVariants = cva(\n 'ds:relative ds:flex ds:w-full ds:flex-col ds:overflow-hidden ds:bg-background',\n {\n variants: {\n density: {\n default: 'ds:gap-[var(--spacing-md)]',\n compact: 'ds:gap-[var(--spacing-sm)]',\n },\n },\n defaultVariants: { density: 'default' },\n },\n);\n\nconst scrollViewportVariants = cva(\n [\n 'ds:flex-1 ds:min-h-0 ds:overflow-y-auto ds:overflow-x-hidden',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n 'ds:pt-[var(--spacing-md)] ds:pb-[var(--spacing-md)]',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:scroll-smooth ds:motion-reduce:scroll-auto ds:[.theme-accessible_&]:scroll-auto',\n // Edge fade — content near the scroll boundaries fades into the\n // container surface instead of clipping abruptly against the header\n // or composer, so avatars / bubbles don't look \"cut in half\" as they\n // pass the viewport edge. Fade width matches the viewport padding so\n // a row can slide fully behind the mask before disappearing.\n // Disabled under HCM (mask strips content), reduced motion (less\n // decoration when motion is off), and the accessible theme.\n 'ds:[mask-image:linear-gradient(to_bottom,transparent_0,black_var(--spacing-md),black_calc(100%-var(--spacing-md)),transparent_100%)]',\n 'ds:motion-reduce:[mask-image:none]',\n 'ds:[.theme-accessible_&]:[mask-image:none]',\n 'ds:forced-colors:[mask-image:none]',\n ].join(' '),\n);\n\nconst VIRTUALIZATION_THRESHOLD = 100;\n/** Pixel slack against the bottom edge that still counts as \"at bottom\". */\nconst BOTTOM_SLACK_PX = 48;\n\nexport interface ChatContainerHandle {\n scrollToBottom: (opts?: { smooth?: boolean }) => void;\n getScrollViewport: () => HTMLDivElement | null;\n}\n\nexport interface ChatContainerProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'children'>,\n VariantProps<typeof rootVariants> {\n /** Array of messages to render. When the array exceeds 100 items the\n * list is virtualised via @tanstack/react-virtual. */\n messages: Array<{ id: string; node: ReactNode }>;\n /** Composer slot pinned to the block-end. */\n composer?: ReactNode;\n /** Fires when the user's auto-scroll preference flips. */\n onAutoScrollChange?: (isAtBottom: boolean) => void;\n /**\n * When true, renders a \"scroll to latest\" FloatingActionButton in the\n * bottom-end of the scroll column whenever the user has scrolled\n * away from the newest message. Defaults to `false` because the\n * affordance is only useful in long-form chat surfaces (fullscreen\n * assistants, dedicated messaging views); in compact docks — e.g. the\n * Leo side-panel — conversations rarely exceed one screen and the FAB\n * just adds visual noise. Turn on for fullscreen chat surfaces.\n */\n showScrollToLatest?: boolean;\n}\n\nexport const ChatContainer = forwardRef<ChatContainerHandle, ChatContainerProps>(\n (\n {\n messages,\n composer,\n density = 'default',\n className,\n onAutoScrollChange,\n showScrollToLatest = false,\n ...rest\n },\n ref,\n ) => {\n const { t } = useTranslation();\n const viewportRef = useRef<HTMLDivElement | null>(null);\n const sentinelRef = useRef<HTMLDivElement | null>(null);\n const [isAtBottom, setIsAtBottom] = useState(true);\n\n const prefersReducedMotion = usePrefersReducedMotion();\n\n const scrollToBottom = useCallback(\n (opts?: { smooth?: boolean }) => {\n const el = viewportRef.current;\n if (!el) return;\n const smooth = (opts?.smooth ?? true) && !prefersReducedMotion;\n el.scrollTo({ top: el.scrollHeight, behavior: smooth ? 'smooth' : 'auto' });\n },\n [prefersReducedMotion],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n scrollToBottom,\n getScrollViewport: () => viewportRef.current,\n }),\n [scrollToBottom],\n );\n\n /* ── Intersection observer: track \"at bottom\" via a sentinel ── */\n useEffect(() => {\n const root = viewportRef.current;\n const sentinel = sentinelRef.current;\n if (!root || !sentinel) return;\n const observer = new IntersectionObserver(\n (entries) => {\n const entry = entries[0];\n setIsAtBottom(entry.isIntersecting);\n onAutoScrollChange?.(entry.isIntersecting);\n },\n {\n root,\n // Fire when the sentinel is within BOTTOM_SLACK_PX of being visible.\n rootMargin: `0px 0px ${BOTTOM_SLACK_PX}px 0px`,\n threshold: 0,\n },\n );\n observer.observe(sentinel);\n return () => observer.disconnect();\n }, [onAutoScrollChange]);\n\n /* ── Auto-scroll on new messages when at bottom ── */\n const messagesLength = messages.length;\n useLayoutEffect(() => {\n // `smooth: false` — when we're already pinned to the bottom and a\n // new message appends, the user doesn't perceive any scroll motion\n // (the sentinel just slides a few px). But a smooth animation DOES\n // give the IntersectionObserver a window in which the sentinel is\n // temporarily outside the rootMargin zone — that's what causes the\n // scroll-to-latest FAB to flicker in and out on every new message.\n // Instant scroll settles in one frame; FAB state stays stable.\n // The user-initiated FAB click below still uses smooth because the\n // jump is large and the motion communicates the travel.\n if (isAtBottom) scrollToBottom({ smooth: false });\n // Intentionally watching only length — individual node updates (streaming)\n // are driven by their own scroll decisions.\n }, [messagesLength, isAtBottom, scrollToBottom]);\n\n const virtualized = messages.length > VIRTUALIZATION_THRESHOLD;\n\n const virtualizer = useVirtualizer({\n count: virtualized ? messages.length : 0,\n getScrollElement: () => viewportRef.current,\n estimateSize: () => 80,\n overscan: 6,\n getItemKey: (i) => messages[i]?.id ?? i,\n });\n\n return (\n <div className={rootVariants({ density, className })} data-component=\"chat-container\" {...rest}>\n {/* Scroll column wraps the viewport AND the FAB together so the\n FAB's absolute `bottom` is measured from the top of the\n composer (this wrapper's end edge), not from the root — which\n would drop the FAB inside the composer/suggestion-chip area. */}\n <div className=\"ds:relative ds:flex-1 ds:min-h-0 ds:flex ds:flex-col\">\n <div\n ref={viewportRef}\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n aria-label={t('ui.chat.container')}\n tabIndex={0}\n className={scrollViewportVariants()}\n >\n {virtualized ? (\n <ol\n className=\"ds:relative ds:list-none ds:ps-0 ds:m-0\"\n // Inline style — permitted per 23-constraints\n // §Runtime-computed dimensions (virtualizer total size).\n style={{ blockSize: `${virtualizer.getTotalSize()}px` }}\n >\n {virtualizer.getVirtualItems().map((vi) => {\n const msg = messages[vi.index];\n if (!msg) return null;\n return (\n <li\n key={msg.id}\n data-index={vi.index}\n ref={virtualizer.measureElement}\n className=\"ds:absolute ds:start-0 ds:end-0 ds:top-0 ds:w-full\"\n // Inline style — permitted per 23-constraints\n // §Runtime-computed dimensions (virtualizer translateY).\n style={{ transform: `translateY(${vi.start}px)` }}\n >\n <div className=\"ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]\">\n {msg.node}\n </div>\n </li>\n );\n })}\n </ol>\n ) : (\n <ol className=\"ds:flex ds:flex-col ds:gap-[var(--spacing-sm)] ds:list-none ds:ps-0 ds:m-0\">\n {messages.map((m) => (\n <li key={m.id}>{m.node}</li>\n ))}\n </ol>\n )}\n <div ref={sentinelRef} aria-hidden=\"true\" className=\"ds:h-1 ds:w-full\" />\n </div>\n\n {showScrollToLatest && !isAtBottom ? (\n <div\n className={[\n 'ds:pointer-events-none ds:absolute ds:inset-inline-end-0',\n // `bottom` is measured from the bottom of the scroll\n // column (i.e. the top edge of the composer slot). A\n // small spacing-md gap keeps the FAB clear of the\n // divider border above the composer.\n 'ds:bottom-[var(--spacing-md)] ds:pe-[var(--spacing-md)]',\n // Enter animation — fade + scale in from 95%. The FAB only\n // unmounts when the user returns to bottom, so an exit\n // animation isn't justified (abrupt disappearance reads as\n // \"task complete\" when they've scrolled back).\n 'ds:motion-safe:animate-in ds:motion-safe:fade-in-0 ds:motion-safe:zoom-in-95',\n 'ds:duration-[var(--animation-duration)] ds:ease-[var(--ease-out)]',\n ].join(' ')}\n >\n <div className=\"ds:pointer-events-auto\">\n <FloatingActionButton\n icon={<ChevronDown />}\n aria-label={t('ui.chat.scrollToLatest')}\n size=\"sm\"\n variant=\"secondary\"\n // `position=\"static\"` — the wrapper is already\n // absolutely-positioned. Without this, FAB's default\n // `bottom-end` variant applies `position: fixed` and\n // pins the button to the browser viewport corner,\n // escaping the container and appearing as an orphan\n // circle that stays put while the chat scrolls.\n position=\"static\"\n onClick={() => scrollToBottom({ smooth: true })}\n />\n </div>\n </div>\n ) : null}\n </div>\n\n {composer ? (\n <div className=\"ds:shrink-0 ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-sm)] ds:bg-background\">\n {composer}\n </div>\n ) : null}\n </div>\n );\n },\n);\n\nChatContainer.displayName = 'ChatContainer';\n"],"names":["rootVariants","cva","scrollViewportVariants","VIRTUALIZATION_THRESHOLD","BOTTOM_SLACK_PX","ChatContainer","forwardRef","messages","composer","density","className","onAutoScrollChange","showScrollToLatest","rest","ref","t","useTranslation","viewportRef","useRef","sentinelRef","isAtBottom","setIsAtBottom","useState","prefersReducedMotion","usePrefersReducedMotion","scrollToBottom","useCallback","opts","el","smooth","useImperativeHandle","useEffect","root","sentinel","observer","entries","entry","messagesLength","useLayoutEffect","virtualized","virtualizer","useVirtualizer","i","_a","jsxs","jsx","vi","msg","m","FloatingActionButton","ChevronDown"],"mappings":";;;;;;;;AAkBA,MAAMA,IAAeC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IACX;AAAA,IAEF,iBAAiB,EAAE,SAAS,UAAA;AAAA,EAAU;AAE1C,GAEMC,IAAy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EAChD,CACF;AAAA,UAAA;AAAA,QAAA,IAEA;AAAA,MAAA,GACN;AAAA,MAECjB,IACC,gBAAAqC,EAAC,OAAA,EAAI,WAAU,wIACZ,aACH,IACE;AAAA,IAAA,GACN;AAAA,EAEJ;AACF;AAEAxC,EAAc,cAAc;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as he, useId as ve, useRef as
|
|
1
|
+
import { jsxs as c, jsx as s, Fragment as ge } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as he, useId as ve, useRef as w, useCallback as K, useState as be, useLayoutEffect as ye } from "react";
|
|
3
3
|
import { c as xe } from "./index-D2ZczOXr.js";
|
|
4
4
|
import { useTranslation as Ie } from "react-i18next";
|
|
5
5
|
import { I as W } from "./icon-button-Wnnde5lc.js";
|
|
@@ -20,13 +20,18 @@ const ze = [
|
|
|
20
20
|
key: "1miecu"
|
|
21
21
|
}
|
|
22
22
|
]
|
|
23
|
-
],
|
|
23
|
+
], we = Ce("paperclip", ze), Fe = xe(
|
|
24
24
|
[
|
|
25
25
|
"ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:w-full",
|
|
26
|
-
|
|
26
|
+
// Soft drop-shadow + transparent border replaces a flat
|
|
27
|
+
// `border-border` (grey-800 since the WCAG 1.4.11 bump). Border kept
|
|
28
|
+
// at 1px so the focus-within color override + forced-colors
|
|
29
|
+
// fallback still paint a visible edge.
|
|
30
|
+
"ds:rounded-[var(--radius-md)] ds:shadow-[var(--shadow-sm)] ds:border ds:border-transparent",
|
|
27
31
|
"ds:bg-background ds:focus-within:border-[color:var(--primary)]",
|
|
28
32
|
"ds:transition-[border-color] ds:duration-[var(--animation-duration)]",
|
|
29
|
-
"ds:motion-reduce:transition-none"
|
|
33
|
+
"ds:motion-reduce:transition-none",
|
|
34
|
+
"ds:forced-colors:border-[CanvasText]"
|
|
30
35
|
].join(" "),
|
|
31
36
|
{
|
|
32
37
|
variants: {
|
|
@@ -44,19 +49,19 @@ function He(u, p) {
|
|
|
44
49
|
try {
|
|
45
50
|
const f = new Intl.Segmenter(p, { granularity: "grapheme" });
|
|
46
51
|
let t = 0;
|
|
47
|
-
for (const
|
|
52
|
+
for (const F of f.segment(u)) t += 1;
|
|
48
53
|
return t;
|
|
49
54
|
} catch {
|
|
50
55
|
}
|
|
51
56
|
return Array.from(u).length;
|
|
52
57
|
}
|
|
53
|
-
const
|
|
58
|
+
const Te = he(
|
|
54
59
|
({
|
|
55
60
|
size: u = "md",
|
|
56
61
|
value: p,
|
|
57
62
|
defaultValue: f,
|
|
58
63
|
maxLength: t,
|
|
59
|
-
submitOnEnter:
|
|
64
|
+
submitOnEnter: F = !1,
|
|
60
65
|
minRows: y = 1,
|
|
61
66
|
maxRows: H = 8,
|
|
62
67
|
onSubmit: x,
|
|
@@ -64,7 +69,7 @@ const je = he(
|
|
|
64
69
|
accept: Y,
|
|
65
70
|
disabled: g,
|
|
66
71
|
toolbar: q,
|
|
67
|
-
label:
|
|
72
|
+
label: T,
|
|
68
73
|
placeholder: G,
|
|
69
74
|
className: J,
|
|
70
75
|
onChange: I,
|
|
@@ -74,17 +79,17 @@ const je = he(
|
|
|
74
79
|
id: L,
|
|
75
80
|
...O
|
|
76
81
|
}, i) => {
|
|
77
|
-
const { t: n, i18n: Q } = Ie(), U = ve(), h =
|
|
82
|
+
const { t: n, i18n: Q } = Ie(), U = ve(), h = w(!1), j = w(null), B = w(null), X = K(
|
|
78
83
|
(e) => {
|
|
79
|
-
|
|
84
|
+
B.current = e, typeof i == "function" ? i(e) : i && (i.current = e);
|
|
80
85
|
},
|
|
81
86
|
[i]
|
|
82
|
-
), o = p !== void 0, [Z,
|
|
87
|
+
), o = p !== void 0, [Z, M] = be(
|
|
83
88
|
String(f ?? "")
|
|
84
89
|
), a = o ? String(p) : Z, z = He(a, Q.language), v = typeof t == "number" && t > 0, D = v ? Math.max(0, t - z) : 0, A = v && z > t * 0.9, l = v && z >= t, E = K(() => {
|
|
85
|
-
const e =
|
|
90
|
+
const e = B.current;
|
|
86
91
|
if (!e) return;
|
|
87
|
-
const r = window.getComputedStyle(e), b = parseFloat(r.lineHeight) || 24,
|
|
92
|
+
const r = window.getComputedStyle(e), b = parseFloat(r.lineHeight) || 24, de = parseFloat(r.paddingTop) || 0, ce = parseFloat(r.paddingBottom) || 0, ue = parseFloat(r.borderTopWidth) || 0, pe = parseFloat(r.borderBottomWidth) || 0, R = de + ce + ue + pe, fe = b * y + R, _ = b * H + R;
|
|
88
93
|
e.style.height = "auto";
|
|
89
94
|
const me = Math.max(fe, Math.min(e.scrollHeight, _));
|
|
90
95
|
e.style.height = `${me}px`, e.style.overflowY = e.scrollHeight > _ ? "auto" : "hidden";
|
|
@@ -93,31 +98,31 @@ const je = he(
|
|
|
93
98
|
E();
|
|
94
99
|
}, [E, a]);
|
|
95
100
|
const ee = (e) => {
|
|
96
|
-
o ||
|
|
101
|
+
o || M(e.target.value), !h.current && (I == null || I(e));
|
|
97
102
|
}, te = (e) => {
|
|
98
103
|
h.current = !0, N == null || N(e);
|
|
99
104
|
}, se = (e) => {
|
|
100
105
|
h.current = !1, k == null || k(e);
|
|
101
106
|
}, re = (e) => e.nativeEvent.isComposing || e.keyCode === 229 || h.current, V = () => {
|
|
102
|
-
!a.trim() || g || l || (x == null || x(a), o ||
|
|
107
|
+
!a.trim() || g || l || (x == null || x(a), o || M(""));
|
|
103
108
|
}, ne = (e) => {
|
|
104
109
|
if (C == null || C(e), !e.defaultPrevented && !re(e) && e.key === "Enter") {
|
|
105
|
-
const r = e.metaKey || e.ctrlKey, b =
|
|
110
|
+
const r = e.metaKey || e.ctrlKey, b = F && !e.shiftKey;
|
|
106
111
|
(r || b) && (e.preventDefault(), V());
|
|
107
112
|
}
|
|
108
113
|
}, ae = () => {
|
|
109
114
|
var e;
|
|
110
|
-
(e =
|
|
115
|
+
(e = j.current) == null || e.click();
|
|
111
116
|
}, ie = (e) => {
|
|
112
117
|
e.target.files && e.target.files.length > 0 && (m == null || m(e.target.files)), e.target.value = "";
|
|
113
|
-
},
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */ s("label", { id: P, htmlFor:
|
|
118
|
+
}, d = L ?? U, P = `${d}-label`, S = v ? `${d}-counter` : void 0, $ = `${d}-hint`, oe = G ?? n("chat.input.placeholder"), le = T ?? n("chat.prompt");
|
|
119
|
+
return /* @__PURE__ */ c("div", { "data-component": "chat-input", className: Fe({ size: u, className: J }), children: [
|
|
120
|
+
/* @__PURE__ */ s("label", { id: P, htmlFor: d, className: T ? "type-label ds:ps-[var(--spacing-sm)] ds:pt-[var(--spacing-sm)]" : "ds:sr-only", children: le }),
|
|
116
121
|
/* @__PURE__ */ s(
|
|
117
122
|
"textarea",
|
|
118
123
|
{
|
|
119
124
|
ref: X,
|
|
120
|
-
id:
|
|
125
|
+
id: d,
|
|
121
126
|
value: o ? a : void 0,
|
|
122
127
|
defaultValue: o ? void 0 : f,
|
|
123
128
|
disabled: g,
|
|
@@ -149,12 +154,12 @@ const je = he(
|
|
|
149
154
|
...O
|
|
150
155
|
}
|
|
151
156
|
),
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
m ? /* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ c("div", { className: "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]", children: [
|
|
158
|
+
m ? /* @__PURE__ */ c(ge, { children: [
|
|
154
159
|
/* @__PURE__ */ s(
|
|
155
160
|
"input",
|
|
156
161
|
{
|
|
157
|
-
ref:
|
|
162
|
+
ref: j,
|
|
158
163
|
type: "file",
|
|
159
164
|
className: "ds:sr-only",
|
|
160
165
|
multiple: !0,
|
|
@@ -165,7 +170,7 @@ const je = he(
|
|
|
165
170
|
/* @__PURE__ */ s(
|
|
166
171
|
W,
|
|
167
172
|
{
|
|
168
|
-
icon: /* @__PURE__ */ s(
|
|
173
|
+
icon: /* @__PURE__ */ s(we, {}),
|
|
169
174
|
"aria-label": n("chat.input.attach"),
|
|
170
175
|
intent: "ghost",
|
|
171
176
|
size: "sm",
|
|
@@ -175,8 +180,8 @@ const je = he(
|
|
|
175
180
|
)
|
|
176
181
|
] }) : null,
|
|
177
182
|
q,
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
A ? /* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ c("div", { className: "ds:ms-auto ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]", children: [
|
|
184
|
+
A ? /* @__PURE__ */ c(
|
|
180
185
|
"span",
|
|
181
186
|
{
|
|
182
187
|
id: S,
|
|
@@ -214,8 +219,8 @@ const je = he(
|
|
|
214
219
|
] });
|
|
215
220
|
}
|
|
216
221
|
);
|
|
217
|
-
|
|
222
|
+
Te.displayName = "ChatInput";
|
|
218
223
|
export {
|
|
219
|
-
|
|
224
|
+
Te as C
|
|
220
225
|
};
|
|
221
|
-
//# sourceMappingURL=chat-input-
|
|
226
|
+
//# sourceMappingURL=chat-input-DreOPP8A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-input-DreOPP8A.js","sources":["../../node_modules/lucide-react/dist/esm/icons/paperclip.js","../../src/components/chat-input/chat-input.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.8.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst __iconNode = [\n [\n \"path\",\n {\n d: \"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551\",\n key: \"1miecu\"\n }\n ]\n];\nconst Paperclip = createLucideIcon(\"paperclip\", __iconNode);\n\nexport { __iconNode, Paperclip as default };\n//# sourceMappingURL=paperclip.js.map\n","import {\n forwardRef,\n useCallback,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type ChangeEvent,\n type CompositionEvent,\n type KeyboardEvent,\n type ReactNode,\n type TextareaHTMLAttributes,\n} from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { useTranslation } from 'react-i18next';\nimport { AlertCircle, Paperclip, Send } from 'lucide-react';\nimport { IconButton } from '../button';\n\nconst rootVariants = cva(\n [\n 'ds:flex ds:flex-col ds:gap-[var(--spacing-xs)] ds:w-full',\n // Soft drop-shadow + transparent border replaces a flat\n // `border-border` (grey-800 since the WCAG 1.4.11 bump). Border kept\n // at 1px so the focus-within color override + forced-colors\n // fallback still paint a visible edge.\n 'ds:rounded-[var(--radius-md)] ds:shadow-[var(--shadow-sm)] ds:border ds:border-transparent',\n 'ds:bg-background ds:focus-within:border-[color:var(--primary)]',\n 'ds:transition-[border-color] ds:duration-[var(--animation-duration)]',\n 'ds:motion-reduce:transition-none',\n 'ds:forced-colors:border-[CanvasText]',\n ].join(' '),\n {\n variants: {\n size: {\n sm: 'ds:text-[length:var(--font-size-sm)]',\n md: 'ds:text-[length:var(--font-size-base)]',\n lg: 'ds:text-[length:var(--font-size-lg)]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n);\n\ntype NativeTextareaProps = Omit<\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n 'size' | 'onSubmit' | 'children'\n>;\n\nexport interface ChatInputProps\n extends NativeTextareaProps,\n VariantProps<typeof rootVariants> {\n /** Invoked when the user submits (Cmd/Ctrl+Enter, or send button). */\n onSubmit?: (text: string) => void;\n /** Maximum allowed characters (grapheme clusters via Intl.Segmenter when available). */\n maxLength?: number;\n /** When true, plain Enter submits and Shift+Enter inserts a newline.\n * Default false (Enter inserts newline; Cmd/Ctrl+Enter submits). */\n submitOnEnter?: boolean;\n /** Minimum visible rows. Default 1. */\n minRows?: number;\n /** Maximum visible rows before the field scrolls. Default 8. */\n maxRows?: number;\n /** Optional attachment handler — when provided, renders the attachment button. */\n onAttach?: (files: FileList) => void;\n /** `accept` forwarded to the hidden file input. */\n accept?: string;\n /** Controls whether the textarea is disabled and submit is blocked. */\n disabled?: boolean;\n /** Optional slot placed between the textarea and the send button. */\n toolbar?: ReactNode;\n /** Visible label above the textarea. When omitted, a visually-hidden label is used. */\n label?: string;\n}\n\nfunction graphemeCount(value: string, locale: string): number {\n if (typeof Intl !== 'undefined' && typeof Intl.Segmenter === 'function') {\n try {\n const seg = new Intl.Segmenter(locale, { granularity: 'grapheme' });\n let n = 0;\n for (const _s of seg.segment(value)) n += 1;\n return n;\n } catch {\n /* fall through to Array.from */\n }\n }\n return Array.from(value).length;\n}\n\nexport const ChatInput = forwardRef<HTMLTextAreaElement, ChatInputProps>(\n (\n {\n size = 'md',\n value,\n defaultValue,\n maxLength,\n submitOnEnter = false,\n minRows = 1,\n maxRows = 8,\n onSubmit,\n onAttach,\n accept,\n disabled,\n toolbar,\n label,\n placeholder,\n className,\n onChange,\n onKeyDown,\n onCompositionStart,\n onCompositionEnd,\n id,\n ...rest\n },\n ref,\n ) => {\n const { t, i18n } = useTranslation();\n const textareaId = useId();\n const composingRef = useRef(false);\n const fileInputRef = useRef<HTMLInputElement>(null);\n const innerRef = useRef<HTMLTextAreaElement | null>(null);\n\n const setRefs = useCallback(\n (node: HTMLTextAreaElement | null) => {\n innerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref],\n );\n\n const isControlled = value !== undefined;\n const [internalValue, setInternalValue] = useState<string>(\n String(defaultValue ?? ''),\n );\n const currentValue = isControlled ? String(value) : internalValue;\n\n const count = graphemeCount(currentValue, i18n.language);\n const hasMaxLength = typeof maxLength === 'number' && maxLength > 0;\n const remaining = hasMaxLength ? Math.max(0, maxLength - count) : 0;\n const showCounter = hasMaxLength && count > (maxLength as number) * 0.9;\n const atLimit = hasMaxLength && count >= maxLength;\n\n /* Auto-grow — compute height from scrollHeight, clamped to [minRows, maxRows].\n Imperative `.style` write is permitted per 23-constraints\n §Runtime-computed dimensions (textarea scrollHeight measurement). */\n const resize = useCallback(() => {\n const el = innerRef.current;\n if (!el) return;\n const styles = window.getComputedStyle(el);\n const lineHeight = parseFloat(styles.lineHeight) || 24;\n const padTop = parseFloat(styles.paddingTop) || 0;\n const padBot = parseFloat(styles.paddingBottom) || 0;\n const borderTop = parseFloat(styles.borderTopWidth) || 0;\n const borderBot = parseFloat(styles.borderBottomWidth) || 0;\n const chrome = padTop + padBot + borderTop + borderBot;\n const minH = lineHeight * minRows + chrome;\n const maxH = lineHeight * maxRows + chrome;\n el.style.height = 'auto';\n const next = Math.max(minH, Math.min(el.scrollHeight, maxH));\n el.style.height = `${next}px`;\n el.style.overflowY = el.scrollHeight > maxH ? 'auto' : 'hidden';\n }, [minRows, maxRows]);\n\n useLayoutEffect(() => {\n resize();\n }, [resize, currentValue]);\n\n const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {\n if (!isControlled) setInternalValue(e.target.value);\n if (composingRef.current) return;\n onChange?.(e);\n };\n\n const handleCompositionStart = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = true;\n onCompositionStart?.(e);\n };\n const handleCompositionEnd = (e: CompositionEvent<HTMLTextAreaElement>) => {\n composingRef.current = false;\n onCompositionEnd?.(e);\n };\n\n const isIMEKey = (e: KeyboardEvent<HTMLTextAreaElement>) =>\n e.nativeEvent.isComposing || e.keyCode === 229 || composingRef.current;\n\n const submit = () => {\n const text = currentValue.trim();\n if (!text || disabled || atLimit) return;\n onSubmit?.(currentValue);\n if (!isControlled) setInternalValue('');\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {\n onKeyDown?.(e);\n if (e.defaultPrevented) return;\n if (isIMEKey(e)) return;\n\n if (e.key === 'Enter') {\n const explicitSubmit = e.metaKey || e.ctrlKey;\n const plainEnterSubmits = submitOnEnter && !e.shiftKey;\n if (explicitSubmit || plainEnterSubmits) {\n e.preventDefault();\n submit();\n }\n }\n };\n\n const handleAttach = () => {\n fileInputRef.current?.click();\n };\n\n const handleFilePick = (e: ChangeEvent<HTMLInputElement>) => {\n if (e.target.files && e.target.files.length > 0) {\n onAttach?.(e.target.files);\n }\n // Reset so picking the same file twice still fires change.\n e.target.value = '';\n };\n\n const effectiveId = id ?? textareaId;\n const labelId = `${effectiveId}-label`;\n const counterId = hasMaxLength ? `${effectiveId}-counter` : undefined;\n const hintId = `${effectiveId}-hint`;\n\n const resolvedPlaceholder =\n placeholder ?? t('chat.input.placeholder');\n const resolvedLabel = label ?? t('chat.prompt');\n\n return (\n <div data-component=\"chat-input\" className={rootVariants({ size, className })}>\n <label id={labelId} htmlFor={effectiveId} className={label ? 'type-label ds:ps-[var(--spacing-sm)] ds:pt-[var(--spacing-sm)]' : 'ds:sr-only'}>\n {resolvedLabel}\n </label>\n <textarea\n ref={setRefs}\n id={effectiveId}\n value={isControlled ? currentValue : undefined}\n defaultValue={!isControlled ? defaultValue : undefined}\n disabled={disabled}\n rows={minRows}\n maxLength={maxLength}\n placeholder={resolvedPlaceholder}\n aria-labelledby={labelId}\n aria-describedby={[counterId, hintId].filter(Boolean).join(' ') || undefined}\n aria-invalid={atLimit || undefined}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onCompositionStart={handleCompositionStart}\n onCompositionEnd={handleCompositionEnd}\n className={[\n 'ds:w-full ds:resize-none ds:bg-transparent',\n 'ds:ps-[var(--spacing-md)] ds:pe-[var(--spacing-md)] ds:pt-[var(--spacing-sm)] ds:pb-[var(--spacing-xs)]',\n 'ds:placeholder:text-[color:var(--muted-foreground)]',\n 'ds:leading-[var(--line-height-base)]',\n 'ds:disabled:opacity-50 ds:disabled:cursor-not-allowed',\n // Tokenised focus ring on the textarea itself — the 1px border\n // shift on the wrapper alone fails the 3px accessible-theme\n // requirement. See a11y-critical-fixes.mdx.\n 'ds:outline-none',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid',\n 'ds:focus-visible:outline-[color:var(--ring)] ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n ].join(' ')}\n {...rest}\n />\n <div className=\"ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]\">\n {onAttach ? (\n <>\n <input\n ref={fileInputRef}\n type=\"file\"\n className=\"ds:sr-only\"\n multiple\n accept={accept}\n onChange={handleFilePick}\n />\n <IconButton\n icon={<Paperclip />}\n aria-label={t('chat.input.attach')}\n intent=\"ghost\"\n size=\"sm\"\n onClick={handleAttach}\n disabled={disabled}\n />\n </>\n ) : null}\n {toolbar}\n <div className=\"ds:ms-auto ds:inline-flex ds:items-center ds:gap-[var(--spacing-sm)]\">\n {showCounter ? (\n <span\n id={counterId}\n aria-live=\"polite\"\n className={[\n 'ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]',\n 'type-meta ds:tabular-nums',\n atLimit\n ? 'ds:text-[color:var(--destructive)]'\n : 'ds:text-[color:var(--muted-foreground)]',\n ].join(' ')}\n >\n {atLimit ? (\n // Icon pairs with --destructive colour so the at-limit\n // state is not conveyed by hue alone (WCAG 1.4.1).\n <AlertCircle aria-hidden=\"true\" className=\"ds:size-3.5\" />\n ) : null}\n {t('chat.input.remaining', { count: remaining })}\n </span>\n ) : null}\n <span id={hintId} className=\"ds:sr-only\">\n {t('chat.input.sendHint')}\n </span>\n <IconButton\n icon={<Send />}\n aria-label={t('chat.send')}\n intent=\"primary\"\n size=\"sm\"\n disabled={disabled || !currentValue.trim() || atLimit}\n onClick={submit}\n aria-keyshortcuts=\"Meta+Enter Control+Enter\"\n />\n </div>\n </div>\n </div>\n );\n },\n);\n\nChatInput.displayName = 'ChatInput';\n"],"names":["__iconNode","Paperclip","createLucideIcon","rootVariants","cva","graphemeCount","value","locale","seg","n","_s","ChatInput","forwardRef","size","defaultValue","maxLength","submitOnEnter","minRows","maxRows","onSubmit","onAttach","accept","disabled","toolbar","label","placeholder","className","onChange","onKeyDown","onCompositionStart","onCompositionEnd","id","rest","ref","t","i18n","useTranslation","textareaId","useId","composingRef","useRef","fileInputRef","innerRef","setRefs","useCallback","node","isControlled","internalValue","setInternalValue","useState","currentValue","count","hasMaxLength","remaining","showCounter","atLimit","resize","el","styles","lineHeight","padTop","padBot","borderTop","borderBot","chrome","minH","maxH","next","useLayoutEffect","handleChange","handleCompositionStart","handleCompositionEnd","isIMEKey","submit","handleKeyDown","explicitSubmit","plainEnterSubmits","handleAttach","_a","handleFilePick","effectiveId","labelId","counterId","hintId","resolvedPlaceholder","resolvedLabel","jsxs","jsx","Fragment","IconButton","AlertCircle","Send"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,KAAa;AAAA,EACjB;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACX;AAAA,EACA;AACA,GACMC,KAAYC,GAAiB,aAAaF,EAAU,GCApDG,KAAeC;AAAA,EACnB;AAAA,IACE;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACA,KAAK,GAAG;AAAA,EACV;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,IACN;AAAA,IAEF,iBAAiB,EAAE,MAAM,KAAA;AAAA,EAAK;AAElC;AAiCA,SAASC,GAAcC,GAAeC,GAAwB;AAC5D,MAAI,OAAO,OAAS,OAAe,OAAO,KAAK,aAAc;AAC3D,QAAI;AACF,YAAMC,IAAM,IAAI,KAAK,UAAUD,GAAQ,EAAE,aAAa,YAAY;AAClE,UAAIE,IAAI;AACR,iBAAWC,KAAMF,EAAI,QAAQF,CAAK,EAAG,CAAAG,KAAK;AAC1C,aAAOA;AAAA,IACT,QAAQ;AAAA,IAER;AA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AAAA;AAAA;AAAA;AAAA,kBAGC,gBAAAgC,EAACG,IAAA,EAAY,eAAY,QAAO,WAAU,cAAA,CAAc;AAAA,oBACtD;AAAA,gBACHxD,EAAE,wBAAwB,EAAE,OAAOmB,GAAW;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA,IAE/C;AAAA,UACJ,gBAAAkC,EAAC,UAAK,IAAIJ,GAAQ,WAAU,cACzB,UAAAjD,EAAE,qBAAqB,GAC1B;AAAA,UACA,gBAAAqD;AAAA,YAACE;AAAA,YAAA;AAAA,cACC,wBAAOE,IAAA,EAAK;AAAA,cACZ,cAAYzD,EAAE,WAAW;AAAA,cACzB,QAAO;AAAA,cACP,MAAK;AAAA,cACL,UAAUZ,KAAY,CAAC4B,EAAa,UAAUK;AAAA,cAC9C,SAASkB;AAAA,cACT,qBAAkB;AAAA,YAAA;AAAA,UAAA;AAAA,QACpB,EAAA,CACF;AAAA,MAAA,EAAA,CACF;AAAA,IAAA,GACF;AAAA,EAEJ;AACF;AAEA9D,GAAU,cAAc;","x_google_ignoreList":[0]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as s, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as r } from "react";
|
|
3
|
-
import * as
|
|
3
|
+
import * as o from "@radix-ui/react-dropdown-menu";
|
|
4
4
|
import { c as l } from "./index-D2ZczOXr.js";
|
|
5
5
|
import { S as M } from "./separator-B4wXDLNC.js";
|
|
6
6
|
import { K as m } from "./kbd-8baVw3KU.js";
|
|
@@ -12,7 +12,11 @@ const u = l(
|
|
|
12
12
|
"ds:z-[var(--z-dropdown)]",
|
|
13
13
|
"ds:min-w-[8rem]",
|
|
14
14
|
"ds:rounded-[var(--radius-md)]",
|
|
15
|
-
|
|
15
|
+
// Border kept (transparent) so the forced-colors override below can
|
|
16
|
+
// repaint a visible edge in HCM. In normal modes the soft drop-shadow
|
|
17
|
+
// carries the edge cue; the heavy `--border` (grey-800 since WCAG
|
|
18
|
+
// 1.4.11 bump in 67fef8c) made the menu read as a charcoal box.
|
|
19
|
+
"ds:border ds:border-transparent",
|
|
16
20
|
"ds:bg-[var(--popover)] ds:text-[color:var(--popover-foreground)]",
|
|
17
21
|
"ds:shadow-[var(--shadow-lg)]",
|
|
18
22
|
"ds:p-[var(--spacing-xs)]",
|
|
@@ -50,28 +54,28 @@ const u = l(
|
|
|
50
54
|
"type-eyebrow ds:text-[color:var(--muted-foreground)]",
|
|
51
55
|
"ds:select-none"
|
|
52
56
|
].join(" ")
|
|
53
|
-
), f = "ds:inline-flex ds:items-center ds:justify-center ds:size-4 ds:shrink-0", h = ({ dir:
|
|
57
|
+
), f = "ds:inline-flex ds:items-center ds:justify-center ds:size-4 ds:shrink-0", h = ({ dir: d, ...e }) => {
|
|
54
58
|
const a = j();
|
|
55
|
-
return /* @__PURE__ */ s(
|
|
59
|
+
return /* @__PURE__ */ s(o.Root, { dir: d ?? a, ...e });
|
|
56
60
|
};
|
|
57
61
|
h.displayName = "DropdownMenu.Root";
|
|
58
|
-
const T =
|
|
59
|
-
|
|
62
|
+
const T = o.Trigger, G = o.Portal, P = o.Group, L = o.RadioGroup, v = r(({ className: d, sideOffset: e = 8, ...a }, n) => /* @__PURE__ */ s(o.Portal, { children: /* @__PURE__ */ s(
|
|
63
|
+
o.Content,
|
|
60
64
|
{
|
|
61
65
|
ref: n,
|
|
62
66
|
sideOffset: e,
|
|
63
|
-
className: u({ className:
|
|
67
|
+
className: u({ className: d }),
|
|
64
68
|
"data-component": "dropdown-menu",
|
|
65
69
|
...a
|
|
66
70
|
}
|
|
67
71
|
) }));
|
|
68
72
|
v.displayName = "DropdownMenu.Content";
|
|
69
73
|
const g = r(
|
|
70
|
-
({ className:
|
|
71
|
-
|
|
74
|
+
({ className: d, startIcon: e, endIcon: a, description: n, shortcut: i, children: D, ...z }, R) => /* @__PURE__ */ t(
|
|
75
|
+
o.Item,
|
|
72
76
|
{
|
|
73
77
|
ref: R,
|
|
74
|
-
className: c({ className:
|
|
78
|
+
className: c({ className: d }),
|
|
75
79
|
...z,
|
|
76
80
|
children: [
|
|
77
81
|
e ? /* @__PURE__ */ s(
|
|
@@ -99,27 +103,27 @@ const g = r(
|
|
|
99
103
|
)
|
|
100
104
|
);
|
|
101
105
|
g.displayName = "DropdownMenu.Item";
|
|
102
|
-
const x = r(({ className:
|
|
103
|
-
|
|
106
|
+
const x = r(({ className: d, children: e, ...a }, n) => /* @__PURE__ */ t(
|
|
107
|
+
o.CheckboxItem,
|
|
104
108
|
{
|
|
105
109
|
ref: n,
|
|
106
|
-
className: c({ className:
|
|
110
|
+
className: c({ className: d }),
|
|
107
111
|
...a,
|
|
108
112
|
children: [
|
|
109
|
-
/* @__PURE__ */ s("span", { className: f, children: /* @__PURE__ */ s(
|
|
113
|
+
/* @__PURE__ */ s("span", { className: f, children: /* @__PURE__ */ s(o.ItemIndicator, { children: /* @__PURE__ */ s(p, { "aria-hidden": !0, className: "ds:size-4" }) }) }),
|
|
110
114
|
/* @__PURE__ */ s("span", { className: "ds:flex-1 ds:truncate", children: e })
|
|
111
115
|
]
|
|
112
116
|
}
|
|
113
117
|
));
|
|
114
118
|
x.displayName = "DropdownMenu.CheckboxItem";
|
|
115
|
-
const K = L, N = r(({ className:
|
|
116
|
-
|
|
119
|
+
const K = L, N = r(({ className: d, children: e, ...a }, n) => /* @__PURE__ */ t(
|
|
120
|
+
o.RadioItem,
|
|
117
121
|
{
|
|
118
122
|
ref: n,
|
|
119
|
-
className: c({ className:
|
|
123
|
+
className: c({ className: d }),
|
|
120
124
|
...a,
|
|
121
125
|
children: [
|
|
122
|
-
/* @__PURE__ */ s("span", { className: f, children: /* @__PURE__ */ s(
|
|
126
|
+
/* @__PURE__ */ s("span", { className: f, children: /* @__PURE__ */ s(o.ItemIndicator, { children: /* @__PURE__ */ s(
|
|
123
127
|
p,
|
|
124
128
|
{
|
|
125
129
|
"aria-hidden": !0,
|
|
@@ -131,31 +135,31 @@ const K = L, N = r(({ className: o, children: e, ...a }, n) => /* @__PURE__ */ t
|
|
|
131
135
|
}
|
|
132
136
|
));
|
|
133
137
|
N.displayName = "DropdownMenu.RadioItem";
|
|
134
|
-
const b = r(({ className:
|
|
135
|
-
|
|
138
|
+
const b = r(({ className: d, ...e }, a) => /* @__PURE__ */ s(
|
|
139
|
+
o.Label,
|
|
136
140
|
{
|
|
137
141
|
ref: a,
|
|
138
|
-
className: I({ className:
|
|
142
|
+
className: I({ className: d }),
|
|
139
143
|
...e
|
|
140
144
|
}
|
|
141
145
|
));
|
|
142
146
|
b.displayName = "DropdownMenu.Label";
|
|
143
|
-
const w = r(({ className:
|
|
147
|
+
const w = r(({ className: d, ...e }, a) => /* @__PURE__ */ s(o.Separator, { ref: a, asChild: !0, ...e, children: /* @__PURE__ */ s(
|
|
144
148
|
M,
|
|
145
149
|
{
|
|
146
|
-
className: ["ds:my-[calc(var(--spacing-xs)/2)]",
|
|
150
|
+
className: ["ds:my-[calc(var(--spacing-xs)/2)]", d ?? ""].filter(Boolean).join(" ")
|
|
147
151
|
}
|
|
148
152
|
) }));
|
|
149
153
|
w.displayName = "DropdownMenu.Separator";
|
|
150
154
|
const y = r(
|
|
151
|
-
({ keys:
|
|
155
|
+
({ keys: d, separator: e = "none" }, a) => /* @__PURE__ */ s("span", { ref: a, className: "ds:ms-auto ds:ps-[var(--spacing-sm)]", children: /* @__PURE__ */ s(m, { keys: d, separator: e, size: "sm" }) })
|
|
152
156
|
);
|
|
153
157
|
y.displayName = "DropdownMenu.Shortcut";
|
|
154
|
-
const B =
|
|
155
|
-
|
|
158
|
+
const B = o.Sub, C = r(({ className: d, startIcon: e, children: a, ...n }, i) => /* @__PURE__ */ t(
|
|
159
|
+
o.SubTrigger,
|
|
156
160
|
{
|
|
157
161
|
ref: i,
|
|
158
|
-
className: c({ className:
|
|
162
|
+
className: c({ className: d }),
|
|
159
163
|
...n,
|
|
160
164
|
children: [
|
|
161
165
|
e ? /* @__PURE__ */ s(
|
|
@@ -178,12 +182,12 @@ const B = d.Sub, C = r(({ className: o, startIcon: e, children: a, ...n }, i) =>
|
|
|
178
182
|
}
|
|
179
183
|
));
|
|
180
184
|
C.displayName = "DropdownMenu.SubTrigger";
|
|
181
|
-
const S = r(({ className:
|
|
182
|
-
|
|
185
|
+
const S = r(({ className: d, ...e }, a) => /* @__PURE__ */ s(o.Portal, { children: /* @__PURE__ */ s(
|
|
186
|
+
o.SubContent,
|
|
183
187
|
{
|
|
184
188
|
ref: a,
|
|
185
189
|
sideOffset: 8,
|
|
186
|
-
className: u({ className:
|
|
190
|
+
className: u({ className: d }),
|
|
187
191
|
...e
|
|
188
192
|
}
|
|
189
193
|
) }));
|
|
@@ -208,4 +212,4 @@ const Q = {
|
|
|
208
212
|
export {
|
|
209
213
|
Q as D
|
|
210
214
|
};
|
|
211
|
-
//# sourceMappingURL=dropdown-menu-
|
|
215
|
+
//# sourceMappingURL=dropdown-menu-Cw3EyPZv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu-Cw3EyPZv.js","sources":["../../src/components/dropdown-menu/dropdown-menu.tsx"],"sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementRef,\n type ReactNode,\n} from 'react';\nimport * as RadixDropdownMenu from '@radix-ui/react-dropdown-menu';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { Check, ChevronRight } from 'lucide-react';\nimport { Separator as DsSeparator } from '../separator/separator';\nimport { Kbd, type KbdNamedKey } from '../kbd/kbd';\nimport { useDocumentDirection } from '../_shared/use-direction';\n\n/* ------------------------------------------------------------------ */\n/* CVA */\n/* ------------------------------------------------------------------ */\n\nconst contentVariants = cva(\n [\n 'ds:z-[var(--z-dropdown)]',\n 'ds:min-w-[8rem]',\n 'ds:rounded-[var(--radius-md)]',\n // Border kept (transparent) so the forced-colors override below can\n // repaint a visible edge in HCM. In normal modes the soft drop-shadow\n // carries the edge cue; the heavy `--border` (grey-800 since WCAG\n // 1.4.11 bump in 67fef8c) made the menu read as a charcoal box.\n 'ds:border ds:border-transparent',\n 'ds:bg-[var(--popover)] ds:text-[color:var(--popover-foreground)]',\n 'ds:shadow-[var(--shadow-lg)]',\n 'ds:p-[var(--spacing-xs)]',\n // Motion — gated on --animation-duration via Tailwind's animate-in\n // preset. motion-reduce disables via the no-preference query.\n 'ds:data-[state=open]:animate-in ds:data-[state=closed]:animate-out',\n 'ds:data-[state=open]:fade-in ds:data-[state=closed]:fade-out',\n 'ds:data-[state=open]:zoom-in-95 ds:data-[state=closed]:zoom-out-95',\n 'ds:motion-reduce:animate-none',\n 'ds:forced-colors:border-[CanvasText]',\n ].join(' '),\n);\n\nconst itemClasses = cva(\n [\n 'ds:relative ds:flex ds:items-center ds:gap-[var(--spacing-sm)]',\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]',\n 'ds:rounded-[var(--radius-sm)]',\n 'ds:min-h-[var(--min-target-size)]',\n 'ds:text-[length:var(--font-size-sm)] ds:text-[color:var(--foreground)]',\n 'ds:cursor-pointer ds:select-none ds:outline-none',\n // Highlighted + hover state\n 'ds:data-[highlighted]:bg-[color:var(--muted)]/40',\n 'ds:focus-visible:outline-[length:var(--focus-ring-width)]',\n 'ds:focus-visible:outline-solid ds:focus-visible:outline-[color:var(--ring)]',\n 'ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]',\n 'ds:forced-colors:focus-visible:outline-[CanvasText]',\n // Disabled\n 'ds:data-[disabled]:opacity-50 ds:data-[disabled]:cursor-not-allowed',\n 'ds:data-[disabled]:pointer-events-none',\n ].join(' '),\n);\n\nconst labelClasses = cva(\n [\n 'ds:ps-[var(--spacing-sm)] ds:pe-[var(--spacing-sm)]',\n 'ds:pt-[var(--spacing-xs)] ds:pb-[var(--spacing-xs)]',\n 'type-eyebrow ds:text-[color:var(--muted-foreground)]',\n 'ds:select-none',\n ].join(' '),\n);\n\nconst indicatorSlotClasses =\n 'ds:inline-flex ds:items-center ds:justify-center ds:size-4 ds:shrink-0';\n\n/* ------------------------------------------------------------------ */\n/* Root / Trigger / Portal */\n/* ------------------------------------------------------------------ */\n\ntype DropdownMenuRootProps = ComponentPropsWithoutRef<typeof RadixDropdownMenu.Root>;\n\nconst Root = ({ dir, ...props }: DropdownMenuRootProps) => {\n const autoDir = useDocumentDirection();\n return <RadixDropdownMenu.Root dir={dir ?? autoDir} {...props} />;\n};\nRoot.displayName = 'DropdownMenu.Root';\n\nconst Trigger = RadixDropdownMenu.Trigger;\nconst Portal = RadixDropdownMenu.Portal;\nconst RadixGroup = RadixDropdownMenu.Group;\nconst RadixRadioGroup = RadixDropdownMenu.RadioGroup;\n\n/* ------------------------------------------------------------------ */\n/* Content */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuContentProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.Content>,\n VariantProps<typeof contentVariants> {}\n\nconst Content = forwardRef<\n ElementRef<typeof RadixDropdownMenu.Content>,\n DropdownMenuContentProps\n>(({ className, sideOffset = 8, ...props }, ref) => (\n <RadixDropdownMenu.Portal>\n <RadixDropdownMenu.Content\n ref={ref}\n sideOffset={sideOffset}\n className={contentVariants({ className })}\n data-component=\"dropdown-menu\"\n {...props}\n />\n </RadixDropdownMenu.Portal>\n));\nContent.displayName = 'DropdownMenu.Content';\n\n/* ------------------------------------------------------------------ */\n/* Item */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuItemProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.Item> {\n startIcon?: ReactNode;\n endIcon?: ReactNode;\n description?: ReactNode;\n /** Convenience — renders a DS <Kbd keys={…}> on the inline-end. */\n shortcut?: Array<KbdNamedKey | string>;\n}\n\nconst Item = forwardRef<\n ElementRef<typeof RadixDropdownMenu.Item>,\n DropdownMenuItemProps\n>(\n (\n { className, startIcon, endIcon, description, shortcut, children, ...props },\n ref,\n ) => (\n <RadixDropdownMenu.Item\n ref={ref}\n className={itemClasses({ className })}\n {...props}\n >\n {startIcon ? (\n <span\n aria-hidden=\"true\"\n className=\"ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center\"\n >\n {startIcon}\n </span>\n ) : null}\n <span className=\"ds:flex-1 ds:flex ds:flex-col ds:min-w-0\">\n <span className=\"ds:truncate\">{children}</span>\n {description ? (\n <span className=\"type-meta ds:text-[color:var(--muted-foreground)] ds:truncate\">\n {description}\n </span>\n ) : null}\n </span>\n {shortcut ? (\n <span className=\"ds:ms-auto\">\n <Kbd keys={shortcut} size=\"sm\" />\n </span>\n ) : endIcon ? (\n <span\n aria-hidden=\"true\"\n className=\"ds:ms-auto ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center\"\n >\n {endIcon}\n </span>\n ) : null}\n </RadixDropdownMenu.Item>\n ),\n);\nItem.displayName = 'DropdownMenu.Item';\n\n/* ------------------------------------------------------------------ */\n/* CheckboxItem */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuCheckboxItemProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.CheckboxItem> {}\n\nconst CheckboxItem = forwardRef<\n ElementRef<typeof RadixDropdownMenu.CheckboxItem>,\n DropdownMenuCheckboxItemProps\n>(({ className, children, ...props }, ref) => (\n <RadixDropdownMenu.CheckboxItem\n ref={ref}\n className={itemClasses({ className })}\n {...props}\n >\n <span className={indicatorSlotClasses}>\n <RadixDropdownMenu.ItemIndicator>\n <Check aria-hidden className=\"ds:size-4\" />\n </RadixDropdownMenu.ItemIndicator>\n </span>\n <span className=\"ds:flex-1 ds:truncate\">{children}</span>\n </RadixDropdownMenu.CheckboxItem>\n));\nCheckboxItem.displayName = 'DropdownMenu.CheckboxItem';\n\n/* ------------------------------------------------------------------ */\n/* RadioGroup / RadioItem */\n/* ------------------------------------------------------------------ */\n\nconst RadioGroup = RadixRadioGroup;\n\nexport interface DropdownMenuRadioItemProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.RadioItem> {}\n\nconst RadioItem = forwardRef<\n ElementRef<typeof RadixDropdownMenu.RadioItem>,\n DropdownMenuRadioItemProps\n>(({ className, children, ...props }, ref) => (\n <RadixDropdownMenu.RadioItem\n ref={ref}\n className={itemClasses({ className })}\n {...props}\n >\n <span className={indicatorSlotClasses}>\n <RadixDropdownMenu.ItemIndicator>\n <Check\n aria-hidden\n className=\"ds:size-4 ds:text-[color:var(--accent)]\"\n />\n </RadixDropdownMenu.ItemIndicator>\n </span>\n <span className=\"ds:flex-1 ds:truncate\">{children}</span>\n </RadixDropdownMenu.RadioItem>\n));\nRadioItem.displayName = 'DropdownMenu.RadioItem';\n\n/* ------------------------------------------------------------------ */\n/* Label */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuLabelProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.Label> {}\n\nconst Label = forwardRef<\n ElementRef<typeof RadixDropdownMenu.Label>,\n DropdownMenuLabelProps\n>(({ className, ...props }, ref) => (\n <RadixDropdownMenu.Label\n ref={ref}\n className={labelClasses({ className })}\n {...props}\n />\n));\nLabel.displayName = 'DropdownMenu.Label';\n\n/* ------------------------------------------------------------------ */\n/* Separator */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuSeparatorProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.Separator> {}\n\nconst MenuSeparator = forwardRef<\n ElementRef<typeof RadixDropdownMenu.Separator>,\n DropdownMenuSeparatorProps\n>(({ className, ...props }, ref) => (\n <RadixDropdownMenu.Separator ref={ref} asChild {...props}>\n <DsSeparator\n className={['ds:my-[calc(var(--spacing-xs)/2)]', className ?? '']\n .filter(Boolean)\n .join(' ')}\n />\n </RadixDropdownMenu.Separator>\n));\nMenuSeparator.displayName = 'DropdownMenu.Separator';\n\n/* ------------------------------------------------------------------ */\n/* Shortcut — thin wrapper over DS Kbd for the right side of an Item */\n/* ------------------------------------------------------------------ */\n\nexport interface DropdownMenuShortcutProps {\n keys: Array<KbdNamedKey | string>;\n separator?: 'none' | 'plus' | 'then';\n}\n\nconst Shortcut = forwardRef<HTMLSpanElement, DropdownMenuShortcutProps>(\n ({ keys, separator = 'none' }, ref) => (\n <span ref={ref} className=\"ds:ms-auto ds:ps-[var(--spacing-sm)]\">\n <Kbd keys={keys} separator={separator} size=\"sm\" />\n </span>\n ),\n);\nShortcut.displayName = 'DropdownMenu.Shortcut';\n\n/* ------------------------------------------------------------------ */\n/* Sub-menu */\n/* ------------------------------------------------------------------ */\n\nconst Sub = RadixDropdownMenu.Sub;\n\nexport interface DropdownMenuSubTriggerProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.SubTrigger> {\n startIcon?: ReactNode;\n}\n\nconst SubTrigger = forwardRef<\n ElementRef<typeof RadixDropdownMenu.SubTrigger>,\n DropdownMenuSubTriggerProps\n>(({ className, startIcon, children, ...props }, ref) => (\n <RadixDropdownMenu.SubTrigger\n ref={ref}\n className={itemClasses({ className })}\n {...props}\n >\n {startIcon ? (\n <span\n aria-hidden=\"true\"\n className=\"ds:inline-flex ds:size-4 ds:shrink-0 ds:items-center ds:justify-center\"\n >\n {startIcon}\n </span>\n ) : null}\n <span className=\"ds:flex-1 ds:truncate\">{children}</span>\n <ChevronRight\n aria-hidden\n className=\"ds:ms-auto ds:size-4 ds:shrink-0 ds:rtl:-scale-x-100\"\n />\n </RadixDropdownMenu.SubTrigger>\n));\nSubTrigger.displayName = 'DropdownMenu.SubTrigger';\n\nexport interface DropdownMenuSubContentProps\n extends ComponentPropsWithoutRef<typeof RadixDropdownMenu.SubContent> {}\n\nconst SubContent = forwardRef<\n ElementRef<typeof RadixDropdownMenu.SubContent>,\n DropdownMenuSubContentProps\n>(({ className, ...props }, ref) => (\n <RadixDropdownMenu.Portal>\n <RadixDropdownMenu.SubContent\n ref={ref}\n sideOffset={8}\n className={contentVariants({ className })}\n {...props}\n />\n </RadixDropdownMenu.Portal>\n));\nSubContent.displayName = 'DropdownMenu.SubContent';\n\n/* ------------------------------------------------------------------ */\n/* Assembled namespace export */\n/* ------------------------------------------------------------------ */\n\nexport const DropdownMenu = {\n Root,\n Trigger,\n Portal,\n Content,\n Group: RadixGroup,\n Item,\n CheckboxItem,\n RadioGroup,\n RadioItem,\n Label,\n Separator: MenuSeparator,\n Shortcut,\n Sub,\n SubTrigger,\n SubContent,\n};\n"],"names":["contentVariants","cva","itemClasses","labelClasses","indicatorSlotClasses","Root","dir","props","autoDir","useDocumentDirection","jsx","RadixDropdownMenu","Trigger","Portal","RadixGroup","RadixRadioGroup","Content","forwardRef","className","sideOffset","ref","Item","startIcon","endIcon","description","shortcut","children","jsxs","Kbd","CheckboxItem","Check","RadioGroup","RadioItem","Label","MenuSeparator","DsSeparator","Shortcut","keys","separator","Sub","SubTrigger","ChevronRight","SubContent","DropdownMenu"],"mappings":";;;;;;;;;AAiBA,MAAMA,IAAkBC;AAAA,EACtB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACA,KAAK,GAAG;AACZ,GAEMC,IAAcD;AAAA,EAClB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAEA;AAAA,IACA;AAAA,EAAA,EACA,KAAK,GAAG;AACZ,GAEME,IAAeF;AAAA,EACnB;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,EACA,KAAK,GAAG;AACZ,GAEMG,IACJ,0EAQIC,IAAO,CAAC,EAAE,KAAAC,GAAK,GAAGC,QAAmC;AACzD,QAAMC,IAAUC,EAAA;AAChB,SAAO,gBAAAC,EAACC,EAAkB,MAAlB,EAAuB,KAAKL,KAAOE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