@lavalogic/scoria 0.37.15 → 0.37.17

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.
@@ -410,7 +410,10 @@
410
410
  </div>
411
411
  {/if}
412
412
 
413
- <span class="column-label">
413
+ <span
414
+ class="column-label"
415
+ title={typeof columnDef.header === 'string' ? columnDef.header : columnDef.id}
416
+ >
414
417
  {#if typeof columnDef.header === 'function'}
415
418
  <!-- FIXME this needs testing -->
416
419
  {@render columnDef.header()}
@@ -521,9 +524,15 @@ li.single-column:not(.anchor):last-of-type {
521
524
  .column-label {
522
525
  flex: 1 1 auto;
523
526
  min-width: 0;
527
+ font-size: 1.125rem;
528
+ line-height: 1.2;
529
+ display: -webkit-box;
530
+ -webkit-line-clamp: 2;
531
+ -webkit-box-orient: vertical;
524
532
  overflow: hidden;
525
533
  text-overflow: ellipsis;
526
- white-space: nowrap;
534
+ word-break: normal;
535
+ overflow-wrap: anywhere;
527
536
  }
528
537
 
529
538
  .reorder-buttons {
@@ -127,19 +127,38 @@ function commonProps(opts, kind) {
127
127
  filterGroup: opts.filterGroup,
128
128
  };
129
129
  }
130
- /** Generate a synthetic id for a column kind that does not take an `id`
131
- * from the caller. Mirrors the existing pattern used by `ActionsDef` and
132
- * `RowSelectionDef`. The returned value is the `SyntheticColumnId` brand. */
130
+ /** Generate a column id for a kind whose option type does not require
131
+ * an `id` from the caller.
132
+ *
133
+ * - When `hint` is provided, use it as the id verbatim. This is the
134
+ * server-side-filtering contract: callers who pass an `idHint` are
135
+ * indicating that the column maps to a real backend field (so the
136
+ * filter row's `id` flows through `createRemoteRowSource` as the
137
+ * query-string key the server expects). Adding a synthetic prefix
138
+ * here would mean every `col.display({ idHint: 'outboundType_id' })`
139
+ * serialised as `display-outboundType_id` and the server rejected
140
+ * the request with "field does not exist".
141
+ * - When no `hint` is provided, fall back to `${prefix}-${UUID}` so
142
+ * the id is still unique within the table. Such columns cannot
143
+ * participate in server-driven filtering anyway (the server would
144
+ * not know the random suffix). */
133
145
  function mintSyntheticId(prefix, hint) {
134
- const suffix = hint ?? generateUUID();
135
- return syntheticColumnId(`${prefix}-${suffix}`);
146
+ if (hint != null) {
147
+ return syntheticColumnId(hint);
148
+ }
149
+ return syntheticColumnId(`${prefix}-${generateUUID()}`);
136
150
  }
137
151
  /** Resolve an `options` field that may be a static array or an async
138
152
  * loader into the always-loader form the Def expects. Mutable arrays are
139
153
  * required by the Def's signature; we spread to drop readonly. */
140
154
  function normaliseOptionsLoader(options) {
141
155
  if (typeof options === 'function') {
142
- return () => options().then((res) => [...res]);
156
+ // `options()` may return either a Promise or a plain array - some
157
+ // project helpers (e.g. flowms `ColumnDefRepository.getAccounts()`
158
+ // vs. `getOutboundStatuses()`) settle on different conventions per
159
+ // data source. `Promise.resolve` accepts both so the loader hands
160
+ // the consumer a uniform Promise either way.
161
+ return () => Promise.resolve(options()).then((res) => [...res]);
143
162
  }
144
163
  const snapshot = [...options];
145
164
  return () => Promise.resolve(snapshot);
@@ -304,6 +323,9 @@ export function createColumnFactory() {
304
323
  },
305
324
  bubble(opts) {
306
325
  const id = mintSyntheticId('bubble', opts.idHint);
326
+ const normalisedOptions = opts.getOptions
327
+ ? normaliseOptionsLoader(opts.getOptions)
328
+ : undefined;
307
329
  const def = new BubbleDef({
308
330
  id,
309
331
  ...commonProps(opts, 'bubble'),
@@ -315,6 +337,7 @@ export function createColumnFactory() {
315
337
  // `setupDefaultColumnDefs`). Caller can override to any other
316
338
  // `filterValueType`, or pass `allowFiltering: false` to opt out.
317
339
  filterValueType: opts.filterValueType ?? FilterValueType.String,
340
+ getOptions: normalisedOptions,
318
341
  });
319
342
  return makeSpec('bubble', def);
320
343
  },
@@ -335,6 +358,9 @@ export function createColumnFactory() {
335
358
  return userColour(row, index, fraction);
336
359
  }
337
360
  : () => 'grey';
361
+ const progressOptions = opts.getOptions
362
+ ? normaliseOptionsLoader(opts.getOptions)
363
+ : undefined;
338
364
  const def = new ProgressBarDef({
339
365
  id,
340
366
  ...commonProps(opts, 'progress'),
@@ -344,6 +370,7 @@ export function createColumnFactory() {
344
370
  // the filter UI by default (matches `ProgressBarDef →
345
371
  // numberFilter` in `setupDefaultColumnDefs`).
346
372
  filterValueType: opts.filterValueType ?? FilterValueType.Number,
373
+ getOptions: progressOptions,
347
374
  });
348
375
  return makeSpec('progress', def);
349
376
  },
@@ -160,4 +160,6 @@
160
160
  display: flex;
161
161
  flex-flow: column nowrap;
162
162
  background-color: #ffffff;
163
+ padding: 0 1.25rem;
164
+ box-sizing: border-box;
163
165
  }</style>
@@ -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.17",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },