@lavalogic/scoria 0.37.2 → 0.37.4

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
@@ -307,12 +308,13 @@ export function createColumnFactory() {
307
308
  const childRowIdFn = typeof opts.childRowId === 'function'
308
309
  ? opts.childRowId
309
310
  : (inner) => inner[opts.childRowId];
311
+ const userIsEnabled = opts.isEnabled;
310
312
  const def = new ExpandDef({
311
313
  id: mintSyntheticId('expand'),
312
314
  header: opts.header ?? '',
313
- isEnabled: () => true,
315
+ isEnabled: userIsEnabled ?? (() => true),
314
316
  accessorFn: opts.childRows,
315
- headerIcon: 'chevron-down',
317
+ headerIcon: opts.headerIcon ?? 'chevron-down',
316
318
  innerTableName: scoriaStorageKey(opts.name),
317
319
  getInnerColumnDefs: () => {
318
320
  const innerFactory = createColumnFactory();
@@ -322,7 +324,14 @@ export function createColumnFactory() {
322
324
  },
323
325
  innerTableOptions: {
324
326
  selectionExtractor: childRowIdFn,
325
- 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,
326
335
  },
327
336
  });
328
337
  return makeSpec('expand', def);
@@ -344,3 +353,25 @@ export function createColumnFactory() {
344
353
  };
345
354
  return factory;
346
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
+ }
@@ -31,5 +31,5 @@ export interface ColumnFactory<TRow extends object> {
31
31
  rowSelection(options?: RowSelectionColumnOptions<TRow>): ColumnSpec<TRow, 'rowSelection'>;
32
32
  actions(options: ActionsColumnOptions<TRow>): ColumnSpec<TRow, 'actions'>;
33
33
  expand<TInner extends object, TInnerId extends Primitive = string>(options: ExpandColumnOptions<TRow, TInner, TInnerId>): ColumnSpec<TRow, 'expand'>;
34
- filterOnly<K extends keyof TRow & string, TValue = TRow[K]>(options: FilterOnlyColumnOptions<TRow, K, TValue>): ColumnSpec<TRow, 'filterOnly'>;
34
+ filterOnly<K extends string = string, TValue = K extends keyof TRow & string ? TRow[K] : unknown>(options: FilterOnlyColumnOptions<TRow, K, TValue>): ColumnSpec<TRow, 'filterOnly'>;
35
35
  }
@@ -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';
@@ -224,6 +225,43 @@ export interface RowAction<TRow extends object> {
224
225
  * this specific action when both are set. Async supported. */
225
226
  isEnabled?: (row: TRow) => boolean | Promise<boolean>;
226
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
+ }
227
265
  /** Options for `col.expand({ name, childRows, childRowId, childColumns })`.
228
266
  * Each row exposes an expand affordance that mounts an inner Table over
229
267
  * the inner row collection. */
@@ -243,11 +281,40 @@ export interface ExpandColumnOptions<TRow extends object, TInner extends object,
243
281
  /** Inner column declarations. Builder closure receives a typed
244
282
  * `ColumnFactory<TInner>`. */
245
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;
246
304
  }
247
- /** Options for `col.filterOnly({ id, header, ... })`. Renders in the filter
248
- * panel only; does not produce a body cell. Useful for surfacing a
249
- * filterable field that should not occupy a column. */
250
- export interface FilterOnlyColumnOptions<TRow extends object, K extends keyof TRow & string, TValue = TRow[K]> extends Omit<BaseColumnOptions, 'allowSorting' | 'resizable' | 'minWidth' | 'width'> {
305
+ /**
306
+ * Options for `col.filterOnly({ id, header, ... })`. Renders in the filter
307
+ * panel only; does not produce a body cell. Useful for surfacing a
308
+ * filterable field that should not occupy a column.
309
+ *
310
+ * `K` defaults to `string` so consumers can pass nested-path / server-only
311
+ * filter ids (e.g. `'orderLines.products.productTags.value'`) that are not
312
+ * direct keys of `TRow`. When `K` does narrow to a `keyof TRow & string`,
313
+ * `TValue` infers the corresponding row value type for the `customFilter`
314
+ * predicate; otherwise `TValue` defaults to `unknown`, which is the right
315
+ * shape for remote-only filters where the server resolves the field.
316
+ */
317
+ export interface FilterOnlyColumnOptions<TRow extends object, K extends string = string, TValue = K extends keyof TRow & string ? TRow[K] : unknown> extends Omit<BaseColumnOptions, 'allowSorting' | 'resizable' | 'minWidth' | 'width'> {
251
318
  id: K;
252
319
  /** Filter value kind; drives which filter input is rendered. */
253
320
  filterValueType: FilterValueType;
@@ -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';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.37.2",
4
+ "version": "0.37.4",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },