@lavalogic/scoria 0.40.13 → 0.40.15
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 +35 -46
- package/dist/Components/AccordionGroupButton.svelte +68 -76
- package/dist/Components/Action.svelte +103 -135
- package/dist/Components/AlertModal.svelte +171 -190
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +614 -697
- package/dist/Components/Base/BaseModal.svelte +90 -116
- package/dist/Components/Base/ContextWrapper.svelte +67 -72
- package/dist/Components/Base/Pagination.svelte +173 -196
- package/dist/Components/Base/Snippets.svelte +34 -36
- package/dist/Components/BigRadioSet.svelte +36 -38
- package/dist/Components/Bubble.svelte +78 -101
- package/dist/Components/Button.svelte +175 -208
- package/dist/Components/Checkbox.svelte +75 -86
- package/dist/Components/CollapsibleCard.svelte +72 -87
- package/dist/Components/CollapsibleMenuGroup.svelte +53 -57
- package/dist/Components/ConditionBuilder/ConditionBuilder.svelte +39 -64
- package/dist/Components/Contexts/ContextMenu.svelte +141 -156
- package/dist/Components/Contexts/ContextMenuDivider.svelte +15 -15
- package/dist/Components/Contexts/ContextMenuOption.svelte +53 -60
- package/dist/Components/Contexts/Toast.svelte +81 -86
- package/dist/Components/Contexts/ToastContainer.svelte +58 -62
- package/dist/Components/Contexts/Tooltip.svelte +36 -37
- package/dist/Components/DataMatrixIcon.svelte +95 -108
- package/dist/Components/DateInput.svelte +118 -146
- package/dist/Components/DatePicker.svelte +255 -294
- package/dist/Components/DesktopModal.svelte +70 -90
- package/dist/Components/Dial.svelte +167 -197
- package/dist/Components/DimensionInput.svelte +124 -169
- package/dist/Components/DragMenu/DragMenuHolder.svelte +98 -114
- package/dist/Components/DragMenu/DraggableCard.svelte +64 -76
- package/dist/Components/FileCard.svelte +21 -24
- package/dist/Components/FileUpload.svelte +190 -225
- package/dist/Components/GridInput.svelte +159 -196
- package/dist/Components/GridInputSet.svelte +24 -29
- package/dist/Components/HorizontalTabGroup.svelte +73 -89
- package/dist/Components/HorizontalTabGroupButton.svelte +40 -44
- package/dist/Components/Icon.svelte +99 -128
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/InfoAlert.svelte +35 -38
- package/dist/Components/LoadingAnimation.svelte +691 -755
- package/dist/Components/LoadingModal.svelte +36 -44
- package/dist/Components/LoadingOverlay.svelte +22 -26
- package/dist/Components/Modal.svelte +204 -254
- package/dist/Components/MultiSelect.svelte +186 -216
- package/dist/Components/Nav/Nav.svelte +94 -110
- package/dist/Components/Nav/NavServiceMenuList.svelte +57 -61
- package/dist/Components/Nav/NavTab.svelte +58 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +103 -111
- package/dist/Components/Nav/ServicesNav.svelte +72 -79
- package/dist/Components/NumberInput.svelte +121 -155
- package/dist/Components/OptionCards.svelte +62 -73
- package/dist/Components/PageHeading.svelte +23 -25
- package/dist/Components/PasswordInput.svelte +69 -88
- package/dist/Components/PopoverButton.svelte +151 -0
- package/dist/Components/PopoverButton.svelte.d.ts +9 -0
- package/dist/Components/PopoverButtonProps.d.ts +21 -0
- package/dist/Components/PopoverButtonProps.js +1 -0
- package/dist/Components/Portal.svelte +29 -35
- package/dist/Components/ProgressBubble.svelte +91 -106
- package/dist/Components/QuerySelect.svelte +260 -346
- package/dist/Components/SidebarPanel.svelte +34 -36
- package/dist/Components/SingleSelect.svelte +196 -244
- package/dist/Components/StepButton.svelte +65 -70
- package/dist/Components/StepForm.svelte +115 -135
- package/dist/Components/Switch.svelte +57 -69
- package/dist/Components/Table/ARCHITECTURE.md +298 -298
- package/dist/Components/Table/Body/QuickSearchCell.svelte +578 -655
- package/dist/Components/Table/Body/Rows/ColumnHighlight.svelte +42 -51
- package/dist/Components/Table/Body/Rows/ColumnList.svelte +42 -58
- package/dist/Components/Table/Body/Rows/ColumnListRow.svelte +403 -442
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +51 -78
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +165 -184
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +110 -123
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +134 -160
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +190 -231
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +82 -104
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +52 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +122 -150
- package/dist/Components/Table/Body/Rows/Columns/TableColumn.svelte +132 -159
- package/dist/Components/Table/Body/Rows/Columns/TableDatePicker.svelte +190 -236
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +173 -211
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +204 -244
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +140 -177
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +188 -217
- package/dist/Components/Table/Body/Rows/Columns/TableTextInput.svelte +173 -193
- package/dist/Components/Table/Body/Rows/Columns/ValidityCell.svelte +166 -187
- package/dist/Components/Table/Body/Rows/TableRow.svelte +245 -288
- package/dist/Components/Table/Body/TableBody.svelte +141 -154
- package/dist/Components/Table/Headers/HighlightAllHeader.svelte +35 -41
- package/dist/Components/Table/Headers/SelectAllHeader.svelte +24 -30
- package/dist/Components/Table/Headers/TableHead.svelte +348 -402
- package/dist/Components/Table/Misc/ColumnPanel.svelte +37 -39
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +35 -39
- package/dist/Components/Table/Misc/FilterInput.svelte +556 -619
- package/dist/Components/Table/Misc/FilterPanel.svelte +170 -183
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +25 -31
- package/dist/Components/Table/Misc/ShareViewModal.svelte +252 -281
- package/dist/Components/Table/Misc/SidePanel.svelte +32 -35
- package/dist/Components/Table/Misc/TableConfigurationModal.svelte +574 -629
- package/dist/Components/Table/Misc/TableFooter.svelte +326 -332
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +134 -140
- package/dist/Components/Table/Misc/TableSidebar.svelte +183 -198
- package/dist/Components/Table/Misc/TableViewDropdown.svelte +83 -103
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +83 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +88 -107
- package/dist/Components/Table/Misc/UpdateViewOptionsModal.svelte +163 -190
- package/dist/Components/Table/NestedTable.svelte +102 -128
- package/dist/Components/Table/Table.svelte +531 -663
- package/dist/Components/Test/TestContextConsumer.svelte +11 -13
- package/dist/Components/TextArea.svelte +95 -130
- package/dist/Components/TextInput.svelte +125 -176
- package/dist/Components/ThreeStateRadio.svelte +111 -130
- package/dist/Components/Touch/BoolCard.svelte +33 -45
- package/dist/Components/Touch/DateModal.svelte +164 -204
- package/dist/Components/Touch/EditCard.svelte +48 -59
- package/dist/Components/Touch/InfoCard.svelte +28 -31
- package/dist/Components/Touch/InfoTextCard.svelte +26 -28
- package/dist/Components/Touch/ModalExplanation.svelte +15 -17
- package/dist/Components/Touch/NumberKeyboard.svelte +181 -218
- package/dist/Components/Touch/NumberModal.svelte +59 -79
- package/dist/Components/Touch/PlusMinusCard.svelte +43 -46
- package/dist/Components/Touch/SelectModal.svelte +111 -126
- package/dist/Components/Touch/SummaryCard.svelte +80 -93
- package/dist/Components/Touch/TextAreaModal.svelte +72 -94
- package/dist/Components/Touch/TextModal.svelte +77 -105
- package/dist/Components/Touch/TouchCard.svelte +31 -33
- package/dist/Components/Touch/TouchModal.svelte +214 -270
- package/dist/Components/Touch/UtilityButton.svelte +88 -109
- package/dist/Components/VerticalTabGroup.svelte +60 -78
- package/dist/Components/VerticalTabGroupButton.svelte +54 -58
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Types/Examples/ExampleModal.svelte +31 -35
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- 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,417 +1,363 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
module
|
|
5
|
-
lang="ts"
|
|
6
|
-
>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* single timer flush. A fast double-click thus cycles straight to
|
|
31
|
-
* desc (or clear-sort) without waiting for the asc state to apply and
|
|
32
|
-
* reload data first. ~150 ms is below the perceived-latency threshold
|
|
33
|
-
* while still wide enough to batch dblclicks. */
|
|
34
|
-
const SORT_DEBOUNCE_MS = 150;
|
|
35
|
-
const sortDebounce = new WeakMap<
|
|
36
|
-
object,
|
|
37
|
-
{ count: number; timer: ReturnType<typeof setTimeout> | null }
|
|
38
|
-
>();
|
|
39
|
-
function debouncedSortToggle(
|
|
40
|
-
columnRef: object,
|
|
41
|
-
// `never[]` rest sidesteps TypeScript's strict-function-type
|
|
42
|
-
// contravariance: any concrete handler signature (e.g. the
|
|
43
|
-
// MouseEvent-typed one tanstack returns) is assignable here, and
|
|
44
|
-
// the body never passes any args.
|
|
45
|
-
handler: ((...args: never[]) => void) | undefined
|
|
46
|
-
): void {
|
|
47
|
-
if (!handler) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let entry = sortDebounce.get(columnRef);
|
|
51
|
-
if (!entry) {
|
|
52
|
-
entry = { count: 0, timer: null };
|
|
53
|
-
sortDebounce.set(columnRef, entry);
|
|
54
|
-
}
|
|
55
|
-
entry.count += 1;
|
|
56
|
-
if (entry.timer != null) {
|
|
57
|
-
clearTimeout(entry.timer);
|
|
58
|
-
}
|
|
59
|
-
entry.timer = setTimeout(() => {
|
|
60
|
-
const toFire = entry!.count;
|
|
61
|
-
entry!.count = 0;
|
|
62
|
-
entry!.timer = null;
|
|
63
|
-
for (let i = 0; i < toFire; i++) {
|
|
64
|
-
handler();
|
|
65
|
-
}
|
|
66
|
-
}, SORT_DEBOUNCE_MS);
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
module
|
|
5
|
+
lang="ts"
|
|
6
|
+
>import Icon from "../../Icon.svelte";
|
|
7
|
+
import { TooltipContext } from "../../../Contexts/TooltipContext.svelte.js";
|
|
8
|
+
import { Delay } from "../../../Delay/Delay.js";
|
|
9
|
+
import { Colour } from "../../../scss/colours.js";
|
|
10
|
+
import { Side } from "../../../Types/Internal/Side.js";
|
|
11
|
+
import { Size } from "../../../Types/Internal/Size.js";
|
|
12
|
+
import { Variant } from "../../../Types/Internal/Variant.js";
|
|
13
|
+
import { getContext } from "svelte";
|
|
14
|
+
import { ExpandDef } from "../Types/Columns/Definitions/Expand/ExpandDef.svelte.js";
|
|
15
|
+
import { RowSelectionDef } from "../Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js";
|
|
16
|
+
import { TableContext } from "../Types/Context/TableContext.svelte.js";
|
|
17
|
+
import HighlightAllHeader from "./HighlightAllHeader.svelte";
|
|
18
|
+
import SelectAllHeader from "./SelectAllHeader.svelte";
|
|
19
|
+
/** Per-column toggle queue. The header onclick funnels through this so
|
|
20
|
+
* multiple clicks inside the debounce window stack and apply on a
|
|
21
|
+
* single timer flush. A fast double-click thus cycles straight to
|
|
22
|
+
* desc (or clear-sort) without waiting for the asc state to apply and
|
|
23
|
+
* reload data first. ~150 ms is below the perceived-latency threshold
|
|
24
|
+
* while still wide enough to batch dblclicks. */
|
|
25
|
+
const SORT_DEBOUNCE_MS = 150;
|
|
26
|
+
const sortDebounce = new WeakMap();
|
|
27
|
+
function debouncedSortToggle(columnRef, handler) {
|
|
28
|
+
if (!handler) {
|
|
29
|
+
return;
|
|
67
30
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
>
|
|
74
|
-
const { oncontextmenu }: TableHeadProps = $props();
|
|
75
|
-
|
|
76
|
-
const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
|
|
77
|
-
const tooltipContext = getContext<TooltipContext>(TooltipContext.identifier);
|
|
78
|
-
|
|
79
|
-
const leftHeaders: Array<AnyHeader<T>> = $derived.by(() => {
|
|
80
|
-
void tableContext.table.columnVisibility;
|
|
81
|
-
void tableContext.table.columnPinning.left?.size;
|
|
82
|
-
void tableContext.table.columnPinning.right?.size;
|
|
83
|
-
return tableContext.table.getLeftHeaderGroups().flatMap((it) => it.headers);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const centreHeaders: Array<AnyHeader<T>> = $derived.by(() => {
|
|
87
|
-
void tableContext.table.columnVisibility;
|
|
88
|
-
void tableContext.table.columnPinning.left?.size;
|
|
89
|
-
void tableContext.table.columnPinning.right?.size;
|
|
90
|
-
return tableContext.table.getCenterHeaderGroups().flatMap((it) => it.headers);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const rightHeaders: Array<AnyHeader<T>> = $derived.by(() => {
|
|
94
|
-
void tableContext.table.columnVisibility;
|
|
95
|
-
void tableContext.table.columnPinning.left?.size;
|
|
96
|
-
void tableContext.table.columnPinning.right?.size;
|
|
97
|
-
return tableContext.table.getRightHeaderGroups().flatMap((it) => it.headers);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Cumulative pinning offsets for sticky-positioned cells. Each
|
|
101
|
-
// pinned-left cell anchors to `left: (sum of preceding pinned-left
|
|
102
|
-
// widths)`; pinned-right cells anchor to `right: (sum of following
|
|
103
|
-
// pinned-right widths)`. Recomputed on resize-handle drag and
|
|
104
|
-
// column-sizing reset.
|
|
105
|
-
//
|
|
106
|
-
// Rendered widths come from the shared context map populated by the
|
|
107
|
-
// ResizeObserver below. The `header.getSize()` fallback (declared
|
|
108
|
-
// width) covers the first frame before the observer fires.
|
|
109
|
-
function renderedWidth(columnId: string, declared: number): number {
|
|
110
|
-
return tableContext._columnRenderedWidths.get(columnId) ?? declared;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Single ResizeObserver shared across all header cells. Each
|
|
114
|
-
// `<div role="columnheader">` registers via the `observeHeader`
|
|
115
|
-
// attachment; the callback writes the cell's rendered inline-size
|
|
116
|
-
// into `_columnRenderedWidths` so TableRow / TableHead / TableBody
|
|
117
|
-
// can read accurate sticky pinning offsets.
|
|
118
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
119
|
-
const elementToColumnId = new WeakMap<Element, string>();
|
|
120
|
-
const headerObserver =
|
|
121
|
-
typeof ResizeObserver === 'undefined'
|
|
122
|
-
? null
|
|
123
|
-
: new ResizeObserver((entries) => {
|
|
124
|
-
for (const entry of entries) {
|
|
125
|
-
const columnId = elementToColumnId.get(entry.target);
|
|
126
|
-
if (columnId == null) {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const inlineSize = entry.borderBoxSize[0]?.inlineSize ?? entry.contentRect.width;
|
|
130
|
-
tableContext._columnRenderedWidths.set(columnId, inlineSize);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
$effect(() => () => {
|
|
135
|
-
headerObserver?.disconnect();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
function observeHeader(node: HTMLElement, columnId: string): () => void {
|
|
139
|
-
if (!headerObserver) {
|
|
140
|
-
return () => {};
|
|
141
|
-
}
|
|
142
|
-
elementToColumnId.set(node, columnId);
|
|
143
|
-
headerObserver.observe(node);
|
|
144
|
-
return () => {
|
|
145
|
-
headerObserver.unobserve(node);
|
|
146
|
-
elementToColumnId.delete(node);
|
|
147
|
-
tableContext._columnRenderedWidths.delete(columnId);
|
|
31
|
+
let entry = sortDebounce.get(columnRef);
|
|
32
|
+
if (!entry) {
|
|
33
|
+
entry = {
|
|
34
|
+
count: 0,
|
|
35
|
+
timer: null
|
|
148
36
|
};
|
|
37
|
+
sortDebounce.set(columnRef, entry);
|
|
149
38
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
39
|
+
entry.count += 1;
|
|
40
|
+
if (entry.timer != null) {
|
|
41
|
+
clearTimeout(entry.timer);
|
|
42
|
+
}
|
|
43
|
+
entry.timer = setTimeout(() => {
|
|
44
|
+
const toFire = entry.count;
|
|
45
|
+
entry.count = 0;
|
|
46
|
+
entry.timer = null;
|
|
47
|
+
for (let i = 0; i < toFire; i++) {
|
|
48
|
+
handler();
|
|
160
49
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
50
|
+
}, SORT_DEBOUNCE_MS);
|
|
51
|
+
}
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<script
|
|
55
|
+
lang="ts"
|
|
56
|
+
generics="T extends object, IdType extends Primitive"
|
|
57
|
+
>const { oncontextmenu } = $props();
|
|
58
|
+
const tableContext = getContext(TableContext.identifier);
|
|
59
|
+
const tooltipContext = getContext(TooltipContext.identifier);
|
|
60
|
+
const leftHeaders = $derived.by(() => {
|
|
61
|
+
void tableContext.table.columnVisibility;
|
|
62
|
+
void tableContext.table.columnPinning.left?.size;
|
|
63
|
+
void tableContext.table.columnPinning.right?.size;
|
|
64
|
+
return tableContext.table.getLeftHeaderGroups().flatMap((it) => it.headers);
|
|
65
|
+
});
|
|
66
|
+
const centreHeaders = $derived.by(() => {
|
|
67
|
+
void tableContext.table.columnVisibility;
|
|
68
|
+
void tableContext.table.columnPinning.left?.size;
|
|
69
|
+
void tableContext.table.columnPinning.right?.size;
|
|
70
|
+
return tableContext.table.getCenterHeaderGroups().flatMap((it) => it.headers);
|
|
71
|
+
});
|
|
72
|
+
const rightHeaders = $derived.by(() => {
|
|
73
|
+
void tableContext.table.columnVisibility;
|
|
74
|
+
void tableContext.table.columnPinning.left?.size;
|
|
75
|
+
void tableContext.table.columnPinning.right?.size;
|
|
76
|
+
return tableContext.table.getRightHeaderGroups().flatMap((it) => it.headers);
|
|
77
|
+
});
|
|
78
|
+
// Cumulative pinning offsets for sticky-positioned cells. Each
|
|
79
|
+
// pinned-left cell anchors to `left: (sum of preceding pinned-left
|
|
80
|
+
// widths)`; pinned-right cells anchor to `right: (sum of following
|
|
81
|
+
// pinned-right widths)`. Recomputed on resize-handle drag and
|
|
82
|
+
// column-sizing reset.
|
|
83
|
+
//
|
|
84
|
+
// Rendered widths come from the shared context map populated by the
|
|
85
|
+
// ResizeObserver below. The `header.getSize()` fallback (declared
|
|
86
|
+
// width) covers the first frame before the observer fires.
|
|
87
|
+
function renderedWidth(columnId, declared) {
|
|
88
|
+
return tableContext._columnRenderedWidths.get(columnId) ?? declared;
|
|
89
|
+
}
|
|
90
|
+
// Single ResizeObserver shared across all header cells. Each
|
|
91
|
+
// `<div role="columnheader">` registers via the `observeHeader`
|
|
92
|
+
// attachment; the callback writes the cell's rendered inline-size
|
|
93
|
+
// into `_columnRenderedWidths` so TableRow / TableHead / TableBody
|
|
94
|
+
// can read accurate sticky pinning offsets.
|
|
95
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
96
|
+
const elementToColumnId = new WeakMap();
|
|
97
|
+
const headerObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver((entries) => {
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
const columnId = elementToColumnId.get(entry.target);
|
|
100
|
+
if (columnId == null) {
|
|
101
|
+
continue;
|
|
171
102
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const showHighlightColumn = $derived(
|
|
176
|
-
leftHeaders.length > 0 || centreHeaders.length > 0 || rightHeaders.length > 0
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const iconNames = {
|
|
180
|
-
asc: 'sort-asc',
|
|
181
|
-
desc: 'sort-desc',
|
|
182
|
-
none: 'sort-none',
|
|
183
|
-
} as const;
|
|
184
|
-
|
|
185
|
-
let currentDropTarget: HTMLElement | null = $state(null);
|
|
186
|
-
|
|
187
|
-
function setCurrentDropTarget(target: EventTarget | null) {
|
|
188
|
-
currentDropTarget = target as HTMLElement | null;
|
|
103
|
+
const inlineSize = entry.borderBoxSize[0]?.inlineSize ?? entry.contentRect.width;
|
|
104
|
+
tableContext._columnRenderedWidths.set(columnId, inlineSize);
|
|
189
105
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (!rect) {
|
|
198
|
-
console.warn('could not find closest columnheader');
|
|
199
|
-
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
tooltipContext.showTooltip({
|
|
204
|
-
text: `Show ${typeof columnDef.header === 'string' ? columnDef.header : columnDef.id}`,
|
|
205
|
-
arrow: Side.Bottom,
|
|
206
|
-
delay: Delay.Default,
|
|
207
|
-
rect,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
106
|
+
});
|
|
107
|
+
$effect(() => () => {
|
|
108
|
+
headerObserver?.disconnect();
|
|
109
|
+
});
|
|
110
|
+
function observeHeader(node, columnId) {
|
|
111
|
+
if (!headerObserver) {
|
|
112
|
+
return () => {};
|
|
210
113
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
114
|
+
elementToColumnId.set(node, columnId);
|
|
115
|
+
headerObserver.observe(node);
|
|
116
|
+
return () => {
|
|
117
|
+
headerObserver.unobserve(node);
|
|
118
|
+
elementToColumnId.delete(node);
|
|
119
|
+
tableContext._columnRenderedWidths.delete(columnId);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const leftOffsets = $derived.by(() => {
|
|
123
|
+
void tableContext._columnRenderedWidths.size;
|
|
124
|
+
const offsets = [];
|
|
125
|
+
// Highlight column is 20px wide and the first pinned-left cell
|
|
126
|
+
// when present, so subsequent pinned-left headers offset past it.
|
|
127
|
+
let cumulative = showHighlightColumn ? 20 : 0;
|
|
128
|
+
for (const header of leftHeaders) {
|
|
129
|
+
offsets.push(cumulative);
|
|
130
|
+
cumulative += renderedWidth(header.column.id, header.getSize());
|
|
218
131
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
132
|
+
return offsets;
|
|
133
|
+
});
|
|
134
|
+
const rightOffsets = $derived.by(() => {
|
|
135
|
+
void tableContext._columnRenderedWidths.size;
|
|
136
|
+
const offsets = new Array(rightHeaders.length).fill(0);
|
|
137
|
+
let cumulative = 0;
|
|
138
|
+
for (let i = rightHeaders.length - 1; i >= 0; i--) {
|
|
139
|
+
offsets[i] = cumulative;
|
|
140
|
+
cumulative += renderedWidth(rightHeaders[i].column.id, rightHeaders[i].getSize());
|
|
141
|
+
}
|
|
142
|
+
return offsets;
|
|
143
|
+
});
|
|
144
|
+
const showHighlightColumn = $derived(leftHeaders.length > 0 || centreHeaders.length > 0 || rightHeaders.length > 0);
|
|
145
|
+
const iconNames = {
|
|
146
|
+
asc: "sort-asc",
|
|
147
|
+
desc: "sort-desc",
|
|
148
|
+
none: "sort-none"
|
|
149
|
+
};
|
|
150
|
+
let currentDropTarget = $state(null);
|
|
151
|
+
function setCurrentDropTarget(target) {
|
|
152
|
+
currentDropTarget = target;
|
|
153
|
+
}
|
|
154
|
+
function showtooltip(e, columnDef) {
|
|
155
|
+
if (columnDef instanceof ExpandDef) {
|
|
156
|
+
const rect = e.target.closest("[role=\"columnheader\"]")?.getBoundingClientRect();
|
|
157
|
+
if (!rect) {
|
|
158
|
+
console.warn("could not find closest columnheader");
|
|
222
159
|
return;
|
|
223
160
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
currentDropTarget = null;
|
|
161
|
+
tooltipContext.showTooltip({
|
|
162
|
+
text: `Show ${typeof columnDef.header === "string" ? columnDef.header : columnDef.id}`,
|
|
163
|
+
arrow: Side.Bottom,
|
|
164
|
+
delay: Delay.Default,
|
|
165
|
+
rect
|
|
166
|
+
});
|
|
232
167
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
if (state === 'desc') {
|
|
239
|
-
return 'descending';
|
|
240
|
-
}
|
|
241
|
-
return 'none';
|
|
168
|
+
}
|
|
169
|
+
function hideTooltip(columnDef) {
|
|
170
|
+
if (columnDef instanceof ExpandDef) {
|
|
171
|
+
tooltipContext.hideTooltip(`Show ${typeof columnDef.header === "string" ? columnDef.header : columnDef.id}`);
|
|
242
172
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
173
|
+
}
|
|
174
|
+
function onDrop() {
|
|
175
|
+
if (!tableContext.dragTarget) {
|
|
176
|
+
return;
|
|
246
177
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
{#
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
178
|
+
const dropTarget = currentDropTarget?.closest("[role=\"columnheader\"]");
|
|
179
|
+
if (dropTarget) {
|
|
180
|
+
tableContext.reorderColumn(dropTarget);
|
|
181
|
+
}
|
|
182
|
+
currentDropTarget = null;
|
|
183
|
+
}
|
|
184
|
+
function ariaSort(state) {
|
|
185
|
+
if (state === "asc") {
|
|
186
|
+
return "ascending";
|
|
187
|
+
}
|
|
188
|
+
if (state === "desc") {
|
|
189
|
+
return "descending";
|
|
190
|
+
}
|
|
191
|
+
return "none";
|
|
192
|
+
}
|
|
193
|
+
function setDragTarget(def) {
|
|
194
|
+
tableContext.dragTarget = def;
|
|
195
|
+
}
|
|
196
|
+
const currentDropTargetId = $derived(currentDropTarget?.closest("[role=\"columnheader\"]")?.id);
|
|
197
|
+
</script>
|
|
198
|
+
|
|
199
|
+
<div
|
|
200
|
+
role="rowgroup"
|
|
201
|
+
class="datatable-header"
|
|
202
|
+
{oncontextmenu}
|
|
203
|
+
>
|
|
204
|
+
<div
|
|
205
|
+
role="row"
|
|
206
|
+
class="datatable-row header-row"
|
|
207
|
+
>
|
|
208
|
+
{#if showHighlightColumn}
|
|
209
|
+
<div
|
|
210
|
+
role="columnheader"
|
|
211
|
+
id="highlight-header"
|
|
212
|
+
class="cell header highlight-column pinned-left"
|
|
213
|
+
style="left: 0px"
|
|
214
|
+
>
|
|
215
|
+
<div class="th">
|
|
216
|
+
<HighlightAllHeader />
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
{/if}
|
|
220
|
+
|
|
221
|
+
{#each leftHeaders as header, index (header.id)}
|
|
222
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
223
|
+
{@render headerCell(header, 'left', leftOffsets[index])}
|
|
224
|
+
{/each}
|
|
225
|
+
{#each centreHeaders as header (header.id)}
|
|
226
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
227
|
+
{@render headerCell(header, undefined, 0)}
|
|
228
|
+
{/each}
|
|
229
|
+
{#each rightHeaders as header, index (header.id)}
|
|
230
|
+
<!-- eslint-disable-next-line @typescript-eslint/no-confusing-void-expression -->
|
|
231
|
+
{@render headerCell(header, 'right', rightOffsets[index])}
|
|
232
|
+
{/each}
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
{#snippet headerCell(header: AnyHeader<T>, side: 'left' | 'right' | undefined, offset: number)}
|
|
237
|
+
{@const headerId = `${tableContext.tableName}-header-${header.id}`}
|
|
238
|
+
<!-- svelte-ignore a11y_interactive_supports_focus -->
|
|
239
|
+
<div
|
|
240
|
+
role="columnheader"
|
|
241
|
+
id={headerId}
|
|
242
|
+
{@attach (node: HTMLElement) => observeHeader(node, header.column.id)}
|
|
243
|
+
draggable={tableContext.allowColumnReordering}
|
|
244
|
+
class="cell header"
|
|
245
|
+
class:pinned-left={side === 'left'}
|
|
246
|
+
class:pinned-right={side === 'right'}
|
|
247
|
+
class:action-column={!header.column.getCanSort()}
|
|
248
|
+
class:targeted={currentDropTargetId === headerId}
|
|
249
|
+
style:left={side === 'left' ? `${offset}px` : null}
|
|
250
|
+
style:right={side === 'right' ? `${offset}px` : null}
|
|
251
|
+
aria-sort={header.column.getCanSort() ? ariaSort(header.column.getIsSorted()) : undefined}
|
|
252
|
+
ondragstart={() => {
|
|
253
|
+
setDragTarget(header.column.columnDef);
|
|
254
|
+
}}
|
|
255
|
+
ondragover={(e) => {
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
if (tableContext.dragTarget?.id !== header.id) {
|
|
258
|
+
setCurrentDropTarget(e.target);
|
|
259
|
+
} else {
|
|
260
|
+
setCurrentDropTarget(null);
|
|
261
|
+
}
|
|
262
|
+
}}
|
|
263
|
+
ondrop={onDrop}
|
|
264
|
+
>
|
|
265
|
+
{#if !header.isPlaceholder}
|
|
266
|
+
<div class="margin-right">
|
|
267
|
+
{#if header.column.getCanSort()}
|
|
268
|
+
<button
|
|
269
|
+
onmouseenter={(e) => {
|
|
270
|
+
showtooltip(e, header.column.columnDef);
|
|
271
|
+
}}
|
|
272
|
+
onmouseleave={() => {
|
|
273
|
+
hideTooltip(header.column.columnDef);
|
|
274
|
+
}}
|
|
275
|
+
class="contents"
|
|
276
|
+
onclick={() => debouncedSortToggle(header.column, header.column.getToggleSortingHandler())}
|
|
277
|
+
>
|
|
278
|
+
<div class="th cursor-pointer select-none">
|
|
279
|
+
<div class="header-text-wrapper">
|
|
280
|
+
{#if header.column.columnDef instanceof RowSelectionDef}
|
|
281
|
+
<SelectAllHeader />
|
|
282
|
+
{:else}
|
|
283
|
+
{#if header.column.columnDef instanceof ExpandDef}
|
|
284
|
+
<Icon
|
|
285
|
+
name={header.column.columnDef.headerIcon}
|
|
286
|
+
colour={Colour['$font-primary']}
|
|
287
|
+
/>
|
|
288
|
+
{:else if typeof header.column.columnDef.header == 'string'}
|
|
289
|
+
{header.column.columnDef.header}
|
|
290
|
+
{:else}
|
|
291
|
+
{@render header.column.columnDef.header()}
|
|
292
|
+
{/if}
|
|
293
|
+
<Icon
|
|
294
|
+
variant={Variant.HeaderIcon}
|
|
295
|
+
size={Size.Medium}
|
|
296
|
+
name={iconNames[header.column.getIsSorted()]}
|
|
297
|
+
/>
|
|
298
|
+
{/if}
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
</button>
|
|
302
|
+
{:else}
|
|
303
|
+
{@const isRowSelect = header.column.columnDef instanceof RowSelectionDef}
|
|
304
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
305
|
+
<div
|
|
306
|
+
onmouseenter={(e) => {
|
|
307
|
+
showtooltip(e, header.column.columnDef);
|
|
308
|
+
}}
|
|
309
|
+
onmouseleave={() => {
|
|
310
|
+
hideTooltip(header.column.columnDef);
|
|
311
|
+
}}
|
|
312
|
+
class="contents"
|
|
313
|
+
>
|
|
314
|
+
<div
|
|
315
|
+
class="th"
|
|
316
|
+
class:nopadding={isRowSelect}
|
|
317
|
+
>
|
|
318
|
+
<div class="header-text-wrapper no-sort cursor-pointer select-none">
|
|
319
|
+
{#if isRowSelect}
|
|
320
|
+
<SelectAllHeader />
|
|
321
|
+
{:else if header.column.columnDef instanceof ExpandDef}
|
|
322
|
+
<Icon
|
|
323
|
+
name={header.column.columnDef.headerIcon}
|
|
324
|
+
colour={Colour['$font-primary']}
|
|
325
|
+
/>
|
|
326
|
+
{:else if typeof header.column.columnDef.header == 'string'}
|
|
327
|
+
{header.column.columnDef.header}
|
|
328
|
+
{:else}
|
|
329
|
+
{@render header.column.columnDef.header()}
|
|
330
|
+
{/if}
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
{/if}
|
|
335
|
+
|
|
336
|
+
{#if tableContext.enableResize}
|
|
337
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
338
|
+
<div
|
|
339
|
+
onmousedown={(e) => {
|
|
340
|
+
e.preventDefault();
|
|
341
|
+
e.stopImmediatePropagation();
|
|
342
|
+
const handler = header.getResizeHandler();
|
|
343
|
+
handler(e);
|
|
344
|
+
}}
|
|
345
|
+
ondblclick={() => {
|
|
346
|
+
// Reset the column to its factory-default width and
|
|
347
|
+
// clear the user-resized flag so the grid track
|
|
348
|
+
// returns to its original `minmax(W, 1fr)` or
|
|
349
|
+
// fixed-`${W}px` branch.
|
|
350
|
+
header.column.columnDef.resetWidth();
|
|
351
|
+
}}
|
|
352
|
+
class="resizer right"
|
|
353
|
+
class:isResizing={header.column.getIsResizing()}
|
|
354
|
+
></div>
|
|
355
|
+
{/if}
|
|
356
|
+
</div>
|
|
357
|
+
{/if}
|
|
358
|
+
</div>
|
|
359
|
+
{/snippet}
|
|
360
|
+
|
|
415
361
|
<style>.cell.header {
|
|
416
362
|
position: relative;
|
|
417
363
|
min-width: 0;
|
|
@@ -562,4 +508,4 @@ div.th::after {
|
|
|
562
508
|
width: 20px;
|
|
563
509
|
overflow: hidden;
|
|
564
510
|
border-right: solid 1px #cbd4da;
|
|
565
|
-
}</style>
|
|
511
|
+
}</style>
|