@lavalogic/scoria 0.21.5 → 0.22.1

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.
@@ -34,11 +34,10 @@
34
34
  oninput,
35
35
 
36
36
  inputRef = $bindable(),
37
- 'data-type': dataType
37
+ 'data-type': dataType,
38
38
  }: DimensionInputProps = $props();
39
39
 
40
- // HACK unable to edit signature
41
- /* eslint-disable @typescript-eslint/no-unused-vars */
40
+ // NOTE unable to edit signature
42
41
  function xNumberValidator(_node: HTMLInputElement, _newValue: number | null | undefined) {
43
42
  // function xNumberValidator() {
44
43
  return {
@@ -49,7 +48,7 @@
49
48
  x = (
50
49
  isNaN(newValue) ? 0 : underMinimum ? min : overMaximum ? max : newValue
51
50
  ) as Centimetres;
52
- }
51
+ },
53
52
  };
54
53
  }
55
54
  function yNumberValidator(_node: HTMLInputElement, _newValue: number | null | undefined) {
@@ -61,7 +60,7 @@
61
60
  y = (
62
61
  isNaN(newValue) ? 0 : underMinimum ? min : overMaximum ? max : newValue
63
62
  ) as Centimetres;
64
- }
63
+ },
65
64
  };
66
65
  }
67
66
 
@@ -75,10 +74,9 @@
75
74
  z = (
76
75
  isNaN(newValue) ? 0 : underMinimum ? min : overMaximum ? max : newValue
77
76
  ) as Centimetres;
78
- }
77
+ },
79
78
  };
80
79
  }
81
- /* eslint-enable @typescript-eslint/no-unused-vars */
82
80
  // ^
83
81
 
