@lavalogic/scoria 0.8.1 → 0.8.2

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.
@@ -14,11 +14,7 @@
14
14
  import { getContext, untrack, onMount } from 'svelte';
15
15
  import { cubicOut } from 'svelte/easing';
16
16
  import { fade } from 'svelte/transition';
17
- import {
18
- searchableTypes,
19
- numberDateFilterTypes,
20
- stringFilterTypes
21
- } from '../Misc/FilterInput.svelte';
17
+ import { numberDateFilterTypes, stringFilterTypes } from '../Misc/FilterInput.svelte';
22
18
  import { quickFilterContextIdentifier } from '../Table.svelte';
23
19
  import { TableContext } from '../Types/Context/TableContext.svelte.js';
24
20
  import { CustomFilterType } from '../Types/Filtering/CustomFilterType.js';
@@ -28,10 +24,8 @@
28
24
  import type { SelectOption } from '../../../Types/Internal/SelectOption.js';
29
25
  import type { Column } from '../Types/Columns/Column.js';
30
26
 
31
- import { AbstractDisplayDef } from '../Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js';
32
27
  import { DateInputDef } from '../Types/Columns/Definitions/Accessors/DateInputDef.svelte.js';
33
28
  import { SelectDef } from '../Types/Columns/Definitions/Accessors/SelectDef.svelte.js';
34
- import { AccessorDef } from '../Types/Columns/Definitions/Accessors/AccessorDef.svelte.js';
35
29
  import { NumberInputDef } from '../Types/Columns/Definitions/Accessors/NumberInputDef.svelte.js';
36
30
  import { dev } from '$app/environment';
37
31
  import { QuerySelect } from '../../../index.js';
@@ -56,14 +50,14 @@
56
50
 
57
51
  const hasFilterFn = $derived(!!def.filterFn && typeof def.filterFn === 'function');
58
52
 
59
- const hasAcceptableColumnType = $derived(
60
- (def instanceof AccessorDef && searchableTypes.has(def.accessorType)) ||
61
- (def instanceof AbstractDisplayDef && searchableTypes.has(def.displayType))
62
- );
53
+ // const hasAcceptableColumnType = $derived(
54
+ // (def instanceof AccessorDef && searchableTypes.has(def.accessorType)) ||
55
+ // (def instanceof AbstractDisplayDef && searchableTypes.has(def.displayType))
56
+ // );
63
57
 
64
58
  const isSearchable = $derived(
65
- def.allowFiltering != false &&
66
- ((hasFilterFn && hasAcceptableColumnType) || customFilters?.has(def.id) == true)
59
+ def.allowFiltering != false && (hasFilterFn || customFilters?.has(def.id) == true)
60
+ // ((hasFilterFn && hasAcceptableColumnType) || customFilters?.has(def.id) == true) // removed hasAcceptableColumnType due to it being redundant
67
61
  );
68
62
 
69
63
  const isNumeric = $derived(
@@ -35,6 +35,13 @@ export class ExampleItemColumnDef {
35
35
  },
36
36
  modal
37
37
  }),
