@lavalogic/scoria 0.37.15 → 0.37.16

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.
@@ -139,7 +139,12 @@ function mintSyntheticId(prefix, hint) {
139
139
  * required by the Def's signature; we spread to drop readonly. */
140
140
  function normaliseOptionsLoader(options) {
141
141
  if (typeof options === 'function') {
142
- return () => options().then((res) => [...res]);
142
+ // `options()` may return either a Promise or a plain array - some
143
+ // project helpers (e.g. flowms `ColumnDefRepository.getAccounts()`
144
+ // vs. `getOutboundStatuses()`) settle on different conventions per
145
+ // data source. `Promise.resolve` accepts both so the loader hands
146
+ // the consumer a uniform Promise either way.
147
+ return () => Promise.resolve(options()).then((res) => [...res]);
143
148
  }
144
149
  const snapshot = [...options];
145
150
  return () => Promise.resolve(snapshot);
@@ -304,6 +309,9 @@ export function createColumnFactory() {
304
309
  },
305
310
  bubble(opts) {
306
311
  const id = mintSyntheticId('bubble', opts.idHint);
312
+ const normalisedOptions = opts.getOptions
313
+ ? normaliseOptionsLoader(opts.getOptions)
314
+ : undefined;
307
315
  const def = new BubbleDef({
308
316
  id,
309
317
  ...commonProps(opts, 'bubble'),
@@ -315,6 +323,7 @@ export function createColumnFactory() {
315
323
  // `setupDefaultColumnDefs`). Caller can override to any other
316
324
  // `filterValueType`, or pass `allowFiltering: false` to opt out.
317
325
  filterValueType: opts.filterValueType ?? FilterValueType.String,
326
+ getOptions: normalisedOptions,
318
327
  });
319
328
  return makeSpec('bubble', def);
320
329
  },
@@ -335,6 +344,9 @@ export function createColumnFactory() {
335
344
  return userColour(row, index, fraction);
336
345
  }
337
346
  : () => 'grey';
347
+ const progressOptions = opts.getOptions
348
+ ? normaliseOptionsLoader(opts.getOptions)
349
+ : undefined;
338
350
  const def = new ProgressBarDef({
339
351
  id,
340
352
  ...commonProps(opts, 'progress'),
@@ -344,6 +356,7 @@ export function createColumnFactory() {
344
356
  // the filter UI by default (matches `ProgressBarDef →
345
357
  // numberFilter` in `setupDefaultColumnDefs`).
346
358
  filterValueType: opts.filterValueType ?? FilterValueType.Number,
359
+ getOptions: progressOptions,
347
360
  });
348
361
  return makeSpec('progress', def);
349
362
  },
@@ -201,6 +201,13 @@ export interface BubbleColumnOptions<TRow extends object, TValue = unknown> exte
201
201
  * where the displayed values are strings but the server filter is a select.
202
202
  */
203
203
  filterValueType?: FilterValueType;
204
+ /**
205
+ * Option list for `filterValueType: 'Select'`. Drives the filter row's
206
+ * dropdown contents. Returning a `Promise` lets consumers fetch
207
+ * options lazily on first read; returning a plain array is also
208
+ * supported (scoria internally wraps it in `Promise.resolve`).
209
+ */
210
+ getOptions?: () => ReadonlyArray<SelectOption<TValue>> | Promise<ReadonlyArray<SelectOption<TValue>>>;
204
211
  }
205
212
  /** Options for `col.progress({ header, value, ... })`. Renders a horizontal
206
213
  * progress bar from a numeric ratio. */
@@ -216,6 +223,11 @@ export interface ProgressColumnOptions<TRow extends object> extends BaseColumnOp
216
223
  * "percent complete" field, in which case set this to `'Number'`.
217
224
  */
218
225
  filterValueType?: FilterValueType;
226
+ /**
227
+ * Option list for `filterValueType: 'Select'`. Drives the filter row's
228
+ * dropdown contents.
229
+ */
230
+ getOptions?: () => ReadonlyArray<SelectOption<unknown>> | Promise<ReadonlyArray<SelectOption<unknown>>>;
219
231
  }
220
232
  /** Options for `col.validity({ header, ... })`. Renders the row's overall
221
233
  * validity indicator and (optionally) opens a modal with the validity
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.15",
4
+ "version": "0.37.16",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },