asterui 0.12.59 → 0.12.61
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/components/Cascader.js +147 -146
- package/dist/components/Cascader.js.map +1 -1
- package/dist/components/ContextMenu.js +90 -89
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/Drawer.js +66 -65
- package/dist/components/Drawer.js.map +1 -1
- package/dist/components/Dropdown.js +174 -173
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Mention.js +66 -65
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/Tour.js +83 -82
- package/dist/components/Tour.js.map +1 -1
- package/dist/components/Transfer.js +107 -103
- package/dist/components/Transfer.js.map +1 -1
- package/dist/components/TreeSelect.js +245 -244
- package/dist/components/TreeSelect.js.map +1 -1
- package/dist/providers/ConfigProvider.d.ts +8 -0
- package/dist/providers/ConfigProvider.js +31 -27
- package/dist/providers/ConfigProvider.js.map +1 -1
- package/package.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sources":["../../src/components/Dropdown.tsx"],"sourcesContent":["import React, { createContext, useContext, useId, useRef, useState, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react'\n\n// DaisyUI classes\nconst dDropdown = 'dropdown'\nconst dDropdownTop = 'dropdown-top'\nconst dDropdownBottom = 'dropdown-bottom'\nconst dDropdownLeft = 'dropdown-left'\nconst dDropdownRight = 'dropdown-right'\nconst dDropdownCenter = 'dropdown-center'\nconst dDropdownEnd = 'dropdown-end'\nconst dDropdownHover = 'dropdown-hover'\nconst dDropdownOpen = 'dropdown-open'\nconst dDropdownContent = 'dropdown-content'\nconst dMenu = 'menu'\n\n// Types for data-driven items prop\nexport type DropdownTriggerType = 'click' | 'hover' | 'contextMenu'\n\nexport interface DropdownMenuItem {\n key: string\n label: React.ReactNode\n icon?: React.ReactNode\n disabled?: boolean\n danger?: boolean\n onClick?: () => void\n children?: DropdownMenuItem[] // For submenus\n}\n\nexport interface DropdownMenuDivider {\n type: 'divider'\n key?: string\n}\n\nexport type DropdownMenuItemType = DropdownMenuItem | DropdownMenuDivider\n\ninterface DropdownContextValue {\n position?: 'top' | 'bottom' | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n menuId: string\n triggerId: string\n isOpen: boolean\n setIsOpen: (open: boolean) => void\n focusedIndex: number\n setFocusedIndex: (index: number) => void\n registerItem: (index: number, ref: HTMLElement | null, disabled: boolean) => void\n itemCount: number\n setItemCount: (count: number) => void\n disabled: boolean\n arrow: boolean\n closeDropdown: () => void\n getTestId: (suffix: string) => string | undefined\n}\n\nconst DropdownContext = createContext<DropdownContextValue | undefined>(undefined)\n\nfunction useDropdownContext() {\n const context = useContext(DropdownContext)\n if (!context) {\n throw new Error('Dropdown compound components must be used within Dropdown')\n }\n return context\n}\n\nexport interface DropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Trigger element and dropdown content (compound pattern) */\n children?: React.ReactNode\n /** Menu items (data-driven pattern) */\n items?: DropdownMenuItemType[]\n /** Trigger mode(s) for dropdown */\n trigger?: DropdownTriggerType[]\n position?: 'top' | 'bottom' | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n /** Controlled open state */\n open?: boolean\n /** Callback when open state changes */\n onOpenChange?: (open: boolean, info?: { source: 'trigger' | 'menu' }) => void\n /** Disable the dropdown */\n disabled?: boolean\n /** Show arrow pointing to trigger */\n arrow?: boolean | { pointAtCenter?: boolean }\n /** Delay before showing dropdown on hover (seconds) */\n mouseEnterDelay?: number\n /** Delay before hiding dropdown on mouse leave (seconds) */\n mouseLeaveDelay?: number\n /** Container for the dropdown menu */\n getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement\n /** Destroy dropdown when hidden */\n destroyOnHidden?: boolean\n /** Customize popup content */\n popupRender?: (menu: React.ReactNode) => React.ReactNode\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nexport interface DropdownTriggerProps {\n children: React.ReactNode\n className?: string\n}\n\nexport interface DropdownMenuProps {\n children?: React.ReactNode\n className?: string\n}\n\nexport interface DropdownItemProps {\n children?: React.ReactNode\n /** Icon to display before label */\n icon?: React.ReactNode\n /** Item label (alternative to children) */\n label?: React.ReactNode\n onClick?: () => void\n active?: boolean\n disabled?: boolean\n danger?: boolean\n className?: string\n /** @internal */\n _index?: number\n /** @internal */\n _key?: string\n}\n\nexport interface DropdownSubMenuProps {\n children: React.ReactNode\n /** Submenu title/label */\n title: React.ReactNode\n /** Icon to display before title */\n icon?: React.ReactNode\n disabled?: boolean\n className?: string\n /** @internal */\n _key?: string\n}\n\nexport interface DropdownDividerProps {\n className?: string\n}\n\nconst DropdownRoot = forwardRef<HTMLDivElement, DropdownProps>(function DropdownRoot(\n {\n children,\n items,\n trigger = ['click'],\n position = 'bottom',\n align = 'start',\n open: controlledOpen,\n onOpenChange,\n disabled = false,\n arrow = false,\n mouseEnterDelay = 0.15,\n mouseLeaveDelay = 0.1,\n getPopupContainer,\n destroyOnHidden = false,\n popupRender,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const menuId = useId()\n const triggerId = useId()\n const [internalOpen, setInternalOpen] = useState(false)\n const [focusedIndex, setFocusedIndex] = useState(-1)\n const [itemCount, setItemCount] = useState(0)\n const [shouldRender, setShouldRender] = useState(!destroyOnHidden)\n const itemRefs = useRef<Map<number, { ref: HTMLElement | null; disabled: boolean }>>(new Map())\n const dropdownRef = useRef<HTMLDivElement>(null)\n const hoverTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const triggers = trigger\n\n // Forward ref\n useImperativeHandle(ref, () => dropdownRef.current!, [])\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n // Use controlled or uncontrolled open state\n const isControlled = controlledOpen !== undefined\n const isOpen = isControlled ? controlledOpen : internalOpen\n\n const setIsOpen = useCallback((open: boolean, source: 'trigger' | 'menu' = 'trigger') => {\n if (disabled) return\n if (!isControlled) {\n setInternalOpen(open)\n }\n if (open) {\n setShouldRender(true)\n }\n onOpenChange?.(open, { source })\n }, [disabled, isControlled, onOpenChange])\n\n const closeDropdown = useCallback(() => {\n setIsOpen(false, 'menu')\n setFocusedIndex(-1)\n document.getElementById(triggerId)?.focus()\n }, [setIsOpen, triggerId])\n\n const registerItem = useCallback((index: number, ref: HTMLElement | null, itemDisabled: boolean) => {\n if (ref) {\n itemRefs.current.set(index, { ref, disabled: itemDisabled })\n } else {\n itemRefs.current.delete(index)\n }\n }, [])\n\n // Handle destroyOnHidden\n useEffect(() => {\n if (destroyOnHidden && !isOpen) {\n const timeout = setTimeout(() => setShouldRender(false), 300)\n return () => clearTimeout(timeout)\n }\n }, [isOpen, destroyOnHidden])\n\n // Close dropdown when clicking outside\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {\n setIsOpen(false, 'trigger')\n setFocusedIndex(-1)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen, setIsOpen])\n\n // Hover handlers with delay\n const handleMouseEnter = useCallback(() => {\n if (!triggers.includes('hover')) return\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n hoverTimeoutRef.current = setTimeout(() => {\n setIsOpen(true, 'trigger')\n }, mouseEnterDelay * 1000)\n }, [triggers, mouseEnterDelay, setIsOpen])\n\n const handleMouseLeave = useCallback(() => {\n if (!triggers.includes('hover')) return\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n hoverTimeoutRef.current = setTimeout(() => {\n setIsOpen(false, 'trigger')\n setFocusedIndex(-1)\n }, mouseLeaveDelay * 1000)\n }, [triggers, mouseLeaveDelay, setIsOpen])\n\n // Context menu handler\n const handleContextMenu = useCallback((event: React.MouseEvent) => {\n if (!triggers.includes('contextMenu')) return\n event.preventDefault()\n setIsOpen(true, 'trigger')\n }, [triggers, setIsOpen])\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n }\n }, [])\n\n const positionClasses: Record<string, string> = {\n top: dDropdownTop,\n bottom: dDropdownBottom,\n left: dDropdownLeft,\n right: dDropdownRight,\n }\n\n const alignClasses: Record<string, string> = {\n start: '',\n center: dDropdownCenter,\n end: dDropdownEnd,\n }\n\n const showArrow = typeof arrow === 'boolean' ? arrow : !!arrow\n\n const dropdownClasses = [\n dDropdown,\n positionClasses[position],\n alignClasses[align],\n triggers.includes('hover') && dDropdownHover,\n isOpen && dDropdownOpen,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Render items from data-driven prop\n const renderItems = () => {\n if (!items) return null\n return items.map((item, index) => {\n if ('type' in item && item.type === 'divider') {\n return <DropdownDivider key={item.key || `divider-${index}`} />\n }\n const menuItem = item as DropdownMenuItem\n if (menuItem.children && menuItem.children.length > 0) {\n return (\n <DropdownSubMenu\n key={menuItem.key}\n title={menuItem.label}\n icon={menuItem.icon}\n disabled={menuItem.disabled}\n >\n {menuItem.children.map((child) => (\n <DropdownItem\n key={child.key}\n icon={child.icon}\n disabled={child.disabled}\n danger={child.danger}\n onClick={child.onClick}\n >\n {child.label}\n </DropdownItem>\n ))}\n </DropdownSubMenu>\n )\n }\n return (\n <DropdownItem\n key={menuItem.key}\n icon={menuItem.icon}\n disabled={menuItem.disabled}\n danger={menuItem.danger}\n onClick={menuItem.onClick}\n >\n {menuItem.label}\n </DropdownItem>\n )\n })\n }\n\n // Determine content - either compound children or items-generated menu\n const menuContent = items ? (\n (shouldRender || !destroyOnHidden) && (\n <DropdownMenu>{renderItems()}</DropdownMenu>\n )\n ) : null\n\n const content = items ? (\n <>\n {React.Children.toArray(children).find(\n (child) => React.isValidElement(child) && child.type === DropdownTrigger\n )}\n {popupRender ? popupRender(menuContent) : menuContent}\n </>\n ) : (\n children\n )\n\n return (\n <DropdownContext.Provider\n value={{\n position,\n align,\n menuId,\n triggerId,\n isOpen,\n setIsOpen,\n focusedIndex,\n setFocusedIndex,\n registerItem,\n itemCount,\n setItemCount,\n disabled,\n arrow: showArrow,\n closeDropdown,\n getTestId,\n }}\n >\n <div\n ref={dropdownRef}\n className={dropdownClasses}\n data-state={isOpen ? 'open' : 'closed'}\n data-testid={testId}\n aria-disabled={disabled || undefined}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onContextMenu={handleContextMenu}\n {...rest}\n >\n {content}\n </div>\n </DropdownContext.Provider>\n )\n})\n\nfunction DropdownTrigger({ children, className = '' }: DropdownTriggerProps) {\n const { menuId, triggerId, isOpen, setIsOpen, setFocusedIndex, itemCount, disabled } = useDropdownContext()\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n switch (event.key) {\n case 'Enter':\n case ' ':\n case 'ArrowDown':\n event.preventDefault()\n setIsOpen(true)\n setFocusedIndex(0)\n break\n case 'ArrowUp':\n event.preventDefault()\n setIsOpen(true)\n setFocusedIndex(itemCount - 1)\n break\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n setFocusedIndex(-1)\n break\n }\n }\n\n const handleClick = () => {\n setIsOpen(!isOpen)\n if (!isOpen) {\n setFocusedIndex(0)\n }\n }\n\n // Clone the child element to add event handlers and ARIA attributes\n const child = React.Children.only(children) as React.ReactElement<\n React.HTMLAttributes<HTMLElement> & {\n onClick?: (e: React.MouseEvent) => void\n onKeyDown?: (e: React.KeyboardEvent) => void\n className?: string\n }\n >\n\n const childProps = child.props\n\n return React.cloneElement(child, {\n id: triggerId,\n tabIndex: disabled ? -1 : 0,\n 'aria-haspopup': 'menu' as const,\n 'aria-expanded': isOpen,\n 'aria-controls': menuId,\n onClick: (e: React.MouseEvent) => {\n handleClick()\n childProps.onClick?.(e)\n },\n onKeyDown: (e: React.KeyboardEvent) => {\n handleKeyDown(e)\n childProps.onKeyDown?.(e)\n },\n className: `${childProps.className || ''} ${className}`.trim(),\n })\n}\n\nfunction DropdownMenu({ children, className = '' }: DropdownMenuProps) {\n const { menuId, triggerId, isOpen, setIsOpen, focusedIndex, setFocusedIndex, setItemCount, arrow, position, getTestId } = useDropdownContext()\n const menuRef = useRef<HTMLUListElement>(null)\n\n // Count children and set item count\n const childArray = React.Children.toArray(children).filter(\n (child) => React.isValidElement(child) && (child.type === DropdownItem)\n )\n\n useEffect(() => {\n setItemCount(childArray.length)\n }, [childArray.length, setItemCount])\n\n // Focus management\n useEffect(() => {\n if (isOpen && focusedIndex >= 0 && menuRef.current) {\n const items = menuRef.current.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n const item = items[focusedIndex] as HTMLElement\n item?.focus()\n }\n }, [isOpen, focusedIndex])\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n const enabledItems = childArray.filter(\n (child) => React.isValidElement(child) && !(child.props as DropdownItemProps).disabled\n )\n const enabledCount = enabledItems.length\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n setFocusedIndex((focusedIndex + 1) % enabledCount)\n break\n case 'ArrowUp':\n event.preventDefault()\n setFocusedIndex((focusedIndex - 1 + enabledCount) % enabledCount)\n break\n case 'Home':\n event.preventDefault()\n setFocusedIndex(0)\n break\n case 'End':\n event.preventDefault()\n setFocusedIndex(enabledCount - 1)\n break\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n setFocusedIndex(-1)\n // Return focus to trigger\n document.getElementById(triggerId)?.focus()\n break\n case 'Tab':\n setIsOpen(false)\n setFocusedIndex(-1)\n break\n }\n }\n\n const menuClasses = [\n dDropdownContent,\n dMenu,\n 'bg-base-100',\n 'rounded-box',\n 'z-50',\n 'shadow',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Clone children to pass index and extract key\n const childrenWithIndex = React.Children.map(children, (child, index) => {\n if (React.isValidElement(child)) {\n const childKey = child.key != null ? String(child.key) : undefined\n if (child.type === DropdownItem) {\n return React.cloneElement(child as React.ReactElement<any>, { _index: index, _key: childKey })\n }\n if (child.type === DropdownSubMenu) {\n return React.cloneElement(child as React.ReactElement<any>, { _key: childKey })\n }\n }\n return child\n })\n\n // Arrow position classes based on menu position\n const arrowPositionClasses: Record<string, string> = {\n top: 'bottom-0 left-1/2 -translate-x-1/2 translate-y-full border-t-base-100 border-l-transparent border-r-transparent border-b-transparent',\n bottom: 'top-0 left-1/2 -translate-x-1/2 -translate-y-full border-b-base-100 border-l-transparent border-r-transparent border-t-transparent',\n left: 'right-0 top-1/2 -translate-y-1/2 translate-x-full border-l-base-100 border-t-transparent border-b-transparent border-r-transparent',\n right: 'left-0 top-1/2 -translate-y-1/2 -translate-x-full border-r-base-100 border-t-transparent border-b-transparent border-l-transparent',\n }\n\n const arrowElement = arrow ? (\n <span\n className={`absolute w-0 h-0 border-8 border-solid ${arrowPositionClasses[position || 'bottom']}`}\n aria-hidden=\"true\"\n />\n ) : null\n\n return (\n <ul\n ref={menuRef}\n id={menuId}\n role=\"menu\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n className={`${menuClasses} ${arrow ? 'relative' : ''}`}\n data-testid={getTestId('menu')}\n onKeyDown={handleKeyDown}\n >\n {arrowElement}\n {childrenWithIndex}\n </ul>\n )\n}\n\nfunction DropdownItem({\n children,\n icon,\n label,\n onClick,\n active = false,\n disabled = false,\n danger = false,\n className = '',\n _key,\n}: DropdownItemProps) {\n const { closeDropdown, getTestId } = useDropdownContext()\n const itemClasses = [active && 'active', disabled && 'disabled', className].filter(Boolean).join(' ')\n\n const handleClick = () => {\n if (!disabled) {\n onClick?.()\n closeDropdown()\n }\n }\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if ((event.key === 'Enter' || event.key === ' ') && !disabled) {\n event.preventDefault()\n handleClick()\n }\n }\n\n const content = label || children\n\n return (\n <li className={itemClasses} role=\"none\" data-key={_key} data-testid={_key ? getTestId(`item-${_key}`) : undefined}>\n <a\n role=\"menuitem\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n className={danger ? 'text-error' : ''}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {icon && <span className=\"mr-2 inline-flex items-center\">{icon}</span>}\n {content}\n </a>\n </li>\n )\n}\n\nfunction DropdownSubMenu({\n children,\n title,\n icon,\n disabled = false,\n className = '',\n _key,\n}: DropdownSubMenuProps) {\n const [isSubOpen, setIsSubOpen] = useState(false)\n const subMenuRef = useRef<HTMLLIElement>(null)\n const summaryRef = useRef<HTMLElement>(null)\n const subMenuListRef = useRef<HTMLUListElement>(null)\n const subMenuId = useId()\n\n const handleMouseEnter = () => {\n if (!disabled) setIsSubOpen(true)\n }\n\n const handleMouseLeave = () => {\n setIsSubOpen(false)\n }\n\n // Focus first item in submenu\n const focusFirstItem = () => {\n setTimeout(() => {\n const firstItem = subMenuListRef.current?.querySelector('[role=\"menuitem\"]:not([aria-disabled=\"true\"])') as HTMLElement\n firstItem?.focus()\n }, 0)\n }\n\n // Keyboard handler for summary (submenu trigger)\n const handleSummaryKeyDown = (event: React.KeyboardEvent) => {\n if (disabled) return\n\n switch (event.key) {\n case 'ArrowRight':\n case 'Enter':\n case ' ':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(true)\n focusFirstItem()\n break\n case 'ArrowLeft':\n case 'Escape':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(false)\n break\n }\n }\n\n // Keyboard handler for submenu items\n const handleSubMenuKeyDown = (event: React.KeyboardEvent) => {\n switch (event.key) {\n case 'ArrowLeft':\n case 'Escape':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(false)\n summaryRef.current?.focus()\n break\n case 'ArrowDown':\n event.preventDefault()\n event.stopPropagation()\n const items = subMenuListRef.current?.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n if (items) {\n const currentIndex = Array.from(items).findIndex(item => item === document.activeElement)\n const nextIndex = (currentIndex + 1) % items.length\n ;(items[nextIndex] as HTMLElement)?.focus()\n }\n break\n case 'ArrowUp':\n event.preventDefault()\n event.stopPropagation()\n const itemsUp = subMenuListRef.current?.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n if (itemsUp) {\n const currentIndexUp = Array.from(itemsUp).findIndex(item => item === document.activeElement)\n const prevIndex = (currentIndexUp - 1 + itemsUp.length) % itemsUp.length\n ;(itemsUp[prevIndex] as HTMLElement)?.focus()\n }\n break\n }\n }\n\n const itemClasses = [disabled && 'disabled', className].filter(Boolean).join(' ')\n\n return (\n <li\n ref={subMenuRef}\n className={itemClasses}\n role=\"none\"\n data-key={_key}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <details open={isSubOpen}>\n <summary\n ref={summaryRef}\n role=\"menuitem\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n aria-haspopup=\"menu\"\n aria-expanded={isSubOpen}\n aria-controls={subMenuId}\n onKeyDown={handleSummaryKeyDown}\n >\n {icon && <span className=\"mr-2 inline-flex items-center\">{icon}</span>}\n {title}\n </summary>\n <ul\n ref={subMenuListRef}\n id={subMenuId}\n className={`${dMenu} bg-base-100 rounded-box z-50 shadow`}\n role=\"menu\"\n aria-label={typeof title === 'string' ? title : undefined}\n onKeyDown={handleSubMenuKeyDown}\n >\n {children}\n </ul>\n </details>\n </li>\n )\n}\n\nfunction DropdownDivider({ className = '' }: DropdownDividerProps) {\n const classes = ['border-base-content/10', className].filter(Boolean).join(' ')\n return (\n <li role=\"separator\" className=\"my-1\">\n <hr className={classes} />\n </li>\n )\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Menu: DropdownMenu,\n Item: DropdownItem,\n SubMenu: DropdownSubMenu,\n Divider: DropdownDivider,\n})\n"],"names":["dDropdown","dDropdownTop","dDropdownBottom","dDropdownLeft","dDropdownRight","dDropdownCenter","dDropdownEnd","dDropdownHover","dDropdownOpen","dDropdownContent","dMenu","DropdownContext","createContext","useDropdownContext","context","useContext","DropdownRoot","forwardRef","children","items","trigger","position","align","controlledOpen","onOpenChange","disabled","arrow","mouseEnterDelay","mouseLeaveDelay","getPopupContainer","destroyOnHidden","popupRender","testId","className","rest","ref","menuId","useId","triggerId","internalOpen","setInternalOpen","useState","focusedIndex","setFocusedIndex","itemCount","setItemCount","shouldRender","setShouldRender","itemRefs","useRef","dropdownRef","hoverTimeoutRef","triggers","useImperativeHandle","getTestId","suffix","isControlled","isOpen","setIsOpen","useCallback","open","source","closeDropdown","registerItem","index","itemDisabled","useEffect","timeout","handleClickOutside","event","handleMouseEnter","handleMouseLeave","handleContextMenu","positionClasses","alignClasses","showArrow","dropdownClasses","menuContent","jsx","DropdownMenu","item","DropdownDivider","menuItem","DropdownSubMenu","child","DropdownItem","content","jsxs","Fragment","React","DropdownTrigger","handleKeyDown","handleClick","childProps","e","menuRef","childArray","enabledCount","menuClasses","childrenWithIndex","childKey","arrowElement","icon","label","onClick","active","danger","_key","itemClasses","title","isSubOpen","setIsSubOpen","subMenuRef","summaryRef","subMenuListRef","subMenuId","focusFirstItem","handleSummaryKeyDown","handleSubMenuKeyDown","nextIndex","itemsUp","prevIndex","classes","Dropdown"],"mappings":";;AAGA,MAAMA,KAAY,YACZC,KAAe,gBACfC,KAAkB,mBAClBC,KAAgB,iBAChBC,KAAiB,kBACjBC,KAAkB,mBAClBC,KAAe,gBACfC,KAAiB,kBACjBC,KAAgB,iBAChBC,KAAmB,oBACnBC,IAAQ,QAwCRC,IAAkBC,GAAgD,MAAS;AAEjF,SAASC,IAAqB;AAC5B,QAAMC,IAAUC,GAAWJ,CAAe;AAC1C,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,2DAA2D;AAE7E,SAAOA;AACT;AA4EA,MAAME,KAAeC,GAA0C,SAC7D;AAAA,EACE,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC,IAAU,CAAC,OAAO;AAAA,EAClB,UAAAC,IAAW;AAAA,EACX,OAAAC,IAAQ;AAAA,EACR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KoC;AAAA,YACL,IAAIC;AAAA,YACJ,WAAW,GAAGzG,CAAK;AAAA,YACnB,MAAK;AAAA,YACL,cAAY,OAAOmG,KAAU,WAAWA,IAAQ;AAAA,YAChD,WAAWS;AAAA,YAEV,UAAApG;AAAA,UAAA;AAAA,QAAA;AAAA,MACH,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAAS+D,EAAgB,EAAE,WAAAhD,IAAY,MAA4B;AACjE,QAAMyF,IAAU,CAAC,0BAA0BzF,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC9E,SACE,gBAAA6C,EAAC,MAAA,EAAG,MAAK,aAAY,WAAU,QAC7B,UAAA,gBAAAA,EAAC,MAAA,EAAG,WAAW4C,EAAA,CAAS,EAAA,CAC1B;AAEJ;AAEO,MAAMC,KAAW,OAAO,OAAO3G,IAAc;AAAA,EAClD,SAAS0E;AAAA,EACT,MAAMX;AAAA,EACN,MAAMM;AAAA,EACN,SAASF;AAAA,EACT,SAASF;AACX,CAAC;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sources":["../../src/components/Dropdown.tsx"],"sourcesContent":["import React, { createContext, useContext, useId, useRef, useState, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dDropdown = 'dropdown'\nconst dDropdownTop = 'dropdown-top'\nconst dDropdownBottom = 'dropdown-bottom'\nconst dDropdownLeft = 'dropdown-left'\nconst dDropdownRight = 'dropdown-right'\nconst dDropdownCenter = 'dropdown-center'\nconst dDropdownEnd = 'dropdown-end'\nconst dDropdownHover = 'dropdown-hover'\nconst dDropdownOpen = 'dropdown-open'\nconst dDropdownContent = 'dropdown-content'\nconst dMenu = 'menu'\n\n// Types for data-driven items prop\nexport type DropdownTriggerType = 'click' | 'hover' | 'contextMenu'\n\nexport interface DropdownMenuItem {\n key: string\n label: React.ReactNode\n icon?: React.ReactNode\n disabled?: boolean\n danger?: boolean\n onClick?: () => void\n children?: DropdownMenuItem[] // For submenus\n}\n\nexport interface DropdownMenuDivider {\n type: 'divider'\n key?: string\n}\n\nexport type DropdownMenuItemType = DropdownMenuItem | DropdownMenuDivider\n\ninterface DropdownContextValue {\n position?: 'top' | 'bottom' | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n menuId: string\n triggerId: string\n isOpen: boolean\n setIsOpen: (open: boolean) => void\n focusedIndex: number\n setFocusedIndex: (index: number) => void\n registerItem: (index: number, ref: HTMLElement | null, disabled: boolean) => void\n itemCount: number\n setItemCount: (count: number) => void\n disabled: boolean\n arrow: boolean\n closeDropdown: () => void\n getTestId: (suffix: string) => string | undefined\n}\n\nconst DropdownContext = createContext<DropdownContextValue | undefined>(undefined)\n\nfunction useDropdownContext() {\n const context = useContext(DropdownContext)\n if (!context) {\n throw new Error('Dropdown compound components must be used within Dropdown')\n }\n return context\n}\n\nexport interface DropdownProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** Trigger element and dropdown content (compound pattern) */\n children?: React.ReactNode\n /** Menu items (data-driven pattern) */\n items?: DropdownMenuItemType[]\n /** Trigger mode(s) for dropdown */\n trigger?: DropdownTriggerType[]\n position?: 'top' | 'bottom' | 'left' | 'right'\n align?: 'start' | 'center' | 'end'\n /** Controlled open state */\n open?: boolean\n /** Callback when open state changes */\n onOpenChange?: (open: boolean, info?: { source: 'trigger' | 'menu' }) => void\n /** Disable the dropdown */\n disabled?: boolean\n /** Show arrow pointing to trigger */\n arrow?: boolean | { pointAtCenter?: boolean }\n /** Delay before showing dropdown on hover (seconds) */\n mouseEnterDelay?: number\n /** Delay before hiding dropdown on mouse leave (seconds) */\n mouseLeaveDelay?: number\n /** Container for the dropdown menu */\n getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement\n /** Destroy dropdown when hidden */\n destroyOnHidden?: boolean\n /** Customize popup content */\n popupRender?: (menu: React.ReactNode) => React.ReactNode\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nexport interface DropdownTriggerProps {\n children: React.ReactNode\n className?: string\n}\n\nexport interface DropdownMenuProps {\n children?: React.ReactNode\n className?: string\n}\n\nexport interface DropdownItemProps {\n children?: React.ReactNode\n /** Icon to display before label */\n icon?: React.ReactNode\n /** Item label (alternative to children) */\n label?: React.ReactNode\n onClick?: () => void\n active?: boolean\n disabled?: boolean\n danger?: boolean\n className?: string\n /** @internal */\n _index?: number\n /** @internal */\n _key?: string\n}\n\nexport interface DropdownSubMenuProps {\n children: React.ReactNode\n /** Submenu title/label */\n title: React.ReactNode\n /** Icon to display before title */\n icon?: React.ReactNode\n disabled?: boolean\n className?: string\n /** @internal */\n _key?: string\n}\n\nexport interface DropdownDividerProps {\n className?: string\n}\n\nconst DropdownRoot = forwardRef<HTMLDivElement, DropdownProps>(function DropdownRoot(\n {\n children,\n items,\n trigger = ['click'],\n position = 'bottom',\n align = 'start',\n open: controlledOpen,\n onOpenChange,\n disabled,\n arrow = false,\n mouseEnterDelay = 0.15,\n mouseLeaveDelay = 0.1,\n getPopupContainer,\n destroyOnHidden = false,\n popupRender,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const { componentDisabled, getPopupContainer: globalGetPopupContainer } = useConfig()\n const effectiveDisabled = disabled ?? componentDisabled ?? false\n const effectiveGetPopupContainer = getPopupContainer ?? globalGetPopupContainer\n\n const menuId = useId()\n const triggerId = useId()\n const [internalOpen, setInternalOpen] = useState(false)\n const [focusedIndex, setFocusedIndex] = useState(-1)\n const [itemCount, setItemCount] = useState(0)\n const [shouldRender, setShouldRender] = useState(!destroyOnHidden)\n const itemRefs = useRef<Map<number, { ref: HTMLElement | null; disabled: boolean }>>(new Map())\n const dropdownRef = useRef<HTMLDivElement>(null)\n const hoverTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)\n\n const triggers = trigger\n\n // Forward ref\n useImperativeHandle(ref, () => dropdownRef.current!, [])\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n // Use controlled or uncontrolled open state\n const isControlled = controlledOpen !== undefined\n const isOpen = isControlled ? controlledOpen : internalOpen\n\n const setIsOpen = useCallback((open: boolean, source: 'trigger' | 'menu' = 'trigger') => {\n if (effectiveDisabled) return\n if (!isControlled) {\n setInternalOpen(open)\n }\n if (open) {\n setShouldRender(true)\n }\n onOpenChange?.(open, { source })\n }, [effectiveDisabled, isControlled, onOpenChange])\n\n const closeDropdown = useCallback(() => {\n setIsOpen(false, 'menu')\n setFocusedIndex(-1)\n document.getElementById(triggerId)?.focus()\n }, [setIsOpen, triggerId])\n\n const registerItem = useCallback((index: number, ref: HTMLElement | null, itemDisabled: boolean) => {\n if (ref) {\n itemRefs.current.set(index, { ref, disabled: itemDisabled })\n } else {\n itemRefs.current.delete(index)\n }\n }, [])\n\n // Handle destroyOnHidden\n useEffect(() => {\n if (destroyOnHidden && !isOpen) {\n const timeout = setTimeout(() => setShouldRender(false), 300)\n return () => clearTimeout(timeout)\n }\n }, [isOpen, destroyOnHidden])\n\n // Close dropdown when clicking outside\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {\n setIsOpen(false, 'trigger')\n setFocusedIndex(-1)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen, setIsOpen])\n\n // Hover handlers with delay\n const handleMouseEnter = useCallback(() => {\n if (!triggers.includes('hover')) return\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n hoverTimeoutRef.current = setTimeout(() => {\n setIsOpen(true, 'trigger')\n }, mouseEnterDelay * 1000)\n }, [triggers, mouseEnterDelay, setIsOpen])\n\n const handleMouseLeave = useCallback(() => {\n if (!triggers.includes('hover')) return\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n hoverTimeoutRef.current = setTimeout(() => {\n setIsOpen(false, 'trigger')\n setFocusedIndex(-1)\n }, mouseLeaveDelay * 1000)\n }, [triggers, mouseLeaveDelay, setIsOpen])\n\n // Context menu handler\n const handleContextMenu = useCallback((event: React.MouseEvent) => {\n if (!triggers.includes('contextMenu')) return\n event.preventDefault()\n setIsOpen(true, 'trigger')\n }, [triggers, setIsOpen])\n\n // Cleanup timeout on unmount\n useEffect(() => {\n return () => {\n if (hoverTimeoutRef.current) {\n clearTimeout(hoverTimeoutRef.current)\n }\n }\n }, [])\n\n const positionClasses: Record<string, string> = {\n top: dDropdownTop,\n bottom: dDropdownBottom,\n left: dDropdownLeft,\n right: dDropdownRight,\n }\n\n const alignClasses: Record<string, string> = {\n start: '',\n center: dDropdownCenter,\n end: dDropdownEnd,\n }\n\n const showArrow = typeof arrow === 'boolean' ? arrow : !!arrow\n\n const dropdownClasses = [\n dDropdown,\n positionClasses[position],\n alignClasses[align],\n triggers.includes('hover') && dDropdownHover,\n isOpen && dDropdownOpen,\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Render items from data-driven prop\n const renderItems = () => {\n if (!items) return null\n return items.map((item, index) => {\n if ('type' in item && item.type === 'divider') {\n return <DropdownDivider key={item.key || `divider-${index}`} />\n }\n const menuItem = item as DropdownMenuItem\n if (menuItem.children && menuItem.children.length > 0) {\n return (\n <DropdownSubMenu\n key={menuItem.key}\n title={menuItem.label}\n icon={menuItem.icon}\n disabled={menuItem.disabled}\n >\n {menuItem.children.map((child) => (\n <DropdownItem\n key={child.key}\n icon={child.icon}\n disabled={child.disabled}\n danger={child.danger}\n onClick={child.onClick}\n >\n {child.label}\n </DropdownItem>\n ))}\n </DropdownSubMenu>\n )\n }\n return (\n <DropdownItem\n key={menuItem.key}\n icon={menuItem.icon}\n disabled={menuItem.disabled}\n danger={menuItem.danger}\n onClick={menuItem.onClick}\n >\n {menuItem.label}\n </DropdownItem>\n )\n })\n }\n\n // Determine content - either compound children or items-generated menu\n const menuContent = items ? (\n (shouldRender || !destroyOnHidden) && (\n <DropdownMenu>{renderItems()}</DropdownMenu>\n )\n ) : null\n\n const content = items ? (\n <>\n {React.Children.toArray(children).find(\n (child) => React.isValidElement(child) && child.type === DropdownTrigger\n )}\n {popupRender ? popupRender(menuContent) : menuContent}\n </>\n ) : (\n children\n )\n\n return (\n <DropdownContext.Provider\n value={{\n position,\n align,\n menuId,\n triggerId,\n isOpen,\n setIsOpen,\n focusedIndex,\n setFocusedIndex,\n registerItem,\n itemCount,\n setItemCount,\n disabled: effectiveDisabled,\n arrow: showArrow,\n closeDropdown,\n getTestId,\n }}\n >\n <div\n ref={dropdownRef}\n className={dropdownClasses}\n data-state={isOpen ? 'open' : 'closed'}\n data-testid={testId}\n aria-disabled={effectiveDisabled || undefined}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onContextMenu={handleContextMenu}\n {...rest}\n >\n {content}\n </div>\n </DropdownContext.Provider>\n )\n})\n\nfunction DropdownTrigger({ children, className = '' }: DropdownTriggerProps) {\n const { menuId, triggerId, isOpen, setIsOpen, setFocusedIndex, itemCount, disabled } = useDropdownContext()\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n switch (event.key) {\n case 'Enter':\n case ' ':\n case 'ArrowDown':\n event.preventDefault()\n setIsOpen(true)\n setFocusedIndex(0)\n break\n case 'ArrowUp':\n event.preventDefault()\n setIsOpen(true)\n setFocusedIndex(itemCount - 1)\n break\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n setFocusedIndex(-1)\n break\n }\n }\n\n const handleClick = () => {\n setIsOpen(!isOpen)\n if (!isOpen) {\n setFocusedIndex(0)\n }\n }\n\n // Clone the child element to add event handlers and ARIA attributes\n const child = React.Children.only(children) as React.ReactElement<\n React.HTMLAttributes<HTMLElement> & {\n onClick?: (e: React.MouseEvent) => void\n onKeyDown?: (e: React.KeyboardEvent) => void\n className?: string\n }\n >\n\n const childProps = child.props\n\n return React.cloneElement(child, {\n id: triggerId,\n tabIndex: disabled ? -1 : 0,\n 'aria-haspopup': 'menu' as const,\n 'aria-expanded': isOpen,\n 'aria-controls': menuId,\n onClick: (e: React.MouseEvent) => {\n handleClick()\n childProps.onClick?.(e)\n },\n onKeyDown: (e: React.KeyboardEvent) => {\n handleKeyDown(e)\n childProps.onKeyDown?.(e)\n },\n className: `${childProps.className || ''} ${className}`.trim(),\n })\n}\n\nfunction DropdownMenu({ children, className = '' }: DropdownMenuProps) {\n const { menuId, triggerId, isOpen, setIsOpen, focusedIndex, setFocusedIndex, setItemCount, arrow, position, getTestId } = useDropdownContext()\n const menuRef = useRef<HTMLUListElement>(null)\n\n // Count children and set item count\n const childArray = React.Children.toArray(children).filter(\n (child) => React.isValidElement(child) && (child.type === DropdownItem)\n )\n\n useEffect(() => {\n setItemCount(childArray.length)\n }, [childArray.length, setItemCount])\n\n // Focus management\n useEffect(() => {\n if (isOpen && focusedIndex >= 0 && menuRef.current) {\n const items = menuRef.current.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n const item = items[focusedIndex] as HTMLElement\n item?.focus()\n }\n }, [isOpen, focusedIndex])\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n const enabledItems = childArray.filter(\n (child) => React.isValidElement(child) && !(child.props as DropdownItemProps).disabled\n )\n const enabledCount = enabledItems.length\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault()\n setFocusedIndex((focusedIndex + 1) % enabledCount)\n break\n case 'ArrowUp':\n event.preventDefault()\n setFocusedIndex((focusedIndex - 1 + enabledCount) % enabledCount)\n break\n case 'Home':\n event.preventDefault()\n setFocusedIndex(0)\n break\n case 'End':\n event.preventDefault()\n setFocusedIndex(enabledCount - 1)\n break\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n setFocusedIndex(-1)\n // Return focus to trigger\n document.getElementById(triggerId)?.focus()\n break\n case 'Tab':\n setIsOpen(false)\n setFocusedIndex(-1)\n break\n }\n }\n\n const menuClasses = [\n dDropdownContent,\n dMenu,\n 'bg-base-100',\n 'rounded-box',\n 'z-50',\n 'shadow',\n className,\n ]\n .filter(Boolean)\n .join(' ')\n\n // Clone children to pass index and extract key\n const childrenWithIndex = React.Children.map(children, (child, index) => {\n if (React.isValidElement(child)) {\n const childKey = child.key != null ? String(child.key) : undefined\n if (child.type === DropdownItem) {\n return React.cloneElement(child as React.ReactElement<any>, { _index: index, _key: childKey })\n }\n if (child.type === DropdownSubMenu) {\n return React.cloneElement(child as React.ReactElement<any>, { _key: childKey })\n }\n }\n return child\n })\n\n // Arrow position classes based on menu position\n const arrowPositionClasses: Record<string, string> = {\n top: 'bottom-0 left-1/2 -translate-x-1/2 translate-y-full border-t-base-100 border-l-transparent border-r-transparent border-b-transparent',\n bottom: 'top-0 left-1/2 -translate-x-1/2 -translate-y-full border-b-base-100 border-l-transparent border-r-transparent border-t-transparent',\n left: 'right-0 top-1/2 -translate-y-1/2 translate-x-full border-l-base-100 border-t-transparent border-b-transparent border-r-transparent',\n right: 'left-0 top-1/2 -translate-y-1/2 -translate-x-full border-r-base-100 border-t-transparent border-b-transparent border-l-transparent',\n }\n\n const arrowElement = arrow ? (\n <span\n className={`absolute w-0 h-0 border-8 border-solid ${arrowPositionClasses[position || 'bottom']}`}\n aria-hidden=\"true\"\n />\n ) : null\n\n return (\n <ul\n ref={menuRef}\n id={menuId}\n role=\"menu\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n className={`${menuClasses} ${arrow ? 'relative' : ''}`}\n data-testid={getTestId('menu')}\n onKeyDown={handleKeyDown}\n >\n {arrowElement}\n {childrenWithIndex}\n </ul>\n )\n}\n\nfunction DropdownItem({\n children,\n icon,\n label,\n onClick,\n active = false,\n disabled = false,\n danger = false,\n className = '',\n _key,\n}: DropdownItemProps) {\n const { closeDropdown, getTestId } = useDropdownContext()\n const itemClasses = [active && 'active', disabled && 'disabled', className].filter(Boolean).join(' ')\n\n const handleClick = () => {\n if (!disabled) {\n onClick?.()\n closeDropdown()\n }\n }\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if ((event.key === 'Enter' || event.key === ' ') && !disabled) {\n event.preventDefault()\n handleClick()\n }\n }\n\n const content = label || children\n\n return (\n <li className={itemClasses} role=\"none\" data-key={_key} data-testid={_key ? getTestId(`item-${_key}`) : undefined}>\n <a\n role=\"menuitem\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n className={danger ? 'text-error' : ''}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n >\n {icon && <span className=\"mr-2 inline-flex items-center\">{icon}</span>}\n {content}\n </a>\n </li>\n )\n}\n\nfunction DropdownSubMenu({\n children,\n title,\n icon,\n disabled = false,\n className = '',\n _key,\n}: DropdownSubMenuProps) {\n const [isSubOpen, setIsSubOpen] = useState(false)\n const subMenuRef = useRef<HTMLLIElement>(null)\n const summaryRef = useRef<HTMLElement>(null)\n const subMenuListRef = useRef<HTMLUListElement>(null)\n const subMenuId = useId()\n\n const handleMouseEnter = () => {\n if (!disabled) setIsSubOpen(true)\n }\n\n const handleMouseLeave = () => {\n setIsSubOpen(false)\n }\n\n // Focus first item in submenu\n const focusFirstItem = () => {\n setTimeout(() => {\n const firstItem = subMenuListRef.current?.querySelector('[role=\"menuitem\"]:not([aria-disabled=\"true\"])') as HTMLElement\n firstItem?.focus()\n }, 0)\n }\n\n // Keyboard handler for summary (submenu trigger)\n const handleSummaryKeyDown = (event: React.KeyboardEvent) => {\n if (disabled) return\n\n switch (event.key) {\n case 'ArrowRight':\n case 'Enter':\n case ' ':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(true)\n focusFirstItem()\n break\n case 'ArrowLeft':\n case 'Escape':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(false)\n break\n }\n }\n\n // Keyboard handler for submenu items\n const handleSubMenuKeyDown = (event: React.KeyboardEvent) => {\n switch (event.key) {\n case 'ArrowLeft':\n case 'Escape':\n event.preventDefault()\n event.stopPropagation()\n setIsSubOpen(false)\n summaryRef.current?.focus()\n break\n case 'ArrowDown':\n event.preventDefault()\n event.stopPropagation()\n const items = subMenuListRef.current?.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n if (items) {\n const currentIndex = Array.from(items).findIndex(item => item === document.activeElement)\n const nextIndex = (currentIndex + 1) % items.length\n ;(items[nextIndex] as HTMLElement)?.focus()\n }\n break\n case 'ArrowUp':\n event.preventDefault()\n event.stopPropagation()\n const itemsUp = subMenuListRef.current?.querySelectorAll('[role=\"menuitem\"]:not([aria-disabled=\"true\"])')\n if (itemsUp) {\n const currentIndexUp = Array.from(itemsUp).findIndex(item => item === document.activeElement)\n const prevIndex = (currentIndexUp - 1 + itemsUp.length) % itemsUp.length\n ;(itemsUp[prevIndex] as HTMLElement)?.focus()\n }\n break\n }\n }\n\n const itemClasses = [disabled && 'disabled', className].filter(Boolean).join(' ')\n\n return (\n <li\n ref={subMenuRef}\n className={itemClasses}\n role=\"none\"\n data-key={_key}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n <details open={isSubOpen}>\n <summary\n ref={summaryRef}\n role=\"menuitem\"\n tabIndex={disabled ? -1 : 0}\n aria-disabled={disabled || undefined}\n aria-haspopup=\"menu\"\n aria-expanded={isSubOpen}\n aria-controls={subMenuId}\n onKeyDown={handleSummaryKeyDown}\n >\n {icon && <span className=\"mr-2 inline-flex items-center\">{icon}</span>}\n {title}\n </summary>\n <ul\n ref={subMenuListRef}\n id={subMenuId}\n className={`${dMenu} bg-base-100 rounded-box z-50 shadow`}\n role=\"menu\"\n aria-label={typeof title === 'string' ? title : undefined}\n onKeyDown={handleSubMenuKeyDown}\n >\n {children}\n </ul>\n </details>\n </li>\n )\n}\n\nfunction DropdownDivider({ className = '' }: DropdownDividerProps) {\n const classes = ['border-base-content/10', className].filter(Boolean).join(' ')\n return (\n <li role=\"separator\" className=\"my-1\">\n <hr className={classes} />\n </li>\n )\n}\n\nexport const Dropdown = Object.assign(DropdownRoot, {\n Trigger: DropdownTrigger,\n Menu: DropdownMenu,\n Item: DropdownItem,\n SubMenu: DropdownSubMenu,\n Divider: DropdownDivider,\n})\n"],"names":["dDropdown","dDropdownTop","dDropdownBottom","dDropdownLeft","dDropdownRight","dDropdownCenter","dDropdownEnd","dDropdownHover","dDropdownOpen","dDropdownContent","dMenu","DropdownContext","createContext","useDropdownContext","context","useContext","DropdownRoot","forwardRef","children","items","trigger","position","align","controlledOpen","onOpenChange","disabled","arrow","mouseEnterDelay","mouseLeaveDelay","getPopupContainer","destroyOnHidden","popupRender","testId","className","rest","ref","componentDisabled","globalGetPopupContainer","useConfig","effectiveDisabled","menuId","useId","triggerId","internalOpen","setInternalOpen","useState","focusedIndex","setFocusedIndex","itemCount","setItemCount","shouldRender","setShouldRender","itemRefs","useRef","dropdownRef","hoverTimeoutRef","triggers","useImperativeHandle","getTestId","suffix","isControlled","isOpen","setIsOpen","useCallback","open","source","closeDropdown","registerItem","index","itemDisabled","useEffect","timeout","handleClickOutside","event","handleMouseEnter","handleMouseLeave","handleContextMenu","positionClasses","alignClasses","showArrow","dropdownClasses","menuContent","jsx","DropdownMenu","item","DropdownDivider","menuItem","DropdownSubMenu","child","DropdownItem","content","jsxs","Fragment","React","DropdownTrigger","handleKeyDown","handleClick","childProps","e","menuRef","childArray","enabledCount","menuClasses","childrenWithIndex","childKey","arrowElement","icon","label","onClick","active","danger","_key","itemClasses","title","isSubOpen","setIsSubOpen","subMenuRef","summaryRef","subMenuListRef","subMenuId","focusFirstItem","handleSummaryKeyDown","handleSubMenuKeyDown","nextIndex","itemsUp","prevIndex","classes","Dropdown"],"mappings":";;;AAIA,MAAMA,KAAY,YACZC,KAAe,gBACfC,KAAkB,mBAClBC,KAAgB,iBAChBC,KAAiB,kBACjBC,KAAkB,mBAClBC,KAAe,gBACfC,KAAiB,kBACjBC,KAAgB,iBAChBC,KAAmB,oBACnBC,IAAQ,QAwCRC,IAAkBC,GAAgD,MAAS;AAEjF,SAASC,IAAqB;AAC5B,QAAMC,IAAUC,GAAWJ,CAAe;AAC1C,MAAI,CAAC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,YAC1B,iBAAeA,KAAY;AAAA,YAC3B,iBAAc;AAAA,YACd,iBAAeyF;AAAA,YACf,iBAAeK;AAAA,YACf,WAAWE;AAAA,YAEV,UAAA;AAAA,cAAAf,KAAQ,gBAAAxB,EAAC,QAAA,EAAK,WAAU,iCAAiC,UAAAwB,GAAK;AAAA,cAC9DO;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEH,gBAAA/B;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAKoC;AAAA,YACL,IAAIC;AAAA,YACJ,WAAW,GAAG7G,CAAK;AAAA,YACnB,MAAK;AAAA,YACL,cAAY,OAAOuG,KAAU,WAAWA,IAAQ;AAAA,YAChD,WAAWS;AAAA,YAEV,UAAAxG;AAAA,UAAA;AAAA,QAAA;AAAA,MACH,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;AAEA,SAASmE,EAAgB,EAAE,WAAApD,IAAY,MAA4B;AACjE,QAAM6F,IAAU,CAAC,0BAA0B7F,CAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAC9E,SACE,gBAAAiD,EAAC,MAAA,EAAG,MAAK,aAAY,WAAU,QAC7B,UAAA,gBAAAA,EAAC,MAAA,EAAG,WAAW4C,EAAA,CAAS,EAAA,CAC1B;AAEJ;AAEO,MAAMC,KAAW,OAAO,OAAO/G,IAAc;AAAA,EAClD,SAAS8E;AAAA,EACT,MAAMX;AAAA,EACN,MAAMM;AAAA,EACN,SAASF;AAAA,EACT,SAASF;AACX,CAAC;"}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import { useState as f, useRef as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as a, jsxs as q } from "react/jsx-runtime";
|
|
2
|
+
import { useState as f, useRef as H, useCallback as A, useEffect as C } from "react";
|
|
3
|
+
import { createPortal as fe } from "react-dom";
|
|
4
|
+
import { useConfig as me } from "../providers/ConfigProvider.js";
|
|
5
|
+
const he = "textarea", ge = "textarea-bordered", be = "menu", pe = "menu-sm", ve = "loading", we = "loading-spinner", xe = "loading-sm", ye = "avatar", Ne = ({
|
|
6
|
+
value: v,
|
|
7
|
+
defaultValue: U = "",
|
|
8
|
+
onChange: E,
|
|
9
|
+
onSelect: W,
|
|
10
|
+
onSearch: X,
|
|
10
11
|
options: $ = [],
|
|
11
|
-
loading:
|
|
12
|
+
loading: Y = !1,
|
|
12
13
|
prefix: R = "@",
|
|
13
|
-
split:
|
|
14
|
-
placeholder:
|
|
15
|
-
disabled:
|
|
16
|
-
readOnly:
|
|
17
|
-
rows:
|
|
14
|
+
split: w = " ",
|
|
15
|
+
placeholder: G,
|
|
16
|
+
disabled: J,
|
|
17
|
+
readOnly: Q = !1,
|
|
18
|
+
rows: L = 3,
|
|
18
19
|
autoSize: l = !1,
|
|
19
|
-
notFoundContent:
|
|
20
|
+
notFoundContent: Z,
|
|
20
21
|
filterOption: x = !0,
|
|
21
|
-
className:
|
|
22
|
-
dropdownClassName:
|
|
23
|
-
...
|
|
22
|
+
className: _ = "",
|
|
23
|
+
dropdownClassName: z = "",
|
|
24
|
+
...ee
|
|
24
25
|
}) => {
|
|
25
|
-
const [
|
|
26
|
+
const { componentDisabled: te, renderEmpty: ne, getPopupContainer: S } = me(), re = J ?? te ?? !1, se = Z ?? ne?.("Mention") ?? "No matches found", [ae, T] = f(U), m = v !== void 0 ? v : ae, [d, h] = f(!1), [k, M] = f(null), [N, D] = f(""), [u, y] = f(0), [g, I] = f(null), [V, oe] = f({ top: 0, left: 0 }), o = H(null), b = H(null), B = H(null), le = Array.isArray(R) ? R : [R], c = A(() => {
|
|
26
27
|
if (!x) return $;
|
|
27
28
|
const e = typeof x == "function" ? x : (t, n) => (n.label || n.value).toLowerCase().includes(t.toLowerCase());
|
|
28
|
-
return $.filter((t) => e(
|
|
29
|
-
}, [$,
|
|
29
|
+
return $.filter((t) => e(N, t));
|
|
30
|
+
}, [$, N, x])(), j = A(() => {
|
|
30
31
|
const e = o.current;
|
|
31
32
|
if (!e || !l) return;
|
|
32
33
|
e.style.height = "auto";
|
|
@@ -38,35 +39,35 @@ const ce = "textarea", ie = "textarea-bordered", de = "menu", ue = "menu-sm", fe
|
|
|
38
39
|
e.style.height = `${t}px`;
|
|
39
40
|
}, [l]);
|
|
40
41
|
C(() => {
|
|
41
|
-
|
|
42
|
-
}, [m,
|
|
43
|
-
const
|
|
44
|
-
const e = o.current, t =
|
|
42
|
+
j();
|
|
43
|
+
}, [m, j]);
|
|
44
|
+
const O = A(() => {
|
|
45
|
+
const e = o.current, t = B.current;
|
|
45
46
|
if (!e || !t || g === null) return;
|
|
46
47
|
const n = m.substring(0, g);
|
|
47
48
|
t.textContent = n;
|
|
48
|
-
const r = e.getBoundingClientRect(), s = t.getBoundingClientRect(),
|
|
49
|
-
|
|
50
|
-
top: r.top + window.scrollY +
|
|
49
|
+
const r = e.getBoundingClientRect(), s = t.getBoundingClientRect(), p = parseInt(getComputedStyle(e).lineHeight) || 20;
|
|
50
|
+
oe({
|
|
51
|
+
top: r.top + window.scrollY + p + 4,
|
|
51
52
|
left: r.left + window.scrollX + Math.min(s.width % r.width, r.width - 200)
|
|
52
53
|
});
|
|
53
54
|
}, [m, g]);
|
|
54
55
|
C(() => {
|
|
55
|
-
d &&
|
|
56
|
-
}, [d,
|
|
57
|
-
const
|
|
56
|
+
d && O();
|
|
57
|
+
}, [d, O, N]);
|
|
58
|
+
const ce = (e) => {
|
|
58
59
|
const t = e.target.value, n = e.target.selectionStart;
|
|
59
|
-
|
|
60
|
-
},
|
|
60
|
+
v === void 0 && T(t), E?.(t), ie(t, n);
|
|
61
|
+
}, ie = (e, t) => {
|
|
61
62
|
let n = null, r = null;
|
|
62
|
-
for (const s of
|
|
63
|
+
for (const s of le) {
|
|
63
64
|
const i = e.substring(0, t).lastIndexOf(s);
|
|
64
65
|
if (i !== -1) {
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
66
|
+
const F = i > 0 ? e[i - 1] : w;
|
|
67
|
+
if (F === w || F === `
|
|
67
68
|
` || i === 0) {
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
69
|
+
const K = e.substring(i + s.length, t);
|
|
70
|
+
if (!K.includes(w) && !K.includes(`
|
|
70
71
|
`)) {
|
|
71
72
|
n = s, r = i;
|
|
72
73
|
break;
|
|
@@ -76,19 +77,19 @@ const ce = "textarea", ie = "textarea-bordered", de = "menu", ue = "menu-sm", fe
|
|
|
76
77
|
}
|
|
77
78
|
if (n !== null && r !== null) {
|
|
78
79
|
const s = e.substring(r + n.length, t);
|
|
79
|
-
|
|
80
|
+
M(n), D(s), I(r), h(!0), y(0), X?.(s, n);
|
|
80
81
|
} else
|
|
81
|
-
h(!1),
|
|
82
|
-
},
|
|
82
|
+
h(!1), M(null), D(""), I(null);
|
|
83
|
+
}, P = (e) => {
|
|
83
84
|
if (e.disabled || g === null || k === null) return;
|
|
84
85
|
const t = o.current;
|
|
85
86
|
if (!t) return;
|
|
86
|
-
const n = m.substring(0, g), r = m.substring(t.selectionStart), s = `${k}${e.value}${
|
|
87
|
-
|
|
87
|
+
const n = m.substring(0, g), r = m.substring(t.selectionStart), s = `${k}${e.value}${w}`, p = n + s + r;
|
|
88
|
+
v === void 0 && T(p), E?.(p), W?.(e, k), h(!1), M(null), D(""), I(null), setTimeout(() => {
|
|
88
89
|
const i = n.length + s.length;
|
|
89
90
|
t.focus(), t.setSelectionRange(i, i);
|
|
90
91
|
}, 0);
|
|
91
|
-
},
|
|
92
|
+
}, de = (e) => {
|
|
92
93
|
if (d)
|
|
93
94
|
switch (e.key) {
|
|
94
95
|
case "ArrowDown":
|
|
@@ -98,13 +99,13 @@ const ce = "textarea", ie = "textarea-bordered", de = "menu", ue = "menu-sm", fe
|
|
|
98
99
|
e.preventDefault(), y((t) => (t - 1 + c.length) % Math.max(c.length, 1));
|
|
99
100
|
break;
|
|
100
101
|
case "Enter":
|
|
101
|
-
c[u] && (e.preventDefault(),
|
|
102
|
+
c[u] && (e.preventDefault(), P(c[u]));
|
|
102
103
|
break;
|
|
103
104
|
case "Escape":
|
|
104
105
|
e.preventDefault(), h(!1);
|
|
105
106
|
break;
|
|
106
107
|
case "Tab":
|
|
107
|
-
c[u] && (e.preventDefault(),
|
|
108
|
+
c[u] && (e.preventDefault(), P(c[u]));
|
|
108
109
|
break;
|
|
109
110
|
}
|
|
110
111
|
};
|
|
@@ -116,37 +117,37 @@ const ce = "textarea", ie = "textarea-bordered", de = "menu", ue = "menu-sm", fe
|
|
|
116
117
|
}, []), C(() => {
|
|
117
118
|
d && b.current && b.current.querySelector('[data-active="true"]')?.scrollIntoView({ block: "nearest" });
|
|
118
119
|
}, [u, d]);
|
|
119
|
-
const
|
|
120
|
+
const ue = d && /* @__PURE__ */ a(
|
|
120
121
|
"div",
|
|
121
122
|
{
|
|
122
123
|
ref: b,
|
|
123
124
|
className: `fixed z-50 bg-base-100 border border-base-300 rounded-lg shadow-lg
|
|
124
|
-
min-w-48 max-h-60 overflow-auto ${
|
|
125
|
+
min-w-48 max-h-60 overflow-auto ${z}`,
|
|
125
126
|
style: {
|
|
126
|
-
top:
|
|
127
|
-
left:
|
|
127
|
+
top: V.top,
|
|
128
|
+
left: V.left
|
|
128
129
|
},
|
|
129
|
-
children:
|
|
130
|
+
children: Y ? /* @__PURE__ */ a("div", { className: "p-3 text-center text-base-content/60", children: /* @__PURE__ */ a("span", { className: `${ve} ${we} ${xe}` }) }) : c.length === 0 ? /* @__PURE__ */ a("div", { className: "p-3 text-center text-base-content/60 text-sm", children: se }) : /* @__PURE__ */ a("ul", { className: `${be} ${pe} p-1`, children: c.map((e, t) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ q(
|
|
130
131
|
"button",
|
|
131
132
|
{
|
|
132
133
|
type: "button",
|
|
133
134
|
"data-active": t === u,
|
|
134
135
|
className: `flex items-center gap-2 ${t === u ? "active" : ""} ${e.disabled ? "disabled opacity-50 cursor-not-allowed" : ""}`,
|
|
135
|
-
onClick: () =>
|
|
136
|
+
onClick: () => P(e),
|
|
136
137
|
onMouseEnter: () => y(t),
|
|
137
138
|
children: [
|
|
138
|
-
e.avatar && /* @__PURE__ */ a("div", { className:
|
|
139
|
+
e.avatar && /* @__PURE__ */ a("div", { className: ye, children: /* @__PURE__ */ a("div", { className: "w-6 h-6 rounded-full", children: /* @__PURE__ */ a("img", { src: e.avatar, alt: "" }) }) }),
|
|
139
140
|
/* @__PURE__ */ a("span", { children: e.label || e.value })
|
|
140
141
|
]
|
|
141
142
|
}
|
|
142
143
|
) }, e.value)) })
|
|
143
144
|
}
|
|
144
145
|
);
|
|
145
|
-
return /* @__PURE__ */
|
|
146
|
+
return /* @__PURE__ */ q("div", { className: `relative ${_}`, "data-state": d ? "open" : "closed", ...ee, children: [
|
|
146
147
|
/* @__PURE__ */ a(
|
|
147
148
|
"div",
|
|
148
149
|
{
|
|
149
|
-
ref:
|
|
150
|
+
ref: B,
|
|
150
151
|
className: "invisible absolute whitespace-pre-wrap break-words",
|
|
151
152
|
style: {
|
|
152
153
|
font: o.current ? getComputedStyle(o.current).font : void 0,
|
|
@@ -161,19 +162,19 @@ const ce = "textarea", ie = "textarea-bordered", de = "menu", ue = "menu-sm", fe
|
|
|
161
162
|
{
|
|
162
163
|
ref: o,
|
|
163
164
|
value: m,
|
|
164
|
-
onChange:
|
|
165
|
-
onKeyDown:
|
|
166
|
-
placeholder:
|
|
167
|
-
disabled:
|
|
168
|
-
readOnly:
|
|
169
|
-
rows: typeof l == "object" ? l.minRows ||
|
|
170
|
-
className: `${
|
|
165
|
+
onChange: ce,
|
|
166
|
+
onKeyDown: de,
|
|
167
|
+
placeholder: G,
|
|
168
|
+
disabled: re,
|
|
169
|
+
readOnly: Q,
|
|
170
|
+
rows: typeof l == "object" ? l.minRows || L : l ? 1 : L,
|
|
171
|
+
className: `${he} ${ge} w-full resize-none`
|
|
171
172
|
}
|
|
172
173
|
),
|
|
173
|
-
|
|
174
|
+
fe(ue, S ? S(document.body) : document.body)
|
|
174
175
|
] });
|
|
175
176
|
};
|
|
176
177
|
export {
|
|
177
|
-
|
|
178
|
+
Ne as Mention
|
|
178
179
|
};
|
|
179
180
|
//# sourceMappingURL=Mention.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mention.js","sources":["../../src/components/Mention.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect } from 'react'\nimport { createPortal } from 'react-dom'\n\n// DaisyUI classes\nconst dTextarea = 'textarea'\nconst dTextareaBordered = 'textarea-bordered'\nconst dMenu = 'menu'\nconst dMenuSm = 'menu-sm'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingSm = 'loading-sm'\nconst dAvatar = 'avatar'\n\nexport interface MentionOption {\n value: string\n label?: string\n avatar?: string\n disabled?: boolean\n}\n\nexport interface MentionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onSelect' | 'defaultValue' | 'prefix'> {\n value?: string\n defaultValue?: string\n onChange?: (value: string) => void\n onSelect?: (option: MentionOption, prefix: string) => void\n onSearch?: (text: string, prefix: string) => void\n options?: MentionOption[]\n loading?: boolean\n prefix?: string | string[]\n split?: string\n placeholder?: string\n disabled?: boolean\n readOnly?: boolean\n rows?: number\n autoSize?: boolean | { minRows?: number; maxRows?: number }\n notFoundContent?: React.ReactNode\n filterOption?: boolean | ((input: string, option: MentionOption) => boolean)\n dropdownClassName?: string\n}\n\nexport const Mention: React.FC<MentionProps> = ({\n value,\n defaultValue = '',\n onChange,\n onSelect,\n onSearch,\n options = [],\n loading = false,\n prefix = '@',\n split = ' ',\n placeholder,\n disabled = false,\n readOnly = false,\n rows = 3,\n autoSize = false,\n notFoundContent = 'No matches found',\n filterOption = true,\n className = '',\n dropdownClassName = '',\n ...rest\n}) => {\n const [internalValue, setInternalValue] = useState(defaultValue)\n const currentValue = value !== undefined ? value : internalValue\n\n const [isOpen, setIsOpen] = useState(false)\n const [activePrefix, setActivePrefix] = useState<string | null>(null)\n const [searchText, setSearchText] = useState('')\n const [activeIndex, setActiveIndex] = useState(0)\n const [mentionStart, setMentionStart] = useState<number | null>(null)\n const [dropdownPosition, setDropdownPosition] = useState({ top: 0, left: 0 })\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const dropdownRef = useRef<HTMLDivElement>(null)\n const measureRef = useRef<HTMLDivElement>(null)\n\n const prefixes = Array.isArray(prefix) ? prefix : [prefix]\n\n // Filter options based on search text\n const filteredOptions = useCallback(() => {\n if (!filterOption) return options\n\n const filterFn =\n typeof filterOption === 'function'\n ? filterOption\n : (input: string, option: MentionOption) => {\n const label = option.label || option.value\n return label.toLowerCase().includes(input.toLowerCase())\n }\n\n return options.filter((opt) => filterFn(searchText, opt))\n }, [options, searchText, filterOption])\n\n const filtered = filteredOptions()\n\n // Update textarea height for autoSize\n const updateHeight = useCallback(() => {\n const textarea = textareaRef.current\n if (!textarea || !autoSize) return\n\n textarea.style.height = 'auto'\n const scrollHeight = textarea.scrollHeight\n\n if (typeof autoSize === 'object') {\n const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 20\n const minHeight = autoSize.minRows ? autoSize.minRows * lineHeight : 0\n const maxHeight = autoSize.maxRows ? autoSize.maxRows * lineHeight : Infinity\n\n textarea.style.height = `${Math.min(Math.max(scrollHeight, minHeight), maxHeight)}px`\n } else {\n textarea.style.height = `${scrollHeight}px`\n }\n }, [autoSize])\n\n useEffect(() => {\n updateHeight()\n }, [currentValue, updateHeight])\n\n // Calculate dropdown position\n const updateDropdownPosition = useCallback(() => {\n const textarea = textareaRef.current\n const measure = measureRef.current\n if (!textarea || !measure || mentionStart === null) return\n\n // Get text before cursor to measure position\n const textBeforeCursor = currentValue.substring(0, mentionStart)\n\n // Create a temporary element to measure text position\n measure.textContent = textBeforeCursor\n\n const textareaRect = textarea.getBoundingClientRect()\n const measureRect = measure.getBoundingClientRect()\n\n // Calculate position relative to viewport\n const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 20\n\n setDropdownPosition({\n top: textareaRect.top + window.scrollY + lineHeight + 4,\n left: textareaRect.left + window.scrollX + Math.min(measureRect.width % textareaRect.width, textareaRect.width - 200),\n })\n }, [currentValue, mentionStart])\n\n useEffect(() => {\n if (isOpen) {\n updateDropdownPosition()\n }\n }, [isOpen, updateDropdownPosition, searchText])\n\n // Handle text change\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value\n const cursorPos = e.target.selectionStart\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n\n // Check if we should open the mention dropdown\n checkForMention(newValue, cursorPos)\n }\n\n const checkForMention = (text: string, cursorPos: number) => {\n // Look backwards from cursor for a prefix\n let foundPrefix: string | null = null\n let foundStart: number | null = null\n\n for (const p of prefixes) {\n // Find the last occurrence of prefix before cursor\n const beforeCursor = text.substring(0, cursorPos)\n const lastPrefixIndex = beforeCursor.lastIndexOf(p)\n\n if (lastPrefixIndex !== -1) {\n // Check if prefix is at start or preceded by whitespace/split\n const charBefore = lastPrefixIndex > 0 ? text[lastPrefixIndex - 1] : split\n if (charBefore === split || charBefore === '\\n' || lastPrefixIndex === 0) {\n // Check if there's no space between prefix and cursor\n const textAfterPrefix = text.substring(lastPrefixIndex + p.length, cursorPos)\n if (!textAfterPrefix.includes(split) && !textAfterPrefix.includes('\\n')) {\n foundPrefix = p\n foundStart = lastPrefixIndex\n break\n }\n }\n }\n }\n\n if (foundPrefix !== null && foundStart !== null) {\n const search = text.substring(foundStart + foundPrefix.length, cursorPos)\n setActivePrefix(foundPrefix)\n setSearchText(search)\n setMentionStart(foundStart)\n setIsOpen(true)\n setActiveIndex(0)\n onSearch?.(search, foundPrefix)\n } else {\n setIsOpen(false)\n setActivePrefix(null)\n setSearchText('')\n setMentionStart(null)\n }\n }\n\n // Handle option selection\n const selectOption = (option: MentionOption) => {\n if (option.disabled || mentionStart === null || activePrefix === null) return\n\n const textarea = textareaRef.current\n if (!textarea) return\n\n const beforeMention = currentValue.substring(0, mentionStart)\n const afterCursor = currentValue.substring(textarea.selectionStart)\n\n const mentionText = `${activePrefix}${option.value}${split}`\n const newValue = beforeMention + mentionText + afterCursor\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n onSelect?.(option, activePrefix)\n\n setIsOpen(false)\n setActivePrefix(null)\n setSearchText('')\n setMentionStart(null)\n\n // Set cursor position after mention\n setTimeout(() => {\n const newCursorPos = beforeMention.length + mentionText.length\n textarea.focus()\n textarea.setSelectionRange(newCursorPos, newCursorPos)\n }, 0)\n }\n\n // Handle keyboard navigation\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (!isOpen) return\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n setActiveIndex((prev) => (prev + 1) % Math.max(filtered.length, 1))\n break\n case 'ArrowUp':\n e.preventDefault()\n setActiveIndex((prev) => (prev - 1 + filtered.length) % Math.max(filtered.length, 1))\n break\n case 'Enter':\n if (filtered[activeIndex]) {\n e.preventDefault()\n selectOption(filtered[activeIndex])\n }\n break\n case 'Escape':\n e.preventDefault()\n setIsOpen(false)\n break\n case 'Tab':\n if (filtered[activeIndex]) {\n e.preventDefault()\n selectOption(filtered[activeIndex])\n }\n break\n }\n }\n\n // Close dropdown on outside click\n useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(e.target as Node) &&\n textareaRef.current &&\n !textareaRef.current.contains(e.target as Node)\n ) {\n setIsOpen(false)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }, [])\n\n // Scroll active item into view\n useEffect(() => {\n if (isOpen && dropdownRef.current) {\n const activeItem = dropdownRef.current.querySelector('[data-active=\"true\"]')\n activeItem?.scrollIntoView({ block: 'nearest' })\n }\n }, [activeIndex, isOpen])\n\n const dropdown = isOpen && (\n <div\n ref={dropdownRef}\n className={`fixed z-50 bg-base-100 border border-base-300 rounded-lg shadow-lg\n min-w-48 max-h-60 overflow-auto ${dropdownClassName}`}\n style={{\n top: dropdownPosition.top,\n left: dropdownPosition.left,\n }}\n >\n {loading ? (\n <div className=\"p-3 text-center text-base-content/60\">\n <span className={`${dLoading} ${dLoadingSpinner} ${dLoadingSm}`}></span>\n </div>\n ) : filtered.length === 0 ? (\n <div className=\"p-3 text-center text-base-content/60 text-sm\">\n {notFoundContent}\n </div>\n ) : (\n <ul className={`${dMenu} ${dMenuSm} p-1`}>\n {filtered.map((option, index) => (\n <li key={option.value}>\n <button\n type=\"button\"\n data-active={index === activeIndex}\n className={`flex items-center gap-2 ${\n index === activeIndex ? 'active' : ''\n } ${option.disabled ? 'disabled opacity-50 cursor-not-allowed' : ''}`}\n onClick={() => selectOption(option)}\n onMouseEnter={() => setActiveIndex(index)}\n >\n {option.avatar && (\n <div className={dAvatar}>\n <div className=\"w-6 h-6 rounded-full\">\n <img src={option.avatar} alt=\"\" />\n </div>\n </div>\n )}\n <span>{option.label || option.value}</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n\n return (\n <div className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} {...rest}>\n {/* Hidden measure element for cursor position */}\n <div\n ref={measureRef}\n className=\"invisible absolute whitespace-pre-wrap break-words\"\n style={{\n font: textareaRef.current ? getComputedStyle(textareaRef.current).font : undefined,\n width: textareaRef.current?.clientWidth,\n padding: textareaRef.current ? getComputedStyle(textareaRef.current).padding : undefined,\n }}\n aria-hidden=\"true\"\n />\n\n <textarea\n ref={textareaRef}\n value={currentValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n rows={typeof autoSize === 'object' ? autoSize.minRows || rows : autoSize ? 1 : rows}\n className={`${dTextarea} ${dTextareaBordered} w-full resize-none`}\n />\n\n {createPortal(dropdown, document.body)}\n </div>\n )\n}\n"],"names":["dTextarea","dTextareaBordered","dMenu","dMenuSm","dLoading","dLoadingSpinner","dLoadingSm","dAvatar","Mention","value","defaultValue","onChange","onSelect","onSearch","options","loading","prefix","split","placeholder","disabled","readOnly","rows","autoSize","notFoundContent","filterOption","className","dropdownClassName","rest","internalValue","setInternalValue","useState","currentValue","isOpen","setIsOpen","activePrefix","setActivePrefix","searchText","setSearchText","activeIndex","setActiveIndex","mentionStart","setMentionStart","dropdownPosition","setDropdownPosition","textareaRef","useRef","dropdownRef","measureRef","prefixes","filtered","useCallback","filterFn","input","option","opt","updateHeight","textarea","scrollHeight","lineHeight","minHeight","maxHeight","useEffect","updateDropdownPosition","measure","textBeforeCursor","textareaRect","measureRect","handleChange","newValue","cursorPos","checkForMention","text","foundPrefix","foundStart","p","lastPrefixIndex","charBefore","textAfterPrefix","search","selectOption","beforeMention","afterCursor","mentionText","newCursorPos","handleKeyDown","prev","handleClickOutside","e","dropdown","jsx","index","jsxs","createPortal"],"mappings":";;;AAIA,MAAMA,KAAY,YACZC,KAAoB,qBACpBC,KAAQ,QACRC,KAAU,WACVC,KAAW,WACXC,KAAkB,mBAClBC,KAAa,cACbC,KAAU,UA6BHC,KAAkC,CAAC;AAAA,EAC9C,OAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,SAAAC,IAAU;AAAA,EACV,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,aAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,iBAAAC,IAAkB;AAAA,EAClB,cAAAC,IAAe;AAAA,EACf,WAAAC,IAAY;AAAA,EACZ,mBAAAC,IAAoB;AAAA,EACpB,GAAGC;AACL,MAAM;AACJ,QAAM,CA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jB/BA,EAAO,KAmBhB,CACD,EAAA,CACH;AAAA,IAAA;AAAA,EAAA;AAKN,SACE,gBAAAsC,EAAC,OAAA,EAAI,WAAW,YAAYlE,CAAS,IAAI,cAAYO,IAAS,SAAS,UAAW,GAAGL,GAEnF,UAAA;AAAA,IAAA,gBAAA8D;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK1C;AAAA,QACL,WAAU;AAAA,QACV,OAAO;AAAA,UACL,MAAMH,EAAY,UAAU,iBAAiBA,EAAY,OAAO,EAAE,OAAO;AAAA,UACzE,OAAOA,EAAY,SAAS;AAAA,UAC5B,SAASA,EAAY,UAAU,iBAAiBA,EAAY,OAAO,EAAE,UAAU;AAAA,QAAA;AAAA,QAEjF,eAAY;AAAA,MAAA;AAAA,IAAA;AAAA,IAGd,gBAAA6C;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,KAAK7C;AAAA,QACL,OAAOb;AAAA,QACP,UAAUoC;AAAA,QACV,WAAWiB;AAAA,QACX,aAAAlE;AAAA,QACA,UAAAC;AAAA,QACA,UAAAC;AAAA,QACA,MAAM,OAAOE,KAAa,WAAWA,EAAS,WAAWD,IAAOC,IAAW,IAAID;AAAA,QAC/E,WAAW,GAAGrB,EAAS,IAAIC,EAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,IAG7C2F,GAAaJ,IAAU,SAAS,IAAI;AAAA,EAAA,GACvC;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Mention.js","sources":["../../src/components/Mention.tsx"],"sourcesContent":["import React, { useState, useRef, useCallback, useEffect } from 'react'\nimport { createPortal } from 'react-dom'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dTextarea = 'textarea'\nconst dTextareaBordered = 'textarea-bordered'\nconst dMenu = 'menu'\nconst dMenuSm = 'menu-sm'\nconst dLoading = 'loading'\nconst dLoadingSpinner = 'loading-spinner'\nconst dLoadingSm = 'loading-sm'\nconst dAvatar = 'avatar'\n\nexport interface MentionOption {\n value: string\n label?: string\n avatar?: string\n disabled?: boolean\n}\n\nexport interface MentionProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'onSelect' | 'defaultValue' | 'prefix'> {\n value?: string\n defaultValue?: string\n onChange?: (value: string) => void\n onSelect?: (option: MentionOption, prefix: string) => void\n onSearch?: (text: string, prefix: string) => void\n options?: MentionOption[]\n loading?: boolean\n prefix?: string | string[]\n split?: string\n placeholder?: string\n disabled?: boolean\n readOnly?: boolean\n rows?: number\n autoSize?: boolean | { minRows?: number; maxRows?: number }\n notFoundContent?: React.ReactNode\n filterOption?: boolean | ((input: string, option: MentionOption) => boolean)\n dropdownClassName?: string\n}\n\nexport const Mention: React.FC<MentionProps> = ({\n value,\n defaultValue = '',\n onChange,\n onSelect,\n onSearch,\n options = [],\n loading = false,\n prefix = '@',\n split = ' ',\n placeholder,\n disabled,\n readOnly = false,\n rows = 3,\n autoSize = false,\n notFoundContent,\n filterOption = true,\n className = '',\n dropdownClassName = '',\n ...rest\n}) => {\n const { componentDisabled, renderEmpty, getPopupContainer } = useConfig()\n const effectiveDisabled = disabled ?? componentDisabled ?? false\n const effectiveNotFoundContent = notFoundContent ?? renderEmpty?.('Mention') ?? 'No matches found'\n\n const [internalValue, setInternalValue] = useState(defaultValue)\n const currentValue = value !== undefined ? value : internalValue\n\n const [isOpen, setIsOpen] = useState(false)\n const [activePrefix, setActivePrefix] = useState<string | null>(null)\n const [searchText, setSearchText] = useState('')\n const [activeIndex, setActiveIndex] = useState(0)\n const [mentionStart, setMentionStart] = useState<number | null>(null)\n const [dropdownPosition, setDropdownPosition] = useState({ top: 0, left: 0 })\n\n const textareaRef = useRef<HTMLTextAreaElement>(null)\n const dropdownRef = useRef<HTMLDivElement>(null)\n const measureRef = useRef<HTMLDivElement>(null)\n\n const prefixes = Array.isArray(prefix) ? prefix : [prefix]\n\n // Filter options based on search text\n const filteredOptions = useCallback(() => {\n if (!filterOption) return options\n\n const filterFn =\n typeof filterOption === 'function'\n ? filterOption\n : (input: string, option: MentionOption) => {\n const label = option.label || option.value\n return label.toLowerCase().includes(input.toLowerCase())\n }\n\n return options.filter((opt) => filterFn(searchText, opt))\n }, [options, searchText, filterOption])\n\n const filtered = filteredOptions()\n\n // Update textarea height for autoSize\n const updateHeight = useCallback(() => {\n const textarea = textareaRef.current\n if (!textarea || !autoSize) return\n\n textarea.style.height = 'auto'\n const scrollHeight = textarea.scrollHeight\n\n if (typeof autoSize === 'object') {\n const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 20\n const minHeight = autoSize.minRows ? autoSize.minRows * lineHeight : 0\n const maxHeight = autoSize.maxRows ? autoSize.maxRows * lineHeight : Infinity\n\n textarea.style.height = `${Math.min(Math.max(scrollHeight, minHeight), maxHeight)}px`\n } else {\n textarea.style.height = `${scrollHeight}px`\n }\n }, [autoSize])\n\n useEffect(() => {\n updateHeight()\n }, [currentValue, updateHeight])\n\n // Calculate dropdown position\n const updateDropdownPosition = useCallback(() => {\n const textarea = textareaRef.current\n const measure = measureRef.current\n if (!textarea || !measure || mentionStart === null) return\n\n // Get text before cursor to measure position\n const textBeforeCursor = currentValue.substring(0, mentionStart)\n\n // Create a temporary element to measure text position\n measure.textContent = textBeforeCursor\n\n const textareaRect = textarea.getBoundingClientRect()\n const measureRect = measure.getBoundingClientRect()\n\n // Calculate position relative to viewport\n const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 20\n\n setDropdownPosition({\n top: textareaRect.top + window.scrollY + lineHeight + 4,\n left: textareaRect.left + window.scrollX + Math.min(measureRect.width % textareaRect.width, textareaRect.width - 200),\n })\n }, [currentValue, mentionStart])\n\n useEffect(() => {\n if (isOpen) {\n updateDropdownPosition()\n }\n }, [isOpen, updateDropdownPosition, searchText])\n\n // Handle text change\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value\n const cursorPos = e.target.selectionStart\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n\n // Check if we should open the mention dropdown\n checkForMention(newValue, cursorPos)\n }\n\n const checkForMention = (text: string, cursorPos: number) => {\n // Look backwards from cursor for a prefix\n let foundPrefix: string | null = null\n let foundStart: number | null = null\n\n for (const p of prefixes) {\n // Find the last occurrence of prefix before cursor\n const beforeCursor = text.substring(0, cursorPos)\n const lastPrefixIndex = beforeCursor.lastIndexOf(p)\n\n if (lastPrefixIndex !== -1) {\n // Check if prefix is at start or preceded by whitespace/split\n const charBefore = lastPrefixIndex > 0 ? text[lastPrefixIndex - 1] : split\n if (charBefore === split || charBefore === '\\n' || lastPrefixIndex === 0) {\n // Check if there's no space between prefix and cursor\n const textAfterPrefix = text.substring(lastPrefixIndex + p.length, cursorPos)\n if (!textAfterPrefix.includes(split) && !textAfterPrefix.includes('\\n')) {\n foundPrefix = p\n foundStart = lastPrefixIndex\n break\n }\n }\n }\n }\n\n if (foundPrefix !== null && foundStart !== null) {\n const search = text.substring(foundStart + foundPrefix.length, cursorPos)\n setActivePrefix(foundPrefix)\n setSearchText(search)\n setMentionStart(foundStart)\n setIsOpen(true)\n setActiveIndex(0)\n onSearch?.(search, foundPrefix)\n } else {\n setIsOpen(false)\n setActivePrefix(null)\n setSearchText('')\n setMentionStart(null)\n }\n }\n\n // Handle option selection\n const selectOption = (option: MentionOption) => {\n if (option.disabled || mentionStart === null || activePrefix === null) return\n\n const textarea = textareaRef.current\n if (!textarea) return\n\n const beforeMention = currentValue.substring(0, mentionStart)\n const afterCursor = currentValue.substring(textarea.selectionStart)\n\n const mentionText = `${activePrefix}${option.value}${split}`\n const newValue = beforeMention + mentionText + afterCursor\n\n if (value === undefined) {\n setInternalValue(newValue)\n }\n onChange?.(newValue)\n onSelect?.(option, activePrefix)\n\n setIsOpen(false)\n setActivePrefix(null)\n setSearchText('')\n setMentionStart(null)\n\n // Set cursor position after mention\n setTimeout(() => {\n const newCursorPos = beforeMention.length + mentionText.length\n textarea.focus()\n textarea.setSelectionRange(newCursorPos, newCursorPos)\n }, 0)\n }\n\n // Handle keyboard navigation\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (!isOpen) return\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault()\n setActiveIndex((prev) => (prev + 1) % Math.max(filtered.length, 1))\n break\n case 'ArrowUp':\n e.preventDefault()\n setActiveIndex((prev) => (prev - 1 + filtered.length) % Math.max(filtered.length, 1))\n break\n case 'Enter':\n if (filtered[activeIndex]) {\n e.preventDefault()\n selectOption(filtered[activeIndex])\n }\n break\n case 'Escape':\n e.preventDefault()\n setIsOpen(false)\n break\n case 'Tab':\n if (filtered[activeIndex]) {\n e.preventDefault()\n selectOption(filtered[activeIndex])\n }\n break\n }\n }\n\n // Close dropdown on outside click\n useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(e.target as Node) &&\n textareaRef.current &&\n !textareaRef.current.contains(e.target as Node)\n ) {\n setIsOpen(false)\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }, [])\n\n // Scroll active item into view\n useEffect(() => {\n if (isOpen && dropdownRef.current) {\n const activeItem = dropdownRef.current.querySelector('[data-active=\"true\"]')\n activeItem?.scrollIntoView({ block: 'nearest' })\n }\n }, [activeIndex, isOpen])\n\n const dropdown = isOpen && (\n <div\n ref={dropdownRef}\n className={`fixed z-50 bg-base-100 border border-base-300 rounded-lg shadow-lg\n min-w-48 max-h-60 overflow-auto ${dropdownClassName}`}\n style={{\n top: dropdownPosition.top,\n left: dropdownPosition.left,\n }}\n >\n {loading ? (\n <div className=\"p-3 text-center text-base-content/60\">\n <span className={`${dLoading} ${dLoadingSpinner} ${dLoadingSm}`}></span>\n </div>\n ) : filtered.length === 0 ? (\n <div className=\"p-3 text-center text-base-content/60 text-sm\">\n {effectiveNotFoundContent}\n </div>\n ) : (\n <ul className={`${dMenu} ${dMenuSm} p-1`}>\n {filtered.map((option, index) => (\n <li key={option.value}>\n <button\n type=\"button\"\n data-active={index === activeIndex}\n className={`flex items-center gap-2 ${\n index === activeIndex ? 'active' : ''\n } ${option.disabled ? 'disabled opacity-50 cursor-not-allowed' : ''}`}\n onClick={() => selectOption(option)}\n onMouseEnter={() => setActiveIndex(index)}\n >\n {option.avatar && (\n <div className={dAvatar}>\n <div className=\"w-6 h-6 rounded-full\">\n <img src={option.avatar} alt=\"\" />\n </div>\n </div>\n )}\n <span>{option.label || option.value}</span>\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n )\n\n return (\n <div className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} {...rest}>\n {/* Hidden measure element for cursor position */}\n <div\n ref={measureRef}\n className=\"invisible absolute whitespace-pre-wrap break-words\"\n style={{\n font: textareaRef.current ? getComputedStyle(textareaRef.current).font : undefined,\n width: textareaRef.current?.clientWidth,\n padding: textareaRef.current ? getComputedStyle(textareaRef.current).padding : undefined,\n }}\n aria-hidden=\"true\"\n />\n\n <textarea\n ref={textareaRef}\n value={currentValue}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={effectiveDisabled}\n readOnly={readOnly}\n rows={typeof autoSize === 'object' ? autoSize.minRows || rows : autoSize ? 1 : rows}\n className={`${dTextarea} ${dTextareaBordered} w-full resize-none`}\n />\n\n {createPortal(dropdown, getPopupContainer ? getPopupContainer(document.body) : document.body)}\n </div>\n )\n}\n"],"names":["dTextarea","dTextareaBordered","dMenu","dMenuSm","dLoading","dLoadingSpinner","dLoadingSm","dAvatar","Mention","value","defaultValue","onChange","onSelect","onSearch","options","loading","prefix","split","placeholder","disabled","readOnly","rows","autoSize","notFoundContent","filterOption","className","dropdownClassName","rest","componentDisabled","renderEmpty","getPopupContainer","useConfig","effectiveDisabled","effectiveNotFoundContent","internalValue","setInternalValue","useState","currentValue","isOpen","setIsOpen","activePrefix","setActivePrefix","searchText","setSearchText","activeIndex","setActiveIndex","mentionStart","setMentionStart","dropdownPosition","setDropdownPosition","textareaRef","useRef","dropdownRef","measureRef","prefixes","filtered","useCallback","filterFn","input","option","opt","updateHeight","textarea","scrollHeight","lineHeight","minHeight","maxHeight","useEffect","updateDropdownPosition","measure","textBeforeCursor","textareaRect","measureRect","handleChange","newValue","cursorPos","checkForMention","text","foundPrefix","foundStart","p","lastPrefixIndex","charBefore","textAfterPrefix","search","selectOption","beforeMention","afterCursor","mentionText","newCursorPos","handleKeyDown","prev","handleClickOutside","e","dropdown","jsx","index","jsxs","createPortal"],"mappings":";;;;AAKA,MAAMA,KAAY,YACZC,KAAoB,qBACpBC,KAAQ,QACRC,KAAU,WACVC,KAAW,WACXC,KAAkB,mBAClBC,KAAa,cACbC,KAAU,UA6BHC,KAAkC,CAAC;AAAA,EAC9C,OAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC,IAAU,CAAA;AAAA,EACV,SAAAC,IAAU;AAAA,EACV,QAAAC,IAAS;AAAA,EACT,OAAAC,IAAQ;AAAA,EACR,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,iBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,WAAAC,IAAY;AAAA,EACZ,mBAAAC,IAAoB;AAAA,EACpB,GAAGC;AACL,MAAM;AACJ,QAAM,EAAE,mBAAAC,IAAmB,aAAAC,IAAa,mBAAAC,EAAA,IAAsBC,GAAA,GACxDC,KAAoBb,KAAYS,MAAqB,IACrDK,KAA2BV,KAAmBM,KAAc,SAAS,KAAK,oBAE1E,CAACK,IAAeC,CAAgB,IAAIC,EAAS1B,CAAY,GACzD2B,IAAe5B,MAAU,SAAYA,IAAQyB,IAE7C,CAACI,GAAQC,CAAS,IAAIH,EAAS,EAAK,GACpC,CAACI,GAAcC,CAAe,IAAIL,EAAwB,IAAI,GAC9D,CAACM,GAAYC,C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