@lavalogic/scoria 0.37.44 → 0.37.45
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/ActionProps.d.ts +2 -6
- package/dist/Components/AlertModal.svelte +195 -183
- package/dist/Components/AppointmentCalendar/AppointmentCalendar.svelte +702 -702
- 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/ButtonProps.d.ts +2 -6
- 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 +83 -83
- 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/DataMatrixIconProps.d.ts +3 -13
- 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/DialProps.d.ts +1 -18
- 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 -200
- 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/IconProps.d.ts +2 -7
- package/dist/Components/Icons.js +357 -357
- package/dist/Components/LoadingAnimation.svelte +29 -29
- package/dist/Components/LoadingModal.svelte +45 -45
- package/dist/Components/LoadingOverlay.svelte +25 -25
- package/dist/Components/LoadingOverlayProps.d.ts +3 -7
- package/dist/Components/Modal.svelte +258 -258
- package/dist/Components/ModalProps.d.ts +0 -3
- package/dist/Components/MultiSelect.svelte +220 -220
- package/dist/Components/MultiSelectCommonProps.d.ts +6 -17
- package/dist/Components/Nav/Nav.svelte +99 -99
- package/dist/Components/Nav/NavProps.d.ts +4 -11
- package/dist/Components/Nav/NavServiceMenuList.svelte +43 -43
- package/dist/Components/Nav/NavTab.svelte +62 -62
- package/dist/Components/Nav/ServiceMenuItem.svelte +100 -100
- 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 -108
- package/dist/Components/ProgressBubbleProps.d.ts +3 -3
- package/dist/Components/QuerySelect.svelte +366 -366
- package/dist/Components/QuerySelectProps.d.ts +4 -14
- package/dist/Components/SingleSelect.svelte +250 -250
- package/dist/Components/SingleSelectCommonProps.d.ts +3 -19
- 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 -0
- package/dist/Components/Table/Body/QuickSearchCell.svelte +679 -694
- 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 +456 -478
- package/dist/Components/Table/Body/Rows/Columns/AccessorComponent.svelte +79 -79
- package/dist/Components/Table/Body/Rows/Columns/ActionsCell.svelte +185 -188
- package/dist/Components/Table/Body/Rows/Columns/BubbleCell.svelte +124 -124
- package/dist/Components/Table/Body/Rows/Columns/ExpandCell.svelte +120 -120
- package/dist/Components/Table/Body/Rows/Columns/FocusableImmutableCell.svelte +230 -230
- package/dist/Components/Table/Body/Rows/Columns/ProgressCell.svelte +105 -105
- package/dist/Components/Table/Body/Rows/Columns/SelectColumn.d.ts +12 -9
- package/dist/Components/Table/Body/Rows/Columns/SelectTableCell.d.ts +5 -5
- package/dist/Components/Table/Body/Rows/Columns/TableAction.svelte +87 -87
- package/dist/Components/Table/Body/Rows/Columns/TableCheckbox.svelte +126 -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/TableDatePickerProps.d.ts +4 -4
- package/dist/Components/Table/Body/Rows/Columns/TableNumberInput.svelte +216 -216
- package/dist/Components/Table/Body/Rows/Columns/TableQueryCell.d.ts +6 -5
- package/dist/Components/Table/Body/Rows/Columns/TableQueryColumn.d.ts +7 -6
- package/dist/Components/Table/Body/Rows/Columns/TableQuerySelect.svelte +252 -257
- package/dist/Components/Table/Body/Rows/Columns/TableRowSelectionCheckbox.svelte +179 -179
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte +221 -229
- package/dist/Components/Table/Body/Rows/Columns/TableSelect.svelte.d.ts +11 -11
- 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/ColumnDefinitions/ExampleItemColumnDefRepository.svelte.js +2 -3
- package/dist/Components/Table/ColumnFactory.svelte.d.ts +9 -11
- package/dist/Components/Table/ColumnFactory.svelte.js +101 -118
- package/dist/Components/Table/ColumnKindRegistry.d.ts +112 -0
- package/dist/Components/Table/ColumnKindRegistry.js +63 -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 -413
- package/dist/Components/Table/Misc/ColumnPanel.svelte +94 -94
- package/dist/Components/Table/Misc/ColumnPanelModal.svelte +112 -112
- package/dist/Components/Table/Misc/FilterInput.svelte +620 -644
- package/dist/Components/Table/Misc/FilterInput.svelte.d.ts +12 -12
- package/dist/Components/Table/Misc/FilterInputProps.d.ts +2 -2
- package/dist/Components/Table/Misc/FilterPanel.svelte +257 -257
- package/dist/Components/Table/Misc/FilterPanelModal.svelte +30 -30
- package/dist/Components/Table/Misc/SidePanel.svelte +35 -35
- package/dist/Components/Table/Misc/TableFooter.svelte +311 -311
- package/dist/Components/Table/Misc/TableHorizontalBar.svelte +125 -125
- package/dist/Components/Table/Misc/TableSidebar.svelte +157 -157
- package/dist/Components/Table/Misc/ToolboxPanel.svelte +100 -100
- package/dist/Components/Table/Misc/ToolboxPanelModal.svelte +107 -107
- package/dist/Components/Table/NestedTable.svelte +130 -133
- package/dist/Components/Table/SubApis.svelte.d.ts +1 -5
- package/dist/Components/Table/SubApis.svelte.js +33 -32
- package/dist/Components/Table/Table.svelte +692 -745
- package/dist/Components/Table/TableHelpers.svelte.d.ts +6 -19
- package/dist/Components/Table/TableHelpers.svelte.js +6 -14
- package/dist/Components/Table/Types/Columns/Column.d.ts +2 -2
- package/dist/Components/Table/Types/Columns/DateColumn.d.ts +3 -3
- package/dist/Components/Table/Types/Columns/DateTableCell.d.ts +7 -7
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/AccessorDef.svelte.d.ts +7 -8
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/AccessorDef.svelte.js +4 -5
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/CheckboxDef.svelte.d.ts +11 -14
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/CheckboxDef.svelte.js +3 -4
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/DateInputDef.svelte.d.ts +7 -11
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/DateInputDef.svelte.js +3 -3
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/NumberInputDef.svelte.d.ts +13 -18
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/NumberInputDef.svelte.js +4 -5
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/QueryDef.svelte.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/QueryDef.svelte.js +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.d.ts +15 -12
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/SelectDef.svelte.js +4 -5
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/TextInputDef.svelte.d.ts +8 -12
- package/dist/Components/Table/Types/Columns/Definitions/Accessors/TextInputDef.svelte.js +3 -3
- package/dist/Components/Table/Types/Columns/Definitions/Actions/ActionsDef.svelte.d.ts +6 -6
- package/dist/Components/Table/Types/Columns/Definitions/Actions/ActionsDef.svelte.js +3 -3
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.d.ts +49 -16
- package/dist/Components/Table/Types/Columns/Definitions/ColumnDef.svelte.js +27 -5
- package/dist/Components/Table/Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.d.ts +7 -7
- package/dist/Components/Table/Types/Columns/Definitions/Display/AbstractDisplayDef.svelte.js +4 -4
- package/dist/Components/Table/Types/Columns/Definitions/Display/BubbleDef.svelte.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/Definitions/Display/BubbleDef.svelte.js +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Display/DisplayDef.svelte.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/Definitions/Display/DisplayDef.svelte.js +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Display/ProgressBarDef.svelte.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/Definitions/Display/ProgressBarDef.svelte.js +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Display/ValidityDef.svelte.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/Definitions/Display/ValidityDef.svelte.js +2 -2
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.d.ts +11 -19
- package/dist/Components/Table/Types/Columns/Definitions/Expand/ExpandDef.svelte.js +4 -8
- package/dist/Components/Table/Types/Columns/Definitions/FilterOnly/FilterOnlyDef.svelte.d.ts +6 -7
- package/dist/Components/Table/Types/Columns/Definitions/FilterOnly/FilterOnlyDef.svelte.js +3 -4
- package/dist/Components/Table/Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.d.ts +9 -9
- package/dist/Components/Table/Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js +4 -4
- package/dist/Components/Table/Types/Columns/ExpandTableCell.d.ts +5 -5
- package/dist/Components/Table/Types/Columns/ProgressBarTableCell.d.ts +6 -6
- package/dist/Components/Table/Types/Columns/TableCell.d.ts +7 -6
- package/dist/Components/Table/Types/Context/ClipboardState.svelte.d.ts +98 -0
- package/dist/Components/Table/Types/Context/ClipboardState.svelte.js +290 -0
- package/dist/Components/Table/Types/Context/ColumnLayoutState.svelte.d.ts +17 -45
- package/dist/Components/Table/Types/Context/ColumnLayoutState.svelte.js +17 -45
- package/dist/Components/Table/Types/Context/FilteringState.svelte.d.ts +9 -20
- package/dist/Components/Table/Types/Context/FilteringState.svelte.js +9 -20
- package/dist/Components/Table/Types/Context/FocusState.svelte.d.ts +23 -42
- package/dist/Components/Table/Types/Context/FocusState.svelte.js +32 -59
- package/dist/Components/Table/Types/Context/ITable.d.ts +5 -8
- package/dist/Components/Table/Types/Context/PreferencesState.svelte.d.ts +29 -56
- package/dist/Components/Table/Types/Context/PreferencesState.svelte.js +28 -55
- package/dist/Components/Table/Types/Context/QueryValuesState.svelte.d.ts +50 -0
- package/dist/Components/Table/Types/Context/QueryValuesState.svelte.js +62 -0
- package/dist/Components/Table/Types/Context/SelectionState.svelte.d.ts +17 -28
- package/dist/Components/Table/Types/Context/SelectionState.svelte.js +17 -28
- package/dist/Components/Table/Types/Context/SortingState.svelte.d.ts +15 -29
- package/dist/Components/Table/Types/Context/SortingState.svelte.js +17 -31
- package/dist/Components/Table/Types/Context/TableContext.svelte.d.ts +212 -325
- package/dist/Components/Table/Types/Context/TableContext.svelte.js +292 -706
- package/dist/Components/Table/Types/Context/VirtualisationState.svelte.d.ts +62 -79
- package/dist/Components/Table/Types/Context/VirtualisationState.svelte.js +54 -73
- package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.d.ts +16 -27
- package/dist/Components/Table/Types/DataRepository/BuiltInRemoteRepository.svelte.js +16 -27
- package/dist/Components/Table/Types/DataRepository/IDataRepository.d.ts +12 -15
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.d.ts +15 -30
- package/dist/Components/Table/Types/DataRepository/TableDataRepository.svelte.js +16 -28
- package/dist/Components/Table/Types/Header.d.ts +4 -4
- package/dist/Components/Table/Types/HeaderGroup.d.ts +5 -5
- package/dist/Components/Table/Types/Public/index.d.ts +2 -4
- package/dist/Components/Table/Types/Public/index.js +2 -4
- package/dist/Components/Table/clipboardEscape.d.ts +32 -0
- package/dist/Components/Table/clipboardEscape.js +45 -0
- package/dist/Components/Table/createTable.svelte.d.ts +8 -18
- package/dist/Components/Table/createTable.svelte.js +19 -47
- 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 +123 -123
- 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/Contexts/ToastContext.svelte.js +3 -4
- package/dist/Helpers/Datamatrix.d.ts +19 -19
- package/dist/Helpers/Datamatrix.js +291 -291
- package/dist/Helpers/Helpers.svelte.d.ts +2 -4
- package/dist/Helpers/Helpers.svelte.js +2 -4
- package/dist/Helpers/dropdownPortal.d.ts +26 -41
- package/dist/Helpers/dropdownPortal.js +62 -116
- package/dist/Types/Examples/ExampleModal.svelte +35 -35
- package/dist/index.d.ts +0 -1
- package/dist/scss/_basics.scss +12 -12
- package/dist/scss/_colours.scss +134 -134
- package/dist/scss/_mixins.scss +3348 -3360
- package/dist/scss/_motion.scss +57 -57
- package/dist/scss/_sizing.scss +85 -85
- package/dist/scss/_transitions.scss +8 -8
- package/package.json +2 -1
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Runtime for the typed column builder closure
|
|
2
|
+
* Runtime for the typed column builder closure passed to
|
|
3
3
|
* `createTable({ columns: (col) => [...] })`. Each method on the returned
|
|
4
|
-
* `ColumnFactory<TRow>` wraps the matching
|
|
5
|
-
* and returns a `ColumnSpec<TRow, Kind>` whose
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* `ColumnFactory<TRow>` wraps the matching internal `<Name>Def` constructor
|
|
5
|
+
* and returns a `ColumnSpec<TRow, Kind>` whose underlying `ColumnDef` plus
|
|
6
|
+
* any per-column edit handler / reactive dependencies are hidden behind a
|
|
7
|
+
* symbol-keyed property (`InternalSpecPayload`).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
12
|
-
*
|
|
13
|
-
* fields, with `id` passed explicitly at each call site so its narrowed
|
|
14
|
-
* type survives the spread.
|
|
9
|
+
* This file is a thin facade: it maps the consumer-friendly option names
|
|
10
|
+
* (`accessor`, `minWidth`, …) onto the internal Def field names (`accessorFn`,
|
|
11
|
+
* `minSize`, …) via the `commonProps(...)` helper. `id` is passed explicitly
|
|
12
|
+
* at each call site so its narrowed literal type survives the object spread.
|
|
15
13
|
*/
|
|
16
14
|
import { generateUUID, syntheticColumnId } from '../../Helpers/Helpers.svelte.js';
|
|
17
15
|
import { CheckboxDef } from './Types/Columns/Definitions/Accessors/CheckboxDef.svelte.js';
|
|
@@ -54,6 +52,10 @@ export function unwrapColumnSpec(spec) {
|
|
|
54
52
|
* `Object.keys` or JSON serialisation, while still being reachable via
|
|
55
53
|
* `unwrapColumnSpec(...)`. */
|
|
56
54
|
function makeSpec(kind, def, internals = {}) {
|
|
55
|
+
// Tag the def with its public-API kind. Drives the kind→filter map in
|
|
56
|
+
// `TableContext.setupDefaultColumnDefs` so the long instanceof cascade
|
|
57
|
+
// can be replaced by a single registry lookup.
|
|
58
|
+
def.kind = kind;
|
|
57
59
|
const spec = {
|
|
58
60
|
kind,
|
|
59
61
|
id: def.id,
|
|
@@ -67,24 +69,20 @@ function makeSpec(kind, def, internals = {}) {
|
|
|
67
69
|
});
|
|
68
70
|
return Object.freeze(spec);
|
|
69
71
|
}
|
|
70
|
-
/** Sensible per-kind default widths so a freshly-built table without
|
|
71
|
-
* per-column `width` overrides ends up visually differentiated
|
|
72
|
-
* every column collapsing to the shared `minSize`
|
|
73
|
-
* taking equal `1fr` shares of
|
|
74
|
-
*
|
|
75
|
-
*
|
|
72
|
+
/** Sensible per-kind default widths so a freshly-built table without
|
|
73
|
+
* explicit per-column `width` overrides ends up visually differentiated
|
|
74
|
+
* (rather than every column collapsing to the shared `minSize` floor and
|
|
75
|
+
* taking equal `1fr` shares of leftover track space). Numbers roughly
|
|
76
|
+
* match what the legacy `<table>` auto-layout produced for typical
|
|
77
|
+
* FloWMS column content.
|
|
78
|
+
*
|
|
79
|
+
* - `number: 120` — fits 7-8 digit IDs alongside sort/filter affordances.
|
|
80
|
+
* - `date: 180` — fits the "DD/MM/YYYY HH:mm" format used across FloWMS;
|
|
81
|
+
* narrower widths truncated the time portion. */
|
|
76
82
|
const KIND_DEFAULT_WIDTHS = {
|
|
77
83
|
text: 180,
|
|
78
|
-
// Bumped from 100 → 120 so 7-8 digit IDs / quantities (e.g. shipment
|
|
79
|
-
// IDs, order IDs) fit cleanly alongside the sort / filter affordances
|
|
80
|
-
// without forcing the value to truncate or wrap.
|
|
81
84
|
number: 120,
|
|
82
85
|
checkbox: 80,
|
|
83
|
-
// Bumped from 140 → 180 so the formatted "DD/MM/YYYY HH:mm" string
|
|
84
|
-
// fits inside the cell. The legacy 140px floor cut off the time
|
|
85
|
-
// portion for the typical date format used across FloWMS pages and
|
|
86
|
-
// forced every consumer to set a per-column `width` override (see
|
|
87
|
-
// OrderManagement, which had to pin date columns at 210).
|
|
88
86
|
date: 180,
|
|
89
87
|
select: 160,
|
|
90
88
|
query: 160,
|
|
@@ -108,22 +106,19 @@ function commonProps(opts, kind) {
|
|
|
108
106
|
const defaultWidth = KIND_DEFAULT_WIDTHS[kind];
|
|
109
107
|
return {
|
|
110
108
|
header: opts.header,
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
// which equalises every accessor column width and erases the
|
|
117
|
-
// per-kind differentiation the factory just put in place.
|
|
109
|
+
// `minSize` mirrors the per-kind default so `TableContext.registerDefs`
|
|
110
|
+
// does NOT fall back to the canvas-based `measureHeaderWidth`, which
|
|
111
|
+
// floors every accessor column at ~130px when quick-filtering is
|
|
112
|
+
// enabled (it returns max(headerWidth, "Lorem Ipsum Dolor" width))
|
|
113
|
+
// and erases the per-kind differentiation.
|
|
118
114
|
minSize: opts.minWidth ?? defaultWidth,
|
|
119
115
|
width: opts.width ?? defaultWidth,
|
|
120
116
|
maxWidth: opts.maxWidth,
|
|
121
117
|
wrapValue: opts.wrapValue,
|
|
122
|
-
// `widthIsFixed` is true only when the caller
|
|
123
|
-
// `width`. The grid template
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
// the fixed columns leave behind.
|
|
118
|
+
// `widthIsFixed` is true only when the caller supplied an explicit
|
|
119
|
+
// `width`. The grid template renders those tracks as `${W}px` and
|
|
120
|
+
// leaves per-kind-default columns on `minmax(W, 1fr)` so they
|
|
121
|
+
// absorb any horizontal space the fixed columns leave behind.
|
|
127
122
|
widthIsFixed: opts.width != null,
|
|
128
123
|
allowSorting: opts.allowSorting,
|
|
129
124
|
allowFiltering: opts.allowFiltering,
|
|
@@ -135,37 +130,28 @@ function commonProps(opts, kind) {
|
|
|
135
130
|
filterGroup: opts.filterGroup,
|
|
136
131
|
};
|
|
137
132
|
}
|
|
138
|
-
/** Generate a column id for a kind whose option type does not require
|
|
139
|
-
*
|
|
133
|
+
/** Generate a column id for a kind whose option type does not require an
|
|
134
|
+
* `id` from the caller.
|
|
140
135
|
*
|
|
141
|
-
* -
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* the request with "field does not exist".
|
|
149
|
-
* - When no `hint` is provided, fall back to `${prefix}-${UUID}` so
|
|
150
|
-
* the id is still unique within the table. Such columns cannot
|
|
151
|
-
* participate in server-driven filtering anyway (the server would
|
|
152
|
-
* not know the random suffix). */
|
|
136
|
+
* - With `hint`: used verbatim. `idHint` is the server-side-filtering
|
|
137
|
+
* contract; the column id flows through `createRemoteRowSource` as
|
|
138
|
+
* the query-string key the server expects, so a synthetic prefix
|
|
139
|
+
* would make every server reject the field as unknown.
|
|
140
|
+
* - Without `hint`: fall back to `${prefix}-${UUID}` so the id is unique
|
|
141
|
+
* within the table. Such columns cannot participate in server-driven
|
|
142
|
+
* filtering (the server has no way to know the random suffix). */
|
|
153
143
|
function mintSyntheticId(prefix, hint) {
|
|
154
144
|
if (hint != null) {
|
|
155
145
|
return syntheticColumnId(hint);
|
|
156
146
|
}
|
|
157
147
|
return syntheticColumnId(`${prefix}-${generateUUID()}`);
|
|
158
148
|
}
|
|
159
|
-
/** Resolve an `options` field that may be a static array or an async
|
|
160
|
-
*
|
|
161
|
-
*
|
|
149
|
+
/** Resolve an `options` field that may be a static array or an async loader
|
|
150
|
+
* into the always-loader form the Def expects. The spread drops the
|
|
151
|
+
* readonly modifier the Def's signature lacks. Loaders may return either
|
|
152
|
+
* a Promise or a plain array; `Promise.resolve` accepts both. */
|
|
162
153
|
function normaliseOptionsLoader(options) {
|
|
163
154
|
if (typeof options === 'function') {
|
|
164
|
-
// `options()` may return either a Promise or a plain array - some
|
|
165
|
-
// project helpers (e.g. flowms `ColumnDefRepository.getAccounts()`
|
|
166
|
-
// vs. `getOutboundStatuses()`) settle on different conventions per
|
|
167
|
-
// data source. `Promise.resolve` accepts both so the loader hands
|
|
168
|
-
// the consumer a uniform Promise either way.
|
|
169
155
|
return () => Promise.resolve(options()).then((res) => [...res]);
|
|
170
156
|
}
|
|
171
157
|
const snapshot = [...options];
|
|
@@ -186,11 +172,10 @@ function normaliseOptionsLoader(options) {
|
|
|
186
172
|
* tests can exercise individual factory methods without round-tripping
|
|
187
173
|
* through a full `createTable(...)` call.
|
|
188
174
|
*/
|
|
189
|
-
/** Format a Date or ISO-8601 date string
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* ISO payload (`2026-04-16T09:44:11+01:00`). */
|
|
175
|
+
/** Format a Date or ISO-8601 date string in the browser locale. Used by
|
|
176
|
+
* `col.display` when the column declares `filterValueType: 'Date'`, so
|
|
177
|
+
* raw backend timestamps render as localised date+time rather than the
|
|
178
|
+
* ISO payload. Returns null / empty input unchanged. */
|
|
194
179
|
function formatLocaleDate(value) {
|
|
195
180
|
if (value == null || value === '') {
|
|
196
181
|
return value;
|
|
@@ -327,12 +312,11 @@ export function createColumnFactory() {
|
|
|
327
312
|
? normaliseOptionsLoader(opts.getOptions)
|
|
328
313
|
: undefined;
|
|
329
314
|
// Display columns have no intrinsic kind (the value comes from an
|
|
330
|
-
// arbitrary `value: (row) => ...` thunk)
|
|
331
|
-
//
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
// instead of every column collapsing to the same 150px floor.
|
|
315
|
+
// arbitrary `value: (row) => ...` thunk). When the consumer passes
|
|
316
|
+
// a `filterValueType`, treat it as a hint about the rendered shape
|
|
317
|
+
// and pick the matching per-kind default width; otherwise fall
|
|
318
|
+
// back to the generic 'display' default so columns are visually
|
|
319
|
+
// differentiated instead of all collapsing to the same floor.
|
|
336
320
|
const inferredKind = opts.filterValueType === 'Number'
|
|
337
321
|
? 'number'
|
|
338
322
|
: opts.filterValueType === 'Date'
|
|
@@ -344,13 +328,11 @@ export function createColumnFactory() {
|
|
|
344
328
|
: opts.filterValueType === 'String'
|
|
345
329
|
? 'text'
|
|
346
330
|
: 'display';
|
|
347
|
-
// For Date-typed display columns,
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
//
|
|
352
|
-
// from `accessorFn` to compose the hover tooltip showing both
|
|
353
|
-
// the local-time and UTC representations.
|
|
331
|
+
// For Date-typed display columns, the accessor returns the raw
|
|
332
|
+
// Date / ISO string (filter/sort operates on the raw value) and
|
|
333
|
+
// `getDisplayValue` surfaces the formatted local-time string.
|
|
334
|
+
// The cell renders `getDisplayValue` for visible text and uses
|
|
335
|
+
// the raw value to compose the hover tooltip (local + UTC).
|
|
354
336
|
const rawValue = opts.value;
|
|
355
337
|
const valueAccessor = rawValue;
|
|
356
338
|
const dateDisplayValue = opts.filterValueType === 'Date'
|
|
@@ -372,27 +354,20 @@ export function createColumnFactory() {
|
|
|
372
354
|
accessorFn: valueAccessor,
|
|
373
355
|
getDisplayValue: dateDisplayValue,
|
|
374
356
|
modal: opts.modal,
|
|
375
|
-
// Display columns have no implicit filter type
|
|
376
|
-
//
|
|
377
|
-
// column
|
|
378
|
-
//
|
|
379
|
-
// Default to string-typed filter when the caller did not specify
|
|
380
|
-
// one, so a display column with no explicit `filterValueType`
|
|
381
|
-
// still appears in the filter UI (matches the `DisplayDef →
|
|
382
|
-
// stringFilter (undefined case)` mapping in
|
|
357
|
+
// Display columns have no implicit filter type. Consumers opt
|
|
358
|
+
// in by passing `filterValueType`; default to String so a
|
|
359
|
+
// column without one still appears in the filter UI (matches
|
|
360
|
+
// the `DisplayDef → stringFilter` mapping in
|
|
383
361
|
// `setupDefaultColumnDefs`).
|
|
384
362
|
filterValueType: opts.filterValueType ?? FilterValueType.String,
|
|
385
363
|
getSortingFn: opts.getSortingFn,
|
|
386
364
|
getOptions: normalisedOptions,
|
|
387
|
-
//
|
|
388
|
-
// `makeRow.getValue` can read
|
|
389
|
-
//
|
|
390
|
-
//
|
|
391
|
-
//
|
|
392
|
-
//
|
|
393
|
-
// refresh when a sibling field is edited (visible on the
|
|
394
|
-
// Receipt pod table: Title / UoM did not reload after the
|
|
395
|
-
// SKU select changed `item.receiptLineId`).
|
|
365
|
+
// `reactiveDependencies` is forwarded onto the def so that
|
|
366
|
+
// `makeRow.getValue` can read it synchronously before invoking
|
|
367
|
+
// a (possibly async) accessor. Without this, reads that only
|
|
368
|
+
// happen after `await` inside the consumer's `value` callback
|
|
369
|
+
// are not tracked by the cell's `$derived`, and downstream
|
|
370
|
+
// cells never refresh when a sibling field is edited.
|
|
396
371
|
reactiveDependencies: opts.reactiveDependencies,
|
|
397
372
|
});
|
|
398
373
|
return makeSpec('display', def);
|
|
@@ -407,12 +382,18 @@ export function createColumnFactory() {
|
|
|
407
382
|
...commonProps(opts, 'bubble'),
|
|
408
383
|
accessorFn: opts.value,
|
|
409
384
|
maxBubbles: opts.maxBubbles,
|
|
385
|
+
// `opts.colour` is typed `(row, index, value: TValue) => ...`
|
|
386
|
+
// but `BubbleDef.getColour` expects `value: string` (one bubble's
|
|
387
|
+
// rendered text). The bridge from `TValue` to `string` happens
|
|
388
|
+
// at render time inside the bubble renderer (each value coerces
|
|
389
|
+
// to a string via `String(...)` for display). The cast is
|
|
390
|
+
// load-bearing because TS cannot prove `TValue` is `string`-
|
|
391
|
+
// compatible at this layer.
|
|
410
392
|
getColour: opts.colour,
|
|
411
|
-
// Default to
|
|
412
|
-
//
|
|
413
|
-
//
|
|
414
|
-
// `
|
|
415
|
-
// `filterValueType`, or pass `allowFiltering: false` to opt out.
|
|
393
|
+
// Default to String so bubble columns appear in the filter UI
|
|
394
|
+
// (matches `BubbleDef → stringFilter` in setupDefaultColumnDefs).
|
|
395
|
+
// Caller can override with another `filterValueType` or pass
|
|
396
|
+
// `allowFiltering: false` to opt out.
|
|
416
397
|
filterValueType: opts.filterValueType ?? FilterValueType.String,
|
|
417
398
|
getOptions: normalisedOptions,
|
|
418
399
|
});
|
|
@@ -443,9 +424,9 @@ export function createColumnFactory() {
|
|
|
443
424
|
...commonProps(opts, 'progress'),
|
|
444
425
|
accessorFn: tupleAccessor,
|
|
445
426
|
getColour,
|
|
446
|
-
// Default to
|
|
447
|
-
//
|
|
448
|
-
//
|
|
427
|
+
// Default to Number so progress columns appear in the filter
|
|
428
|
+
// UI (matches `ProgressBarDef → numberFilter` in
|
|
429
|
+
// setupDefaultColumnDefs).
|
|
449
430
|
filterValueType: opts.filterValueType ?? FilterValueType.Number,
|
|
450
431
|
getOptions: progressOptions,
|
|
451
432
|
});
|
|
@@ -473,9 +454,9 @@ export function createColumnFactory() {
|
|
|
473
454
|
const def = new RowSelectionDef({
|
|
474
455
|
isSelectable: opts?.isSelectable ?? (() => true),
|
|
475
456
|
});
|
|
476
|
-
// RowSelection has no public width option
|
|
477
|
-
// default so the column does not
|
|
478
|
-
//
|
|
457
|
+
// RowSelection has no public width option — apply the per-kind
|
|
458
|
+
// default so the column does not fall back to the 48px ColumnDef
|
|
459
|
+
// floor and share equal `1fr` track space with wider columns.
|
|
479
460
|
def.width = KIND_DEFAULT_WIDTHS.rowSelection;
|
|
480
461
|
def.minSize = KIND_DEFAULT_WIDTHS.rowSelection;
|
|
481
462
|
def.widthIsFixed = true;
|
|
@@ -484,8 +465,7 @@ export function createColumnFactory() {
|
|
|
484
465
|
actions(opts) {
|
|
485
466
|
const wrapped = opts.actions.map((action) => {
|
|
486
467
|
// `label` may be a literal string or a `(row) => string |
|
|
487
|
-
// Promise<string>` function
|
|
488
|
-
// `getLabel(item, index)` so wrap accordingly.
|
|
468
|
+
// Promise<string>` function; the Def needs the function form.
|
|
489
469
|
const labelOption = action.label;
|
|
490
470
|
const getLabel = typeof labelOption === 'function' ? (item) => labelOption(item) : () => labelOption;
|
|
491
471
|
return {
|
|
@@ -501,17 +481,16 @@ export function createColumnFactory() {
|
|
|
501
481
|
actions: wrapped,
|
|
502
482
|
isEnabled: isEnabledFn ? (item) => isEnabledFn(item) : undefined,
|
|
503
483
|
});
|
|
504
|
-
// Actions has no public width option
|
|
484
|
+
// Actions has no public width option — apply the per-kind default.
|
|
505
485
|
def.width = KIND_DEFAULT_WIDTHS.actions;
|
|
506
486
|
def.widthIsFixed = true;
|
|
507
487
|
return makeSpec('actions', def);
|
|
508
488
|
},
|
|
509
489
|
expand(opts) {
|
|
510
|
-
// `childRowId` may be
|
|
511
|
-
//
|
|
490
|
+
// `childRowId` may be a function or a key string; the inner
|
|
491
|
+
// `TableContext` expects the function form for
|
|
512
492
|
// `selectionExtractor`. Normalise here so the nested table
|
|
513
|
-
//
|
|
514
|
-
// can safely invoke the extractor.
|
|
493
|
+
// always receives a callable.
|
|
515
494
|
const childRowIdFn = typeof opts.childRowId === 'function'
|
|
516
495
|
? opts.childRowId
|
|
517
496
|
: (inner) => inner[opts.childRowId];
|
|
@@ -524,11 +503,9 @@ export function createColumnFactory() {
|
|
|
524
503
|
headerIcon: opts.headerIcon ?? 'chevron-down',
|
|
525
504
|
innerTableName: scoriaStorageKey(opts.name),
|
|
526
505
|
getInnerColumnDefs: (row, index) => {
|
|
527
|
-
// `childColumns` receives the outer row + index so the
|
|
528
|
-
//
|
|
529
|
-
// drill-downs
|
|
530
|
-
// at the consumer site, so closures that ignore them
|
|
531
|
-
// continue working unchanged.
|
|
506
|
+
// `childColumns` receives the outer row + index so the inner
|
|
507
|
+
// column set may branch per row (e.g. pick-wave-subtype
|
|
508
|
+
// drill-downs). Both args are optional at the consumer site.
|
|
532
509
|
const innerFactory = createColumnFactory();
|
|
533
510
|
const innerSpecs = opts.childColumns(innerFactory, row, index);
|
|
534
511
|
const innerDefs = innerSpecs.map((spec) => unwrapColumnSpec(spec).def);
|
|
@@ -546,7 +523,7 @@ export function createColumnFactory() {
|
|
|
546
523
|
allowCopy: opts.inner?.allowCopy,
|
|
547
524
|
},
|
|
548
525
|
});
|
|
549
|
-
// Expand has no public width option
|
|
526
|
+
// Expand has no public width option — apply the per-kind default.
|
|
550
527
|
def.width = KIND_DEFAULT_WIDTHS.expand;
|
|
551
528
|
def.minSize = KIND_DEFAULT_WIDTHS.expand;
|
|
552
529
|
def.widthIsFixed = true;
|
|
@@ -554,6 +531,12 @@ export function createColumnFactory() {
|
|
|
554
531
|
},
|
|
555
532
|
filterOnly(opts) {
|
|
556
533
|
const def = new FilterOnlyDef({
|
|
534
|
+
// `opts.id` is `K extends string`, which allows free-form
|
|
535
|
+
// dotted-path / camelCase ids (the public surface flowms
|
|
536
|
+
// relies on). The Def's `id` field is the branded
|
|
537
|
+
// `ColumnId<TRow>`; the brand is structural and the cast is
|
|
538
|
+
// safe because `FilterOnlyDef` never narrows back to
|
|
539
|
+
// `keyof TRow` at runtime.
|
|
557
540
|
id: opts.id,
|
|
558
541
|
header: opts.header,
|
|
559
542
|
allowSorting: false,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ColumnDef } from './Types/Columns/Definitions/ColumnDef.svelte.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shape of the per-type filter function set `TableContext` owns. Each
|
|
4
|
+
* concrete `FilterFn<T, ValueType>` narrows its second generic to the
|
|
5
|
+
* value-type it accepts; the registry stays decoupled from that detail
|
|
6
|
+
* by reaching for these via a name lookup and returning `unknown` to the
|
|
7
|
+
* call site, which casts back to `ColumnDef.filterFn` at assignment.
|
|
8
|
+
*/
|
|
9
|
+
export interface LocalFilterFns {
|
|
10
|
+
stringFilter: unknown;
|
|
11
|
+
numberFilter: unknown;
|
|
12
|
+
selectFilter: unknown;
|
|
13
|
+
boolFilter: unknown;
|
|
14
|
+
dateFilter: unknown;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Categorisation used by `setupDefaultColumnDefs`:
|
|
18
|
+
*
|
|
19
|
+
* - `accessor` — column has its own data accessor; the kind dictates the
|
|
20
|
+
* filter (text→string, number→number, etc.). MinSize falls back to the
|
|
21
|
+
* measured header width.
|
|
22
|
+
* - `display` — column has no accessor; the consumer's `filterValueType`
|
|
23
|
+
* on the def picks the filter at runtime via `resolveDisplayFilter`.
|
|
24
|
+
* - `structural` — row-selection / actions / expand / filterOnly etc. No
|
|
25
|
+
* default filter wiring.
|
|
26
|
+
*/
|
|
27
|
+
export type ColumnKindCategory = 'accessor' | 'display' | 'structural';
|
|
28
|
+
export interface ColumnKindEntry {
|
|
29
|
+
readonly category: ColumnKindCategory;
|
|
30
|
+
/**
|
|
31
|
+
* For `accessor`-category kinds: the name of the filter function on
|
|
32
|
+
* `LocalFilterFns` that this kind defaults to.
|
|
33
|
+
*
|
|
34
|
+
* For `display`-category kinds whose filter is fixed (e.g. `bubble`
|
|
35
|
+
* always uses `stringFilter`, `progress` always uses `numberFilter`):
|
|
36
|
+
* same lookup.
|
|
37
|
+
*
|
|
38
|
+
* `undefined` for `structural` kinds and for `display` kinds whose
|
|
39
|
+
* filter follows `def.filterValueType` (handled by
|
|
40
|
+
* `resolveDisplayFilter` instead).
|
|
41
|
+
*/
|
|
42
|
+
readonly defaultFilter?: keyof LocalFilterFns;
|
|
43
|
+
}
|
|
44
|
+
/** Registry literal. Kept in sync with the `ColumnKind` type by the
|
|
45
|
+
* `satisfies Record<ColumnKind, ColumnKindEntry>` check below. */
|
|
46
|
+
export declare const COLUMN_KIND_REGISTRY: {
|
|
47
|
+
readonly text: {
|
|
48
|
+
readonly category: "accessor";
|
|
49
|
+
readonly defaultFilter: "stringFilter";
|
|
50
|
+
};
|
|
51
|
+
readonly number: {
|
|
52
|
+
readonly category: "accessor";
|
|
53
|
+
readonly defaultFilter: "numberFilter";
|
|
54
|
+
};
|
|
55
|
+
readonly checkbox: {
|
|
56
|
+
readonly category: "accessor";
|
|
57
|
+
readonly defaultFilter: "boolFilter";
|
|
58
|
+
};
|
|
59
|
+
readonly date: {
|
|
60
|
+
readonly category: "accessor";
|
|
61
|
+
readonly defaultFilter: "dateFilter";
|
|
62
|
+
};
|
|
63
|
+
readonly select: {
|
|
64
|
+
readonly category: "accessor";
|
|
65
|
+
readonly defaultFilter: "selectFilter";
|
|
66
|
+
};
|
|
67
|
+
readonly query: {
|
|
68
|
+
readonly category: "accessor";
|
|
69
|
+
readonly defaultFilter: "stringFilter";
|
|
70
|
+
};
|
|
71
|
+
readonly display: {
|
|
72
|
+
readonly category: "display";
|
|
73
|
+
};
|
|
74
|
+
readonly bubble: {
|
|
75
|
+
readonly category: "display";
|
|
76
|
+
readonly defaultFilter: "stringFilter";
|
|
77
|
+
};
|
|
78
|
+
readonly progress: {
|
|
79
|
+
readonly category: "display";
|
|
80
|
+
readonly defaultFilter: "numberFilter";
|
|
81
|
+
};
|
|
82
|
+
readonly validity: {
|
|
83
|
+
readonly category: "structural";
|
|
84
|
+
};
|
|
85
|
+
readonly actions: {
|
|
86
|
+
readonly category: "structural";
|
|
87
|
+
};
|
|
88
|
+
readonly rowSelection: {
|
|
89
|
+
readonly category: "structural";
|
|
90
|
+
};
|
|
91
|
+
readonly expand: {
|
|
92
|
+
readonly category: "structural";
|
|
93
|
+
};
|
|
94
|
+
readonly filterOnly: {
|
|
95
|
+
readonly category: "structural";
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Resolve a `display`-category def's filter from its `filterValueType`.
|
|
100
|
+
* Returns `undefined` when the value-type is unrecognised, so callers may
|
|
101
|
+
* fall through to a no-op or default.
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveDisplayFilter<T extends object>(def: ColumnDef<T>, filters: LocalFilterFns): unknown;
|
|
104
|
+
/**
|
|
105
|
+
* Resolve the default filter function for a column given its `kind`.
|
|
106
|
+
* Returns `unknown` (the call site casts back to the def's local
|
|
107
|
+
* `FilterFn<T, ValueType>` shape on assignment). Returns `undefined`
|
|
108
|
+
* when the kind is structural, when the kind is unknown (e.g. a
|
|
109
|
+
* hand-constructed `ColumnDef` outside the factory), or when a
|
|
110
|
+
* `display` column has no recognised `filterValueType`.
|
|
111
|
+
*/
|
|
112
|
+
export declare function resolveDefaultFilter<T extends object>(def: ColumnDef<T>, filters: LocalFilterFns): unknown;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Registry literal. Kept in sync with the `ColumnKind` type by the
|
|
2
|
+
* `satisfies Record<ColumnKind, ColumnKindEntry>` check below. */
|
|
3
|
+
export const COLUMN_KIND_REGISTRY = {
|
|
4
|
+
text: { category: 'accessor', defaultFilter: 'stringFilter' },
|
|
5
|
+
number: { category: 'accessor', defaultFilter: 'numberFilter' },
|
|
6
|
+
checkbox: { category: 'accessor', defaultFilter: 'boolFilter' },
|
|
7
|
+
date: { category: 'accessor', defaultFilter: 'dateFilter' },
|
|
8
|
+
select: { category: 'accessor', defaultFilter: 'selectFilter' },
|
|
9
|
+
query: { category: 'accessor', defaultFilter: 'stringFilter' },
|
|
10
|
+
display: { category: 'display' },
|
|
11
|
+
bubble: { category: 'display', defaultFilter: 'stringFilter' },
|
|
12
|
+
progress: { category: 'display', defaultFilter: 'numberFilter' },
|
|
13
|
+
validity: { category: 'structural' },
|
|
14
|
+
actions: { category: 'structural' },
|
|
15
|
+
rowSelection: { category: 'structural' },
|
|
16
|
+
expand: { category: 'structural' },
|
|
17
|
+
filterOnly: { category: 'structural' },
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Resolve a `display`-category def's filter from its `filterValueType`.
|
|
21
|
+
* Returns `undefined` when the value-type is unrecognised, so callers may
|
|
22
|
+
* fall through to a no-op or default.
|
|
23
|
+
*/
|
|
24
|
+
export function resolveDisplayFilter(def, filters) {
|
|
25
|
+
switch (def.filterValueType) {
|
|
26
|
+
case undefined:
|
|
27
|
+
case 'String':
|
|
28
|
+
return filters.stringFilter;
|
|
29
|
+
case 'Bool':
|
|
30
|
+
return filters.boolFilter;
|
|
31
|
+
case 'Date':
|
|
32
|
+
return filters.dateFilter;
|
|
33
|
+
case 'Number':
|
|
34
|
+
return filters.numberFilter;
|
|
35
|
+
case 'Select':
|
|
36
|
+
return filters.selectFilter;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the default filter function for a column given its `kind`.
|
|
41
|
+
* Returns `unknown` (the call site casts back to the def's local
|
|
42
|
+
* `FilterFn<T, ValueType>` shape on assignment). Returns `undefined`
|
|
43
|
+
* when the kind is structural, when the kind is unknown (e.g. a
|
|
44
|
+
* hand-constructed `ColumnDef` outside the factory), or when a
|
|
45
|
+
* `display` column has no recognised `filterValueType`.
|
|
46
|
+
*/
|
|
47
|
+
export function resolveDefaultFilter(def, filters) {
|
|
48
|
+
if (def.kind == null) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const entry = COLUMN_KIND_REGISTRY[def.kind];
|
|
52
|
+
if (entry.category === 'structural') {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
if (entry.defaultFilter !== undefined) {
|
|
56
|
+
return filters[entry.defaultFilter];
|
|
57
|
+
}
|
|
58
|
+
// Plain `col.display` — filter follows the consumer's filterValueType.
|
|
59
|
+
if (entry.category === 'display') {
|
|
60
|
+
return resolveDisplayFilter(def, filters);
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
<svelte:options runes />
|
|
2
|
-
|
|
3
|
-
<script
|
|
4
|
-
lang="ts"
|
|
5
|
-
generics="T extends object, IdType extends Primitive"
|
|
6
|
-
>
|
|
7
|
-
import { devCatch } from '../../../Helpers/Helpers.svelte.js';
|
|
8
|
-
import { Colour } from '../../../scss/colours.js';
|
|
9
|
-
import { Size } from '../../../Types/Internal/Size.js';
|
|
10
|
-
import { getContext } from 'svelte';
|
|
11
|
-
import Action from '../../Action.svelte';
|
|
12
|
-
import { TableContext } from '../Types/Context/TableContext.svelte.js';
|
|
13
|
-
import type { Primitive } from '../Types/Context/TableInitOptions.js';
|
|
14
|
-
|
|
15
|
-
const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
|
|
16
|
-
|
|
17
|
-
const backgroundColour = $derived.by(() => {
|
|
18
|
-
return tableContext.sortedData.length > 0 && tableContext.allHighlighted
|
|
19
|
-
? Colour['$brand-primary']
|
|
20
|
-
: Colour['$ui-white'];
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<div class="highlight-header">
|
|
25
|
-
<div class="wrapper">
|
|
26
|
-
<Action
|
|
27
|
-
label="Highlight all rows"
|
|
28
|
-
{backgroundColour}
|
|
29
|
-
hoverBackgroundColour={Colour['$brand-dark']}
|
|
30
|
-
size={Size.FillWidth}
|
|
31
|
-
icon={{
|
|
32
|
-
name: 'nothing',
|
|
33
|
-
}}
|
|
34
|
-
onclick={() => {
|
|
35
|
-
tableContext.onHighlightAll()?.catch(devCatch);
|
|
36
|
-
}}
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
1
|
+
<svelte:options runes />
|
|
2
|
+
|
|
3
|
+
<script
|
|
4
|
+
lang="ts"
|
|
5
|
+
generics="T extends object, IdType extends Primitive"
|
|
6
|
+
>
|
|
7
|
+
import { devCatch } from '../../../Helpers/Helpers.svelte.js';
|
|
8
|
+
import { Colour } from '../../../scss/colours.js';
|
|
9
|
+
import { Size } from '../../../Types/Internal/Size.js';
|
|
10
|
+
import { getContext } from 'svelte';
|
|
11
|
+
import Action from '../../Action.svelte';
|
|
12
|
+
import { TableContext } from '../Types/Context/TableContext.svelte.js';
|
|
13
|
+
import type { Primitive } from '../Types/Context/TableInitOptions.js';
|
|
14
|
+
|
|
15
|
+
const tableContext = getContext<TableContext<T, IdType>>(TableContext.identifier);
|
|
16
|
+
|
|
17
|
+
const backgroundColour = $derived.by(() => {
|
|
18
|
+
return tableContext.sortedData.length > 0 && tableContext.allHighlighted
|
|
19
|
+
? Colour['$brand-primary']
|
|
20
|
+
: Colour['$ui-white'];
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div class="highlight-header">
|
|
25
|
+
<div class="wrapper">
|
|
26
|
+
<Action
|
|
27
|
+
label="Highlight all rows"
|
|
28
|
+
{backgroundColour}
|
|
29
|
+
hoverBackgroundColour={Colour['$brand-dark']}
|
|
30
|
+
size={Size.FillWidth}
|
|
31
|
+
icon={{
|
|
32
|
+
name: 'nothing',
|
|
33
|
+
}}
|
|
34
|
+
onclick={() => {
|
|
35
|
+
tableContext.onHighlightAll()?.catch(devCatch);
|
|
36
|
+
}}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
41
|
<style>div.wrapper {
|
|
42
42
|
position: absolute;
|
|
43
43
|
top: 0;
|
|
@@ -47,4 +47,4 @@
|
|
|
47
47
|
display: flex;
|
|
48
48
|
align-items: stretch;
|
|
49
49
|
justify-content: stretch;
|
|
50
|
-
}</style>
|
|
50
|
+
}</style>
|