wx-svelte-grid 2.5.0 → 2.5.1
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 +10 -10
- package/src/components/Cell.svelte +3 -2
- package/src/components/HeaderCell.svelte +4 -3
- package/src/components/Layout.svelte +17 -15
- package/src/components/Tooltip.svelte +3 -2
- package/src/components/print/HeaderFooter.svelte +1 -1
- package/src/helpers/actions/reorder.js +1 -5
- package/whatsnew.md +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wx-svelte-grid",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "A fast, feature-rich Svelte DataGrid component",
|
|
5
5
|
"productTag": "grid",
|
|
6
6
|
"productTrial": false,
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://svar.dev/svelte/datagrid/",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@svar-ui/lib-dom": "0.
|
|
36
|
+
"@svar-ui/lib-dom": "0.12.0",
|
|
37
37
|
"@svar-ui/lib-state": "1.9.6",
|
|
38
38
|
"@svar-ui/lib-svelte": "0.5.2",
|
|
39
|
-
"@svar-ui/svelte-menu": "2.4.
|
|
40
|
-
"@svar-ui/svelte-core": "2.4.
|
|
41
|
-
"@svar-ui/svelte-toolbar": "2.4.
|
|
42
|
-
"@svar-ui/grid-data-provider": "2.5.
|
|
43
|
-
"@svar-ui/grid-locales": "2.5.
|
|
44
|
-
"@svar-ui/grid-store": "2.5.
|
|
39
|
+
"@svar-ui/svelte-menu": "2.4.2",
|
|
40
|
+
"@svar-ui/svelte-core": "2.4.1",
|
|
41
|
+
"@svar-ui/svelte-toolbar": "2.4.1",
|
|
42
|
+
"@svar-ui/grid-data-provider": "2.5.1",
|
|
43
|
+
"@svar-ui/grid-locales": "2.5.1",
|
|
44
|
+
"@svar-ui/grid-store": "2.5.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@svar-ui/svelte-editor": "2.4.
|
|
48
|
-
"@svar-ui/svelte-filter": "2.4.
|
|
47
|
+
"@svar-ui/svelte-editor": "2.4.1",
|
|
48
|
+
"@svar-ui/svelte-filter": "2.4.2"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"src",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { onDestroy, getContext, untrack } from "svelte";
|
|
3
3
|
import { getStyle } from "../helpers/columnWidth";
|
|
4
4
|
import { getRenderValue } from "@svar-ui/grid-store";
|
|
5
|
+
import { setID } from "@svar-ui/lib-dom";
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
row,
|
|
@@ -95,8 +96,8 @@
|
|
|
95
96
|
onfocus={toggleFocusAction}
|
|
96
97
|
class:wx-fixed-right={column.fixed && column.fixed.right}
|
|
97
98
|
{style}
|
|
98
|
-
data-row-id={row.id}
|
|
99
|
-
data-col-id={column.id}
|
|
99
|
+
data-row-id={setID(row.id)}
|
|
100
|
+
data-col-id={setID(column.id)}
|
|
100
101
|
tabindex={focusable ? "0" : "-1"}
|
|
101
102
|
role={"gridcell"}
|
|
102
103
|
aria-colindex={column._colindex}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { resize } from "../helpers/actions/resize";
|
|
4
4
|
import { getCssName, getStyle } from "../helpers/columnWidth";
|
|
5
5
|
import Filter from "./inlineFilters/Filter.svelte";
|
|
6
|
+
import { setID } from "@svar-ui/lib-dom";
|
|
6
7
|
|
|
7
8
|
let {
|
|
8
9
|
cell,
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
}
|
|
50
51
|
api.exec("sort-rows", {
|
|
51
52
|
key: cell.id,
|
|
52
|
-
add: ev.ctrlKey,
|
|
53
|
+
add: ev.ctrlKey || ev.metaKey,
|
|
53
54
|
order: sortMark?.order,
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
tabindex="0"
|
|
107
108
|
onkeydown={toggleCollapseColumn}
|
|
108
109
|
onclick={collapse}
|
|
109
|
-
data-header-id={column.id}
|
|
110
|
+
data-header-id={setID(column.id)}
|
|
110
111
|
>
|
|
111
112
|
<div class="wx-text" style={collapsedTextStyle}>
|
|
112
113
|
{cell.text || ""}
|
|
@@ -121,7 +122,7 @@
|
|
|
121
122
|
class:wx-fixed-right={column.fixed && column.fixed.right}
|
|
122
123
|
{style}
|
|
123
124
|
onclick={sort}
|
|
124
|
-
data-header-id={column.id}
|
|
125
|
+
data-header-id={setID(column.id)}
|
|
125
126
|
tabindex={!cell._hidden && column.sort && !cell.filter
|
|
126
127
|
? "0"
|
|
127
128
|
: undefined}
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
import {
|
|
10
10
|
clickOutside,
|
|
11
11
|
delegateClick,
|
|
12
|
-
locateAttr,
|
|
13
12
|
locate,
|
|
14
|
-
|
|
13
|
+
setID,
|
|
14
|
+
locateID,
|
|
15
|
+
getID,
|
|
15
16
|
} from "@svar-ui/lib-dom";
|
|
16
17
|
|
|
17
18
|
import { hotkeys, defaultHotkeys } from "@svar-ui/grid-store";
|
|
@@ -410,12 +411,12 @@
|
|
|
410
411
|
|
|
411
412
|
const bodyClickHandlers = {
|
|
412
413
|
dblclick: (id, ev) => {
|
|
413
|
-
const data = { id, column:
|
|
414
|
+
const data = { id, column: locateID(ev, "data-col-id") };
|
|
414
415
|
api.exec("open-editor", data);
|
|
415
416
|
},
|
|
416
417
|
click: (id, ev) => {
|
|
417
418
|
if (postDrag) return;
|
|
418
|
-
const column =
|
|
419
|
+
const column = locateID(ev, "data-col-id");
|
|
419
420
|
if ($focusCell?.id !== id)
|
|
420
421
|
api.exec("focus-cell", {
|
|
421
422
|
row: id,
|
|
@@ -425,7 +426,7 @@
|
|
|
425
426
|
|
|
426
427
|
if ($select === false) return;
|
|
427
428
|
|
|
428
|
-
const toggle = multiselect && ev.ctrlKey;
|
|
429
|
+
const toggle = multiselect && (ev.ctrlKey || ev.metaKey);
|
|
429
430
|
const range = multiselect && ev.shiftKey;
|
|
430
431
|
|
|
431
432
|
if (
|
|
@@ -467,11 +468,11 @@
|
|
|
467
468
|
|
|
468
469
|
dragItem = from;
|
|
469
470
|
|
|
470
|
-
if (api.getRow(dragItem).open)
|
|
471
|
+
if ($tree && api.getRow(dragItem).open)
|
|
471
472
|
api.exec("close-row", { id: dragItem, nested: true });
|
|
472
473
|
|
|
473
474
|
// default to drag source (target may be shifted by this moment)
|
|
474
|
-
const itemNode = locate(sourceNode
|
|
475
|
+
const itemNode = locate(sourceNode);
|
|
475
476
|
dragNode = itemNode.cloneNode(true);
|
|
476
477
|
dragNode.classList.remove("wx-selected");
|
|
477
478
|
dragNode
|
|
@@ -521,8 +522,8 @@
|
|
|
521
522
|
}
|
|
522
523
|
|
|
523
524
|
if (tableNode.contains(context.targetNode)) {
|
|
524
|
-
const targetRow = locate(context.targetNode
|
|
525
|
-
const to =
|
|
525
|
+
const targetRow = locate(context.targetNode);
|
|
526
|
+
const to = targetRow && getID(targetRow);
|
|
526
527
|
|
|
527
528
|
if (to && to !== from) {
|
|
528
529
|
context.to = to;
|
|
@@ -675,9 +676,9 @@
|
|
|
675
676
|
!focus ||
|
|
676
677
|
(visibleSelection.length &&
|
|
677
678
|
!visibleSelection.includes(focus.row)) ||
|
|
678
|
-
dataRows.findIndex(r => r.id
|
|
679
|
+
dataRows.findIndex(r => r.id === focus.row) === -1 ||
|
|
679
680
|
renderColumns.data.findIndex(
|
|
680
|
-
c => c.id
|
|
681
|
+
c => c.id === focus.column && !c.collapsed
|
|
681
682
|
) === -1
|
|
682
683
|
) {
|
|
683
684
|
const row = visibleSelection[0] || dataRows[0].id;
|
|
@@ -753,6 +754,7 @@
|
|
|
753
754
|
style="width:{contentWidth}px;height:{fullHeight}px;"
|
|
754
755
|
onmousedown={ev => lockSelection(ev)}
|
|
755
756
|
use:clickOutside={() =>
|
|
757
|
+
$focusCell &&
|
|
756
758
|
api.exec("focus-cell", { eventSource: "click" })}
|
|
757
759
|
use:delegateClick={bodyClickHandlers}
|
|
758
760
|
>
|
|
@@ -771,8 +773,8 @@
|
|
|
771
773
|
class:wx-autoheight={autoRowHeight}
|
|
772
774
|
class={"wx-row" +
|
|
773
775
|
(rowStyle ? " " + rowStyle(row) : "")}
|
|
774
|
-
data-id={row.id}
|
|
775
|
-
data-context-id={row.id}
|
|
776
|
+
data-id={setID(row.id)}
|
|
777
|
+
data-context-id={setID(row.id)}
|
|
776
778
|
class:wx-selected={isSelected}
|
|
777
779
|
class:wx-inactive={dragItem === row.id}
|
|
778
780
|
style={`${autoRowHeight ? "min-height" : "height"}:${row.rowHeight || defaultRowHeight}px;`}
|
|
@@ -786,7 +788,7 @@
|
|
|
786
788
|
{#each renderColumns.data as column (column.id)}
|
|
787
789
|
{#if column.collapsed}
|
|
788
790
|
<div class="wx-cell wx-collapsed"></div>
|
|
789
|
-
{:else if $editor?.id === row.id && $editor.column
|
|
791
|
+
{:else if $editor?.id === row.id && $editor.column === column.id}
|
|
790
792
|
<Editor {row} {column} />
|
|
791
793
|
{:else}
|
|
792
794
|
<Cell
|
|
@@ -796,7 +798,7 @@
|
|
|
796
798
|
{cellStyle}
|
|
797
799
|
{reorder}
|
|
798
800
|
focusable={focus?.row === row.id &&
|
|
799
|
-
focus?.column
|
|
801
|
+
focus?.column === column.id}
|
|
800
802
|
/>
|
|
801
803
|
{/if}
|
|
802
804
|
{/each}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { getRenderValue } from "@svar-ui/grid-store";
|
|
3
|
+
import { getID } from "@svar-ui/lib-dom";
|
|
3
4
|
|
|
4
5
|
let { content: Content = null, api, children } = $props();
|
|
5
6
|
|
|
@@ -12,8 +13,8 @@
|
|
|
12
13
|
function findAttribute(node) {
|
|
13
14
|
while (node) {
|
|
14
15
|
if (node.getAttribute) {
|
|
15
|
-
const id = node
|
|
16
|
-
const colId = node
|
|
16
|
+
const id = getID(node, "data-row-id");
|
|
17
|
+
const colId = getID(node, "data-col-id");
|
|
17
18
|
if (id && api && colId) {
|
|
18
19
|
const col = api.getColumn(colId);
|
|
19
20
|
return { id, col, target: node };
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{#each columns as row, i}
|
|
16
16
|
<tr>
|
|
17
17
|
{#each row as cell (cell.id)}
|
|
18
|
-
{@const column = _columns.find(c => c.id
|
|
18
|
+
{@const column = _columns.find(c => c.id === cell.id)}
|
|
19
19
|
<th
|
|
20
20
|
style={getPrintCellStyle(cell, sizes.columnWidth)}
|
|
21
21
|
class="wx-print-cell-{type} {getColumnCss(column)}"
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { locate,
|
|
1
|
+
import { locate, getID } from "@svar-ui/lib-dom";
|
|
2
2
|
|
|
3
3
|
const SHIFT = 5;
|
|
4
4
|
const LONG_TOUCH_DELAY = 700;
|
|
5
5
|
|
|
6
|
-
function getID(node) {
|
|
7
|
-
return id(node.getAttribute("data-id"));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
export function getOffset(node) {
|
|
11
7
|
const box = node.getBoundingClientRect();
|
|
12
8
|
const body = document.body;
|