@invopop/popui 0.0.18 → 0.0.19
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/dist/BaseTable.svelte
CHANGED
|
@@ -74,6 +74,13 @@ function unselectRow(row) {
|
|
|
74
74
|
lastSelected = {};
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
function toggleRow(row) {
|
|
78
|
+
if (selectedRows.find((r) => r[selectedTrackedBy] === row[selectedTrackedBy])) {
|
|
79
|
+
unselectRow(row);
|
|
80
|
+
} else {
|
|
81
|
+
selectRow(row);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
77
84
|
function selectRange(to) {
|
|
78
85
|
if (lastSelectedIndex < 0)
|
|
79
86
|
return;
|
|
@@ -95,6 +102,10 @@ function selectRange(to) {
|
|
|
95
102
|
lastSelected = {}
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
if ((event.code === 'Space' || event.key === ' ') && lastSelected) {
|
|
106
|
+
toggleRow(lastSelected)
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
metaKeyPressed = event.metaKey
|
|
99
110
|
shiftKeyPressed = event.shiftKey
|
|
100
111
|
|
|
@@ -111,41 +122,49 @@ function selectRange(to) {
|
|
|
111
122
|
}
|
|
112
123
|
|
|
113
124
|
if (event.key === 'ArrowUp') {
|
|
114
|
-
if (!shiftKeyPressed) return
|
|
115
125
|
const toIndex = lastSelectedIndex - 1
|
|
116
126
|
const to = flattedData[toIndex]
|
|
117
127
|
|
|
118
128
|
if (!to) return
|
|
119
129
|
|
|
130
|
+
const previousSelected = { ...lastSelected }
|
|
131
|
+
lastSelected = to
|
|
132
|
+
|
|
133
|
+
if (!shiftKeyPressed) return
|
|
134
|
+
|
|
120
135
|
if (toIndex < selectWithArrowPosition) {
|
|
136
|
+
selectRow(previousSelected)
|
|
121
137
|
selectRow(to)
|
|
122
138
|
} else {
|
|
123
139
|
unselectRow(lastSelected)
|
|
124
140
|
}
|
|
125
|
-
|
|
126
|
-
lastSelected = to
|
|
127
141
|
}
|
|
128
142
|
|
|
129
143
|
if (event.key === 'ArrowDown') {
|
|
130
144
|
if (lastSelectedIndex < 0) {
|
|
131
|
-
|
|
145
|
+
if (shiftKeyPressed) {
|
|
146
|
+
selectRow(flattedData[0])
|
|
147
|
+
}
|
|
132
148
|
lastSelected = flattedData[0]
|
|
149
|
+
return
|
|
133
150
|
}
|
|
134
151
|
|
|
135
|
-
if (!shiftKeyPressed) return
|
|
136
|
-
|
|
137
152
|
const toIndex = lastSelectedIndex + 1
|
|
138
153
|
const to = flattedData[toIndex]
|
|
139
154
|
|
|
140
155
|
if (!to) return
|
|
141
156
|
|
|
157
|
+
const previousSelected = { ...lastSelected }
|
|
158
|
+
lastSelected = to
|
|
159
|
+
|
|
160
|
+
if (!shiftKeyPressed) return
|
|
161
|
+
|
|
142
162
|
if (toIndex > selectWithArrowPosition) {
|
|
163
|
+
selectRow(previousSelected)
|
|
143
164
|
selectRow(to)
|
|
144
165
|
} else {
|
|
145
166
|
unselectRow(lastSelected)
|
|
146
167
|
}
|
|
147
|
-
|
|
148
|
-
lastSelected = to
|
|
149
168
|
}
|
|
150
169
|
}}
|
|
151
170
|
on:keyup={(event) => {
|
|
@@ -227,6 +246,7 @@ function selectRange(to) {
|
|
|
227
246
|
{selectable}
|
|
228
247
|
{selectedRows}
|
|
229
248
|
{selectedTrackedBy}
|
|
249
|
+
selected={lastSelected && row[selectedTrackedBy] === lastSelected[selectedTrackedBy]}
|
|
230
250
|
on:click={() => {
|
|
231
251
|
if (disableRowClick) return
|
|
232
252
|
|
package/dist/BaseTableRow.svelte
CHANGED
|
@@ -12,6 +12,7 @@ export let fields = [];
|
|
|
12
12
|
export let disableRowClick = false;
|
|
13
13
|
export let freeWrap = false;
|
|
14
14
|
export let selectable = false;
|
|
15
|
+
export let selected = false;
|
|
15
16
|
export let selectedTrackedBy = "id";
|
|
16
17
|
export let selectedRows = [];
|
|
17
18
|
$:
|
|
@@ -24,7 +25,7 @@ $:
|
|
|
24
25
|
return field === row[selectedTrackedBy];
|
|
25
26
|
});
|
|
26
27
|
$:
|
|
27
|
-
if (
|
|
28
|
+
if (selected) {
|
|
28
29
|
scrollIntoView();
|
|
29
30
|
}
|
|
30
31
|
function scrollIntoView() {
|
|
@@ -34,7 +35,8 @@ function scrollIntoView() {
|
|
|
34
35
|
|
|
35
36
|
<tr
|
|
36
37
|
class:cursor-pointer={!disableRowClick}
|
|
37
|
-
class:bg-
|
|
38
|
+
class:bg-neutral-50={selected}
|
|
39
|
+
class:bg-workspace-accent-50={checked && !selected}
|
|
38
40
|
class="hover:bg-neutral-50"
|
|
39
41
|
on:click
|
|
40
42
|
on:contextmenu|preventDefault={() => {
|
|
@@ -8,6 +8,7 @@ declare const __propDef: {
|
|
|
8
8
|
disableRowClick?: boolean | undefined;
|
|
9
9
|
freeWrap?: boolean | undefined;
|
|
10
10
|
selectable?: boolean | undefined;
|
|
11
|
+
selected?: boolean | undefined;
|
|
11
12
|
selectedTrackedBy?: string | undefined;
|
|
12
13
|
selectedRows?: TableDataRow[] | undefined;
|
|
13
14
|
};
|
package/dist/helpers.js
CHANGED
|
@@ -59,15 +59,16 @@ export function scrollIntoTableView(element) {
|
|
|
59
59
|
const elementBottom = elementRect.bottom - containerRect.top + container.scrollTop;
|
|
60
60
|
const isAboveView = elementTop - offsetTop < container.scrollTop;
|
|
61
61
|
const isBelowView = elementBottom + offset > container.scrollTop + container.clientHeight;
|
|
62
|
-
if (
|
|
62
|
+
if (isBelowView) {
|
|
63
63
|
container.scrollTo({
|
|
64
|
-
top:
|
|
64
|
+
top: elementBottom - container.clientHeight + offset,
|
|
65
65
|
behavior: 'smooth'
|
|
66
66
|
});
|
|
67
|
+
return;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
if (isAboveView) {
|
|
69
70
|
container.scrollTo({
|
|
70
|
-
top:
|
|
71
|
+
top: elementTop - offsetTop,
|
|
71
72
|
behavior: 'smooth'
|
|
72
73
|
});
|
|
73
74
|
}
|