asterui 0.12.24 → 0.12.25
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/Card.d.ts +24 -7
- package/dist/components/Tag.d.ts +8 -4
- package/dist/components/TreeSelect.d.ts +35 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +43 -42
- package/dist/index11.js +55 -55
- package/dist/index11.js.map +1 -1
- package/dist/index13.js +39 -39
- package/dist/index13.js.map +1 -1
- package/dist/index14.js +192 -107
- package/dist/index14.js.map +1 -1
- package/dist/index15.js +1 -1
- package/dist/index15.js.map +1 -1
- package/dist/index30.js +9 -8
- package/dist/index30.js.map +1 -1
- package/dist/index35.js +35 -36
- package/dist/index35.js.map +1 -1
- package/dist/index43.js +19 -20
- package/dist/index43.js.map +1 -1
- package/dist/index44.js +6 -7
- package/dist/index44.js.map +1 -1
- package/dist/index5.js +9 -9
- package/dist/index5.js.map +1 -1
- package/dist/index61.js +7 -7
- package/dist/index61.js.map +1 -1
- package/dist/index62.js +10 -10
- package/dist/index62.js.map +1 -1
- package/dist/index85.js +126 -92
- package/dist/index85.js.map +1 -1
- package/dist/index92.js +1 -1
- package/dist/index92.js.map +1 -1
- package/dist/index94.js +478 -385
- package/dist/index94.js.map +1 -1
- package/package.json +1 -1
package/dist/index94.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index94.js","sources":["../src/components/TreeSelect.tsx"],"sourcesContent":["import React, {\n useState,\n useCallback,\n useRef,\n useEffect,\n useMemo,\n forwardRef,\n useId,\n} from 'react'\nimport type { TreeDataNode } from './Tree'\n\nexport type TreeSelectSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\nexport type TreeSelectColor =\n | 'primary'\n | 'secondary'\n | 'accent'\n | 'info'\n | 'success'\n | 'warning'\n | 'error'\nexport type TreeSelectStatus = 'error' | 'warning'\nexport type ShowCheckedStrategy = 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD'\n\nexport interface TreeSelectFieldNames {\n label?: string\n value?: string\n children?: string\n}\n\nexport interface TreeSelectProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n treeData: TreeDataNode[]\n value?: string | string[]\n defaultValue?: string | string[]\n onChange?: (value: string | string[], labels: React.ReactNode[]) => void\n multiple?: boolean\n treeCheckable?: boolean\n treeCheckStrictly?: boolean\n showCheckedStrategy?: ShowCheckedStrategy\n showSearch?: boolean\n searchValue?: string\n onSearch?: (value: string) => void\n filterTreeNode?: (searchValue: string, node: TreeDataNode) => boolean\n placeholder?: string\n allowClear?: boolean\n disabled?: boolean\n treeDefaultExpandAll?: boolean\n treeDefaultExpandedKeys?: string[]\n treeExpandedKeys?: string[]\n onTreeExpand?: (expandedKeys: string[]) => void\n size?: TreeSelectSize\n color?: TreeSelectColor\n status?: TreeSelectStatus\n maxTagCount?: number | 'responsive'\n maxTagPlaceholder?: React.ReactNode | ((omittedValues: string[]) => React.ReactNode)\n labelInValue?: boolean\n treeLine?: boolean\n treeIcon?: boolean\n loadData?: (node: TreeDataNode) => Promise<void>\n fieldNames?: TreeSelectFieldNames\n open?: boolean\n onDropdownVisibleChange?: (open: boolean) => void\n suffixIcon?: React.ReactNode\n switcherIcon?: React.ReactNode | ((props: { expanded: boolean }) => React.ReactNode)\n notFoundContent?: React.ReactNode\n dropdownRender?: (menu: React.ReactNode) => React.ReactNode\n popupClassName?: string\n 'data-testid'?: string\n}\n\n// Helper to get field value based on fieldNames\nfunction getFieldValue(\n node: TreeDataNode,\n field: 'title' | 'key' | 'children',\n fieldNames?: TreeSelectFieldNames\n): unknown {\n if (field === 'title') {\n const labelField = fieldNames?.label || 'title'\n return (node as Record<string, unknown>)[labelField]\n }\n if (field === 'key') {\n const valueField = fieldNames?.value || 'key'\n return (node as Record<string, unknown>)[valueField]\n }\n if (field === 'children') {\n const childrenField = fieldNames?.children || 'children'\n return (node as Record<string, unknown>)[childrenField]\n }\n return undefined\n}\n\n// Helper to flatten tree data for search\nfunction flattenTree(\n data: TreeDataNode[],\n parentPath: React.ReactNode[] = [],\n fieldNames?: TreeSelectFieldNames\n): Array<{ node: TreeDataNode; path: React.ReactNode[] }> {\n const result: Array<{ node: TreeDataNode; path: React.ReactNode[] }> = []\n\n data.forEach((node) => {\n const title = getFieldValue(node, 'title', fieldNames) as React.ReactNode\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n const currentPath = [...parentPath, title]\n result.push({ node, path: currentPath })\n if (children) {\n result.push(...flattenTree(children, currentPath, fieldNames))\n }\n })\n\n return result\n}\n\n// Helper to get all keys\nfunction getAllKeys(data: TreeDataNode[], fieldNames?: TreeSelectFieldNames): string[] {\n const keys: string[] = []\n const traverse = (nodes: TreeDataNode[]) => {\n nodes.forEach((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n keys.push(key)\n if (children) traverse(children)\n })\n }\n traverse(data)\n return keys\n}\n\n// Helper to find node by key\nfunction findNode(\n data: TreeDataNode[],\n key: string,\n fieldNames?: TreeSelectFieldNames\n): TreeDataNode | null {\n for (const node of data) {\n const nodeKey = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n if (nodeKey === key) return node\n if (children) {\n const found = findNode(children, key, fieldNames)\n if (found) return found\n }\n }\n return null\n}\n\n// Helper to get all descendant keys\nfunction getDescendantKeys(node: TreeDataNode, fieldNames?: TreeSelectFieldNames): string[] {\n const keys: string[] = []\n const traverse = (n: TreeDataNode) => {\n const children = getFieldValue(n, 'children', fieldNames) as TreeDataNode[] | undefined\n if (children) {\n children.forEach((child) => {\n const childKey = getFieldValue(child, 'key', fieldNames) as string\n keys.push(childKey)\n traverse(child)\n })\n }\n }\n traverse(node)\n return keys\n}\n\n// Helper to get parent keys for a node\nfunction getParentKeys(\n data: TreeDataNode[],\n targetKey: string,\n fieldNames?: TreeSelectFieldNames,\n parentKeys: string[] = []\n): string[] | null {\n for (const node of data) {\n const nodeKey = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n if (nodeKey === targetKey) return parentKeys\n if (children) {\n const found = getParentKeys(children, targetKey, fieldNames, [...parentKeys, nodeKey])\n if (found) return found\n }\n }\n return null\n}\n\ninterface TreeSelectNodeProps {\n node: TreeDataNode\n level: number\n expanded: boolean\n selected: boolean\n checked: boolean\n indeterminate: boolean\n treeCheckable: boolean\n treeLine: boolean\n focused: boolean\n loading: boolean\n baseTestId: string\n id: string\n fieldNames?: TreeSelectFieldNames\n switcherIcon?: React.ReactNode | ((props: { expanded: boolean }) => React.ReactNode)\n onToggle: (key: string) => void\n onSelect: (key: string, node: TreeDataNode) => void\n onCheck: (key: string, node: TreeDataNode) => void\n renderChildren: (children: TreeDataNode[], level: number) => React.ReactNode\n}\n\nfunction TreeSelectNode({\n node,\n level,\n expanded,\n selected,\n checked,\n indeterminate,\n treeCheckable,\n treeLine,\n focused,\n loading,\n baseTestId,\n id,\n fieldNames,\n switcherIcon,\n onToggle,\n onSelect,\n onCheck,\n renderChildren,\n}: TreeSelectNodeProps) {\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n const title = getFieldValue(node, 'title', fieldNames) as React.ReactNode\n const key = getFieldValue(node, 'key', fieldNames) as string\n const hasChildren = children && children.length > 0\n const isLeaf = node.isLeaf ?? !hasChildren\n\n const handleToggle = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!isLeaf) {\n onToggle(key)\n }\n }\n\n const handleSelect = () => {\n if (!node.disabled) {\n if (treeCheckable) {\n onCheck(key, node)\n } else {\n onSelect(key, node)\n }\n }\n }\n\n const handleCheck = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!node.disabled) {\n onCheck(key, node)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleSelect()\n }\n }\n\n const renderSwitcherIcon = () => {\n if (loading) {\n return (\n <span className=\"loading loading-spinner loading-xs\" />\n )\n }\n\n if (switcherIcon) {\n if (typeof switcherIcon === 'function') {\n return switcherIcon({ expanded })\n }\n return switcherIcon\n }\n\n return (\n <svg\n className={`w-3 h-3 transition-transform ${expanded ? 'rotate-90' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M9 5l7 7-7 7\" />\n </svg>\n )\n }\n\n return (\n <div\n className=\"tree-select-node\"\n role=\"treeitem\"\n id={id}\n aria-selected={selected || checked}\n aria-expanded={hasChildren ? expanded : undefined}\n data-testid={`${baseTestId}-option-${key}`}\n data-state={selected || checked ? 'selected' : 'unselected'}\n data-disabled={node.disabled || undefined}\n >\n <div\n className={[\n 'flex items-center py-1.5 px-2 cursor-pointer hover:bg-base-200 transition-colors outline-none',\n (selected || checked) && 'bg-primary/10 text-primary',\n node.disabled && 'opacity-50 cursor-not-allowed',\n focused && 'ring-2 ring-primary ring-inset',\n treeLine && level > 0 && 'border-l border-base-300 ml-2',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{ paddingLeft: `${level * 16 + 8}px` }}\n onClick={handleSelect}\n onKeyDown={handleKeyDown}\n tabIndex={-1}\n >\n {/* Expand/Collapse icon */}\n <span\n className={[\n 'w-4 h-4 flex items-center justify-center flex-shrink-0 mr-1',\n !isLeaf && 'cursor-pointer',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={handleToggle}\n aria-hidden=\"true\"\n >\n {!isLeaf && renderSwitcherIcon()}\n </span>\n\n {/* Checkbox for treeCheckable mode */}\n {treeCheckable && (\n <span className=\"mr-2 flex-shrink-0\" onClick={handleCheck}>\n <input\n type=\"checkbox\"\n className=\"checkbox checkbox-sm checkbox-primary\"\n checked={checked}\n ref={(el) => {\n if (el) el.indeterminate = indeterminate\n }}\n disabled={node.disabled}\n onChange={handleSelect}\n aria-label={typeof title === 'string' ? title : undefined}\n tabIndex={-1}\n />\n </span>\n )}\n\n {/* Title */}\n <span className=\"flex-1 truncate select-none text-sm\">{title}</span>\n </div>\n\n {/* Children */}\n {hasChildren && expanded && (\n <div role=\"group\">{renderChildren(children!, level + 1)}</div>\n )}\n </div>\n )\n}\n\nconst sizeClasses: Record<TreeSelectSize, string> = {\n xs: 'min-h-6 text-xs',\n sm: 'min-h-8 text-sm',\n md: 'min-h-10 text-base',\n lg: 'min-h-12 text-lg',\n xl: 'min-h-14 text-xl',\n}\n\nconst colorClasses: Record<TreeSelectColor, string> = {\n primary: 'border-primary focus-within:border-primary',\n secondary: 'border-secondary focus-within:border-secondary',\n accent: 'border-accent focus-within:border-accent',\n info: 'border-info focus-within:border-info',\n success: 'border-success focus-within:border-success',\n warning: 'border-warning focus-within:border-warning',\n error: 'border-error focus-within:border-error',\n}\n\nconst statusClasses: Record<TreeSelectStatus, string> = {\n error: 'border-error focus-within:border-error',\n warning: 'border-warning focus-within:border-warning',\n}\n\nexport const TreeSelect = forwardRef<HTMLDivElement, TreeSelectProps>(\n (\n {\n treeData,\n value: controlledValue,\n defaultValue = [],\n onChange,\n multiple = false,\n treeCheckable = false,\n treeCheckStrictly = false,\n showCheckedStrategy = 'SHOW_ALL',\n showSearch = false,\n searchValue: controlledSearchValue,\n onSearch,\n filterTreeNode,\n placeholder = 'Please select',\n allowClear = true,\n disabled = false,\n treeDefaultExpandAll = false,\n treeDefaultExpandedKeys = [],\n treeExpandedKeys: controlledExpandedKeys,\n onTreeExpand,\n size = 'md',\n color,\n status,\n maxTagCount,\n maxTagPlaceholder,\n labelInValue = false,\n treeLine = false,\n loadData,\n fieldNames,\n open: controlledOpen,\n onDropdownVisibleChange,\n suffixIcon,\n switcherIcon,\n notFoundContent = 'No results found',\n dropdownRender,\n popupClassName = '',\n className = '',\n 'data-testid': testId,\n ...rest\n },\n ref\n ) => {\n const baseTestId = testId ?? 'treeselect'\n const instanceId = useId()\n const listboxId = `${instanceId}-listbox`\n const [isOpen, setIsOpen] = useState(false)\n const [internalSearchValue, setInternalSearchValue] = useState('')\n const [focusedKey, setFocusedKey] = useState<string | null>(null)\n const [loadingKeys, setLoadingKeys] = useState<Set<string>>(new Set())\n const containerRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n const searchValue = controlledSearchValue ?? internalSearchValue\n const open = controlledOpen ?? isOpen\n\n // Normalize value to array\n const normalizeValue = (val: string | string[] | undefined): string[] => {\n if (val === undefined) return []\n return Array.isArray(val) ? val : [val]\n }\n\n const initialValue = normalizeValue(defaultValue)\n const [internalValue, setInternalValue] = useState<string[]>(initialValue)\n\n const value = controlledValue !== undefined ? normalizeValue(controlledValue) : internalValue\n\n // Expanded keys\n const initialExpandedKeys = useMemo(() => {\n if (treeDefaultExpandAll) return getAllKeys(treeData, fieldNames)\n return treeDefaultExpandedKeys\n }, [treeData, treeDefaultExpandAll, treeDefaultExpandedKeys, fieldNames])\n\n const [internalExpandedKeys, setInternalExpandedKeys] = useState<string[]>(initialExpandedKeys)\n const expandedKeys = controlledExpandedKeys ?? internalExpandedKeys\n\n // Get flattened visible nodes for keyboard navigation\n const visibleNodes = useMemo(() => {\n const nodes: { key: string; node: TreeDataNode }[] = []\n const traverse = (data: TreeDataNode[]) => {\n data.forEach((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n nodes.push({ key, node })\n if (children && expandedKeys.includes(key)) {\n traverse(children)\n }\n })\n }\n traverse(treeData)\n return nodes\n }, [treeData, expandedKeys, fieldNames])\n\n const setOpen = useCallback(\n (newOpen: boolean) => {\n if (controlledOpen === undefined) {\n setIsOpen(newOpen)\n }\n onDropdownVisibleChange?.(newOpen)\n },\n [controlledOpen, onDropdownVisibleChange]\n )\n\n // Close on click outside\n useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }, [setOpen, controlledSearchValue])\n\n // Focus management\n useEffect(() => {\n if (open && showSearch && inputRef.current) {\n inputRef.current.focus()\n } else if (open && triggerRef.current) {\n triggerRef.current.focus()\n }\n }, [open, showSearch])\n\n // Initialize focused key when opening\n useEffect(() => {\n if (open && visibleNodes.length > 0) {\n if (value.length > 0) {\n setFocusedKey(value[0])\n } else {\n setFocusedKey(visibleNodes[0].key)\n }\n } else if (!open) {\n setFocusedKey(null)\n }\n }, [open, visibleNodes, value])\n\n // Filter tree data based on search\n const filteredData = useMemo(() => {\n if (!searchValue) return treeData\n\n const flatNodes = flattenTree(treeData, [], fieldNames)\n const matchingKeys = new Set<string>()\n\n flatNodes.forEach(({ node }) => {\n const title = getFieldValue(node, 'title', fieldNames)\n const key = getFieldValue(node, 'key', fieldNames) as string\n\n let isMatch = false\n if (filterTreeNode) {\n isMatch = filterTreeNode(searchValue, node)\n } else {\n const titleStr = typeof title === 'string' ? title : String(title)\n isMatch = titleStr.toLowerCase().includes(searchValue.toLowerCase())\n }\n\n if (isMatch) {\n matchingKeys.add(key)\n }\n })\n\n // Include parent keys of matching nodes\n const filterTree = (nodes: TreeDataNode[]): TreeDataNode[] => {\n return nodes\n .map((node) => {\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n const key = getFieldValue(node, 'key', fieldNames) as string\n const hasMatchingChildren = children && filterTree(children).length > 0\n const isMatch = matchingKeys.has(key)\n\n if (isMatch || hasMatchingChildren) {\n return {\n ...node,\n children: children ? filterTree(children) : undefined,\n }\n }\n return null\n })\n .filter(Boolean) as TreeDataNode[]\n }\n\n return filterTree(treeData)\n }, [treeData, searchValue, filterTreeNode, fieldNames])\n\n const handleToggle = useCallback(\n async (key: string) => {\n const node = findNode(treeData, key, fieldNames)\n\n // Handle async loading\n if (loadData && node) {\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n if (!children || children.length === 0) {\n setLoadingKeys((prev) => new Set(prev).add(key))\n try {\n await loadData(node)\n } finally {\n setLoadingKeys((prev) => {\n const next = new Set(prev)\n next.delete(key)\n return next\n })\n }\n }\n }\n\n const newKeys = expandedKeys.includes(key)\n ? expandedKeys.filter((k) => k !== key)\n : [...expandedKeys, key]\n\n if (controlledExpandedKeys === undefined) {\n setInternalExpandedKeys(newKeys)\n }\n onTreeExpand?.(newKeys)\n },\n [expandedKeys, controlledExpandedKeys, onTreeExpand, loadData, treeData, fieldNames]\n )\n\n const handleSelect = useCallback(\n (key: string, _node: TreeDataNode) => {\n let newValue: string[]\n\n if (multiple) {\n if (value.includes(key)) {\n newValue = value.filter((k) => k !== key)\n } else {\n newValue = [...value, key]\n }\n } else {\n newValue = [key]\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n }\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const node = findNode(treeData, k, fieldNames)\n return node ? getFieldValue(node, 'title', fieldNames) as React.ReactNode : k\n })\n onChange?.(multiple ? newValue : newValue[0] || '', labels)\n },\n [\n value,\n multiple,\n controlledValue,\n onChange,\n treeData,\n setOpen,\n controlledSearchValue,\n fieldNames,\n ]\n )\n\n const handleCheck = useCallback(\n (key: string, node: TreeDataNode) => {\n const isChecked = value.includes(key)\n let newValue = [...value]\n\n if (treeCheckStrictly) {\n // No parent-child association\n if (isChecked) {\n newValue = newValue.filter((k) => k !== key)\n } else {\n newValue.push(key)\n }\n } else {\n const descendantKeys = getDescendantKeys(node, fieldNames)\n\n if (isChecked) {\n newValue = newValue.filter((k) => k !== key && !descendantKeys.includes(k))\n } else {\n newValue.push(key)\n descendantKeys.forEach((dk) => {\n if (!newValue.includes(dk)) newValue.push(dk)\n })\n }\n }\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const n = findNode(treeData, k, fieldNames)\n return n ? getFieldValue(n, 'title', fieldNames) as React.ReactNode : k\n })\n onChange?.(newValue, labels)\n },\n [value, controlledValue, onChange, treeData, treeCheckStrictly, fieldNames]\n )\n\n const handleClear = (e: React.MouseEvent) => {\n e.stopPropagation()\n const newValue: string[] = []\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n onChange?.(multiple || treeCheckable ? newValue : '', [])\n }\n\n const removeTag = (key: string, e: React.MouseEvent) => {\n e.stopPropagation()\n const newValue = value.filter((k) => k !== key)\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const n = findNode(treeData, k, fieldNames)\n return n ? getFieldValue(n, 'title', fieldNames) as React.ReactNode : k\n })\n onChange?.(multiple || treeCheckable ? newValue : newValue[0] || '', labels)\n }\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value\n if (controlledSearchValue === undefined) {\n setInternalSearchValue(newValue)\n }\n onSearch?.(newValue)\n }\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return\n\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (!open) {\n e.preventDefault()\n setOpen(true)\n } else if (focusedKey) {\n e.preventDefault()\n const node = findNode(treeData, focusedKey, fieldNames)\n if (node && !node.disabled) {\n if (treeCheckable) {\n handleCheck(focusedKey, node)\n } else {\n handleSelect(focusedKey, node)\n }\n }\n }\n break\n\n case 'Escape':\n e.preventDefault()\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n triggerRef.current?.focus()\n break\n\n case 'ArrowDown':\n e.preventDefault()\n if (!open) {\n setOpen(true)\n } else {\n const currentIndex = visibleNodes.findIndex((n) => n.key === focusedKey)\n const nextIndex = currentIndex < visibleNodes.length - 1 ? currentIndex + 1 : 0\n setFocusedKey(visibleNodes[nextIndex]?.key || null)\n }\n break\n\n case 'ArrowUp':\n e.preventDefault()\n if (open) {\n const currentIndex = visibleNodes.findIndex((n) => n.key === focusedKey)\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : visibleNodes.length - 1\n setFocusedKey(visibleNodes[prevIndex]?.key || null)\n }\n break\n\n case 'ArrowRight':\n if (open && focusedKey) {\n e.preventDefault()\n const node = findNode(treeData, focusedKey, fieldNames)\n const children = node\n ? (getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined)\n : undefined\n if (children && children.length > 0 && !expandedKeys.includes(focusedKey)) {\n handleToggle(focusedKey)\n }\n }\n break\n\n case 'ArrowLeft':\n if (open && focusedKey) {\n e.preventDefault()\n if (expandedKeys.includes(focusedKey)) {\n handleToggle(focusedKey)\n } else {\n // Move to parent\n const parentKeys = getParentKeys(treeData, focusedKey, fieldNames)\n if (parentKeys && parentKeys.length > 0) {\n setFocusedKey(parentKeys[parentKeys.length - 1])\n }\n }\n }\n break\n\n case 'Home':\n if (open) {\n e.preventDefault()\n setFocusedKey(visibleNodes[0]?.key || null)\n }\n break\n\n case 'End':\n if (open) {\n e.preventDefault()\n setFocusedKey(visibleNodes[visibleNodes.length - 1]?.key || null)\n }\n break\n }\n }\n\n const getCheckedState = useCallback(\n (node: TreeDataNode): { checked: boolean; indeterminate: boolean } => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n\n if (treeCheckStrictly) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n if (!children || children.length === 0) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n const descendantKeys = getDescendantKeys(node, fieldNames)\n const checkedDescendants = descendantKeys.filter((k) => value.includes(k))\n\n if (checkedDescendants.length === 0) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n if (checkedDescendants.length === descendantKeys.length) {\n return { checked: true, indeterminate: false }\n }\n\n return { checked: false, indeterminate: true }\n },\n [value, treeCheckStrictly, fieldNames]\n )\n\n const renderNodes = useCallback(\n (nodes: TreeDataNode[], level: number): React.ReactNode => {\n return nodes.map((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const { checked, indeterminate } = getCheckedState(node)\n\n return (\n <TreeSelectNode\n key={key}\n node={node}\n level={level}\n expanded={expandedKeys.includes(key)}\n selected={value.includes(key)}\n checked={checked}\n indeterminate={indeterminate}\n treeCheckable={treeCheckable}\n treeLine={treeLine}\n focused={focusedKey === key}\n loading={loadingKeys.has(key)}\n baseTestId={baseTestId}\n id={`${instanceId}-option-${key}`}\n fieldNames={fieldNames}\n switcherIcon={switcherIcon}\n onToggle={handleToggle}\n onSelect={handleSelect}\n onCheck={handleCheck}\n renderChildren={renderNodes}\n />\n )\n })\n },\n [\n expandedKeys,\n value,\n treeCheckable,\n treeLine,\n focusedKey,\n loadingKeys,\n baseTestId,\n instanceId,\n fieldNames,\n switcherIcon,\n handleToggle,\n handleSelect,\n handleCheck,\n getCheckedState,\n ]\n )\n\n // Display value with showCheckedStrategy\n const displayValue = useMemo(() => {\n if (value.length === 0) return null\n\n let displayKeys = value\n\n if ((treeCheckable || multiple) && showCheckedStrategy !== 'SHOW_ALL') {\n if (showCheckedStrategy === 'SHOW_PARENT') {\n // Only show parent nodes when all children are selected\n displayKeys = value.filter((key) => {\n const parentKeys = getParentKeys(treeData, key, fieldNames)\n if (!parentKeys) return true\n // Check if any parent is fully selected\n return !parentKeys.some((pk) => value.includes(pk))\n })\n } else if (showCheckedStrategy === 'SHOW_CHILD') {\n // Only show leaf nodes\n displayKeys = value.filter((key) => {\n const node = findNode(treeData, key, fieldNames)\n if (!node) return true\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n return !children || children.length === 0\n })\n }\n }\n\n if (multiple || treeCheckable) {\n let keysToShow = displayKeys\n let hiddenCount = 0\n\n if (maxTagCount !== undefined && maxTagCount !== 'responsive') {\n if (displayKeys.length > maxTagCount) {\n keysToShow = displayKeys.slice(0, maxTagCount)\n hiddenCount = displayKeys.length - maxTagCount\n }\n }\n\n const tags = keysToShow.map((key) => {\n const node = findNode(treeData, key, fieldNames)\n const title = node ? getFieldValue(node, 'title', fieldNames) : key\n return (\n <span\n key={key}\n className=\"inline-flex items-center gap-1 px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1\"\n data-testid={`${baseTestId}-tag-${key}`}\n >\n {title as React.ReactNode}\n <button\n type=\"button\"\n className=\"hover:text-error\"\n onClick={(e) => removeTag(key, e)}\n aria-label={`Remove ${typeof title === 'string' ? title : key}`}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n </span>\n )\n })\n\n if (hiddenCount > 0) {\n const hiddenKeys = displayKeys.slice(maxTagCount as number)\n const placeholder =\n typeof maxTagPlaceholder === 'function'\n ? maxTagPlaceholder(hiddenKeys)\n : maxTagPlaceholder || `+${hiddenCount} more`\n\n tags.push(\n <span\n key=\"__more__\"\n className=\"inline-flex items-center px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1\"\n >\n {placeholder}\n </span>\n )\n }\n\n return tags\n }\n\n const node = findNode(treeData, value[0], fieldNames)\n const title = node ? getFieldValue(node, 'title', fieldNames) : value[0]\n return title as React.ReactNode\n }, [\n value,\n treeData,\n multiple,\n treeCheckable,\n showCheckedStrategy,\n maxTagCount,\n maxTagPlaceholder,\n baseTestId,\n fieldNames,\n ])\n\n const borderClass = status ? statusClasses[status] : color ? colorClasses[color] : ''\n\n const dropdownContent = (\n <div className=\"py-1\" role=\"tree\" aria-label=\"Tree options\">\n {filteredData.length > 0 ? (\n renderNodes(filteredData, 0)\n ) : (\n <div\n className=\"px-4 py-2 text-base-content/50 text-sm text-center\"\n data-testid={`${baseTestId}-empty`}\n >\n {notFoundContent}\n </div>\n )}\n </div>\n )\n\n return (\n <div\n ref={(node) => {\n containerRef.current = node\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n }}\n className={`relative ${className}`}\n data-testid={baseTestId}\n data-state={open ? 'open' : 'closed'}\n data-disabled={disabled || undefined}\n onKeyDown={handleKeyDown}\n {...rest}\n >\n {/* Trigger */}\n <div\n ref={triggerRef}\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"tree\"\n aria-owns={open ? listboxId : undefined}\n aria-activedescendant={open && focusedKey ? `${instanceId}-option-${focusedKey}` : undefined}\n aria-disabled={disabled}\n tabIndex={disabled ? -1 : 0}\n className={[\n 'input input-bordered flex items-center gap-2 cursor-pointer flex-wrap',\n sizeClasses[size],\n borderClass,\n disabled && 'input-disabled opacity-50 cursor-not-allowed',\n open && !borderClass && 'input-primary',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={() => !disabled && setOpen(!open)}\n data-testid={`${baseTestId}-trigger`}\n >\n <div className=\"flex-1 flex flex-wrap items-center gap-1 min-w-0\">\n {displayValue || <span className=\"text-base-content/50\">{placeholder}</span>}\n </div>\n\n {/* Clear button */}\n {allowClear && value.length > 0 && !disabled && (\n <button\n type=\"button\"\n className=\"hover:text-error flex-shrink-0\"\n onClick={handleClear}\n aria-label=\"Clear selection\"\n data-testid={`${baseTestId}-clear`}\n >\n <svg\n className=\"w-4 h-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n )}\n\n {/* Suffix icon / Dropdown arrow */}\n {suffixIcon || (\n <svg\n className={`w-4 h-4 flex-shrink-0 transition-transform ${open ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n )}\n </div>\n\n {/* Dropdown */}\n {open && (\n <div\n id={listboxId}\n className={`absolute z-50 mt-1 w-full bg-base-100 border border-base-300 rounded-lg shadow-lg max-h-64 overflow-auto ${popupClassName}`}\n data-testid={`${baseTestId}-dropdown`}\n >\n {/* Search input */}\n {showSearch && (\n <div className=\"p-2 border-b border-base-300\">\n <input\n ref={inputRef}\n type=\"text\"\n className=\"input input-bordered input-sm w-full\"\n placeholder=\"Search...\"\n value={searchValue}\n onChange={handleSearchChange}\n onClick={(e) => e.stopPropagation()}\n aria-label=\"Search tree options\"\n data-testid={`${baseTestId}-search`}\n />\n </div>\n )}\n\n {/* Tree */}\n {dropdownRender ? dropdownRender(dropdownContent) : dropdownContent}\n </div>\n )}\n </div>\n )\n }\n)\n\nTreeSelect.displayName = 'TreeSelect'\n"],"names":["getFieldValue","node","field","fieldNames","labelField","valueField","childrenField","flattenTree","data","parentPath","result","title","children","currentPath","getAllKeys","keys","traverse","nodes","key","findNode","nodeKey","found","getDescendantKeys","n","child","childKey","getParentKeys","targetKey","parentKeys","TreeSelectNode","level","expanded","selected","checked","indeterminate","treeCheckable","treeLine","focused","loading","baseTestId","id","switcherIcon","onToggle","onSelect","onCheck","renderChildren","hasChildren","isLeaf","handleToggle","e","handleSelect","handleCheck","handleKeyDown","renderSwitcherIcon","jsx","jsxs","el","sizeClasses","colorClasses","statusClasses","TreeSelect","forwardRef","treeData","controlledValue","defaultValue","onChange","multiple","treeCheckStrictly","showCheckedStrategy","showSearch","controlledSearchValue","onSearch","filterTreeNode","placeholder","allowClear","disabled","treeDefaultExpandAll","treeDefaultExpandedKeys","controlledExpandedKeys","onTreeExpand","size","color","status","maxTagCount","maxTagPlaceholder","labelInValue","loadData","controlledOpen","onDropdownVisibleChange","suffixIcon","notFoundContent","dropdownRender","popupClassName","className","testId","rest","ref","instanceId","useId","listboxId","isOpen","setIsOpen","useState","internalSearchValue","setInternalSearchValue","focusedKey","setFocusedKey","loadingKeys","setLoadingKeys","containerRef","useRef","inputRef","triggerRef","searchValue","open","normalizeValue","val","initialValue","internalValue","setInternalValue","value","initialExpandedKeys","useMemo","internalExpandedKeys","setInternalExpandedKeys","expandedKeys","visibleNodes","setOpen","useCallback","newOpen","useEffect","handleClickOutside","filteredData","flatNodes","matchingKeys","isMatch","filterTree","hasMatchingChildren","prev","next","newKeys","k","_node","newValue","labels","isChecked","descendantKeys","dk","handleClear","removeTag","handleSearchChange","currentIndex","nextIndex","prevIndex","getCheckedState","checkedDescendants","renderNodes","displayValue","displayKeys","pk","keysToShow","hiddenCount","tags","hiddenKeys","borderClass","dropdownContent"],"mappings":";;AAuEA,SAASA,EACPC,GACAC,GACAC,GACS;AACT,MAAID,MAAU,SAAS;AACrB,UAAME,IAAaD,GAAY,SAAS;AACxC,WAAQF,EAAiCG,CAAU;AAAA,EACrD;AACA,MAAIF,MAAU,OAAO;AACnB,UAAMG,IAAaF,GAAY,SAAS;AACxC,WAAQF,EAAiCI,CAAU;AAAA,EACrD;AACA,MAAIH,MAAU,YAAY;AACxB,UAAMI,IAAgBH,GAAY,YAAY;AAC9C,WAAQF,EAAiCK,CAAa;AAAA,EACxD;AAEF;AAGA,SAASC,GACPC,GACAC,IAAgC,CAAA,GAChCN,GACwD;AACxD,QAAMO,IAAiE,CAAA;AAEvE,SAAAF,EAAK,QAAQ,CAACP,MAAS;AACrB,UAAMU,IAAQX,EAAcC,GAAM,SAASE,CAAU,GAC/CS,IAAWZ,EAAcC,GAAM,YAAYE,CAAU,GACrDU,IAAc,CAAC,GAAGJ,GAAYE,CAAK;AACzC,IAAAD,EAAO,KAAK,EAAE,MAAAT,GAAM,MAAMY,GAAa,GACnCD,KACFF,EAAO,KAAK,GAAGH,GAAYK,GAAUC,GAA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],"sourcesContent":["import React, {\n useState,\n useCallback,\n useRef,\n useEffect,\n useMemo,\n forwardRef,\n useId,\n} from 'react'\nimport type { TreeDataNode } from './Tree'\n\nexport type TreeSelectSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\nexport type TreeSelectColor =\n | 'primary'\n | 'secondary'\n | 'accent'\n | 'neutral'\n | 'info'\n | 'success'\n | 'warning'\n | 'error'\nexport type TreeSelectStatus = 'error' | 'warning'\nexport type TreeSelectVariant = 'outlined' | 'filled' | 'borderless'\nexport type ShowCheckedStrategy = 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD'\n\n// Static strategy constants\nconst SHOW_ALL: ShowCheckedStrategy = 'SHOW_ALL'\nconst SHOW_PARENT: ShowCheckedStrategy = 'SHOW_PARENT'\nconst SHOW_CHILD: ShowCheckedStrategy = 'SHOW_CHILD'\n\nexport interface TreeSelectFieldNames {\n label?: string\n value?: string\n children?: string\n}\n\n/** Value type when labelInValue is true */\nexport interface LabeledValue {\n value: string\n label: React.ReactNode\n}\n\nexport interface TreeSelectProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n treeData: TreeDataNode[]\n value?: string | string[] | LabeledValue | LabeledValue[]\n defaultValue?: string | string[] | LabeledValue | LabeledValue[]\n onChange?: (\n value: string | string[] | LabeledValue | LabeledValue[],\n labels: React.ReactNode[],\n extra?: { triggerValue: string; triggerNode: TreeDataNode }\n ) => void\n multiple?: boolean\n treeCheckable?: boolean\n treeCheckStrictly?: boolean\n showCheckedStrategy?: ShowCheckedStrategy\n showSearch?: boolean\n searchValue?: string\n onSearch?: (value: string) => void\n filterTreeNode?: (searchValue: string, node: TreeDataNode) => boolean\n placeholder?: string\n allowClear?: boolean\n disabled?: boolean\n treeDefaultExpandAll?: boolean\n treeDefaultExpandedKeys?: string[]\n treeExpandedKeys?: string[]\n onTreeExpand?: (expandedKeys: string[]) => void\n size?: TreeSelectSize\n color?: TreeSelectColor\n status?: TreeSelectStatus\n /** Visual variant style */\n variant?: TreeSelectVariant\n /** Ghost style with no background */\n ghost?: boolean\n /** Maximum number of tags to show (multiple/treeCheckable mode) */\n maxTagCount?: number | 'responsive'\n maxTagPlaceholder?: React.ReactNode | ((omittedValues: string[]) => React.ReactNode)\n /** Maximum number of selections allowed */\n maxCount?: number\n /** Return object with value and label instead of just value */\n labelInValue?: boolean\n /** Custom tag render function */\n tagRender?: (props: {\n label: React.ReactNode\n value: string\n closable: boolean\n onClose: () => void\n }) => React.ReactNode\n treeLine?: boolean\n /** Show tree node icon */\n treeIcon?: boolean\n loadData?: (node: TreeDataNode) => Promise<void>\n fieldNames?: TreeSelectFieldNames\n open?: boolean\n onDropdownVisibleChange?: (open: boolean) => void\n suffixIcon?: React.ReactNode\n switcherIcon?: React.ReactNode | ((props: { expanded: boolean }) => React.ReactNode)\n notFoundContent?: React.ReactNode\n dropdownRender?: (menu: React.ReactNode) => React.ReactNode\n popupClassName?: string\n 'data-testid'?: string\n}\n\n// Helper to get field value based on fieldNames\nfunction getFieldValue(\n node: TreeDataNode,\n field: 'title' | 'key' | 'children',\n fieldNames?: TreeSelectFieldNames\n): unknown {\n if (field === 'title') {\n const labelField = fieldNames?.label || 'title'\n return (node as unknown as Record<string, unknown>)[labelField]\n }\n if (field === 'key') {\n const valueField = fieldNames?.value || 'key'\n return (node as unknown as Record<string, unknown>)[valueField]\n }\n if (field === 'children') {\n const childrenField = fieldNames?.children || 'children'\n return (node as unknown as Record<string, unknown>)[childrenField]\n }\n return undefined\n}\n\n// Helper to flatten tree data for search\nfunction flattenTree(\n data: TreeDataNode[],\n parentPath: React.ReactNode[] = [],\n fieldNames?: TreeSelectFieldNames\n): Array<{ node: TreeDataNode; path: React.ReactNode[] }> {\n const result: Array<{ node: TreeDataNode; path: React.ReactNode[] }> = []\n\n data.forEach((node) => {\n const title = getFieldValue(node, 'title', fieldNames) as React.ReactNode\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n const currentPath = [...parentPath, title]\n result.push({ node, path: currentPath })\n if (children) {\n result.push(...flattenTree(children, currentPath, fieldNames))\n }\n })\n\n return result\n}\n\n// Helper to get all keys\nfunction getAllKeys(data: TreeDataNode[], fieldNames?: TreeSelectFieldNames): string[] {\n const keys: string[] = []\n const traverse = (nodes: TreeDataNode[]) => {\n nodes.forEach((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n keys.push(key)\n if (children) traverse(children)\n })\n }\n traverse(data)\n return keys\n}\n\n// Helper to find node by key\nfunction findNode(\n data: TreeDataNode[],\n key: string,\n fieldNames?: TreeSelectFieldNames\n): TreeDataNode | null {\n for (const node of data) {\n const nodeKey = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n if (nodeKey === key) return node\n if (children) {\n const found = findNode(children, key, fieldNames)\n if (found) return found\n }\n }\n return null\n}\n\n// Helper to get all descendant keys\nfunction getDescendantKeys(node: TreeDataNode, fieldNames?: TreeSelectFieldNames): string[] {\n const keys: string[] = []\n const traverse = (n: TreeDataNode) => {\n const children = getFieldValue(n, 'children', fieldNames) as TreeDataNode[] | undefined\n if (children) {\n children.forEach((child) => {\n const childKey = getFieldValue(child, 'key', fieldNames) as string\n keys.push(childKey)\n traverse(child)\n })\n }\n }\n traverse(node)\n return keys\n}\n\n// Helper to get parent keys for a node\nfunction getParentKeys(\n data: TreeDataNode[],\n targetKey: string,\n fieldNames?: TreeSelectFieldNames,\n parentKeys: string[] = []\n): string[] | null {\n for (const node of data) {\n const nodeKey = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n if (nodeKey === targetKey) return parentKeys\n if (children) {\n const found = getParentKeys(children, targetKey, fieldNames, [...parentKeys, nodeKey])\n if (found) return found\n }\n }\n return null\n}\n\ninterface TreeSelectNodeProps {\n node: TreeDataNode\n level: number\n expanded: boolean\n selected: boolean\n checked: boolean\n indeterminate: boolean\n treeCheckable: boolean\n treeLine: boolean\n treeIcon: boolean\n focused: boolean\n loading: boolean\n baseTestId: string\n id: string\n fieldNames?: TreeSelectFieldNames\n switcherIcon?: React.ReactNode | ((props: { expanded: boolean }) => React.ReactNode)\n onToggle: (key: string) => void\n onSelect: (key: string, node: TreeDataNode) => void\n onCheck: (key: string, node: TreeDataNode) => void\n renderChildren: (children: TreeDataNode[], level: number) => React.ReactNode\n}\n\nfunction TreeSelectNode({\n node,\n level,\n expanded,\n selected,\n checked,\n indeterminate,\n treeCheckable,\n treeLine,\n treeIcon: showTreeIcon,\n focused,\n loading,\n baseTestId,\n id,\n fieldNames,\n switcherIcon,\n onToggle,\n onSelect,\n onCheck,\n renderChildren,\n}: TreeSelectNodeProps) {\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n const title = getFieldValue(node, 'title', fieldNames) as React.ReactNode\n const key = getFieldValue(node, 'key', fieldNames) as string\n const nodeIcon = node.icon\n const hasChildren = children && children.length > 0\n const isLeaf = node.isLeaf ?? !hasChildren\n\n const handleToggle = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!isLeaf) {\n onToggle(key)\n }\n }\n\n const handleSelect = () => {\n if (!node.disabled) {\n if (treeCheckable) {\n onCheck(key, node)\n } else {\n onSelect(key, node)\n }\n }\n }\n\n const handleCheck = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!node.disabled) {\n onCheck(key, node)\n }\n }\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleSelect()\n }\n }\n\n const renderSwitcherIcon = () => {\n if (loading) {\n return (\n <span className=\"loading loading-spinner loading-xs\" />\n )\n }\n\n if (switcherIcon) {\n if (typeof switcherIcon === 'function') {\n return switcherIcon({ expanded })\n }\n return switcherIcon\n }\n\n return (\n <svg\n className={`w-3 h-3 transition-transform ${expanded ? 'rotate-90' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M9 5l7 7-7 7\" />\n </svg>\n )\n }\n\n return (\n <div\n className=\"tree-select-node\"\n role=\"treeitem\"\n id={id}\n aria-selected={selected || checked}\n aria-expanded={hasChildren ? expanded : undefined}\n data-testid={`${baseTestId}-option-${key}`}\n data-state={selected || checked ? 'selected' : 'unselected'}\n data-disabled={node.disabled || undefined}\n >\n <div\n className={[\n 'flex items-center py-1.5 px-2 cursor-pointer hover:bg-base-200 transition-colors outline-none',\n (selected || checked) && 'bg-primary/10 text-primary',\n node.disabled && 'opacity-50 cursor-not-allowed',\n focused && 'ring-2 ring-primary ring-inset',\n treeLine && level > 0 && 'border-l border-base-300 ml-2',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{ paddingLeft: `${level * 16 + 8}px` }}\n onClick={handleSelect}\n onKeyDown={handleKeyDown}\n tabIndex={-1}\n >\n {/* Expand/Collapse icon */}\n <span\n className={[\n 'w-4 h-4 flex items-center justify-center flex-shrink-0 mr-1',\n !isLeaf && 'cursor-pointer',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={handleToggle}\n aria-hidden=\"true\"\n >\n {!isLeaf && renderSwitcherIcon()}\n </span>\n\n {/* Checkbox for treeCheckable mode */}\n {treeCheckable && (\n <span className=\"mr-2 flex-shrink-0\" onClick={handleCheck}>\n <input\n type=\"checkbox\"\n className=\"checkbox checkbox-sm checkbox-primary\"\n checked={checked}\n ref={(el) => {\n if (el) el.indeterminate = indeterminate\n }}\n disabled={node.disabled}\n onChange={handleSelect}\n aria-label={typeof title === 'string' ? title : undefined}\n tabIndex={-1}\n />\n </span>\n )}\n\n {/* Node icon */}\n {showTreeIcon && nodeIcon && (\n <span className=\"mr-1.5 flex-shrink-0 flex items-center\">{nodeIcon}</span>\n )}\n\n {/* Title */}\n <span className=\"flex-1 truncate select-none text-sm\">{title}</span>\n </div>\n\n {/* Children */}\n {hasChildren && expanded && (\n <div role=\"group\">{renderChildren(children!, level + 1)}</div>\n )}\n </div>\n )\n}\n\nconst sizeClasses: Record<TreeSelectSize, string> = {\n xs: 'min-h-6 text-xs',\n sm: 'min-h-8 text-sm',\n md: 'min-h-10 text-base',\n lg: 'min-h-12 text-lg',\n xl: 'min-h-14 text-xl',\n}\n\nconst colorClasses: Record<TreeSelectColor, string> = {\n primary: 'border-primary focus-within:border-primary',\n secondary: 'border-secondary focus-within:border-secondary',\n accent: 'border-accent focus-within:border-accent',\n neutral: 'border-neutral focus-within:border-neutral',\n info: 'border-info focus-within:border-info',\n success: 'border-success focus-within:border-success',\n warning: 'border-warning focus-within:border-warning',\n error: 'border-error focus-within:border-error',\n}\n\nconst statusClasses: Record<TreeSelectStatus, string> = {\n error: 'border-error focus-within:border-error',\n warning: 'border-warning focus-within:border-warning',\n}\n\nconst variantClasses: Record<TreeSelectVariant, string> = {\n outlined: 'border border-base-300',\n filled: 'bg-base-200 border-transparent',\n borderless: 'border-transparent',\n}\n\nexport const TreeSelect = forwardRef<HTMLDivElement, TreeSelectProps>(\n (\n {\n treeData,\n value: controlledValue,\n defaultValue = [],\n onChange,\n multiple = false,\n treeCheckable = false,\n treeCheckStrictly = false,\n showCheckedStrategy = 'SHOW_ALL',\n showSearch = false,\n searchValue: controlledSearchValue,\n onSearch,\n filterTreeNode,\n placeholder = 'Please select',\n allowClear = true,\n disabled = false,\n treeDefaultExpandAll = false,\n treeDefaultExpandedKeys = [],\n treeExpandedKeys: controlledExpandedKeys,\n onTreeExpand,\n size = 'md',\n color,\n status,\n variant = 'outlined',\n ghost = false,\n maxTagCount,\n maxTagPlaceholder,\n maxCount,\n labelInValue = false,\n tagRender,\n treeLine = false,\n treeIcon = false,\n loadData,\n fieldNames,\n open: controlledOpen,\n onDropdownVisibleChange,\n suffixIcon,\n switcherIcon,\n notFoundContent = 'No results found',\n dropdownRender,\n popupClassName = '',\n className = '',\n 'data-testid': testId,\n ...rest\n },\n ref\n ) => {\n const baseTestId = testId ?? 'treeselect'\n const instanceId = useId()\n const listboxId = `${instanceId}-listbox`\n const [isOpen, setIsOpen] = useState(false)\n const [internalSearchValue, setInternalSearchValue] = useState('')\n const [focusedKey, setFocusedKey] = useState<string | null>(null)\n const [loadingKeys, setLoadingKeys] = useState<Set<string>>(new Set())\n const containerRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\n const triggerRef = useRef<HTMLDivElement>(null)\n\n const searchValue = controlledSearchValue ?? internalSearchValue\n const open = controlledOpen ?? isOpen\n\n // Normalize value to array - handle labelInValue format\n const normalizeValue = (val: string | string[] | LabeledValue | LabeledValue[] | undefined): string[] => {\n if (val === undefined) return []\n if (Array.isArray(val)) {\n return val.map((v) => (typeof v === 'object' && v !== null ? v.value : v))\n }\n if (typeof val === 'object' && val !== null) {\n return [(val as LabeledValue).value]\n }\n return [val as string]\n }\n\n const initialValue = normalizeValue(defaultValue)\n const [internalValue, setInternalValue] = useState<string[]>(initialValue)\n\n const value = controlledValue !== undefined ? normalizeValue(controlledValue) : internalValue\n\n // Expanded keys\n const initialExpandedKeys = useMemo(() => {\n if (treeDefaultExpandAll) return getAllKeys(treeData, fieldNames)\n return treeDefaultExpandedKeys\n }, [treeData, treeDefaultExpandAll, treeDefaultExpandedKeys, fieldNames])\n\n const [internalExpandedKeys, setInternalExpandedKeys] = useState<string[]>(initialExpandedKeys)\n const expandedKeys = controlledExpandedKeys ?? internalExpandedKeys\n\n // Get flattened visible nodes for keyboard navigation\n const visibleNodes = useMemo(() => {\n const nodes: { key: string; node: TreeDataNode }[] = []\n const traverse = (data: TreeDataNode[]) => {\n data.forEach((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n nodes.push({ key, node })\n if (children && expandedKeys.includes(key)) {\n traverse(children)\n }\n })\n }\n traverse(treeData)\n return nodes\n }, [treeData, expandedKeys, fieldNames])\n\n const setOpen = useCallback(\n (newOpen: boolean) => {\n if (controlledOpen === undefined) {\n setIsOpen(newOpen)\n }\n onDropdownVisibleChange?.(newOpen)\n },\n [controlledOpen, onDropdownVisibleChange]\n )\n\n // Close on click outside\n useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }, [setOpen, controlledSearchValue])\n\n // Focus management\n useEffect(() => {\n if (open && showSearch && inputRef.current) {\n inputRef.current.focus()\n } else if (open && triggerRef.current) {\n triggerRef.current.focus()\n }\n }, [open, showSearch])\n\n // Initialize focused key when opening\n useEffect(() => {\n if (open && visibleNodes.length > 0) {\n if (value.length > 0) {\n setFocusedKey(value[0])\n } else {\n setFocusedKey(visibleNodes[0].key)\n }\n } else if (!open) {\n setFocusedKey(null)\n }\n }, [open, visibleNodes, value])\n\n // Filter tree data based on search\n const filteredData = useMemo(() => {\n if (!searchValue) return treeData\n\n const flatNodes = flattenTree(treeData, [], fieldNames)\n const matchingKeys = new Set<string>()\n\n flatNodes.forEach(({ node }) => {\n const title = getFieldValue(node, 'title', fieldNames)\n const key = getFieldValue(node, 'key', fieldNames) as string\n\n let isMatch = false\n if (filterTreeNode) {\n isMatch = filterTreeNode(searchValue, node)\n } else {\n const titleStr = typeof title === 'string' ? title : String(title)\n isMatch = titleStr.toLowerCase().includes(searchValue.toLowerCase())\n }\n\n if (isMatch) {\n matchingKeys.add(key)\n }\n })\n\n // Include parent keys of matching nodes\n const filterTree = (nodes: TreeDataNode[]): TreeDataNode[] => {\n return nodes\n .map((node) => {\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n const key = getFieldValue(node, 'key', fieldNames) as string\n const hasMatchingChildren = children && filterTree(children).length > 0\n const isMatch = matchingKeys.has(key)\n\n if (isMatch || hasMatchingChildren) {\n return {\n ...node,\n children: children ? filterTree(children) : undefined,\n }\n }\n return null\n })\n .filter(Boolean) as TreeDataNode[]\n }\n\n return filterTree(treeData)\n }, [treeData, searchValue, filterTreeNode, fieldNames])\n\n const handleToggle = useCallback(\n async (key: string) => {\n const node = findNode(treeData, key, fieldNames)\n\n // Handle async loading\n if (loadData && node) {\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n if (!children || children.length === 0) {\n setLoadingKeys((prev) => new Set(prev).add(key))\n try {\n await loadData(node)\n } finally {\n setLoadingKeys((prev) => {\n const next = new Set(prev)\n next.delete(key)\n return next\n })\n }\n }\n }\n\n const newKeys = expandedKeys.includes(key)\n ? expandedKeys.filter((k) => k !== key)\n : [...expandedKeys, key]\n\n if (controlledExpandedKeys === undefined) {\n setInternalExpandedKeys(newKeys)\n }\n onTreeExpand?.(newKeys)\n },\n [expandedKeys, controlledExpandedKeys, onTreeExpand, loadData, treeData, fieldNames]\n )\n\n const handleSelect = useCallback(\n (key: string, triggerNode: TreeDataNode) => {\n let newValue: string[]\n\n if (multiple) {\n if (value.includes(key)) {\n newValue = value.filter((k) => k !== key)\n } else {\n // Check maxCount limit\n if (maxCount !== undefined && value.length >= maxCount) {\n return // Don't add more if at limit\n }\n newValue = [...value, key]\n }\n } else {\n newValue = [key]\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n }\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const node = findNode(treeData, k, fieldNames)\n return node ? getFieldValue(node, 'title', fieldNames) as React.ReactNode : k\n })\n\n // Build return value based on labelInValue setting\n if (labelInValue) {\n const labeledValues: LabeledValue[] = newValue.map((k) => {\n const node = findNode(treeData, k, fieldNames)\n return {\n value: k,\n label: node ? getFieldValue(node, 'title', fieldNames) as React.ReactNode : k,\n }\n })\n onChange?.(\n multiple ? labeledValues : labeledValues[0] || { value: '', label: '' },\n labels,\n { triggerValue: key, triggerNode }\n )\n } else {\n onChange?.(multiple ? newValue : newValue[0] || '', labels, { triggerValue: key, triggerNode })\n }\n },\n [\n value,\n multiple,\n maxCount,\n controlledValue,\n onChange,\n treeData,\n setOpen,\n controlledSearchValue,\n fieldNames,\n labelInValue,\n ]\n )\n\n const handleCheck = useCallback(\n (key: string, triggerNode: TreeDataNode) => {\n const isChecked = value.includes(key)\n let newValue = [...value]\n\n if (treeCheckStrictly) {\n // No parent-child association\n if (isChecked) {\n newValue = newValue.filter((k) => k !== key)\n } else {\n // Check maxCount limit\n if (maxCount !== undefined && value.length >= maxCount) {\n return // Don't add more if at limit\n }\n newValue.push(key)\n }\n } else {\n const descendantKeys = getDescendantKeys(triggerNode, fieldNames)\n\n if (isChecked) {\n newValue = newValue.filter((k) => k !== key && !descendantKeys.includes(k))\n } else {\n // Check maxCount limit for adding multiple\n const keysToAdd = [key, ...descendantKeys.filter((dk) => !newValue.includes(dk))]\n if (maxCount !== undefined && newValue.length + keysToAdd.length > maxCount) {\n // Add only up to maxCount\n const remainingSlots = maxCount - newValue.length\n if (remainingSlots <= 0) return\n keysToAdd.slice(0, remainingSlots).forEach((k) => newValue.push(k))\n } else {\n newValue.push(key)\n descendantKeys.forEach((dk) => {\n if (!newValue.includes(dk)) newValue.push(dk)\n })\n }\n }\n }\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const n = findNode(treeData, k, fieldNames)\n return n ? getFieldValue(n, 'title', fieldNames) as React.ReactNode : k\n })\n\n // Build return value based on labelInValue setting\n if (labelInValue) {\n const labeledValues: LabeledValue[] = newValue.map((k) => {\n const node = findNode(treeData, k, fieldNames)\n return {\n value: k,\n label: node ? getFieldValue(node, 'title', fieldNames) as React.ReactNode : k,\n }\n })\n onChange?.(labeledValues, labels, { triggerValue: key, triggerNode })\n } else {\n onChange?.(newValue, labels, { triggerValue: key, triggerNode })\n }\n },\n [value, controlledValue, onChange, treeData, treeCheckStrictly, fieldNames, maxCount, labelInValue]\n )\n\n const handleClear = (e: React.MouseEvent) => {\n e.stopPropagation()\n const newValue: string[] = []\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n if (labelInValue) {\n onChange?.(multiple || treeCheckable ? [] : { value: '', label: '' }, [])\n } else {\n onChange?.(multiple || treeCheckable ? newValue : '', [])\n }\n }\n\n const removeTag = (key: string, e: React.MouseEvent) => {\n e.stopPropagation()\n const newValue = value.filter((k) => k !== key)\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => {\n const n = findNode(treeData, k, fieldNames)\n return n ? getFieldValue(n, 'title', fieldNames) as React.ReactNode : k\n })\n\n if (labelInValue) {\n const labeledValues: LabeledValue[] = newValue.map((k) => {\n const node = findNode(treeData, k, fieldNames)\n return {\n value: k,\n label: node ? getFieldValue(node, 'title', fieldNames) as React.ReactNode : k,\n }\n })\n onChange?.(\n multiple || treeCheckable ? labeledValues : labeledValues[0] || { value: '', label: '' },\n labels\n )\n } else {\n onChange?.(multiple || treeCheckable ? newValue : newValue[0] || '', labels)\n }\n }\n\n const handleSearchChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value\n if (controlledSearchValue === undefined) {\n setInternalSearchValue(newValue)\n }\n onSearch?.(newValue)\n }\n\n const handleKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return\n\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (!open) {\n e.preventDefault()\n setOpen(true)\n } else if (focusedKey) {\n e.preventDefault()\n const node = findNode(treeData, focusedKey, fieldNames)\n if (node && !node.disabled) {\n if (treeCheckable) {\n handleCheck(focusedKey, node)\n } else {\n handleSelect(focusedKey, node)\n }\n }\n }\n break\n\n case 'Escape':\n e.preventDefault()\n setOpen(false)\n if (controlledSearchValue === undefined) {\n setInternalSearchValue('')\n }\n triggerRef.current?.focus()\n break\n\n case 'ArrowDown':\n e.preventDefault()\n if (!open) {\n setOpen(true)\n } else {\n const currentIndex = visibleNodes.findIndex((n) => n.key === focusedKey)\n const nextIndex = currentIndex < visibleNodes.length - 1 ? currentIndex + 1 : 0\n setFocusedKey(visibleNodes[nextIndex]?.key || null)\n }\n break\n\n case 'ArrowUp':\n e.preventDefault()\n if (open) {\n const currentIndex = visibleNodes.findIndex((n) => n.key === focusedKey)\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : visibleNodes.length - 1\n setFocusedKey(visibleNodes[prevIndex]?.key || null)\n }\n break\n\n case 'ArrowRight':\n if (open && focusedKey) {\n e.preventDefault()\n const node = findNode(treeData, focusedKey, fieldNames)\n const children = node\n ? (getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined)\n : undefined\n if (children && children.length > 0 && !expandedKeys.includes(focusedKey)) {\n handleToggle(focusedKey)\n }\n }\n break\n\n case 'ArrowLeft':\n if (open && focusedKey) {\n e.preventDefault()\n if (expandedKeys.includes(focusedKey)) {\n handleToggle(focusedKey)\n } else {\n // Move to parent\n const parentKeys = getParentKeys(treeData, focusedKey, fieldNames)\n if (parentKeys && parentKeys.length > 0) {\n setFocusedKey(parentKeys[parentKeys.length - 1])\n }\n }\n }\n break\n\n case 'Home':\n if (open) {\n e.preventDefault()\n setFocusedKey(visibleNodes[0]?.key || null)\n }\n break\n\n case 'End':\n if (open) {\n e.preventDefault()\n setFocusedKey(visibleNodes[visibleNodes.length - 1]?.key || null)\n }\n break\n }\n }\n\n const getCheckedState = useCallback(\n (node: TreeDataNode): { checked: boolean; indeterminate: boolean } => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const children = getFieldValue(node, 'children', fieldNames) as TreeDataNode[] | undefined\n\n if (treeCheckStrictly) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n if (!children || children.length === 0) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n const descendantKeys = getDescendantKeys(node, fieldNames)\n const checkedDescendants = descendantKeys.filter((k) => value.includes(k))\n\n if (checkedDescendants.length === 0) {\n return { checked: value.includes(key), indeterminate: false }\n }\n\n if (checkedDescendants.length === descendantKeys.length) {\n return { checked: true, indeterminate: false }\n }\n\n return { checked: false, indeterminate: true }\n },\n [value, treeCheckStrictly, fieldNames]\n )\n\n const renderNodes = useCallback(\n (nodes: TreeDataNode[], level: number): React.ReactNode => {\n return nodes.map((node) => {\n const key = getFieldValue(node, 'key', fieldNames) as string\n const { checked, indeterminate } = getCheckedState(node)\n\n return (\n <TreeSelectNode\n key={key}\n node={node}\n level={level}\n expanded={expandedKeys.includes(key)}\n selected={value.includes(key)}\n checked={checked}\n indeterminate={indeterminate}\n treeCheckable={treeCheckable}\n treeLine={treeLine}\n treeIcon={treeIcon}\n focused={focusedKey === key}\n loading={loadingKeys.has(key)}\n baseTestId={baseTestId}\n id={`${instanceId}-option-${key}`}\n fieldNames={fieldNames}\n switcherIcon={switcherIcon}\n onToggle={handleToggle}\n onSelect={handleSelect}\n onCheck={handleCheck}\n renderChildren={renderNodes}\n />\n )\n })\n },\n [\n expandedKeys,\n value,\n treeCheckable,\n treeLine,\n treeIcon,\n focusedKey,\n loadingKeys,\n baseTestId,\n instanceId,\n fieldNames,\n switcherIcon,\n handleToggle,\n handleSelect,\n handleCheck,\n getCheckedState,\n ]\n )\n\n // Display value with showCheckedStrategy\n const displayValue = useMemo(() => {\n if (value.length === 0) return null\n\n let displayKeys = value\n\n if ((treeCheckable || multiple) && showCheckedStrategy !== 'SHOW_ALL') {\n if (showCheckedStrategy === 'SHOW_PARENT') {\n // Only show parent nodes when all children are selected\n displayKeys = value.filter((key) => {\n const parentKeys = getParentKeys(treeData, key, fieldNames)\n if (!parentKeys) return true\n // Check if any parent is fully selected\n return !parentKeys.some((pk) => value.includes(pk))\n })\n } else if (showCheckedStrategy === 'SHOW_CHILD') {\n // Only show leaf nodes\n displayKeys = value.filter((key) => {\n const node = findNode(treeData, key, fieldNames)\n if (!node) return true\n const children = getFieldValue(node, 'children', fieldNames) as\n | TreeDataNode[]\n | undefined\n return !children || children.length === 0\n })\n }\n }\n\n if (multiple || treeCheckable) {\n let keysToShow = displayKeys\n let hiddenCount = 0\n\n if (maxTagCount !== undefined && maxTagCount !== 'responsive') {\n if (displayKeys.length > maxTagCount) {\n keysToShow = displayKeys.slice(0, maxTagCount)\n hiddenCount = displayKeys.length - maxTagCount\n }\n }\n\n const tags = keysToShow.map((key) => {\n const node = findNode(treeData, key, fieldNames)\n const title = node ? getFieldValue(node, 'title', fieldNames) : key\n const label = title as React.ReactNode\n const closable = !disabled\n const onClose = () => {\n const fakeEvent = { stopPropagation: () => {} } as React.MouseEvent\n removeTag(key, fakeEvent)\n }\n\n // Use custom tagRender if provided\n if (tagRender) {\n return (\n <React.Fragment key={key}>\n {tagRender({ label, value: key, closable, onClose })}\n </React.Fragment>\n )\n }\n\n return (\n <span\n key={key}\n className=\"inline-flex items-center gap-1 px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1\"\n data-testid={`${baseTestId}-tag-${key}`}\n >\n {label}\n {closable && (\n <button\n type=\"button\"\n className=\"hover:text-error\"\n onClick={(e) => removeTag(key, e)}\n aria-label={`Remove ${typeof title === 'string' ? title : key}`}\n >\n <svg\n className=\"w-3 h-3\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n )}\n </span>\n )\n })\n\n if (hiddenCount > 0) {\n const hiddenKeys = displayKeys.slice(maxTagCount as number)\n const placeholder =\n typeof maxTagPlaceholder === 'function'\n ? maxTagPlaceholder(hiddenKeys)\n : maxTagPlaceholder || `+${hiddenCount} more`\n\n tags.push(\n <span\n key=\"__more__\"\n className=\"inline-flex items-center px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1\"\n >\n {placeholder}\n </span>\n )\n }\n\n return tags\n }\n\n const node = findNode(treeData, value[0], fieldNames)\n const title = node ? getFieldValue(node, 'title', fieldNames) : value[0]\n return title as React.ReactNode\n }, [\n value,\n treeData,\n multiple,\n treeCheckable,\n showCheckedStrategy,\n maxTagCount,\n maxTagPlaceholder,\n baseTestId,\n fieldNames,\n disabled,\n tagRender,\n ])\n\n const borderClass = status ? statusClasses[status] : color ? colorClasses[color] : ''\n const variantClass = ghost ? 'bg-transparent border-transparent' : variantClasses[variant]\n\n const dropdownContent = (\n <div className=\"py-1\" role=\"tree\" aria-label=\"Tree options\">\n {filteredData.length > 0 ? (\n renderNodes(filteredData, 0)\n ) : (\n <div\n className=\"px-4 py-2 text-base-content/50 text-sm text-center\"\n data-testid={`${baseTestId}-empty`}\n >\n {notFoundContent}\n </div>\n )}\n </div>\n )\n\n return (\n <div\n ref={(node) => {\n containerRef.current = node\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref) {\n ref.current = node\n }\n }}\n className={`relative ${className}`}\n data-testid={baseTestId}\n data-state={open ? 'open' : 'closed'}\n data-disabled={disabled || undefined}\n onKeyDown={handleKeyDown}\n {...rest}\n >\n {/* Trigger */}\n <div\n ref={triggerRef}\n role=\"combobox\"\n aria-expanded={open}\n aria-haspopup=\"tree\"\n aria-owns={open ? listboxId : undefined}\n aria-activedescendant={open && focusedKey ? `${instanceId}-option-${focusedKey}` : undefined}\n aria-disabled={disabled}\n tabIndex={disabled ? -1 : 0}\n className={[\n 'input flex items-center gap-2 cursor-pointer flex-wrap',\n sizeClasses[size],\n variantClass,\n borderClass,\n disabled && 'input-disabled opacity-50 cursor-not-allowed',\n open && !borderClass && 'border-primary',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={() => !disabled && setOpen(!open)}\n data-testid={`${baseTestId}-trigger`}\n >\n <div className=\"flex-1 flex flex-wrap items-center gap-1 min-w-0\">\n {displayValue || <span className=\"text-base-content/50\">{placeholder}</span>}\n </div>\n\n {/* Clear button */}\n {allowClear && value.length > 0 && !disabled && (\n <button\n type=\"button\"\n className=\"hover:text-error flex-shrink-0\"\n onClick={handleClear}\n aria-label=\"Clear selection\"\n data-testid={`${baseTestId}-clear`}\n >\n <svg\n className=\"w-4 h-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n )}\n\n {/* Suffix icon / Dropdown arrow */}\n {suffixIcon || (\n <svg\n className={`w-4 h-4 flex-shrink-0 transition-transform ${open ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n )}\n </div>\n\n {/* Dropdown */}\n {open && (\n <div\n id={listboxId}\n className={`absolute z-50 mt-1 w-full bg-base-100 border border-base-300 rounded-lg shadow-lg max-h-64 overflow-auto ${popupClassName}`}\n data-testid={`${baseTestId}-dropdown`}\n >\n {/* Search input */}\n {showSearch && (\n <div className=\"p-2 border-b border-base-300\">\n <input\n ref={inputRef}\n type=\"text\"\n className=\"input input-sm w-full\"\n placeholder=\"Search...\"\n value={searchValue}\n onChange={handleSearchChange}\n onClick={(e) => e.stopPropagation()}\n aria-label=\"Search tree options\"\n data-testid={`${baseTestId}-search`}\n />\n </div>\n )}\n\n {/* Tree */}\n {dropdownRender ? dropdownRender(dropdownContent) : dropdownContent}\n </div>\n )}\n </div>\n )\n }\n)\n\nTreeSelect.displayName = 'TreeSelect'\n\n// Attach static strategy constants to TreeSelect\nexport const TreeSelectComponent = Object.assign(TreeSelect, {\n SHOW_ALL,\n SHOW_PARENT,\n SHOW_CHILD,\n})\n\nexport { TreeSelectComponent as default }\n"],"names":["SHOW_ALL","SHOW_PARENT","SHOW_CHILD","getFieldValue","node","field","fieldNames","labelField","valueField","childrenField","flattenTree","data","parentPath","result","title","children","currentPath","getAllKeys","keys","traverse","nodes","key","findNode","nodeKey","found","getDescendantKeys","n","child","childKey","getParentKeys","targetKey","parentKeys","TreeSelectNode","level","expanded","selected","checked","indeterminate","treeCheckable","treeLine","showTreeIcon","focused","loading","baseTestId","id","switcherIcon","onToggle","onSelect","onCheck","renderChildren","nodeIcon","hasChildren","isLeaf","handleToggle","e","handleSelect","handleCheck","handleKeyDown","renderSwitcherIcon","jsx","jsxs","el","sizeClasses","colorClasses","statusClasses","variantClasses","TreeSelect","forwardRef","treeData","controlledValue","defaultValue","onChange","multiple","treeCheckStrictly","showCheckedStrategy","showSearch","controlledSearchValue","onSearch","filterTreeNode","placeholder","allowClear","disabled","treeDefaultExpandAll","treeDefaultExpandedKeys","controlledExpandedKeys","onTreeExpand","size","color","status","variant","ghost","maxTagCount","maxTagPlaceholder","maxCount","labelInValue","tagRender","treeIcon","loadData","controlledOpen","onDropdownVisibleChange","suffixIcon","notFoundContent","dropdownRender","popupClassName","className","testId","rest","ref","instanceId","useId","listboxId","isOpen","setIsOpen","useState","internalSearchValue","setInternalSearchValue","focusedKey","setFocusedKey","loadingKeys","setLoadingKeys","containerRef","useRef","inputRef","triggerRef","searchValue","open","normalizeValue","val","v","initialValue","internalValue","setInternalValue","value","initialExpandedKeys","useMemo","internalExpandedKeys","setInternalExpandedKeys","expandedKeys","visibleNodes","setOpen","useCallback","newOpen","useEffect","handleClickOutside","filteredData","flatNodes","matchingKeys","isMatch","filterTree","hasMatchingChildren","prev","next","newKeys","k","triggerNode","newValue","labels","labeledValues","isChecked","descendantKeys","keysToAdd","dk","remainingSlots","handleClear","removeTag","handleSearchChange","currentIndex","nextIndex","prevIndex","getCheckedState","checkedDescendants","renderNodes","displayValue","displayKeys","pk","keysToShow","hiddenCount","tags","label","closable","onClose","React","hiddenKeys","borderClass","variantClass","dropdownContent","TreeSelectComponent"],"mappings":";;AA0BA,MAAMA,KAAgC,YAChCC,KAAm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