@sheetwrite/svelte 0.7.0 → 0.7.2

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/README.md CHANGED
@@ -32,6 +32,12 @@ import "@sheetwrite/svelte/styles.css";
32
32
 
33
33
  WASM initializes on client mount. Use `fallback` while loading, `onInitializationError` for failures, and `wasmSource` for an explicit source.
34
34
 
35
+ ## New in 0.7.0
36
+
37
+ - Install add-ons once with `initSheetwrite({ addons: [...] })` from `@sheetwrite/core` before the component mounts. The `addons` prop gives one grid its own add-on settings, such as `addons={{ queries: { fetchSource } }}`. See [Add-on registration](https://www.sheetwrite.dev/docs/start/upgrade-to-0-7-0/#add-on-registration).
38
+ - Enable the Keyboard shortcuts panel with `config={{ keyboardSettings: true }}`, and store the user's keys from `onKeyBindingsChange`. The compact ribbon is `config={{ ribbon: { mode: "compact" } }}`.
39
+ - Sort moves the cells; `grid.setViewSort` is the display-only sort. Columns without a `type` use the new `general` type. See the [0.7.0 release notes](https://www.sheetwrite.dev/docs/releases/0.7.0/) and the [upgrade guide](https://www.sheetwrite.dev/docs/start/upgrade-to-0-7-0/).
40
+
35
41
  ## New in 0.6.0
36
42
 
37
43
  - Enable the opt-in ribbon with `config={{ ribbon: true }}`. It loads only when requested. See [Toolbar and ribbon](https://www.sheetwrite.dev/docs/features/grid/toolbar-and-ribbon/).
@@ -55,9 +61,9 @@ The bindable `grid` is published before
55
61
  `onReady({ grid, generation, reason })` and clears during replacement or
56
62
  unmount. Reset-bound inputs are `workbook`, `data`, `datasource`,
57
63
  `datasourceStorage`, `presentation`, `editors`, `protectionResolver`,
58
- `mutationPolicy`, `transactionResourceLimits`, `renderer`, `workerUrl`, and
59
- `renderers`; `theme`, `readOnly`, `config`, `overscan`, and `minColumns` update
60
- live.
64
+ `mutationPolicy`, `transactionResourceLimits`, `hyperlinkActivation`, `addons`,
65
+ `renderer`, `workerUrl`, and `renderers`; `theme`, `readOnly`, `config`,
66
+ `overscan`, and `minColumns` update live.
61
67
 
62
68
  Readiness observes the latest committed live options, including changes while
63
69
  WASM initialization is pending. A throwing ready callback retires the new Grid;
@@ -65,7 +71,7 @@ consumer errors are not initialization failures. Omitted `renderer` and
65
71
  `"canvas"` are equivalent. Changing an explicit `wasmSource` after readiness
66
72
  preserves the Grid and retains the loader's first-source warning.
67
73
 
68
- Grid callbacks are `onGridChange`, `onViewportChange`, `onSelectionChange`, `onEditBegin`, `onEditCommit`, `onSearch`, `onCommandStateChange`, `onActiveSheetChange`, `onMutationRejected`, `onRendererFallback`, `onDatasourceError`, and `onExportError`.
74
+ Grid callbacks are `onGridChange`, `onRowDelta`, `onViewportChange`, `onSelectionChange`, `onEditBegin`, `onEditCommit`, `onSearch`, `onCommandStateChange`, `onActiveSheetChange`, `onMutationRejected`, `onRendererFallback`, `onDatasourceError`, `onExportError`, and `onKeyBindingsChange`.
69
75
 
70
76
  For vanilla/preload control, use `initSheetwrite()` and `createGrid()` from `@sheetwrite/core`. See [installation](https://www.sheetwrite.dev/docs/start/installation/), [Svelte tutorial](https://www.sheetwrite.dev/docs/tutorials/excel-in-svelte/), and [collaboration](https://www.sheetwrite.dev/docs/features/collaboration/).
71
77
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheetwrite/svelte",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "Svelte adapter for Sheetwrite.",
6
6
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "svelte": ">=5"
60
60
  },
61
61
  "dependencies": {
62
- "@sheetwrite/core": "0.7.0"
62
+ "@sheetwrite/core": "0.7.2"
63
63
  },
64
64
  "devDependencies": {
65
65
  "svelte-check": "4.7.3",
package/src/Grid.svelte CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  type GridAdapterEventHandlers,
7
7
  type GridPublicationAdapter,
8
8
  gridSizeStyle,
9
+ gridSkeletonStyle,
9
10
  } from "@sheetwrite/core/adapter";
10
11
  import { untrack } from "svelte";
11
12
  import type { SheetwriteGridProps as Props } from "./props.js";
@@ -35,6 +36,7 @@ let {
35
36
  fill,
36
37
  rowBridge: row_bridge,
37
38
  fallback,
39
+ skeleton = true,
38
40
  onGridChange: on_grid_change,
39
41
  onRowDelta: on_row_delta,
40
42
  onSelectionChange: on_selection_change,
@@ -47,6 +49,7 @@ let {
47
49
  onMutationRejected: on_mutation_rejected,
48
50
  onRendererFallback: on_renderer_fallback,
49
51
  onDatasourceError: on_datasource_error,
52
+ onLoadingChange: on_loading_change,
50
53
  onExportError: on_export_error,
51
54
  onKeyBindingsChange: on_key_bindings_change,
52
55
  onReady: on_ready,
@@ -56,7 +59,11 @@ let {
56
59
  }: Props = $props();
57
60
 
58
61
  let host: HTMLDivElement;
59
- let loading = $state(!isSheetwriteReady());
62
+ // On a page whose WASM is already initialized there is nothing to wait for:
63
+ // the grid paints in the same task, so the cover never shows.
64
+ let initialization_state = $state<"loading" | "ready" | "error">(
65
+ isSheetwriteReady() ? "ready" : "loading",
66
+ );
60
67
 
61
68
  function forward_command_state_change(
62
69
  event: Parameters<NonNullable<typeof on_command_state_change>>[0],
@@ -89,6 +96,8 @@ const handlers: GridAdapterEventHandlers = {
89
96
  on_renderer_fallback?.(event),
90
97
  onDatasourceError: (event: Parameters<NonNullable<typeof on_datasource_error>>[0]) =>
91
98
  on_datasource_error?.(event),
99
+ onLoadingChange: (event: Parameters<NonNullable<typeof on_loading_change>>[0]) =>
100
+ on_loading_change?.(event),
92
101
  onExportError: (event: Parameters<NonNullable<typeof on_export_error>>[0]) =>
93
102
  on_export_error?.(event),
94
103
  onKeyBindingsChange: (event: Parameters<NonNullable<typeof on_key_bindings_change>>[0]) =>
@@ -103,7 +112,7 @@ const lifetime = createAdapterGridController(handlers, {
103
112
  grid = next_grid ?? undefined;
104
113
  },
105
114
  setInitializationState(state) {
106
- loading = state !== "ready";
115
+ initialization_state = state;
107
116
  },
108
117
  reportConsumerFailure(thrown) {
109
118
  reportError(thrown);
@@ -136,6 +145,14 @@ $effect(() => {
136
145
  $effect(() => () => untrack(() => lifetime.unmount()));
137
146
 
138
147
  let sizing = $derived(gridSizeStyle({ height, fill }));
148
+ // The built-in skeleton, sized from the grid's options, when no fallback replaces it.
149
+ let skeleton_style = $derived(
150
+ fallback || !skeleton || initialization_state === "error"
151
+ ? null
152
+ : Object.entries(gridSkeletonStyle({ workbook, theme, config, presentation }))
153
+ .map(([name, value]) => `${name}:${value}`)
154
+ .join(";"),
155
+ );
139
156
  </script>
140
157
 
141
158
  <div
@@ -146,5 +163,13 @@ let sizing = $derived(gridSizeStyle({ height, fill }));
146
163
  style:height={sizing.height}
147
164
  style:min-height={sizing.minHeight}
148
165
  >
149
- {#if loading && fallback}{@render fallback()}{/if}
166
+ {#if initialization_state !== "ready" && (fallback || skeleton_style !== null)}
167
+ <div class="sheetwrite-fallback">
168
+ {#if fallback}{@render fallback()}{:else}<div
169
+ class="sheetwrite-skeleton"
170
+ aria-hidden="true"
171
+ style={skeleton_style}
172
+ ></div>{/if}
173
+ </div>
174
+ {/if}
150
175
  </div>
package/src/props.ts CHANGED
@@ -61,8 +61,14 @@ export interface SheetwriteGridProps<Id extends RowBridgeId = RowBridgeId>
61
61
  height?: number | string;
62
62
  /** Fills the parent's available size. */
63
63
  fill?: true;
64
- /** Content shown until initialization succeeds. */
64
+ /**
65
+ * Content that covers the host while WASM loads and until the grid's first
66
+ * frame is painted, then fades out; also shown when initialization fails.
67
+ * Without it the adapter shows the built-in skeleton.
68
+ */
65
69
  fallback?: Snippet;
70
+ /** `false` shows nothing instead of the built-in skeleton while the grid loads. */
71
+ skeleton?: boolean;
66
72
  /** Bindable live Grid, cleared on reset or unmount. */
67
73
  grid?: Grid;
68
74
  }