@isoftdata/svelte-table 2.10.0-beta.0 → 2.10.0

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/README.md CHANGED
@@ -35,6 +35,7 @@ This component uses a generic type `R` to represent the type of a single row pas
35
35
  | class | `string` | Any extra classes to apply to the `table`. | `""` |
36
36
  | columnClickedMethod | `(column: Column, direction: SortDirection) => void` | Called when a column is clicked. Should update `previousSortOrder`, `previousSortDirection`, `previousSortColumn`, and `sortedRows`. | `defaultColumnClicked` |
37
37
  | columnHidingEnabled | `boolean` | When enabled, the user will be able to right click a column header and hide/show it. | `false` |
38
+ | columnPinningEnabled | `boolean` | When enabled, the user will be able to right click a column header and pin or unpin it. | `false` |
38
39
  | columnResizingEnabled | `boolean` | When enabled, the user will be able to drag on the edge of a column header and resize it. | `false` |
39
40
  | columns | `Array<Column>` | The definition of the columns. See columns docs below. | **Required** |
40
41
  | currentPageNumber | `number` | The current page number. | `1` |
package/dist/Table.svelte CHANGED
@@ -995,6 +995,38 @@
995
995
  id="hide-column-context-menu"
996
996
  bind:this={contextMenu}
997
997
  >
998
+ {#if columnPinningEnabled}
999
+ {@const isPinned = !!contextMenuColumn?.pinned}
1000
+ <DropdownItem
1001
+ icon={isPinned ? 'thumbtack-angle-slash' : 'thumbtack-angle'}
1002
+ title={isPinned
1003
+ ? translate('common:tableUnpinColumnTitle', 'Unpinning this column will make it scroll normally')
1004
+ : translate(
1005
+ 'common:tablePinColumnTitle',
1006
+ 'Pinning this column will keep it visible as you scroll to the right',
1007
+ )}
1008
+ onclick={() => {
1009
+ if (contextMenuColumn) {
1010
+ pinUnpinColumn(contextMenuColumn)
1011
+ }
1012
+ }}
1013
+ >{#if contextMenuColumn?.name}
1014
+ {isPinned
1015
+ ? translate('common:tableUnpinColumnName', 'Unpin {{name}}', { name: contextMenuColumn.name })
1016
+ : translate('common:tablePinColumnName', 'Pin {{name}}', { name: contextMenuColumn.name })}
1017
+ {:else}
1018
+ {isPinned ? translate('common:tableUnpinColumn', 'Unpin') : translate('common:tablePinColumn', 'Pin')}
1019
+ {#if contextMenuColumn?.icon}
1020
+ <Icon icon={contextMenuColumn.icon}></Icon>
1021
+ {/if}
1022
+ {/if}
1023
+ </DropdownItem>
1024
+
1025
+ {#if columnHidingEnabled || columnResizingEnabled}
1026
+ <div class="dropdown-divider"></div>
1027
+ {/if}
1028
+ {/if}
1029
+
998
1030
  {#if columnHidingEnabled}
999
1031
  <DropdownItem
1000
1032
  class={hideButtonClass}
@@ -1029,26 +1061,6 @@
1029
1061
  {/each}
1030
1062
  </div>
1031
1063
 
1032
- {#if columnPinningEnabled || columnResizingEnabled}
1033
- <div class="dropdown-divider"></div>
1034
- {/if}
1035
- {/if}
1036
-
1037
- {#if columnPinningEnabled}
1038
- {@const isPinned = !!contextMenuColumn?.pinned}
1039
- <DropdownItem
1040
- icon={isPinned ? 'thumbtack-angle-slash' : 'thumbtack-angle'}
1041
- title={isPinned
1042
- ? 'Unpinning this column will make it scroll normally'
1043
- : 'Pinning this column will keep it visible as you scroll to the right'}
1044
- onclick={() => {
1045
- if (contextMenuColumn) {
1046
- pinUnpinColumn(contextMenuColumn)
1047
- }
1048
- }}
1049
- >{isPinned ? `Unpin ${contextMenuColumn?.name}` : `Pin ${contextMenuColumn?.name}`}
1050
- </DropdownItem>
1051
-
1052
1064
  {#if columnResizingEnabled}
1053
1065
  <div class="dropdown-divider"></div>
1054
1066
  {/if}
package/dist/Td.svelte CHANGED
@@ -118,6 +118,7 @@
118
118
  style:text-overflow={$columnResizingEnabled ? 'ellipsis' : undefined}
119
119
  style:position={thisColumnInfo?.pinned ? 'sticky' : undefined}
120
120
  style:left={thisColumnInfo?.pinned ? columnInfo.getPinnedColumnOffset(property) : undefined}
121
+ style:z-index={thisColumnInfo.pinned ? 5 : undefined}
121
122
  >
122
123
  <!--
123
124
  Don't listen to events that the user hasn't turned on the features for.
@@ -77,7 +77,7 @@ export class ColumnInfoRunicStore {
77
77
  return '0px';
78
78
  }
79
79
  else if (colIndex === 0) {
80
- return '0px';
80
+ return '-1px'; // Fix the gap on the left side of the first column
81
81
  }
82
82
  const offsetPx = this.pinnedColumns.slice(0, colIndex).reduce((acc, col) => {
83
83
  if (col.userWidth && col.visible) {
@@ -88,7 +88,7 @@ export class ColumnInfoRunicStore {
88
88
  }
89
89
  return acc;
90
90
  }, 0);
91
- return `${offsetPx}px`;
91
+ return `${offsetPx - colIndex - 1}px`;
92
92
  }
93
93
  getStoreValFromColumns(columns, storeValue) {
94
94
  const columnInfo = columns.reduce((acc, column) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-table",
3
- "version": "2.10.0-beta.0",
3
+ "version": "2.10.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",