7a521e2ebbb5e5bcaecd8fde2649c805.json
25.2 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport debounce from 'lodash/debounce';\nimport { conductExpandParent } from \"rc-tree/es/util\";\nimport { convertDataToEntities, convertTreeToData } from \"rc-tree/es/utils/treeUtil\";\nimport FileOutlined from '@ant-design/icons/FileOutlined';\nimport FolderOpenOutlined from '@ant-design/icons/FolderOpenOutlined';\nimport FolderOutlined from '@ant-design/icons/FolderOutlined';\nimport { ConfigContext } from '../config-provider';\nimport Tree from './Tree';\nimport { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil';\n\nfunction getIcon(props) {\n var isLeaf = props.isLeaf,\n expanded = props.expanded;\n\n if (isLeaf) {\n return /*#__PURE__*/React.createElement(FileOutlined, null);\n }\n\n return expanded ? /*#__PURE__*/React.createElement(FolderOpenOutlined, null) : /*#__PURE__*/React.createElement(FolderOutlined, null);\n}\n\nfunction getTreeData(_ref) {\n var treeData = _ref.treeData,\n children = _ref.children;\n return treeData || convertTreeToData(children);\n}\n\nvar DirectoryTree = function DirectoryTree(_a, ref) {\n var defaultExpandAll = _a.defaultExpandAll,\n defaultExpandParent = _a.defaultExpandParent,\n defaultExpandedKeys = _a.defaultExpandedKeys,\n props = __rest(_a, [\"defaultExpandAll\", \"defaultExpandParent\", \"defaultExpandedKeys\"]); // Shift click usage\n\n\n var lastSelectedKey = React.useRef();\n var cachedSelectedKeys = React.useRef();\n var treeRef = /*#__PURE__*/React.createRef();\n React.useImperativeHandle(ref, function () {\n return treeRef.current;\n });\n\n var getInitExpandedKeys = function getInitExpandedKeys() {\n var _convertDataToEntitie = convertDataToEntities(getTreeData(props)),\n keyEntities = _convertDataToEntitie.keyEntities;\n\n var initExpandedKeys; // Expanded keys\n\n if (defaultExpandAll) {\n initExpandedKeys = Object.keys(keyEntities);\n } else if (defaultExpandParent) {\n initExpandedKeys = conductExpandParent(props.expandedKeys || defaultExpandedKeys, keyEntities);\n } else {\n initExpandedKeys = props.expandedKeys || defaultExpandedKeys;\n }\n\n return initExpandedKeys;\n };\n\n var _React$useState = React.useState(props.selectedKeys || props.defaultSelectedKeys || []),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n selectedKeys = _React$useState2[0],\n setSelectedKeys = _React$useState2[1];\n\n var _React$useState3 = React.useState(getInitExpandedKeys()),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n expandedKeys = _React$useState4[0],\n setExpandedKeys = _React$useState4[1];\n\n React.useEffect(function () {\n if ('selectedKeys' in props) {\n setSelectedKeys(props.selectedKeys);\n }\n }, [props.selectedKeys]);\n React.useEffect(function () {\n if ('expandedKeys' in props) {\n setExpandedKeys(props.expandedKeys);\n }\n }, [props.expandedKeys]);\n\n var expandFolderNode = function expandFolderNode(event, node) {\n var isLeaf = node.isLeaf;\n\n if (isLeaf || event.shiftKey || event.metaKey || event.ctrlKey) {\n return;\n } // Call internal rc-tree expand function\n // https://github.com/ant-design/ant-design/issues/12567\n\n\n treeRef.current.onNodeExpand(event, node);\n };\n\n var onDebounceExpand = debounce(expandFolderNode, 200, {\n leading: true\n });\n\n var onExpand = function onExpand(keys, info) {\n if (!('expandedKeys' in props)) {\n setExpandedKeys(keys);\n } // Call origin function\n\n\n if (props.onExpand) {\n return props.onExpand(keys, info);\n }\n\n return undefined;\n };\n\n var onClick = function onClick(event, node) {\n var expandAction = props.expandAction; // Expand the tree\n\n if (expandAction === 'click') {\n onDebounceExpand(event, node);\n }\n\n if (props.onClick) {\n props.onClick(event, node);\n }\n };\n\n var onDoubleClick = function onDoubleClick(event, node) {\n var expandAction = props.expandAction; // Expand the tree\n\n if (expandAction === 'doubleClick') {\n onDebounceExpand(event, node);\n }\n\n if (props.onDoubleClick) {\n props.onDoubleClick(event, node);\n }\n };\n\n var onSelect = function onSelect(keys, event) {\n var multiple = props.multiple;\n var node = event.node,\n nativeEvent = event.nativeEvent;\n var _node$key = node.key,\n key = _node$key === void 0 ? '' : _node$key;\n var treeData = getTreeData(props); // const newState: DirectoryTreeState = {};\n // We need wrap this event since some value is not same\n\n var newEvent = _extends(_extends({}, event), {\n selected: true\n }); // Windows / Mac single pick\n\n\n var ctrlPick = nativeEvent.ctrlKey || nativeEvent.metaKey;\n var shiftPick = nativeEvent.shiftKey; // Generate new selected keys\n\n var newSelectedKeys;\n\n if (multiple && ctrlPick) {\n // Control click\n newSelectedKeys = keys;\n lastSelectedKey.current = key;\n cachedSelectedKeys.current = newSelectedKeys;\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n } else if (multiple && shiftPick) {\n // Shift click\n newSelectedKeys = Array.from(new Set([].concat(_toConsumableArray(cachedSelectedKeys.current || []), _toConsumableArray(calcRangeKeys({\n treeData: treeData,\n expandedKeys: expandedKeys,\n startKey: key,\n endKey: lastSelectedKey.current\n })))));\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n } else {\n // Single click\n newSelectedKeys = [key];\n lastSelectedKey.current = key;\n cachedSelectedKeys.current = newSelectedKeys;\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n }\n\n if (props.onSelect) {\n props.onSelect(newSelectedKeys, newEvent);\n }\n\n if (!('selectedKeys' in props)) {\n setSelectedKeys(newSelectedKeys);\n }\n };\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction;\n\n var customizePrefixCls = props.prefixCls,\n className = props.className,\n otherProps = __rest(props, [\"prefixCls\", \"className\"]);\n\n var prefixCls = getPrefixCls('tree', customizePrefixCls);\n var connectClassName = classNames(\"\".concat(prefixCls, \"-directory\"), _defineProperty({}, \"\".concat(prefixCls, \"-directory-rtl\"), direction === 'rtl'), className);\n return /*#__PURE__*/React.createElement(Tree, _extends({\n icon: getIcon,\n ref: treeRef,\n blockNode: true\n }, otherProps, {\n prefixCls: prefixCls,\n className: connectClassName,\n expandedKeys: expandedKeys,\n selectedKeys: selectedKeys,\n onSelect: onSelect,\n onClick: onClick,\n onDoubleClick: onDoubleClick,\n onExpand: onExpand\n }));\n};\n\nvar ForwardDirectoryTree = /*#__PURE__*/React.forwardRef(DirectoryTree);\nForwardDirectoryTree.displayName = 'DirectoryTree';\nForwardDirectoryTree.defaultProps = {\n showIcon: true,\n expandAction: 'click'\n};\nexport default ForwardDirectoryTree;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/tree/DirectoryTree.js"],"names":["_defineProperty","_toConsumableArray","_extends","_slicedToArray","__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","classNames","debounce","conductExpandParent","convertDataToEntities","convertTreeToData","FileOutlined","FolderOpenOutlined","FolderOutlined","ConfigContext","Tree","calcRangeKeys","convertDirectoryKeysToNodes","getIcon","props","isLeaf","expanded","createElement","getTreeData","_ref","treeData","children","DirectoryTree","_a","ref","defaultExpandAll","defaultExpandParent","defaultExpandedKeys","lastSelectedKey","useRef","cachedSelectedKeys","treeRef","createRef","useImperativeHandle","current","getInitExpandedKeys","_convertDataToEntitie","keyEntities","initExpandedKeys","keys","expandedKeys","_React$useState","useState","selectedKeys","defaultSelectedKeys","_React$useState2","setSelectedKeys","_React$useState3","_React$useState4","setExpandedKeys","useEffect","expandFolderNode","event","node","shiftKey","metaKey","ctrlKey","onNodeExpand","onDebounceExpand","leading","onExpand","info","undefined","onClick","expandAction","onDoubleClick","onSelect","multiple","nativeEvent","_node$key","key","newEvent","selected","ctrlPick","shiftPick","newSelectedKeys","selectedNodes","Array","from","Set","concat","startKey","endKey","_React$useContext","useContext","getPrefixCls","direction","customizePrefixCls","prefixCls","className","otherProps","connectClassName","icon","blockNode","ForwardDirectoryTree","forwardRef","displayName","defaultProps","showIcon"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,uCAA5B;AACA,OAAOC,kBAAP,MAA+B,0CAA/B;AACA,OAAOC,QAAP,MAAqB,gCAArB;AACA,OAAOC,cAAP,MAA2B,sCAA3B;;AAEA,IAAIC,MAAM,GAAG,QAAQ,KAAKA,MAAb,IAAuB,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAClD,MAAIC,CAAC,GAAG,EAAR;;AAEA,OAAK,IAAIC,CAAT,IAAcH,CAAd,EAAiB;AACf,QAAII,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCP,CAArC,EAAwCG,CAAxC,KAA8CF,CAAC,CAACO,OAAF,CAAUL,CAAV,IAAe,CAAjE,EAAoED,CAAC,CAACC,CAAD,CAAD,GAAOH,CAAC,CAACG,CAAD,CAAR;AACrE;;AAED,MAAIH,CAAC,IAAI,IAAL,IAAa,OAAOI,MAAM,CAACK,qBAAd,KAAwC,UAAzD,EAAqE,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWP,CAAC,GAAGC,MAAM,CAACK,qBAAP,CAA6BT,CAA7B,CAApB,EAAqDU,CAAC,GAAGP,CAAC,CAACQ,MAA3D,EAAmED,CAAC,EAApE,EAAwE;AAC3I,QAAIT,CAAC,CAACO,OAAF,CAAUL,CAAC,CAACO,CAAD,CAAX,IAAkB,CAAlB,IAAuBN,MAAM,CAACC,SAAP,CAAiBO,oBAAjB,CAAsCL,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gBAAgB,GAAG1F,UAAU,CAAC,GAAG+E,MAAH,CAAUQ,SAAV,EAAqB,YAArB,CAAD,EAAqC1G,eAAe,CAAC,EAAD,EAAK,GAAGkG,MAAH,CAAUQ,SAAV,EAAqB,gBAArB,CAAL,EAA6CF,SAAS,KAAK,KAA3D,CAApD,EAAuHG,SAAvH,CAAjC;AACA,SAAO,aAAazF,KAAK,CAACiB,aAAN,CAAoBP,IAApB,EAA0B1B,QAAQ,CAAC;AACrD4G,IAAAA,IAAI,EAAE/E,OAD+C;AAErDW,IAAAA,GAAG,EAAEO,OAFgD;AAGrD8D,IAAAA,SAAS,EAAE;AAH0C,GAAD,EAInDH,UAJmD,EAIvC;AACbF,IAAAA,SAAS,EAAEA,SADE;AAEbC,IAAAA,SAAS,EAAEE,gBAFE;AAGbnD,IAAAA,YAAY,EAAEA,YAHD;AAIbG,IAAAA,YAAY,EAAEA,YAJD;AAKbuB,IAAAA,QAAQ,EAAEA,QALG;AAMbH,IAAAA,OAAO,EAAEA,OANI;AAObE,IAAAA,aAAa,EAAEA,aAPF;AAQbL,IAAAA,QAAQ,EAAEA;AARG,GAJuC,CAAlC,CAApB;AAcD,CApLD;;AAsLA,IAAIkC,oBAAoB,GAAG,aAAa9F,KAAK,CAAC+F,UAAN,CAAiBzE,aAAjB,CAAxC;AACAwE,oBAAoB,CAACE,WAArB,GAAmC,eAAnC;AACAF,oBAAoB,CAACG,YAArB,GAAoC;AAClCC,EAAAA,QAAQ,EAAE,IADwB;AAElClC,EAAAA,YAAY,EAAE;AAFoB,CAApC;AAIA,eAAe8B,oBAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/toConsumableArray\";\nimport _extends from \"@babel/runtime/helpers/extends\";\nimport _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n\n for (var p in s) {\n if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n }\n\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport debounce from 'lodash/debounce';\nimport { conductExpandParent } from \"rc-tree/es/util\";\nimport { convertDataToEntities, convertTreeToData } from \"rc-tree/es/utils/treeUtil\";\nimport FileOutlined from '@ant-design/icons/FileOutlined';\nimport FolderOpenOutlined from '@ant-design/icons/FolderOpenOutlined';\nimport FolderOutlined from '@ant-design/icons/FolderOutlined';\nimport { ConfigContext } from '../config-provider';\nimport Tree from './Tree';\nimport { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil';\n\nfunction getIcon(props) {\n var isLeaf = props.isLeaf,\n expanded = props.expanded;\n\n if (isLeaf) {\n return /*#__PURE__*/React.createElement(FileOutlined, null);\n }\n\n return expanded ? /*#__PURE__*/React.createElement(FolderOpenOutlined, null) : /*#__PURE__*/React.createElement(FolderOutlined, null);\n}\n\nfunction getTreeData(_ref) {\n var treeData = _ref.treeData,\n children = _ref.children;\n return treeData || convertTreeToData(children);\n}\n\nvar DirectoryTree = function DirectoryTree(_a, ref) {\n var defaultExpandAll = _a.defaultExpandAll,\n defaultExpandParent = _a.defaultExpandParent,\n defaultExpandedKeys = _a.defaultExpandedKeys,\n props = __rest(_a, [\"defaultExpandAll\", \"defaultExpandParent\", \"defaultExpandedKeys\"]); // Shift click usage\n\n\n var lastSelectedKey = React.useRef();\n var cachedSelectedKeys = React.useRef();\n var treeRef = /*#__PURE__*/React.createRef();\n React.useImperativeHandle(ref, function () {\n return treeRef.current;\n });\n\n var getInitExpandedKeys = function getInitExpandedKeys() {\n var _convertDataToEntitie = convertDataToEntities(getTreeData(props)),\n keyEntities = _convertDataToEntitie.keyEntities;\n\n var initExpandedKeys; // Expanded keys\n\n if (defaultExpandAll) {\n initExpandedKeys = Object.keys(keyEntities);\n } else if (defaultExpandParent) {\n initExpandedKeys = conductExpandParent(props.expandedKeys || defaultExpandedKeys, keyEntities);\n } else {\n initExpandedKeys = props.expandedKeys || defaultExpandedKeys;\n }\n\n return initExpandedKeys;\n };\n\n var _React$useState = React.useState(props.selectedKeys || props.defaultSelectedKeys || []),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n selectedKeys = _React$useState2[0],\n setSelectedKeys = _React$useState2[1];\n\n var _React$useState3 = React.useState(getInitExpandedKeys()),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n expandedKeys = _React$useState4[0],\n setExpandedKeys = _React$useState4[1];\n\n React.useEffect(function () {\n if ('selectedKeys' in props) {\n setSelectedKeys(props.selectedKeys);\n }\n }, [props.selectedKeys]);\n React.useEffect(function () {\n if ('expandedKeys' in props) {\n setExpandedKeys(props.expandedKeys);\n }\n }, [props.expandedKeys]);\n\n var expandFolderNode = function expandFolderNode(event, node) {\n var isLeaf = node.isLeaf;\n\n if (isLeaf || event.shiftKey || event.metaKey || event.ctrlKey) {\n return;\n } // Call internal rc-tree expand function\n // https://github.com/ant-design/ant-design/issues/12567\n\n\n treeRef.current.onNodeExpand(event, node);\n };\n\n var onDebounceExpand = debounce(expandFolderNode, 200, {\n leading: true\n });\n\n var onExpand = function onExpand(keys, info) {\n if (!('expandedKeys' in props)) {\n setExpandedKeys(keys);\n } // Call origin function\n\n\n if (props.onExpand) {\n return props.onExpand(keys, info);\n }\n\n return undefined;\n };\n\n var onClick = function onClick(event, node) {\n var expandAction = props.expandAction; // Expand the tree\n\n if (expandAction === 'click') {\n onDebounceExpand(event, node);\n }\n\n if (props.onClick) {\n props.onClick(event, node);\n }\n };\n\n var onDoubleClick = function onDoubleClick(event, node) {\n var expandAction = props.expandAction; // Expand the tree\n\n if (expandAction === 'doubleClick') {\n onDebounceExpand(event, node);\n }\n\n if (props.onDoubleClick) {\n props.onDoubleClick(event, node);\n }\n };\n\n var onSelect = function onSelect(keys, event) {\n var multiple = props.multiple;\n var node = event.node,\n nativeEvent = event.nativeEvent;\n var _node$key = node.key,\n key = _node$key === void 0 ? '' : _node$key;\n var treeData = getTreeData(props); // const newState: DirectoryTreeState = {};\n // We need wrap this event since some value is not same\n\n var newEvent = _extends(_extends({}, event), {\n selected: true\n }); // Windows / Mac single pick\n\n\n var ctrlPick = nativeEvent.ctrlKey || nativeEvent.metaKey;\n var shiftPick = nativeEvent.shiftKey; // Generate new selected keys\n\n var newSelectedKeys;\n\n if (multiple && ctrlPick) {\n // Control click\n newSelectedKeys = keys;\n lastSelectedKey.current = key;\n cachedSelectedKeys.current = newSelectedKeys;\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n } else if (multiple && shiftPick) {\n // Shift click\n newSelectedKeys = Array.from(new Set([].concat(_toConsumableArray(cachedSelectedKeys.current || []), _toConsumableArray(calcRangeKeys({\n treeData: treeData,\n expandedKeys: expandedKeys,\n startKey: key,\n endKey: lastSelectedKey.current\n })))));\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n } else {\n // Single click\n newSelectedKeys = [key];\n lastSelectedKey.current = key;\n cachedSelectedKeys.current = newSelectedKeys;\n newEvent.selectedNodes = convertDirectoryKeysToNodes(treeData, newSelectedKeys);\n }\n\n if (props.onSelect) {\n props.onSelect(newSelectedKeys, newEvent);\n }\n\n if (!('selectedKeys' in props)) {\n setSelectedKeys(newSelectedKeys);\n }\n };\n\n var _React$useContext = React.useContext(ConfigContext),\n getPrefixCls = _React$useContext.getPrefixCls,\n direction = _React$useContext.direction;\n\n var customizePrefixCls = props.prefixCls,\n className = props.className,\n otherProps = __rest(props, [\"prefixCls\", \"className\"]);\n\n var prefixCls = getPrefixCls('tree', customizePrefixCls);\n var connectClassName = classNames(\"\".concat(prefixCls, \"-directory\"), _defineProperty({}, \"\".concat(prefixCls, \"-directory-rtl\"), direction === 'rtl'), className);\n return /*#__PURE__*/React.createElement(Tree, _extends({\n icon: getIcon,\n ref: treeRef,\n blockNode: true\n }, otherProps, {\n prefixCls: prefixCls,\n className: connectClassName,\n expandedKeys: expandedKeys,\n selectedKeys: selectedKeys,\n onSelect: onSelect,\n onClick: onClick,\n onDoubleClick: onDoubleClick,\n onExpand: onExpand\n }));\n};\n\nvar ForwardDirectoryTree = /*#__PURE__*/React.forwardRef(DirectoryTree);\nForwardDirectoryTree.displayName = 'DirectoryTree';\nForwardDirectoryTree.defaultProps = {\n showIcon: true,\n expandAction: 'click'\n};\nexport default ForwardDirectoryTree;"]},"metadata":{},"sourceType":"module"}