@guiexpert/svelte-table 5.1.91 → 5.1.93

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.
@@ -4,6 +4,7 @@
4
4
  Shipped as Svelte source (not pre-compiled), so it is compiled by YOUR Svelte compiler and works with
5
5
  Svelte 4 and Svelte 5. Written in plain JS (types in GuiexpertTable.svelte.d.ts) – no preprocessor needed.
6
6
 
7
+ `loading` (boolean) shows the loading overlay without re-creating the table.
7
8
  Events: listen with `on:tableReady` / `on:mouseClicked` … (event payload in `e.detail`) or pass callback
8
9
  props `onTableReady` / `onMouseClicked` … (payload directly; use these in Svelte 5 runes mode).
9
10
  A new `tableModel` or `tableOptions` object re-creates the table (the previous one is destroyed).
@@ -18,6 +19,12 @@
18
19
  export let tableOptions = undefined;
19
20
  /** @type {string | undefined} */
20
21
  export let licenseKey = undefined;
22
+ /**
23
+ * `true` shows the loading overlay ("Loading…" with a CSS spinner) over the body, `false` hides it –
24
+ * without re-creating the table (since 1.1.92).
25
+ * @type {boolean}
26
+ */
27
+ export let loading = false;
21
28
 
22
29
  /** @type {((api: import("@guiexpert/table").TableApi) => void) | undefined} */
23
30
  export let onTableReady = undefined;
@@ -41,6 +48,11 @@
41
48
  export let onFocusChanged = undefined;
42
49
  /** @type {((evt: import("@guiexpert/table").GeScrollEvent) => void) | undefined} */
43
50
  export let onScroll = undefined;
51
+ /**
52
+ * The state changed (column layout, sorting, scroll position …) – since 1.1.92.
53
+ * @type {((evt: import("@guiexpert/table").GeStateChangeEvent) => void) | undefined}
54
+ */
55
+ export let onStateChanged = undefined;
44
56
 
45
57
  const dispatch = createEventDispatcher();
46
58
 
@@ -61,7 +73,8 @@
61
73
  onMouseDragging: (evt) => { dispatch("mouseDragging", evt); onMouseDragging?.(evt); },
62
74
  onMouseDraggingEnd: (evt) => { dispatch("mouseDraggingEnd", evt); onMouseDraggingEnd?.(evt); },
63
75
  onMouseMoved: (evt) => { dispatch("mouseMoved", evt); onMouseMoved?.(evt); },
64
- onScroll: (evt) => { dispatch("scroll", evt); onScroll?.(evt); }
76
+ onScroll: (evt) => { dispatch("scroll", evt); onScroll?.(evt); },
77
+ onStateChanged: (evt) => { dispatch("stateChanged", evt); onStateChanged?.(evt); }
65
78
  };
66
79
 
67
80
  /**
@@ -76,11 +89,27 @@
76
89
  }
77
90
  tableScope = new TableScope(root, model, new SimpleDomService(), options ?? new TableOptions(), listener);
78
91
  tableScope.firstInit();
92
+ shownByProp = false;
93
+ applyLoading(loading); // a re-created table keeps showing the overlay
79
94
  const api = tableScope.getApi();
80
95
  dispatch("tableReady", api);
81
96
  onTableReady?.(api);
82
97
  }
83
98
 
99
+ // loading={false} hides only an overlay the prop showed (not one the app showed itself)
100
+ let shownByProp = false;
101
+
102
+ /** @param {boolean} show */
103
+ function applyLoading(show) {
104
+ if (show) {
105
+ tableScope?.showLoadingOverlay();
106
+ shownByProp = true;
107
+ } else if (shownByProp) {
108
+ tableScope?.hideOverlay();
109
+ shownByProp = false;
110
+ }
111
+ }
112
+
84
113
  onMount(() => {
85
114
  mounted = true;
86
115
  });
@@ -93,6 +122,9 @@
93
122
  // runs after mount and whenever a new tableModel / tableOptions object arrives
94
123
  $: if (mounted) init(tableModel, tableOptions);
95
124
 
125
+ // the loading prop: only shows/hides the overlay (depends on `loading` only, no re-creation)
126
+ $: applyLoading(loading);
127
+
96
128
  $: if (licenseKey) LicenseManager.getInstance().setLicenseKey(licenseKey);
97
129
  </script>
98
130
 
@@ -4,6 +4,7 @@ import type {
4
4
  GeModelChangeEvent,
5
5
  GeMouseEvent,
6
6
  GeScrollEvent,
7
+ GeStateChangeEvent,
7
8
  SelectionModelIf,
8
9
  TableApi,
9
10
  TableModelIf,
@@ -14,6 +15,8 @@ export interface GuiexpertTableProps {
14
15
  tableModel: TableModelIf;
15
16
  tableOptions?: TableOptionsIf;
16
17
  licenseKey?: string;
18
+ /** `true` shows the loading overlay ("Loading…"), `false` hides it – no re-creation of the table. @since 1.1.92 */
19
+ loading?: boolean;
17
20
  /** Callback props – alternative to `on:…` (required in Svelte 5 runes mode). */
18
21
  onTableReady?: (api: TableApi) => void;
19
22
  onMouseClicked?: (evt: GeMouseEvent) => void;
@@ -26,6 +29,8 @@ export interface GuiexpertTableProps {
26
29
  onSelectionChanged?: (model: SelectionModelIf) => void;
27
30
  onFocusChanged?: (model: FocusModelIf) => void;
28
31
  onScroll?: (evt: GeScrollEvent) => void;
32
+ /** The state changed (column layout, sorting, scroll position …). @since 1.1.92 */
33
+ onStateChanged?: (evt: GeStateChangeEvent) => void;
29
34
  }
30
35
 
31
36
  export interface GuiexpertTableEvents {
@@ -40,6 +45,8 @@ export interface GuiexpertTableEvents {
40
45
  selectionChanged: CustomEvent<SelectionModelIf>;
41
46
  focusChanged: CustomEvent<FocusModelIf>;
42
47
  scroll: CustomEvent<GeScrollEvent>;
48
+ /** @since 1.1.92 */
49
+ stateChanged: CustomEvent<GeStateChangeEvent>;
43
50
  }
44
51
 
45
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guiexpert/svelte-table",
3
- "version": "5.1.91",
3
+ "version": "5.1.93",
4
4
  "license": "MIT",
5
5
  "author": "Dr. Marc Kronberg <info@gui.expert> (https://gui.expert)",
6
6
  "repository": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "tslib": "^2.3.0",
33
- "@guiexpert/table": "^1.1.91"
33
+ "@guiexpert/table": "^1.1.93"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "svelte": "^4.0.0 || ^5.0.0"