84
82
  let isInvalid = $derived(
@@ -108,7 +106,10 @@
108
106
  <span class="border">Dimensions - <span class="optional">optional</span></span>
109
107
  {/if}
110
108
  <!-- style="--background-colour: {leftIcon?.backgroundColour ?? rightIcon?.backgroundColour};" -->
111
- <div class="icon-container" class:for-modal={variant == InputVariant.Modal}>
109
+ <div
110
+ class="icon-container"
111
+ class:for-modal={variant == InputVariant.Modal}
112
+ >
112
113
  <input
113
114
  {id}
114
115
  class:for-default={variant === InputVariant.Default}
@@ -173,7 +174,10 @@
173
174
  step={decimal ? 0.01 : 1}
174
175
  />
175
176
  <div class="spacer"></div>
176
- <span class="right-label inset" class:for-modal={variant == InputVariant.Modal}>cm</span>
177
+ <span
178
+ class="right-label inset"
179
+ class:for-modal={variant == InputVariant.Modal}>cm</span
180
+ >
177
181
  </div>
178
182
  </div>
179
183
 
@@ -1,19 +1,26 @@
1
1
  <svelte:options runes />
2
2
 
3
- <script lang="ts" generics="CommonDenominator">
3
+ <script
4
+ lang="ts"
5
+ generics="CommonDenominator"
6
+ >
4
7
  import HorizontalTabGroupButton from './HorizontalTabGroupButton.svelte';
5
8
  import type { HorizontalTabGroupProps } from './HorizontalTabGroupProps.js';
6
9
  let {
7
- name: _name,
10
+ // name: _name, //FIXME why is this not implemented?
8
11
  tabComponent,
9
12
  options,
10
13
  selected,
11
14
  noRadius = false,
12
- grow = false
15
+ grow = false,
13
16
  }: HorizontalTabGroupProps<CommonDenominator> = $props();
14
17
  </script>
15
18
 
16
- <div class="wrapper" class:no-radius={noRadius} class:grow>
19
+ <div
20
+ class="wrapper"
21
+ class:no-radius={noRadius}
22
+ class:grow
23
+ >
17
24
  <div class="tabs">
18
25
  {#if tabComponent}
19
26
  {#each options as option (option)}
@@ -21,7 +28,10 @@
21
28
  {/each}
22
29
  {:else}
23
30
  {#each options as option (option)}
24
- <HorizontalTabGroupButton {option} selected={selected === option} />
31
+ <HorizontalTabGroupButton
32
+ {option}
33
+ selected={selected === option}
34
+ />
25
35
  {/each}
26
36
  {/if}
27
37
  </div>
@@ -22,7 +22,7 @@ export function generateExampleItemColumnDefs(modal) {
22
22
  if (!$effect.tracking()) {
23
23
  throw new Error(`NOT in tracking context`);
24
24
  }
25
- return isSelected.then((isSelected) => {
25
+ const compareValidity = (isSelected) => {
26
26
  if (isSelected) {
27
27
  if (!item.name.trim()) {
28
28
  return { value: Validity.Invalid, reason: 'Missing name' };
@@ -36,7 +36,10 @@ export function generateExampleItemColumnDefs(modal) {
36
36
  };
37
37
  }
38
38
  return { value: Validity.Neutral, reason: 'row not selected' };
39
- });
39
+ };
40
+ return isSelected instanceof Promise
41
+ ? isSelected.then(compareValidity)
42
+ : compareValidity(isSelected);
40
43
  };
41
44
  const expandDef = $state(new ExpandDef({
42
45
  accessorFn: (it) => [it],
@@ -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: Promise<boolean>) => Validity | Promise<Validity | ValidityWrapper> | ValidityWrapper;
3
+ export type ValidationFn<T> = (item: T, isSelected: boolean | Promise<boolean>) => Validity | Promise<Validity | ValidityWrapper> | ValidityWrapper;
@@ -51,7 +51,6 @@ export declare class TableContext<T extends object, RowIdType extends Primitive>
51
51
  get remoteFilters(): CustomRemoteFilters<unknown> | undefined;
52
52
  private set remoteFilters(value);
53
53
  private _showSelectedOnly;
54
- private _pageBeforeSelectedOnly;
55
54
  get showSelectedOnly(): boolean;
56
55
  set showSelectedOnly(v: boolean);
57
56
  readonly dateFilter: FilterFn<T, DateFilterValueType> | undefined;
@@ -161,7 +160,7 @@ export declare class TableContext<T extends object, RowIdType extends Primitive>
161
160
  private _flushScheduled;
162
161
  private _flushPendingSelectionChanges;
163
162
  private _schedulePendingFlush;
164
- readonly selectionContains: (item: T) => Promise<boolean>;
163
+ readonly selectionContains: (item: T) => boolean | Promise<boolean>;
165
164
  readonly addInvalidValue: (item: T) => void | Promise<void>;
166
165
  readonly removeInvalidValue: (item: T) => void | Promise<void>;
167
166
  readonly setOpenModalCoordinates: (coordinates: CellCoordinatesWithoutColumn | null) => void;
@@ -423,7 +423,6 @@ export class TableContext {
423
423
  this._remoteFilters = v;
424
424
  }
425
425
  _showSelectedOnly = $state(false);
426
- _pageBeforeSelectedOnly = undefined;
427
426
  get showSelectedOnly() {
428
427
  return this._showSelectedOnly;
429
428
  }
@@ -432,14 +431,6 @@ export class TableContext {
432
431
  return;
433
432
  }
434
433
  this._showSelectedOnly = v;
435
- if (v) {
436
- this._pageBeforeSelectedOnly = (this.paginationRepo?.paginationState.pageIndex ?? 0) + 1;
437
- this.paginationRepo?.setPage(1);
438
- }
439
- else if (this._pageBeforeSelectedOnly != null) {
440
- this.paginationRepo?.setPage(this._pageBeforeSelectedOnly);
441
- this._pageBeforeSelectedOnly = undefined;
442
- }
443
434
  }
444
435
  dateFilter = $derived(this.paginationRepo?.dateFilter);
445
436
  numberFilter = $derived(this.paginationRepo?.numberFilter);
@@ -1054,7 +1045,7 @@ export class TableContext {
1054
1045
  })
1055
1046
  .catch(devCatch);
1056
1047
  }
1057
- selectionContains = async (item) => {
1048
+ selectionContains = (item) => {
1058
1049
  void item;
1059
1050
  void this.isSelectable;
1060
1051
  void this.selectedItems.size;
@@ -1065,9 +1056,9 @@ export class TableContext {
1065
1056
  return true;
1066
1057
  }
1067
1058
  const rawIdentity = this._cachedKey(item);
1068
- const identity = rawIdentity instanceof Promise ? await rawIdentity : rawIdentity;
1069
- const has = this.selectedItems.has(identity);
1070
- return has;
1059
+ return rawIdentity instanceof Promise
1060
+ ? rawIdentity.then((identity) => this.selectedItems.has(identity))
1061
+ : this.selectedItems.has(rawIdentity);
1071
1062
  };
1072
1063
  addInvalidValue = (item) => {
1073
1064
  const raw = this._cachedKey(item);
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.21.5",
4
+ "version": "0.22.1",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },