@dosgato/dialog 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/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.39",
4
+ "version": "0.0.41",
5
5
  "dependencies": {
6
6
  "@txstate-mws/svelte-components": "^1.3.8",
7
7
  "@txstate-mws/svelte-forms": "^1.3.4",
package/tree/Tree.svelte CHANGED
@@ -2,6 +2,7 @@
2
2
  import { derivedStore, Store } from '@txstate-mws/svelte-store';
3
3
  import { afterUpdate, beforeUpdate, onDestroy, onMount, setContext } from 'svelte';
4
4
  import { hashid } from 'txstate-utils';
5
+ import LoadIcon from './LoadIcon.svelte';
5
6
  import TreeNode from './TreeNode.svelte';
6
7
  import { TreeStore, TREE_STORE_CONTEXT } from './treestore';
7
8
  export let headers;
@@ -92,16 +93,15 @@ function headerDragEnd() {
92
93
  function headerDragReset() {
93
94
  store.resetHeaderOverride();
94
95
  }
95
- let mounted = false;
96
96
  onMount(async () => {
97
97
  document.addEventListener('dragend', onDragEnd);
98
+ const saveFocusId = $store.focused?.id;
98
99
  await store.refresh();
99
- if ($store.focused?.id) {
100
+ if ($store.focused?.id && $store.focused.id === saveFocusId) {
100
101
  const el = document.getElementById(hashid($store.focused.id));
101
102
  el?.scrollIntoView({ block: 'center' });
102
103
  }
103
104
  headerSizes.set(calcHeaderSizes()); // seems to need a kick on first mount
104
- mounted = true;
105
105
  });
106
106
  onDestroy(() => {
107
107
  document.removeEventListener('dragend', onDragEnd);
@@ -123,15 +123,15 @@ afterUpdate(() => {
123
123
 
124
124
  <svelte:window on:mouseup={headerDragEnd} />
125
125
 
126
- <div class="tree-header" class:mounted class:resizing={!!dragheaderid} use:resize={{ store: treeWidth }} aria-hidden="true" on:mouseup={headerDragEnd} on:touchend={headerDragEnd} on:mousemove={dragheaderid ? headerDrag : undefined} on:touchmove={dragheaderid ? headerDrag : undefined}>
126
+ <div class="tree-header" class:resizing={!!dragheaderid} use:resize={{ store: treeWidth }} aria-hidden="true" on:mouseup={headerDragEnd} on:touchend={headerDragEnd} on:mousemove={dragheaderid ? headerDrag : undefined} on:touchmove={dragheaderid ? headerDrag : undefined}>
127
127
  <div class="checkbox" bind:this={checkboxelement}>&nbsp;</div>
128
128
  {#each headers as header, i (header.label)}
129
- <div bind:this={headerelements[i]} id={header.id} class="tree-header-cell {header.id}" style:width={$headerOverride[header.id] ?? $headerSizes?.[i]}>{header.label}</div>
129
+ <div bind:this={headerelements[i]} id={header.id} class="tree-header-cell {header.id}" style:width={$headerOverride[header.id] ?? $headerSizes?.[i]}>{header.label}{#if i === 0 && $store.loading}<LoadIcon />{/if}</div>
130
130
  {#if enableResize && i !== headers.length - 1}<div class="tree-separator" on:mousedown={headerDragStart(header, i)} on:touchstart={headerDragStart(header, i)} on:dblclick={headerDragReset}>&nbsp;</div>{/if}
131
131
  {/each}
132
132
  </div>
133
133
  {#if $rootItems?.length}
134
- <ul bind:this={store.treeElement} class:mounted role="tree" class:resizing={!!dragheaderid} on:mousemove={dragheaderid ? headerDrag : undefined} on:touchmove={dragheaderid ? headerDrag : undefined} on:mouseup={headerDragEnd} on:touchend={headerDragEnd}>
134
+ <ul bind:this={store.treeElement} role="tree" class:resizing={!!dragheaderid} on:mousemove={dragheaderid ? headerDrag : undefined} on:touchmove={dragheaderid ? headerDrag : undefined} on:mouseup={headerDragEnd} on:touchend={headerDragEnd}>
135
135
  {#each $rootItems as item, i (item.id)}
136
136
  <TreeNode
137
137
  {item}
@@ -161,10 +161,6 @@ afterUpdate(() => {
161
161
  left: 0;
162
162
  z-index: 1;
163
163
  font-size: 0.9em;
164
- opacity: 0;
165
- }
166
- .tree-header.mounted {
167
- opacity: 1;
168
164
  }
169
165
  .tree-header.resizing {
170
166
  cursor: col-resize;
@@ -200,10 +196,6 @@ afterUpdate(() => {
200
196
  margin: 0;
201
197
  list-style: none;
202
198
  font-size: 0.9em;
203
- opacity: 0;
204
- }
205
- ul.mounted {
206
- opacity: 1;
207
199
  }
208
200
  :global([data-eq~="650px"]) ul {
209
201
  font-size: 0.8em;
package/tree/treestore.js CHANGED
@@ -101,6 +101,8 @@ export class TreeStore extends ActiveStore {
101
101
  this.value.rootItems = children;
102
102
  }
103
103
  this.addLookup(children);
104
+ // if any selected items disappeared in the refresh, we need to remove them from the selection map
105
+ this.cleanSelected();
104
106
  // if the focused item disappeared in the refresh, we need to replace it,
105
107
  // as without a focus the tree becomes invisible to keyboard nav
106
108
  if (!this.value.itemsById[this.value.focused?.id ?? ''])