@isoftdata/svelte-table 2.6.5 → 2.6.7

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
@@ -69,7 +69,7 @@ This component uses a generic type `R` to represent the type of a single row pas
69
69
  | rowSelectionIdProp | `K \| "uuid"` | The property to use as the unique identifier for each row in the row selection feature. | `"uuid"` |
70
70
  | rowSelectionRequiresModKey | `boolean` | Whether the row selection feature requires a modifier key or not. | `false` |
71
71
  | selectionEnabled | `boolean` | Whether the row selection feature is enabled or not. | `false` |
72
- | selectionMode | `"SINGLE" \| "RANGE" \| null` | The selection mode for the row selection feature. When `allowMultiSelect` is true, both selection modes will allow you to select multiple rows. | `null` |
72
+ | selectionMode | `"SINGLE" \| "RANGE" \| null` | The selection mode for the row selection feature. When `multiSelectEnabled` is true, both selection modes will allow you to select multiple rows. | `null` |
73
73
  | showFilterLabel | `boolean` | Whether the filter label is shown or not. | `false` |
74
74
  | showFooter | `boolean` | Defines if a `<tfoot>` should be shown. See `footers` slot below. | `false` |
75
75
  | size | `"sm" \| ""` | The size of the table. | `"sm"` |
@@ -53,9 +53,9 @@
53
53
  const buttonWidth = $derived.by(() => {
54
54
  // keep all the buttons the same size, but make them big enough to fit large page #s
55
55
  if (mobileSize) {
56
- return lastPageNumber >= 100 ? 51 : lastPageNumber >= 10 ? 40 : 34
56
+ return lastPageNumber >= 100 ? 51 : lastPageNumber >= 10 ? 40 : 36
57
57
  } else {
58
- return lastPageNumber >= 100 ? 40 : lastPageNumber >= 10 ? 34 : 28
58
+ return lastPageNumber >= 100 ? 40 : lastPageNumber >= 10 ? 36 : 28
59
59
  }
60
60
  })
61
61
 
package/dist/Table.svelte CHANGED
@@ -216,6 +216,7 @@
216
216
  setContext('expandedRows', expandedRows)
217
217
  }
218
218
 
219
+ // TODO: bad things will happen if we update any of our apps to use Runes for the store if we don't account for that here
219
220
  const session = getContext<Writable<{ userAccountId?: number }> | undefined>('session')
220
221
  // This will be accessible on the component instance, ie `const columnInfo = $derived(table?.columnInfo)` if you need it
