@lavalogic/scoria 0.39.2 → 0.40.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 (141) hide show
  1. package/README.md +58 -58
  2. package/dist/Components/AccordionGroup.svelte +46 -46
  3. package/dist/Components/AccordionGroupButton.svelte +76 -76
  4. package/dist/Components/Action.svelte +136 -136
  5. package/dist/Components/AlertModal.svelte +195 -195
  6. package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
  7. package/dist/Components/Base/BaseModal.svelte +125 -125
  8. package/dist/Components/Base/ContextWrapper.svelte +72 -72
  9. package/dist/Components/Base/Pagination.svelte +198 -198
  10. package/dist/Components/Base/Snippets.svelte +36 -36
  11. package/dist/Components/BigRadioSet.svelte +38 -38
  12. package/dist/Components/Bubble.svelte +101 -101
  13. package/dist/Components/Button.svelte +209 -209
  14. package/dist/Components/Checkbox.svelte +86 -86
  15. package/dist/Components/CollapsibleCard.svelte +78 -78
  16. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +212 -0
  17. package/dist/Components/ConditionBuilder/ConditionBuilder.svelte.d.ts +25 -0
  18. package/dist/Components/ConditionBuilder/ConditionBuilderProps.d.ts +45 -0
  19. package/dist/Components/ConditionBuilder/ConditionBuilderProps.js +1 -0
  20. package/dist/Components/ConditionBuilder/ConditionTree.d.ts +27 -0
  21. package/dist/Components/ConditionBuilder/ConditionTree.js +9 -0
  22. package/dist/Components/Contexts/ContextMenu.svelte +164 -164
  23. package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
  24. package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
  25. package/dist/Components/Contexts/Toast.svelte +86 -86
  26. package/dist/Components/Contexts/ToastContainer.svelte +65 -65
  27. package/dist/Components/Contexts/Tooltip.svelte +37 -37
  28. package/dist/Components/DataMatrixIcon.svelte +112 -112
  29. package/dist/Components/DateInput.svelte +148 -148
  30. package/dist/Components/DatePicker.svelte +300 -300
  31. package/dist/Components/DesktopModal.svelte +90 -90
  32. package/dist/Components/Dial.svelte +204 -204
  33. package/dist/Components/DimensionInput.svelte +170 -170
  34. package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
  35. package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
  36. package/dist/Components/FileCard.svelte +24 -24
  37. package/dist/Components/FileUpload.svelte +236 -236
  38. package/dist/Components/GridInput.svelte +196 -196
  39. package/dist/Components/GridInputSet.svelte +29 -29
  40. package/dist/Components/HorizontalTabGroup.svelte +82 -82
  41. package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
  42. package/dist/Components/Icon.svelte +128 -128
  43. package/dist/Components/Icons.js +357 -357
  44. package/dist/Components/InfoAlert.svelte +35 -35
  45. package/dist/Components/LoadingAnimation.svelte +29 -29
  46. package/dist/Components/LoadingModal.svelte +45 -45
  47. package/dist/Components/LoadingOverlay.svelte +25 -25
  48. package/dist/Components/Modal.svelte +258 -258
  49. package/dist/Components/MultiSelect.svelte +220 -220
  50. package/dist/Components/Nav/Nav.svelte +110 -110
  51. package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
  52. package/dist/Components/Nav/NavTab.svelte +62 -62
  53. package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
  54. package/dist/Components/Nav/ServicesNav.svelte +80 -80
  55. package/dist/Components/NumberInput.svelte +157 -157
  56. package/dist/Components/PageHeading.svelte +25 -25
  57. package/dist/Components/PasswordInput.svelte +88 -88
  58. package/dist/Components/Portal.svelte +36 -36
  59. package/dist/Components/ProgressBubble.svelte +107 -107
  60. package/dist/Components/QuerySelect.svelte +366 -366
  61. package/dist/Components/SingleSelect.svelte +250 -250
  62. package/dist/Components/StepButton.svelte +70 -70
  63. package/dist/Components/StepForm.svelte +140 -140
  64. package/dist/Components/Switch.svelte +69 -69
  65. package/dist/Components/Table/ARCHITECTURE.md +298 -298
  66. package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
  67. package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
  68. package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
  69. package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
  70. package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
  71. package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
  72. package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
  73. package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
  74. package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
  75. package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
  76. package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
  77. package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -126
  78. package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
  79. package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
  80. package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
  81. package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
  82. package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
  83. package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
  84. package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
  85. package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
  86. package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
  87. package/dist/Components/Table/Body/TableBody.svelte +155 -155
  88. package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
  89. package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
  90. package/dist/Components/Table/Headers/TableHead.svelte +415 -415
  91. package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
  92. package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
  93. package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
  94. package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
  95. package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
  96. package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
  97. package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
  98. package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
  99. package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
  100. package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
  101. package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
  102. package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
  103. package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
  104. package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
  105. package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
  106. package/dist/Components/Table/NestedTable.svelte +130 -130
  107. package/dist/Components/Table/Table.svelte +692 -692
  108. package/dist/Components/Test/TestContextConsumer.svelte +13 -13
  109. package/dist/Components/TextArea.svelte +130 -130
  110. package/dist/Components/TextInput.svelte +176 -176
  111. package/dist/Components/ThreeStateRadio.svelte +131 -131
  112. package/dist/Components/Touch/BoolCard.svelte +45 -45
  113. package/dist/Components/Touch/DateModal.svelte +209 -209
  114. package/dist/Components/Touch/EditCard.svelte +59 -59
  115. package/dist/Components/Touch/InfoCard.svelte +31 -31
  116. package/dist/Components/Touch/InfoTextCard.svelte +28 -28
  117. package/dist/Components/Touch/ModalExplanation.svelte +17 -17
  118. package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
  119. package/dist/Components/Touch/NumberModal.svelte +79 -79
  120. package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
  121. package/dist/Components/Touch/SelectModal.svelte +127 -127
  122. package/dist/Components/Touch/SummaryCard.svelte +93 -93
  123. package/dist/Components/Touch/TextAreaModal.svelte +95 -95
  124. package/dist/Components/Touch/TextModal.svelte +106 -106
  125. package/dist/Components/Touch/TouchCard.svelte +33 -33
  126. package/dist/Components/Touch/TouchModal.svelte +274 -274
  127. package/dist/Components/Touch/UtilityButton.svelte +109 -109
  128. package/dist/Components/VerticalTabGroup.svelte +79 -79
  129. package/dist/Components/VerticalTabGroupButton.svelte +58 -58
  130. package/dist/Helpers/Datamatrix.d.ts +19 -19
  131. package/dist/Helpers/Datamatrix.js +291 -291
  132. package/dist/Types/Examples/ExampleModal.svelte +35 -35
  133. package/dist/index.d.ts +3 -0
  134. package/dist/index.js +2 -0
  135. package/dist/scss/_basics.scss +12 -12
  136. package/dist/scss/_colours.scss +134 -134
  137. package/dist/scss/_mixins.scss +3392 -3392
  138. package/dist/scss/_motion.scss +57 -57
  139. package/dist/scss/_sizing.scss +85 -85
  140. package/dist/scss/_transitions.scss +8 -8
  141. package/package.json +1 -1
