@pierre%2Ftrees@1.0.0-beta.4.patch 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. diff --git a/dist/model/FileTreeController.js b/dist/model/FileTreeController.js
  2. index 37c5d1ffedd5aff0258dec41b1b5cedb240aa3a6..365c42ef4c824bfd13d14f0d09226929af625c73 100644
  3. --- a/dist/model/FileTreeController.js
  4. +++ b/dist/model/FileTreeController.js
  5. @@ -1052,8 +1052,8 @@ var FileTreeController = class {
  6. this.#setExpandedPaths(expandedPaths);
  7. return focusCandidate ?? this.#focusedPath;
  8. }
  9. - #emit() {
  10. - for (const listener of this.#listeners) listener();
  11. + #emit(event) {
  12. + for (const listener of this.#listeners) listener(event);
  13. }
  14. #emitMutation(event) {
  15. this.#mutationListeners.get(event.operation)?.forEach((listener) => {
  16. @@ -1149,7 +1149,7 @@ var FileTreeController = class {
  17. const searchFocusCandidate = this.#searchValue != null && this.#searchValue.length > 0 ? this.#refreshActiveSearchState() : this.#searchValue === "" ? this.#focusedPath : focusPathCandidate;
  18. const shouldBuildFullProjection = this.#searchValue != null || event.operation !== "expand" && event.operation !== "collapse";
  19. this.#rebuildVisibleProjection(searchFocusCandidate, shouldBuildFullProjection);
  20. - this.#emit();
  21. + this.#emit(event);
  22. const mutationEvent = toTreesMutationEvent(event);
  23. if (mutationEvent != null) this.#emitMutation(mutationEvent);
  24. });
  25. diff --git a/dist/model/internalTypes.d.ts b/dist/model/internalTypes.d.ts
  26. index 5b0fdd5a3b483439ae256795f3dad5a32182ab78..073c6f21edc20ce5bd44b122fe02b83de802b887 100644
  27. --- a/dist/model/internalTypes.d.ts
  28. +++ b/dist/model/internalTypes.d.ts
  29. @@ -4,7 +4,10 @@ import { FileTreeCompositionOptions, FileTreePublicId, FileTreeRenderOptions, Fi
  30. import { FileTreeController } from "./FileTreeController.js";
  31. //#region src/model/internalTypes.d.ts
  32. -type FileTreeControllerListener = () => void;
  33. +type FileTreeControllerListener = (event?: {
  34. + operation: 'expand' | 'collapse';
  35. + path: string;
  36. +}) => void;
  37. interface FileTreeStickyRowCandidate {
  38. row: FileTreeVisibleRow;
  39. subtreeEndIndex: number;
  40. diff --git a/dist/model/publicTypes.d.ts b/dist/model/publicTypes.d.ts
  41. index 84a7e2d14f67c1aad8230f19a3426ab7403f378e..752e262e6d2d8a836931b7b83a93d89a75e6209c 100644
  42. --- a/dist/model/publicTypes.d.ts
  43. +++ b/dist/model/publicTypes.d.ts
  44. @@ -167,6 +167,10 @@ type FileTreeOptionSurface = FileTreeRenderOptions & {
  45. gitStatus?: readonly GitStatusEntry[];
  46. id?: string;
  47. icons?: FileTreeIcons;
  48. + onExpansionChange?: (change: {
  49. + expanded: boolean;
  50. + path: FileTreePublicId;
  51. + }) => void;
  52. onSelectionChange?: FileTreeSelectionChangeListener;
  53. renderRowDecoration?: FileTreeRowDecorationRenderer;
  54. search?: boolean;
  55. diff --git a/dist/render/FileTree.js b/dist/render/FileTree.js
  56. index 6db15e51b833192f79b71a15febe1612a4c185d0..36a4e6ac527595849c1db0e6bbebb475b6030b7b 100644
  57. --- a/dist/render/FileTree.js
  58. +++ b/dist/render/FileTree.js
  59. @@ -63,6 +63,7 @@ var FileTree = class {
  60. #composition;
  61. #controller;
  62. #id;
  63. + #onExpansionChange;
  64. #onSelectionChange;
  65. #renderRowDecoration;
  66. #renamingEnabled;
  67. @@ -80,16 +81,18 @@ var FileTree = class {
  68. #appliedUnsafeCSS;
  69. #selectionVersion;
  70. #selectionSubscription = null;
  71. + #expansionSubscription = null;
  72. #wrapper;
  73. #wroteHostItemHeight = false;
  74. #wroteHostDensityFactor = false;
  75. constructor(options) {
  76. - const { composition, density, fileTreeSearchMode, gitStatus, id, initialSearchQuery, icons, itemHeight, onSearchChange, onSelectionChange, overscan, renderRowDecoration, renaming, search, searchBlurBehavior, searchFakeFocus, stickyFolders, unsafeCSS, initialVisibleRowCount,...controllerOptions } = options;
  77. + const { composition, density, fileTreeSearchMode, gitStatus, id, initialSearchQuery, icons, itemHeight, onExpansionChange, onSearchChange, onSelectionChange, overscan, renderRowDecoration, renaming, search, searchBlurBehavior, searchFakeFocus, stickyFolders, unsafeCSS, initialVisibleRowCount,...controllerOptions } = options;
  78. this.#composition = composition;
  79. this.#id = createClientId(id);
  80. this.#gitStatusState = resolveFileTreeGitStatusState(gitStatus);
  81. this.#icons = icons;
  82. this.#unsafeCSS = unsafeCSS;
  83. + this.#onExpansionChange = onExpansionChange;
  84. this.#onSelectionChange = onSelectionChange;
  85. this.#renderRowDecoration = renderRowDecoration;
  86. this.#renamingEnabled = renaming != null && renaming !== false;
  87. @@ -114,6 +117,10 @@ var FileTree = class {
  88. this.#selectionSubscription = this.#onSelectionChange == null ? null : this.subscribe(() => {
  89. this.#emitSelectionChange();
  90. });
  91. + this.#expansionSubscription = this.#onExpansionChange == null ? null : this.#controller.subscribe((event) => {
  92. + if (event?.operation !== "expand" && event?.operation !== "collapse") return;
  93. + this.#onExpansionChange?.({ path: event.path, expanded: event.operation === "expand" });
  94. + });
  95. }
  96. unmount() {
  97. if (this.#wrapper != null) {
  98. @@ -133,6 +140,8 @@ var FileTree = class {
  99. this.unmount();
  100. this.#selectionSubscription?.();
  101. this.#selectionSubscription = null;
  102. + this.#expansionSubscription?.();
  103. + this.#expansionSubscription = null;
  104. this.#controller.destroy();
  105. }
  106. getFileTreeContainer() {