@lavalogic/scoria 0.37.1 → 0.37.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,6 +29,7 @@ import { ExpandDef } from './Types/Columns/Definitions/Expand/ExpandDef.svelte.j
|
|
|
29
29
|
import { FilterOnlyDef } from './Types/Columns/Definitions/FilterOnly/FilterOnlyDef.svelte.js';
|
|
30
30
|
import { RowSelectionDef } from './Types/Columns/Definitions/RowSelection/RowSelectionDef.svelte.js';
|
|
31
31
|
import { FilterValueType } from './Types/Filtering/FilterValueType.js';
|
|
32
|
+
import { ToolbarPosition } from './Types/Toolbar/ToolbarPosition.js';
|
|
32
33
|
import { scoriaStorageKey } from '../../Helpers/Helpers.svelte.js';
|
|
33
34
|
// ─────────────────────────────────────────────────────────────────────────
|
|
34
35
|
// Internal payload carried on every spec
|
|
@@ -215,6 +216,11 @@ export function createColumnFactory() {
|
|
|
215
216
|
...commonProps(opts),
|
|
216
217
|
accessorFn: opts.value,
|
|
217
218
|
modal: opts.modal,
|
|
219
|
+
// Display columns have no implicit filter type (unlike the
|
|
220
|
+
// typed kinds where the factory pins one based on the
|
|
221
|
+
// column kind). Consumers opt in by passing the type they
|
|
222
|
+
// want the filter input rendered as.
|
|
223
|
+
filterValueType: opts.filterValueType,
|
|
218
224
|
});
|
|
219
225
|
return makeSpec('display', def);
|
|
220
226
|
},
|
|
@@ -225,6 +231,7 @@ export function createColumnFactory() {
|
|
|
225
231
|
...commonProps(opts),
|
|
226
232
|
accessorFn: opts.value,
|
|
227
233
|
getColour: opts.colour,
|
|
234
|
+
filterValueType: opts.filterValueType,
|
|
228
235
|
});
|
|
229
236
|
return makeSpec('bubble', def);
|
|
230
237
|
},
|
|
@@ -250,6 +257,7 @@ export function createColumnFactory() {
|
|
|
250
257
|
...commonProps(opts),
|
|
251
258
|
accessorFn: tupleAccessor,
|
|
252
259
|
getColour,
|
|
260
|
+
filterValueType: opts.filterValueType,
|
|
253
261
|
});
|
|
254
262
|
return makeSpec('progress', def);
|
|
255
263
|
},
|
|
@@ -300,12 +308,13 @@ export function createColumnFactory() {
|
|
|
300
308
|
const childRowIdFn = typeof opts.childRowId === 'function'
|
|
301
309
|
? opts.childRowId
|
|
302
310
|
: (inner) => inner[opts.childRowId];
|
|
311
|
+
const userIsEnabled = opts.isEnabled;
|
|
303
312
|
const def = new ExpandDef({
|
|
304
313
|
id: mintSyntheticId('expand'),
|
|
305
314
|
header: opts.header ?? '',
|
|
306
|
-
isEnabled: () => true,
|
|
315
|
+
isEnabled: userIsEnabled ?? (() => true),
|
|
307
316
|
accessorFn: opts.childRows,
|
|
308
|
-
headerIcon: 'chevron-down',
|
|
317
|
+
headerIcon: opts.headerIcon ?? 'chevron-down',
|
|
309
318
|
innerTableName: scoriaStorageKey(opts.name),
|
|
310
319
|
getInnerColumnDefs: () => {
|
|
311
320
|
const innerFactory = createColumnFactory();
|
|
@@ -315,7 +324,14 @@ export function createColumnFactory() {
|
|
|
315
324
|
},
|
|
316
325
|
innerTableOptions: {
|
|
317
326
|
selectionExtractor: childRowIdFn,
|
|
318
|
-
getUserId: () => undefined,
|
|
327
|
+
getUserId: opts.inner?.getUserId ?? (() => undefined),
|
|
328
|
+
toolbar: translateInnerToolbar(opts.inner?.toolbar),
|
|
329
|
+
displayFooter: opts.inner?.showFooter,
|
|
330
|
+
allowAdvancedFiltering: opts.inner?.allowAdvancedFilter,
|
|
331
|
+
allowQuickFiltering: opts.inner?.allowQuickFilter,
|
|
332
|
+
allowColumnReordering: opts.inner?.allowReorder,
|
|
333
|
+
enableResize: opts.inner?.allowResize,
|
|
334
|
+
allowCopy: opts.inner?.allowCopy,
|
|
319
335
|
},
|
|
320
336
|
});
|
|
321
337
|
return makeSpec('expand', def);
|
|
@@ -337,3 +353,25 @@ export function createColumnFactory() {
|
|
|
337
353
|
};
|
|
338
354
|
return factory;
|
|
339
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Translate the public string-literal `inner.toolbar` option on
|
|
358
|
+
* `ExpandColumnOptions` into the internal `ToolbarPosition` enum used by
|
|
359
|
+
* `TableInitOptions`. Mirrors the outer-table translator in
|
|
360
|
+
* `createTable.svelte.ts`; kept local to the factory so the public API
|
|
361
|
+
* stays free of the enum.
|
|
362
|
+
*/
|
|
363
|
+
function translateInnerToolbar(toolbar) {
|
|
364
|
+
if (!toolbar) {
|
|
365
|
+
return undefined;
|
|
366
|
+
}
|
|
367
|
+
switch (toolbar) {
|
|
368
|
+
case 'top':
|
|
369
|
+
return ToolbarPosition.Top;
|
|
370
|
+
case 'right':
|
|
371
|
+
return ToolbarPosition.Right;
|
|
372
|
+
case 'left':
|
|
373
|
+
return ToolbarPosition.Left;
|
|
374
|
+
case 'none':
|
|
375
|
+
return ToolbarPosition.None;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { CustomFilter } from '../Filtering/CustomFilter.js';
|
|
|
4
4
|
import type { FilterValueType } from '../Filtering/FilterValueType.js';
|
|
5
5
|
import type { Primitive } from '../Context/TableInitOptions.js';
|
|
6
6
|
import type { BubbleColour } from '../../../BubbleColour.js';
|
|
7
|
+
import type { IconProps } from '../../../IconProps.js';
|
|
7
8
|
import type { SelectOption } from '../../../../Types/Internal/SelectOption.js';
|
|
8
9
|
import type { ValidationFn } from '../Columns/Definitions/ValidationFn.js';
|
|
9
10
|
import type { ColourSet } from '../../../../scss/colours.js';
|
|
@@ -132,6 +133,21 @@ export interface DisplayColumnOptions<TRow extends object, TValue = unknown> ext
|
|
|
132
133
|
/** Override the auto-generated id. Rare; only useful when the consumer
|
|
133
134
|
* needs a stable id for preset persistence or test selectors. */
|
|
134
135
|
idHint?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Filter-input shape for this column. Display columns have no
|
|
138
|
+
* implicit filter type (unlike `col.number` / `col.date` etc.
|
|
139
|
+
* which derive theirs from the column kind). Set this when the
|
|
140
|
+
* displayed `value` is a computed string but the underlying field
|
|
141
|
+
* the server filters on is a number / date / select - this keeps
|
|
142
|
+
* the typed filter UI (e.g. number ranges, date pickers) for
|
|
143
|
+
* foreign-key columns that show a human-readable name.
|
|
144
|
+
*
|
|
145
|
+
* When omitted, the filter row renders a generic string input.
|
|
146
|
+
*
|
|
147
|
+
* The filter targets the column id (use `idHint` to set a stable
|
|
148
|
+
* id matching the server field name).
|
|
149
|
+
*/
|
|
150
|
+
filterValueType?: FilterValueType;
|
|
135
151
|
}
|
|
136
152
|
/** Options for `col.bubble({ header, value, colour, ... })`. Renders one or
|
|
137
153
|
* more coloured pill bubbles per row. */
|
|
@@ -143,6 +159,12 @@ export interface BubbleColumnOptions<TRow extends object, TValue = unknown> exte
|
|
|
143
159
|
* so multi-bubble cells can colour each independently. */
|
|
144
160
|
colour: (row: TRow, index: number, value: TValue) => BubbleColour | Promise<BubbleColour>;
|
|
145
161
|
idHint?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Filter-input shape for this column. See `DisplayColumnOptions.filterValueType`
|
|
164
|
+
* - same semantics, applied to bubble cells. Common case: a tag-bubble column
|
|
165
|
+
* where the displayed values are strings but the server filter is a select.
|
|
166
|
+
*/
|
|
167
|
+
filterValueType?: FilterValueType;
|
|
146
168
|
}
|
|
147
169
|
/** Options for `col.progress({ header, value, ... })`. Renders a horizontal
|
|
148
170
|
* progress bar from a numeric ratio. */
|
|
@@ -152,6 +174,12 @@ export interface ProgressColumnOptions<TRow extends object> extends BaseColumnOp
|
|
|
152
174
|
/** Optional colour override. Defaults to scoria's progress colour ramp. */
|
|
153
175
|
colour?: (row: TRow, index: number, fraction: number) => ColourSet | Promise<ColourSet>;
|
|
154
176
|
idHint?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Filter-input shape for this column. See `DisplayColumnOptions.filterValueType`
|
|
179
|
+
* - same semantics. Progress columns most commonly filter on a numeric
|
|
180
|
+
* "percent complete" field, in which case set this to `'Number'`.
|
|
181
|
+
*/
|
|
182
|
+
filterValueType?: FilterValueType;
|
|
155
183
|
}
|
|
156
184
|
/** Options for `col.validity({ header, ... })`. Renders the row's overall
|
|
157
185
|
* validity indicator and (optionally) opens a modal with the validity
|
|
@@ -197,6 +225,43 @@ export interface RowAction<TRow extends object> {
|
|
|
197
225
|
* this specific action when both are set. Async supported. */
|
|
198
226
|
isEnabled?: (row: TRow) => boolean | Promise<boolean>;
|
|
199
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Layout / behaviour options for the inner Table mounted inside an expanded
|
|
230
|
+
* row. Each field maps 1:1 onto the matching `CreateTableOptions` field that
|
|
231
|
+
* configures an outer Table; supply only the ones that should differ from the
|
|
232
|
+
* scoria defaults.
|
|
233
|
+
*
|
|
234
|
+
* Common per-table overrides flowms (and most consumers) need:
|
|
235
|
+
* - `toolbar: 'none'` to hide the toolbar on inner detail tables
|
|
236
|
+
* - `showFooter: false` to hide pagination on inner tables backed by an
|
|
237
|
+
* already-bounded child collection
|
|
238
|
+
* - `getUserId` so inner-table preset persistence keys are namespaced per user
|
|
239
|
+
*/
|
|
240
|
+
export interface ExpandInnerTableOptions {
|
|
241
|
+
/** Inner-table toolbar position. Defaults to scoria's outer-table default
|
|
242
|
+
* (`'right'`). Pass `'none'` to hide the toolbar entirely. */
|
|
243
|
+
toolbar?: 'top' | 'right' | 'left' | 'none';
|
|
244
|
+
/** Whether the inner table's pagination footer renders. Defaults to true. */
|
|
245
|
+
showFooter?: boolean;
|
|
246
|
+
/** Whether the inner table's advanced filter panel renders. Defaults to
|
|
247
|
+
* the outer Table's default (`true`). */
|
|
248
|
+
allowAdvancedFilter?: boolean;
|
|
249
|
+
/** Whether the inner table's quick-filter input row renders. Defaults to
|
|
250
|
+
* the outer Table's default (`true`). */
|
|
251
|
+
allowQuickFilter?: boolean;
|
|
252
|
+
/** Whether the inner table allows column reordering. Defaults to scoria's
|
|
253
|
+
* outer-table default (`true`). */
|
|
254
|
+
allowReorder?: boolean;
|
|
255
|
+
/** Whether the inner table allows column resizing. Defaults to scoria's
|
|
256
|
+
* outer-table default (`true`). */
|
|
257
|
+
allowResize?: boolean;
|
|
258
|
+
/** Whether the inner table allows clipboard copy. Defaults to scoria's
|
|
259
|
+
* outer-table default (`true`). */
|
|
260
|
+
allowCopy?: boolean;
|
|
261
|
+
/** Returns the current user id for the inner table's persistence
|
|
262
|
+
* namespacing. Defaults to `() => undefined` (no per-user keying). */
|
|
263
|
+
getUserId?: () => string | undefined;
|
|
264
|
+
}
|
|
200
265
|
/** Options for `col.expand({ name, childRows, childRowId, childColumns })`.
|
|
201
266
|
* Each row exposes an expand affordance that mounts an inner Table over
|
|
202
267
|
* the inner row collection. */
|
|
@@ -216,6 +281,26 @@ export interface ExpandColumnOptions<TRow extends object, TInner extends object,
|
|
|
216
281
|
/** Inner column declarations. Builder closure receives a typed
|
|
217
282
|
* `ColumnFactory<TInner>`. */
|
|
218
283
|
childColumns: (col: ColumnFactory<TInner>) => ReadonlyArray<ColumnSpec<TInner>>;
|
|
284
|
+
/**
|
|
285
|
+
* Icon rendered on the per-row expand toggle button. Defaults to
|
|
286
|
+
* `'chevron-down'`. Useful when the parent context needs a richer
|
|
287
|
+
* visual cue (e.g. `'list'` for an order-lines drill-down).
|
|
288
|
+
*/
|
|
289
|
+
headerIcon?: IconProps['name'];
|
|
290
|
+
/**
|
|
291
|
+
* Per-row predicate for whether the expand affordance is enabled.
|
|
292
|
+
* When the predicate resolves to `false`, the toggle is rendered
|
|
293
|
+
* disabled (or hidden) so users cannot expand rows that have no
|
|
294
|
+
* inner content. Async supported. Defaults to `() => true`.
|
|
295
|
+
*/
|
|
296
|
+
isEnabled?: (row: TRow, index: number) => boolean | Promise<boolean>;
|
|
297
|
+
/**
|
|
298
|
+
* Inner-table configuration. Each field maps 1:1 onto the equivalent
|
|
299
|
+
* `CreateTableOptions` field that configures an outer Table; supply
|
|
300
|
+
* only the ones that should differ from scoria's outer-table defaults.
|
|
301
|
+
* See {@link ExpandInnerTableOptions}.
|
|
302
|
+
*/
|
|
303
|
+
inner?: ExpandInnerTableOptions;
|
|
219
304
|
}
|
|
220
305
|
/** Options for `col.filterOnly({ id, header, ... })`. Renders in the filter
|
|
221
306
|
* panel only; does not produce a body cell. Useful for surfacing a
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export type { AnyEditEvent } from './AnyEditEvent.js';
|
|
9
9
|
export type { BaseColumnOptions } from './BaseColumnOptions.js';
|
|
10
10
|
export type { ColumnFactory } from './ColumnFactory.js';
|
|
11
|
-
export type { ActionsColumnOptions, BubbleColumnOptions, CheckboxColumnOptions, DateColumnOptions, DisplayColumnOptions, DisplayModalProps, ExpandColumnOptions, FilterOnlyColumnOptions, NumberColumnOptions, ProgressColumnOptions, QueryColumnOptions, RowAction, RowSelectionColumnOptions, SelectColumnOptions, TextColumnOptions, ValidityColumnOptions, } from './ColumnOptions.js';
|
|
11
|
+
export type { ActionsColumnOptions, BubbleColumnOptions, CheckboxColumnOptions, DateColumnOptions, DisplayColumnOptions, DisplayModalProps, ExpandColumnOptions, ExpandInnerTableOptions, FilterOnlyColumnOptions, NumberColumnOptions, ProgressColumnOptions, QueryColumnOptions, RowAction, RowSelectionColumnOptions, SelectColumnOptions, TextColumnOptions, ValidityColumnOptions, } from './ColumnOptions.js';
|
|
12
12
|
export type { ColumnKind, ColumnSpec } from './ColumnSpec.js';
|
|
13
13
|
export type { CreateTableOptions } from './CreateTableOptions.js';
|
|
14
14
|
export type { BooleanKeyOf, DateKeyOf, LiteralRowIdKey, NumberKeyOf, StringKeyOf, } from './KeyConstraints.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -104,7 +104,7 @@ export type { TabGroupButtonProps } from './Components/TabGroupButtonProps.js';
|
|
|
104
104
|
export { default as Table, type TableProps } from './Components/Table/Table.svelte';
|
|
105
105
|
export { createTable, customRows, localRows, remoteRows, } from './Components/Table/createTable.svelte.js';
|
|
106
106
|
export type { ColumnSpecInternals } from './Components/Table/ColumnFactory.svelte.js';
|
|
107
|
-
export type { ActionsColumnOptions, AnyEditEvent, BaseColumnOptions, BooleanKeyOf, BubbleColumnOptions, CheckboxColumnOptions, ClipboardApi, ColumnFactory as TableColumnFactory, ColumnKind, ColumnSpec, ColumnsApi, CreateTableOptions, CustomRowSource, DateColumnOptions, DateKeyOf, DisplayColumnOptions, DisplayModalProps, ExpandColumnOptions, FilterOnlyColumnOptions, FilteringApi, FocusApi, LiteralRowIdKey, LocalRowSource, ModalApi, NumberColumnOptions, NumberKeyOf, PaginationApi, PreferencesApi, ProgressColumnOptions, QueryColumnOptions, RemoteRowSource, RowAction, RowFetchRequest, RowFetchResponse, RowSelectionColumnOptions, RowSource, SavedPreset, SelectColumnOptions, SelectionApi, SelectionOptions, SortingApi, StringKeyOf, Table as TableInstance, TableInitialState, TablePersistence, TablePersistenceObject, TableStorageAdapter, TextColumnOptions, ValidityColumnOptions, } from './Components/Table/Types/Public/index.js';
|
|
107
|
+
export type { ActionsColumnOptions, AnyEditEvent, BaseColumnOptions, BooleanKeyOf, BubbleColumnOptions, CheckboxColumnOptions, ClipboardApi, ColumnFactory as TableColumnFactory, ColumnKind, ColumnSpec, ColumnsApi, CreateTableOptions, CustomRowSource, DateColumnOptions, DateKeyOf, DisplayColumnOptions, DisplayModalProps, ExpandColumnOptions, ExpandInnerTableOptions, FilterOnlyColumnOptions, FilteringApi, FocusApi, LiteralRowIdKey, LocalRowSource, ModalApi, NumberColumnOptions, NumberKeyOf, PaginationApi, PreferencesApi, ProgressColumnOptions, QueryColumnOptions, RemoteRowSource, RowAction, RowFetchRequest, RowFetchResponse, RowSelectionColumnOptions, RowSource, SavedPreset, SelectColumnOptions, SelectionApi, SelectionOptions, SortingApi, StringKeyOf, Table as TableInstance, TableInitialState, TablePersistence, TablePersistenceObject, TableStorageAdapter, TextColumnOptions, ValidityColumnOptions, } from './Components/Table/Types/Public/index.js';
|
|
108
108
|
export { type CellCoordinates } from './Components/Table/Types/Coordinates/CellCoordinates.js';
|
|
109
109
|
export { type ColumnPinningState } from './Components/Table/Types/Columns/ColumnPinningState.js';
|
|
110
110
|
export { type ColumnSizingState } from './Components/Table/Types/Columns/ColumnSizingState.js';
|