mobx-view-model-devtools 0.0.39 → 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
@@ -6,7 +6,7 @@ import { VirtualizerHandle } from 'virtua';
6
6
  import { Ref } from 'yummies/mobx';
7
7
  import { AnyObject, Maybe, Defined } from 'yummies/types';
8
8
  import { KeyboardHandler as KeyboardHandler$1, KeyboardHandlerAction } from 'mobx-swiss-knife';
9
- import { ComponentType, ChangeEventHandler } from 'react';
9
+ import { ComponentType, ChangeEventHandler, ChangeEvent, KeyboardEvent } from 'react';
10
10
 
11
11
  declare class KeyboardHandler extends KeyboardHandler$1<KeyboardHandlerAction> {
12
12
  constructor(devtools: ViewModelDevtools);
@@ -39,7 +39,6 @@ declare abstract class ListItem<T> {
39
39
  get expandedChildren(): ListItem<any>[];
40
40
  get expandedChildrenWithSelf(): ListItem<any>[];
41
41
  get data(): T;
42
- get isFitted(): boolean;
43
42
  get closingItem(): ListItem<any> | null;
44
43
  abstract get depth(): number;
45
44
  get depthLine(): string;
@@ -58,13 +57,13 @@ declare class PropertyListItem extends ListItem<any> {
58
57
  editContent: string;
59
58
  isEditMode: boolean;
60
59
  get isExpanded(): boolean;
60
+ get isExpandable(): boolean;
61
61
  get data(): any;
62
62
  get descriptor(): PropertyDescriptor | null | undefined;
63
63
  get dataType(): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
64
64
  get stringifiedDataType(): string;
65
65
  get type(): "array" | "instance" | "function" | "object" | "primitive";
66
66
  get children(): PropertyListItem[];
67
- get isFitted(): boolean;
68
67
  get extraContent(): "," | null;
69
68
  private get propertyClosingTag();
70
69
  get closingItem(): ListItem<any> | null;
@@ -79,6 +78,7 @@ declare class PropertyListItem extends ListItem<any> {
79
78
  get operations(): ListItemOperation<any>[];
80
79
  handleChangeEditContent: ChangeEventHandler<HTMLInputElement>;
81
80
  getSavedTempVarNotification(tempVarName: string): string;
81
+ get parentListItem(): ListItem<any>;
82
82
  protected constructor(devtools: ViewModelDevtools, property: Maybe<string>, path: string, order: number, parent: ListItem<any>);
83
83
  static createKey(parent: ListItem<any>, property: Maybe<string>): string;
84
84
  static create(devtools: ViewModelDevtools, property: Maybe<string>, path: string, order: number, parent: ListItem<any>): PropertyListItem;
@@ -89,18 +89,84 @@ interface FocusableRef<T extends HTMLElement = HTMLElement> extends Ref<T, {
89
89
  }> {
90
90
  }
91
91
 
92
+ interface SearchEngineConfig {
93
+ getContainerId: () => string;
94
+ getIsActive: () => boolean;
95
+ getItemOffset: (index: number) => number;
96
+ scrollToOffset: (offset: number) => void;
97
+ getRootItems: () => ListItem<any>[];
98
+ getPresentationMode: () => 'tree' | 'list';
99
+ }
92
100
  declare class SearchEngine {
101
+ private config;
93
102
  searchInputRef: FocusableRef<HTMLInputElement>;
94
- fittedVmIds: Set<string>;
95
- private rawSearchText;
96
- formattedSearchText: string;
97
- private searchTextUpdateTimeout;
98
- segments: string[];
99
- get isActive(): boolean;
103
+ searchText: string;
104
+ searchCacheKey: string;
105
+ isSearching: boolean;
106
+ get formattedSearchText(): string;
107
+ /**
108
+ * Сегменты поиска, разбитые по точке.
109
+ * Trailing-пустой сегмент (от trailing dot) убирается — для этого есть endsWithDot.
110
+ */
111
+ get segments(): string[];
100
112
  get endsWithDot(): boolean;
101
- private setSearchText;
113
+ get isActive(): boolean;
114
+ /**
115
+ * Суффикс первого найденного свойства, которое начинается с последнего сегмента.
116
+ * Отображается как серая подсказка в инпуте.
117
+ * Например: ввод "_pay" → suggestionSuffix = "load" (от "_payload")
118
+ */
119
+ get suggestionSuffix(): string;
120
+ handleSearchInput: (e: ChangeEvent<HTMLInputElement>) => void;
121
+ handleKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
122
+ /**
123
+ * Рекурсивно собирает все VMListItem из дерева (включая вложенные).
124
+ */
125
+ private collectAllVMs;
126
+ /**
127
+ * Возвращает PropertyListItem на целевой глубине для получения подсказки.
128
+ * pathSegments — все сегменты кроме последнего (путь навигации).
129
+ */
130
+ private getCandidatePropsAtDepth;
131
+ /**
132
+ * Навигация вглубь по цепочке свойств.
133
+ * Возвращает свойства на нужной глубине.
134
+ */
135
+ private navigatePropertyPath;
136
+ /**
137
+ * Плоский список для режима 'list': все VM показываются независимо,
138
+ * сворачивание VM скрывает только его свойства, но не дочерние VM.
139
+ */
140
+ private getFlatListItems;
141
+ getListItems(rootItems: ListItem<any>[]): ListItem<any>[];
142
+ private getFilteredItemsForSearch;
143
+ private getVMSearchItems;
144
+ /**
145
+ * Рекурсивно строит плоский список PropertyListItem для отображения.
146
+ *
147
+ * propSegments[0] — фильтр текущего уровня.
148
+ * Совпадающие свойства с propSegments[0], у которых есть ещё сегменты
149
+ * (т.е. не последний) — автоматически раскрываются (рекурсия вглубь).
150
+ * Последний сегмент только окрашивает (серый/нормальный), не раскрывает.
151
+ */
152
+ private getPropertySearchItems;
153
+ private vmMatchesSearch;
154
+ isPropertyItemExpanded(item: PropertyListItem): boolean;
155
+ isPropertyItemExpandable(item: PropertyListItem): boolean;
156
+ isVmItemExpanded(item: VMListItem): boolean;
157
+ /**
158
+ * Определяет, должен ли элемент отображаться «нормально» (true)
159
+ * или «затемнённо» (false — серым).
160
+ *
161
+ * Для PropertyListItem: проходим вверх по цепочке parentListItem,
162
+ * собирая предков и вычисляя уровень вложенности.
163
+ * Затем проверяем, что вся цепочка предков соответствует сегментам поиска:
164
+ * если хотя бы один предок не совпадает с нужным сегментом —
165
+ * элемент находится в «несовпадающей ветке» и тоже должен быть серым.
166
+ */
167
+ isItemFitted(item: ListItem<any>): boolean;
102
168
  resetSearch: () => void;
103
- constructor();
169
+ constructor(config: SearchEngineConfig);
104
170
  }
105
171
 
106
172
  interface ViewModelDevtoolsConfig {
@@ -129,28 +195,17 @@ declare class ViewModelDevtools {
129
195
  scrollListRef: Ref<VirtualizerHandle>;
130
196
  private storage;
131
197
  anyCache: mobx.ObservableMap<string, any>;
132
- private autoscrollTimeout;
133
- searchResultsCache: mobx.IObservableArray<ListItem<any>>;
134
- searchCacheKey: string;
135
- private searchTaskId;
136
- isSearching: boolean;
137
- private searchInitTaskId;
138
198
  get allVms(): AnyVM[];
139
199
  private get rootVmListItems();
140
200
  private get extraListItems();
201
+ private get searchRootItems();
141
202
  get listItems(): ListItem<any>[];
142
- private startLazySearch;
143
- private performLazySearch;
144
- private filterAndCacheResults;
145
- private filterItemsWithParentsLazy;
146
- private getParentItemsWithMatchedChildren;
147
- private findParent;
148
203
  get isActive(): boolean;
149
204
  private get containerId();
150
205
  isExpanded(vmItem: VMListItem): boolean;
151
206
  checkIsExtraPathExpanded(path: string): boolean;
152
207
  handleExpandVmPropertyClick(vmItem: VMListItem, path: string): void;
153
- handlePropertyClick(item: PropertyListItem, e: React.MouseEvent<HTMLElement>): void;
208
+ handlePropertyClick(item: PropertyListItem, _e: React.MouseEvent<HTMLElement>): void;
154
209
  handleVmItemHeaderClick(vmItem: VMListItem): void;
155
210
  isExpandable(vmItem: VMListItem): boolean | undefined;
156
211
  private getVmParams;
@@ -178,7 +233,6 @@ declare class VMListItem extends ListItem<AnyVM> {
178
233
  private allVms;
179
234
  private parent?;
180
235
  private get childVMListItems();
181
- get isFitted(): boolean;
182
236
  private get propertyListItems();
183
237
  get children(): ListItem<any>[];
184
238
  private getVmParams;