@lavalogic/scoria 0.10.0 → 0.11.0

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.
@@ -12,18 +12,21 @@
12
12
 
13
13
  export interface ContextWrapperProps {
14
14
  children: Snippet;
15
+ debug?: boolean;
15
16
  }
16
17
  </script>
17
18
 
18
19
  <script lang="ts">
19
- const { children }: ContextWrapperProps = $props();
20
+ const { children, debug = false }: ContextWrapperProps = $props();
20
21
 
21
22
  setContext(ContextMenuContext.identifier, new ContextMenuContext());
22
23
  setContext(TooltipContext.identifier, new TooltipContext());
23
24
  setContext(ToastContext.identifier, new ToastContext());
24
25
  const alertContext = new AlertContext();
25
26
  setContext(AlertContext.identifier, alertContext);
26
- setContext(UntypedInputContext.identifier, new UntypedInputContext());
27
+
28
+ const untypedListenerContext = new UntypedInputContext(debug);
29
+ setContext(UntypedInputContext.identifier, untypedListenerContext);
27
30
  </script>
28
31
 
29
32
  <ContextMenu />
@@ -32,5 +35,5 @@
32
35
  {#if alertContext.showModal}
33
36
  <AlertModal />
34
37
  {/if}
35
-
38
+ <svelte:window onkeydown={untypedListenerContext.handleGlobalKeydown} />
36
39
  {@render children()}
@@ -1,6 +1,7 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  export interface ContextWrapperProps {
3
3
  children: Snippet;
4
+ debug?: boolean;
4
5
  }
5
6
  declare const ContextWrapper: import("svelte").Component<ContextWrapperProps, {}, "">;
6
7
  type ContextWrapper = ReturnType<typeof ContextWrapper>;
@@ -10,13 +10,12 @@
10
10
 
11
11
  export interface FocusableImmutableCellProps<T extends object> {
12
12
  cell: TableCell<T>;
13
- value?: unknown;
14
13
  children?: Snippet;
15
14
  }
16
15
  </script>
17
16
 
18
17
  <script lang="ts" generics="T extends object">
19
- const { cell, value: externalValue, children }: FocusableImmutableCellProps<T> = $props();
18
+ const { cell, children }: FocusableImmutableCellProps<T> = $props();
20
19
 
21
20
  const value = $derived(cell.getValue());
22
21
 
@@ -72,27 +71,19 @@ class:bottom={focusDetails.bottomEdge} -->
72
71
  }}
73
72
  >
