@dosgato/dialog 0.0.58 → 0.0.59

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.
@@ -89,6 +89,9 @@ export declare class TreeStore<T extends TreeItemFromDB> extends ActiveStore<ITr
89
89
  notify?: boolean | undefined;
90
90
  toggle?: boolean | undefined;
91
91
  }): void;
92
+ setSelected(items: TypedTreeItem<T>[], { notify }: {
93
+ notify?: boolean | undefined;
94
+ }): void;
92
95
  selectById(id: string, { clear, notify, toggle }: {
93
96
  clear?: boolean | undefined;
94
97
  notify?: boolean | undefined;
@@ -11,15 +11,25 @@ export class TreeStore extends ActiveStore {
11
11
  if (!this.searchableFn || !rootItems?.length || isBlank(filter))
12
12
  return this.value.rootItems;
13
13
  const ret = [];
14
+ const newselected = [];
15
+ let foundfocus = false;
14
16
  for (const itm of this.value.rootItems ?? []) {
15
17
  let found = false;
16
18
  for (const val of this.searchableFn(itm)) {
17
19
  if (val.toLocaleLowerCase().startsWith(filter))
18
20
  found = true;
19
21
  }
20
- if (found)
22
+ if (found) {
23
+ if (this.value.selected.has(itm.id))
24
+ newselected.push(itm);
25
+ if (this.value.focused?.id === itm.id)
26
+ foundfocus = true;
21
27
  ret.push(itm);
28
+ }
22
29
  }
30
+ if (!foundfocus)
31
+ this.focus(ret[0]);
32
+ this.setSelected(newselected, {});
23
33
  return ret;
24
34
  });
25
35
  draggable = derivedStore(this, v => v.draggable && !v.loading);
@@ -167,6 +177,13 @@ export class TreeStore extends ActiveStore {
167
177
  if (notify)
168
178
  this.trigger();
169
179
  }
180
+ setSelected(items, { notify = true }) {
181
+ this.value.selected.clear();
182
+ for (const itm of items)
183
+ this.value.selected.set(itm.id, itm);
184
+ if (notify)
185
+ this.trigger();
186
+ }
170
187
  selectById(id, { clear = false, notify = true, toggle = false }) {
171
188
  const item = this.value.itemsById[id];
172
189
  if (item)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dosgato/dialog",
3
3
  "description": "A component library for building forms that edit a JSON document.",
4
- "version": "0.0.58",
4
+ "version": "0.0.59",
5
5
  "scripts": {
6
6
  "prepublishOnly": "svelte-package",
7
7
  "dev": "vite dev --force",