221
222
  export const columnInfo = new ColumnInfoRunicStore<R>(() => columns, {
@@ -546,9 +547,12 @@
546
547
 
547
548
  try {
548
549
  untrack(() => {
549
- columnProperties.forEach(column => {
550
- columnInfo.updateColumn(column, { visible })
551
- })
550
+ columnInfo.updateColumns(
551
+ columnProperties.map((property): { property: RowProperties<R>; visible: boolean } => ({
552
+ property,
553
+ visible,
554
+ })),
555
+ )
552
556
  })
553
557
  } catch (err) {
554
558
  console.error(`Error setting column visibility for columns ${JSON.stringify(columnProperties)}`, err)
@@ -638,20 +642,28 @@
638
642
  useFixedLayout = false
639
643
  await tick()
640
644
  if (columnResizingEnabled) {
641
- columns.forEach((column, index) => {
642
- const th = tableParent?.querySelector<HTMLTableCellElement>(`#col-${tableId}-${CSS.escape(column.property)}`)
643
- if (th) {
645
+ columnInfo.updateColumns(
646
+ columns.map((column): { property: RowProperties<R>; userWidth: string } => {
644
647
  const thisColumnInfo = columnInfo.current[column.property]
645
648
  const prevUserWidth = thisColumnInfo?.userWidth
646
649
  // Minimum width will be inherited from the layout on reset, but this won't, so re-set it here if needed
647
650
  const explicitWidth = thisColumnInfo?.width
648
- const userWidth = prevUserWidth ?? explicitWidth ?? `${th.offsetWidth}px`
649
- columnInfo.updateColumn(column.property, { userWidth })
650
- }
651
- })
651
+
652
+ return {
653
+ property: column.property,
654
+ userWidth: prevUserWidth ?? explicitWidth ?? getColumnThWidth(column.property),
655
+ }
656
+ }),
657
+ )
652
658
  useFixedLayout = true
653
659
  }
654
660
  }
661
+
662
+ function getColumnThWidth(property: string) {
663
+ const thWidth =
664
+ tableParent?.querySelector<HTMLTableCellElement>(`#col-${tableId}-${CSS.escape(property)}`)?.offsetWidth ?? 25
665
+ return `${thWidth}px`
666
+ }
655
667
  // #region Computed
656
668
  $effect(() => {
657
669
  selectedRowIdsStore.set(selectedRowIds)
@@ -955,10 +967,12 @@
955
967
  <DropdownItem
956
968
  icon="broom"
957
969
  onclick={() => {
958
- for (const property in columnInfo.current) {
959
- // @ts-expect-error
960
- columnInfo.updateColumn(property, { userWidth: undefined })
961
- }
970
+ columnInfo.updateColumns(
971
+ computedColumns.map(col => ({
972
+ property: col.property,
973
+ userWidth: undefined,
974
+ })),
975
+ )
962
976
  setDefaultColumnWidths()
963
977
  }}>{translate('common:tableResetColumnSizes', 'Reset Column Sizes')}</DropdownItem
964
978
  >
@@ -56,7 +56,10 @@ export declare class ColumnInfoRunicStore<R extends UuidRowProps> {
56
56
  visible: boolean;
57
57
  }[];
58
58
  get current(): ColumnInfoObject<R>;
59
- updateColumn: (property: RowProperties<R>, value: Partial<GenericColumnInfo<R>>) => void;
59
+ updateColumn(property: RowProperties<R>, value: Partial<GenericColumnInfo<R>>): void;
60
+ updateColumns(newColumnInfos: Array<Partial<GenericColumnInfo<R>> & {
61
+ property: RowProperties<R>;
62
+ }>): void;
60
63
  private getStoreValFromColumns;
61
64
  /** Takes values from the given column, removes non-serializable values, and fills in with default serializable values */
62
65
  private getSerializableValuesWithDefaults;
@@ -47,18 +47,28 @@ export class ColumnInfoRunicStore {
47
47
  get current() {
48
48
  return this.#value;
49
49
  }
50
- updateColumn = (property, value) => {
51
- if (!(property in this.#value)) {
52
- console.error(`Column ${property} not found in column info store`);
53
- return;
54
- }
55
- const info = this.#value[property];
56
- this.#value[property] = { ...info, ...value };
50
+ updateColumn(property, value) {
51
+ this.updateColumns([
52
+ {
53
+ ...value,
54
+ property,
55
+ },
56
+ ]);
57
+ }
58
+ updateColumns(newColumnInfos) {
59
+ newColumnInfos.forEach(col => {
60
+ if (!(col.property in this.#value)) {
61
+ console.error(`Column ${col.property} not found in column info store`);
62
+ return;
63
+ }
64
+ // This gets run for every column in the table on render, so use Object.assign as it's faster
65
+ Object.assign(this.#value[col.property], col);
66
+ });
57
67
  this.#lastValue = this.#value;
58
68
  if (this.#persistedState) {
59
69
  this.#persistedState.current = this.makeDerived(this.#value);
60
70
  }
61
- };
71
+ }
62
72
  getStoreValFromColumns(columns, storeValue) {
63
73
  const columnInfo = columns.reduce((acc, column) => {
64
74
  const storedColumn = storeValue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isoftdata/svelte-table",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",