@lavalogic/scoria 0.0.25 → 0.0.27

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.
@@ -10,7 +10,7 @@
10
10
  import { Validity } from '../../../../../Types/Internal/Validity.js';
11
11
 
12
12
  export interface ActionsCellProps<T extends object> {
13
- cell: TableCell<T>;
13
+ cell: ActionsTableCell<T>;
14
14
  }
15
15
 
16
16
  export let shownPopup = refWrapper<symbol | undefined>(undefined);
@@ -18,7 +18,7 @@
18
18
 
19
19
  <script lang="ts" generics="T extends object">
20
20
  import { getContext, tick, untrack } from 'svelte';
21
- import TableAction from './TableAction.svelte';
21
+ import TableAction, { type ActionsTableCell } from './TableAction.svelte';
22
22
  import type { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
23
23
  import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
24
24
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
@@ -1,8 +1,8 @@
1
1
  export interface ActionsCellProps<T extends object> {
2
- cell: TableCell<T>;
2
+ cell: ActionsTableCell<T>;
3
3
  }
4
4
  export declare let shownPopup: import("../../../../../index.js").RefWrapper<symbol | undefined>;
5
- import type { TableCell } from '../../../Types/Columns/TableCell.js';
5
+ import { type ActionsTableCell } from './TableAction.svelte';
6
6
  declare function $$render<T extends object>(): {
7
7
  props: ActionsCellProps<T>;
8
8
  exports: {};
@@ -7,10 +7,17 @@
7
7
  import type { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
8
8
  import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
9
9
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
10
+ import type { Column } from '../../../Types/Columns/Column.js';
10
11
 
12
+ export interface ActionsColumn<T extends object> extends Column<T> {
13
+ columnDef: ActionsDef<T>;
14
+ }
15
+ export interface ActionsTableCell<T extends object> extends TableCell<T> {
16
+ column: ActionsColumn<T>;
17
+ }
11
18
  export interface TableActionProps<T extends object> {
12
19
  action: TableActionButton<T>;
13
- cell: TableCell<T>;
20
+ cell: ActionsTableCell<T>;
14
21
  }
15
22
  </script>
16
23
 
@@ -18,17 +25,22 @@
18
25
  const { action, cell }: TableActionProps<T> = $props();
19
26
 
20
27
  const isEnabledPromise: boolean | Promise<boolean> = $derived.by(() => {
21
- if (action.isDisabled) {
22
- return action.isDisabled(cell.row.original, cell.row.index);
23
- } else if ((cell.column.columnDef as ActionsDef<T>).isEnabled) {
24
- return (cell.column.columnDef as ActionsDef<T>).isEnabled!(
28
+ const disabled = action.isDisabled?.(cell.row.original, cell.row.index);
29
+
30
+ if (disabled != null) {
31
+ if (typeof disabled == 'boolean') {
32
+ return !disabled;
33
+ } else {
34
+ return disabled.then((it) => !it);
35
+ }
36
+ }
37
+ return (
38
+ (cell.column.columnDef as ActionsDef<T>).isEnabled?.(
25
39
  cell.row.original,
26
40
  cell.row.index,
27
41
  action
28
- );
29
- }
30
-
31
- return Promise.resolve(true);
42
+ ) ?? true
43
+ );
32
44
  });
33
45
 
34
46
  const labelPromise: Promise<string> = $derived.by(() => {
@@ -42,20 +54,25 @@
42
54
  });
43
55
  </script>
44
56
 
45
- {#await Promise.all([labelPromise, isEnabledPromise]) then [label, enabled]}
46
- <Button
47
- fullWidth
48
- size={Size.Medium}
49
- colourSet={(cell.column.columnDef as ActionsDef<T>).getColourSet?.(
50
- cell.row.original,
51
- cell.row.index,
52
- action
53
- ) ?? ColourSet.Secondary}
54
- disabled={!enabled}
55
- onclick={() => {
56
- action.callback(cell.row.original, cell.row.index);
57
- }}>{label}</Button
58
- >
57
+ {#await labelPromise then label}
58
+ {#await isEnabledPromise then isEnabled}
59
+ <Button
60
+ fullWidth
61
+ size={Size.Medium}
62
+ colourSet={(cell.column.columnDef as ActionsDef<T>).getColourSet?.(
63
+ cell.row.original,
64
+ cell.row.index,
65
+ action
66
+ ) ?? ColourSet.Secondary}
67
+ disabled={!isEnabled}
68
+ onclick={() => {
69
+ action.callback(cell.row.original, cell.row.index);
70
+ }}>{label}</Button
71
+ >
72
+ {:catch e}
73
+ {@debug e}
74
+ Error Loading Button
75
+ {/await}
59
76
  {:catch e}
60
77
  {@debug e}
61
78
  Error Loading Button
@@ -1,8 +1,16 @@
1
+ import type { ActionsDef } from '../../../Types/Columns/Definitions/Actions/ActionsDef.svelte.js';
1
2
  import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
2
3
  import type { TableCell } from '../../../Types/Columns/TableCell.js';
4
+ import type { Column } from '../../../Types/Columns/Column.js';
5
+ export interface ActionsColumn<T extends object> extends Column<T> {
6
+ columnDef: ActionsDef<T>;
7
+ }
8
+ export interface ActionsTableCell<T extends object> extends TableCell<T> {
9
+ column: ActionsColumn<T>;
10
+ }
3
11
  export interface TableActionProps<T extends object> {
4
12
  action: TableActionButton<T>;
5
- cell: TableCell<T>;
13
+ cell: ActionsTableCell<T>;
6
14
  }
7
15
  declare function $$render<T extends object>(): {
8
16
  props: TableActionProps<T>;
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.25",
4
+ "version": "0.0.27",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },