@lavalogic/scoria 0.0.42 → 0.0.44

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.
@@ -5,7 +5,7 @@ export interface SelectDefProps<T extends object> extends ColumnDefProps<T> {
5
5
  getOptions: () => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
6
6
  getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
7
7
  sortingFn?: (a: T, b: T) => 1 | -1 | 0;
8
- getSpecificOptions?: (item?: T, index?: number) => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
8
+ getSpecificOptions?: (item: T, index: number) => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
9
9
  optional?: boolean;
10
10
  clearable?: boolean;
11
11
  }
@@ -16,6 +16,6 @@ export declare class SelectDef<T extends object> extends AccessorDef<T, T> {
16
16
  readonly getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
17
17
  readonly optional: boolean;
18
18
  readonly clearable: boolean;
19
- readonly getSpecificOptions?: (item?: T, index?: number) => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
19
+ readonly getSpecificOptions?: (item: T, index: number) => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
20
20
  readonly getOptions: () => Array<SelectOption<unknown>> | Promise<Array<SelectOption<unknown>>>;
21
21
  }
@@ -1,3 +1,3 @@
1
1
  import type { Validity } from '../../../../../Types/Internal/Validity.js';
2
2
  import type { ValidityWrapper } from '../../../../../Types/Internal/ValidityWrapper.js';