74
73
  {#if hasValue}
75
- {#if externalValue}
76
- {#await externalValue}
77
- loading…
78
- {:then externalValue}
79
- {externalValue}
80
- {/await}
81
- {:else}
82
- {#await visibleValue}
83
- loading…
84
- {:then value}
85
- {(value instanceof Date
86
- ? value.toLocaleDateString()
87
- : options.length
88
- ? options.find((it) => it.value === value)?.label
89
- : value) ??
90
- value ??
91
- ''}
92
- {:catch e}
93
- {e?.toString()}
94
- {/await}
95
- {/if}
74
+ {#await visibleValue}
75
+ loading…
76
+ {:then visibleValue}
77
+ {(visibleValue instanceof Date
78
+ ? visibleValue.toLocaleDateString()
79
+ : options.length
80
+ ? options.find((it) => it.value === visibleValue)?.label
81
+ : visibleValue) ??
82
+ visibleValue ??
83
+ ''}
84
+ {:catch e}
85
+ {e?.toString()}
86
+ {/await}
96
87
  {:else if children}
97
88
  <div
98
89
  class="slot-wrapper"
@@ -2,7 +2,6 @@ import { type Snippet } from 'svelte';
2
2
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
3
3
  export interface FocusableImmutableCellProps<T extends object> {
4
4
  cell: TableCell<T>;
5
- value?: unknown;
6
5
  children?: Snippet;
7
6
  }
8
7
  declare function $$render<T extends object>(): {
@@ -58,9 +58,7 @@
58
58
  {#if cell.column.getIsVisible()}
59
59
  {@const columnDef = cell.column.columnDef}
60
60
 
61
- {#if cell.column.columnDef instanceof ValidityDef}
62
- <ValidityCell {cell} />
63
- {:else if columnDef instanceof RowSelectionDef}
61
+ {#if columnDef instanceof RowSelectionDef}
64
62
  <TableRowSelectionCheckbox {cell} />
65
63
  {:else if isActionsDef(cell)}
66
64
  <ActionsCell {cell} />
@@ -68,6 +66,18 @@
68
66
  <ExpandCell {cell} {expandedColumnDef} {onExpandChange} />
69
67
  {:else if columnDef.columnType !== ColumnType.Display}
70
68
  <AccessorComponent {cell} />
69
+ {:else if cell.column.columnDef instanceof AbstractDisplayDef}
70
+ {#if cell.column.columnDef.displayType === DisplayType.Bubbles}
71
+ <BubbleCell {cell} />
72
+ {:else if cell.column.columnDef.displayType === DisplayType.Validity}
73
+ <ValidityCell {cell} />
74
+ {:else if isProgressBarTableCell(cell)}
75
+ <ProgressCell {cell} />
76
+ {:else if cell.column.columnDef.displayType === DisplayType.Normal}
77
+ <FocusableImmutableCell {cell} />
78
+ {:else}
79
+ {@debug cell}
80
+ {/if}
71
81
  {:else}
72
82
  {@const valueOrComponentPromise =
73
83
  cell.column.columnDef.accessorFn?.(cell.row.original, cell.row.originalIndex) ??
@@ -75,35 +85,25 @@
75
85
  null}
76
86
 
77
87
  {#await valueOrComponentPromise}
78
- <FocusableImmutableCell value={valueOrComponentPromise} {cell} />
79
- {:then value}
80
- {@render ValueFallback(value)}
88
+ <FocusableImmutableCell {cell} />
89
+ {:then Value}
90
+ {#if Value == null || typeof Value === 'string' || typeof Value == 'number'}
91
+ <FocusableImmutableCell {cell} />
92
+ {:else if valueOrComponentIsConstructor(Value)}
93
+ <FocusableImmutableCell {cell}>
94
+ <Value {cell} />
95
+ </FocusableImmutableCell>
96
+ {:else if typeof Value === 'function'}
97
+ <FocusableImmutableCell {cell}>
98
+ {@render Value(cell)}
99
+ </FocusableImmutableCell>
100
+ {:else}
101
+ {@debug cell}
102
+ {/if}
81
103
  {:catch e}
82
- <FocusableImmutableCell value={e?.toString()} {cell} />
104
+ <FocusableImmutableCell {cell}>
105
+ {e?.toString()}
106
+ </FocusableImmutableCell>
83
107
  {/await}
84
108
  {/if}
85
109
  {/if}
86
-
87
- {#snippet ValueFallback(Value: unknown)}
88
- {#if cell.column.columnDef instanceof AbstractDisplayDef && Array.isArray(Value)}
89
- {#if cell.column.columnDef.displayType === DisplayType.Bubbles}
90
- <BubbleCell {cell} />
91
- {:else if isProgressBarTableCell(cell)}
92
- <ProgressCell {cell} />
93
- {:else}
94
- {@debug cell}
95
- {/if}
96
- {:else if Value == null || typeof Value === 'string' || typeof Value == 'number'}
97
- <FocusableImmutableCell value={Value} {cell} />
98
- {:else if valueOrComponentIsConstructor(Value)}
99
- <FocusableImmutableCell {cell}>
100
- <Value {cell} />
101
- </FocusableImmutableCell>
102
- {:else if typeof Value === 'function'}
103
- <FocusableImmutableCell {cell}>
104
- {@render Value(cell)}
105
- </FocusableImmutableCell>
106
- {:else}
107
- {@debug cell}
108
- {/if}
109
- {/snippet}
@@ -16,14 +16,14 @@
16
16
  <label>
17
17
  {#await checked}
18
18
  <input
19
- onchange={tableContext.onSelectAllInCurrentPage}
19
+ onchange={tableContext.selectAllInCurrentPage}
20
20
  type="checkbox"
21
21
  checked={false}
22
22
  disabled={tableContext.showSelectedOnly}
23
23
  />
24
24
  {:then checked}
25
25
  <input
26
- onchange={tableContext.onSelectAllInCurrentPage}
26
+ onchange={tableContext.selectAllInCurrentPage}
27
27
  type="checkbox"
28
28
  {checked}
29
29
  disabled={tableContext.showSelectedOnly}
@@ -2,7 +2,6 @@ export declare const DisplayType: {
2
2
  readonly Normal: "Normal";
3
3
  readonly Bubbles: "Bubbles";
4
4
  readonly Progress: "Progress";
5
- readonly Icon: "Icon";
6
5
  readonly Validity: "Validity";
7
6
  };
8
7
  export type DisplayType = (typeof DisplayType)[keyof typeof DisplayType];
@@ -2,7 +2,7 @@ export const DisplayType = {
2
2
  Normal: 'Normal',
3
3
  Bubbles: 'Bubbles',
4
4
  Progress: 'Progress',
5
- Icon: 'Icon',
5
+ // Icon: 'Icon', // NYI
6
6
  Validity: 'Validity'
7
7
  };
8
8
  Object.freeze(DisplayType);
@@ -165,7 +165,7 @@ export declare class TableContext<T extends object> {
165
165
  readonly updateSelectedItems: () => Promise<void>;
166
166
  readonly resetSelectedItems: () => void;
167
167
  readonly recalculateAllSelectedInCurrentPage: () => void;
168
- readonly onSelectAllInCurrentPage: () => Promise<void>;
168
+ readonly selectAllInCurrentPage: () => Promise<void>;
169
169
  readonly onHighlightAll: () => void;
170
170
  readonly onEditCell: (item: T, coords: CellCoordinates, value: unknown) => Promise<void>;
171
171
  readonly handleTdKeydown: (e: KeyboardEvent) => void;
@@ -860,7 +860,7 @@ export class TableContext {
860
860
  });
861
861
  });
862
862
  };
863
- onSelectAllInCurrentPage = async () => {
863
+ selectAllInCurrentPage = async () => {
864
864
  if (!this.dataRepo) {
865
865
  return;
866
866
  }
@@ -12,14 +12,23 @@
12
12
  style?: string;
13
13
  noscroll?: boolean;
14
14
  noTabMessage?: string;
15
+ nohistory?: boolean;
15
16
  }
16
17
  </script>
17
18
 
18
19
  <script lang="ts">
19
- let { name, tabs, selected, style, noscroll, noTabMessage }: VerticalTabGroupProps = $props();
20
+ let {
21
+ name,
22
+ tabs,
23
+ selected,
24
+ style,
25
+ noscroll,
26
+ noTabMessage,
27
+ nohistory = false
28
+ }: VerticalTabGroupProps = $props();
20
29
 
21
30
  onMount(() => {
22
- if (name) {
31
+ if (name && nohistory !== true) {
23
32
  const tabName = sessionStorage.getItem(`${name}-active-tab`);
24
33
  if (tabName) {
25
34
  tabs.find((it) => it.label === tabName)?.onclick();
@@ -6,6 +6,7 @@ export interface VerticalTabGroupProps {
6
6
  style?: string;
7
7
  noscroll?: boolean;
8
8
  noTabMessage?: string;
9
+ nohistory?: boolean;
9
10
  }
10
11
  declare const VerticalTabGroup: import("svelte").Component<VerticalTabGroupProps, {}, "">;
11
12
  type VerticalTabGroup = ReturnType<typeof VerticalTabGroup>;
@@ -1,6 +1,8 @@
1
1
  export type StringCallback = (value: string) => boolean | void | Promise<boolean | void>;
2
2
  import type { Unsubscriber } from '../Types/Internal/Misc.js';
3
3
  export declare class UntypedInputContext {
4
+ private debug;
5
+ constructor(debug?: boolean);
4
6
  static readonly identifier: unique symbol;
5
7
  private readonly registeredListeners;
6
8
  readonly registerListener: (listener: StringCallback) => Unsubscriber;
@@ -1,4 +1,8 @@
1
1
  export class UntypedInputContext {
2
+ debug;
3
+ constructor(debug = false) {
4
+ this.debug = debug;
5
+ }
2
6
  static identifier = Symbol();
3
7
  registeredListeners = [];
4
8
  registerListener = (listener) => {
@@ -42,11 +46,20 @@ export class UntypedInputContext {
42
46
  if (!this.tagNameSet.has(document.activeElement?.tagName)) {
43
47
  clearTimeout(this.debounceTimer);
44
48
  if (e.key === 'Enter') {
49
+ if (this.debug) {
50
+ console.log('firing');
51
+ }
45
52
  this.fire();
53
+ if (this.debug) {
54
+ console.log('clearing');
55
+ }
46
56
  this.untypedValue = '';
47
57
  return;
48
58
  }
49
59
  if (e.key.length == 1) {
60
+ if (this.debug) {
61
+ console.log(`adding ${e.key}`);
62
+ }
50
63
  this.untypedValue += e.key;
51
64
  }
52
65
  // else {
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.10.0",
4
+ "version": "0.11.0",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },