@lavalogic/scoria 0.35.0 → 0.36.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.
- package/README.md +58 -58
- package/dist/Components/AccordionGroup.svelte +42 -42
- package/dist/Components/AccordionGroupButton.svelte +99 -99
- package/dist/Components/Action.svelte +138 -138
- package/dist/Components/AlertModal.svelte +125 -125
- package/dist/Components/Base/ContextWrapper.svelte +50 -50
- package/dist/Components/Base/Pagination.svelte +190 -190
- package/dist/Components/Base/Snippets.svelte +29 -29
- package/dist/Components/BigRadioSet.svelte +29 -29
- package/dist/Components/Bubble.svelte +77 -77
- package/dist/Components/Button.svelte +197 -197
- package/dist/Components/Checkbox.svelte +68 -68
- package/dist/Components/CollapsibleCard.svelte +70 -70
- package/dist/Components/Contexts/ContextMenu.svelte +157 -157
- package/dist/Components/Contexts/ContextMenuDivider.svelte +11 -11
- package/dist/Components/Contexts/ContextMenuOption.svelte +52 -52
- package/dist/Components/Contexts/Toast.svelte +61 -61
- package/dist/Components/Contexts/ToastContainer.svelte +46 -46
- package/dist/Components/Contexts/Tooltip.svelte +26 -26
- package/dist/Components/DataMatrixIcon.svelte +41 -41
- package/dist/Components/DateInput.svelte +109 -109
- package/dist/Components/DatePicker.svelte +312 -312
- package/dist/Components/DesktopModal.svelte +106 -106
- package/dist/Components/Dial.svelte +151 -151
- package/dist/Components/DimensionInput.svelte +184 -184
- package/dist/Components/DragMenu/DragMenuHolder.svelte +106 -106
- package/dist/Components/DragMenu/DraggableCard.svelte +41 -41
- package/dist/Components/FileCard.svelte +20 -20
- package/dist/Components/FileUpload.svelte +196 -196
- package/dist/Components/GridInput.svelte +190 -190
- package/dist/Components/GridInputSet.svelte +22 -22
- package/dist/Components/HorizontalTabGroup.svelte +78 -78
- package/dist/Components/HorizontalTabGroupButton.svelte +96 -96
- package/dist/Components/Icon.svelte +97 -97
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/LoadingAnimation.svelte +32 -32
- package/dist/Components/LoadingModal.svelte +47 -47
- package/dist/Components/LoadingOverlay.svelte +27 -27
- package/dist/Components/Modal.svelte +251 -251
- package/dist/Components/MultiSelect.svelte +197 -197
- package/dist/Components/Nav/Nav.svelte +97 -97
- package/dist/Components/Nav/NavServiceMenuList.svelte +34 -34
- package/dist/Components/Nav/NavTab.svelte +91 -91
- package/dist/Components/Nav/ServiceMenuItem.svelte +91 -91
- package/dist/Components/Nav/ServicesNav.svelte +53 -53
- package/dist/Components/NumberInput.svelte +144 -144
- package/dist/Components/PageHeading.svelte +36 -36
- package/dist/Components/PasswordInput.svelte +73 -73
- package/dist/Components/Portal.svelte +25 -25
- package/dist/Components/ProgressBubble.svelte +80 -80
- package/dist/Components/QuerySelect.svelte +411 -411
- package/dist/Components/SingleSelect.svelte +261 -261
- package/dist/Components/StepButton.svelte +120 -120
- package/dist/Components/StepForm.svelte +108 -108
- package/dist/Components/Switch.svelte +36 -36
- package/dist/Components/Table/Body/QuickSearchCell.svelte +632 -632
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +30 -30
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +56 -56
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +49 -49
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +180 -180
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +102 -102
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +119 -119
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +114 -114
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +96 -96
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +72 -72
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +131 -131
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +144 -144
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +238 -238
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +358 -358
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +338 -338
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +183 -183
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +309 -309
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +369 -369
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +170 -170
- package/dist/Components/Table/Body/Rows/TableRow.svelte +259 -259
- package/dist/Components/Table/Body/TableBody.svelte +67 -67
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +39 -39
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +28 -28
- package/dist/Components/Table/Headers/TableHead.svelte +260 -260
- package/dist/Components/Table/Misc/ColumnPanel.svelte +78 -78
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +99 -99
- package/dist/Components/Table/Misc/FilterInput.svelte +556 -556
- package/dist/Components/Table/Misc/FilterPanel.svelte +46 -46
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +67 -67
- package/dist/Components/Table/Misc/SidePanel.svelte +32 -32
- package/dist/Components/Table/Misc/TableFooter.svelte +304 -304
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +156 -156
- package/dist/Components/Table/Misc/TableSidebar.svelte +176 -176
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +77 -77
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +91 -91
- package/dist/Components/Table/NestedTable.svelte +84 -84
- package/dist/Components/Table/Table.svelte +492 -492
- package/dist/Components/Test/TestContextConsumer.svelte +13 -13
- package/dist/Components/TextArea.svelte +108 -108
- package/dist/Components/TextInput.svelte +147 -147
- package/dist/Components/ThreeStateRadio.svelte +124 -124
- package/dist/Components/Touch/BoolCard.svelte +52 -52
- package/dist/Components/Touch/DateModal.svelte +217 -217
- package/dist/Components/Touch/EditCard.svelte +52 -52
- package/dist/Components/Touch/InfoCard.svelte +24 -24
- package/dist/Components/Touch/InfoTextCard.svelte +21 -21
- package/dist/Components/Touch/ModalExplanation.svelte +20 -20
- package/dist/Components/Touch/NumberKeyboard.svelte +268 -268
- package/dist/Components/Touch/NumberModal.svelte +69 -69
- package/dist/Components/Touch/PlusMinusCard.svelte +50 -50
- package/dist/Components/Touch/SelectModal.svelte +105 -105
- package/dist/Components/Touch/SummaryCard.svelte +65 -65
- package/dist/Components/Touch/TextAreaModal.svelte +86 -86
- package/dist/Components/Touch/TextModal.svelte +123 -123
- package/dist/Components/Touch/TouchCard.svelte +28 -28
- package/dist/Components/Touch/TouchModal.svelte +259 -259
- package/dist/Components/Touch/UtilityButton.svelte +91 -91
- package/dist/Components/VerticalTabGroup.svelte +66 -66
- package/dist/Components/VerticalTabGroupButton.svelte +97 -97
- package/dist/Helpers/Datamatrix.d.ts +10 -10
- package/dist/Helpers/Datamatrix.js +1 -1
- package/dist/Helpers/Helpers.svelte.d.ts +1 -0
- package/dist/Helpers/Helpers.svelte.js +15 -0
- package/dist/Types/Examples/ExampleModal.svelte +34 -34
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3016 -3016
- package/dist/scss/_sizing.scss +69 -69
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +30 -30
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import Action from '../../../Action.svelte';
|
|
5
|
-
import { Colour } from '../../../../scss/colours.js';
|
|
6
|
-
import { Size } from '../../../../Types/Internal/Size.js';
|
|
7
|
-
import type { ColumnHighlightProps } from './ColumnHighlightProps.js';
|
|
8
|
-
|
|
9
|
-
const { rowIndex, highlighted, toggleHighlightedRow }: ColumnHighlightProps = $props();
|
|
10
|
-
|
|
11
|
-
const backgroundColour = $derived(highlighted ? Colour['$brand-primary'] : Colour['$ui-white']);
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<td id="tagger-row-{rowIndex}">
|
|
15
|
-
<div class="wrapper">
|
|
16
|
-
<Action
|
|
17
|
-
{backgroundColour}
|
|
18
|
-
hoverBackgroundColour={Colour['$brand-dark']}
|
|
19
|
-
size={Size.FillWidth}
|
|
20
|
-
icon={{
|
|
21
|
-
name: 'nothing'
|
|
22
|
-
}}
|
|
23
|
-
onclick={() => {
|
|
24
|
-
toggleHighlightedRow();
|
|
25
|
-
}}
|
|
26
|
-
/>
|
|
27
|
-
</div></td
|
|
28
|
-
>
|
|
29
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import Action from '../../../Action.svelte';
|
|
5
|
+
import { Colour } from '../../../../scss/colours.js';
|
|
6
|
+
import { Size } from '../../../../Types/Internal/Size.js';
|
|
7
|
+
import type { ColumnHighlightProps } from './ColumnHighlightProps.js';
|
|
8
|
+
|
|
9
|
+
const { rowIndex, highlighted, toggleHighlightedRow }: ColumnHighlightProps = $props();
|
|
10
|
+
|
|
11
|
+
const backgroundColour = $derived(highlighted ? Colour['$brand-primary'] : Colour['$ui-white']);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<td id="tagger-row-{rowIndex}">
|
|
15
|
+
<div class="wrapper">
|
|
16
|
+
<Action
|
|
17
|
+
{backgroundColour}
|
|
18
|
+
hoverBackgroundColour={Colour['$brand-dark']}
|
|
19
|
+
size={Size.FillWidth}
|
|
20
|
+
icon={{
|
|
21
|
+
name: 'nothing'
|
|
22
|
+
}}
|
|
23
|
+
onclick={() => {
|
|
24
|
+
toggleHighlightedRow();
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
</div></td
|
|
28
|
+
>
|
|
29
|
+
|
|
30
30
|
<style>td {
|
|
31
31
|
transition: line-height 0.2s ease, height 0.2s ease;
|
|
32
32
|
--input-border: none;
|
|
@@ -59,4 +59,4 @@ div.wrapper {
|
|
|
59
59
|
|
|
60
60
|
.wrapper {
|
|
61
61
|
overflow: hidden;
|
|
62
|
-
}</style>
|
|
62
|
+
}</style>
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object"
|
|
6
|
-
>
|
|
7
|
-
import { ColumnType } from '../../Types/Columns/ColumnType.js';
|
|
8
|
-
import type { ColumnDef } from '../../Types/Columns/Definitions/ColumnDef.svelte.js';
|
|
9
|
-
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
10
|
-
import { getContext } from 'svelte';
|
|
11
|
-
import type { ColumnListProps } from './ColumnListProps.js';
|
|
12
|
-
import ColumnListRow from './ColumnListRow.svelte';
|
|
13
|
-
|
|
14
|
-
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
15
|
-
|
|
16
|
-
const { searchValue }: ColumnListProps = $props();
|
|
17
|
-
|
|
18
|
-
const visibleColumns: Array<ColumnDef<T>> = $derived.by(() => {
|
|
19
|
-
const lowercasedSearchValue = searchValue.toLocaleLowerCase();
|
|
20
|
-
return tableContext.columnDefs.filter(
|
|
21
|
-
(it) =>
|
|
22
|
-
it.columnType !== ColumnType.FilterOnly &&
|
|
23
|
-
(it.id.toLowerCase().includes(lowercasedSearchValue) ||
|
|
24
|
-
(typeof it.header === 'string' &&
|
|
25
|
-
it.header.toLowerCase().includes(lowercasedSearchValue)))
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
function onDrop(e: DragEvent) {
|
|
30
|
-
if (!tableContext.dragTarget) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const dropTarget = (e.target as HTMLElement | undefined)?.closest('li');
|
|
35
|
-
|
|
36
|
-
if (dropTarget) {
|
|
37
|
-
tableContext.reorderColumn(dropTarget);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<ul
|
|
43
|
-
class="column-list"
|
|
44
|
-
ondrop={onDrop}
|
|
45
|
-
>
|
|
46
|
-
<!-- key={"top-anchor"} -->
|
|
47
|
-
<!-- HACK this is used as an anchor for dragging rows to the top -->
|
|
48
|
-
<ColumnListRow columnDef={null} />
|
|
49
|
-
|
|
50
|
-
<!-- TODO try to find a key for these -->
|
|
51
|
-
{#each visibleColumns as columnDef (columnDef)}
|
|
52
|
-
<ColumnListRow {columnDef} />
|
|
53
|
-
{/each}
|
|
54
|
-
</ul>
|
|
55
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object"
|
|
6
|
+
>
|
|
7
|
+
import { ColumnType } from '../../Types/Columns/ColumnType.js';
|
|
8
|
+
import type { ColumnDef } from '../../Types/Columns/Definitions/ColumnDef.svelte.js';
|
|
9
|
+
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
10
|
+
import { getContext } from 'svelte';
|
|
11
|
+
import type { ColumnListProps } from './ColumnListProps.js';
|
|
12
|
+
import ColumnListRow from './ColumnListRow.svelte';
|
|
13
|
+
|
|
14
|
+
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
15
|
+
|
|
16
|
+
const { searchValue }: ColumnListProps = $props();
|
|
17
|
+
|
|
18
|
+
const visibleColumns: Array<ColumnDef<T>> = $derived.by(() => {
|
|
19
|
+
const lowercasedSearchValue = searchValue.toLocaleLowerCase();
|
|
20
|
+
return tableContext.columnDefs.filter(
|
|
21
|
+
(it) =>
|
|
22
|
+
it.columnType !== ColumnType.FilterOnly &&
|
|
23
|
+
(it.id.toLowerCase().includes(lowercasedSearchValue) ||
|
|
24
|
+
(typeof it.header === 'string' &&
|
|
25
|
+
it.header.toLowerCase().includes(lowercasedSearchValue)))
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function onDrop(e: DragEvent) {
|
|
30
|
+
if (!tableContext.dragTarget) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const dropTarget = (e.target as HTMLElement | undefined)?.closest('li');
|
|
35
|
+
|
|
36
|
+
if (dropTarget) {
|
|
37
|
+
tableContext.reorderColumn(dropTarget);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<ul
|
|
43
|
+
class="column-list"
|
|
44
|
+
ondrop={onDrop}
|
|
45
|
+
>
|
|
46
|
+
<!-- key={"top-anchor"} -->
|
|
47
|
+
<!-- HACK this is used as an anchor for dragging rows to the top -->
|
|
48
|
+
<ColumnListRow columnDef={null} />
|
|
49
|
+
|
|
50
|
+
<!-- TODO try to find a key for these -->
|
|
51
|
+
{#each visibleColumns as columnDef (columnDef)}
|
|
52
|
+
<ColumnListRow {columnDef} />
|
|
53
|
+
{/each}
|
|
54
|
+
</ul>
|
|
55
|
+
|
|
56
56
|
<style>ul {
|
|
57
57
|
list-style: none;
|
|
58
58
|
background-color: #ffffff;
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
padding: 0.5rem;
|
|
66
66
|
margin: 0;
|
|
67
67
|
overflow: auto;
|
|
68
|
-
}</style>
|
|
68
|
+
}</style>
|
|
@@ -1,181 +1,181 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object"
|
|
6
|
-
>
|
|
7
|
-
import Checkbox from '../../../Checkbox.svelte';
|
|
8
|
-
import Icon from '../../../Icon.svelte';
|
|
9
|
-
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
10
|
-
import { Size } from '../../../../Types/Internal/Size.js';
|
|
11
|
-
import { getContext } from 'svelte';
|
|
12
|
-
import type { ColumnListRowProps } from './ColumnListRowProps.js';
|
|
13
|
-
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
14
|
-
|
|
15
|
-
const { columnDef }: ColumnListRowProps<T> = $props();
|
|
16
|
-
|
|
17
|
-
const isExpandColumn = $derived(columnDef?.columnType === 'Expand');
|
|
18
|
-
|
|
19
|
-
let isBeingTargeted = $state(false);
|
|
20
|
-
|
|
21
|
-
function disableDragVisual() {
|
|
22
|
-
isBeingTargeted = false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function makeKVPairs(item: string, index: number): readonly [string, number] {
|
|
26
|
-
return [item, index];
|
|
27
|
-
}
|
|
28
|
-
function togglePinLeft() {
|
|
29
|
-
if (columnDef == null) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
tableContext.setColumnPinning((pinning) => {
|
|
34
|
-
const leftPinIndex = pinning.left?.get(columnDef.id) ?? -1;
|
|
35
|
-
const left = [...(pinning.left?.keys() ?? [])];
|
|
36
|
-
if (leftPinIndex !== -1) {
|
|
37
|
-
left.splice(leftPinIndex, 1);
|
|
38
|
-
} else {
|
|
39
|
-
left.push(columnDef.id);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const rightPinIndex = pinning.right?.get(columnDef.id) ?? -1;
|
|
43
|
-
const right = [...(pinning.right?.keys() ?? [])];
|
|
44
|
-
if (rightPinIndex !== -1) {
|
|
45
|
-
right.splice(rightPinIndex, 1);
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
...pinning,
|
|
49
|
-
left: new Map(left.map(makeKVPairs)),
|
|
50
|
-
right: new Map(right.map(makeKVPairs)),
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function togglePinRight() {
|
|
56
|
-
if (columnDef == null) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
tableContext.setColumnPinning((pinning) => {
|
|
61
|
-
const rightPinIndex = pinning.right?.get(columnDef.id) ?? -1;
|
|
62
|
-
const right = [...(pinning.right?.keys() ?? [])];
|
|
63
|
-
|
|
64
|
-
if (rightPinIndex !== -1) {
|
|
65
|
-
right.splice(rightPinIndex, 1);
|
|
66
|
-
} else {
|
|
67
|
-
right.push(columnDef.id);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const leftPinIndex = pinning.left?.get(columnDef.id) ?? -1;
|
|
71
|
-
const left = [...(pinning.left?.keys() ?? [])];
|
|
72
|
-
if (leftPinIndex !== -1) {
|
|
73
|
-
left.splice(leftPinIndex, 1);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
...pinning,
|
|
78
|
-
left: new Map(left.map(makeKVPairs)),
|
|
79
|
-
right: new Map(right.map(makeKVPairs)),
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const onVisibilityChange = (e: Event) => {
|
|
85
|
-
if (!columnDef) {
|
|
86
|
-
console.warn('no def found', e);
|
|
87
|
-
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
tableContext.updateVisibility((defs) => {
|
|
91
|
-
defs[columnDef.id] = (e.target as HTMLInputElement).checked;
|
|
92
|
-
return defs;
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
</script>
|
|
96
|
-
|
|
97
|
-
{#if columnDef}
|
|
98
|
-
<li
|
|
99
|
-
class="single-column"
|
|
100
|
-
class:targeted={isBeingTargeted}
|
|
101
|
-
id="{tableContext.tableName}-column-settings-{columnDef.id}"
|
|
102
|
-
draggable={tableContext.allowColumnReordering}
|
|
103
|
-
ondragstart={() => {
|
|
104
|
-
tableContext.dragTarget = columnDef;
|
|
105
|
-
}}
|
|
106
|
-
ondragend={disableDragVisual}
|
|
107
|
-
ondragover={(e) => {
|
|
108
|
-
e.preventDefault();
|
|
109
|
-
if (tableContext.dragTarget?.id !== columnDef.id) {
|
|
110
|
-
isBeingTargeted = true;
|
|
111
|
-
}
|
|
112
|
-
}}
|
|
113
|
-
ondragleave={disableDragVisual}
|
|
114
|
-
ondrop={disableDragVisual}
|
|
115
|
-
>
|
|
116
|
-
<Checkbox
|
|
117
|
-
icon={{ name: 'assessment' }}
|
|
118
|
-
id={`is-visible-${tableContext.tableName}-${columnDef.id}`}
|
|
119
|
-
value={tableContext.columnVisibility[columnDef.id] !== false}
|
|
120
|
-
onchange={onVisibilityChange}
|
|
121
|
-
/>
|
|
122
|
-
|
|
123
|
-
{#if tableContext.allowColumnReordering}
|
|
124
|
-
<!-- value={tableContext.columnPinning.left?.has(columnDef.id) ?? false} -->
|
|
125
|
-
<Checkbox
|
|
126
|
-
disabled={isExpandColumn}
|
|
127
|
-
icon={{ name: 'pin-left' }}
|
|
128
|
-
id={`is-pinned-left-${tableContext.tableName}-${columnDef.id}`}
|
|
129
|
-
value={tableContext.columnPinning.left?.has(columnDef.id) || false}
|
|
130
|
-
onchange={() => {
|
|
131
|
-
togglePinLeft();
|
|
132
|
-
}}
|
|
133
|
-
/>
|
|
134
|
-
<!-- value={tableContext.columnPinning.right?.has(columnDef.id) ?? false} -->
|
|
135
|
-
<Checkbox
|
|
136
|
-
disabled={isExpandColumn}
|
|
137
|
-
icon={{ name: 'pin-right' }}
|
|
138
|
-
id={`is-pinned-right-${tableContext.tableName}-${columnDef.id}`}
|
|
139
|
-
value={tableContext.columnPinning.right?.has(columnDef.id) || false}
|
|
140
|
-
onchange={() => {
|
|
141
|
-
togglePinRight();
|
|
142
|
-
}}
|
|
143
|
-
/>
|
|
144
|
-
<div
|
|
145
|
-
id={`drag-handle-${tableContext.tableName}-${columnDef.id}`}
|
|
146
|
-
style="display: flex; cursor: move;"
|
|
147
|
-
>
|
|
148
|
-
<Icon
|
|
149
|
-
name="handle"
|
|
150
|
-
size={Size.Large}
|
|
151
|
-
/>
|
|
152
|
-
</div>
|
|
153
|
-
{/if}
|
|
154
|
-
{#if typeof columnDef.header === 'function'}
|
|
155
|
-
<!-- FIXME this needs testing -->
|
|
156
|
-
{@render columnDef.header()}
|
|
157
|
-
<!-- <span>{columnDef.id}</span> -->
|
|
158
|
-
{:else}
|
|
159
|
-
<span>{columnDef.header}</span>
|
|
160
|
-
{/if}
|
|
161
|
-
</li>
|
|
162
|
-
{:else}
|
|
163
|
-
<li
|
|
164
|
-
id="{tableContext.tableName}-column-settings-top-anchor"
|
|
165
|
-
class="single-column anchor"
|
|
166
|
-
class:targeted={isBeingTargeted}
|
|
167
|
-
ondragover={(e) => {
|
|
168
|
-
e.preventDefault();
|
|
169
|
-
|
|
170
|
-
if (tableContext.dragTarget?.id !== undefined) {
|
|
171
|
-
isBeingTargeted = true;
|
|
172
|
-
}
|
|
173
|
-
}}
|
|
174
|
-
ondragleave={disableDragVisual}
|
|
175
|
-
ondrop={disableDragVisual}
|
|
176
|
-
></li>
|
|
177
|
-
{/if}
|
|
178
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object"
|
|
6
|
+
>
|
|
7
|
+
import Checkbox from '../../../Checkbox.svelte';
|
|
8
|
+
import Icon from '../../../Icon.svelte';
|
|
9
|
+
import { TableContext } from '../../Types/Context/TableContext.svelte.js';
|
|
10
|
+
import { Size } from '../../../../Types/Internal/Size.js';
|
|
11
|
+
import { getContext } from 'svelte';
|
|
12
|
+
import type { ColumnListRowProps } from './ColumnListRowProps.js';
|
|
13
|
+
const tableContext = getContext<TableContext<T, never>>(TableContext.identifier);
|
|
14
|
+
|
|
15
|
+
const { columnDef }: ColumnListRowProps<T> = $props();
|
|
16
|
+
|
|
17
|
+
const isExpandColumn = $derived(columnDef?.columnType === 'Expand');
|
|
18
|
+
|
|
19
|
+
let isBeingTargeted = $state(false);
|
|
20
|
+
|
|
21
|
+
function disableDragVisual() {
|
|
22
|
+
isBeingTargeted = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function makeKVPairs(item: string, index: number): readonly [string, number] {
|
|
26
|
+
return [item, index];
|
|
27
|
+
}
|
|
28
|
+
function togglePinLeft() {
|
|
29
|
+
if (columnDef == null) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
tableContext.setColumnPinning((pinning) => {
|
|
34
|
+
const leftPinIndex = pinning.left?.get(columnDef.id) ?? -1;
|
|
35
|
+
const left = [...(pinning.left?.keys() ?? [])];
|
|
36
|
+
if (leftPinIndex !== -1) {
|
|
37
|
+
left.splice(leftPinIndex, 1);
|
|
38
|
+
} else {
|
|
39
|
+
left.push(columnDef.id);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const rightPinIndex = pinning.right?.get(columnDef.id) ?? -1;
|
|
43
|
+
const right = [...(pinning.right?.keys() ?? [])];
|
|
44
|
+
if (rightPinIndex !== -1) {
|
|
45
|
+
right.splice(rightPinIndex, 1);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
...pinning,
|
|
49
|
+
left: new Map(left.map(makeKVPairs)),
|
|
50
|
+
right: new Map(right.map(makeKVPairs)),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function togglePinRight() {
|
|
56
|
+
if (columnDef == null) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
tableContext.setColumnPinning((pinning) => {
|
|
61
|
+
const rightPinIndex = pinning.right?.get(columnDef.id) ?? -1;
|
|
62
|
+
const right = [...(pinning.right?.keys() ?? [])];
|
|
63
|
+
|
|
64
|
+
if (rightPinIndex !== -1) {
|
|
65
|
+
right.splice(rightPinIndex, 1);
|
|
66
|
+
} else {
|
|
67
|
+
right.push(columnDef.id);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const leftPinIndex = pinning.left?.get(columnDef.id) ?? -1;
|
|
71
|
+
const left = [...(pinning.left?.keys() ?? [])];
|
|
72
|
+
if (leftPinIndex !== -1) {
|
|
73
|
+
left.splice(leftPinIndex, 1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
...pinning,
|
|
78
|
+
left: new Map(left.map(makeKVPairs)),
|
|
79
|
+
right: new Map(right.map(makeKVPairs)),
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const onVisibilityChange = (e: Event) => {
|
|
85
|
+
if (!columnDef) {
|
|
86
|
+
console.warn('no def found', e);
|
|
87
|
+
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
tableContext.updateVisibility((defs) => {
|
|
91
|
+
defs[columnDef.id] = (e.target as HTMLInputElement).checked;
|
|
92
|
+
return defs;
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
{#if columnDef}
|
|
98
|
+
<li
|
|
99
|
+
class="single-column"
|
|
100
|
+
class:targeted={isBeingTargeted}
|
|
101
|
+
id="{tableContext.tableName}-column-settings-{columnDef.id}"
|
|
102
|
+
draggable={tableContext.allowColumnReordering}
|
|
103
|
+
ondragstart={() => {
|
|
104
|
+
tableContext.dragTarget = columnDef;
|
|
105
|
+
}}
|
|
106
|
+
ondragend={disableDragVisual}
|
|
107
|
+
ondragover={(e) => {
|
|
108
|
+
e.preventDefault();
|
|
109
|
+
if (tableContext.dragTarget?.id !== columnDef.id) {
|
|
110
|
+
isBeingTargeted = true;
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
ondragleave={disableDragVisual}
|
|
114
|
+
ondrop={disableDragVisual}
|
|
115
|
+
>
|
|
116
|
+
<Checkbox
|
|
117
|
+
icon={{ name: 'assessment' }}
|
|
118
|
+
id={`is-visible-${tableContext.tableName}-${columnDef.id}`}
|
|
119
|
+
value={tableContext.columnVisibility[columnDef.id] !== false}
|
|
120
|
+
onchange={onVisibilityChange}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
{#if tableContext.allowColumnReordering}
|
|
124
|
+
<!-- value={tableContext.columnPinning.left?.has(columnDef.id) ?? false} -->
|
|
125
|
+
<Checkbox
|
|
126
|
+
disabled={isExpandColumn}
|
|
127
|
+
icon={{ name: 'pin-left' }}
|
|
128
|
+
id={`is-pinned-left-${tableContext.tableName}-${columnDef.id}`}
|
|
129
|
+
value={tableContext.columnPinning.left?.has(columnDef.id) || false}
|
|
130
|
+
onchange={() => {
|
|
131
|
+
togglePinLeft();
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
<!-- value={tableContext.columnPinning.right?.has(columnDef.id) ?? false} -->
|
|
135
|
+
<Checkbox
|
|
136
|
+
disabled={isExpandColumn}
|
|
137
|
+
icon={{ name: 'pin-right' }}
|
|
138
|
+
id={`is-pinned-right-${tableContext.tableName}-${columnDef.id}`}
|
|
139
|
+
value={tableContext.columnPinning.right?.has(columnDef.id) || false}
|
|
140
|
+
onchange={() => {
|
|
141
|
+
togglePinRight();
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
<div
|
|
145
|
+
id={`drag-handle-${tableContext.tableName}-${columnDef.id}`}
|
|
146
|
+
style="display: flex; cursor: move;"
|
|
147
|
+
>
|
|
148
|
+
<Icon
|
|
149
|
+
name="handle"
|
|
150
|
+
size={Size.Large}
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
{/if}
|
|
154
|
+
{#if typeof columnDef.header === 'function'}
|
|
155
|
+
<!-- FIXME this needs testing -->
|
|
156
|
+
{@render columnDef.header()}
|
|
157
|
+
<!-- <span>{columnDef.id}</span> -->
|
|
158
|
+
{:else}
|
|
159
|
+
<span>{columnDef.header}</span>
|
|
160
|
+
{/if}
|
|
161
|
+
</li>
|
|
162
|
+
{:else}
|
|
163
|
+
<li
|
|
164
|
+
id="{tableContext.tableName}-column-settings-top-anchor"
|
|
165
|
+
class="single-column anchor"
|
|
166
|
+
class:targeted={isBeingTargeted}
|
|
167
|
+
ondragover={(e) => {
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
|
|
170
|
+
if (tableContext.dragTarget?.id !== undefined) {
|
|
171
|
+
isBeingTargeted = true;
|
|
172
|
+
}
|
|
173
|
+
}}
|
|
174
|
+
ondragleave={disableDragVisual}
|
|
175
|
+
ondrop={disableDragVisual}
|
|
176
|
+
></li>
|
|
177
|
+
{/if}
|
|
178
|
+
|
|
179
179
|
<style>li {
|
|
180
180
|
box-sizing: border-box;
|
|
181
181
|
}
|
|
@@ -191,4 +191,4 @@ li.single-column {
|
|
|
191
191
|
gap: 1rem;
|
|
192
192
|
padding: 0.5rem 0.5rem;
|
|
193
193
|
align-items: center;
|
|
194
|
-
}</style>
|
|
194
|
+
}</style>
|
|
@@ -1,49 +1,49 @@
|
|
|
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
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<script
|
|
21
|
-
lang="ts"
|
|
22
|
-
generics="T extends object"
|
|
23
|
-
>
|
|
24
|
-
const { cell }: AccessorComponentProps<T> = $props();
|
|
25
|
-
|
|
26
|
-
const cellTypes: Record<
|
|
27
|
-
'Number' | 'Date' | 'Select' | 'Checkbox' | 'Query' | 'Text',
|
|
28
|
-
object & Component<any>
|
|
29
|
-
> = {
|
|
30
|
-
Number: TableNumberInput,
|
|
31
|
-
Date: TableDatePicker,
|
|
32
|
-
Select: TableSelect,
|
|
33
|
-
Query: TableQuerySelect,
|
|
34
|
-
Checkbox: TableCheckbox,
|
|
35
|
-
Text: TableTextInput,
|
|
36
|
-
} as const;
|
|
37
|
-
|
|
38
|
-
const CurrentComponent = $derived(getAppropriateAccessorDef(cell.column.columnDef));
|
|
39
|
-
|
|
40
|
-
function getAppropriateAccessorDef(columnDef: ColumnDef<T>): Component<any> {
|
|
41
|
-
if (columnDef instanceof AccessorDef) {
|
|
42
|
-
return cellTypes[columnDef.accessorType];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return FocusableImmutableCell;
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<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
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script
|
|
21
|
+
lang="ts"
|
|
22
|
+
generics="T extends object"
|
|
23
|
+
>
|
|
24
|
+
const { cell }: AccessorComponentProps<T> = $props();
|
|
25
|
+
|
|
26
|
+
const cellTypes: Record<
|
|
27
|
+
'Number' | 'Date' | 'Select' | 'Checkbox' | 'Query' | 'Text',
|
|
28
|
+
object & Component<any>
|
|
29
|
+
> = {
|
|
30
|
+
Number: TableNumberInput,
|
|
31
|
+
Date: TableDatePicker,
|
|
32
|
+
Select: TableSelect,
|
|
33
|
+
Query: TableQuerySelect,
|
|
34
|
+
Checkbox: TableCheckbox,
|
|
35
|
+
Text: TableTextInput,
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
const CurrentComponent = $derived(getAppropriateAccessorDef(cell.column.columnDef));
|
|
39
|
+
|
|
40
|
+
function getAppropriateAccessorDef(columnDef: ColumnDef<T>): Component<any> {
|
|
41
|
+
if (columnDef instanceof AccessorDef) {
|
|
42
|
+
return cellTypes[columnDef.accessorType];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return FocusableImmutableCell;
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<CurrentComponent {cell} />
|