3
- export type ValidationFn<T> = (item: T, isSelected: boolean) => Validity | Promise<Validity> | ValidityWrapper | Promise<ValidityWrapper>;
3
+ export type ValidationFn<T> = (item: T, isSelected: boolean) => Validity | Promise<Validity | ValidityWrapper> | ValidityWrapper;
@@ -25,6 +25,7 @@ export declare class TableContext<T extends object> {
25
25
  enableResize: boolean;
26
26
  allowColumnReordering: boolean;
27
27
  allowQuickFiltering: boolean;
28
+ showQuickFilterByDefault: boolean;
28
29
  allowAdvancedFiltering: boolean;
29
30
  toolbarPosition: ToolbarPosition;
30
31
  displayFooter: boolean;
@@ -33,7 +34,7 @@ export declare class TableContext<T extends object> {
33
34
  private _onEditCell;
34
35
  static readonly identifier: unique symbol;
35
36
  static init<T extends object>(defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, options: TableInitOptions<T>): TableContext<T>;
36
- protected constructor(INTERNAL_ONLY: symbol, defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, allowCopy: boolean, enableResize: boolean, allowColumnReordering: boolean, allowQuickFiltering: boolean, allowAdvancedFiltering: boolean, toolbarPosition: ToolbarPosition, displayFooter: boolean, selectionExtractor: TableInitOptions<T>['selectionExtractor'], getUserId: () => string | undefined, _onEditCell?: TableInitOptions<T>['onEditCell']);
37
+ protected constructor(INTERNAL_ONLY: symbol, defaultColumnDefs: DefsWrapper<T>, tableName: string, dataRepo: IDataRepository<T>, allowCopy: boolean, enableResize: boolean, allowColumnReordering: boolean, allowQuickFiltering: boolean, showQuickFilterByDefault: boolean, allowAdvancedFiltering: boolean, toolbarPosition: ToolbarPosition, displayFooter: boolean, selectionExtractor: TableInitOptions<T>['selectionExtractor'], getUserId: () => string | undefined, _onEditCell?: TableInitOptions<T>['onEditCell']);
37
38
  private readonly userId;
38
39
  private isSelectable;
39
40
  __queryValues: SvelteMap<string, unknown>;
@@ -25,6 +25,7 @@ export class TableContext {
25
25
  enableResize;
26
26
  allowColumnReordering;
27
27
  allowQuickFiltering;
28
+ showQuickFilterByDefault;
28
29
  allowAdvancedFiltering;
29
30
  toolbarPosition;
30
31
  displayFooter;
@@ -33,11 +34,11 @@ export class TableContext {
33
34
  _onEditCell;
34
35
  static identifier = Symbol();
35
36
  static init(defaultColumnDefs, tableName, dataRepo, options) {
36
- const context = new this(InternalSymbol, defaultColumnDefs, tableName, dataRepo, options.allowCopy ?? true, options.enableResize ?? true, options.allowColumnReordering ?? true, options.allowQuickFiltering ?? true, options.allowAdvancedFiltering ?? true, options.toolbar ?? ToolbarPosition.Right, options.displayFooter ?? true, options.selectionExtractor, options.getUserId, options.onEditCell);
37
+ const context = new this(InternalSymbol, defaultColumnDefs, tableName, dataRepo, options.allowCopy ?? true, options.enableResize ?? true, options.allowColumnReordering ?? true, options.allowQuickFiltering ?? true, options.showQuickFilterByDefault ?? true, options.allowAdvancedFiltering ?? true, options.toolbar ?? ToolbarPosition.Right, options.displayFooter ?? true, options.selectionExtractor, options.getUserId, options.onEditCell);
37
38
  return context;
38
39
  }
39
40
  // #region constructor
40
- constructor(INTERNAL_ONLY, defaultColumnDefs, tableName, dataRepo, allowCopy, enableResize, allowColumnReordering, allowQuickFiltering, allowAdvancedFiltering, toolbarPosition, displayFooter, selectionExtractor, getUserId, _onEditCell = async () => {
41
+ constructor(INTERNAL_ONLY, defaultColumnDefs, tableName, dataRepo, allowCopy, enableResize, allowColumnReordering, allowQuickFiltering, showQuickFilterByDefault, allowAdvancedFiltering, toolbarPosition, displayFooter, selectionExtractor, getUserId, _onEditCell = async () => {
41
42
  console.warn('Cannot edit immutable table');
42
43
  }) {
43
44
  this.defaultColumnDefs = defaultColumnDefs;
@@ -46,6 +47,7 @@ export class TableContext {
46
47
  this.enableResize = enableResize;
47
48
  this.allowColumnReordering = allowColumnReordering;
48
49
  this.allowQuickFiltering = allowQuickFiltering;
50
+ this.showQuickFilterByDefault = showQuickFilterByDefault;
49
51
  this.allowAdvancedFiltering = allowAdvancedFiltering;
50
52
  this.toolbarPosition = toolbarPosition;
51
53
  this.displayFooter = displayFooter;
@@ -91,6 +93,7 @@ export class TableContext {
91
93
  };
92
94
  this.setupDefaultColumnDefs()
93
95
  .then((defs) => {
96
+ this.showQuickFiltering = this.showQuickFilterByDefault;
94
97
  this.isSelectable = defs.some((it) => it.id.startsWith('is-selectable-'));
95
98
  if (this.allowColumnReordering) {
96
99
  const savedPresets = localStorage.getItem(`${this.userId}-${tableName}-presets`);
@@ -634,7 +637,13 @@ export class TableContext {
634
637
  const leftVisibleCells = $derived([...(this.columnPinning.left?.keys() ?? [])].map(makeCellFromId) ?? []);
635
638
  const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
636
639
  const centerVisibleCells = $derived(this.columnDefs
637
- .filter((it) => !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id)))
640
+ .filter((it) => {
641
+ if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
642
+ // eslint-disable-next-line no-debugger
643
+ debugger;
644
+ }
645
+ return !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id));
646
+ })
638
647
  .map(makeRow));
639
648
  return row;
640
649
  });
@@ -1607,7 +1616,13 @@ export class TableContext {
1607
1616
  const leftVisibleCells = $derived([...(this.columnPinning.left?.keys() ?? [])].map(makeCellFromId) ?? []);
1608
1617
  const rightVisibleCells = $derived([...(this.columnPinning.right?.keys() ?? [])].map(makeCellFromId) ?? []);
1609
1618
  const centerVisibleCells = $derived(this.columnDefs
1610
- .filter((it) => !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id)))
1619
+ .filter((it) => {
1620
+ if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
1621
+ // eslint-disable-next-line no-debugger
1622
+ debugger;
1623
+ }
1624
+ return !(this.columnPinning.left?.has(it.id) || this.columnPinning.right?.has(it.id));
1625
+ })
1611
1626
  .map(makeRow));
1612
1627
  return row;
1613
1628
  }
@@ -1831,6 +1846,10 @@ export class TableContext {
1831
1846
  const midDefs = [];
1832
1847
  const rightDefs = [];
1833
1848
  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
+ }
1834
1853
  if (this.columnPinning.left?.has(def.id)) {
1835
1854
  leftDefs.push(def);
1836
1855
  }
@@ -1961,7 +1980,13 @@ export class TableContext {
1961
1980
  // eslint-disable-next-line svelte/prefer-svelte-reactivity
1962
1981
  left: new Map(this.columnPinning.left &&
1963
1982
  this.columnDefs
1964
- .filter((col) => this.columnPinning.left?.has(col.id))
1983
+ .filter((col) => {
1984
+ if (this.columnPinning.left && typeof this.columnPinning.left.has == 'function') {
1985
+ // eslint-disable-next-line no-debugger
1986
+ debugger;
1987
+ }
1988
+ this.columnPinning.left?.has(col.id);
1989
+ })
1965
1990
  .map((col, index) => [col.id, index])),
1966
1991
  // eslint-disable-next-line svelte/prefer-svelte-reactivity
1967
1992
  right: new Map(this.columnPinning.right &&
@@ -2113,7 +2138,18 @@ function generateTableOptions(contextObj) {
2113
2138
  };
2114
2139
  const leftHeaderGroups = $derived.by(() => {
2115
2140
  const headers = contextObj.columnDefs
2116
- .filter((it) => contextObj.columnVisibility[it.id] != false && contextObj.columnPinning.left?.has(it.id))
2141
+ .filter((it) => {
2142
+ const isVisible = contextObj.columnVisibility[it.id] != false;
2143
+ if (!isVisible) {
2144
+ return false;
2145
+ }
2146
+ if (contextObj.columnPinning.left &&
2147
+ typeof contextObj.columnPinning.left.has != 'function') {
2148
+ // eslint-disable-next-line no-debugger
2149
+ debugger;
2150
+ }
2151
+ return contextObj.columnPinning.left?.has(it.id);
2152
+ })
2117
2153
  .map(makeHeader);
2118
2154
  return [
2119
2155
  {
@@ -2137,8 +2173,15 @@ function generateTableOptions(contextObj) {
2137
2173
  });
2138
2174
  const centerHeaderGroups = $derived.by(() => {
2139
2175
  const headers = contextObj.columnDefs
2140
- .filter((it) => contextObj.columnVisibility[it.id] != false &&
2141
- !(contextObj.columnPinning.left?.has(it.id) || contextObj.columnPinning.right?.has(it.id)))
2176
+ .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
+ return (contextObj.columnVisibility[it.id] != false &&
2183
+ !(contextObj.columnPinning.left?.has(it.id) || contextObj.columnPinning.right?.has(it.id)));
2184
+ })
2142
2185
  .map(makeHeader);
2143
2186
  return [
2144
2187
  {
@@ -6,6 +6,7 @@ export interface TableInitOptions<T extends object> {
6
6
  enableResize?: boolean;
7
7
  allowColumnReordering?: boolean;
8
8
  allowQuickFiltering?: boolean;
9
+ showQuickFilterByDefault?: boolean;
9
10
  allowAdvancedFiltering?: boolean;
10
11
  toolbar?: ToolbarPosition;
11
12
  displayFooter?: boolean;
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.42",
4
+ "version": "0.0.44",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },