asterui 0.12.22 → 0.12.24
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.d.ts +55 -5
- package/dist/components/Tree.d.ts +78 -2
- package/dist/components/TreeSelect.d.ts +35 -2
- package/dist/index.d.ts +1 -1
- package/dist/index15.js +391 -137
- package/dist/index15.js.map +1 -1
- package/dist/index93.js +422 -194
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +626 -263
- package/dist/index94.js.map +1 -1
- package/dist/index97.js +23 -23
- package/dist/index97.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, { useState, useCallback, useRef, useEffect, useMemo } from 'react'\nimport type { TreeDataNode } from './Tree'\n\nexport interface TreeSelectProps 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 showSearch?: 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?: 'xs' | 'sm' | 'md' | 'lg'\n}\n\n// Helper to flatten tree data for search\nfunction flattenTree(\n data: TreeDataNode[],\n parentPath: React.ReactNode[] = []\n): Array<{ node: TreeDataNode; path: React.ReactNode[] }> {\n const result: Array<{ node: TreeDataNode; path: React.ReactNode[] }> = []\n\n data.forEach((node) => {\n const currentPath = [...parentPath, node.title]\n result.push({ node, path: currentPath })\n if (node.children) {\n result.push(...flattenTree(node.children, currentPath))\n }\n })\n\n return result\n}\n\n// Helper to get all keys\nfunction getAllKeys(data: TreeDataNode[]): string[] {\n const keys: string[] = []\n const traverse = (nodes: TreeDataNode[]) => {\n nodes.forEach((node) => {\n keys.push(node.key)\n if (node.children) traverse(node.children)\n })\n }\n traverse(data)\n return keys\n}\n\n// Helper to find node by key\nfunction findNode(data: TreeDataNode[], key: string): TreeDataNode | null {\n for (const node of data) {\n if (node.key === key) return node\n if (node.children) {\n const found = findNode(node.children, key)\n if (found) return found\n }\n }\n return null\n}\n\n// Helper to get all descendant keys\nfunction getDescendantKeys(node: TreeDataNode): string[] {\n const keys: string[] = []\n const traverse = (n: TreeDataNode) => {\n if (n.children) {\n n.children.forEach((child) => {\n keys.push(child.key)\n traverse(child)\n })\n }\n }\n traverse(node)\n return keys\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 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 onToggle,\n onSelect,\n onCheck,\n renderChildren,\n}: TreeSelectNodeProps) {\n const hasChildren = node.children && node.children.length > 0\n const isLeaf = node.isLeaf ?? !hasChildren\n\n const handleToggle = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!isLeaf) {\n onToggle(node.key)\n }\n }\n\n const handleSelect = () => {\n if (!node.disabled) {\n if (treeCheckable) {\n onCheck(node.key, node)\n } else {\n onSelect(node.key, node)\n }\n }\n }\n\n const handleCheck = (e: React.MouseEvent) => {\n e.stopPropagation()\n if (!node.disabled) {\n onCheck(node.key, node)\n }\n }\n\n return (\n <div className=\"tree-select-node\">\n <div\n className={[\n 'flex items-center py-1.5 px-2 cursor-pointer hover:bg-base-200 transition-colors',\n (selected || checked) && 'bg-primary/10 text-primary',\n node.disabled && 'opacity-50 cursor-not-allowed',\n ]\n .filter(Boolean)\n .join(' ')}\n style={{ paddingLeft: `${level * 16 + 8}px` }}\n onClick={handleSelect}\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 >\n {!isLeaf && (\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 >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M9 5l7 7-7 7\" />\n </svg>\n )}\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={() => {}}\n />\n </span>\n )}\n\n {/* Title */}\n <span className=\"flex-1 truncate select-none text-sm\">{node.title}</span>\n </div>\n\n {/* Children */}\n {hasChildren && expanded && renderChildren(node.children!, level + 1)}\n </div>\n )\n}\n\nexport function TreeSelect({\n treeData,\n value: controlledValue,\n defaultValue = [],\n onChange,\n multiple = false,\n treeCheckable = false,\n showSearch = false,\n placeholder = 'Please select',\n allowClear = true,\n disabled = false,\n treeDefaultExpandAll = false,\n treeDefaultExpandedKeys = [],\n treeExpandedKeys: controlledExpandedKeys,\n onTreeExpand,\n size = 'md',\n className = '',\n ...rest\n}: TreeSelectProps) {\n const [isOpen, setIsOpen] = useState(false)\n const [searchValue, setSearchValue] = useState('')\n const containerRef = useRef<HTMLDivElement>(null)\n const inputRef = useRef<HTMLInputElement>(null)\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)\n return treeDefaultExpandedKeys\n }, [])\n\n const [internalExpandedKeys, setInternalExpandedKeys] = useState<string[]>(initialExpandedKeys)\n const expandedKeys = controlledExpandedKeys ?? internalExpandedKeys\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 setIsOpen(false)\n setSearchValue('')\n }\n }\n\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }, [])\n\n // Filter tree data based on search\n const filteredData = useMemo(() => {\n if (!searchValue) return treeData\n\n const flatNodes = flattenTree(treeData)\n const matchingKeys = new Set<string>()\n\n flatNodes.forEach(({ node }) => {\n const titleStr =\n typeof node.title === 'string' ? node.title : String(node.title)\n if (titleStr.toLowerCase().includes(searchValue.toLowerCase())) {\n matchingKeys.add(node.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 hasMatchingChildren =\n node.children && filterTree(node.children).length > 0\n const isMatch = matchingKeys.has(node.key)\n\n if (isMatch || hasMatchingChildren) {\n return {\n ...node,\n children: node.children ? filterTree(node.children) : undefined,\n }\n }\n return null\n })\n .filter(Boolean) as TreeDataNode[]\n }\n\n return filterTree(treeData)\n }, [treeData, searchValue])\n\n const handleToggle = useCallback(\n (key: string) => {\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]\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 setIsOpen(false)\n setSearchValue('')\n }\n\n if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => findNode(treeData, k)?.title || k)\n onChange?.(multiple ? newValue : newValue[0] || '', labels)\n },\n [value, multiple, controlledValue, onChange, treeData]\n )\n\n const handleCheck = useCallback(\n (key: string, node: TreeDataNode) => {\n const isChecked = value.includes(key)\n let newValue = [...value]\n const descendantKeys = getDescendantKeys(node)\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 if (controlledValue === undefined) {\n setInternalValue(newValue)\n }\n\n const labels = newValue.map((k) => findNode(treeData, k)?.title || k)\n onChange?.(newValue, labels)\n },\n [value, controlledValue, onChange, treeData]\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 ? 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) => findNode(treeData, k)?.title || k)\n onChange?.(multiple ? newValue : newValue[0] || '', labels)\n }\n\n const getCheckedState = useCallback(\n (node: TreeDataNode): { checked: boolean; indeterminate: boolean } => {\n if (!node.children || node.children.length === 0) {\n return { checked: value.includes(node.key), indeterminate: false }\n }\n\n const descendantKeys = getDescendantKeys(node)\n const checkedDescendants = descendantKeys.filter((k) => value.includes(k))\n\n if (checkedDescendants.length === 0) {\n return { checked: value.includes(node.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]\n )\n\n const renderNodes = useCallback(\n (nodes: TreeDataNode[], level: number): React.ReactNode => {\n return nodes.map((node) => {\n const { checked, indeterminate } = getCheckedState(node)\n\n return (\n <TreeSelectNode\n key={node.key}\n node={node}\n level={level}\n expanded={expandedKeys.includes(node.key)}\n selected={value.includes(node.key)}\n checked={checked}\n indeterminate={indeterminate}\n treeCheckable={treeCheckable}\n onToggle={handleToggle}\n onSelect={handleSelect}\n onCheck={handleCheck}\n renderChildren={renderNodes}\n />\n )\n })\n },\n [expandedKeys, value, treeCheckable, handleToggle, handleSelect, handleCheck, getCheckedState]\n )\n\n // Display value\n const displayValue = useMemo(() => {\n if (value.length === 0) return null\n\n if (multiple || treeCheckable) {\n return value.map((key) => {\n const node = findNode(treeData, 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 >\n {node?.title || key}\n <button\n type=\"button\"\n className=\"hover:text-error\"\n onClick={(e) => removeTag(key, e)}\n >\n <svg className=\"w-3 h-3\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n </span>\n )\n })\n }\n\n const node = findNode(treeData, value[0])\n return node?.title || value[0]\n }, [value, treeData, multiple, treeCheckable])\n\n const sizeClasses = {\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 }\n\n return (\n <div ref={containerRef} className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} {...rest}>\n {/* Trigger */}\n <div\n className={[\n 'input input-bordered flex items-center gap-2 cursor-pointer flex-wrap',\n sizeClasses[size],\n disabled && 'input-disabled opacity-50 cursor-not-allowed',\n isOpen && 'input-primary',\n ]\n .filter(Boolean)\n .join(' ')}\n onClick={() => !disabled && setIsOpen(!isOpen)}\n >\n <div className=\"flex-1 flex flex-wrap items-center gap-1 min-w-0\">\n {displayValue || (\n <span className=\"text-base-content/50\">{placeholder}</span>\n )}\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 >\n <svg className=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M6 18L18 6M6 6l12 12\" />\n </svg>\n </button>\n )}\n\n {/* Dropdown arrow */}\n <svg\n className={`w-4 h-4 flex-shrink-0 transition-transform ${isOpen ? 'rotate-180' : ''}`}\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M19 9l-7 7-7-7\" />\n </svg>\n </div>\n\n {/* Dropdown */}\n {isOpen && (\n <div className=\"absolute z-50 mt-1 w-full bg-base-100 border border-base-300 rounded-lg shadow-lg max-h-64 overflow-auto\">\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={(e) => setSearchValue(e.target.value)}\n onClick={(e) => e.stopPropagation()}\n autoFocus\n />\n </div>\n )}\n\n {/* Tree */}\n <div className=\"py-1\">\n {filteredData.length > 0 ? (\n renderNodes(filteredData, 0)\n ) : (\n <div className=\"px-4 py-2 text-base-content/50 text-sm text-center\">\n No results found\n </div>\n )}\n </div>\n </div>\n )}\n </div>\n )\n}\n"],"names":["flattenTree","data","parentPath","result","node","currentPath","getAllKeys","keys","traverse","nodes","findNode","key","found","getDescendantKeys","n","child","TreeSelectNode","level","expanded","selected","checked","indeterminate","treeCheckable","onToggle","onSelect","onCheck","renderChildren","hasChildren","isLeaf","handleToggle","e","handleSelect","handleCheck","jsxs","jsx","el","TreeSelect","treeData","controlledValue","defaultValue","onChange","multiple","showSearch","placeholder","allowClear","disabled","treeDefaultExpandAll","treeDefaultExpandedKeys","controlledExpandedKeys","onTreeExpand","size","className","rest","isOpen","setIsOpen","useState","searchValue","setSearchValue","containerRef","useRef","inputRef","normalizeValue","val","initialValue","internalValue","setInternalValue","value","initialExpandedKeys","useMemo","internalExpandedKeys","setInternalExpandedKeys","expandedKeys","useEffect","handleClickOutside","filteredData","flatNodes","matchingKeys","filterTree","hasMatchingChildren","useCallback","newKeys","k","_node","newValue","labels","isChecked","descendantKeys","dk","handleClear","removeTag","getCheckedState","checkedDescendants","renderNodes","displayValue","sizeClasses"],"mappings":";;AAsBA,SAASA,EACPC,GACAC,IAAgC,IACwB;AACxD,QAAMC,IAAiE,CAAA;AAEvE,SAAAF,EAAK,QAAQ,CAACG,MAAS;AACrB,UAAMC,IAAc,CAAC,GAAGH,GAAYE,EAAK,KAAK;AAC9C,IAAAD,EAAO,KAAK,EAAE,MAAAC,GAAM,MAAMC,GAAa,GACnCD,EAAK,YACPD,EAAO,KAAK,GAAGH,EAAYI,EAAK,UAAUC,CAAW,CAAC;AAAA,EAE1D,CAAC,GAEMF;AACT;AAGA,SAASG,GAAWL,GAAgC;AAClD,QAAMM,IAAiB,CAAA,GACjBC,IAAW,CAACC,MAA0B;AAC1C,IAAAA,EAAM,QAAQ,CAACL,MAAS;AACtB,MAAAG,EAAK,KAAKH,EAAK,GAAG,GACdA,EAAK,YAAUI,EAASJ,EAAK,QAAQ;AAAA,IAC3C,CAAC;AAAA,EACH;AACA,SAAAI,EAASP,CAAI,GACNM;AACT;AAGA,SAASG,EAAST,GAAsBU,GAAkC;AACxE,aAAWP,KAAQH,GAAM;AACvB,QAAIG,EAAK,QAAQO,EAAK,QAAOP;AAC7B,QAAIA,EAAK,UAAU;AACjB,YAAMQ,IAAQ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M,EAAE,gBAAA;AAAA,UAClB,WAAS;AAAA,QAAA;AAAA,MAAA,GAEb;AAAA,wBAID,OAAA,EAAI,WAAU,QACZ,UAAAiB,EAAa,SAAS,IACrBkB,EAAYlB,GAAc,CAAC,IAE3B,gBAAAxC,EAAC,OAAA,EAAI,WAAU,sDAAqD,8BAEpE,EAAA,CAEJ;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
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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IAAI4C;AAAA,cACJ,WAAW,4GAA4GP,EAAc;AAAA,cACrI,eAAa,GAAGrD,CAAU;AAAA,cAGzB,UAAA;AAAA,gBAAA8B,KACC,gBAAAf,EAAC,OAAA,EAAI,WAAU,gCACb,UAAA,gBAAAA;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACC,KAAKyD;AAAA,oBACL,MAAK;AAAA,oBACL,WAAU;AAAA,oBACV,aAAY;AAAA,oBACZ,OAAOE;AAAA,oBACP,UAAUqC;AAAA,oBACV,SAAS,CAAC,MAAM,EAAE,gBAAA;AAAA,oBAClB,cAAW;AAAA,oBACX,eAAa,GAAG/G,CAAU;AAAA,kBAAA;AAAA,gBAAA,GAE9B;AAAA,gBAIDoD,KAAiBA,GAAe0E,EAAe,IAAIA;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACtD;AAAA,MAAA;AAAA,IAAA;AAAA,EAIR;AACF;AAEAzG,GAAW,cAAc;"}
|
package/dist/index97.js
CHANGED
|
@@ -3,57 +3,57 @@ import { useRef as o } from "react";
|
|
|
3
3
|
import { useVirtualizer as S } from "./index110.js";
|
|
4
4
|
function N({
|
|
5
5
|
items: e,
|
|
6
|
-
height:
|
|
6
|
+
height: u,
|
|
7
7
|
itemHeight: i,
|
|
8
|
-
renderItem:
|
|
9
|
-
overscan:
|
|
10
|
-
className:
|
|
11
|
-
innerClassName:
|
|
12
|
-
itemClassName:
|
|
13
|
-
width:
|
|
14
|
-
gap:
|
|
8
|
+
renderItem: d,
|
|
9
|
+
overscan: f = 5,
|
|
10
|
+
className: h = "",
|
|
11
|
+
innerClassName: p = "",
|
|
12
|
+
itemClassName: m = "",
|
|
13
|
+
width: g,
|
|
14
|
+
gap: s = 0,
|
|
15
15
|
onScroll: x
|
|
16
16
|
}) {
|
|
17
|
-
const
|
|
18
|
-
r.current = i,
|
|
19
|
-
const
|
|
17
|
+
const l = o(null), r = o(i), c = o(e);
|
|
18
|
+
r.current = i, c.current = e;
|
|
19
|
+
const a = S({
|
|
20
20
|
count: e.length,
|
|
21
|
-
getScrollElement: () =>
|
|
22
|
-
estimateSize: (t) => (typeof r.current == "function" ? r.current(
|
|
23
|
-
overscan:
|
|
24
|
-
}), y =
|
|
21
|
+
getScrollElement: () => l.current,
|
|
22
|
+
estimateSize: (t) => (typeof r.current == "function" ? r.current(c.current[t], t) : r.current) + s,
|
|
23
|
+
overscan: f
|
|
24
|
+
}), y = a.getVirtualItems(), z = (t) => {
|
|
25
25
|
x?.(t.currentTarget.scrollTop);
|
|
26
26
|
};
|
|
27
27
|
return /* @__PURE__ */ n(
|
|
28
28
|
"div",
|
|
29
29
|
{
|
|
30
|
-
ref:
|
|
31
|
-
className: `overflow-auto ${
|
|
32
|
-
style: { height:
|
|
30
|
+
ref: l,
|
|
31
|
+
className: `overflow-auto ${h}`,
|
|
32
|
+
style: { height: u, width: g },
|
|
33
33
|
onScroll: z,
|
|
34
34
|
children: /* @__PURE__ */ n(
|
|
35
35
|
"div",
|
|
36
36
|
{
|
|
37
|
-
className:
|
|
37
|
+
className: p,
|
|
38
38
|
style: {
|
|
39
|
-
height:
|
|
39
|
+
height: a.getTotalSize(),
|
|
40
40
|
width: "100%",
|
|
41
41
|
position: "relative"
|
|
42
42
|
},
|
|
43
43
|
children: y.map((t) => /* @__PURE__ */ n(
|
|
44
44
|
"div",
|
|
45
45
|
{
|
|
46
|
-
className:
|
|
46
|
+
className: m,
|
|
47
47
|
"data-index": t.index,
|
|
48
48
|
style: {
|
|
49
49
|
position: "absolute",
|
|
50
50
|
top: 0,
|
|
51
51
|
left: 0,
|
|
52
52
|
width: "100%",
|
|
53
|
-
height: t.size,
|
|
53
|
+
height: t.size - s,
|
|
54
54
|
transform: `translateY(${t.start}px)`
|
|
55
55
|
},
|
|
56
|
-
children:
|
|
56
|
+
children: d(e[t.index], t.index)
|
|
57
57
|
},
|
|
58
58
|
t.key
|
|
59
59
|
))
|
package/dist/index97.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index97.js","sources":["../src/components/VirtualList.tsx"],"sourcesContent":["import React, { useRef } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nexport interface VirtualListProps<T> {\n /** Array of items to render */\n items: T[]\n /** Height of the scrollable container */\n height: number | string\n /** Height of each item, or function returning estimated height per item */\n itemHeight: number | ((item: T, index: number) => number)\n /** Render function for each item */\n renderItem: (item: T, index: number) => React.ReactNode\n /** Number of items to render outside visible area */\n overscan?: number\n /** Additional class for the scroll container */\n className?: string\n /** Additional class for the inner container */\n innerClassName?: string\n /** Additional class for each item wrapper */\n itemClassName?: string\n /** Width of the container */\n width?: number | string\n /** Gap between items */\n gap?: number\n /** Callback when scroll position changes */\n onScroll?: (scrollTop: number) => void\n}\n\nexport function VirtualList<T>({\n items,\n height,\n itemHeight,\n renderItem,\n overscan = 5,\n className = '',\n innerClassName = '',\n itemClassName = '',\n width,\n gap = 0,\n onScroll,\n}: VirtualListProps<T>) {\n const parentRef = useRef<HTMLDivElement>(null)\n const itemHeightRef = useRef(itemHeight)\n const itemsRef = useRef(items)\n itemHeightRef.current = itemHeight\n itemsRef.current = items\n\n const virtualizer = useVirtualizer({\n count: items.length,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n const h = typeof itemHeightRef.current === 'function'\n ? itemHeightRef.current(itemsRef.current[index], index)\n : itemHeightRef.current\n return h + gap\n },\n overscan,\n })\n\n const virtualItems = virtualizer.getVirtualItems()\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n onScroll?.(e.currentTarget.scrollTop)\n }\n\n return (\n <div\n ref={parentRef}\n className={`overflow-auto ${className}`}\n style={{ height, width }}\n onScroll={handleScroll}\n >\n <div\n className={innerClassName}\n style={{\n height: virtualizer.getTotalSize(),\n width: '100%',\n position: 'relative',\n }}\n >\n {virtualItems.map((virtualItem) => (\n <div\n key={virtualItem.key}\n className={itemClassName}\n data-index={virtualItem.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: virtualItem.size,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderItem(items[virtualItem.index], virtualItem.index)}\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nVirtualList.displayName = 'VirtualList'\n"],"names":["VirtualList","items","height","itemHeight","renderItem","overscan","className","innerClassName","itemClassName","width","gap","onScroll","parentRef","useRef","itemHeightRef","itemsRef","virtualizer","useVirtualizer","index","virtualItems","handleScroll","e","jsx","virtualItem"],"mappings":";;;AA4BO,SAASA,EAAe;AAAA,EAC7B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,gBAAAC,IAAiB;AAAA,EACjB,eAAAC,IAAgB;AAAA,EAChB,OAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,UAAAC;AACF,GAAwB;AACtB,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAgBD,EAAOV,CAAU,GACjCY,IAAWF,EAAOZ,CAAK;AAC7B,EAAAa,EAAc,UAAUX,GACxBY,EAAS,UAAUd;AAEnB,QAAMe,IAAcC,EAAe;AAAA,IACjC,OAAOhB,EAAM;AAAA,IACb,kBAAkB,MAAMW,EAAU;AAAA,IAClC,cAAc,CAACM,OACH,OAAOJ,EAAc,WAAY,aACvCA,EAAc,QAAQC,EAAS,QAAQG,CAAK,GAAGA,CAAK,IACpDJ,EAAc,WACPJ;AAAA,IAEb,UAAAL;AAAA,EAAA,CACD,GAEKc,IAAeH,EAAY,gBAAA,GAE3BI,IAAe,CAACC,MAAqC;AACzD,IAAAV,IAAWU,EAAE,cAAc,SAAS;AAAA,EACtC;AAEA,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKV;AAAA,MACL,WAAW,iBAAiBN,CAAS;AAAA,MACrC,OAAO,EAAE,QAAAJ,GAAQ,OAAAO,EAAA;AAAA,MACjB,UAAUW;AAAA,MAEV,UAAA,gBAAAE;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWf;AAAA,UACX,OAAO;AAAA,YACL,QAAQS,EAAY,aAAA;AAAA,YACpB,OAAO;AAAA,YACP,UAAU;AAAA,UAAA;AAAA,UAGX,UAAAG,EAAa,IAAI,CAACI,MACjB,gBAAAD;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,WAAWd;AAAA,cACX,cAAYe,EAAY;AAAA,cACxB,OAAO;AAAA,gBACL,UAAU;AAAA,gBACV,KAAK;AAAA,gBACL,MAAM;AAAA,gBACN,OAAO;AAAA,gBACP,QAAQA,EAAY;AAAA,
|
|
1
|
+
{"version":3,"file":"index97.js","sources":["../src/components/VirtualList.tsx"],"sourcesContent":["import React, { useRef } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nexport interface VirtualListProps<T> {\n /** Array of items to render */\n items: T[]\n /** Height of the scrollable container */\n height: number | string\n /** Height of each item, or function returning estimated height per item */\n itemHeight: number | ((item: T, index: number) => number)\n /** Render function for each item */\n renderItem: (item: T, index: number) => React.ReactNode\n /** Number of items to render outside visible area */\n overscan?: number\n /** Additional class for the scroll container */\n className?: string\n /** Additional class for the inner container */\n innerClassName?: string\n /** Additional class for each item wrapper */\n itemClassName?: string\n /** Width of the container */\n width?: number | string\n /** Gap between items */\n gap?: number\n /** Callback when scroll position changes */\n onScroll?: (scrollTop: number) => void\n}\n\nexport function VirtualList<T>({\n items,\n height,\n itemHeight,\n renderItem,\n overscan = 5,\n className = '',\n innerClassName = '',\n itemClassName = '',\n width,\n gap = 0,\n onScroll,\n}: VirtualListProps<T>) {\n const parentRef = useRef<HTMLDivElement>(null)\n const itemHeightRef = useRef(itemHeight)\n const itemsRef = useRef(items)\n itemHeightRef.current = itemHeight\n itemsRef.current = items\n\n const virtualizer = useVirtualizer({\n count: items.length,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n const h = typeof itemHeightRef.current === 'function'\n ? itemHeightRef.current(itemsRef.current[index], index)\n : itemHeightRef.current\n return h + gap\n },\n overscan,\n })\n\n const virtualItems = virtualizer.getVirtualItems()\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n onScroll?.(e.currentTarget.scrollTop)\n }\n\n return (\n <div\n ref={parentRef}\n className={`overflow-auto ${className}`}\n style={{ height, width }}\n onScroll={handleScroll}\n >\n <div\n className={innerClassName}\n style={{\n height: virtualizer.getTotalSize(),\n width: '100%',\n position: 'relative',\n }}\n >\n {virtualItems.map((virtualItem) => (\n <div\n key={virtualItem.key}\n className={itemClassName}\n data-index={virtualItem.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: virtualItem.size - gap,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderItem(items[virtualItem.index], virtualItem.index)}\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nVirtualList.displayName = 'VirtualList'\n"],"names":["VirtualList","items","height","itemHeight","renderItem","overscan","className","innerClassName","itemClassName","width","gap","onScroll","parentRef","useRef","itemHeightRef","itemsRef","virtualizer","useVirtualizer","index","virtualItems","handleScroll","e","jsx","virtualItem"],"mappings":";;;AA4BO,SAASA,EAAe;AAAA,EAC7B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,gBAAAC,IAAiB;AAAA,EACjB,eAAAC,IAAgB;AAAA,EAChB,OAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,UAAAC;AACF,GAAwB;AACtB,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAgBD,EAAOV,CAAU,GACjCY,IAAWF,EAAOZ,CAAK;AAC7B,EAAAa,EAAc,UAAUX,GACxBY,EAAS,UAAUd;AAEnB,QAAMe,IAAcC,EAAe;AAAA,IACjC,OAAOhB,EAAM;AAAA,IACb,kBAAkB,MAAMW,EAAU;AAAA,IAClC,cAA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