mobx-view-model-devtools 0.0.40 → 0.0.41

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/index.d.ts CHANGED
@@ -95,6 +95,7 @@ interface SearchEngineConfig {
95
95
  getItemOffset: (index: number) => number;
96
96
  scrollToOffset: (offset: number) => void;
97
97
  getRootItems: () => ListItem<any>[];
98
+ getPresentationMode: () => 'tree' | 'list';
98
99
  }
99
100
  declare class SearchEngine {
100
101
  private config;
@@ -118,6 +119,10 @@ declare class SearchEngine {
118
119
  get suggestionSuffix(): string;
119
120
  handleSearchInput: (e: ChangeEvent<HTMLInputElement>) => void;
120
121
  handleKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
122
+ /**
123
+ * Рекурсивно собирает все VMListItem из дерева (включая вложенные).
124
+ */
125
+ private collectAllVMs;
121
126
  /**
122
127
  * Возвращает PropertyListItem на целевой глубине для получения подсказки.
123
128
  * pathSegments — все сегменты кроме последнего (путь навигации).
@@ -128,6 +133,11 @@ declare class SearchEngine {
128
133
  * Возвращает свойства на нужной глубине.
129
134
  */
130
135
  private navigatePropertyPath;
136
+ /**
137
+ * Плоский список для режима 'list': все VM показываются независимо,
138
+ * сворачивание VM скрывает только его свойства, но не дочерние VM.
139
+ */
140
+ private getFlatListItems;
131
141
  getListItems(rootItems: ListItem<any>[]): ListItem<any>[];
132
142
  private getFilteredItemsForSearch;
133
143
  private getVMSearchItems;
@@ -149,7 +159,10 @@ declare class SearchEngine {
149
159
  * или «затемнённо» (false — серым).
150
160
  *
151
161
  * Для PropertyListItem: проходим вверх по цепочке parentListItem,
152
- * чтобы определить уровень вложенности и соответствующий сегмент фильтра.
162
+ * собирая предков и вычисляя уровень вложенности.
163
+ * Затем проверяем, что вся цепочка предков соответствует сегментам поиска:
164
+ * если хотя бы один предок не совпадает с нужным сегментом —
165
+ * элемент находится в «несовпадающей ветке» и тоже должен быть серым.
153
166
  */
154
167
  isItemFitted(item: ListItem<any>): boolean;
155
168
  resetSearch: () => void;
package/index.js CHANGED
@@ -39319,17 +39319,33 @@ class SearchEngine {
39319
39319
  this.searchText += this.suggestionSuffix;
39320
39320
  }
39321
39321
  };
39322
+ /**
39323
+ * Рекурсивно собирает все VMListItem из дерева (включая вложенные).
39324
+ */
39325
+ collectAllVMs(rootItems) {
39326
+ const result = [];
39327
+ const traverse = (item) => {
39328
+ if (item instanceof VMListItem) {
39329
+ result.push(item);
39330
+ for (const child of item.children) {
39331
+ traverse(child);
39332
+ }
39333
+ }
39334
+ };
39335
+ for (const item of rootItems) {
39336
+ traverse(item);
39337
+ }
39338
+ return result;
39339
+ }
39322
39340
  /**
39323
39341
  * Возвращает PropertyListItem на целевой глубине для получения подсказки.
39324
39342
  * pathSegments — все сегменты кроме последнего (путь навигации).
39325
39343
  */
39326
39344
  getCandidatePropsAtDepth(rootItems, pathSegments) {
39327
- const vms = rootItems.filter(
39328
- (item) => item instanceof VMListItem
39329
- );
39345
+ const allVMs = this.collectAllVMs(rootItems);
39330
39346
  if (pathSegments.length === 0) {
39331
39347
  const props = [];
39332
- for (const vm of vms) {
39348
+ for (const vm of allVMs) {
39333
39349
  props.push(
39334
39350
  ...vm.children.filter(
39335
39351
  (c) => c instanceof PropertyListItem
@@ -39340,7 +39356,7 @@ class SearchEngine {
39340
39356
  }
39341
39357
  const firstSeg = pathSegments[0];
39342
39358
  const result = [];
39343
- for (const vm of vms) {
39359
+ for (const vm of allVMs) {
39344
39360
  const directProps = vm.children.filter(
39345
39361
  (c) => c instanceof PropertyListItem
39346
39362
  );
@@ -39395,8 +39411,44 @@ class SearchEngine {
39395
39411
  }
39396
39412
  return result;
39397
39413
  }
39414
+ /**
39415
+ * Плоский список для режима 'list': все VM показываются независимо,
39416
+ * сворачивание VM скрывает только его свойства, но не дочерние VM.
39417
+ */
39418
+ getFlatListItems(rootItems) {
39419
+ const result = [];
39420
+ const collectItem = (item) => {
39421
+ if (item instanceof VMListItem) {
39422
+ result.push(item);
39423
+ if (item.isExpanded) {
39424
+ for (const child of item.children) {
39425
+ if (!(child instanceof VMListItem)) {
39426
+ result.push(...child.expandedChildrenWithSelf);
39427
+ }
39428
+ }
39429
+ }
39430
+ for (const child of item.children) {
39431
+ if (child instanceof VMListItem) {
39432
+ collectItem(child);
39433
+ }
39434
+ }
39435
+ } else {
39436
+ result.push(item);
39437
+ if (item.isExpanded) {
39438
+ result.push(...item.expandedChildren);
39439
+ }
39440
+ }
39441
+ };
39442
+ for (const item of rootItems) {
39443
+ collectItem(item);
39444
+ }
39445
+ return result;
39446
+ }
39398
39447
  getListItems(rootItems) {
39399
39448
  if (!this.isActive) {
39449
+ if (this.config.getPresentationMode() === "list") {
39450
+ return this.getFlatListItems(rootItems);
39451
+ }
39400
39452
  return rootItems.flatMap((item) => item.expandedChildrenWithSelf);
39401
39453
  }
39402
39454
  return rootItems.flatMap((item) => this.getFilteredItemsForSearch(item));
@@ -39465,6 +39517,8 @@ class SearchEngine {
39465
39517
  result.push(
39466
39518
  ...this.getPropertySearchItems(prop.children, propSegments.slice(1))
39467
39519
  );
39520
+ } else if (prop.isExpanded) {
39521
+ result.push(...prop.expandedChildren);
39468
39522
  }
39469
39523
  }
39470
39524
  return result;
@@ -39494,7 +39548,10 @@ class SearchEngine {
39494
39548
  * или «затемнённо» (false — серым).
39495
39549
  *
39496
39550
  * Для PropertyListItem: проходим вверх по цепочке parentListItem,
39497
- * чтобы определить уровень вложенности и соответствующий сегмент фильтра.
39551
+ * собирая предков и вычисляя уровень вложенности.
39552
+ * Затем проверяем, что вся цепочка предков соответствует сегментам поиска:
39553
+ * если хотя бы один предок не совпадает с нужным сегментом —
39554
+ * элемент находится в «несовпадающей ветке» и тоже должен быть серым.
39498
39555
  */
39499
39556
  isItemFitted(item) {
39500
39557
  if (!this.isActive) return true;
@@ -39503,7 +39560,9 @@ class SearchEngine {
39503
39560
  if (segments.length === 0) return true;
39504
39561
  let parent = item.parentListItem;
39505
39562
  let propLevel = 0;
39563
+ const ancestors = [];
39506
39564
  while (parent instanceof PropertyListItem) {
39565
+ ancestors.push(parent);
39507
39566
  propLevel++;
39508
39567
  parent = parent.parentListItem;
39509
39568
  }
@@ -39511,7 +39570,17 @@ class SearchEngine {
39511
39570
  const firstSeg = segments[0];
39512
39571
  const vmMatchesByName = parent.searchData.name.includes(firstSeg) || parent.searchData.id.includes(firstSeg);
39513
39572
  const propSegments = vmMatchesByName ? segments.slice(1) : segments;
39514
- if (propLevel >= propSegments.length) return true;
39573
+ const depthToCheck = Math.min(propLevel, propSegments.length);
39574
+ for (let i = 0; i < depthToCheck; i++) {
39575
+ const ancestor = ancestors[propLevel - 1 - i];
39576
+ const seg2 = propSegments[i];
39577
+ if (seg2 && !ancestor.searchData.property.includes(seg2)) {
39578
+ return false;
39579
+ }
39580
+ }
39581
+ if (propLevel >= propSegments.length) {
39582
+ return true;
39583
+ }
39515
39584
  const seg = propSegments[propLevel];
39516
39585
  return !seg || item.searchData.property.includes(seg);
39517
39586
  }
@@ -39543,7 +39612,8 @@ class ViewModelDevtools {
39543
39612
  getIsActive: () => this.isActive,
39544
39613
  getItemOffset: (index) => this.scrollListRef.current?.getItemOffset(index) ?? 0,
39545
39614
  scrollToOffset: (offset) => this.scrollListRef.current?.scrollTo(offset),
39546
- getRootItems: () => this.searchRootItems
39615
+ getRootItems: () => this.searchRootItems,
39616
+ getPresentationMode: () => this.presentationMode
39547
39617
  });
39548
39618
  makeObservable(this, {
39549
39619
  position: observable.ref,
@@ -39640,7 +39710,10 @@ class ViewModelDevtools {
39640
39710
  vmItem.toggleExpand();
39641
39711
  }
39642
39712
  isExpandable(vmItem) {
39643
- return vmItem.isExpandable && this.presentationMode !== "list";
39713
+ if (this.presentationMode === "list") {
39714
+ return vmItem.children.some((c) => !(c instanceof VMListItem));
39715
+ }
39716
+ return vmItem.isExpandable;
39644
39717
  }
39645
39718
  getVmParams(vm) {
39646
39719
  if ("vmParams" in vm) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-view-model-devtools",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "js2me",