@@ -1,79 +1,79 @@
1
- <svelte:options runes />
2
-
3
- <script
4
- lang="ts"
5
- module
6
- >
7
- import { AccessorDef } from '../../../Types/Columns/Definitions/Accessors/AccessorDef.svelte.js';
8
- import type { ColumnDef } from '../../../Types/Columns/Definitions/ColumnDef.svelte.js';
9
- import type { Component } from 'svelte';
10
- import type { AccessorComponentProps } from './AccessorComponentProps.js';
11
- import FocusableImmutableCell from './FocusableImmutableCell.svelte';
12
- import TableCheckbox from './TableCheckbox.svelte';
13
- import TableDatePicker from './TableDatePicker.svelte';
14
- import TableNumberInput from './TableNumberInput.svelte';
15
- import TableQuerySelect from './TableQuerySelect.svelte';
16
- import TableSelect from './TableSelect.svelte';
17
- import TableTextInput from './TableTextInput.svelte';
18
-
19
- /**
20
- * Loose structural type used for the cell-host dispatch table.
21
- *
22
- * Every accessor cell host (TableNumberInput, TableDatePicker, ...) is a
23
- * Svelte 5 `Component` whose props include at minimum `{ cell: TableCell<T> }`
24
- * plus host-specific extras. A fully discriminated `AccessorComponentMap<T>`
25
- * keyed on `accessorType` was considered (see the RowGenericThreading
26
- * follow-up workorder) but deferred: it would force every cell host to share
27
- * an identical prop signature or each branch of the dispatch to be invoked
28
- * through a type-narrowed switch, both of which have a large blast radius
29
- * across the Table subtree. Using `Component<Record<string, unknown>>` keeps
30
- * the residual loosening contained to a single line and removes the previous
31
- * `Component<any>` from this file.
32
- */
33
- type AccessorCellComponent = Component<Record<string, unknown>>;
34
-
35
- /**
36
- * Frozen lookup from `AccessorDef.accessorType` discriminator to the matching
37
- * cell-host Svelte component. Hoisted to module scope so the table does not
38
- * allocate a fresh 6-key object per cell on each render (with 100 rows by
39
- * roughly 10 accessor columns that would be 1000 redundant allocations per
40
- * render).
41
- */
42
- const cellTypes = Object.freeze({
43
- Number: TableNumberInput,
44
- Date: TableDatePicker,
45
- Select: TableSelect,
46
- Query: TableQuerySelect,
47
- Checkbox: TableCheckbox,
48
- Text: TableTextInput,
49
- }) as unknown as Readonly<
50
- Record<'Number' | 'Date' | 'Select' | 'Checkbox' | 'Query' | 'Text', AccessorCellComponent>
51
- >;
52
- </script>
53
-
54
- <script
55
- lang="ts"
56
- generics="T extends object"
57
- >
58
- /** Single cell to render for the supplied {@link TableCell}. The accessor type discriminator is read off `cell.column.columnDef`. */
59
- const { cell }: AccessorComponentProps<T> = $props();
60
-
61
- const CurrentComponent = $derived(getAppropriateAccessorDef(cell.column.columnDef));
62
-
63
- /**
64
- * Returns the cell-host component for `columnDef`'s discriminant. Falls back
65
- * to `FocusableImmutableCell` when the column is not an `AccessorDef` (this
66
- * branch is technically dead in the live dispatcher since `TableColumn`
67
- * filters first, but the total function keeps this file safe to call
68
- * directly from other dispatch sites).
69
- */
70
- function getAppropriateAccessorDef(columnDef: ColumnDef<T>): AccessorCellComponent {
71
- if (columnDef instanceof AccessorDef) {
72
- return cellTypes[columnDef.accessorType];
73
- }
74
-
75
- return FocusableImmutableCell as unknown as AccessorCellComponent;
76
- }
77
- </script>
78
-
79
- <CurrentComponent {cell} />
1
+ <svelte:options runes />
2
+
3
+ <script
4
+ lang="ts"
5
+ module
6
+ >
7
+ import { AccessorDef } from '../../../Types/Columns/Definitions/Accessors/AccessorDef.svelte.js';
8
+ import type { ColumnDef } from '../../../Types/Columns/Definitions/ColumnDef.svelte.js';
9
+ import type { Component } from 'svelte';
10
+ import type { AccessorComponentProps } from './AccessorComponentProps.js';
11
+ import FocusableImmutableCell from './FocusableImmutableCell.svelte';
12
+ import TableCheckbox from './TableCheckbox.svelte';
13
+ import TableDatePicker from './TableDatePicker.svelte';
14
+ import TableNumberInput from './TableNumberInput.svelte';
15
+ import TableQuerySelect from './TableQuerySelect.svelte';
16
+ import TableSelect from './TableSelect.svelte';
17
+ import TableTextInput from './TableTextInput.svelte';
18
+
19
+ /**
20
+ * Loose structural type used for the cell-host dispatch table.
21
+ *
22
+ * Every accessor cell host (TableNumberInput, TableDatePicker, ...) is a
23
+ * Svelte 5 `Component` whose props include at minimum `{ cell: TableCell<T> }`
24
+ * plus host-specific extras. A fully discriminated `AccessorComponentMap<T>`
25
+ * keyed on `accessorType` was considered (see the RowGenericThreading
26
+ * follow-up workorder) but deferred: it would force every cell host to share
27
+ * an identical prop signature or each branch of the dispatch to be invoked
28
+ * through a type-narrowed switch, both of which have a large blast radius
29
+ * across the Table subtree. Using `Component<Record<string, unknown>>` keeps
30
+ * the residual loosening contained to a single line and removes the previous
31
+ * `Component<any>` from this file.
32
+ */
33
+ type AccessorCellComponent = Component<Record<string, unknown>>;
34
+
35
+ /**
36
+ * Frozen lookup from `AccessorDef.accessorType` discriminator to the matching
37
+ * cell-host Svelte component. Hoisted to module scope so the table does not
38
+ * allocate a fresh 6-key object per cell on each render (with 100 rows by
39
+ * roughly 10 accessor columns that would be 1000 redundant allocations per
40
+ * render).
41
+ */
42
+ const cellTypes = Object.freeze({
43
+ Number: TableNumberInput,
44
+ Date: TableDatePicker,
45
+ Select: TableSelect,
46
+ Query: TableQuerySelect,
47
+ Checkbox: TableCheckbox,
48
+ Text: TableTextInput,
49
+ }) as unknown as Readonly<
50
+ Record<'Number' | 'Date' | 'Select' | 'Checkbox' | 'Query' | 'Text', AccessorCellComponent>
51
+ >;
52
+ </script>
53
+
54
+ <script
55
+ lang="ts"
56
+ generics="T extends object"
57
+ >
58
+ /** Single cell to render for the supplied {@link TableCell}. The accessor type discriminator is read off `cell.column.columnDef`. */
59
+ const { cell }: AccessorComponentProps<T> = $props();
60
+
61
+ const CurrentComponent = $derived(getAppropriateAccessorDef(cell.column.columnDef));
62
+
63
+ /**
64
+ * Returns the cell-host component for `columnDef`'s discriminant. Falls back
65
+ * to `FocusableImmutableCell` when the column is not an `AccessorDef` (this
66
+ * branch is technically dead in the live dispatcher since `TableColumn`
67
+ * filters first, but the total function keeps this file safe to call
68
+ * directly from other dispatch sites).
69
+ */
70
+ function getAppropriateAccessorDef(columnDef: ColumnDef<T>): AccessorCellComponent {
71
+ if (columnDef instanceof AccessorDef) {
72
+ return cellTypes[columnDef.accessorType];
73
+ }
74
+
75
+ return FocusableImmutableCell as unknown as AccessorCellComponent;
76
+ }
77
+ </script>
78
+
79
+ <CurrentComponent {cell} />
@@ -1,187 +1,187 @@
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 type { Primitive } from '../../../Types/Context/TableInitOptions.js';
12
- import { MultiFocusEdge } from '../../../Types/Focus/MultiFocusEdge.js';
13
- import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
14
- import { asyncMap, devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
15
- import { Colour, ColourSet } from '../../../../../scss/colours.js';
16
- import { Size } from '../../../../../Types/Internal/Size.js';
17
- import { Validity } from '../../../../../Types/Internal/Validity.js';
18
- import { getContext, untrack } from 'svelte';
19
- import type { ActionsCellProps } from './ActionsCellProps.js';
20
- import TableAction from './TableAction.svelte';
21
- </script>
22
-
23
- <script
24
- lang="ts"
25
- generics="T extends object, FilterValueType, RowIdType extends Primitive"
26
- >
27
- const { cell }: ActionsCellProps<T, FilterValueType> = $props();
28
-
29
- const value = $derived(cell.getValue());
30
-
31
- const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
32
-
33
- const actions: Array<TableActionButton<T>> = $derived(cell.column.columnDef.actions);
34
-
35
- const thisPopup = $state(Symbol());
36
- const thisPopupIsVisibile = $derived(thisPopup === tableContext.shownActionsPopup);
37
- const hasValue: boolean = $derived(value !== undefined);
38
- const edge: MultiFocusEdge | undefined = $state();
39
- const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
40
- tableContext._focus.getFocusDetailsFor(cell)
41
- );
42
-
43
- let cellRef: HTMLDivElement | undefined = $state();
44
-
45
- let x = $state(0);
46
- let y = $state(0);
47
- $effect.pre(() => {
48
- if (thisPopupIsVisibile && cellRef) {
49
- const rect = cellRef.getBoundingClientRect();
50
- untrack(() => {
51
- const totalOffsetX = -6;
52
- const totalOffsetY = rect.height / 2;
53
-
54
- x = rect.x + totalOffsetX;
55
- y = rect.y + totalOffsetY;
56
- });
57
- }
58
- });
59
-
60
- let validity: Validity = $state(Validity.Valid);
61
- $effect(() => {
62
- const validityPromise = focusDetails.validity;
63
-
64
- validityPromise
65
- .then((v) => {
66
- if (!v) {
67
- validity = Validity.Neutral;
68
- } else if (isValidityTuple(v)) {
69
- validity = v.value;
70
- } else {
71
- validity = v;
72
- }
73
- })
74
- .catch(devCatch);
75
- });
76
- </script>
77
-
78
- <!-- svelte-ignore a11y_mouse_events_have_key_events -->
79
- <!-- svelte-ignore a11y_no_static_element_interactions -->
80
- <div
81
- id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
82
- tabIndex={hasValue ? 0 : undefined}
83
- class="focusable"
84
- class:multifocus={hasValue && focusDetails.isMultiFocused}
85
- class:multifocus-start={hasValue && focusDetails.isMultiFocusStart}
86
- class:left={edge === MultiFocusEdge.Left}
87
- class:top-left={edge === MultiFocusEdge.TopLeft}
88
- class:top={edge === MultiFocusEdge.Top}
89
- class:top-right={edge === MultiFocusEdge.TopRight}
90
- class:right={edge === MultiFocusEdge.Right}
91
- class:bottom-right={edge === MultiFocusEdge.BottomRight}
92
- class:bottom={edge === MultiFocusEdge.Bottom}
93
- class:bottom-left={edge === MultiFocusEdge.BottomLeft}
94
- class:info={validity == Validity.Info}
95
- class:success={validity == Validity.Valid}
96
- class:warning={validity == Validity.Warning}
97
- class:error={validity == Validity.Invalid}
98
- onmousedown={(e) => {
99
- // start focus only on left click
100
- if (e.button === 0) {
101
- if (e.shiftKey) {
102
- e.preventDefault();
103
- tableContext.setFocusEnd(focusDetails.coordinates);
104
- } else {
105
- tableContext.startFocus(focusDetails.coordinates);
106
- }
107
- }
108
- }}
109
- onmouseover={() => {
110
- if (tableContext.isMousingDown) {
111
- tableContext.setFocusEnd(focusDetails.coordinates);
112
- }
113
- }}
114
- onmouseup={() => {
115
- tableContext.endFocus(focusDetails.coordinates);
116
- }}
117
- >
118
- <!-- svelte-ignore a11y_no_static_element_interactions -->
119
- <div
120
- class="slot-wrapper"
121
- class:multifocus={focusDetails.isMultiFocused}
122
- class:multifocus-start={focusDetails.isMultiFocusStart}
123
- bind:this={cellRef}
124
- onmousedown={(e) => {
125
- // Suppress click side effects that jump the table horizontally
126
- // on Action clicks:
127
- // 1. `preventDefault()` cancels the default mousedown ->
128
- // focus on the inner `<button>`, which would otherwise
129
- // call `scrollIntoView` against the button's position
130
- // at the far right (the Actions column is sticky-pinned
131
- // right).
132
- // 2. `stopPropagation()` keeps the event out of the outer
133
- // `.focusable` cell handler, which would otherwise call
134
- // `tableContext.startFocus(...)` and trigger another
135
- // `scrollIntoView` via Table.svelte's focusStart effect.
136
- // The Action's `onclick` still fires (click is dispatched on
137
- // mouseup independent of mousedown), so the popup toggle works.
138
- e.preventDefault();
139
- e.stopPropagation();
140
- }}
141
- >
142
- <!-- TODO {isMultiFocusStart} -->
143
- <Action
144
- style={focusDetails.outline}
145
- border={false}
146
- size={Size.FillWidth}
147
- icon={{ name: 'ellipsis', size: Size.Medium, colour: Colour['$brand-primary'] }}
148
- colourSet={ColourSet.Auxiliary}
149
- onclick={() => {
150
- if (tableContext.shownActionsPopup === thisPopup) {
151
- tableContext.shownActionsPopup = undefined;
152
- } else {
153
- tableContext.shownActionsPopup = thisPopup;
154
- }
155
- }}
156
- />
157
- </div>
158
- {#if thisPopupIsVisibile}
159
- {@const awaitedActions = asyncMap<TableActionButton<T>, [TableActionButton<T>, string]>(
160
- actions,
161
- async (item) => {
162
- return [item, await item.getLabel(cell.row.original, cell.row.visibleIndex)];
163
- }
164
- )}
165
- {#await awaitedActions then actions}
166
- <Portal>
167
- <div
168
- class="popup"
169
- style="--y: {y}px; --x: {x}px;"
170
- >
171
- <div class="action-container">
172
- {#each actions as [action, label] (label)}
173
- <TableAction
174
- {action}
175
- {cell}
176
- />
177
- {/each}
178
- </div>
179
- </div>
180
- </Portal>
181
- {/await}
182
- {/if}
183
- </div>
184
-
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 type { Primitive } from '../../../Types/Context/TableInitOptions.js';
12
+ import { MultiFocusEdge } from '../../../Types/Focus/MultiFocusEdge.js';
13
+ import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
14
+ import { asyncMap, devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
15
+ import { Colour, ColourSet } from '../../../../../scss/colours.js';
16
+ import { Size } from '../../../../../Types/Internal/Size.js';
17
+ import { Validity } from '../../../../../Types/Internal/Validity.js';
18
+ import { getContext, untrack } from 'svelte';
19
+ import type { ActionsCellProps } from './ActionsCellProps.js';
20
+ import TableAction from './TableAction.svelte';
21
+ </script>
22
+
23
+ <script
24
+ lang="ts"
25
+ generics="T extends object, FilterValueType, RowIdType extends Primitive"
26
+ >
27
+ const { cell }: ActionsCellProps<T, FilterValueType> = $props();
28
+
29
+ const value = $derived(cell.getValue());
30
+
31
+ const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
32
+
33
+ const actions: Array<TableActionButton<T>> = $derived(cell.column.columnDef.actions);
34
+
35
+ const thisPopup = $state(Symbol());
36
+ const thisPopupIsVisibile = $derived(thisPopup === tableContext.shownActionsPopup);
37
+ const hasValue: boolean = $derived(value !== undefined);
38
+ const edge: MultiFocusEdge | undefined = $state();
39
+ const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
40
+ tableContext._focus.getFocusDetailsFor(cell)
41
+ );
42
+
43
+ let cellRef: HTMLDivElement | undefined = $state();
44
+
45
+ let x = $state(0);
46
+ let y = $state(0);
47
+ $effect.pre(() => {
48
+ if (thisPopupIsVisibile && cellRef) {
49
+ const rect = cellRef.getBoundingClientRect();
50
+ untrack(() => {
51
+ const totalOffsetX = -6;
52
+ const totalOffsetY = rect.height / 2;
53
+
54
+ x = rect.x + totalOffsetX;
55
+ y = rect.y + totalOffsetY;
56
+ });
57
+ }
58
+ });
59
+
60
+ let validity: Validity = $state(Validity.Valid);
61
+ $effect(() => {
62
+ const validityPromise = focusDetails.validity;
63
+
64
+ validityPromise
65
+ .then((v) => {
66
+ if (!v) {
67
+ validity = Validity.Neutral;
68
+ } else if (isValidityTuple(v)) {
69
+ validity = v.value;
70
+ } else {
71
+ validity = v;
72
+ }
73
+ })
74
+ .catch(devCatch);
75
+ });
76
+ </script>
77
+
78
+ <!-- svelte-ignore a11y_mouse_events_have_key_events -->
79
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
80
+ <div
81
+ id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
82
+ tabIndex={hasValue ? 0 : undefined}
83
+ class="focusable"
84
+ class:multifocus={hasValue && focusDetails.isMultiFocused}
85
+ class:multifocus-start={hasValue && focusDetails.isMultiFocusStart}
86
+ class:left={edge === MultiFocusEdge.Left}
87
+ class:top-left={edge === MultiFocusEdge.TopLeft}
88
+ class:top={edge === MultiFocusEdge.Top}
89
+ class:top-right={edge === MultiFocusEdge.TopRight}
90
+ class:right={edge === MultiFocusEdge.Right}
91
+ class:bottom-right={edge === MultiFocusEdge.BottomRight}
92
+ class:bottom={edge === MultiFocusEdge.Bottom}
93
+ class:bottom-left={edge === MultiFocusEdge.BottomLeft}
94
+ class:info={validity == Validity.Info}
95
+ class:success={validity == Validity.Valid}
96
+ class:warning={validity == Validity.Warning}
97
+ class:error={validity == Validity.Invalid}
98
+ onmousedown={(e) => {
99
+ // start focus only on left click
100
+ if (e.button === 0) {
101
+ if (e.shiftKey) {
102
+ e.preventDefault();
103
+ tableContext.setFocusEnd(focusDetails.coordinates);
104
+ } else {
105
+ tableContext.startFocus(focusDetails.coordinates);
106
+ }
107
+ }
108
+ }}
109
+ onmouseover={() => {
110
+ if (tableContext.isMousingDown) {
111
+ tableContext.setFocusEnd(focusDetails.coordinates);
112
+ }
113
+ }}
114
+ onmouseup={() => {
115
+ tableContext.endFocus(focusDetails.coordinates);
116
+ }}
117
+ >
118
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
119
+ <div
120
+ class="slot-wrapper"
121
+ class:multifocus={focusDetails.isMultiFocused}
122
+ class:multifocus-start={focusDetails.isMultiFocusStart}
123
+ bind:this={cellRef}
124
+ onmousedown={(e) => {
125
+ // Suppress click side effects that jump the table horizontally
126
+ // on Action clicks:
127
+ // 1. `preventDefault()` cancels the default mousedown ->
128
+ // focus on the inner `<button>`, which would otherwise
129
+ // call `scrollIntoView` against the button's position
130
+ // at the far right (the Actions column is sticky-pinned
131
+ // right).
132
+ // 2. `stopPropagation()` keeps the event out of the outer
133
+ // `.focusable` cell handler, which would otherwise call
134
+ // `tableContext.startFocus(...)` and trigger another
135
+ // `scrollIntoView` via Table.svelte's focusStart effect.
136
+ // The Action's `onclick` still fires (click is dispatched on
137
+ // mouseup independent of mousedown), so the popup toggle works.
138
+ e.preventDefault();
139
+ e.stopPropagation();
140
+ }}
141
+ >
142
+ <!-- TODO {isMultiFocusStart} -->
143
+ <Action
144
+ style={focusDetails.outline}
145
+ border={false}
146
+ size={Size.FillWidth}
147
+ icon={{ name: 'ellipsis', size: Size.Medium, colour: Colour['$brand-primary'] }}
148
+ colourSet={ColourSet.Auxiliary}
149
+ onclick={() => {
150
+ if (tableContext.shownActionsPopup === thisPopup) {
151
+ tableContext.shownActionsPopup = undefined;
152
+ } else {
153
+ tableContext.shownActionsPopup = thisPopup;
154
+ }
155
+ }}
156
+ />
157
+ </div>
158
+ {#if thisPopupIsVisibile}
159
+ {@const awaitedActions = asyncMap<TableActionButton<T>, [TableActionButton<T>, string]>(
160
+ actions,
161
+ async (item) => {
162
+ return [item, await item.getLabel(cell.row.original, cell.row.visibleIndex)];
163
+ }
164
+ )}
165
+ {#await awaitedActions then actions}
166
+ <Portal>
167
+ <div
168
+ class="popup"
169
+ style="--y: {y}px; --x: {x}px;"
170
+ >
171
+ <div class="action-container">
172
+ {#each actions as [action, label] (label)}
173
+ <TableAction
174
+ {action}
175
+ {cell}
176
+ />
177
+ {/each}
178
+ </div>
179
+ </div>
180
+ </Portal>
181
+ {/await}
182
+ {/if}
183
+ </div>
184
+
185
185
  <style>.focusable,
186
186
  .checkbox-cell,
187
187
  .input-cell,
@@ -333,4 +333,4 @@ div.slot-wrapper {
333
333
  display: flex;
334
334
  align-items: center;
335
335
  justify-content: center;
336
- }</style>
336
+ }</style>