@kne/file-system-view 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -256,6 +256,7 @@ render(<ControlledExample />);
256
256
  | menuItems | `MenuItem[]` | - | 操作菜单项配置,不传则不显示操作按钮 |
257
257
  | defaultExpandAll | `boolean` | `false` | 是否默认展开所有目录 |
258
258
  | expandedKeys | `string[]` | - | (受控)展开的节点 key 数组 |
259
+ | selectedPath | `string` | - | 选中的文件/目录路径,用于高亮显示 |
259
260
  | onExpand | `(keys: string[], info: { node, expanded, nativeEvent }) => void` | - | 展开/收起节点时的回调 |
260
261
  | onFileClick | `(data: FileItem, key: string) => void` | - | 点击文件时的回调 |
261
262
 
package/dist/index.css CHANGED
@@ -65,6 +65,12 @@
65
65
  opacity: 1;
66
66
  visibility: visible;
67
67
  }
68
+ ._t015K._vI5hy {
69
+ background: rgba(22, 119, 255, 0.12);
70
+ }
71
+ ._t015K._vI5hy:hover {
72
+ background: rgba(22, 119, 255, 0.16);
73
+ }
68
74
 
69
75
  ._dgomj {
70
76
  display: flex;
@@ -1 +1 @@
1
- {"version":3,"sources":["style.module.scss"],"names":[],"mappings":"AAAA;EACE,eAAe;EACf,yBAAiB;UAAjB,iBAAiB;AACnB;AACA;EACE,uBAAuB;AACzB;AACA;EACE,UAAU;EACV,WAAW;EACX,kBAAkB;AACpB;AACA;EACE,SAAS;AACX;AACA;EACE,UAAU;EACV,OAAO;EACP,YAAY;AACd;AACA;EACE,uBAAuB;AACzB;AACA;EACE,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,WAAW;EACX,cAAc;AAChB;AACA;EACE,aAAa;AACf;AACA;EACE,eAAe;AACjB;AACA;EACE,cAAc;AAChB;AACA;EACE,kCAAkC;EAClC,yBAAyB;AAC3B;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,yBAAyB;EACzB,kBAAkB;EAClB,gBAAgB;EAChB,WAAW;AACb;AACA;EACE,+BAA+B;AACjC;AACA;EACE,gBAAgB;EAChB,UAAU;EACV,mBAAmB;AACrB;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,WAAW;EACX,YAAY;EACZ,iBAAiB;EACjB,cAAc;AAChB;AACA;EACE,eAAe;AACjB;;AAEA;EACE,OAAO;EACP,gBAAgB;EAChB,mBAAmB;EACnB,WAAW;EACX,eAAe;EACf,aAAa;EACb,YAAY;AACd;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;EACnB,YAAY;AACd;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,UAAU;EACV,kBAAkB;EAClB,yBAAyB;EACzB,iBAAiB;EACjB,cAAc;EACd,YAAY;EACZ,WAAW;EACX,cAAc;EACd,WAAW;AACb;AACA;EACE,cAAc;EACd,mCAAmC;AACrC;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB","file":"index.css","sourcesContent":[".file-system-view {\n font-size: 14px;\n user-select: none;\n}\n.file-system-view :global .ant-tree {\n background: transparent;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode {\n padding: 0;\n width: 100%;\n position: relative;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode:before {\n bottom: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-node-content-wrapper {\n padding: 0;\n flex: 1;\n min-width: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-node-content-wrapper:hover {\n background: transparent;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-switcher {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 10px;\n flex-shrink: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-switcher:before {\n display: none;\n}\n.file-system-view :global .ant-tree-list-holder-inner .ant-tree-treenode {\n padding-left: 0;\n}\n.file-system-view :global .ant-tree-switcher-line-icon {\n color: #d9d9d9;\n}\n.file-system-view :global .ant-tree-node-content-wrapper .tree-node {\n border-left: 2px solid transparent;\n transition: all 0.2s ease;\n}\n.file-system-view :global .ant-tree-treenode[style*=\"padding-left: 0px\"] .tree-node, .file-system-view :global .ant-tree-treenode:first-child .tree-node {\n background: rgba(0, 0, 0, 0.02);\n}\n\n.tree-node {\n display: flex;\n align-items: center;\n padding: 4px 8px;\n border-radius: 4px;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n min-height: 28px;\n width: 100%;\n}\n.tree-node:hover {\n background: rgba(0, 0, 0, 0.04);\n}\n.tree-node:hover .action-btn {\n margin-left: 4px;\n opacity: 1;\n visibility: visible;\n}\n\n.node-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n margin-right: 6px;\n flex-shrink: 0;\n}\n.node-icon :global .anticon {\n font-size: 14px;\n}\n\n.node-title {\n flex: 1;\n overflow: hidden;\n white-space: nowrap;\n color: #333;\n font-size: 13px;\n display: flex;\n min-width: 0;\n}\n\n.node-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.node-ext {\n flex-shrink: 0;\n}\n\n.action-btn {\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n margin-left: auto;\n padding: 0 2px;\n height: 20px;\n width: 20px;\n flex-shrink: 0;\n color: #999;\n}\n.action-btn:hover {\n color: #1677ff;\n background: rgba(22, 119, 255, 0.1);\n}\n\n.empty {\n padding: 40px 20px;\n text-align: center;\n color: #999;\n font-size: 14px;\n}"]}
1
+ {"version":3,"sources":["style.module.scss"],"names":[],"mappings":"AAAA;EACE,eAAe;EACf,yBAAiB;UAAjB,iBAAiB;AACnB;AACA;EACE,uBAAuB;AACzB;AACA;EACE,UAAU;EACV,WAAW;EACX,kBAAkB;AACpB;AACA;EACE,SAAS;AACX;AACA;EACE,UAAU;EACV,OAAO;EACP,YAAY;AACd;AACA;EACE,uBAAuB;AACzB;AACA;EACE,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,WAAW;EACX,cAAc;AAChB;AACA;EACE,aAAa;AACf;AACA;EACE,eAAe;AACjB;AACA;EACE,cAAc;AAChB;AACA;EACE,kCAAkC;EAClC,yBAAyB;AAC3B;AACA;EACE,+BAA+B;AACjC;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,gBAAgB;EAChB,kBAAkB;EAClB,eAAe;EACf,yBAAyB;EACzB,kBAAkB;EAClB,gBAAgB;EAChB,WAAW;AACb;AACA;EACE,+BAA+B;AACjC;AACA;EACE,gBAAgB;EAChB,UAAU;EACV,mBAAmB;AACrB;AACA;EACE,oCAAoC;AACtC;AACA;EACE,oCAAoC;AACtC;;AAEA;EACE,aAAa;EACb,mBAAmB;EACnB,uBAAuB;EACvB,WAAW;EACX,YAAY;EACZ,iBAAiB;EACjB,cAAc;AAChB;AACA;EACE,eAAe;AACjB;;AAEA;EACE,OAAO;EACP,gBAAgB;EAChB,mBAAmB;EACnB,WAAW;EACX,eAAe;EACf,aAAa;EACb,YAAY;AACd;;AAEA;EACE,gBAAgB;EAChB,uBAAuB;EACvB,mBAAmB;EACnB,YAAY;AACd;;AAEA;EACE,cAAc;AAChB;;AAEA;EACE,UAAU;EACV,kBAAkB;EAClB,yBAAyB;EACzB,iBAAiB;EACjB,cAAc;EACd,YAAY;EACZ,WAAW;EACX,cAAc;EACd,WAAW;AACb;AACA;EACE,cAAc;EACd,mCAAmC;AACrC;;AAEA;EACE,kBAAkB;EAClB,kBAAkB;EAClB,WAAW;EACX,eAAe;AACjB","file":"index.css","sourcesContent":[".file-system-view {\n font-size: 14px;\n user-select: none;\n}\n.file-system-view :global .ant-tree {\n background: transparent;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode {\n padding: 0;\n width: 100%;\n position: relative;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode:before {\n bottom: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-node-content-wrapper {\n padding: 0;\n flex: 1;\n min-width: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-node-content-wrapper:hover {\n background: transparent;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-switcher {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 10px;\n flex-shrink: 0;\n}\n.file-system-view :global .ant-tree .ant-tree-treenode .ant-tree-switcher:before {\n display: none;\n}\n.file-system-view :global .ant-tree-list-holder-inner .ant-tree-treenode {\n padding-left: 0;\n}\n.file-system-view :global .ant-tree-switcher-line-icon {\n color: #d9d9d9;\n}\n.file-system-view :global .ant-tree-node-content-wrapper .tree-node {\n border-left: 2px solid transparent;\n transition: all 0.2s ease;\n}\n.file-system-view :global .ant-tree-treenode[style*=\"padding-left: 0px\"] .tree-node, .file-system-view :global .ant-tree-treenode:first-child .tree-node {\n background: rgba(0, 0, 0, 0.02);\n}\n\n.tree-node {\n display: flex;\n align-items: center;\n padding: 4px 8px;\n border-radius: 4px;\n cursor: pointer;\n transition: all 0.2s ease;\n position: relative;\n min-height: 28px;\n width: 100%;\n}\n.tree-node:hover {\n background: rgba(0, 0, 0, 0.04);\n}\n.tree-node:hover .action-btn {\n margin-left: 4px;\n opacity: 1;\n visibility: visible;\n}\n.tree-node.selected {\n background: rgba(22, 119, 255, 0.12);\n}\n.tree-node.selected:hover {\n background: rgba(22, 119, 255, 0.16);\n}\n\n.node-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n margin-right: 6px;\n flex-shrink: 0;\n}\n.node-icon :global .anticon {\n font-size: 14px;\n}\n\n.node-title {\n flex: 1;\n overflow: hidden;\n white-space: nowrap;\n color: #333;\n font-size: 13px;\n display: flex;\n min-width: 0;\n}\n\n.node-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n min-width: 0;\n}\n\n.node-ext {\n flex-shrink: 0;\n}\n\n.action-btn {\n opacity: 0;\n visibility: hidden;\n transition: all 0.2s ease;\n margin-left: auto;\n padding: 0 2px;\n height: 20px;\n width: 20px;\n flex-shrink: 0;\n color: #999;\n}\n.action-btn:hover {\n color: #1677ff;\n background: rgba(22, 119, 255, 0.1);\n}\n\n.empty {\n padding: 40px 20px;\n text-align: center;\n color: #999;\n font-size: 14px;\n}"]}
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ const withLocale = reactIntl.createWithIntlProvider({
43
43
  namespace: 'file-system-view'
44
44
  });
45
45
 
46
- var style = {"file-system-view":"_qMhn9","tree-node":"_t015K","action-btn":"_mLgqh","node-icon":"_dgomj","node-title":"_r6Ngq","node-name":"_st428","node-ext":"_POSao","empty":"_4zeDm"};
46
+ var style = {"file-system-view":"_qMhn9","tree-node":"_t015K","action-btn":"_mLgqh","selected":"_vI5hy","node-icon":"_dgomj","node-title":"_r6Ngq","node-name":"_st428","node-ext":"_POSao","empty":"_4zeDm"};
47
47
 
48
48
  const IconContext = /*#__PURE__*/React.createContext({});
49
49
  var Context = IconContext;
@@ -1733,6 +1733,7 @@ const TreeNode = ({
1733
1733
  node,
1734
1734
  menuItems,
1735
1735
  expandedKeys,
1736
+ selectedPath,
1736
1737
  onToggle,
1737
1738
  onFileClick,
1738
1739
  rootRef
@@ -1745,6 +1746,7 @@ const TreeNode = ({
1745
1746
  data
1746
1747
  } = node;
1747
1748
  const isExpanded = expandedKeys.includes(key);
1749
+ const isSelected = selectedPath === key;
1748
1750
  const {
1749
1751
  icon: IconComponent,
1750
1752
  color
@@ -1777,7 +1779,7 @@ const TreeNode = ({
1777
1779
  }
1778
1780
  }, [isDirectory, onToggle, onFileClick, key, isExpanded, data]);
1779
1781
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
1780
- className: style['tree-node'],
1782
+ className: `${style['tree-node']}${isSelected ? ` ${style['selected']}` : ''}`,
1781
1783
  onClick: handleNodeClick,
1782
1784
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
1783
1785
  className: style['node-icon'],
@@ -1821,6 +1823,7 @@ const FileSystemView = withLocale(_ref => {
1821
1823
  menuItems,
1822
1824
  defaultExpandAll,
1823
1825
  expandedKeys: controlledExpandedKeys,
1826
+ selectedPath,
1824
1827
  onExpand,
1825
1828
  onFileClick
1826
1829
  } = _ref;
@@ -1878,9 +1881,10 @@ const FileSystemView = withLocale(_ref => {
1878
1881
  node: node,
1879
1882
  menuItems: menuItems,
1880
1883
  expandedKeys: expandedKeys,
1884
+ selectedPath: selectedPath,
1881
1885
  onToggle: handleToggle,
1882
1886
  onFileClick: onFileClick
1883
- }), [menuItems, expandedKeys, handleToggle, onFileClick]);
1887
+ }), [menuItems, expandedKeys, selectedPath, handleToggle, onFileClick]);
1884
1888
  if (!data || data.length === 0) {
1885
1889
  return /*#__PURE__*/jsxRuntime.jsx("div", {
1886
1890
  className: style['empty'],