1 line
12 KiB
JSON
1 line
12 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport React from 'react';\nimport HolderOutlined from \"@ant-design/icons/es/icons/HolderOutlined\";\nimport classNames from 'classnames';\nimport RcTree from 'rc-tree';\nimport initCollapseMotion from '../_util/motion';\nimport { ConfigContext } from '../config-provider';\nimport { useToken } from '../theme/internal';\nimport useStyle from './style';\nimport dropIndicatorRender from './utils/dropIndicator';\nimport SwitcherIconCom from './utils/iconUtil';\nconst Tree = /*#__PURE__*/React.forwardRef((props, ref) => {\n var _a;\n const {\n getPrefixCls,\n direction,\n virtual,\n tree\n } = React.useContext(ConfigContext);\n const {\n prefixCls: customizePrefixCls,\n className,\n showIcon = false,\n showLine,\n switcherIcon,\n switcherLoadingIcon,\n blockNode = false,\n children,\n checkable = false,\n selectable = true,\n draggable,\n motion: customMotion,\n style\n } = props;\n const prefixCls = getPrefixCls('tree', customizePrefixCls);\n const rootPrefixCls = getPrefixCls();\n const motion = customMotion !== null && customMotion !== void 0 ? customMotion : Object.assign(Object.assign({}, initCollapseMotion(rootPrefixCls)), {\n motionAppear: false\n });\n const newProps = Object.assign(Object.assign({}, props), {\n checkable,\n selectable,\n showIcon,\n motion,\n blockNode,\n showLine: Boolean(showLine),\n dropIndicatorRender\n });\n const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);\n const [, token] = useToken();\n const itemHeight = token.paddingXS / 2 + (((_a = token.Tree) === null || _a === void 0 ? void 0 : _a.titleHeight) || token.controlHeightSM);\n const draggableConfig = React.useMemo(() => {\n if (!draggable) {\n return false;\n }\n let mergedDraggable = {};\n switch (typeof draggable) {\n case 'function':\n mergedDraggable.nodeDraggable = draggable;\n break;\n case 'object':\n mergedDraggable = Object.assign({}, draggable);\n break;\n default:\n break;\n // Do nothing\n }\n if (mergedDraggable.icon !== false) {\n mergedDraggable.icon = mergedDraggable.icon || /*#__PURE__*/React.createElement(HolderOutlined, null);\n }\n return mergedDraggable;\n }, [draggable]);\n const renderSwitcherIcon = nodeProps => ( /*#__PURE__*/React.createElement(SwitcherIconCom, {\n prefixCls: prefixCls,\n switcherIcon: switcherIcon,\n switcherLoadingIcon: switcherLoadingIcon,\n treeNodeProps: nodeProps,\n showLine: showLine\n }));\n return wrapCSSVar( /*#__PURE__*/\n // @ts-ignore\n React.createElement(RcTree, Object.assign({\n itemHeight: itemHeight,\n ref: ref,\n virtual: virtual\n }, newProps, {\n // newProps may contain style so declare style below it\n style: Object.assign(Object.assign({}, tree === null || tree === void 0 ? void 0 : tree.style), style),\n prefixCls: prefixCls,\n className: classNames({\n [`${prefixCls}-icon-hide`]: !showIcon,\n [`${prefixCls}-block-node`]: blockNode,\n [`${prefixCls}-unselectable`]: !selectable,\n [`${prefixCls}-rtl`]: direction === 'rtl'\n }, tree === null || tree === void 0 ? void 0 : tree.className, className, hashId, cssVarCls),\n direction: direction,\n checkable: checkable ? /*#__PURE__*/React.createElement(\"span\", {\n className: `${prefixCls}-checkbox-inner`\n }) : checkable,\n selectable: selectable,\n switcherIcon: renderSwitcherIcon,\n draggable: draggableConfig\n }), children));\n});\nif (process.env.NODE_ENV !== 'production') {\n Tree.displayName = 'Tree';\n}\nexport default Tree;","map":{"version":3,"names":["React","HolderOutlined","classNames","RcTree","initCollapseMotion","ConfigContext","useToken","useStyle","dropIndicatorRender","SwitcherIconCom","Tree","forwardRef","props","ref","_a","getPrefixCls","direction","virtual","tree","useContext","prefixCls","customizePrefixCls","className","showIcon","showLine","switcherIcon","switcherLoadingIcon","blockNode","chi
|