@isoftdata/svelte-table 2.10.1 → 2.10.3

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 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:position={column.pinned ? 'sticky' : undefined}
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={[classNames, alignClass]}
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:position={thisColumnInfo?.pinned ? 'sticky' : undefined}
122
- style:left={thisColumnInfo?.pinned ? columnInfo.getPinnedColumnOffset(property) : undefined}
123
- style:z-index={thisColumnInfo?.pinned ? 5 : 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,6 +71,8 @@ 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
78
  console.warn(`Could not find columns ${property} in list of pinned columns: ${this.pinnedColumns.join(', ')}`);
@@ -83,7 +85,7 @@ export class ColumnInfoRunicStore {
83
85
  if (col.userWidth && col.visible) {
84
86
  acc += parseFloat(col.userWidth);
85
87
  }
86
- else {
88
+ else if (!col.userWidth) {
87
89
  console.warn(`Cannot make column ${property} pinned because it has no userWidth!`);
88
90
  }
89
91
  return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-table",
3
- "version": "2.10.1",
3
+ "version": "2.10.3",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",