@lavalogic/scoria 0.0.44 → 0.0.46

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.
@@ -0,0 +1,11 @@
1
+ import type { SortingState } from '../../DataRepository/SortingState.js';
2
+ import type { JSONColumnPinningState } from '../JSONColumnPinningState.js';
3
+ import type { VisibilityState } from '../VisibilityState.js';
4
+ import type { ColumnDef } from './ColumnDef.svelte.js';
5
+ export interface JSONColumnDefSet<T extends object> {
6
+ name: string;
7
+ sortingState: SortingState;
8
+ visibilityState: VisibilityState;
9
+ columnPinningState: JSONColumnPinningState;
10
+ columnDefs: Array<ColumnDef<T>>;
11
+ }
@@ -0,0 +1,4 @@
1
+ export interface JSONColumnPinningState {
2
+ left?: Array<[string, number]>;
3
+ right?: Array<[string, number]>;
4
+ }
@@ -14,8 +14,6 @@ import { DateInputDef } from '../Columns/Definitions/Accessors/DateInputDef.svel
14
14
  import { ProgressBarDef } from '../Columns/Definitions/Display/ProgressBarDef.svelte.js';
15
15
  import { DisplayDef } from '../Columns/Definitions/Display/DisplayDef.svelte.js';
16
16
  import { browser } from '$app/environment';
17
- import { NumberDateFilterMode } from '../Filtering/NumberDateFilterMode.js';
18
- import { FilterValueType } from '../Filtering/FilterValueType.js';
19
17
  const SORTING_ICON_WIDTH = 24;
20
18
  const InternalSymbol = Symbol();
21
19
  export class TableContext {
@@ -100,7 +98,7 @@ export class TableContext {
100
98
  if (savedPresets) {
101
99
  const presets = JSON.parse(savedPresets);
102
100
  if (presets[0] && areDefsEquivalent(defs, presets[0].columnDefs)) {
103
- return this.reassignDefsToPresets(presets).then(() => presets);
101
+ return this.reassignDefsToPresets(presets).then((p) => p);
104
102
  }
105
103
  }
106
104
  }
@@ -638,10 +636,6 @@ export class TableContext {
638
636
  const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
639
637
  const centerVisibleCells = $derived(this.columnDefs
640
638
  .filter((it) => {
641
- if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
642
- // eslint-disable-next-line no-debugger
643
- debugger;
644
- }
645
639
  return !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id));
646
640
  })
647
641
  .map(makeRow));
@@ -1617,10 +1611,6 @@ export class TableContext {
1617
1611
  const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
1618
1612
  const centerVisibleCells = $derived(this.columnDefs
1619
1613
  .filter((it) => {
1620
- if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
1621
- // eslint-disable-next-line no-debugger
1622
- debugger;
1623
- }
1624
1614
  return !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id));
1625
1615
  })
1626
1616
  .map(makeRow));
