@neo4j-ndl/react 2.9.3 → 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 +12 -0
- package/lib/LICENSES.txt +27 -1
- package/lib/NOTICE.txt +10 -2
- package/lib/cjs/_common/utils.js +41 -1
- package/lib/cjs/_common/utils.js.map +1 -1
- package/lib/cjs/data-grid/Components.js +3 -1
- package/lib/cjs/data-grid/Components.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/data-grid/Components.js +3 -1
- package/lib/esm/data-grid/Components.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/data-grid/datagrid-types.d.ts +5 -2
- 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
package/lib/esm/index.js
CHANGED
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc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,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,172 @@
|
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) "Neo4j"
|
|
16
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
+
*
|
|
18
|
+
* This file is part of Neo4j.
|
|
19
|
+
*
|
|
20
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
+
* it under the terms of the GNU General Public License as published by
|
|
22
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
+
* (at your option) any later version.
|
|
24
|
+
*
|
|
25
|
+
* This program is distributed in the hope that it will be useful,
|
|
26
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
+
* GNU General Public License for more details.
|
|
29
|
+
*
|
|
30
|
+
* You should have received a copy of the GNU General Public License
|
|
31
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
+
*/
|
|
33
|
+
import classNames from 'classnames';
|
|
34
|
+
import React, { useRef } from 'react';
|
|
35
|
+
import { findFocusableChildren, findFocusableSibling } from '../_common/utils';
|
|
36
|
+
import { DragIcon } from '../icons';
|
|
37
|
+
import { Trail } from './TreeViewTrail';
|
|
38
|
+
import { focusCellInNextRow, focusCellInPreviousRow, focusNextRow, focusPreviousRow, } from './tree-view-keyboard-helpers';
|
|
39
|
+
/**
|
|
40
|
+
* Handles keydown events for when the item itself is focused (wrapperRef.current)
|
|
41
|
+
* Moves the focus between the item and its children as well as toggles collapsing of the item
|
|
42
|
+
* @param event
|
|
43
|
+
* @param shouldDisableInteraction
|
|
44
|
+
* @param wrapperRef
|
|
45
|
+
* @param onCollapse
|
|
46
|
+
* @param item
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
const onWrapperKeyDown = (event, shouldDisableInteraction, wrapperRef, onCollapse, item) => {
|
|
50
|
+
if (shouldDisableInteraction || wrapperRef.current === null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (event.key === 'Enter' && onCollapse) {
|
|
54
|
+
onCollapse();
|
|
55
|
+
}
|
|
56
|
+
else if (event.key === 'ArrowRight') {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
if (item.canHaveSubItems && item.isCollapsed && onCollapse) {
|
|
59
|
+
onCollapse();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const focusable = findFocusableChildren(wrapperRef.current);
|
|
63
|
+
const [firstElement] = focusable;
|
|
64
|
+
if (firstElement instanceof HTMLElement) {
|
|
65
|
+
firstElement.focus();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
}
|
|
70
|
+
else if (event.key === 'ArrowLeft') {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
if (item.canHaveSubItems && !item.isCollapsed && onCollapse) {
|
|
73
|
+
onCollapse();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
focusPreviousRow(wrapperRef.current);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (event.key === 'ArrowDown') {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
focusNextRow(wrapperRef.current);
|
|
82
|
+
}
|
|
83
|
+
else if (event.key === 'ArrowUp') {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
focusPreviousRow(wrapperRef.current);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Handles keydown events for when one of the items children is focused
|
|
90
|
+
* Moves the focus between the children of the item and up to the parent if needed.
|
|
91
|
+
* Stops the event from propagating to the parent since it has it own keydown handler
|
|
92
|
+
* The parent is the wrapperRef.current and uses onWrapperKeyDown
|
|
93
|
+
* @param event
|
|
94
|
+
* @param shouldDisableInteraction
|
|
95
|
+
* @param wrapperRef
|
|
96
|
+
*/
|
|
97
|
+
const onInnerDivKeyDown = (event, shouldDisableInteraction, wrapperRef) => {
|
|
98
|
+
var _a;
|
|
99
|
+
if (shouldDisableInteraction) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
if (event.key === 'ArrowRight') {
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
const nextElement = findFocusableSibling(wrapperRef, 'next');
|
|
106
|
+
if (nextElement) {
|
|
107
|
+
nextElement.focus();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (event.key === 'ArrowLeft') {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
const previousElement = findFocusableSibling(wrapperRef, 'prev');
|
|
113
|
+
if (previousElement) {
|
|
114
|
+
previousElement.focus();
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
(_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else if (event.key === 'ArrowDown' && wrapperRef.current !== null) {
|
|
121
|
+
event.preventDefault();
|
|
122
|
+
focusCellInNextRow(wrapperRef.current);
|
|
123
|
+
}
|
|
124
|
+
else if (event.key === 'ArrowUp' && wrapperRef.current !== null) {
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
focusCellInPreviousRow(wrapperRef.current);
|
|
127
|
+
}
|
|
128
|
+
else if (event.shiftKey && event.key === 'Tab') {
|
|
129
|
+
const previousElement = findFocusableSibling(wrapperRef, 'prev');
|
|
130
|
+
if (previousElement) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
previousElement.focus();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if (event.key === 'Tab') {
|
|
136
|
+
if (event.shiftKey) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const nextElement = findFocusableSibling(wrapperRef, 'next');
|
|
140
|
+
if (nextElement) {
|
|
141
|
+
nextElement.focus();
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Used as a helper function to wrap the TreeItem component
|
|
148
|
+
* This adds the drag handle and trail to the start of a tree item.
|
|
149
|
+
* Useful if you want to add additional functionality to the tree item but still keep the drag handle and trail
|
|
150
|
+
* Is also used internally to create the TreeViewTextItem component
|
|
151
|
+
*/
|
|
152
|
+
export const TreeItemWrapper = React.forwardRef(function TreeItemWrapper(_a, ref) {
|
|
153
|
+
var { depth, shouldDisableInteraction, shouldDisableSorting, isGhost, isIndicator, onCollapse, item, setNodeRef, setActivatorNodeRef, dragHandleProps, style, trails, children, indentationWidth, tabIndex, onFocus } = _a,
|
|
154
|
+
// Need to destruct to avoid passing it to the component
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
+
restProps = __rest(_a, ["depth", "shouldDisableInteraction", "shouldDisableSorting", "isGhost", "isIndicator", "onCollapse", "item", "setNodeRef", "setActivatorNodeRef", "dragHandleProps", "style", "trails", "children", "indentationWidth", "tabIndex", "onFocus"]);
|
|
157
|
+
const wrapperRef = useRef(null);
|
|
158
|
+
return (_jsx("li", { ref: (el) => {
|
|
159
|
+
wrapperRef.current = el;
|
|
160
|
+
if (el === null)
|
|
161
|
+
return;
|
|
162
|
+
setNodeRef(el);
|
|
163
|
+
}, className: classNames({
|
|
164
|
+
'ndl-tree-view-list-item': true,
|
|
165
|
+
indicator: isIndicator,
|
|
166
|
+
'ndl-tree-view-list-item-placeholder': isGhost,
|
|
167
|
+
'ndl-tree-view-list-item-disable-interaction': shouldDisableInteraction,
|
|
168
|
+
}), style: Object.assign(Object.assign({}, style), { paddingLeft: isIndicator ? `${depth * indentationWidth}px` : 0 }), role: "treeitem", onFocus: onFocus, "aria-selected": item.isSelected, "aria-expanded": item.canHaveSubItems ? !item.isCollapsed : undefined, onKeyDown: (event) => onWrapperKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef, onCollapse, item), children: _jsxs("div", { role: "presentation", className: "ndl-tree-view-list-item-content", ref: ref, onKeyDown: (event) => onInnerDivKeyDown(event, shouldDisableInteraction !== null && shouldDisableInteraction !== void 0 ? shouldDisableInteraction : false, wrapperRef), children: [!shouldDisableSorting && (_jsx("button", Object.assign({ className: "ndl-tree-view-drag-handle", ref: setActivatorNodeRef, "aria-label": "pick up" }, dragHandleProps, { tabIndex: tabIndex, children: _jsx(DragIcon, {}) }))), trails.map((trail, index) => {
|
|
169
|
+
return _jsx(Trail, { variant: trail }, index);
|
|
170
|
+
}), children] }) }));
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=TreeItemWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeItemWrapper.js","sourceRoot":"","sources":["../../../src/tree-view/TreeItemWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA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
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) "Neo4j"
|
|
16
|
+
* Neo4j Sweden AB [http://neo4j.com]
|
|
17
|
+
*
|
|
18
|
+
* This file is part of Neo4j.
|
|
19
|
+
*
|
|
20
|
+
* Neo4j is free software: you can redistribute it and/or modify
|
|
21
|
+
* it under the terms of the GNU General Public License as published by
|
|
22
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
23
|
+
* (at your option) any later version.
|
|
24
|
+
*
|
|
25
|
+
* This program is distributed in the hope that it will be useful,
|
|
26
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
27
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
28
|
+
* GNU General Public License for more details.
|
|
29
|
+
*
|
|
30
|
+
* You should have received a copy of the GNU General Public License
|
|
31
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
32
|
+
*/
|
|
33
|
+
import { DndContext, DragOverlay, KeyboardSensor, MeasuringStrategy, PointerSensor, closestCenter, defaultDropAnimation, useSensor, useSensors, } from '@dnd-kit/core';
|
|
34
|
+
import { SortableContext, arrayMove, verticalListSortingStrategy, } from '@dnd-kit/sortable';
|
|
35
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
36
|
+
import { createPortal } from 'react-dom';
|
|
37
|
+
import { TreeItemWrapper } from './TreeItemWrapper';
|
|
38
|
+
import { SortableTreeViewItem } from './TreeViewItem';
|
|
39
|
+
import { TreeViewTextItem } from './TreeViewTextItem';
|
|
40
|
+
import { sortableTreeKeyboardCoordinates } from './tree-view-keyboard-coordinates';
|
|
41
|
+
import { buildTree, flattenTree, getProjection, removeChildrenOf, transformToString, } from './tree-view-utils';
|
|
42
|
+
const indentationWidth = 20;
|
|
43
|
+
const ACTIVE_PLACEHOLDER_ID = 'ndl-active-tree-item';
|
|
44
|
+
const dropAnimationConfig = {
|
|
45
|
+
keyframes({ transform }) {
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
opacity: 1,
|
|
49
|
+
transform: transformToString(transform.initial),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
opacity: 0,
|
|
53
|
+
transform: transformToString(Object.assign(Object.assign({}, transform.final), { y: transform.final.y + 5, x: transform.final.x + 5 })),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
},
|
|
57
|
+
easing: 'ease-out',
|
|
58
|
+
sideEffects({ active }) {
|
|
59
|
+
active.node.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
60
|
+
duration: defaultDropAnimation.duration,
|
|
61
|
+
easing: defaultDropAnimation.easing,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
export const TreeView = (_a) => {
|
|
66
|
+
var _b;
|
|
67
|
+
var { items, TreeItemComponent, onItemsChanged } = _a, rest = __rest(_a, ["items", "TreeItemComponent", "onItemsChanged"]);
|
|
68
|
+
const flattenItems = useMemo(() => flattenTree(items), [items]);
|
|
69
|
+
const [activeId, setActiveId] = useState(null);
|
|
70
|
+
const [overId, setOverId] = useState(null);
|
|
71
|
+
const [focusedRowId, setFocusedRowId] = useState(null);
|
|
72
|
+
const [currentPosition, setCurrentPosition] = useState(null);
|
|
73
|
+
const [offsetLeft, setOffsetLeft] = useState(0);
|
|
74
|
+
/* ------------------------------ Setup of Data ------------------------------ */
|
|
75
|
+
const flattenedAndRemovedCollapsedItems = useMemo(() => {
|
|
76
|
+
const collapsedItemsIds = flattenItems
|
|
77
|
+
.filter((item) => item.canHaveSubItems && item.isCollapsed)
|
|
78
|
+
.map((item) => item.id);
|
|
79
|
+
return removeChildrenOf([...flattenItems], activeId !== null ? [activeId, ...collapsedItemsIds] : collapsedItemsIds);
|
|
80
|
+
}, [activeId, flattenItems]);
|
|
81
|
+
const activeItem = useMemo(() => (activeId ? flattenItems.find(({ id }) => id === activeId) : null), [activeId, flattenItems]);
|
|
82
|
+
const flattenedAndRemovedCollapsedItemsWithActive = useMemo(() => {
|
|
83
|
+
const collapsedItems = flattenItems.reduce((acc, item) => {
|
|
84
|
+
if (item.canHaveSubItems && item.isCollapsed) {
|
|
85
|
+
return [...acc, item.id];
|
|
86
|
+
}
|
|
87
|
+
return acc;
|
|
88
|
+
}, []);
|
|
89
|
+
const ItemsWithCollapsedRemoved = removeChildrenOf(flattenItems, activeId ? [activeId, ...collapsedItems] : collapsedItems);
|
|
90
|
+
const newArray = [];
|
|
91
|
+
for (const item of ItemsWithCollapsedRemoved) {
|
|
92
|
+
newArray.push(item);
|
|
93
|
+
if (item.id === activeId) {
|
|
94
|
+
newArray.push(Object.assign(Object.assign({}, item), { id: ACTIVE_PLACEHOLDER_ID }));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return newArray;
|
|
98
|
+
}, [flattenItems, activeId]);
|
|
99
|
+
activeItem && activeItem.canHaveSubItems && !activeItem.isCollapsed
|
|
100
|
+
? flattenedAndRemovedCollapsedItems.concat(Object.assign(Object.assign({}, activeItem), { id: ACTIVE_PLACEHOLDER_ID }))
|
|
101
|
+
: flattenedAndRemovedCollapsedItems;
|
|
102
|
+
const sensorContext = useRef({
|
|
103
|
+
items: flattenedAndRemovedCollapsedItemsWithActive,
|
|
104
|
+
offset: offsetLeft,
|
|
105
|
+
});
|
|
106
|
+
const coordinateGetter = useMemo(() => {
|
|
107
|
+
sensorContext.current.items = flattenedAndRemovedCollapsedItemsWithActive;
|
|
108
|
+
sensorContext.current.offset = offsetLeft;
|
|
109
|
+
return sortableTreeKeyboardCoordinates(sensorContext, true, indentationWidth);
|
|
110
|
+
}, [flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
|
|
111
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
112
|
+
coordinateGetter: coordinateGetter,
|
|
113
|
+
}));
|
|
114
|
+
const projected = useMemo(() => activeId && overId
|
|
115
|
+
? getProjection(flattenedAndRemovedCollapsedItemsWithActive, activeId, overId, offsetLeft, indentationWidth)
|
|
116
|
+
: null, [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);
|
|
117
|
+
/* ------------------------------ Handlers ------------------------------ */
|
|
118
|
+
function handleDragStart({ active }) {
|
|
119
|
+
const activeId = active.id;
|
|
120
|
+
setActiveId(activeId);
|
|
121
|
+
setOverId(activeId);
|
|
122
|
+
const activeItem = flattenItems.find(({ id }) => id === activeId);
|
|
123
|
+
if (activeItem) {
|
|
124
|
+
setCurrentPosition({
|
|
125
|
+
parentId: activeItem.parentId,
|
|
126
|
+
overId: activeId,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
document.body.style.setProperty('cursor', 'grabbing');
|
|
130
|
+
}
|
|
131
|
+
function handleDragMove({ delta }) {
|
|
132
|
+
setOffsetLeft(delta.x);
|
|
133
|
+
}
|
|
134
|
+
function handleDragOver({ over }) {
|
|
135
|
+
var _a;
|
|
136
|
+
setOverId((_a = over === null || over === void 0 ? void 0 : over.id) !== null && _a !== void 0 ? _a : null);
|
|
137
|
+
}
|
|
138
|
+
function resetState() {
|
|
139
|
+
setOverId(null);
|
|
140
|
+
setActiveId(null);
|
|
141
|
+
setOffsetLeft(0);
|
|
142
|
+
setCurrentPosition(null);
|
|
143
|
+
document.body.style.setProperty('cursor', '');
|
|
144
|
+
}
|
|
145
|
+
const handleDragEnd = useCallback((event) => {
|
|
146
|
+
const { active, over } = event;
|
|
147
|
+
resetState();
|
|
148
|
+
let overIndex = flattenItems.findIndex((item) => item.id === (over === null || over === void 0 ? void 0 : over.id));
|
|
149
|
+
if ((over === null || over === void 0 ? void 0 : over.id) === ACTIVE_PLACEHOLDER_ID) {
|
|
150
|
+
overIndex = flattenItems.findIndex((item) => item.id === active.id);
|
|
151
|
+
}
|
|
152
|
+
if (projected && over) {
|
|
153
|
+
const { depth, parentId } = projected;
|
|
154
|
+
const clonedItems = [...flattenItems];
|
|
155
|
+
const parentIndex = clonedItems.findIndex((item) => item.id === parentId);
|
|
156
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);
|
|
157
|
+
const activeTreeItem = clonedItems[activeIndex];
|
|
158
|
+
clonedItems[activeIndex] = Object.assign(Object.assign({}, activeTreeItem), { depth, parentId });
|
|
159
|
+
const parentItem = clonedItems[parentIndex];
|
|
160
|
+
if (parentItem && parentItem.canHaveSubItems) {
|
|
161
|
+
clonedItems[parentIndex] = Object.assign(Object.assign({}, parentItem), { isCollapsed: false });
|
|
162
|
+
}
|
|
163
|
+
const newItems = buildTree(arrayMove(clonedItems, activeIndex, overIndex));
|
|
164
|
+
onItemsChanged(newItems, {
|
|
165
|
+
reason: 'dropped',
|
|
166
|
+
item: activeTreeItem,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, [flattenItems, onItemsChanged, projected]);
|
|
170
|
+
function handleToggleCollapse(id) {
|
|
171
|
+
const item = flattenItems.find((item) => item.id === id);
|
|
172
|
+
if (!item || item.canHaveSubItems !== true)
|
|
173
|
+
return;
|
|
174
|
+
onItemsChanged(buildTree(flattenItems.map((item) => {
|
|
175
|
+
if (item.id === id && item.canHaveSubItems === true) {
|
|
176
|
+
return Object.assign(Object.assign({}, item), { isCollapsed: !item.isCollapsed });
|
|
177
|
+
}
|
|
178
|
+
return item;
|
|
179
|
+
})), {
|
|
180
|
+
reason: item.isCollapsed ? 'expanded' : 'collapsed',
|
|
181
|
+
item,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function handleDragCancel() {
|
|
185
|
+
resetState();
|
|
186
|
+
}
|
|
187
|
+
/* ------------------------------ Keyboard functions ------------------------------ */
|
|
188
|
+
const getMovementAnnouncement = (eventName, activeId, overId) => {
|
|
189
|
+
if (overId && projected) {
|
|
190
|
+
if (eventName !== 'onDragEnd') {
|
|
191
|
+
if (currentPosition &&
|
|
192
|
+
projected.parentId === currentPosition.parentId &&
|
|
193
|
+
overId === currentPosition.overId) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
setCurrentPosition({
|
|
198
|
+
parentId: projected.parentId,
|
|
199
|
+
overId,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const clonedItems = [
|
|
204
|
+
...flattenedAndRemovedCollapsedItemsWithActive,
|
|
205
|
+
];
|
|
206
|
+
const overIndex = clonedItems.findIndex(({ id }) => id === overId);
|
|
207
|
+
const activeIndex = clonedItems.findIndex(({ id }) => id === activeId);
|
|
208
|
+
const sortedItems = arrayMove(clonedItems, activeIndex, overIndex);
|
|
209
|
+
const previousItem = sortedItems[overIndex - 1];
|
|
210
|
+
let announcement;
|
|
211
|
+
const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';
|
|
212
|
+
const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';
|
|
213
|
+
if (!previousItem) {
|
|
214
|
+
const nextItem = sortedItems[overIndex + 1];
|
|
215
|
+
announcement = `${activeId} was ${movedVerb} before ${nextItem.id}.`;
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (projected.depth > previousItem.depth) {
|
|
219
|
+
announcement = `${activeId} was ${nestedVerb} under ${previousItem.id}.`;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
let previousSibling = previousItem;
|
|
223
|
+
while (previousSibling && projected.depth < previousSibling.depth) {
|
|
224
|
+
const parentId = previousSibling.parentId;
|
|
225
|
+
previousSibling = sortedItems.find(({ id }) => id === parentId);
|
|
226
|
+
}
|
|
227
|
+
if (previousSibling) {
|
|
228
|
+
announcement = `${activeId} was ${movedVerb} after ${previousSibling.id}.`;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return announcement;
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
};
|
|
236
|
+
const announcements = {
|
|
237
|
+
onDragStart({ active }) {
|
|
238
|
+
return `Picked up ${active.id}.`;
|
|
239
|
+
},
|
|
240
|
+
onDragMove({ active, over }) {
|
|
241
|
+
return getMovementAnnouncement('onDragMove', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
242
|
+
},
|
|
243
|
+
onDragOver({ active, over }) {
|
|
244
|
+
return getMovementAnnouncement('onDragOver', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
245
|
+
},
|
|
246
|
+
onDragEnd({ active, over }) {
|
|
247
|
+
return getMovementAnnouncement('onDragEnd', active.id, over === null || over === void 0 ? void 0 : over.id);
|
|
248
|
+
},
|
|
249
|
+
onDragCancel({ active }) {
|
|
250
|
+
return `Moving was cancelled. ${active.id} was dropped in its original position.`;
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
/* ------------------------------ Visual ------------------------------ */
|
|
254
|
+
function getTrailList() {
|
|
255
|
+
const trails = {};
|
|
256
|
+
//Loop through the items in reverse
|
|
257
|
+
[...flattenedAndRemovedCollapsedItemsWithActive]
|
|
258
|
+
.reverse()
|
|
259
|
+
.forEach((item, itemIndex, reversedList) => {
|
|
260
|
+
const trailList = [];
|
|
261
|
+
const nextItem = reversedList[itemIndex - 1];
|
|
262
|
+
//Loop through the depth of the item
|
|
263
|
+
for (let trailDepth = 0; trailDepth < item.depth; trailDepth++) {
|
|
264
|
+
//Not closest to the item so should be straight or none
|
|
265
|
+
if (trailDepth < item.depth - 1) {
|
|
266
|
+
if (nextItem === undefined) {
|
|
267
|
+
trailList.push('none');
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
else if (trails[nextItem === null || nextItem === void 0 ? void 0 : nextItem.id][trailDepth] === 'none') {
|
|
271
|
+
trailList.push('none');
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
else if (nextItem && nextItem.depth <= trailDepth) {
|
|
275
|
+
trailList.push('none');
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
trailList.push('straight');
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
if ((nextItem && trails[nextItem === null || nextItem === void 0 ? void 0 : nextItem.id][trailDepth] === 'none') ||
|
|
282
|
+
nextItem === undefined ||
|
|
283
|
+
nextItem.depth <= trailDepth) {
|
|
284
|
+
trailList.push('curved');
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
trailList.push('straight-curved');
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
trails[item.id] = trailList;
|
|
292
|
+
});
|
|
293
|
+
return trails;
|
|
294
|
+
}
|
|
295
|
+
const measuring = {
|
|
296
|
+
droppable: {
|
|
297
|
+
strategy: MeasuringStrategy.Always,
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
const trails = getTrailList();
|
|
301
|
+
const rowIdWithFocus = focusedRowId !== null && focusedRowId !== void 0 ? focusedRowId : (_b = flattenedAndRemovedCollapsedItemsWithActive[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
302
|
+
return (_jsx(DndContext, { accessibility: { announcements }, sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart, onDragMove: handleDragMove, onDragOver: handleDragOver, onDragCancel: handleDragCancel, measuring: measuring, children: _jsxs(SortableContext, { items: flattenedAndRemovedCollapsedItemsWithActive.map((item) => item.id), strategy: verticalListSortingStrategy, children: [_jsx("ol", Object.assign({ className: "ndl-tree-view-list", role: "tree" }, rest, { children: flattenedAndRemovedCollapsedItemsWithActive.map((item) => {
|
|
303
|
+
var _a;
|
|
304
|
+
return (_jsx(SortableTreeViewItem, { depth: item.id === activeId && projected ? projected.depth : item.depth, indentationWidth: indentationWidth, item: item, isLast: false, parent: (_a = flattenItems.find((i) => i.id === item.parentId)) !== null && _a !== void 0 ? _a : null, id: item.id, trails: trails[item.id], keepGhostInPlace: item.id === ACTIVE_PLACEHOLDER_ID, TreeItemComponent: TreeItemComponent === undefined
|
|
305
|
+
? TreeViewTextItem
|
|
306
|
+
: TreeItemComponent, onCollapse: () => handleToggleCollapse(item.id), onItemsChanged: (newItems, itemChangedReason) => onItemsChanged(buildTree(newItems), itemChangedReason), items: flattenItems, tabIndex: item.id === rowIdWithFocus ? 0 : -1, onFocus: () => setFocusedRowId(item.id), shouldDisableSorting: item.isSortable === false }, item.id));
|
|
307
|
+
}) })), createPortal(_jsx(DragOverlay, { dropAnimation: dropAnimationConfig }), document.body)] }) }));
|
|
308
|
+
};
|
|
309
|
+
TreeView.TreeItemWrapper = TreeItemWrapper;
|
|
310
|
+
//# sourceMappingURL=TreeView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeView.js","sourceRoot":"","sources":["../../../src/tree-view/TreeView.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAEL,UAAU,EAIV,WAAW,EAGX,cAAc,EACd,iBAAiB,EACjB,aAAa,EAEb,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,eAAe,EACf,SAAS,EACT,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO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ACvC,oBAAoB,EAAE,IAAI,CAAC,UAAU,KAAK,KAAK,IAvB1C,IAAI,CAAC,EAAE,CAwBZ,CACH,CAAA;qBAAA,CAAC,IACC,EAEJ,YAAY,CACX,KAAC,WAAW,IAAC,aAAa,EAAE,mBAAmB,GAAgB,EAC/D,QAAQ,CAAC,IAAI,CACd,IACe,GACP,CACd,CAAC;AACJ,CAAC,CAAC;AAEF,QAAQ,CAAC,eAAe,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
25
|
+
t[p] = s[p];
|
|
26
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
27
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
29
|
+
t[p[i]] = s[p[i]];
|
|
30
|
+
}
|
|
31
|
+
return t;
|
|
32
|
+
};
|
|
33
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
34
|
+
import { useSortable, } from '@dnd-kit/sortable';
|
|
35
|
+
import React, { useMemo } from 'react';
|
|
36
|
+
import { transformToString } from './tree-view-utils';
|
|
37
|
+
const animateLayoutChanges = ({ isSorting, isDragging, }) => (isSorting || isDragging ? false : true);
|
|
38
|
+
const SortableTreeViewItemNotMemoized = function SortableTreeViewItem(_a) {
|
|
39
|
+
var { id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting,
|
|
40
|
+
// need to destruct to avoid passing it to the component
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
+
sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, tabIndex, onFocus } = _a, restProps = __rest(_a, ["id", "depth", "isLast", "TreeItemComponent", "parent", "shouldDisableSorting", "sortableProps", "keepGhostInPlace", "item", "onCollapse", "trails", "onItemsChanged", "items", "tabIndex", "onFocus"]);
|
|
43
|
+
const { attributes, listeners, setNodeRef, transform, setActivatorNodeRef, transition, isDragging, isSorting, isOver, } = useSortable({
|
|
44
|
+
id: id,
|
|
45
|
+
animateLayoutChanges,
|
|
46
|
+
transition: {
|
|
47
|
+
duration: 150,
|
|
48
|
+
easing: 'cubic-bezier(0.25, 1, 0.5, 1)',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
const style = {
|
|
52
|
+
transform: transform ? transformToString(transform) : undefined,
|
|
53
|
+
transition: transition !== null && transition !== void 0 ? transition : undefined,
|
|
54
|
+
};
|
|
55
|
+
const localCollapse = useMemo(() => {
|
|
56
|
+
if (!onCollapse)
|
|
57
|
+
return undefined;
|
|
58
|
+
return () => onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(item.id);
|
|
59
|
+
}, [item.id, onCollapse]);
|
|
60
|
+
return (_jsx(TreeItemComponent, Object.assign({ item: item, isOverParent: false }, restProps, { setActivatorNodeRef: setActivatorNodeRef, setNodeRef: setNodeRef, style: style, depth: depth, isGhost: keepGhostInPlace, shouldDisableInteraction: isSorting, isLastInParent: isLast, parent: parent, dragHandleProps: Object.assign(Object.assign({}, attributes), listeners), isIndicator: isDragging, onCollapse: localCollapse, onItemsChanged: onItemsChanged, items: items, shouldDisableSorting: shouldDisableSorting, isOver: isOver, trails: trails, tabIndex: tabIndex, onFocus: onFocus })));
|
|
61
|
+
};
|
|
62
|
+
export const SortableTreeViewItem = React.memo(SortableTreeViewItemNotMemoized);
|
|
63
|
+
//# sourceMappingURL=TreeViewItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeViewItem.js","sourceRoot":"","sources":["../../../src/tree-view/TreeViewItem.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAqBA,OAAO,EAGL,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,EAAsB,OAAO,EAAE,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkBtD,MAAM,oBAAoB,GAAyB,CAAC,EAClD,SAAS,EACT,UAAU,GACX,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAqB/C,MAAM,+BAA+B,GAAG,SAAS,oBAAoB,CAGnE,EAmB4B;QAnB5B,EACA,EAAE,EACF,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,MAAM,EACN,oBAAoB;IACpB,wDAAwD;IACxD,6DAA6D;IAC7D,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,MAAM,EACN,cAAc,EACd,KAAK,EACL,QAAQ,EACR,OAAO,OAEqB,EADzB,SAAS,cAlBZ,uMAmBD,CADa;IAEZ,MAAM,EACJ,UAAU,EACV,SAAS,EACT,UA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