@lavalogic/scoria 0.14.1 → 0.14.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.
@@ -54,7 +54,7 @@ export function generateExampleItemColumnDefs(modal) {
54
54
  },
55
55
  getDisplayValue: (item) => item.someSelect,
56
56
  isEditable: () => true
57
- }));
57
+ })).downcast();
58
58
  let defs = $state([
59
59
  expandDef,
60
60
  new ValidityDef({
@@ -170,6 +170,7 @@ export function generateExampleItemColumnDefs(modal) {
170
170
  defaultHidden: true,
171
171
  showTime: true
172
172
  }),
173
+ // altSelectDef,
173
174
  selectDef,
174
175
  new BubbleDef({
175
176
  header: 'Generated Bubble',
@@ -193,3 +194,16 @@ export function generateExampleItemColumnDefs(modal) {
193
194
  }
194
195
  };
195
196
  }
197
+ //sanity check
198
+ // class A<T> {}
199
+ // class B {}
200
+ // class C<T> extends A<T> {}
201
+ // class D extends B {}
202
+ // function asdf() {
203
+ // const x: Array<A<B>> = [];
204
+ // //C extends A, D extends B
205
+ // const y: C<D> = new C();
206
+ // x.push(y); // error
207
+ // const g: A<B> = y; //valid, subtype
208
+ // x.push(g); // no error
209
+ // }
@@ -1,9 +1,10 @@
1
1
  import { ColumnDef, type ColumnDefProps } from '../ColumnDef.svelte.js';
2
2
  import type { AccessorType } from './AccessorType.js';
3
- export interface AccessorDefProps<T extends object, FilterFnType = unknown> extends ColumnDefProps<T, FilterFnType> {
3
+ export interface AccessorDefProps<T extends object, FilterValueType> extends ColumnDefProps<T, FilterValueType> {
4
4
  readonly id: string & keyof T;
5
5
  }
6
- export declare abstract class AccessorDef<T extends object, FilterFnType = unknown> extends ColumnDef<T, FilterFnType> {
6
+ export declare abstract class AccessorDef<T extends object, FilterValueType> extends ColumnDef<T, FilterValueType> {
7
+ constructor(props: AccessorDefProps<T, FilterValueType>);
7
8
  readonly columnType: "Accessor";
8
9
  abstract readonly accessorType: AccessorType;
9
10
  }
@@ -1,5 +1,10 @@
1
1
  import { ColumnType } from '../../ColumnType.js';
2
2
  import { ColumnDef } from '../ColumnDef.svelte.js';
3
3
  export class AccessorDef extends ColumnDef {
4
+ // NOTE: constructor in place to enforce that we're using AccessorDefProps
5
+ // eslint-disable-next-line @typescript-eslint/no-useless-constructor
6
+ constructor(props) {
7
+ super(props);
8
+ }
4
9
  columnType = ColumnType.Accessor;
5
10
  }
@@ -1,9 +1,8 @@
1
1
  import type { SelectOption } from '../../../../../../Types/Internal/SelectOption.js';
2
2
  import type { CustomFilterFn } from '../../../Filtering/CustomFilterFn.js';
3
- import type { FilterFn, SelectFilterValueType } from '../../../Filtering/FilterFn.js';
4
- import type { ColumnDefProps } from '../ColumnDef.svelte.js';
5
- import { AccessorDef } from './AccessorDef.svelte.js';
6
- export interface SelectDefProps<T extends object, FilterValueType = unknown> extends ColumnDefProps<T, FilterValueType> {
3
+ import type { FilterFn } from '../../../Filtering/FilterFn.js';
4
+ import { AccessorDef, type AccessorDefProps } from './AccessorDef.svelte.js';
5
+ export interface SelectDefProps<T extends object, FilterValueType> extends AccessorDefProps<T, FilterValueType> {
7
6
  getOptions: () => Array<SelectOption<FilterValueType>> | Promise<Array<SelectOption<FilterValueType>>>;
8
7
  getDisplayValue: (item: T, index: number) => string | null | Promise<string | null>;
9
8
  sortingFn?: (a: T, b: T) => 1 | -1 | 0;
@@ -11,7 +10,7 @@ export interface SelectDefProps<T extends object, FilterValueType = unknown> ext
11
10
  optional?: boolean;
12
11
  clearable?: boolean;
13
12
  }
14
- export declare class SelectDef<T extends object, FilterValueType = SelectFilterValueType<T>> extends AccessorDef<T, FilterValueType> {
13
+ export declare class SelectDef<T extends object, FilterValueType> extends AccessorDef<T, FilterValueType> {
15
14
  constructor(props: SelectDefProps<T, FilterValueType>);
16
15
  readonly accessorType: "Select";
17
16
  private _filterFn;
@@ -61,4 +61,5 @@ export declare abstract class ColumnDef<T extends object, FilterFnType> {
61
61
  readonly resizable: boolean;
62
62
  readonly header: string | Snippet;
63
63
  readonly getOptions?: () => Array<SelectOption<FilterFnType>> | Promise<Array<SelectOption<FilterFnType>>>;
64
+ readonly downcast: () => ColumnDef<T, FilterFnType>;
64
65
  }
@@ -83,4 +83,10 @@ export class ColumnDef {
83
83
  resizable;
84
84
  header;
85
85
  getOptions;
86
+ // HACK: indended to be used as a quick type coercion for lists of ColumnDef<T,unknown>
87
+ // not the best way to solve this problem, but I've wasted enough time on this.
88
+ // eslint-disable-next-line @typescript-eslint/prefer-return-this-type
89
+ downcast = () => {
90
+ return this;
91
+ };
86
92
  }
@@ -1,7 +1,7 @@
1
1
  export declare const ExampleSelectEnum: {
2
- FirstOption: string;
3
- SecondOption: string;
4
- ThirdOption: string;
5
- FourthOption: string;
2
+ readonly FirstOption: "FirstOption";
3
+ readonly SecondOption: "SecondOption";
4
+ readonly ThirdOption: "ThirdOption";
5
+ readonly FourthOption: "FourthOption";
6
6
  };
7
7
  export type ExampleSelectEnum = (typeof ExampleSelectEnum)[keyof typeof ExampleSelectEnum];
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.14.1",
4
+ "version": "0.14.2",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },