@lavalogic/scoria 0.34.0 → 0.35.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.
Files changed (125) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +42 -42
  3. package/dist/Components/AccordionGroupButton.svelte +99 -99
  4. package/dist/Components/Action.svelte +138 -138
  5. package/dist/Components/AlertModal.svelte +125 -125
  6. package/dist/Components/Base/ContextWrapper.svelte +50 -50
  7. package/dist/Components/Base/Pagination.svelte +190 -190
  8. package/dist/Components/Base/Snippets.svelte +29 -29
  9. package/dist/Components/BigRadioSet.svelte +29 -29
  10. package/dist/Components/Bubble.svelte +77 -77
  11. package/dist/Components/Button.svelte +197 -197
  12. package/dist/Components/Checkbox.svelte +68 -68
  13. package/dist/Components/CollapsibleCard.svelte +70 -70
  14. package/dist/Components/Contexts/ContextMenu.svelte +157 -157
  15. package/dist/Components/Contexts/ContextMenuDivider.svelte +11 -11
  16. package/dist/Components/Contexts/ContextMenuOption.svelte +52 -52
  17. package/dist/Components/Contexts/Toast.svelte +61 -61
  18. package/dist/Components/Contexts/ToastContainer.svelte +46 -46
  19. package/dist/Components/Contexts/Tooltip.svelte +26 -26
  20. package/dist/Components/DataMatrixIcon.svelte +41 -41
  21. package/dist/Components/DateInput.svelte +109 -109
  22. package/dist/Components/DatePicker.svelte +312 -312
  23. package/dist/Components/DesktopModal.svelte +106 -106
  24. package/dist/Components/Dial.svelte +151 -151
  25. package/dist/Components/DimensionInput.svelte +184 -184
  26. package/dist/Components/DragMenu/DragMenuHolder.svelte +106 -106
  27. package/dist/Components/DragMenu/DraggableCard.svelte +41 -41
  28. package/dist/Components/FileCard.svelte +20 -20
  29. package/dist/Components/FileUpload.svelte +196 -196
  30. package/dist/Components/GridInput.svelte +190 -190
  31. package/dist/Components/GridInputSet.svelte +22 -22
  32. package/dist/Components/HorizontalTabGroup.svelte +78 -78
  33. package/dist/Components/HorizontalTabGroupButton.svelte +96 -96
  34. package/dist/Components/Icon.svelte +97 -97
  35. package/dist/Components/Icons.js +357 -357
  36. package/dist/Components/LoadingAnimation.svelte +32 -32
  37. package/dist/Components/LoadingModal.svelte +47 -47
  38. package/dist/Components/LoadingOverlay.svelte +27 -27
  39. package/dist/Components/Modal.svelte +251 -251
  40. package/dist/Components/MultiSelect.svelte +197 -197
  41. package/dist/Components/Nav/Nav.svelte +97 -97
  42. package/dist/Components/Nav/NavServiceMenuList.svelte +34 -34
  43. package/dist/Components/Nav/NavTab.svelte +91 -91
  44. package/dist/Components/Nav/ServiceMenuItem.svelte +91 -91
  45. package/dist/Components/Nav/ServicesNav.svelte +53 -53
  46. package/dist/Components/NumberInput.svelte +144 -144
  47. package/dist/Components/PageHeading.svelte +36 -36
  48. package/dist/Components/PasswordInput.svelte +73 -73
  49. package/dist/Components/Portal.svelte +25 -25
  50. package/dist/Components/ProgressBubble.svelte +80 -80
  51. package/dist/Components/QuerySelect.svelte +411 -411
  52. package/dist/Components/SingleSelect.svelte +261 -261
  53. package/dist/Components/StepButton.svelte +120 -120
  54. package/dist/Components/StepForm.svelte +108 -108
  55. package/dist/Components/Switch.svelte +36 -36
  56. package/dist/Components/Table/Body/QuickSearchCell.svelte +632 -632
  57. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +30 -30
  58. package/dist/Components/Table/Body/Rows/ColumnList.svelte +56 -56
  59. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +179 -179
  60. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +49 -49
  61. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +180 -180
  62. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +102 -102
  63. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +119 -119
  64. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +114 -114
  65. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +96 -96
  66. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +72 -72
  67. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +131 -131
  68. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +144 -144
  69. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +238 -238
  70. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +358 -358
  71. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +338 -338
  72. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +183 -183
  73. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +309 -309
  74. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +369 -369
  75. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +170 -170
  76. package/dist/Components/Table/Body/Rows/TableRow.svelte +259 -259
  77. package/dist/Components/Table/Body/TableBody.svelte +67 -67
  78. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +39 -39
  79. package/dist/Components/Table/Headers/SelectAllHeader.svelte +28 -28
  80. package/dist/Components/Table/Headers/TableHead.svelte +260 -260
  81. package/dist/Components/Table/Misc/ColumnPanel.svelte +78 -78
  82. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +99 -99
  83. package/dist/Components/Table/Misc/FilterInput.svelte +556 -556
  84. package/dist/Components/Table/Misc/FilterPanel.svelte +46 -46
  85. package/dist/Components/Table/Misc/FilterPanelModal.svelte +67 -67
  86. package/dist/Components/Table/Misc/SidePanel.svelte +32 -32
  87. package/dist/Components/Table/Misc/TableFooter.svelte +304 -304
  88. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +156 -156
  89. package/dist/Components/Table/Misc/TableSidebar.svelte +176 -176
  90. package/dist/Components/Table/Misc/ToolboxPanel.svelte +77 -77
  91. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +91 -91
  92. package/dist/Components/Table/NestedTable.svelte +84 -84
  93. package/dist/Components/Table/Table.svelte +492 -492
  94. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  95. package/dist/Components/TextArea.svelte +108 -108
  96. package/dist/Components/TextInput.svelte +147 -147
  97. package/dist/Components/ThreeStateRadio.svelte +124 -124
  98. package/dist/Components/Touch/BoolCard.svelte +52 -52
  99. package/dist/Components/Touch/DateModal.svelte +217 -217
  100. package/dist/Components/Touch/EditCard.svelte +52 -52
  101. package/dist/Components/Touch/InfoCard.svelte +24 -24
  102. package/dist/Components/Touch/InfoTextCard.svelte +21 -21
  103. package/dist/Components/Touch/ModalExplanation.svelte +20 -20
  104. package/dist/Components/Touch/NumberKeyboard.svelte +268 -268
  105. package/dist/Components/Touch/NumberModal.svelte +69 -69
  106. package/dist/Components/Touch/PlusMinusCard.svelte +50 -50
  107. package/dist/Components/Touch/SelectModal.svelte +105 -105
  108. package/dist/Components/Touch/SummaryCard.svelte +65 -65
  109. package/dist/Components/Touch/TextAreaModal.svelte +86 -86
  110. package/dist/Components/Touch/TextModal.svelte +123 -123
  111. package/dist/Components/Touch/TouchCard.svelte +28 -28
  112. package/dist/Components/Touch/TouchModal.svelte +259 -259
  113. package/dist/Components/Touch/UtilityButton.svelte +91 -91
  114. package/dist/Components/VerticalTabGroup.svelte +66 -66
  115. package/dist/Components/VerticalTabGroupButton.svelte +97 -97
  116. package/dist/Helpers/Datamatrix.d.ts +10 -10
  117. package/dist/Helpers/Datamatrix.js +1 -1
  118. package/dist/Helpers/Helpers.svelte.js +6 -4
  119. package/dist/Types/Examples/ExampleModal.svelte +34 -34
  120. package/dist/scss/_basics.scss +12 -12
  121. package/dist/scss/_colours.scss +134 -134
  122. package/dist/scss/_mixins.scss +3016 -3016
  123. package/dist/scss/_sizing.scss +69 -69
  124. package/dist/scss/_transitions.scss +8 -8
  125. package/package.json +2 -2
@@ -1,182 +1,182 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import Action from '../../../../Action.svelte';
8
- import Portal from '../../../../Portal.svelte';
9
- import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
10
- import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
11
- import { MultiFocusEdge } from '../../../Types/Focus/MultiFocusEdge.js';
12
- import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
13
- import { asyncMap, devCatch, isValidityTuple, refWrapper } from '../../../../../Helpers/Helpers.svelte.js';
14
- import { Colour, ColourSet } from '../../../../../scss/colours.js';
15
- import { Size } from '../../../../../Types/Internal/Size.js';
16
- import { Validity } from '../../../../../Types/Internal/Validity.js';
17
- import { getContext, untrack } from 'svelte';
18
- import type { ActionsCellProps } from './ActionsCellProps.js';
19
- import TableAction from './TableAction.svelte';
20
-
21
- export let shownPopup = refWrapper<symbol | undefined>(undefined);
22
- </script>
23
-
24
- <script
25
- lang="ts"
26
- generics="T extends object,FilterValueType"
27
- >
28
- const { cell }: ActionsCellProps<T, FilterValueType> = $props();
29
-
30
- const value = $derived(cell.getValue());
31
-
32
- const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
33
-
34
- const actions: Array<TableActionButton<T>> = $derived(cell.column.columnDef.actions);
35
-
36
- const thisPopup = $state(Symbol());
37
- const thisPopupIsVisibile = $derived(thisPopup === shownPopup.value);
38
- const hasValue: boolean = $derived(value !== undefined);
39
- const edge: MultiFocusEdge | undefined = $state();
40
- const focusDetails: TableFocusDetails<T, never> = $derived(
41
- new TableFocusDetails(cell, tableContext)
42
- );
43
-
44
- let cellRef: HTMLDivElement | undefined = $state();
45
-
46
- let x = $state(0);
47
- let y = $state(0);
48
- $effect.pre(() => {
49
- if (thisPopupIsVisibile && cellRef) {
50
- const rect = cellRef.getBoundingClientRect();
51
- untrack(() => {
52
- const totalOffsetX = -6;
53
- // (props.offsetX ?? 0) +
54
- // (props.arrow === Side.Top || props.arrow === Side.Bottom
55
- // ? props.rect.width / 2
56
- // : props.arrow === Side.Right
57
- // ? -6 // arrow width
58
- // : props.rect.width + 6); // arrow width
59
-
60
- const totalOffsetY = rect.height / 2;
61
- // (props.offsetY ?? 0) +
62
- // (props.arrow === Side.Left || props.arrow === Side.Right
63
- // ? props.rect.height / 2
64
- // : props.arrow === Side.Top
65
- // ? props.rect.height
66
- // : 0);
67
-
68
- x = rect.x + totalOffsetX;
69
- y = rect.y + totalOffsetY;
70
- });
71
- }
72
- });
73
-
74
- let validity: Validity = $state(Validity.Valid);
75
- $effect(() => {
76
- const validityPromise = focusDetails.validity;
77
-
78
- validityPromise
79
- .then((v) => {
80
- if (!v) {
81
- validity = Validity.Neutral;
82
- } else if (isValidityTuple(v)) {
83
- validity = v.value;
84
- } else {
85
- validity = v;
86
- }
87
- })
88
- .catch(devCatch);
89
- });
90
- </script>
91
-
92
- <!-- svelte-ignore a11y_mouse_events_have_key_events -->
93
- <td
94
- id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
95
- tabIndex={hasValue ? 0 : undefined}
96
- class="focusable"
97
- class:multifocus={hasValue && focusDetails.isMultiFocused}
98
- class:multifocus-start={hasValue && focusDetails.isMultiFocusStart}
99
- class:left={edge === MultiFocusEdge.Left}
100
- class:top-left={edge === MultiFocusEdge.TopLeft}
101
- class:top={edge === MultiFocusEdge.Top}
102
- class:top-right={edge === MultiFocusEdge.TopRight}
103
- class:right={edge === MultiFocusEdge.Right}
104
- class:bottom-right={edge === MultiFocusEdge.BottomRight}
105
- class:bottom={edge === MultiFocusEdge.Bottom}
106
- class:bottom-left={edge === MultiFocusEdge.BottomLeft}
107
- class:info={validity == Validity.Info}
108
- class:success={validity == Validity.Valid}
109
- class:warning={validity == Validity.Warning}
110
- class:error={validity == Validity.Invalid}
111
- onmousedown={(e) => {
112
- // start focus only on left click
113
- if (e.button === 0) {
114
- if (e.shiftKey) {
115
- e.preventDefault();
116
- tableContext.setFocusEnd(focusDetails.coordinates);
117
- } else {
118
- tableContext.startFocus(focusDetails.coordinates);
119
- }
120
- }
121
- }}
122
- onmouseover={() => {
123
- if (tableContext.isMousingDown) {
124
- tableContext.setFocusEnd(focusDetails.coordinates);
125
- }
126
- }}
127
- onmouseup={() => {
128
- tableContext.endFocus(focusDetails.coordinates);
129
- }}
130
- >
131
- <div
132
- class="slot-wrapper"
133
- class:multifocus={focusDetails.isMultiFocused}
134
- class:multifocus-start={focusDetails.isMultiFocusStart}
135
- bind:this={cellRef}
136
- >
137
- <!-- TODO {isMultiFocusStart} -->
138
- <Action
139
- style={focusDetails.outline}
140
- border={false}
141
- size={Size.FillWidth}
142
- icon={{ name: 'ellipsis', size: Size.Medium, colour: Colour['$brand-primary'] }}
143
- colourSet={ColourSet.Auxiliary}
144
- onclick={() => {
145
- if (shownPopup.value === thisPopup) {
146
- shownPopup.value = undefined;
147
- } else {
148
- shownPopup.value = thisPopup;
149
- }
150
- }}
151
- />
152
- </div>
153
- {#if thisPopupIsVisibile}
154
- {@const awaitedActions = asyncMap<TableActionButton<T>, [TableActionButton<T>, string]>(
155
- actions,
156
- async (item) => {
157
- return [item, await item.getLabel(cell.row.original, cell.row.visibleIndex)];
158
- }
159
- )}
160
- {#await awaitedActions then actions}
161
- <Portal>
162
- <div
163
- class="popup"
164
- style="--y: {y}px; --x: {x}px;"
165
- >
166
- <div class="action-container">
167
- {#each actions as [action, label] (label)}
168
- <TableAction
169
- {action}
170
- {cell}
171
- />
172
- {/each}
173
- </div>
174
- </div>
175
- </Portal>
176
- {/await}
177
- {/if}
178
- </td>
179
-
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import Action from '../../../../Action.svelte';
8
+ import Portal from '../../../../Portal.svelte';
9
+ import type { TableActionButton } from '../../../Types/Columns/TableActionButton.js';
10
+ import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
11
+ import { MultiFocusEdge } from '../../../Types/Focus/MultiFocusEdge.js';
12
+ import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
13
+ import { asyncMap, devCatch, isValidityTuple, refWrapper } from '../../../../../Helpers/Helpers.svelte.js';
14
+ import { Colour, ColourSet } from '../../../../../scss/colours.js';
15
+ import { Size } from '../../../../../Types/Internal/Size.js';
16
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
17
+ import { getContext, untrack } from 'svelte';
18
+ import type { ActionsCellProps } from './ActionsCellProps.js';
19
+ import TableAction from './TableAction.svelte';
20
+
21
+ export let shownPopup = refWrapper<symbol | undefined>(undefined);
22
+ </script>
23
+
24
+ <script
25
+ lang="ts"
26
+ generics="T extends object,FilterValueType"
27
+ >
28
+ const { cell }: ActionsCellProps<T, FilterValueType> = $props();
29
+
30
+ const value = $derived(cell.getValue());
31
+
32
+ const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
33
+
34
+ const actions: Array<TableActionButton<T>> = $derived(cell.column.columnDef.actions);
35
+
36
+ const thisPopup = $state(Symbol());
37
+ const thisPopupIsVisibile = $derived(thisPopup === shownPopup.value);
38
+ const hasValue: boolean = $derived(value !== undefined);
39
+ const edge: MultiFocusEdge | undefined = $state();
40
+ const focusDetails: TableFocusDetails<T, never> = $derived(
41
+ new TableFocusDetails(cell, tableContext)
42
+ );
43
+
44
+ let cellRef: HTMLDivElement | undefined = $state();
45
+
46
+ let x = $state(0);
47
+ let y = $state(0);
48
+ $effect.pre(() => {
49
+ if (thisPopupIsVisibile && cellRef) {
50
+ const rect = cellRef.getBoundingClientRect();
51
+ untrack(() => {
52
+ const totalOffsetX = -6;
53
+ // (props.offsetX ?? 0) +
54
+ // (props.arrow === Side.Top || props.arrow === Side.Bottom
55
+ // ? props.rect.width / 2
56
+ // : props.arrow === Side.Right
57
+ // ? -6 // arrow width
58
+ // : props.rect.width + 6); // arrow width
59
+
60
+ const totalOffsetY = rect.height / 2;
61
+ // (props.offsetY ?? 0) +
62
+ // (props.arrow === Side.Left || props.arrow === Side.Right
63
+ // ? props.rect.height / 2
64
+ // : props.arrow === Side.Top
65
+ // ? props.rect.height
66
+ // : 0);
67
+
68
+ x = rect.x + totalOffsetX;
69
+ y = rect.y + totalOffsetY;
70
+ });
71
+ }
72
+ });
73
+
74
+ let validity: Validity = $state(Validity.Valid);
75
+ $effect(() => {
76
+ const validityPromise = focusDetails.validity;
77
+
78
+ validityPromise
79
+ .then((v) => {
80
+ if (!v) {
81
+ validity = Validity.Neutral;
82
+ } else if (isValidityTuple(v)) {
83
+ validity = v.value;
84
+ } else {
85
+ validity = v;
86
+ }
87
+ })
88
+ .catch(devCatch);
89
+ });
90
+ </script>
91
+
92
+ <!-- svelte-ignore a11y_mouse_events_have_key_events -->
93
+ <td
94
+ id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
95
+ tabIndex={hasValue ? 0 : undefined}
96
+ class="focusable"
97
+ class:multifocus={hasValue && focusDetails.isMultiFocused}
98
+ class:multifocus-start={hasValue && focusDetails.isMultiFocusStart}
99
+ class:left={edge === MultiFocusEdge.Left}
100
+ class:top-left={edge === MultiFocusEdge.TopLeft}
101
+ class:top={edge === MultiFocusEdge.Top}
102
+ class:top-right={edge === MultiFocusEdge.TopRight}
103
+ class:right={edge === MultiFocusEdge.Right}
104
+ class:bottom-right={edge === MultiFocusEdge.BottomRight}
105
+ class:bottom={edge === MultiFocusEdge.Bottom}
106
+ class:bottom-left={edge === MultiFocusEdge.BottomLeft}
107
+ class:info={validity == Validity.Info}
108
+ class:success={validity == Validity.Valid}
109
+ class:warning={validity == Validity.Warning}
110
+ class:error={validity == Validity.Invalid}
111
+ onmousedown={(e) => {
112
+ // start focus only on left click
113
+ if (e.button === 0) {
114
+ if (e.shiftKey) {
115
+ e.preventDefault();
116
+ tableContext.setFocusEnd(focusDetails.coordinates);
117
+ } else {
118
+ tableContext.startFocus(focusDetails.coordinates);
119
+ }
120
+ }
121
+ }}
122
+ onmouseover={() => {
123
+ if (tableContext.isMousingDown) {
124
+ tableContext.setFocusEnd(focusDetails.coordinates);
125
+ }
126
+ }}
127
+ onmouseup={() => {
128
+ tableContext.endFocus(focusDetails.coordinates);
129
+ }}
130
+ >
131
+ <div
132
+ class="slot-wrapper"
133
+ class:multifocus={focusDetails.isMultiFocused}
134
+ class:multifocus-start={focusDetails.isMultiFocusStart}
135
+ bind:this={cellRef}
136
+ >
137
+ <!-- TODO {isMultiFocusStart} -->
138
+ <Action
139
+ style={focusDetails.outline}
140
+ border={false}
141
+ size={Size.FillWidth}
142
+ icon={{ name: 'ellipsis', size: Size.Medium, colour: Colour['$brand-primary'] }}
143
+ colourSet={ColourSet.Auxiliary}
144
+ onclick={() => {
145
+ if (shownPopup.value === thisPopup) {
146
+ shownPopup.value = undefined;
147
+ } else {
148
+ shownPopup.value = thisPopup;
149
+ }
150
+ }}
151
+ />
152
+ </div>
153
+ {#if thisPopupIsVisibile}
154
+ {@const awaitedActions = asyncMap<TableActionButton<T>, [TableActionButton<T>, string]>(
155
+ actions,
156
+ async (item) => {
157
+ return [item, await item.getLabel(cell.row.original, cell.row.visibleIndex)];
158
+ }
159
+ )}
160
+ {#await awaitedActions then actions}
161
+ <Portal>
162
+ <div
163
+ class="popup"
164
+ style="--y: {y}px; --x: {x}px;"
165
+ >
166
+ <div class="action-container">
167
+ {#each actions as [action, label] (label)}
168
+ <TableAction
169
+ {action}
170
+ {cell}
171
+ />
172
+ {/each}
173
+ </div>
174
+ </div>
175
+ </Portal>
176
+ {/await}
177
+ {/if}
178
+ </td>
179
+
180
180
  <style>td {
181
181
  transition: line-height 0.2s ease, height 0.2s ease;
182
182
  --input-border: none;
@@ -302,4 +302,4 @@ div.slot-wrapper {
302
302
  display: flex;
303
303
  align-items: center;
304
304
  justify-content: center;
305
- }</style>
305
+ }</style>
@@ -1,104 +1,104 @@
1
- <svelte:options runes />
2
-
3
- <!-- TODO editable version of this should contain a multi select -->
4
- <script
5
- lang="ts"
6
- generics="T extends object,FilterValueType"
7
- >
8
- import Bubble from '../../../../Bubble.svelte';
9
- import { BubbleDef } from '../../../Types/Columns/Definitions/Display/BubbleDef.svelte.js';
10
- import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
11
- import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
12
- import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
13
- import { Validity } from '../../../../../Types/Internal/Validity.js';
14
- import { getContext } from 'svelte';
15
- import type { FocusableImmutableCellProps } from './FocusableImmutableCellProps.js';
16
-
17
- const { cell }: FocusableImmutableCellProps<T, FilterValueType> = $props();
18
-
19
- const values = $derived(cell.getValue()) as Array<string> | Promise<Array<string>>;
20
-
21
- const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
22
-
23
- const focusDetails: TableFocusDetails<T, never> = $derived(
24
- new TableFocusDetails(cell, tableContext)
25
- );
26
-
27
- let validity: Validity = $state(Validity.Valid);
28
- $effect(() => {
29
- const validityPromise = focusDetails.validity;
30
-
31
- validityPromise
32
- .then((v) => {
33
- if (!v) {
34
- validity = Validity.Neutral;
35
- } else if (isValidityTuple(v)) {
36
- validity = v.value;
37
- } else {
38
- validity = v;
39
- }
40
- })
41
- .catch(devCatch);
42
- });
43
- </script>
44
-
45
- <!-- svelte-ignore a11y_mouse_events_have_key_events -->
46
- <td
47
- id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
48
- tabIndex={0}
49
- class="focusable"
50
- class:multifocus={focusDetails.isMultiFocused}
51
- class:multifocus-start={focusDetails.isMultiFocusStart}
52
- style={focusDetails.outline}
53
- class:info={validity == Validity.Info}
54
- class:success={validity == Validity.Valid}
55
- class:warning={validity == Validity.Warning}
56
- class:error={validity == Validity.Invalid}
57
- onmousedown={(e) => {
58
- // start focus only on left click
59
- if (e.button === 0) {
60
- if (e.shiftKey) {
61
- e.preventDefault();
62
- tableContext.setFocusEnd(focusDetails.coordinates);
63
- } else {
64
- tableContext.startFocus(focusDetails.coordinates);
65
- }
66
- }
67
- }}
68
- onmouseover={() => {
69
- if (tableContext.isMousingDown) {
70
- tableContext.setFocusEnd(focusDetails.coordinates);
71
- }
72
- }}
73
- onmouseup={() => {
74
- tableContext.endFocus(focusDetails.coordinates);
75
- }}
76
- >
77
- <div class="bubble-parent">
78
- {#await values then values}
79
- <!-- eslint-disable-next-line svelte/require-each-key -->
80
- {#each values as value}
81
- {@const colourPromise = (cell.column.columnDef as BubbleDef<T>).getColour?.(
82
- cell.row.original,
83
- cell.row.originalIndex,
84
- value
85
- )}
86
-
87
- {#if colourPromise == undefined}
88
- <Bubble {value} />
89
- {:else}
90
- {#await colourPromise then colour}
91
- <Bubble
92
- {value}
93
- colours={colour}
94
- />
95
- {/await}
96
- {/if}
97
- {/each}
98
- {/await}
99
- </div>
100
- </td>
101
-
1
+ <svelte:options runes />
2
+
3
+ <!-- TODO editable version of this should contain a multi select -->
4
+ <script
5
+ lang="ts"
6
+ generics="T extends object,FilterValueType"
7
+ >
8
+ import Bubble from '../../../../Bubble.svelte';
9
+ import { BubbleDef } from '../../../Types/Columns/Definitions/Display/BubbleDef.svelte.js';
10
+ import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
11
+ import { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
12
+ import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
13
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
14
+ import { getContext } from 'svelte';
15
+ import type { FocusableImmutableCellProps } from './FocusableImmutableCellProps.js';
16
+
17
+ const { cell }: FocusableImmutableCellProps<T, FilterValueType> = $props();
18
+
19
+ const values = $derived(cell.getValue()) as Array<string> | Promise<Array<string>>;
20
+
21
+ const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
22
+
23
+ const focusDetails: TableFocusDetails<T, never> = $derived(
24
+ new TableFocusDetails(cell, tableContext)
25
+ );
26
+
27
+ let validity: Validity = $state(Validity.Valid);
28
+ $effect(() => {
29
+ const validityPromise = focusDetails.validity;
30
+
31
+ validityPromise
32
+ .then((v) => {
33
+ if (!v) {
34
+ validity = Validity.Neutral;
35
+ } else if (isValidityTuple(v)) {
36
+ validity = v.value;
37
+ } else {
38
+ validity = v;
39
+ }
40
+ })
41
+ .catch(devCatch);
42
+ });
43
+ </script>
44
+
45
+ <!-- svelte-ignore a11y_mouse_events_have_key_events -->
46
+ <td
47
+ id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
48
+ tabIndex={0}
49
+ class="focusable"
50
+ class:multifocus={focusDetails.isMultiFocused}
51
+ class:multifocus-start={focusDetails.isMultiFocusStart}
52
+ style={focusDetails.outline}
53
+ class:info={validity == Validity.Info}
54
+ class:success={validity == Validity.Valid}
55
+ class:warning={validity == Validity.Warning}
56
+ class:error={validity == Validity.Invalid}
57
+ onmousedown={(e) => {
58
+ // start focus only on left click
59
+ if (e.button === 0) {
60
+ if (e.shiftKey) {
61
+ e.preventDefault();
62
+ tableContext.setFocusEnd(focusDetails.coordinates);
63
+ } else {
64
+ tableContext.startFocus(focusDetails.coordinates);
65
+ }
66
+ }
67
+ }}
68
+ onmouseover={() => {
69
+ if (tableContext.isMousingDown) {
70
+ tableContext.setFocusEnd(focusDetails.coordinates);
71
+ }
72
+ }}
73
+ onmouseup={() => {
74
+ tableContext.endFocus(focusDetails.coordinates);
75
+ }}
76
+ >
77
+ <div class="bubble-parent">
78
+ {#await values then values}
79
+ <!-- eslint-disable-next-line svelte/require-each-key -->
80
+ {#each values as value}
81
+ {@const colourPromise = (cell.column.columnDef as BubbleDef<T>).getColour?.(
82
+ cell.row.original,
83
+ cell.row.originalIndex,
84
+ value
85
+ )}
86
+
87
+ {#if colourPromise == undefined}
88
+ <Bubble {value} />
89
+ {:else}
90
+ {#await colourPromise then colour}
91
+ <Bubble
92
+ {value}
93
+ colours={colour}
94
+ />
95
+ {/await}
96
+ {/if}
97
+ {/each}
98
+ {/await}
99
+ </div>
100
+ </td>
101
+
102
102
  <style>td {
103
103
  transition: line-height 0.2s ease, height 0.2s ease;
104
104
  --input-border: none;
@@ -157,4 +157,4 @@ div.bubble-parent {
157
157
  align-items: center;
158
158
  gap: 0.5rem;
159
159
  --line-height: 1;
160
- }</style>
160
+ }</style>