@@ -1846,10 +1836,6 @@ export class TableContext {
1846
1836
  const midDefs = [];
1847
1837
  const rightDefs = [];
1848
1838
  this.columnDefs.forEach((def) => {
1849
- if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
1850
- // eslint-disable-next-line no-debugger
1851
- debugger;
1852
- }
1853
1839
  if (this.columnPinning.left?.has(def.id)) {
1854
1840
  leftDefs.push(def);
1855
1841
  }
@@ -1981,10 +1967,6 @@ export class TableContext {
1981
1967
  left: new Map(this.columnPinning.left &&
1982
1968
  this.columnDefs
1983
1969
  .filter((col) => {
1984
- if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
1985
- // eslint-disable-next-line no-debugger
1986
- debugger;
1987
- }
1988
1970
  this.columnPinning.left?.has(col.id);
1989
1971
  })
1990
1972
  .map((col, index) => [col.id, index])),
@@ -2021,16 +2003,20 @@ export class TableContext {
2021
2003
  const adjustedDefs = this.columnDefs;
2022
2004
  const asMap = columnDefsToMap(adjustedDefs);
2023
2005
  console.log('reassigning presets');
2024
- presets.forEach((preset) => {
2025
- preset.columnDefs.forEach((def, index) => {
2026
- const realDef = def.columnType == ColumnType.RowSelect || def.columnType == ColumnType.Actions
2027
- ? adjustedDefs.find((it) => it.columnType === def.columnType)
2028
- : asMap.get(def.id);
2029
- if (!realDef) {
2030
- throw new Error('Could not find equivalent column def:', { cause: def });
2031
- }
2032
- preset.columnDefs[index] = realDef;
2033
- });
2006
+ return presets.map((preset) => {
2007
+ return {
2008
+ ...preset,
2009
+ columnPinningState: adaptJSONPinningState(preset.columnPinningState),
2010
+ columnDefs: preset.columnDefs.map((def, index) => {
2011
+ const realDef = def.columnType == ColumnType.RowSelect || def.columnType == ColumnType.Actions
2012
+ ? adjustedDefs.find((it) => it.columnType === def.columnType)
2013
+ : asMap.get(def.id);
2014
+ if (!realDef) {
2015
+ throw new Error('Could not find equivalent column def:', { cause: def });
2016
+ }
2017
+ return (preset.columnDefs[index] = realDef);
2018
+ })
2019
+ };
2034
2020
  });
2035
2021
  }
2036
2022
  }
@@ -2143,11 +2129,6 @@ function generateTableOptions(contextObj) {
2143
2129
  if (!isVisible) {
2144
2130
  return false;
2145
2131
  }
2146
- if (contextObj.columnPinning.left &&
2147
- typeof contextObj.columnPinning.left.has != 'function') {
2148
- // eslint-disable-next-line no-debugger
2149
- debugger;
2150
- }
2151
2132
  return contextObj.columnPinning.left?.has(it.id);
2152
2133
  })
2153
2134
  .map(makeHeader);
@@ -2174,11 +2155,6 @@ function generateTableOptions(contextObj) {
2174
2155
  const centerHeaderGroups = $derived.by(() => {
2175
2156
  const headers = contextObj.columnDefs
2176
2157
  .filter((it) => {
2177
- if (contextObj.columnPinning.left &&
2178
- typeof contextObj.columnPinning.left.has == 'function') {
2179
- // eslint-disable-next-line no-debugger
2180
- debugger;
2181
- }
2182
2158
  return (contextObj.columnVisibility[it.id] != false &&
2183
2159
  !(contextObj.columnPinning.left?.has(it.id) || contextObj.columnPinning.right?.has(it.id)));
2184
2160
  })
@@ -2354,4 +2330,10 @@ function progressSortingFn(id, desc) {
2354
2330
  return 0;
2355
2331
  };
2356
2332
  }
2333
+ function adaptJSONPinningState(state) {
2334
+ return {
2335
+ left: new Map(state.left),
2336
+ right: new Map(state.right)
2337
+ };
2338
+ }
2357
2339
  // #endregion
package/dist/index.d.ts CHANGED
@@ -21,7 +21,6 @@ export { type AccessorFn } from './Components/Table/Types/Columns/Definitions/Ac
21
21
  export { type ColumnDefProps, ColumnDef } from './Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js';
22
22
  export { type ColumnDefSet } from './Components/Table/Types/Columns/Definitions/ColumnDefSet.js';
23
23
  export { type ValidationFn } from './Components/Table/Types/Columns/Definitions/ValidationFn.js';
24
- export { type ColumnDefPreset } from './Components/Table/Types/Columns/ColumnDefPreset.js';
25
24
  export { type ColumnPinningState } from './Components/Table/Types/Columns/ColumnPinningState.js';
26
25
  export { type ColumnSizingState } from './Components/Table/Types/Columns/ColumnSizingState.js';
27
26
  export { ColumnType } from './Components/Table/Types/Columns/ColumnType.js';
package/dist/index.js CHANGED
@@ -26,7 +26,6 @@ export { ColumnDef } from './Components/Table/Types/Columns/Definitions/ColumnDe
26
26
  export {} from './Components/Table/Types/Columns/Definitions/ColumnDefSet.js';
27
27
  export {} from './Components/Table/Types/Columns/Definitions/ValidationFn.js';
28
28
  // Column is not exported
29
- export {} from './Components/Table/Types/Columns/ColumnDefPreset.js';
30
29
  export {} from './Components/Table/Types/Columns/ColumnPinningState.js';
31
30
  export {} from './Components/Table/Types/Columns/ColumnSizingState.js';
32
31
  export { ColumnType } from './Components/Table/Types/Columns/ColumnType.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.0.44",
4
+ "version": "0.0.46",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },
@@ -1,11 +0,0 @@
1
- import type { SortingState } from '../DataRepository/SortingState.js';
2
- import type { ColumnPinningState } from './ColumnPinningState.js';
3
- import type { ColumnDef } from './Definitions/ColumnDef.svelte.js';
4
- import type { VisibilityState } from './VisibilityState.js';
5
- export interface ColumnDefPreset<T extends object> {
6
- name: string;
7
- sortingState: SortingState;
8
- visibilityState: VisibilityState;
9
- columnPinningState: ColumnPinningState;
10
- columnDefs: Array<ColumnDef<T>>;
11
- }