@electerm/electerm-react 3.7.18 → 3.8.8
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/client/components/file-transfer/transfer.jsx +17 -6
- package/client/components/setting-panel/setting-modal.jsx +1 -0
- package/client/components/sftp/file-info-modal.jsx +50 -0
- package/client/components/sftp/file-item.jsx +7 -7
- package/client/components/tree-list/tree-expander.jsx +9 -20
- package/client/components/tree-list/tree-item-op.jsx +156 -0
- package/client/components/tree-list/tree-list-editor-overlay.jsx +47 -0
- package/client/components/tree-list/tree-list-item.jsx +6 -170
- package/client/components/tree-list/tree-list-layout.js +3 -0
- package/client/components/tree-list/tree-list-row.jsx +111 -0
- package/client/components/tree-list/tree-list-rows.js +107 -0
- package/client/components/tree-list/tree-list.jsx +226 -314
- package/client/components/tree-list/tree-list.styl +49 -6
- package/client/components/tree-list/virtual-tree-list.jsx +112 -0
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import TreeExpander from './tree-expander'
|
|
2
|
+
import TreeListItem from './tree-list-item'
|
|
3
|
+
import TreeItemOp from './tree-item-op'
|
|
4
|
+
import { treeLevelIndent } from './tree-list-layout'
|
|
5
|
+
|
|
6
|
+
export default function TreeListRow (props) {
|
|
7
|
+
const {
|
|
8
|
+
row,
|
|
9
|
+
keyword,
|
|
10
|
+
expandedKeys,
|
|
11
|
+
activeItemId,
|
|
12
|
+
searchSelectedRowKey,
|
|
13
|
+
staticList,
|
|
14
|
+
leftSidebarWidth,
|
|
15
|
+
handleExpand,
|
|
16
|
+
handleUnExpand,
|
|
17
|
+
del,
|
|
18
|
+
openAll,
|
|
19
|
+
openMoveModal,
|
|
20
|
+
editItem,
|
|
21
|
+
addSubCat,
|
|
22
|
+
onSelect,
|
|
23
|
+
duplicateItem,
|
|
24
|
+
onDragStart,
|
|
25
|
+
onDrop,
|
|
26
|
+
onDragEnter,
|
|
27
|
+
onDragLeave,
|
|
28
|
+
onDragOver,
|
|
29
|
+
isHidden
|
|
30
|
+
} = props
|
|
31
|
+
const { item, isGroup, parentId, depth } = row
|
|
32
|
+
const groupHasChildren = Boolean(
|
|
33
|
+
item?.bookmarkIds?.length ||
|
|
34
|
+
item?.bookmarkGroupIds?.length
|
|
35
|
+
)
|
|
36
|
+
const isGroupExpanded = Boolean(keyword) || expandedKeys.includes(item.id)
|
|
37
|
+
const itemProps = {
|
|
38
|
+
item,
|
|
39
|
+
isGroup,
|
|
40
|
+
parentId,
|
|
41
|
+
leftSidebarWidth,
|
|
42
|
+
staticList,
|
|
43
|
+
selectedItemId: activeItemId,
|
|
44
|
+
searchSelected: searchSelectedRowKey === row.key,
|
|
45
|
+
del,
|
|
46
|
+
openAll,
|
|
47
|
+
openMoveModal,
|
|
48
|
+
editItem,
|
|
49
|
+
addSubCat,
|
|
50
|
+
onSelect,
|
|
51
|
+
duplicateItem,
|
|
52
|
+
onDragStart,
|
|
53
|
+
onDrop,
|
|
54
|
+
onDragEnter,
|
|
55
|
+
onDragLeave,
|
|
56
|
+
onDragOver,
|
|
57
|
+
keyword
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!isGroup) {
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
className={`tree-list-row${isHidden ? ' is-hidden' : ''}`}
|
|
64
|
+
style={{ paddingLeft: depth * treeLevelIndent }}
|
|
65
|
+
>
|
|
66
|
+
<TreeListItem {...itemProps} />
|
|
67
|
+
<TreeItemOp
|
|
68
|
+
item={item}
|
|
69
|
+
isGroup={isGroup}
|
|
70
|
+
staticList={staticList}
|
|
71
|
+
del={del}
|
|
72
|
+
openAll={openAll}
|
|
73
|
+
openMoveModal={openMoveModal}
|
|
74
|
+
editItem={editItem}
|
|
75
|
+
addSubCat={addSubCat}
|
|
76
|
+
duplicateItem={duplicateItem}
|
|
77
|
+
/>
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
className={`tree-list-row${isHidden ? ' is-hidden' : ''}`}
|
|
85
|
+
style={{ paddingLeft: Math.max(0, (depth - 1) * treeLevelIndent) }}
|
|
86
|
+
>
|
|
87
|
+
<div className='tree-list-row-group'>
|
|
88
|
+
<TreeExpander
|
|
89
|
+
level={parentId}
|
|
90
|
+
group={item}
|
|
91
|
+
hasChildren={groupHasChildren}
|
|
92
|
+
shouldOpen={isGroupExpanded}
|
|
93
|
+
onExpand={handleExpand}
|
|
94
|
+
onUnExpand={handleUnExpand}
|
|
95
|
+
/>
|
|
96
|
+
<TreeListItem {...itemProps} />
|
|
97
|
+
<TreeItemOp
|
|
98
|
+
item={item}
|
|
99
|
+
isGroup={isGroup}
|
|
100
|
+
staticList={staticList}
|
|
101
|
+
del={del}
|
|
102
|
+
openAll={openAll}
|
|
103
|
+
openMoveModal={openMoveModal}
|
|
104
|
+
editItem={editItem}
|
|
105
|
+
addSubCat={addSubCat}
|
|
106
|
+
duplicateItem={duplicateItem}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import createName from '../../common/create-title'
|
|
2
|
+
|
|
3
|
+
function isTopLevelGroup (group) {
|
|
4
|
+
return !group?.level || group.level < 2
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function buildVisibleTreeRows ({
|
|
8
|
+
bookmarkGroups,
|
|
9
|
+
bookmarkGroupTree,
|
|
10
|
+
bookmarksMap,
|
|
11
|
+
expandedKeys,
|
|
12
|
+
keyword
|
|
13
|
+
}) {
|
|
14
|
+
const groupTree = bookmarkGroupTree || {}
|
|
15
|
+
const rows = []
|
|
16
|
+
const matchedRowKeys = []
|
|
17
|
+
const expandedKeySet = new Set(expandedKeys || [])
|
|
18
|
+
const lowerKeyword = (keyword || '').toLowerCase()
|
|
19
|
+
const bookmarkMatchCache = new Map()
|
|
20
|
+
const groupMatchCache = new Map()
|
|
21
|
+
|
|
22
|
+
const bookmarkMatches = (bookmarkId) => {
|
|
23
|
+
if (bookmarkMatchCache.has(bookmarkId)) {
|
|
24
|
+
return bookmarkMatchCache.get(bookmarkId)
|
|
25
|
+
}
|
|
26
|
+
const item = bookmarksMap.get(bookmarkId)
|
|
27
|
+
const matched = Boolean(
|
|
28
|
+
item &&
|
|
29
|
+
(!lowerKeyword || createName(item).toLowerCase().includes(lowerKeyword))
|
|
30
|
+
)
|
|
31
|
+
bookmarkMatchCache.set(bookmarkId, matched)
|
|
32
|
+
return matched
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const groupHasMatchedBookmarks = (group) => {
|
|
36
|
+
if (!lowerKeyword) {
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
if (!group) {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
if (groupMatchCache.has(group.id)) {
|
|
43
|
+
return groupMatchCache.get(group.id)
|
|
44
|
+
}
|
|
45
|
+
const hasMatch = (group.bookmarkIds || []).some(bookmarkMatches) ||
|
|
46
|
+
(group.bookmarkGroupIds || []).some(id => {
|
|
47
|
+
return groupHasMatchedBookmarks(groupTree[id])
|
|
48
|
+
})
|
|
49
|
+
groupMatchCache.set(group.id, hasMatch)
|
|
50
|
+
return hasMatch
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const visitGroup = (group, parentId = '', depth = 1) => {
|
|
54
|
+
if (!group || (lowerKeyword && !groupHasMatchedBookmarks(group))) {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
rows.push({
|
|
59
|
+
key: `group:${group.id}`,
|
|
60
|
+
item: group,
|
|
61
|
+
isGroup: true,
|
|
62
|
+
parentId,
|
|
63
|
+
depth
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
if (!lowerKeyword && !expandedKeySet.has(group.id)) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const nextParentId = parentId
|
|
71
|
+
? `${parentId}#${group.id}`
|
|
72
|
+
: `#${group.id}`
|
|
73
|
+
|
|
74
|
+
for (const groupId of group.bookmarkGroupIds || []) {
|
|
75
|
+
visitGroup(groupTree[groupId], nextParentId, depth + 1)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
for (const bookmarkId of group.bookmarkIds || []) {
|
|
79
|
+
const item = bookmarksMap.get(bookmarkId)
|
|
80
|
+
if (!item || (lowerKeyword && !bookmarkMatches(bookmarkId))) {
|
|
81
|
+
continue
|
|
82
|
+
}
|
|
83
|
+
const rowKey = `bookmark:${item.id}`
|
|
84
|
+
rows.push({
|
|
85
|
+
key: rowKey,
|
|
86
|
+
item,
|
|
87
|
+
isGroup: false,
|
|
88
|
+
parentId: nextParentId,
|
|
89
|
+
depth
|
|
90
|
+
})
|
|
91
|
+
if (lowerKeyword) {
|
|
92
|
+
matchedRowKeys.push(rowKey)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const group of bookmarkGroups || []) {
|
|
98
|
+
if (isTopLevelGroup(group)) {
|
|
99
|
+
visitGroup(group)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
rows,
|
|
105
|
+
matchedRowKeys
|
|
106
|
+
}
|
|
107
|
+
}
|