@lavalogic/scoria 0.40.1 → 0.40.3
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.
- package/README.md +58 -58
- package/dist/Components/AccordionGroup.svelte +46 -46
- package/dist/Components/AccordionGroupButton.svelte +76 -76
- package/dist/Components/Action.svelte +136 -136
- package/dist/Components/AlertModal.svelte +195 -195
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +729 -729
- package/dist/Components/Base/BaseModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +72 -72
- package/dist/Components/Base/Pagination.svelte +198 -198
- package/dist/Components/Base/Snippets.svelte +36 -36
- package/dist/Components/BigRadioSet.svelte +38 -38
- package/dist/Components/Bubble.svelte +101 -101
- package/dist/Components/Button.svelte +209 -209
- package/dist/Components/Checkbox.svelte +86 -86
- package/dist/Components/CollapsibleCard.svelte +78 -78
- package/dist/Components/Contexts/ContextMenu.svelte +164 -164
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +60 -60
- package/dist/Components/Contexts/Toast.svelte +86 -86
- package/dist/Components/Contexts/ToastContainer.svelte +65 -65
- package/dist/Components/Contexts/Tooltip.svelte +37 -37
- package/dist/Components/DataMatrixIcon.svelte +112 -112
- package/dist/Components/DateInput.svelte +148 -148
- package/dist/Components/DatePicker.svelte +300 -300
- package/dist/Components/DesktopModal.svelte +90 -90
- package/dist/Components/Dial.svelte +204 -204
- package/dist/Components/DimensionInput.svelte +170 -170
- package/dist/Components/DragMenu/DragMenuHolder.svelte +119 -119
- package/dist/Components/DragMenu/DraggableCard.svelte +77 -77
- package/dist/Components/FileCard.svelte +24 -24
- package/dist/Components/FileUpload.svelte +236 -236
- package/dist/Components/GridInput.svelte +196 -196
- package/dist/Components/GridInputSet.svelte +29 -29
- package/dist/Components/HorizontalTabGroup.svelte +82 -82
- package/dist/Components/HorizontalTabGroupButton.svelte +44 -44
- package/dist/Components/Icon.svelte +128 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -35
- package/dist/Components/LoadingAnimation.svelte +29 -29
- package/dist/Components/LoadingModal.svelte +45 -45
- package/dist/Components/LoadingOverlay.svelte +25 -25
- package/dist/Components/Modal.svelte +258 -258
- package/dist/Components/MultiSelect.svelte +220 -220
- package/dist/Components/Nav/Nav.svelte +110 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
- package/dist/Components/Nav/NavTab.svelte +62 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +112 -112
- package/dist/Components/Nav/ServicesNav.svelte +80 -80
- package/dist/Components/NumberInput.svelte +157 -157
- package/dist/Components/PageHeading.svelte +25 -25
- package/dist/Components/PasswordInput.svelte +88 -88
- package/dist/Components/Portal.svelte +36 -36
- package/dist/Components/ProgressBubble.svelte +107 -107
- package/dist/Components/QuerySelect.svelte +366 -366
- package/dist/Components/SingleSelect.svelte +250 -250
- package/dist/Components/StepButton.svelte +70 -70
- package/dist/Components/StepForm.svelte +140 -140
- package/dist/Components/Switch.svelte +69 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -679
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +51 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +59 -59
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +454 -454
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -185
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +163 -120
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +234 -234
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +160 -126
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +159 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +246 -246
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -252
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -221
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +197 -197
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +190 -190
- package/dist/Components/Table/Body/Rows/TableRow.svelte +290 -290
- package/dist/Components/Table/Body/TableBody.svelte +155 -155
- package/dist/Components/Table/ColumnFactory.svelte.js +7 -0
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +41 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +30 -30
- package/dist/Components/Table/Headers/TableHead.svelte +415 -415
- package/dist/Components/Table/Misc/ColumnPanel.svelte +39 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +39 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +641 -641
- package/dist/Components/Table/Misc/FilterPanel.svelte +190 -190
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +31 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +291 -291
- package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +644 -644
- package/dist/Components/Table/Misc/TableFooter.svelte +340 -340
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +140 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +200 -200
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +105 -105
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +192 -192
- package/dist/Components/Table/NestedTable.svelte +130 -130
- package/dist/Components/Table/Table.svelte +692 -692
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +9 -0
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +6 -0
- package/dist/Components/Table/Types/Public/ColumnOptions.d.ts +19 -0
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +130 -130
- package/dist/Components/TextInput.svelte +176 -176
- package/dist/Components/ThreeStateRadio.svelte +131 -131
- package/dist/Components/Touch/BoolCard.svelte +45 -45
- package/dist/Components/Touch/DateModal.svelte +209 -209
- package/dist/Components/Touch/EditCard.svelte +59 -59
- package/dist/Components/Touch/InfoCard.svelte +31 -31
- package/dist/Components/Touch/InfoTextCard.svelte +28 -28
- package/dist/Components/Touch/ModalExplanation.svelte +17 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +225 -225
- package/dist/Components/Touch/NumberModal.svelte +79 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +46 -46
- package/dist/Components/Touch/SelectModal.svelte +127 -127
- package/dist/Components/Touch/SummaryCard.svelte +93 -93
- package/dist/Components/Touch/TextAreaModal.svelte +95 -95
- package/dist/Components/Touch/TextModal.svelte +106 -106
- package/dist/Components/Touch/TouchCard.svelte +33 -33
- package/dist/Components/Touch/TouchModal.svelte +274 -274
- package/dist/Components/Touch/UtilityButton.svelte +109 -109
- package/dist/Components/VerticalTabGroup.svelte +79 -79
- package/dist/Components/VerticalTabGroupButton.svelte +58 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +35 -35
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3392 -3392
- package/dist/scss/_motion.scss +57 -57
- package/dist/scss/_sizing.scss +85 -85
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +1 -1
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object, FilterValueType, RowIdType extends Primitive"
|
|
6
|
-
>
|
|
7
|
-
import Bubble from '../../../../Bubble.svelte';
|
|
8
|
-
import { BubbleDef } from '../../../Types/Columns/Definitions/Display/BubbleDef.svelte.js';
|
|
9
|
-
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
10
|
-
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
11
|
-
import type { 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 { BubbleCellProps } from './BubbleCellProps.js';
|
|
16
|
-
|
|
17
|
-
const { cell }: BubbleCellProps<T, FilterValueType> = $props();
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Awaited or sync array of string labels to render as Bubble chips.
|
|
21
|
-
* The cast is required because `BubbleDef` does not yet carry a
|
|
22
|
-
* narrowed `TValue` generic and the dispatch passes the loose
|
|
23
|
-
* `TableCell` rather than `BubbleTableCell<T, FilterValueType>`.
|
|
24
|
-
*/
|
|
25
|
-
const values = $derived(cell.getValue()) as Array<string> | Promise<Array<string>>;
|
|
26
|
-
|
|
27
|
-
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
28
|
-
|
|
29
|
-
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
30
|
-
tableContext._focus.getFocusDetailsFor(cell)
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
let validity: Validity = $state(Validity.Valid);
|
|
34
|
-
$effect(() => {
|
|
35
|
-
const validityPromise = focusDetails.validity;
|
|
36
|
-
|
|
37
|
-
validityPromise
|
|
38
|
-
.then((v) => {
|
|
39
|
-
if (!v) {
|
|
40
|
-
validity = Validity.Neutral;
|
|
41
|
-
} else if (isValidityTuple(v)) {
|
|
42
|
-
validity = v.value;
|
|
43
|
-
} else {
|
|
44
|
-
validity = v;
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
.catch(devCatch);
|
|
48
|
-
});
|
|
49
|
-
</script>
|
|
50
|
-
|
|
51
|
-
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
52
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
53
|
-
<div
|
|
54
|
-
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
55
|
-
tabIndex={0}
|
|
56
|
-
class="focusable"
|
|
57
|
-
class:multifocus={focusDetails.isMultiFocused}
|
|
58
|
-
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
59
|
-
style={focusDetails.outline}
|
|
60
|
-
class:info={validity == Validity.Info}
|
|
61
|
-
class:success={validity == Validity.Valid}
|
|
62
|
-
class:warning={validity == Validity.Warning}
|
|
63
|
-
class:error={validity == Validity.Invalid}
|
|
64
|
-
onmousedown={(e) => {
|
|
65
|
-
// start focus only on left click
|
|
66
|
-
if (e.button === 0) {
|
|
67
|
-
if (e.shiftKey) {
|
|
68
|
-
e.preventDefault();
|
|
69
|
-
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
70
|
-
} else {
|
|
71
|
-
tableContext.startFocus(focusDetails.coordinates);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}}
|
|
75
|
-
onmouseover={() => {
|
|
76
|
-
if (tableContext.isMousingDown) {
|
|
77
|
-
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
78
|
-
}
|
|
79
|
-
}}
|
|
80
|
-
onmouseup={() => {
|
|
81
|
-
tableContext.endFocus(focusDetails.coordinates);
|
|
82
|
-
}}
|
|
83
|
-
>
|
|
84
|
-
<div class="bubble-parent">
|
|
85
|
-
{#await values then values}
|
|
86
|
-
<!-- `maxBubbles` (default 3) caps how many pills render inline;
|
|
87
|
-
anything beyond gets a single `"+N more"` overflow chip with
|
|
88
|
-
the hidden labels as a hover tooltip. Key combines index and
|
|
89
|
-
value because duplicate labels would otherwise collapse and
|
|
90
|
-
reordering with identical labels would force unrelated
|
|
91
|
-
bubbles to swap. -->
|
|
92
|
-
{@const maxBubbles = (cell.column.columnDef as BubbleDef<T>).maxBubbles ?? 3}
|
|
93
|
-
{@const visibleBubbles = values.slice(0, maxBubbles)}
|
|
94
|
-
{@const overflowCount = Math.max(0, values.length - maxBubbles)}
|
|
95
|
-
{@const overflowTitle = values.slice(maxBubbles).join(', ')}
|
|
96
|
-
{#each visibleBubbles as value, index (`${index}:${value}`)}
|
|
97
|
-
{@const colourPromise = (cell.column.columnDef as BubbleDef<T>).getColour?.(
|
|
98
|
-
cell.row.original,
|
|
99
|
-
cell.row.originalIndex,
|
|
100
|
-
value
|
|
101
|
-
)}
|
|
102
|
-
|
|
103
|
-
{#if colourPromise == undefined}
|
|
104
|
-
<Bubble {value} />
|
|
105
|
-
{:else}
|
|
106
|
-
{#await colourPromise then colour}
|
|
107
|
-
<Bubble
|
|
108
|
-
{value}
|
|
109
|
-
colours={colour ?? undefined}
|
|
110
|
-
/>
|
|
111
|
-
{/await}
|
|
112
|
-
{/if}
|
|
113
|
-
{/each}
|
|
114
|
-
{#if overflowCount > 0}
|
|
115
|
-
<span
|
|
116
|
-
class="bubble-overflow"
|
|
117
|
-
title={overflowTitle}
|
|
118
|
-
>+{overflowCount} more</span>
|
|
119
|
-
{/if}
|
|
120
|
-
{/await}
|
|
121
|
-
</div>
|
|
122
|
-
</div>
|
|
123
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object, FilterValueType, RowIdType extends Primitive"
|
|
6
|
+
>
|
|
7
|
+
import Bubble from '../../../../Bubble.svelte';
|
|
8
|
+
import { BubbleDef } from '../../../Types/Columns/Definitions/Display/BubbleDef.svelte.js';
|
|
9
|
+
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
10
|
+
import { type Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
11
|
+
import type { 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 { BubbleCellProps } from './BubbleCellProps.js';
|
|
16
|
+
|
|
17
|
+
const { cell }: BubbleCellProps<T, FilterValueType> = $props();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Awaited or sync array of string labels to render as Bubble chips.
|
|
21
|
+
* The cast is required because `BubbleDef` does not yet carry a
|
|
22
|
+
* narrowed `TValue` generic and the dispatch passes the loose
|
|
23
|
+
* `TableCell` rather than `BubbleTableCell<T, FilterValueType>`.
|
|
24
|
+
*/
|
|
25
|
+
const values = $derived(cell.getValue()) as Array<string> | Promise<Array<string>>;
|
|
26
|
+
|
|
27
|
+
const tableContext = getContext<TableContext<T, RowIdType>>(TableContext.identifier);
|
|
28
|
+
|
|
29
|
+
const focusDetails: TableFocusDetails<T, RowIdType> = $derived(
|
|
30
|
+
tableContext._focus.getFocusDetailsFor(cell)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
let validity: Validity = $state(Validity.Valid);
|
|
34
|
+
$effect(() => {
|
|
35
|
+
const validityPromise = focusDetails.validity;
|
|
36
|
+
|
|
37
|
+
validityPromise
|
|
38
|
+
.then((v) => {
|
|
39
|
+
if (!v) {
|
|
40
|
+
validity = Validity.Neutral;
|
|
41
|
+
} else if (isValidityTuple(v)) {
|
|
42
|
+
validity = v.value;
|
|
43
|
+
} else {
|
|
44
|
+
validity = v;
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.catch(devCatch);
|
|
48
|
+
});
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
52
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
53
|
+
<div
|
|
54
|
+
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
55
|
+
tabIndex={0}
|
|
56
|
+
class="focusable"
|
|
57
|
+
class:multifocus={focusDetails.isMultiFocused}
|
|
58
|
+
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
59
|
+
style={focusDetails.outline}
|
|
60
|
+
class:info={validity == Validity.Info}
|
|
61
|
+
class:success={validity == Validity.Valid}
|
|
62
|
+
class:warning={validity == Validity.Warning}
|
|
63
|
+
class:error={validity == Validity.Invalid}
|
|
64
|
+
onmousedown={(e) => {
|
|
65
|
+
// start focus only on left click
|
|
66
|
+
if (e.button === 0) {
|
|
67
|
+
if (e.shiftKey) {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
70
|
+
} else {
|
|
71
|
+
tableContext.startFocus(focusDetails.coordinates);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}}
|
|
75
|
+
onmouseover={() => {
|
|
76
|
+
if (tableContext.isMousingDown) {
|
|
77
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
78
|
+
}
|
|
79
|
+
}}
|
|
80
|
+
onmouseup={() => {
|
|
81
|
+
tableContext.endFocus(focusDetails.coordinates);
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<div class="bubble-parent">
|
|
85
|
+
{#await values then values}
|
|
86
|
+
<!-- `maxBubbles` (default 3) caps how many pills render inline;
|
|
87
|
+
anything beyond gets a single `"+N more"` overflow chip with
|
|
88
|
+
the hidden labels as a hover tooltip. Key combines index and
|
|
89
|
+
value because duplicate labels would otherwise collapse and
|
|
90
|
+
reordering with identical labels would force unrelated
|
|
91
|
+
bubbles to swap. -->
|
|
92
|
+
{@const maxBubbles = (cell.column.columnDef as BubbleDef<T>).maxBubbles ?? 3}
|
|
93
|
+
{@const visibleBubbles = values.slice(0, maxBubbles)}
|
|
94
|
+
{@const overflowCount = Math.max(0, values.length - maxBubbles)}
|
|
95
|
+
{@const overflowTitle = values.slice(maxBubbles).join(', ')}
|
|
96
|
+
{#each visibleBubbles as value, index (`${index}:${value}`)}
|
|
97
|
+
{@const colourPromise = (cell.column.columnDef as BubbleDef<T>).getColour?.(
|
|
98
|
+
cell.row.original,
|
|
99
|
+
cell.row.originalIndex,
|
|
100
|
+
value
|
|
101
|
+
)}
|
|
102
|
+
|
|
103
|
+
{#if colourPromise == undefined}
|
|
104
|
+
<Bubble {value} />
|
|
105
|
+
{:else}
|
|
106
|
+
{#await colourPromise then colour}
|
|
107
|
+
<Bubble
|
|
108
|
+
{value}
|
|
109
|
+
colours={colour ?? undefined}
|
|
110
|
+
/>
|
|
111
|
+
{/await}
|
|
112
|
+
{/if}
|
|
113
|
+
{/each}
|
|
114
|
+
{#if overflowCount > 0}
|
|
115
|
+
<span
|
|
116
|
+
class="bubble-overflow"
|
|
117
|
+
title={overflowTitle}
|
|
118
|
+
>+{overflowCount} more</span>
|
|
119
|
+
{/if}
|
|
120
|
+
{/await}
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
124
|
<style>.focusable,
|
|
125
125
|
.checkbox-cell,
|
|
126
126
|
.input-cell,
|
|
@@ -218,4 +218,4 @@ div.bubble-parent {
|
|
|
218
218
|
font-weight: 500;
|
|
219
219
|
white-space: nowrap;
|
|
220
220
|
cursor: default;
|
|
221
|
-
}</style>
|
|
221
|
+
}</style>
|
|
@@ -1,122 +1,165 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object, R extends object,FilterValueType, IdType extends Primitive"
|
|
6
|
-
>
|
|
7
|
-
import Action from '../../../../Action.svelte';
|
|
8
|
-
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
9
|
-
import type { Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
10
|
-
import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
11
|
-
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
12
|
-
import { ColourSet } from '../../../../../scss/colours.js';
|
|
13
|
-
import { Size } from '../../../../../Types/Internal/Size.js';
|
|
14
|
-
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
15
|
-
import { getContext } from 'svelte';
|
|
16
|
-
import type { ExpandCellProps } from './ExpandCellProps.js';
|
|
17
|
-
|
|
18
|
-
const {
|
|
19
|
-
cell,
|
|
20
|
-
expandedColumnDef,
|
|
21
|
-
onExpandChange,
|
|
22
|
-
}: ExpandCellProps<T, R, IdType, FilterValueType> = $props();
|
|
23
|
-
|
|
24
|
-
const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
|
|
25
|
-
const focusDetails: TableFocusDetails<T, IdType> = $derived(
|
|
26
|
-
tableContext._focus.getFocusDetailsFor(cell)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const enabled: boolean | Promise<boolean> = $derived(
|
|
30
|
-
cell.column.columnDef.isEnabled(cell.row.original, cell.row.originalIndex)
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object, R extends object,FilterValueType, IdType extends Primitive"
|
|
6
|
+
>
|
|
7
|
+
import Action from '../../../../Action.svelte';
|
|
8
|
+
import { TableContext } from '../../../Types/Context/TableContext.svelte.js';
|
|
9
|
+
import type { Primitive } from '../../../Types/Context/TableInitOptions.js';
|
|
10
|
+
import type { TableFocusDetails } from '../../../Types/Focus/TableFocusDetails.svelte.js';
|
|
11
|
+
import { devCatch, isValidityTuple } from '../../../../../Helpers/Helpers.svelte.js';
|
|
12
|
+
import { ColourSet } from '../../../../../scss/colours.js';
|
|
13
|
+
import { Size } from '../../../../../Types/Internal/Size.js';
|
|
14
|
+
import { Validity } from '../../../../../Types/Internal/Validity.js';
|
|
15
|
+
import { getContext } from 'svelte';
|
|
16
|
+
import type { ExpandCellProps } from './ExpandCellProps.js';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
cell,
|
|
20
|
+
expandedColumnDef,
|
|
21
|
+
onExpandChange,
|
|
22
|
+
}: ExpandCellProps<T, R, IdType, FilterValueType> = $props();
|
|
23
|
+
|
|
24
|
+
const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
|
|
25
|
+
const focusDetails: TableFocusDetails<T, IdType> = $derived(
|
|
26
|
+
tableContext._focus.getFocusDetailsFor(cell)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const enabled: boolean | Promise<boolean> = $derived(
|
|
30
|
+
cell.column.columnDef.isEnabled(cell.row.original, cell.row.originalIndex)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Per-row toggle visibility. When `isVisible` resolves false the toggle is
|
|
34
|
+
// omitted entirely (rather than disabled). Sync booleans are used directly
|
|
35
|
+
// so non-visible rows never flash the icon; promises resolve into state.
|
|
36
|
+
const visibleRaw: boolean | Promise<boolean> = $derived(
|
|
37
|
+
cell.column.columnDef.isVisible
|
|
38
|
+
? cell.column.columnDef.isVisible(cell.row.original, cell.row.originalIndex)
|
|
39
|
+
: true
|
|
40
|
+
);
|
|
41
|
+
let visibleAsyncResolved = $state(true);
|
|
42
|
+
let visibleCounter = 0;
|
|
43
|
+
$effect(() => {
|
|
44
|
+
const raw = visibleRaw;
|
|
45
|
+
if (typeof raw === 'boolean') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const local = (visibleCounter = visibleCounter + 1);
|
|
49
|
+
raw
|
|
50
|
+
.then((v) => {
|
|
51
|
+
if (visibleCounter === local) {
|
|
52
|
+
visibleAsyncResolved = v;
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.catch(() => {
|
|
56
|
+
if (visibleCounter === local) {
|
|
57
|
+
visibleAsyncResolved = false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
const visible = $derived(typeof visibleRaw === 'boolean' ? visibleRaw : visibleAsyncResolved);
|
|
62
|
+
|
|
63
|
+
let validity: Validity = $state(Validity.Valid);
|
|
64
|
+
$effect(() => {
|
|
65
|
+
const validityPromise = focusDetails.validity;
|
|
66
|
+
|
|
67
|
+
validityPromise
|
|
68
|
+
.then((v) => {
|
|
69
|
+
if (!v) {
|
|
70
|
+
validity = Validity.Neutral;
|
|
71
|
+
} else if (isValidityTuple(v)) {
|
|
72
|
+
validity = v.value;
|
|
73
|
+
} else {
|
|
74
|
+
validity = v;
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.catch(devCatch);
|
|
78
|
+
});
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<!-- svelte-ignore a11y_mouse_events_have_key_events -->
|
|
82
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
83
|
+
<div
|
|
84
|
+
class:info={validity == Validity.Info}
|
|
85
|
+
class:success={validity == Validity.Valid}
|
|
86
|
+
class:warning={validity == Validity.Warning}
|
|
87
|
+
class:error={validity == Validity.Invalid}
|
|
88
|
+
class="focusable"
|
|
89
|
+
onmousedown={(e) => {
|
|
90
|
+
// start focus only on left click
|
|
91
|
+
if (e.button === 0) {
|
|
92
|
+
if (e.shiftKey) {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
95
|
+
} else {
|
|
96
|
+
tableContext.startFocus(focusDetails.coordinates);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}}
|
|
100
|
+
onmouseover={() => {
|
|
101
|
+
if (tableContext.isMousingDown) {
|
|
102
|
+
tableContext.setFocusEnd(focusDetails.coordinates);
|
|
103
|
+
}
|
|
104
|
+
}}
|
|
105
|
+
onmouseup={() => {
|
|
106
|
+
tableContext.endFocus(focusDetails.coordinates);
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
<div
|
|
110
|
+
class="slot-wrapper"
|
|
111
|
+
class:multifocus={focusDetails.isMultiFocused}
|
|
112
|
+
class:multifocus-start={focusDetails.isMultiFocusStart}
|
|
113
|
+
>
|
|
114
|
+
{#if visible}
|
|
115
|
+
{#await enabled}
|
|
116
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
117
|
+
{@render action(false)}
|
|
118
|
+
{:then enabled}
|
|
119
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
120
|
+
{@render action(enabled)}
|
|
121
|
+
{/await}
|
|
122
|
+
{/if}
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
{#snippet action(enabled: boolean)}
|
|
127
|
+
<div class="noninteractive">
|
|
128
|
+
<Action
|
|
129
|
+
id={`${tableContext.tableName}-cell-${cell.row.visibleIndex}-${cell.column.id}`}
|
|
130
|
+
style={focusDetails.outline}
|
|
131
|
+
disabled={!enabled}
|
|
132
|
+
border={false}
|
|
133
|
+
label={cell.column.columnDef.onActivate ? 'Open Related Table' : 'Expand Nested Table'}
|
|
134
|
+
size={Size.FillWidth}
|
|
135
|
+
icon={{
|
|
136
|
+
name:
|
|
137
|
+
!cell.column.columnDef.onActivate &&
|
|
138
|
+
expandedColumnDef?.id === cell.column.columnDef.id
|
|
139
|
+
? 'minus'
|
|
140
|
+
: 'plus',
|
|
141
|
+
size: Size.Medium,
|
|
142
|
+
}}
|
|
143
|
+
colourSet={expandedColumnDef?.id === cell.column.columnDef.id && !cell.column.columnDef.onActivate
|
|
144
|
+
? ColourSet.Primary
|
|
145
|
+
: ColourSet.Auxiliary}
|
|
146
|
+
onclick={(e: MouseEvent) => {
|
|
147
|
+
// FIXME why is this required? svelte bug?
|
|
148
|
+
e.stopImmediatePropagation();
|
|
149
|
+
// Navigate-instead-of-expand: when the column carries an
|
|
150
|
+
// `onActivate`, drive the consumer's drill-down rather than
|
|
151
|
+
// mounting an inner table.
|
|
152
|
+
const onActivate = cell.column.columnDef.onActivate;
|
|
153
|
+
if (onActivate) {
|
|
154
|
+
void onActivate(cell.row.original);
|
|
155
|
+
} else {
|
|
156
|
+
onExpandChange(cell.column.columnDef);
|
|
157
|
+
}
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
{/snippet}
|
|
162
|
+
|
|
120
163
|
<style>.focusable,
|
|
121
164
|
.checkbox-cell,
|
|
122
165
|
.input-cell,
|
|
@@ -199,4 +242,4 @@ div.slot-wrapper {
|
|
|
199
242
|
.noninteractive {
|
|
200
243
|
display: contents;
|
|
201
244
|
user-select: none;
|
|
202
|
-
}</style>
|
|
245
|
+
}</style>
|