@poirazis/supercomponents-shared 1.0.9 → 1.0.18
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/index.js +6975 -6106
- package/dist/index.umd.cjs +11 -11
- package/dist/style.css +1 -1
- package/package.json +4 -3
- package/src/index.js +1 -0
- package/src/index.ts +1 -0
- package/src/lib/SuperForm/InnerForm.svelte +511 -0
- package/src/lib/SuperForm/SuperForm.svelte +145 -0
- package/src/lib/SuperTable/SuperTable.svelte +17 -35
- package/src/lib/SuperTableCells/CellCommon.css +2 -0
- package/src/lib/SuperTableCells/CellIcon.svelte +0 -1
- package/src/lib/SuperTableCells/CellString.svelte +12 -1
- package/src/lib/SuperTableCells/CellStringSimple.svelte +2 -2
- package/src/lib/SuperTableColumn/parts/SuperColumnBody.svelte +1 -1
- package/src/lib/SuperTableColumn/parts/SuperColumnRow.svelte +15 -8
@@ -3,6 +3,7 @@
|
|
3
3
|
import fsm from "svelte-fsm";
|
4
4
|
import { writable } from "svelte/store";
|
5
5
|
|
6
|
+
import "./SuperTable.css";
|
6
7
|
import {
|
7
8
|
sizingMap,
|
8
9
|
defaultOperatorMap,
|
@@ -290,11 +291,14 @@
|
|
290
291
|
$: cumulativeHeights = derivedMemo(
|
291
292
|
[stbRowMetadata, stbSettings],
|
292
293
|
([$meta, $settings]) => {
|
293
|
-
const defaultRowHeight = $settings.appearance?.rowHeight || 36;
|
294
|
+
const defaultRowHeight = $settings.appearance?.rowHeight || 36;
|
294
295
|
return $meta.map((_, i) =>
|
295
296
|
$meta
|
296
297
|
.slice(0, i + 1)
|
297
|
-
.reduce(
|
298
|
+
.reduce(
|
299
|
+
(sum, meta) => sum + Math.max(meta.height || defaultRowHeight, 0),
|
300
|
+
0
|
301
|
+
)
|
298
302
|
);
|
299
303
|
}
|
300
304
|
);
|
@@ -703,11 +707,10 @@
|
|
703
707
|
if (!rows?.length || !viewport || !$cumulativeHeights.length) return;
|
704
708
|
|
705
709
|
const defaultRowHeight = $stbSettings.appearance.rowHeight;
|
706
|
-
let start =
|
707
|
-
|
708
|
-
let end = 0;
|
710
|
+
let start = 0,
|
711
|
+
end = rows.length;
|
709
712
|
|
710
|
-
// Find start index
|
713
|
+
// Find start index
|
711
714
|
for (let i = 0; i < rows.length; i++) {
|
712
715
|
if ($cumulativeHeights[i] > $stbScrollPos) {
|
713
716
|
start = i;
|
@@ -715,45 +718,30 @@
|
|
715
718
|
}
|
716
719
|
}
|
717
720
|
|
718
|
-
// Find end index
|
721
|
+
// Find end index
|
719
722
|
for (let i = start; i < rows.length; i++) {
|
720
|
-
if (
|
721
|
-
$cumulativeHeights[i] >=
|
722
|
-
$stbScrollPos + maxBodyHeight - defaultRowHeight
|
723
|
-
) {
|
723
|
+
if ($cumulativeHeights[i] >= $stbScrollPos + maxBodyHeight) {
|
724
724
|
end = i + 1;
|
725
725
|
break;
|
726
726
|
}
|
727
727
|
}
|
728
728
|
|
729
|
-
// Ensure all rows are included when at the bottom
|
730
|
-
end = end || rows.length;
|
731
|
-
|
732
729
|
// Update visible rows
|
733
730
|
$stbVisibleRows = $stbData?.rows
|
734
|
-
|
731
|
+
.slice(start, end)
|
735
732
|
.map((_, i) => i + start);
|
736
733
|
|
737
|
-
// Calculate scroll offset
|
734
|
+
// Calculate scroll offset
|
738
735
|
const startHeight = start > 0 ? $cumulativeHeights[start - 1] : 0;
|
739
736
|
$stbScrollOffset = $stbScrollPos - startHeight;
|
740
737
|
|
741
|
-
//
|
742
|
-
if ($stbScrollPos >= scrollHeight - maxBodyHeight) {
|
743
|
-
$stbScrollPos = Math.max(0, scrollHeight - maxBodyHeight);
|
744
|
-
$stbScrollOffset = Math.min(
|
745
|
-
$stbScrollOffset,
|
746
|
-
maxBodyHeight - defaultRowHeight
|
747
|
-
);
|
748
|
-
}
|
749
|
-
|
750
|
-
// Fetch more rows if nearing the end of loaded data
|
738
|
+
// Fetch more rows if nearing the end
|
751
739
|
if (fetchOnScroll && rows.length > 0) {
|
752
740
|
const loadedHeight = $cumulativeHeights[rows.length - 1];
|
753
741
|
const remainingHeight =
|
754
742
|
loadedHeight - ($stbScrollPos + maxBodyHeight);
|
755
|
-
if (remainingHeight < maxBodyHeight && rows.length
|
756
|
-
stbState.fetchMoreRows.debounce(200, 100); // Debounced fetch
|
743
|
+
if (remainingHeight < maxBodyHeight && rows.length === _limit) {
|
744
|
+
stbState.fetchMoreRows.debounce(200, 100); // Debounced fetch
|
757
745
|
}
|
758
746
|
}
|
759
747
|
},
|
@@ -769,11 +757,7 @@
|
|
769
757
|
scrollHeight > maxBodyHeight
|
770
758
|
? $stbScrollPos / (scrollHeight - maxBodyHeight)
|
771
759
|
: 0;
|
772
|
-
|
773
|
-
$stbScrollPos % $stbSettings.appearance.rowHeight
|
774
|
-
);
|
775
|
-
|
776
|
-
this.calculateRowBoundaries.debounce(1);
|
760
|
+
window.requestAnimationFrame(() => this.calculateRowBoundaries());
|
777
761
|
},
|
778
762
|
handleWheel(e) {
|
779
763
|
if ($stbState == "Inserting") {
|
@@ -1194,8 +1178,6 @@
|
|
1194
1178
|
$: console.log("Table Filters : ", stbColumnFilters);
|
1195
1179
|
$: console.log("Table Settings : ", $stbSettings);
|
1196
1180
|
*/
|
1197
|
-
|
1198
|
-
$: console.log($stbSchema);
|
1199
1181
|
</script>
|
1200
1182
|
|
1201
1183
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
@@ -205,6 +205,8 @@
|
|
205
205
|
color: var(--spectrum-global-color-gray-800);
|
206
206
|
border: 1px solid var(--spectrum-global-color-gray-300);
|
207
207
|
background: var(--spectrum-global-color-gray-50);
|
208
|
+
min-height: 2rem;
|
209
|
+
max-height: 2rem;
|
208
210
|
|
209
211
|
&:focus-within {
|
210
212
|
border: 1px solid var(--spectrum-global-color-blue-400) !important;
|
@@ -1,5 +1,10 @@
|
|
1
1
|
<script>
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
createEventDispatcher,
|
4
|
+
getContext,
|
5
|
+
onMount,
|
6
|
+
onDestroy,
|
7
|
+
} from "svelte";
|
3
8
|
import fsm from "svelte-fsm";
|
4
9
|
const dispatch = createEventDispatcher();
|
5
10
|
const { processStringSync } = getContext("sdk");
|
@@ -28,6 +33,7 @@
|
|
28
33
|
reset() {
|
29
34
|
localValue = value;
|
30
35
|
lastEdit = undefined;
|
36
|
+
return "View";
|
31
37
|
},
|
32
38
|
},
|
33
39
|
View: {
|
@@ -109,6 +115,11 @@
|
|
109
115
|
cellState.focus();
|
110
116
|
}, 50);
|
111
117
|
});
|
118
|
+
|
119
|
+
onDestroy(() => {
|
120
|
+
clearTimeout(timer);
|
121
|
+
cellState.reset();
|
122
|
+
});
|
112
123
|
</script>
|
113
124
|
|
114
125
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
@@ -11,11 +11,11 @@
|
|
11
11
|
};
|
12
12
|
|
13
13
|
$: formattedValue =
|
14
|
-
|
14
|
+
cellOptions?.template
|
15
15
|
? processStringSync(cellOptions.template, {
|
16
16
|
value,
|
17
17
|
})
|
18
|
-
:
|
18
|
+
: undefined;;
|
19
19
|
|
20
20
|
$: placeholder =
|
21
21
|
cellOptions.readonly || cellOptions.disabled
|
@@ -1,7 +1,13 @@
|
|
1
1
|
<script>
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
getContext,
|
4
|
+
createEventDispatcher,
|
5
|
+
onMount,
|
6
|
+
tick,
|
7
|
+
onDestroy,
|
8
|
+
} from "svelte";
|
3
9
|
|
4
|
-
const { Provider,
|
10
|
+
const { Provider, ContextScopes } = getContext("sdk");
|
5
11
|
|
6
12
|
const dispatch = createEventDispatcher();
|
7
13
|
const columnSettings = getContext("stColumnOptions");
|
@@ -10,6 +16,7 @@
|
|
10
16
|
const rowMetadata = getContext("stbRowMetadata");
|
11
17
|
const stbHovered = getContext("stbHovered");
|
12
18
|
const stbSelected = getContext("stbSelected");
|
19
|
+
const stbEditing = getContext("stbEditing");
|
13
20
|
const stbAPI = getContext("stbAPI");
|
14
21
|
const stbState = getContext("stbState");
|
15
22
|
const stbMenuID = getContext("stbMenuID");
|
@@ -34,12 +41,6 @@
|
|
34
41
|
$: isSelected = $stbSelected.includes(id);
|
35
42
|
$: hasChildren = $columnSettings.hasChildren > 0;
|
36
43
|
|
37
|
-
const getCellValue = (value) => {
|
38
|
-
return $columnSettings.template
|
39
|
-
? processStringSync($columnSettings.template, { value })
|
40
|
-
: undefined;
|
41
|
-
};
|
42
|
-
|
43
44
|
const patchRow = async (change) => {
|
44
45
|
let patch = {
|
45
46
|
...row,
|
@@ -88,6 +89,12 @@
|
|
88
89
|
} else return obj[path] ?? undefined;
|
89
90
|
};
|
90
91
|
onMount(() => (mounted = $columnSettings.superColumn));
|
92
|
+
|
93
|
+
onDestroy(() => {
|
94
|
+
if ($stbEditing == index) {
|
95
|
+
columnState.exitedit();
|
96
|
+
}
|
97
|
+
});
|
91
98
|
</script>
|
92
99
|
|
93
100
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|