@neo4j-ndl/react 2.9.4 → 2.10.0
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/CHANGELOG.md +6 -0
- package/lib/LICENSES.txt +26 -0
- package/lib/NOTICE.txt +6 -0
- package/lib/cjs/_common/utils.js +41 -1
- package/lib/cjs/_common/utils.js.map +1 -1
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/tree-view/TreeItemWrapper.js +201 -0
- package/lib/cjs/tree-view/TreeItemWrapper.js.map +1 -0
- package/lib/cjs/tree-view/TreeView.js +314 -0
- package/lib/cjs/tree-view/TreeView.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewItem.js +89 -0
- package/lib/cjs/tree-view/TreeViewItem.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewTextItem.js +153 -0
- package/lib/cjs/tree-view/TreeViewTextItem.js.map +1 -0
- package/lib/cjs/tree-view/TreeViewTrail.js +30 -0
- package/lib/cjs/tree-view/TreeViewTrail.js.map +1 -0
- package/lib/cjs/tree-view/index.js +26 -0
- package/lib/cjs/tree-view/index.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js +119 -0
- package/lib/cjs/tree-view/tree-view-keyboard-coordinates.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-keyboard-helpers.js +75 -0
- package/lib/cjs/tree-view/tree-view-keyboard-helpers.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-types.js +24 -0
- package/lib/cjs/tree-view/tree-view-types.js.map +1 -0
- package/lib/cjs/tree-view/tree-view-utils.js +187 -0
- package/lib/cjs/tree-view/tree-view-utils.js.map +1 -0
- package/lib/esm/_common/utils.js +38 -0
- package/lib/esm/_common/utils.js.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/tree-view/TreeItemWrapper.js +172 -0
- package/lib/esm/tree-view/TreeItemWrapper.js.map +1 -0
- package/lib/esm/tree-view/TreeView.js +310 -0
- package/lib/esm/tree-view/TreeView.js.map +1 -0
- package/lib/esm/tree-view/TreeViewItem.js +63 -0
- package/lib/esm/tree-view/TreeViewItem.js.map +1 -0
- package/lib/esm/tree-view/TreeViewTextItem.js +147 -0
- package/lib/esm/tree-view/TreeViewTextItem.js.map +1 -0
- package/lib/esm/tree-view/TreeViewTrail.js +26 -0
- package/lib/esm/tree-view/TreeViewTrail.js.map +1 -0
- package/lib/esm/tree-view/index.js +22 -0
- package/lib/esm/tree-view/index.js.map +1 -0
- package/lib/esm/tree-view/tree-view-keyboard-coordinates.js +115 -0
- package/lib/esm/tree-view/tree-view-keyboard-coordinates.js.map +1 -0
- package/lib/esm/tree-view/tree-view-keyboard-helpers.js +68 -0
- package/lib/esm/tree-view/tree-view-keyboard-helpers.js.map +1 -0
- package/lib/esm/tree-view/tree-view-types.js +23 -0
- package/lib/esm/tree-view/tree-view-types.js.map +1 -0
- package/lib/esm/tree-view/tree-view-utils.js +179 -0
- package/lib/esm/tree-view/tree-view-utils.js.map +1 -0
- package/lib/types/_common/utils.d.ts +12 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/table/Table.d.ts +1 -1
- package/lib/types/tree-view/TreeItemWrapper.d.ts +32 -0
- package/lib/types/tree-view/TreeView.d.ts +34 -0
- package/lib/types/tree-view/TreeViewItem.d.ts +52 -0
- package/lib/types/tree-view/TreeViewTextItem.d.ts +23 -0
- package/lib/types/tree-view/TreeViewTrail.d.ts +24 -0
- package/lib/types/tree-view/index.d.ts +23 -0
- package/lib/types/tree-view/tree-view-keyboard-coordinates.d.ts +23 -0
- package/lib/types/tree-view/tree-view-keyboard-helpers.d.ts +25 -0
- package/lib/types/tree-view/tree-view-types.d.ts +80 -0
- package/lib/types/tree-view/tree-view-utils.d.ts +77 -0
- package/lib/types/typography/Typography.d.ts +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { createElement as _createElement } from "react";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) "Neo4j"
|
|
17
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
18
|
+
*
|
|
19
|
+
* This file is part of Neo4j.
|
|
20
|
+
*
|
|
21
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
22
|
+
* it under the terms of the GNU General Public License as published by
|
|
23
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
24
|
+
* (at your option) any later version.
|
|
25
|
+
*
|
|
26
|
+
* This program is distributed in the hope that it will be useful,
|
|
27
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
28
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
29
|
+
* GNU General Public License for more details.
|
|
30
|
+
*
|
|
31
|
+
* You should have received a copy of the GNU General Public License
|
|
32
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
33
|
+
*/
|
|
34
|
+
import React from 'react';
|
|
35
|
+
import { ConditionalWrap } from '../_common/coditionalWrap';
|
|
36
|
+
import { IconButton } from '../button';
|
|
37
|
+
import { Checkbox } from '../checkbox';
|
|
38
|
+
import { ChevronDownIconOutline, ChevronRightIconOutline } from '../icons';
|
|
39
|
+
import { Typography } from '../typography';
|
|
40
|
+
import { TreeItemWrapper } from './TreeItemWrapper';
|
|
41
|
+
/**
|
|
42
|
+
* checks if any parent is checked
|
|
43
|
+
* @param item
|
|
44
|
+
* @param items
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
const parentIsCheckedRecursively = (item, items) => {
|
|
48
|
+
const parent = items.find((i) => i.id === item.parentId);
|
|
49
|
+
if (parent) {
|
|
50
|
+
if (parent.isSelected) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return parentIsCheckedRecursively(parent, items);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* checks if any children are checked
|
|
59
|
+
* @param item
|
|
60
|
+
* @param items
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
const childrenCheckedRecursively = (item, items) => {
|
|
64
|
+
const children = items.filter((i) => i.parentId === item.id);
|
|
65
|
+
if (children.length === 0) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return children.some((i) => i.isSelected || childrenCheckedRecursively(i, items));
|
|
69
|
+
};
|
|
70
|
+
export const TreeViewTextItem = React.forwardRef(function TreeViewTextItem(_a, ref) {
|
|
71
|
+
var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, indentationWidth, isIndicator, isCollapsed, onCollapse, item, parent, isOver, isOverParent, setNodeRef, setActivatorNodeRef, dragHandleProps, style, trails, onItemsChanged, items, tabIndex } = _a, restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "indentationWidth", "isIndicator", "isCollapsed", "onCollapse", "item", "parent", "isOver", "isOverParent", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "trails", "onItemsChanged", "items", "tabIndex"]);
|
|
72
|
+
const checkboxRef = React.useRef(null);
|
|
73
|
+
const isAnyParentChecked = parentIsCheckedRecursively(item, items);
|
|
74
|
+
if (checkboxRef.current) {
|
|
75
|
+
const isAnyChildChecked = childrenCheckedRecursively(item, items);
|
|
76
|
+
if (isAnyChildChecked && !isAnyParentChecked && !item.isSelected) {
|
|
77
|
+
checkboxRef.current.indeterminate = true;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
checkboxRef.current.indeterminate = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return (_jsxs(TreeItemWrapper, Object.assign({ depth: depth, shouldDisableInteraction: shouldDisableInteraction, shouldDisableSorting: shouldDisableSorting, isGhost: isGhost, indentationWidth: indentationWidth, isIndicator: isIndicator, isCollapsed: isCollapsed, onCollapse: onCollapse, item: item, parent: parent, isOver: isOver, isOverParent: isOverParent, setNodeRef: setNodeRef, setActivatorNodeRef: setActivatorNodeRef, dragHandleProps: dragHandleProps, style: style, trails: trails,
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
85
|
+
onItemsChanged: () => { }, ref: ref, items: items, tabIndex: tabIndex }, restProps, { children: [item.canHaveSubItems && onCollapse && (_jsxs("button", { className: "ndl-tree-view-collapse-button", onClick: () => onCollapse(), "aria-label": item.isCollapsed ? 'Expand' : 'Collapse', "aria-expanded": item.isCollapsed ? 'false' : 'true', "aria-pressed": !item.isCollapsed,
|
|
86
|
+
/**
|
|
87
|
+
* Tab index is set to -1 to prevent the item from being focused when the tree is navigated with tab
|
|
88
|
+
* since we use the arrow keys instead
|
|
89
|
+
*/
|
|
90
|
+
tabIndex: tabIndex, children: [item.isCollapsed && _jsx(ChevronRightIconOutline, { className: "ndl-icon" }), !item.isCollapsed && _jsx(ChevronDownIconOutline, { className: "ndl-icon" })] })), item.isSelected !== undefined && (_jsx(Checkbox, { ref: checkboxRef, checked: item.isSelected, tabIndex: tabIndex, onChange: (event) => {
|
|
91
|
+
const newItems = items.map((i) => {
|
|
92
|
+
if (i.id === item.id) {
|
|
93
|
+
return Object.assign(Object.assign({}, i), { isSelected: event.target.checked });
|
|
94
|
+
}
|
|
95
|
+
return i;
|
|
96
|
+
});
|
|
97
|
+
//Uncheck parents if a child is unchecked
|
|
98
|
+
if (!event.target.checked) {
|
|
99
|
+
let parentId = item.parentId;
|
|
100
|
+
while (parentId !== null) {
|
|
101
|
+
const parent = newItems.find((newItem) => newItem.id === parentId);
|
|
102
|
+
if (parent) {
|
|
103
|
+
newItems.forEach((newItem) => {
|
|
104
|
+
if (newItem.id === parent.id) {
|
|
105
|
+
newItem.isSelected = false;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
parentId = parent.parentId;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
parentId = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//Check children if a parent is checked
|
|
116
|
+
if (item.canHaveSubItems) {
|
|
117
|
+
const childIdsToUncheck = items
|
|
118
|
+
.filter((i) => i.parentId === item.id)
|
|
119
|
+
.map((i) => i.id);
|
|
120
|
+
while (childIdsToUncheck.length > 0) {
|
|
121
|
+
const childId = childIdsToUncheck.pop();
|
|
122
|
+
const child = items.find((i) => i.id === childId);
|
|
123
|
+
if (child) {
|
|
124
|
+
newItems.forEach((newItem) => {
|
|
125
|
+
if (newItem.id === child.id) {
|
|
126
|
+
newItem.isSelected = event.target.checked;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
newItems
|
|
130
|
+
.filter((i) => i.parentId === child.id)
|
|
131
|
+
.forEach((i) => {
|
|
132
|
+
childIdsToUncheck.push(i.id);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
onItemsChanged(newItems, { item, reason: 'selected' });
|
|
138
|
+
}, "aria-label": item.data.text })), _jsx(ConditionalWrap, { condition: item.data.onTextClick !== undefined, wrapper: (children) => (_jsx("button", { onClick: item.data.onTextClick, className: "ndl-tree-view-text-clickable", tabIndex: tabIndex, children: children })), children: _jsx(Typography, { style: {
|
|
139
|
+
overflow: 'hidden',
|
|
140
|
+
textOverflow: 'ellipsis',
|
|
141
|
+
whiteSpace: 'nowrap',
|
|
142
|
+
}, variant: item.canHaveSubItems ? 'subheading-small' : 'body-medium', children: item.data.text }) }), _jsx("div", { className: "ndl-tree-view-actions", children: item.data.actions &&
|
|
143
|
+
item.data.actions.map((action, index) => {
|
|
144
|
+
return (_createElement(IconButton, Object.assign({}, action.buttonProps, { key: index, className: "ndl-tree-view-action", clean: true, size: "small", tabIndex: tabIndex }), action.icon));
|
|
145
|
+
}) })] })));
|
|
146
|
+
});
|
|
147
|
+
//# sourceMappingURL=TreeViewTextItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewTextItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTextItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOpD;;;;;GAKG;AACH,MAAM,0BAA0B,GAAG,CACjC,IAAqC,EACrC,KAAwC,EAC/B,EAAE;IACX,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,IAAI,MAAM,EAAE;QACV,IAAI,MAAM,CAAC,UAAU,EAAE;YACrB,OAAO,IAAI,CAAC;SACb;QACD,OAAO,0BAA0B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KAClD;IAC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,UAAU,IACT,KAAK,EAAE;wBACL,QAAQ,EAAE,QAAQ;wBAClB,YAAY,EAAE,UAAU;wBACxB,UAAU,EAAE,QAAQ;qBACrB,EACD,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,aAAa,YAEjE,IAAI,CAAC,IAAI,CAAC,IAAI,GACJ,GACG,EAClB,cAAK,SAAS,EAAC,uBAAuB,YACnC,IAAI,CAAC,IAAI,CAAC,OAAO;oBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;wBACtC,OAAO,CACL,eAAC,UAAU,oBACL,MAAM,CAAC,WAAW,IACtB,GAAG,EAAE,KAAK,EACV,SAAS,EAAC,sBAAsB,EAChC,KAAK,QACL,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,QAAQ,KAEjB,MAAM,CAAC,IAAI,CACD,CACd,CAAC;oBACJ,CAAC,CAAC,GACA,KACU,CACnB,CAAC;AACJ,CAAC,CAKsB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
+
export const Trail = ({ variant }) => {
|
|
24
|
+
return (_jsxs("div", { className: "ndl-trail", children: [variant === 'straight' && (_jsx("svg", { className: "ndl-trail-straight", width: "2", height: "24", viewBox: "0 0 2 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M1.00001 16.0005L1 -4.00049L1 28.0004", stroke: "#BBBEC3" }) })), variant === 'curved' && (_jsx("svg", { className: "ndl-trail-curved", width: "9", height: "13", viewBox: "0 0 9 13", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M1 -4L1 3.99988C1 8.41816 4.58172 11.9999 9 11.9999V11.9999", stroke: "#BBBEC3" }) })), variant === 'straight-curved' && (_jsxs("svg", { className: "ndl-trail-straight-curved", width: "16", height: "24", viewBox: "0 0 16 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("g", { clipPath: "url(#clip0_16990_133)", children: _jsx("path", { d: "M16 12V12C11.5817 12 8.00001 8.41828 8.00001 4L8.00001 -4L8 28", stroke: "#BBBEC3" }) }), _jsx("defs", { children: _jsx("clipPath", { id: "clip0_16990_133", children: _jsx("rect", { width: "16", height: "24", fill: "white" }) }) })] }))] }));
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=TreeViewTrail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewTrail.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewTrail.tsx"],"names":[],"mappings":";AAwBA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,OAAO,EAAc,EAAE,EAAE;IAC/C,OAAO,CACL,eAAK,SAAS,EAAC,WAAW,aACvB,OAAO,KAAK,UAAU,IAAI,CACzB,cACE,SAAS,EAAC,oBAAoB,EAC9B,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,eAAM,CAAC,EAAC,uCAAuC,EAAC,MAAM,EAAC,SAAS,GAAG,GAC/D,CACP,EACA,OAAO,KAAK,QAAQ,IAAI,CACvB,cACE,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,UAAU,EAClB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,YAElC,eACE,CAAC,EAAC,6DAA6D,EAC/D,MAAM,EAAC,SAAS,GAChB,GACE,CACP,EACA,OAAO,KAAK,iBAAiB,IAAI,CAChC,eACE,SAAS,EAAC,2BAA2B,EACrC,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,aAElC,YAAG,QAAQ,EAAC,uBAAuB,YACjC,eACE,CAAC,EAAC,gEAAgE,EAClE,MAAM,EAAC,SAAS,GAChB,GACA,EACJ,yBACE,mBAAU,EAAE,EAAC,iBAAiB,YAC5B,eAAM,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,GAAG,GACnC,GACN,IACH,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
export { TreeView } from './TreeView';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tree-view/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { KeyboardCode, closestCorners, getFirstCollision, } from '@dnd-kit/core';
|
|
22
|
+
import { getProjection } from './tree-view-utils';
|
|
23
|
+
const directions = [
|
|
24
|
+
KeyboardCode.Down,
|
|
25
|
+
KeyboardCode.Right,
|
|
26
|
+
KeyboardCode.Up,
|
|
27
|
+
KeyboardCode.Left,
|
|
28
|
+
];
|
|
29
|
+
const horizontal = [KeyboardCode.Left, KeyboardCode.Right];
|
|
30
|
+
export const sortableTreeKeyboardCoordinates = (context, indicator, indentationWidth) => (event, { currentCoordinates, context: { active, over, collisionRect, droppableRects, droppableContainers, }, }) => {
|
|
31
|
+
if (directions.includes(event.code)) {
|
|
32
|
+
if (!active || !collisionRect) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
const { current: { items, offset }, } = context;
|
|
37
|
+
if (horizontal.includes(event.code) && (over === null || over === void 0 ? void 0 : over.id)) {
|
|
38
|
+
const { depth, maxDepth, minDepth } = getProjection(items, active.id, over.id, offset, indentationWidth);
|
|
39
|
+
switch (event.code) {
|
|
40
|
+
case KeyboardCode.Left:
|
|
41
|
+
if (depth > minDepth) {
|
|
42
|
+
return Object.assign(Object.assign({}, currentCoordinates), { x: currentCoordinates.x - indentationWidth });
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case KeyboardCode.Right:
|
|
46
|
+
if (depth < maxDepth) {
|
|
47
|
+
return Object.assign(Object.assign({}, currentCoordinates), { x: currentCoordinates.x + indentationWidth });
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const containers = [];
|
|
54
|
+
droppableContainers.forEach((container) => {
|
|
55
|
+
if ((container === null || container === void 0 ? void 0 : container.disabled) ||
|
|
56
|
+
container.id === (over === null || over === void 0 ? void 0 : over.id) ||
|
|
57
|
+
(container === null || container === void 0 ? void 0 : container.id) === 'ndl-active-tree-item') {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const rect = droppableRects.get(container.id);
|
|
61
|
+
if (!rect) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
switch (event.code) {
|
|
65
|
+
case KeyboardCode.Down:
|
|
66
|
+
if (collisionRect.top < rect.top) {
|
|
67
|
+
containers.push(container);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case KeyboardCode.Up:
|
|
71
|
+
if (collisionRect.top > rect.top) {
|
|
72
|
+
containers.push(container);
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const collisions = closestCorners({
|
|
78
|
+
active,
|
|
79
|
+
collisionRect,
|
|
80
|
+
pointerCoordinates: null,
|
|
81
|
+
droppableRects,
|
|
82
|
+
droppableContainers: containers,
|
|
83
|
+
});
|
|
84
|
+
let closestId = getFirstCollision(collisions, 'id');
|
|
85
|
+
if (closestId === (over === null || over === void 0 ? void 0 : over.id) && collisions.length > 1) {
|
|
86
|
+
closestId = collisions[1].id;
|
|
87
|
+
}
|
|
88
|
+
if (closestId && (over === null || over === void 0 ? void 0 : over.id)) {
|
|
89
|
+
const activeRect = droppableRects.get(active.id);
|
|
90
|
+
const newRect = droppableRects.get(closestId);
|
|
91
|
+
const newDroppable = droppableContainers.get(closestId);
|
|
92
|
+
if (activeRect && newRect && newDroppable) {
|
|
93
|
+
const newIndex = items.findIndex(({ id }) => id === closestId);
|
|
94
|
+
const newItem = items[newIndex];
|
|
95
|
+
const activeIndex = items.findIndex(({ id }) => id === active.id);
|
|
96
|
+
const activeItem = items[activeIndex];
|
|
97
|
+
if (newItem && activeItem) {
|
|
98
|
+
const { depth } = getProjection(items, active.id, closestId, (newItem.depth - activeItem.depth) * indentationWidth, indentationWidth);
|
|
99
|
+
const isBelow = newIndex > activeIndex;
|
|
100
|
+
const modifier = isBelow ? 1 : -1;
|
|
101
|
+
const offset = indicator
|
|
102
|
+
? (collisionRect.height - activeRect.height) / 2
|
|
103
|
+
: 0;
|
|
104
|
+
const newCoordinates = {
|
|
105
|
+
x: newRect.left + depth * indentationWidth,
|
|
106
|
+
y: newRect.top + modifier * offset,
|
|
107
|
+
};
|
|
108
|
+
return newCoordinates;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=tree-view-keyboard-coordinates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-keyboard-coordinates.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-keyboard-coordinates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,YAAY,EAEZ,cAAc,EACd,iBAAiB,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAsB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,UAAU,GAAa;IAC3B,YAAY,CAAC,IAAI;IACjB,YAAY,CAAC,KAAK;IAClB,YAAY,CAAC,EAAE;IACf,YAAY,CAAC,IAAI;CAClB,CAAC;AAEF,MAAM,UAAU,GAAa,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;AAErE,MAAM,CAAC,MAAM,+BAA+B,GAK1C,CAAC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE,CACzC,CACE,KAAK,EACL,EACE,kBAAkB,EAClB,OAAO,EAAE,EACP,MAAM,EACN,IAAI,EACJ,aAAa,EACb,cAAc,EACd,mBAAmB,GACpB,GACF,EACD,EAAE;IACF,IAAI,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACnC,IAAI,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE;YAC7B,OAAO;SACR;QACD,KAAK,CAAC,cAAc,EAAE,CAAC;QAEvB,MAAM,EACJ,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,GAC3B,GAAG,OAAO,CAAC;QACZ,IAAI,UAAU,CAAC,QAAQ,CAAC,K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AAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAC;gBAClE,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;gBAEtC,IAAI,OAAO,IAAI,UAAU,EAAE;oBACzB,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa,CAC7B,KAAK,EACL,MAAM,CAAC,EAAE,EACT,SAAS,EACT,CAAC,OAAO,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,gBAAgB,EACrD,gBAAgB,CACjB,CAAC;oBACF,MAAM,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;oBACvC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAClC,MAAM,MAAM,GAAG,SAAS;wBACtB,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC;wBAChD,CAAC,CAAC,CAAC,CAAC;oBAEN,MAAM,cAAc,GAAG;wBACrB,CAAC,EAAE,OAAO,CAAC,IAAI,GAAG,KAAK,GAAG,gBAAgB;wBAC1C,CAAC,EAAE,OAAO,CAAC,GAAG,GAAG,QAAQ,GAAG,MAAM;qBACnC,CAAC;oBAEF,OAAO,cAAc,CAAC;iBACvB;aACF;SACF;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
import { findFocusableChildren } from '../_common/utils';
|
|
22
|
+
const focusElementInElement = (parentElement, newParentElement, activeElement) => {
|
|
23
|
+
const focusable = findFocusableChildren(newParentElement);
|
|
24
|
+
const focusableCurrent = findFocusableChildren(parentElement);
|
|
25
|
+
const cellIndex = focusableCurrent.indexOf(activeElement);
|
|
26
|
+
let newIndex = cellIndex;
|
|
27
|
+
if (cellIndex >= focusable.length) {
|
|
28
|
+
newIndex = focusable.length - 1;
|
|
29
|
+
}
|
|
30
|
+
else if (cellIndex < 0) {
|
|
31
|
+
newIndex = 0;
|
|
32
|
+
}
|
|
33
|
+
const element = focusable[newIndex];
|
|
34
|
+
if (element instanceof HTMLElement) {
|
|
35
|
+
element.focus();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const focusNextRow = (parentElement) => {
|
|
39
|
+
const { nextElementSibling } = parentElement;
|
|
40
|
+
if (nextElementSibling instanceof HTMLElement) {
|
|
41
|
+
nextElementSibling.focus();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export const focusPreviousRow = (parentElement) => {
|
|
45
|
+
const { previousElementSibling } = parentElement;
|
|
46
|
+
if (previousElementSibling instanceof HTMLElement) {
|
|
47
|
+
previousElementSibling.focus();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const focusCellInNextRow = (parentElement) => {
|
|
51
|
+
const { nextElementSibling } = parentElement;
|
|
52
|
+
const { activeElement } = document;
|
|
53
|
+
if (!(nextElementSibling instanceof HTMLElement) ||
|
|
54
|
+
!(activeElement instanceof HTMLElement)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
focusElementInElement(parentElement, nextElementSibling, activeElement);
|
|
58
|
+
};
|
|
59
|
+
export const focusCellInPreviousRow = (parentElement) => {
|
|
60
|
+
const { previousElementSibling } = parentElement;
|
|
61
|
+
const { activeElement } = document;
|
|
62
|
+
if (!(previousElementSibling instanceof HTMLElement) ||
|
|
63
|
+
!(activeElement instanceof HTMLElement)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
focusElementInElement(parentElement, previousElementSibling, activeElement);
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=tree-view-keyboard-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-keyboard-helpers.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-keyboard-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,MAAM,qBAAqB,GAAG,CAC5B,aAA0B,EAC1B,gBAA6B,EAC7B,aAA0B,EAC1B,EAAE;IACF,MAAM,SAAS,GAAG,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE1D,IAAI,QAAQ,GAAG,SAAS,CAAC;IAEzB,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,EAAE;QACjC,QAAQ,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;KACjC;SAAM,IAAI,SAAS,GAAG,CAAC,EAAE;QACxB,QAAQ,GAAG,CAAC,CAAC;KACd;IACD,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACpC,IAAI,OAAO,Y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|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=tree-view-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-types.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) "Neo4j"
|
|
4
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
5
|
+
*
|
|
6
|
+
* This file is part of Neo4j.
|
|
7
|
+
*
|
|
8
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
9
|
+
* it under the terms of the GNU General Public License as published by
|
|
10
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
* (at your option) any later version.
|
|
12
|
+
*
|
|
13
|
+
* This program is distributed in the hope that it will be useful,
|
|
14
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
* GNU General Public License for more details.
|
|
17
|
+
*
|
|
18
|
+
* You should have received a copy of the GNU General Public License
|
|
19
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { arrayMove } from '@dnd-kit/sortable';
|
|
23
|
+
/**
|
|
24
|
+
* Takes a tree and flattens it into a list of item
|
|
25
|
+
* where each item has a depth and a parentId.
|
|
26
|
+
* @param tree the tree to flatten
|
|
27
|
+
* @param depth the depth of the root of the tree (default 0)
|
|
28
|
+
* @param parentId the id of the parent of the root of the tree (default null)
|
|
29
|
+
* @returns a list of items with depth and parentId
|
|
30
|
+
*/
|
|
31
|
+
export const flattenTree = (tree, depth = 0, parentId = null) => {
|
|
32
|
+
const flattened = [];
|
|
33
|
+
tree.forEach((item) => {
|
|
34
|
+
flattened.push(Object.assign(Object.assign({}, item), { depth: depth, parentId: parentId }));
|
|
35
|
+
if (item.canHaveSubItems) {
|
|
36
|
+
flattenTree(item.subItems, depth + 1, item.id).forEach((subItem) => flattened.push(Object.assign({}, subItem)));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return flattened;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Removes the children of the items with the given ids
|
|
43
|
+
* @param items the flattened tree items to remove the children from
|
|
44
|
+
* @param ids the ids of the items to remove the children from
|
|
45
|
+
* @returns a new list of items with the children of the items with the given ids removed
|
|
46
|
+
*/
|
|
47
|
+
export function removeChildrenOf(items, ids) {
|
|
48
|
+
const excludeParentIds = [...ids];
|
|
49
|
+
return items.filter((item) => {
|
|
50
|
+
if (item.parentId !== null && excludeParentIds.includes(item.parentId)) {
|
|
51
|
+
if (item.canHaveSubItems && item.subItems.length > 0) {
|
|
52
|
+
excludeParentIds.push(item.id);
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Builds a tree from a list of flattened tree items
|
|
61
|
+
* @param items the flattened tree items
|
|
62
|
+
* @returns the items as a tree data structure
|
|
63
|
+
*/
|
|
64
|
+
export function buildTree(items) {
|
|
65
|
+
const tree = [];
|
|
66
|
+
const itemMap = {};
|
|
67
|
+
items.forEach((item) => {
|
|
68
|
+
const { id } = item;
|
|
69
|
+
if (item.canHaveSubItems) {
|
|
70
|
+
itemMap[id] = {
|
|
71
|
+
id: id,
|
|
72
|
+
canHaveSubItems: true,
|
|
73
|
+
isCollapsed: item.isCollapsed,
|
|
74
|
+
subItems: [],
|
|
75
|
+
data: item.data,
|
|
76
|
+
isSelected: item.isSelected,
|
|
77
|
+
isSortable: item.isSortable,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
itemMap[id] = {
|
|
82
|
+
id: id,
|
|
83
|
+
canHaveSubItems: false,
|
|
84
|
+
data: item.data,
|
|
85
|
+
isSortable: item.isSortable,
|
|
86
|
+
isSelected: item.isSelected,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
// Build the tree structure by assigning children to their parent items
|
|
91
|
+
items.forEach((item) => {
|
|
92
|
+
const { id, parentId } = item;
|
|
93
|
+
if (parentId !== null) {
|
|
94
|
+
const parentItem = itemMap[parentId];
|
|
95
|
+
if (parentItem && parentItem.canHaveSubItems) {
|
|
96
|
+
parentItem.subItems.push(itemMap[id]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
tree.push(itemMap[id]);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return tree;
|
|
104
|
+
}
|
|
105
|
+
function getDragDepth(offset, indentationWidth) {
|
|
106
|
+
return Math.round(offset / indentationWidth);
|
|
107
|
+
}
|
|
108
|
+
function getMaxDepth({ previousItem, }) {
|
|
109
|
+
var _a;
|
|
110
|
+
if (previousItem && previousItem.canHaveSubItems === true) {
|
|
111
|
+
return previousItem.depth + 1;
|
|
112
|
+
}
|
|
113
|
+
return (_a = previousItem === null || previousItem === void 0 ? void 0 : previousItem.depth) !== null && _a !== void 0 ? _a : 0;
|
|
114
|
+
}
|
|
115
|
+
function getMinDepth({ nextItem }) {
|
|
116
|
+
if (nextItem) {
|
|
117
|
+
return nextItem.depth;
|
|
118
|
+
}
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Calculates the new depth, max depth, min depth and parent id of the item being dragged
|
|
123
|
+
* Used to project the position of the dragged item. For example, to convert the item being dragged into a placeholder.
|
|
124
|
+
* such as the line that appears when dragging an item in a tree view.
|
|
125
|
+
* @param items the flattened tree items
|
|
126
|
+
* @param activeId the id of the item being dragged
|
|
127
|
+
* @param overId the id of the item that the dragged item is being dragged over
|
|
128
|
+
* @param dragOffset the offset of the drag in pixels
|
|
129
|
+
* @param indentationWidth the width of the indentation in pixels
|
|
130
|
+
* @returns the depth, max depth, min depth and parent id of the item being dragged
|
|
131
|
+
*/
|
|
132
|
+
export function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
|
|
133
|
+
const overItemIndex = items.findIndex(({ id }) => id === overId);
|
|
134
|
+
const activeItemIndex = items.findIndex(({ id }) => id === activeId);
|
|
135
|
+
const activeItem = items[activeItemIndex];
|
|
136
|
+
const newItems = arrayMove(items, activeItemIndex, overItemIndex);
|
|
137
|
+
const previousItem = newItems[overItemIndex - 1];
|
|
138
|
+
const nextItem = newItems[overItemIndex + 1];
|
|
139
|
+
const dragDepth = getDragDepth(dragOffset, indentationWidth);
|
|
140
|
+
const projectedDepth = activeItem.depth + dragDepth;
|
|
141
|
+
const maxDepth = getMaxDepth({
|
|
142
|
+
previousItem,
|
|
143
|
+
});
|
|
144
|
+
const minDepth = getMinDepth({ nextItem });
|
|
145
|
+
let depth = projectedDepth;
|
|
146
|
+
if (projectedDepth >= maxDepth) {
|
|
147
|
+
depth = maxDepth;
|
|
148
|
+
}
|
|
149
|
+
else if (projectedDepth < minDepth) {
|
|
150
|
+
depth = minDepth;
|
|
151
|
+
}
|
|
152
|
+
return { depth, maxDepth, minDepth, parentId: getParentId() };
|
|
153
|
+
function getParentId() {
|
|
154
|
+
var _a;
|
|
155
|
+
if (depth === 0 || !previousItem) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (depth === previousItem.depth) {
|
|
159
|
+
return previousItem.parentId;
|
|
160
|
+
}
|
|
161
|
+
if (depth > previousItem.depth) {
|
|
162
|
+
return previousItem.id;
|
|
163
|
+
}
|
|
164
|
+
const newParent = (_a = newItems
|
|
165
|
+
.slice(0, overItemIndex)
|
|
166
|
+
.reverse()
|
|
167
|
+
.find((item) => item.depth === depth)) === null || _a === void 0 ? void 0 : _a.parentId;
|
|
168
|
+
return newParent !== null && newParent !== void 0 ? newParent : null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
*
|
|
173
|
+
* @param transform a transform object
|
|
174
|
+
* @returns a css transform string
|
|
175
|
+
*/
|
|
176
|
+
export const transformToString = (transform) => {
|
|
177
|
+
return `scaleX(${transform.scaleX}) scaleY(${transform.scaleY}) translate3d(${transform.x}px, ${transform.y}px, 0)`;
|
|
178
|
+
};
|
|
179
|
+
//# sourceMappingURL=tree-view-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-view-utils.js","sourceRoot":"","sources":["../../../src/tree-view/tree-view-utils.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAU9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAmB,EACnB,KAAK,GAAG,CAAC,EACT,WAAoC,IAAI,EAChB,EAAE;IAC1B,MAAM,SAAS,GAA2B,EAAE,CAAC;IAE7C,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpB,SAAS,CAAC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AC9B,KAAK,GAAG,QAAQ,CAAC;KAClB;SAAM,IAAI,cAAc,GAAG,QAAQ,EAAE;QACpC,KAAK,GAAG,QAAQ,CAAC;KAClB;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,CAAC;IAE9D,SAAS,WAAW;;QAClB,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE;YAChC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,KAAK,KAAK,YAAY,CAAC,KAAK,EAAE;YAChC,OAAO,YAAY,CAAC,QAAQ,CAAC;SAC9B;QAED,IAAI,KAAK,GAAG,YAAY,CAAC,KAAK,EAAE;YAC9B,OAAO,YAAY,CAAC,EAAE,CAAC;SACxB;QAED,MAAM,SAAS,GAAG,MAAA,QAAQ;aACvB,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC;aACvB,OAAO,EAAE;aACT,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,0CAAE,QAAQ,CAAC;QAElD,OAAO,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC;IAC3B,CAAC;AACH,CAAC;AACD;;;;GAIG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,SAKjC,EAAE,EAAE;IACH,OAAO,UAAU,SAAS,CAAC,MAAM,YAAY,SAAS,CAAC,MAAM,iBAAiB,SAAS,CAAC,CAAC,OAAO,SAAS,CAAC,CAAC,QAAQ,CAAC;AACtH,CAAC,CAAC"}
|
|
@@ -50,3 +50,15 @@ export declare function isRefObject<T>(obj: React.RefObject<T> | T): obj is Reac
|
|
|
50
50
|
* or vice versa.
|
|
51
51
|
*/
|
|
52
52
|
export declare function findUntil(direction: 'next' | 'prev', el: Element | ChildNode, matchSelector: string): Element | null;
|
|
53
|
+
/**
|
|
54
|
+
* Find all html elements that are focusable given a parent element
|
|
55
|
+
* @param parentElement the parent element
|
|
56
|
+
* @returns an array of HTML elements
|
|
57
|
+
*/
|
|
58
|
+
export declare const findFocusableChildren: (parentElement: HTMLElement) => Element[];
|
|
59
|
+
/**
|
|
60
|
+
* Using the element that currently has focus, finds the previous sibling of the currently focused element that is focusable
|
|
61
|
+
* @param parentRef the parent element
|
|
62
|
+
* @returns the previous focusable element
|
|
63
|
+
*/
|
|
64
|
+
export declare const findFocusableSibling: (parentRef: React.RefObject<HTMLElement>, direction: 'prev' | 'next') => HTMLElement | undefined;
|