38
+ new DisplayDef({
39
+ id: 'account_id',
40
+ header: 'Account',
41
+ accessorFn: (item) => `Unknown (id ${item.id})`,
42
+ filterValueType: 'Number',
43
+ debug: true
44
+ }),
38
45
  new DisplayDef({
39
46
  header: 'ID',
40
47
  id: 'id',
@@ -55,22 +55,22 @@
55
55
  { value: NumberDateFilterMode.null, label: 'Is null' }
56
56
  ];
57
57
 
58
- export const searchableColumnTypes = new Set<ColumnType | undefined>([
59
- ColumnType.Accessor,
60
- // ColumnType.Display,
61
- ColumnType.FilterOnly
62
- //ColumnType.Custom,
63
- ]);
64
- export const searchableTypes = new Set<AccessorType | DisplayType | undefined>([
65
- AccessorType.Text,
66
- AccessorType.Number,
67
- AccessorType.Date,
68
- // AccessorType.Checkbox,
69
- DisplayType.Normal,
70
- DisplayType.Bubbles,
71
- DisplayType.Progress,
72
- DisplayType.Icon
73
- ]);
58
+ // export const searchableColumnTypes = new Set<ColumnType | undefined>([
59
+ // ColumnType.Accessor,
60
+ // ColumnType.Display,
61
+ // ColumnType.FilterOnly
62
+ // //ColumnType.Custom,
63
+ // ]);
64
+ // export const searchableTypes = new Set<AccessorType | DisplayType | undefined>([
65
+ // AccessorType.Text,
66
+ // AccessorType.Number,
67
+ // AccessorType.Date,
68
+ // // AccessorType.Checkbox,
69
+ // DisplayType.Normal,
70
+ // DisplayType.Bubbles,
71
+ // DisplayType.Progress,
72
+ // DisplayType.Icon
73
+ // ]);
74
74
 
75
75
  export interface FilterInputProps<T extends object> {
76
76
  def: ColumnDef<T>;
@@ -100,14 +100,14 @@
100
100
 
101
101
  const hasFilterFn = $derived(!!def.filterFn && typeof def.filterFn === 'function');
102
102
 
103
- const hasAcceptableColumnType = $derived(
104
- (def instanceof AccessorDef && searchableTypes.has(def.accessorType)) ||
105
- (def instanceof AbstractDisplayDef && searchableTypes.has(def.displayType))
106
- );
103
+ // const hasAcceptableColumnType = $derived(
104
+ // (def instanceof AccessorDef && searchableTypes.has(def.accessorType)) ||
105
+ // (def instanceof AbstractDisplayDef && searchableTypes.has(def.displayType))
106
+ // );
107
107
 
108
108
  const isSearchable = $derived(
109
- def.allowFiltering != false &&
110
- ((hasFilterFn && hasAcceptableColumnType) || customFilters?.has(def.id) == true)
109
+ def.allowFiltering != false && (hasFilterFn || customFilters?.has(def.id) == true)
110
+ // ((hasFilterFn && hasAcceptableColumnType) || customFilters?.has(def.id) == true) // removed hasAcceptableColumnType due to it being redundant
111
111
  );
112
112
 
113
113
  const hasQuery = $derived(isRemoteSelect && customFilter?.query);
@@ -1,6 +1,3 @@
1
- import { ColumnType } from '../Types/Columns/ColumnType.js';
2
- import { AccessorType } from '../Types/Columns/Definitions/Accessors/AccessorType.js';
3
- import { DisplayType } from '../Types/Columns/DisplayType.js';
4
1
  import type { CustomRemoteFilters } from '../Types/Filtering/CustomRemoteFilters.js';
5
2
  import { NumberDateFilterMode } from '../Types/Filtering/NumberDateFilterMode.js';
6
3
  import { StringFilterMode } from '../Types/Filtering/StringFilterMode.js';
@@ -13,8 +10,6 @@ export declare const numberDateFilterTypes: {
13
10
  value: NumberDateFilterMode;
14
11
  label: string;
15
12
  }[];
16
- export declare const searchableColumnTypes: Set<ColumnType | undefined>;
17
- export declare const searchableTypes: Set<AccessorType | DisplayType | undefined>;
18
13
  export interface FilterInputProps<T extends object> {
19
14
  def: ColumnDef<T>;
20
15
  customFilters?: CustomRemoteFilters | undefined;
@@ -1919,8 +1919,14 @@ export class TableContext {
1919
1919
  const adjustedDefsPromises = this.defaultColumnDefs.defs.map(async (def) => {
1920
1920
  if (def instanceof AccessorDef) {
1921
1921
  if (def.allowFiltering == false) {
1922
+ if (def.debug) {
1923
+ console.log(`${def.id}: does not allow filtering`, def);
1924
+ }
1922
1925
  return def;
1923
1926
  }
1927
+ if (def.debug) {
1928
+ console.log(`${def.id}: is an accessor def`, def);
1929
+ }
1924
1930
  if (!('minSize' in def) || !def.minSize) {
1925
1931
  if (typeof def.header === 'string') {
1926
1932
  const minWidth = this.measureHeaderWidth(def);
@@ -1934,56 +1940,104 @@ export class TableContext {
1934
1940
  // code smell...
1935
1941
  if (def instanceof TextInputDef) {
1936
1942
  def.filterFn = this.stringFilter;
1943
+ if (def.debug) {
1944
+ console.log(`${def.id}: given a string filter`, def);
1945
+ }
1937
1946
  }
1938
1947
  else if (def instanceof NumberInputDef) {
1939
1948
  def.filterFn = this.numberFilter;
1949
+ if (def.debug) {
1950
+ console.log(`${def.id}: given a number filter`, def);
1951
+ }
1940
1952
  }
1941
1953
  else if (def instanceof SelectDef) {
1942
1954
  def.filterFn = this.selectFilter;
1955
+ if (def.debug) {
1956
+ console.log(`${def.id}: given a select filter`, def);
1957
+ }
1943
1958
  }
1944
1959
  else if (def instanceof CheckboxDef) {
1945
1960
  def.filterFn = this.boolFilter;
1961
+ if (def.debug) {
1962
+ console.log(`${def.id}: given a bool filter`, def);
1963
+ }
1946
1964
  }
1947
1965
  else if (def instanceof DateInputDef) {
1948
1966
  def.filterFn = this.dateFilter;
1967
+ if (def.debug) {
1968
+ console.log(`${def.id}: given a date filter`, def);
1969
+ }
1970
+ }
1971
+ else if (def.debug) {
1972
+ console.log(`${def.id}: was not a text,number,select,checkbox,or date accessor, and was not given a filter`, def);
1949
1973
  }
1950
1974
  }
1951
1975
  else if (
1952
1976
  // this.paginationRepo?.paginationType == PaginationType.Local &&
1953
1977
  !def.filterFn &&
1954
- def.allowFiltering != false) {
1978
+ def.allowFiltering !== false) {
1955
1979
  if (def instanceof DisplayDef) {
1980
+ if (def.debug) {
1981
+ console.log(`${def.id}: is a display def`, def);
1982
+ }
1956
1983
  switch (def.filterValueType) {
1957
1984
  case undefined:
1958
1985
  case 'String': {
1959
1986
  def.filterFn = this.stringFilter;
1987
+ if (def.debug) {
1988
+ console.log(`${def.id}: given a string filter`, def);
1989
+ }
1960
1990
  break;
1961
1991
  }
1962
1992
  case 'Bool': {
1963
1993
  def.filterFn = this.boolFilter;
1994
+ if (def.debug) {
1995
+ console.log(`${def.id}: given a bool filter`, def);
1996
+ }
1964
1997
  break;
1965
1998
  }
1966
1999
  case 'Date': {
1967
2000
  def.filterFn = this.dateFilter;
2001
+ if (def.debug) {
2002
+ console.log(`${def.id}: given a date filter`, def);
2003
+ }
1968
2004
  break;
1969
2005
  }
1970
2006
  case 'Number': {
1971
2007
  def.filterFn = this.numberFilter;
2008
+ if (def.debug) {
2009
+ console.log(`${def.id}: given a number filter`, def);
2010
+ }
1972
2011
  break;
1973
2012
  }
1974
2013
  case 'Select': {
1975
2014
  def.filterFn = this.selectFilter;
2015
+ if (def.debug) {
2016
+ console.log(`${def.id}: given a select filter`, def);
2017
+ }
1976
2018
  break;
1977
2019
  }
1978
2020
  }
1979
2021
  }
1980
2022
  else if (def instanceof BubbleDef) {
1981
2023
  def.filterFn = this.stringFilter;
2024
+ if (def.debug) {
2025
+ console.log(`${def.id}: is a bubble def. given a string filter`, def);
2026
+ }
1982
2027
  }
1983
2028
  else if (def instanceof ProgressBarDef) {
1984
2029
  def.filterFn = this.numberFilter;
2030
+ if (def.debug) {
2031
+ console.log(`${def.id}: is a progress def. given a number filter`, def);
2032
+ }
2033
+ }
2034
+ else if (def.debug) {
2035
+ console.log(`${def.id}: is not a display, bubble, or progressbar def, and was not given a filter`, def);
1985
2036
  }
1986
2037
  }
2038
+ else if (def.debug) {
2039
+ console.log(`${def.id}: no filtering matched`, def);
2040
+ }
1987
2041
  return def;
1988
2042
  });
1989
2043
  const adjustedDefs = (await Promise.all(adjustedDefsPromises))
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.8.1",
4
+ "version": "0.8.2",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },