@adecore/ui 0.40.1 → 0.40.3
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.
|
@@ -41,3 +41,6 @@ export declare function expansionChanges(rows: readonly FileTreeVisibleRow[], co
|
|
|
41
41
|
collapse: string[];
|
|
42
42
|
expand: string[];
|
|
43
43
|
};
|
|
44
|
+
export declare function rebuildPaths(model: FileTree, paths: readonly string[], fold: () => void, applying: {
|
|
45
|
+
current: boolean;
|
|
46
|
+
}): void;
|
|
@@ -187,4 +187,25 @@ export function expansionChanges(rows, collapsed, keyOf = plainKey) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
return changes;
|
|
190
|
+
}
|
|
191
|
+
/*
|
|
192
|
+
* Builds a tree from `paths` again, keeping its selection, and while the tree has the keyboard its focus,
|
|
193
|
+
* on the nearest row when that one went. `fold` puts back what stood folded while `applying` is set,
|
|
194
|
+
* so the tree's own report of it is not read back as a person's doing.
|
|
195
|
+
*/
|
|
196
|
+
export function rebuildPaths(model, paths, fold, applying) {
|
|
197
|
+
const selected = model.getSelectedPaths();
|
|
198
|
+
const focused = model.getFocusedPath();
|
|
199
|
+
const typing = document.activeElement !== null && document.activeElement === model.getFileTreeContainer();
|
|
200
|
+
applying.current = true;
|
|
201
|
+
model.resetPaths(paths);
|
|
202
|
+
fold();
|
|
203
|
+
applying.current = false;
|
|
204
|
+
for (const path of selected) {
|
|
205
|
+
model.getItem(path)?.select();
|
|
206
|
+
}
|
|
207
|
+
const next = !typing || focused === null ? null : model.getItem(focused) !== null ? focused : model.focusNearestPath(focused);
|
|
208
|
+
if (next !== null) {
|
|
209
|
+
focusRow(model, next);
|
|
210
|
+
}
|
|
190
211
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { FileTreeRoot as Root } from './parts.tsx';
|
|
2
2
|
export { TreeCheckbox as Checkbox, TreeControl as Control, TreeDecoration as Decoration } from '../tree/parts.tsx';
|
|
3
|
-
export { ancestorDirsOf, applyExpansion, collapsedPathsOf, compareRows, directoryHandle, dirPathOf, expansionChanges, extendsSelection, focusRow, followFocus, menuTargetsOf, mergeCollapsedPaths, mergeExpanded, movesFocus, newlyExpanded, pathOfRow, resetExpandedPaths, rowPathOf, selectOnly, visibleRows, withoutClosedBranches } from './helpers.ts';
|
|
3
|
+
export { ancestorDirsOf, applyExpansion, collapsedPathsOf, compareRows, directoryHandle, dirPathOf, expansionChanges, extendsSelection, focusRow, followFocus, menuTargetsOf, mergeCollapsedPaths, mergeExpanded, movesFocus, newlyExpanded, pathOfRow, rebuildPaths, resetExpandedPaths, rowPathOf, selectOnly, visibleRows, withoutClosedBranches } from './helpers.ts';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { FileTreeRoot as Root } from "./parts.js";
|
|
2
2
|
export { TreeCheckbox as Checkbox, TreeControl as Control, TreeDecoration as Decoration } from "../tree/parts.js";
|
|
3
|
-
export { ancestorDirsOf, applyExpansion, collapsedPathsOf, compareRows, directoryHandle, dirPathOf, expansionChanges, extendsSelection, focusRow, followFocus, menuTargetsOf, mergeCollapsedPaths, mergeExpanded, movesFocus, newlyExpanded, pathOfRow, resetExpandedPaths, rowPathOf, selectOnly, visibleRows, withoutClosedBranches } from './helpers.js';
|
|
3
|
+
export { ancestorDirsOf, applyExpansion, collapsedPathsOf, compareRows, directoryHandle, dirPathOf, expansionChanges, extendsSelection, focusRow, followFocus, menuTargetsOf, mergeCollapsedPaths, mergeExpanded, movesFocus, newlyExpanded, pathOfRow, rebuildPaths, resetExpandedPaths, rowPathOf, selectOnly, visibleRows, withoutClosedBranches } from './helpers.js';
|
package/package.json
CHANGED
package/src/file-tree/helpers.ts
CHANGED
|
@@ -245,3 +245,28 @@ export function expansionChanges(
|
|
|
245
245
|
|
|
246
246
|
return changes;
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* Builds a tree from `paths` again, keeping its selection, and while the tree has the keyboard its focus,
|
|
251
|
+
* on the nearest row when that one went. `fold` puts back what stood folded while `applying` is set,
|
|
252
|
+
* so the tree's own report of it is not read back as a person's doing.
|
|
253
|
+
*/
|
|
254
|
+
export function rebuildPaths(model: FileTree, paths: readonly string[], fold: () => void, applying: { current: boolean }): void {
|
|
255
|
+
const selected = model.getSelectedPaths();
|
|
256
|
+
const focused = model.getFocusedPath();
|
|
257
|
+
const typing = document.activeElement !== null && document.activeElement === model.getFileTreeContainer();
|
|
258
|
+
applying.current = true;
|
|
259
|
+
model.resetPaths(paths);
|
|
260
|
+
fold();
|
|
261
|
+
applying.current = false;
|
|
262
|
+
|
|
263
|
+
for (const path of selected) {
|
|
264
|
+
model.getItem(path)?.select();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const next = !typing || focused === null ? null : model.getItem(focused) !== null ? focused : model.focusNearestPath(focused);
|
|
268
|
+
|
|
269
|
+
if (next !== null) {
|
|
270
|
+
focusRow(model, next);
|
|
271
|
+
}
|
|
272
|
+
}
|