@marktiderman/genesis-core 2.0.0 → 2.2.0
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/dist/chunk-5JRXF7F7.js +58 -0
- package/dist/chunk-5JRXF7F7.js.map +1 -0
- package/dist/{chunk-IOTHEKO7.js → chunk-7GW3QR63.js} +45 -12
- package/dist/chunk-7GW3QR63.js.map +1 -0
- package/dist/{chunk-3FFBW4XC.js → chunk-N5BKU7PR.js} +49 -4
- package/dist/chunk-N5BKU7PR.js.map +1 -0
- package/dist/{chunk-QPD4FKPC.js → chunk-X6EO3XBB.js} +22 -6
- package/dist/chunk-X6EO3XBB.js.map +1 -0
- package/dist/form-types.d.ts +13 -0
- package/dist/hooks/index.d.ts +59 -3
- package/dist/hooks/index.js +6 -5
- package/dist/hooks/use-resource-form.d.ts +11 -1
- package/dist/hooks/use-resource-form.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -6
- package/dist/provider/index.d.ts +18 -3
- package/dist/provider/index.js +1 -1
- package/dist/resource-view/index.d.ts +80 -33
- package/dist/resource-view/index.js +36 -10
- package/dist/resource-view/index.js.map +1 -1
- package/dist/workspaces.d.ts +130 -0
- package/dist/workspaces.js +3 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +70 -2
- package/dist/chunk-3FFBW4XC.js.map +0 -1
- package/dist/chunk-IOTHEKO7.js.map +0 -1
- package/dist/chunk-QPD4FKPC.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataRow, e as ResourceContract,
|
|
1
|
+
import { D as DataRow, e as ResourceContract, j as RowOf, i as RowAction, F as FieldSchema } from '../types-o8j7g6O6.js';
|
|
2
2
|
import { C as ChipTone, R as Readiness } from '../status-BXRokZD9.js';
|
|
3
3
|
import { V as Viewer, R as ResourceScope } from '../viewer-scope-bthEYSOB.js';
|
|
4
4
|
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-bthEYSOB.js';
|
|
@@ -156,11 +156,20 @@ type RowPicture = {
|
|
|
156
156
|
readonly kind: "initials";
|
|
157
157
|
readonly text: string;
|
|
158
158
|
};
|
|
159
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* The words a view shows. Each one is a step in a chain, and each step overrides the one before:
|
|
161
|
+
* words derived from the resource's name, then the contract's (`noun`, `nounPlural`, `label`, which
|
|
162
|
+
* `genesis introspect` reads from the table comment's `@genesis {...}`), then these, then the
|
|
163
|
+
* screen's own props. Templates take `{noun}`, `{nouns}`, `{count}` and `{total}`.
|
|
164
|
+
*/
|
|
160
165
|
interface ViewCopy {
|
|
161
|
-
/** One row, in a sentence: "brand". */
|
|
166
|
+
/** One row, in a sentence: "brand". Default: the contract's `noun`, then the table name's singular. */
|
|
162
167
|
noun?: string;
|
|
163
|
-
/**
|
|
168
|
+
/**
|
|
169
|
+
* Several: "brands". Default: the contract's `nounPlural`, then the plural of a `noun` the view or
|
|
170
|
+
* contract gives ("entry" → "entries"); with only a noun derived from the name, the contract's
|
|
171
|
+
* label when it reads as a plural ("People"), else the table name.
|
|
172
|
+
*/
|
|
164
173
|
nounPlural?: string;
|
|
165
174
|
/** The page title. Default: the contract's label, then the plural noun in title case. */
|
|
166
175
|
title?: string;
|
|
@@ -169,7 +178,22 @@ interface ViewCopy {
|
|
|
169
178
|
title?: string;
|
|
170
179
|
body?: string;
|
|
171
180
|
};
|
|
181
|
+
/** The create button. Default "New". */
|
|
172
182
|
create?: string;
|
|
183
|
+
/** The form's title. Default "New {noun}" and "Edit {noun}" (the UI catalogue's `form`). */
|
|
184
|
+
form?: {
|
|
185
|
+
createTitle?: string;
|
|
186
|
+
editTitle?: string;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* The count beside the title. Default "{count} {noun}" for one, "{count} {nouns}" for more, and
|
|
190
|
+
* "{count} of {total}" when filtered (the UI catalogue's `page.count*`).
|
|
191
|
+
*/
|
|
192
|
+
count?: {
|
|
193
|
+
one?: string;
|
|
194
|
+
other?: string;
|
|
195
|
+
filtered?: string;
|
|
196
|
+
};
|
|
173
197
|
}
|
|
174
198
|
/** What `defineView` accepts. */
|
|
175
199
|
interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {
|
|
@@ -293,6 +317,10 @@ declare class ViewDefinitionError extends Error {
|
|
|
293
317
|
}
|
|
294
318
|
/** The display a field gets when the view doesn't name one. */
|
|
295
319
|
declare function deriveDisplay(field: FieldSchema): DisplayHint;
|
|
320
|
+
/** A table name's singular, for the default noun. A wrong guess is fixed with `@genesis {"noun"}`. */
|
|
321
|
+
declare function singular(word: string): string;
|
|
322
|
+
/** A noun's plural, the inverse of `singular`: entry → entries, box → boxes, person → people. */
|
|
323
|
+
declare function plural(word: string): string;
|
|
296
324
|
/** A value in words: its entry in `labels`, else the value in title case (`draft` → "Draft"). */
|
|
297
325
|
declare function valueText(labels: Readonly<Record<string, string>> | undefined, value: unknown): string;
|
|
298
326
|
/**
|
|
@@ -348,6 +376,13 @@ type ScopeValue = string | number | boolean | null;
|
|
|
348
376
|
* it is left out; row-level security still decides what the viewer reads.
|
|
349
377
|
*/
|
|
350
378
|
declare function scopeValues(view: Pick<ResourceView<any, any>, "resource" | "definition">, scope: ResourceScope | null | undefined): Readonly<Record<string, ScopeValue>>;
|
|
379
|
+
/**
|
|
380
|
+
* The view's scope keys as a list filter, the way `ResourceView` applies them itself: like
|
|
381
|
+
* {@link scopeValues}, but a list (`{ orgId: ["o1", "o2"] }`, a roll-up across organizations)
|
|
382
|
+
* filters to any of its values, and a key the scope doesn't set is left out instead of throwing.
|
|
383
|
+
* A single value also starts new rows; a list doesn't, so a new row in a roll-up asks which one.
|
|
384
|
+
*/
|
|
385
|
+
declare function scopeFilter(view: Pick<ResourceView<any, any>, "definition">, scope: ResourceScope | null | undefined): Readonly<Record<string, ScopeValue | readonly (string | number)[]>>;
|
|
351
386
|
|
|
352
387
|
/**
|
|
353
388
|
* A screen's `tree` (`<ResourceView tree={{ getParentId }} />`): rows nest under the row
|
|
@@ -442,33 +477,33 @@ declare function cascadeSelection(selected: ReadonlySet<string>, id: string, des
|
|
|
442
477
|
|
|
443
478
|
type AnyView = ResourceView<ResourceContract<any>, any>;
|
|
444
479
|
/** Equality filters for a child list, sent to the server: `{ brand_id: brand.id }`. `null` is "is empty". */
|
|
445
|
-
type
|
|
480
|
+
type RecordViewFilter = Readonly<Record<string, string | number | boolean | null>>;
|
|
446
481
|
interface SectionBase {
|
|
447
|
-
/** Unique in the
|
|
482
|
+
/** Unique in the record view; the screen's route segment or slot key. */
|
|
448
483
|
id: string;
|
|
449
484
|
label: string;
|
|
450
485
|
}
|
|
451
486
|
/** A child list: another view, filtered by this record. */
|
|
452
|
-
interface
|
|
487
|
+
interface RecordViewListSection<Row extends DataRow = DataRow> extends SectionBase {
|
|
453
488
|
list: {
|
|
454
489
|
view: AnyView;
|
|
455
|
-
filter: (row: Row) =>
|
|
490
|
+
filter: (row: Row) => RecordViewFilter;
|
|
456
491
|
};
|
|
457
492
|
settings?: never;
|
|
458
493
|
}
|
|
459
494
|
/** A few of this record's own fields, edited in place. Each must be in `view.writable("edit")`. */
|
|
460
|
-
interface
|
|
495
|
+
interface RecordViewSettingsSection<Name extends string = string> extends SectionBase {
|
|
461
496
|
settings: readonly Name[];
|
|
462
497
|
list?: never;
|
|
463
498
|
}
|
|
464
499
|
/** A section the screen fills itself, through a slot keyed by `id`. */
|
|
465
|
-
interface
|
|
500
|
+
interface RecordViewSlotSection extends SectionBase {
|
|
466
501
|
list?: never;
|
|
467
502
|
settings?: never;
|
|
468
503
|
}
|
|
469
|
-
type
|
|
504
|
+
type RecordViewSection<Row extends DataRow = DataRow, Name extends string = string> = RecordViewListSection<Row> | RecordViewSettingsSection<Name> | RecordViewSlotSection;
|
|
470
505
|
/** One readiness check: "Has a logo", ok or not, and why not. */
|
|
471
|
-
interface
|
|
506
|
+
interface RecordViewReadinessItem {
|
|
472
507
|
/** A stable key for the check; default its position and title. */
|
|
473
508
|
id?: string;
|
|
474
509
|
title: string;
|
|
@@ -477,17 +512,17 @@ interface WorkspaceReadinessItem {
|
|
|
477
512
|
/** Genesis chip tones only. Default `success` when ok, `warning` when not. */
|
|
478
513
|
tone?: ViewTone;
|
|
479
514
|
}
|
|
480
|
-
/** What `
|
|
481
|
-
interface
|
|
515
|
+
/** What `defineRecordView` accepts. */
|
|
516
|
+
interface RecordViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {
|
|
482
517
|
/** The view actions the header offers, by name, in order. Default: every view action. */
|
|
483
518
|
header?: {
|
|
484
519
|
actions?: readonly string[];
|
|
485
520
|
};
|
|
486
|
-
sections: readonly
|
|
487
|
-
readiness?: (row: Row) => readonly
|
|
521
|
+
sections: readonly RecordViewSection<Row, FieldNameOf<C>>[];
|
|
522
|
+
readiness?: (row: Row) => readonly RecordViewReadinessItem[];
|
|
488
523
|
}
|
|
489
524
|
/** A section as a renderer draws it. */
|
|
490
|
-
type
|
|
525
|
+
type ResolvedRecordViewSection = {
|
|
491
526
|
readonly id: string;
|
|
492
527
|
readonly label: string;
|
|
493
528
|
readonly kind: "list";
|
|
@@ -503,7 +538,7 @@ type ResolvedWorkspaceSection = {
|
|
|
503
538
|
readonly kind: "slot";
|
|
504
539
|
};
|
|
505
540
|
/** A header action with whether this row allows it. */
|
|
506
|
-
interface
|
|
541
|
+
interface RecordViewHeaderAction {
|
|
507
542
|
readonly name: string;
|
|
508
543
|
readonly label: string;
|
|
509
544
|
readonly confirm?: string;
|
|
@@ -513,17 +548,17 @@ interface WorkspaceHeaderAction {
|
|
|
513
548
|
readonly allowed: Allowed;
|
|
514
549
|
}
|
|
515
550
|
/** The header for one row: the view's summary plus the header's actions. */
|
|
516
|
-
interface
|
|
551
|
+
interface RecordViewHeader {
|
|
517
552
|
readonly title: string;
|
|
518
553
|
readonly subtitle?: string;
|
|
519
554
|
readonly chips: readonly {
|
|
520
555
|
label: string;
|
|
521
556
|
tone?: ViewTone;
|
|
522
557
|
}[];
|
|
523
|
-
readonly actions: readonly
|
|
558
|
+
readonly actions: readonly RecordViewHeaderAction[];
|
|
524
559
|
}
|
|
525
560
|
/** What a screen and its provider add to the header: they only narrow the view's guards. */
|
|
526
|
-
interface
|
|
561
|
+
interface RecordViewHeaderOptions<Row extends DataRow = DataRow> {
|
|
527
562
|
/** The screen's own rule: `false` hides the action, a sentence refuses it with that reason. */
|
|
528
563
|
can?: (action: string, row: Row) => Allowed | boolean;
|
|
529
564
|
/** Whether anything can run actions here (the screen's `onAction`, or the provider's `runAction`). `false` hides them all. */
|
|
@@ -542,14 +577,14 @@ interface ResolvedReadinessItem {
|
|
|
542
577
|
readonly reason?: string;
|
|
543
578
|
readonly tone: ViewTone;
|
|
544
579
|
}
|
|
545
|
-
/** What `
|
|
546
|
-
interface
|
|
580
|
+
/** What `defineRecordView` returns: frozen, with pure helpers for the renderers. */
|
|
581
|
+
interface RecordView<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> {
|
|
547
582
|
readonly view: ResourceView<C, Row>;
|
|
548
|
-
readonly sections: readonly
|
|
583
|
+
readonly sections: readonly ResolvedRecordViewSection[];
|
|
549
584
|
/** The header's action names, in order. */
|
|
550
585
|
readonly headerActions: readonly string[];
|
|
551
586
|
readonly hasReadiness: boolean;
|
|
552
|
-
section(id: string):
|
|
587
|
+
section(id: string): ResolvedRecordViewSection | undefined;
|
|
553
588
|
/** The record's address for the provider: its key fields (`keyFields`), composite keys encoded. */
|
|
554
589
|
recordId(row: Row): Identifier;
|
|
555
590
|
/**
|
|
@@ -558,7 +593,7 @@ interface ResourceWorkspace<C extends ResourceContract = ResourceContract, Row e
|
|
|
558
593
|
* Without a viewer the guard gets no one, so one that needs the viewer locks them.
|
|
559
594
|
*/
|
|
560
595
|
settingsLocked(row: Row, viewer?: Viewer): string | null;
|
|
561
|
-
headerFor(row: Row, options?:
|
|
596
|
+
headerFor(row: Row, options?: RecordViewHeaderOptions<Row>): RecordViewHeader;
|
|
562
597
|
/**
|
|
563
598
|
* Settings fields as the view's form resolves them (`view.form("edit")`), in the order listed:
|
|
564
599
|
* one section's, or every settings section's without an id.
|
|
@@ -570,7 +605,7 @@ interface ResourceWorkspace<C extends ResourceContract = ResourceContract, Row e
|
|
|
570
605
|
* A list section's filter for this row. In development, a filter with no key, or a value that
|
|
571
606
|
* isn't a string, number, boolean or null, throws: it would show every child row.
|
|
572
607
|
*/
|
|
573
|
-
listFilter(sectionId: string, row: Row):
|
|
608
|
+
listFilter(sectionId: string, row: Row): RecordViewFilter;
|
|
574
609
|
/** The readiness checks for this row, tones resolved; empty without `readiness`. */
|
|
575
610
|
readinessFor(row: Row): readonly ResolvedReadinessItem[];
|
|
576
611
|
/**
|
|
@@ -580,13 +615,13 @@ interface ResourceWorkspace<C extends ResourceContract = ResourceContract, Row e
|
|
|
580
615
|
*/
|
|
581
616
|
readinessSummary(row: Row): Readiness | null;
|
|
582
617
|
}
|
|
583
|
-
/** Whether a value is a
|
|
584
|
-
declare function
|
|
618
|
+
/** Whether a value is a record view (`defineRecordView`'s result). */
|
|
619
|
+
declare function isRecordView(value: unknown): value is RecordView;
|
|
585
620
|
/**
|
|
586
621
|
* One record's screen from its view:
|
|
587
622
|
*
|
|
588
623
|
* ```ts
|
|
589
|
-
* export const
|
|
624
|
+
* export const brandRecordView = defineRecordView(brandsView, {
|
|
590
625
|
* header: { actions: ["archive"] },
|
|
591
626
|
* sections: [
|
|
592
627
|
* { id: "products", label: "Products", list: { view: productsView, filter: (b) => ({ brand_id: b.id }) } },
|
|
@@ -598,8 +633,20 @@ declare function isWorkspace(value: unknown): value is ResourceWorkspace;
|
|
|
598
633
|
* ```
|
|
599
634
|
*
|
|
600
635
|
* Throws {@link ViewDefinitionError} for a settings field the view can't write, a header action
|
|
601
|
-
* the view doesn't define, a repeated section id, or a section that holds another
|
|
636
|
+
* the view doesn't define, a repeated section id, or a section that holds another record view.
|
|
602
637
|
*/
|
|
603
|
-
declare function
|
|
638
|
+
declare function defineRecordView<C extends ResourceContract, Row extends DataRow = RowOf<C>>(view: ResourceView<C, Row>, definition: RecordViewDefinition<C, Row>): RecordView<C, Row>;
|
|
639
|
+
/** @deprecated Renamed `defineRecordView`. */
|
|
640
|
+
declare const defineWorkspace: typeof defineRecordView;
|
|
641
|
+
/** @deprecated Renamed `isRecordView`. */
|
|
642
|
+
declare const isWorkspace: typeof isRecordView;
|
|
643
|
+
/** @deprecated Renamed `RecordView`. */
|
|
644
|
+
type ResourceWorkspace<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> = RecordView<C, Row>;
|
|
645
|
+
/** @deprecated Renamed `RecordViewDefinition`. */
|
|
646
|
+
type WorkspaceDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> = RecordViewDefinition<C, Row>;
|
|
647
|
+
/** @deprecated Renamed `RecordViewSection`. */
|
|
648
|
+
type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = string> = RecordViewSection<Row, Name>;
|
|
649
|
+
/** @deprecated Renamed `RecordViewHeaderAction`. */
|
|
650
|
+
type WorkspaceHeaderAction = RecordViewHeaderAction;
|
|
604
651
|
|
|
605
|
-
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type ResolvedColumn, type ResolvedFormField, type ResolvedReadinessItem, type
|
|
652
|
+
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
@@ -64,6 +64,19 @@ function singular(word) {
|
|
|
64
64
|
if (/(?:ss|us|is)$/.test(lower) || !lower.endsWith("s")) return word;
|
|
65
65
|
return one(last.slice(0, -1));
|
|
66
66
|
}
|
|
67
|
+
var PLURAL_OF = Object.fromEntries(
|
|
68
|
+
Object.entries(SAME_OR_IRREGULAR).map(([many, one]) => [one, many])
|
|
69
|
+
);
|
|
70
|
+
function plural(word) {
|
|
71
|
+
const last = word.split(" ").pop();
|
|
72
|
+
const head = word.slice(0, word.length - last.length);
|
|
73
|
+
const lower = last.toLowerCase();
|
|
74
|
+
const many = (s) => head + s;
|
|
75
|
+
if (PLURAL_OF[lower]) return many(PLURAL_OF[lower]);
|
|
76
|
+
if (/[^aeiou]y$/.test(lower)) return many(`${last.slice(0, -1)}ies`);
|
|
77
|
+
if (/(?:s|x|z|ch|sh)$/.test(lower)) return many(`${last}es`);
|
|
78
|
+
return many(`${last}s`);
|
|
79
|
+
}
|
|
67
80
|
var RESERVED_ACTIONS = /* @__PURE__ */ new Set(["create", "update", "delete"]);
|
|
68
81
|
var own = (record, key) => record && Object.hasOwn(record, key) ? record[key] : void 0;
|
|
69
82
|
function valueText(labels, value) {
|
|
@@ -202,7 +215,8 @@ function defineView(contract, definition = {}) {
|
|
|
202
215
|
const copy = definition.copy ?? {};
|
|
203
216
|
const base = contract.name.split(".").pop() ?? contract.name;
|
|
204
217
|
const noun = copy.noun ?? facts.noun ?? singular(base.replace(/_/g, " "));
|
|
205
|
-
const
|
|
218
|
+
const labelWords = facts.label?.toLowerCase();
|
|
219
|
+
const nounPlural = copy.nounPlural ?? facts.nounPlural ?? (copy.noun || facts.noun ? plural(noun) : labelWords && singular(labelWords) !== labelWords ? labelWords : base.replace(/_/g, " "));
|
|
206
220
|
const title = copy.title ?? facts.label ?? titleCase(nounPlural);
|
|
207
221
|
const labelField = facts.labelField ?? fields.find((f) => /^(name|title|label|full_name|display_name)$/.test(f.name))?.name;
|
|
208
222
|
const label = (name) => own(viewFields, name)?.label ?? byName.get(name)?.label ?? titleCase(name);
|
|
@@ -390,6 +404,16 @@ function scopeValues(view, scope) {
|
|
|
390
404
|
}
|
|
391
405
|
return Object.freeze(out);
|
|
392
406
|
}
|
|
407
|
+
function scopeFilter(view, scope) {
|
|
408
|
+
const out = {};
|
|
409
|
+
if (!scope) return out;
|
|
410
|
+
for (const key of view.definition.scope ?? []) {
|
|
411
|
+
const value = Object.hasOwn(scope, key) ? scope[key] : scope[camel(key)];
|
|
412
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") out[key] = value;
|
|
413
|
+
else if (Array.isArray(value) && value.every((v) => typeof v === "string" || typeof v === "number")) out[key] = value;
|
|
414
|
+
}
|
|
415
|
+
return Object.freeze(out);
|
|
416
|
+
}
|
|
393
417
|
|
|
394
418
|
// src/resource-view/tree.ts
|
|
395
419
|
var rootish = (parent) => parent == null || parent === "";
|
|
@@ -509,7 +533,7 @@ function cascadeSelection(selected, id, descendants) {
|
|
|
509
533
|
return next;
|
|
510
534
|
}
|
|
511
535
|
|
|
512
|
-
// src/resource-view/
|
|
536
|
+
// src/resource-view/record-view.ts
|
|
513
537
|
var WORKSPACE = /* @__PURE__ */ Symbol.for("genesis.resource-workspace");
|
|
514
538
|
var REFUSED = "This isn't allowed.";
|
|
515
539
|
var TONES = /* @__PURE__ */ new Set(["success", "warning", "danger", "info", "muted"]);
|
|
@@ -524,14 +548,14 @@ function unsettable(field) {
|
|
|
524
548
|
if (facts.sensitive) return "is sensitive";
|
|
525
549
|
return null;
|
|
526
550
|
}
|
|
527
|
-
function
|
|
551
|
+
function isRecordView(value) {
|
|
528
552
|
return typeof value === "object" && value !== null && value[WORKSPACE] === true;
|
|
529
553
|
}
|
|
530
554
|
function isView(value) {
|
|
531
555
|
return typeof value === "object" && value !== null && typeof value.columns === "function" && typeof value.resource === "string";
|
|
532
556
|
}
|
|
533
|
-
function
|
|
534
|
-
const where = `${view.resource}
|
|
557
|
+
function defineRecordView(view, definition) {
|
|
558
|
+
const where = `${view.resource} record view`;
|
|
535
559
|
const problems = [];
|
|
536
560
|
const writable = new Set(view.writable("edit"));
|
|
537
561
|
const actionNames = new Set(view.actions().map((a) => a.name));
|
|
@@ -555,8 +579,8 @@ function defineWorkspace(view, definition) {
|
|
|
555
579
|
else ids.add(name);
|
|
556
580
|
const label = `sections.${name ?? i}`;
|
|
557
581
|
if (typeof s.label !== "string" || !s.label.trim()) problems.push(`${label} has no label`);
|
|
558
|
-
if (
|
|
559
|
-
problems.push(`${label} holds a
|
|
582
|
+
if (isRecordView(s) || "sections" in s || "workspace" in s) {
|
|
583
|
+
problems.push(`${label} holds a record view; sections don't nest`);
|
|
560
584
|
return;
|
|
561
585
|
}
|
|
562
586
|
const unknown = Object.keys(s).filter((k) => !SECTION_KEYS.has(k));
|
|
@@ -569,10 +593,10 @@ function defineWorkspace(view, definition) {
|
|
|
569
593
|
}
|
|
570
594
|
if (hasList) {
|
|
571
595
|
const list = s.list;
|
|
572
|
-
if (
|
|
596
|
+
if (isRecordView(list?.view)) problems.push(`${label}.list.view is a record view; sections don't nest`);
|
|
573
597
|
else if (!isView(list?.view)) problems.push(`${label}.list.view isn't a view`);
|
|
574
598
|
if (typeof list?.filter !== "function") problems.push(`${label}.list.filter isn't a function`);
|
|
575
|
-
if (name && isView(list?.view) && !
|
|
599
|
+
if (name && isView(list?.view) && !isRecordView(list.view) && typeof list.filter === "function") {
|
|
576
600
|
filters.set(name, list.filter);
|
|
577
601
|
sections.push(Object.freeze({ id: name, label: s.label, kind: "list", view: list.view }));
|
|
578
602
|
}
|
|
@@ -711,7 +735,9 @@ function defineWorkspace(view, definition) {
|
|
|
711
735
|
readinessSummary
|
|
712
736
|
});
|
|
713
737
|
}
|
|
738
|
+
var defineWorkspace = defineRecordView;
|
|
739
|
+
var isWorkspace = isRecordView;
|
|
714
740
|
|
|
715
|
-
export { ViewDefinitionError, cascadeSelection, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isWorkspace, rowPicture, scopeValues, setExpanded, treeRows, valueText };
|
|
741
|
+
export { ViewDefinitionError, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
716
742
|
//# sourceMappingURL=index.js.map
|
|
717
743
|
//# sourceMappingURL=index.js.map
|