@isoftdata/svelte-table 2.10.2 → 2.10.4
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/Table.svelte +29 -15
- package/dist/Td.svelte +14 -4
- package/dist/column-info-store.svelte.js +15 -5
- package/package.json +1 -1
package/dist/Table.svelte
CHANGED
|
@@ -859,25 +859,29 @@
|
|
|
859
859
|
|
|
860
860
|
<th
|
|
861
861
|
id="col-{tableId}-{column.property}"
|
|
862
|
+
class={[
|
|
863
|
+
'unselectable',
|
|
864
|
+
column.class,
|
|
865
|
+
{
|
|
866
|
+
'cursor-pointer': column.sortType !== false && !isArbitraryProperty(column.property),
|
|
867
|
+
'd-print-none': column.hideForPrint,
|
|
868
|
+
'text-left': !bs5 && column.align === 'left',
|
|
869
|
+
'text-start': column.align === 'start' || (bs5 && column.align === 'left'),
|
|
870
|
+
'text-right': !bs5 && (column.align === 'right' || column.numeric),
|
|
871
|
+
'text-end': column.align === 'end' || (bs5 && (column.align === 'right' || column.numeric)),
|
|
872
|
+
'text-center': column.align === 'center',
|
|
873
|
+
'text-truncate': doEllipsis,
|
|
874
|
+
'bg-white': !bs5 && stickyHeader,
|
|
875
|
+
'table-secondary': column.pinned,
|
|
876
|
+
'text-nowrap': !column.wrap,
|
|
877
|
+
pinned: column.pinned,
|
|
878
|
+
},
|
|
879
|
+
]}
|
|
862
880
|
title={column.title ?? column.name}
|
|
863
|
-
style:cursor={column.sortType !== false && !isArbitraryProperty(column.property) ? 'pointer' : ''}
|
|
864
881
|
style:width={column.userWidth ?? column.width}
|
|
865
882
|
style:min-width={column.minWidth}
|
|
866
|
-
style
|
|
867
|
-
style:left={column.pinned ? columnInfo.getPinnedColumnOffset(column.property) : undefined}
|
|
868
|
-
style:z-index={column.pinned ? 5 : undefined}
|
|
883
|
+
style:--pinned-column-offset={column.pinned ? columnInfo.getPinnedColumnOffset(column.property) : undefined}
|
|
869
884
|
data-sort-specified={isSortColumn ? sortDirection : ''}
|
|
870
|
-
class:text-nowrap={!column.wrap}
|
|
871
|
-
class="unselectable {column.class ?? ''}"
|
|
872
|
-
class:d-print-none={column.hideForPrint}
|
|
873
|
-
class:text-left={!bs5 && column.align === 'left'}
|
|
874
|
-
class:text-start={column.align === 'start' || (bs5 && column.align === 'left')}
|
|
875
|
-
class:text-right={!bs5 && (column.align === 'right' || column.numeric)}
|
|
876
|
-
class:text-end={column.align === 'end' || (bs5 && (column.align === 'right' || column.numeric))}
|
|
877
|
-
class:text-center={column.align === 'center'}
|
|
878
|
-
class:text-truncate={doEllipsis}
|
|
879
|
-
class:bg-white={!bs5 && stickyHeader}
|
|
880
|
-
class:table-secondary={column.pinned}
|
|
881
885
|
onclick={() => columnClickHandler(column)}
|
|
882
886
|
oncontextmenu={event => contextMenuHandler(event, column.property)}
|
|
883
887
|
>
|
|
@@ -1144,4 +1148,14 @@
|
|
|
1144
1148
|
.table-layout-fixed {
|
|
1145
1149
|
table-layout: fixed;
|
|
1146
1150
|
}
|
|
1151
|
+
|
|
1152
|
+
th.pinned {
|
|
1153
|
+
position: sticky;
|
|
1154
|
+
z-index: 5 !important;
|
|
1155
|
+
left: var(--pinned-column-offset, -1);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.cursor-pointer {
|
|
1159
|
+
cursor: pointer;
|
|
1160
|
+
}
|
|
1147
1161
|
</style>
|
package/dist/Td.svelte
CHANGED
|
@@ -113,14 +113,18 @@
|
|
|
113
113
|
{#if visible}
|
|
114
114
|
<svelte:element
|
|
115
115
|
this={tagName}
|
|
116
|
-
class={[
|
|
116
|
+
class={[
|
|
117
|
+
classNames,
|
|
118
|
+
alignClass,
|
|
119
|
+
{
|
|
120
|
+
pinned: thisColumnInfo?.pinned,
|
|
121
|
+
},
|
|
122
|
+
]}
|
|
117
123
|
{...rest}
|
|
118
124
|
style:font-variant-numeric={thisColumnInfo?.numeric ? 'tabular-nums' : undefined}
|
|
119
125
|
style:overflow={$columnResizingEnabled ? 'hidden' : undefined}
|
|
120
126
|
style:text-overflow={$columnResizingEnabled ? 'ellipsis' : undefined}
|
|
121
|
-
style
|
|
122
|
-
style:left={thisColumnInfo?.pinned ? columnInfo.getPinnedColumnOffset(property) : undefined}
|
|
123
|
-
style:z-index={thisColumnInfo?.pinned ? 4 : undefined}
|
|
127
|
+
style:--pinned-column-offset={thisColumnInfo?.pinned ? columnInfo.getPinnedColumnOffset(property) : undefined}
|
|
124
128
|
>
|
|
125
129
|
<!--
|
|
126
130
|
Don't listen to events that the user hasn't turned on the features for.
|
|
@@ -158,4 +162,10 @@
|
|
|
158
162
|
td:where(.text-start, .text-center, .text-end) :global(.form-check-input) {
|
|
159
163
|
float: unset;
|
|
160
164
|
}
|
|
165
|
+
|
|
166
|
+
.pinned {
|
|
167
|
+
position: sticky;
|
|
168
|
+
z-index: 4 !important;
|
|
169
|
+
left: var(--pinned-column-offset, -1);
|
|
170
|
+
}
|
|
161
171
|
</style>
|
|
@@ -71,20 +71,29 @@ export class ColumnInfoRunicStore {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
getPinnedColumnOffset(property) {
|
|
74
|
+
// When referenced in an effect, this function will re-run when pinnedColumns is updated
|
|
75
|
+
// Such as when a new columns is pinned, or a pinned column is hidden/resized or otherwise modified
|
|
74
76
|
const colIndex = this.pinnedColumns.findIndex(c => c.property === property);
|
|
75
77
|
if (colIndex === -1) {
|
|
76
|
-
console.warn(`Could not find columns ${property} in list of pinned columns: ${this.pinnedColumns.join(', ')}`);
|
|
78
|
+
console.warn(`Could not find columns "${property}" in list of pinned columns: ${this.pinnedColumns.join(', ')}`);
|
|
77
79
|
return '0px';
|
|
78
80
|
}
|
|
79
81
|
else if (colIndex === 0) {
|
|
80
82
|
return '-1px'; // Fix the gap on the left side of the first column
|
|
81
83
|
}
|
|
82
84
|
const offsetPx = this.pinnedColumns.slice(0, colIndex).reduce((acc, col) => {
|
|
83
|
-
if (col.
|
|
84
|
-
acc
|
|
85
|
+
if (!col.visible) {
|
|
86
|
+
return acc;
|
|
85
87
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const px = col.userWidth?.match(pixelRegex)?.[1] ?? null;
|
|
89
|
+
if (col.userWidth && px) {
|
|
90
|
+
acc += parseFloat(px);
|
|
91
|
+
}
|
|
92
|
+
else if (!col.userWidth) {
|
|
93
|
+
console.warn(`Cannot make column "${property}" pinned because it has no userWidth!`);
|
|
94
|
+
}
|
|
95
|
+
else if (!px) {
|
|
96
|
+
console.warn(`Cannot make column "${property}" pinned because its userWidth "${col.userWidth}" is not in pixels!`);
|
|
88
97
|
}
|
|
89
98
|
return acc;
|
|
90
99
|
}, 0);
|
|
@@ -133,3 +142,4 @@ export class ColumnInfoRunicStore {
|
|
|
133
142
|
return derivedValue;
|
|
134
143
|
}
|
|
135
144
|
}
|
|
145
|
+
const pixelRegex = /(\d+)px/;
|