@masterteam/components 0.0.300 → 0.0.302

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masterteam/components",
3
- "version": "0.0.300",
3
+ "version": "0.0.302",
4
4
  "publishConfig": {
5
5
  "directory": "../../../dist/masterteam/components",
6
6
  "linkDirectory": true,
@@ -1,10 +1,11 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { AfterViewInit, InjectionToken, Type, Provider, OnInit } from '@angular/core';
2
+ import { AfterViewInit, OnInit, InjectionToken, Type, Provider } from '@angular/core';
3
3
  import { LookupMatrixFieldConfig, LookupOptionItemConfig, LookupMatrixCellConfig, SchemaConnectionFieldRuntimeContext, SchedulePredecessorFieldRuntimeContext, EntityListFieldRuntimeContext, ScheduleItemSelectorFieldRuntimeContext, LookupCheckListPropertyConfig, LookupModuleCheckListFieldRuntimeContext } from '@masterteam/components';
4
- import { ControlValueAccessor, NgControl, Validators } from '@angular/forms';
4
+ import { ControlValueAccessor, NgControl, AbstractControl, Validators } from '@angular/forms';
5
5
  import { HttpContext } from '@angular/common/http';
6
6
  import { ColumnDef, TableAction } from '@masterteam/components/table';
7
- import { EntityData } from '@masterteam/components/entities';
7
+ import * as _masterteam_components_entities from '@masterteam/components/entities';
8
+ import { EntityData, EntityListLocalSchemaField, EntityListLocalCell } from '@masterteam/components/entities';
8
9
 
9
10
  declare class LookupMatrixField implements AfterViewInit {
10
11
  readonly config: _angular_core.InputSignal<LookupMatrixFieldConfig>;
@@ -104,10 +105,15 @@ interface SourceLevelState {
104
105
  options: any[];
105
106
  loading: boolean;
106
107
  }
107
- declare class SchemaConnectionField implements ControlValueAccessor {
108
+ declare class SchemaConnectionField implements ControlValueAccessor, OnInit {
108
109
  readonly label: _angular_core.InputSignal<string>;
109
110
  readonly placeholder: _angular_core.InputSignal<string>;
110
111
  readonly readonly: _angular_core.InputSignal<boolean>;
112
+ /**
113
+ * Kept for direct-host API compatibility. Dynamic/client forms do not bind
114
+ * it; runtime requiredness is defined per source by
115
+ * `configuration.sourceLevels[].isOptional`.
116
+ */
111
117
  readonly required: _angular_core.InputSignal<boolean>;
112
118
  readonly filter: _angular_core.InputSignal<boolean>;
113
119
  /**
@@ -137,17 +143,15 @@ declare class SchemaConnectionField implements ControlValueAccessor {
137
143
  onTouched: () => void;
138
144
  onModelChange: (value: ConnectionPayload | null) => void;
139
145
  /**
140
- * Required-validation for a connection: emptiness is decided by the selected
141
- * `sources`, not by the value being null. The runtime loads an unselected
142
- * connection as `{ levelId, sources: [] }` — a non-null object that Angular's
143
- * stock `Validators.required` accepts — so a plain required check would let an
144
- * empty connection pass and the form submit. Mirrors {@link syncValue}, which
145
- * collapses a source-less selection to `null`.
146
+ * Every source whose `isOptional` is false must have at least one selected
147
+ * record. The field-level `isRequired` flag is intentionally ignored because
148
+ * one Connection property can mix optional and required source levels.
146
149
  */
147
- private readonly connectionRequiredValidator;
150
+ private readonly requiredSourcesValidator;
148
151
  ngControl: NgControl | null;
149
152
  private http;
150
153
  private destroyRef;
154
+ private readonly cdr;
151
155
  private transloco;
152
156
  /** Active UI language, kept reactive so source labels re-resolve on switch. */
153
157
  private readonly activeLang;
@@ -178,12 +182,52 @@ declare class SchemaConnectionField implements ControlValueAccessor {
178
182
  */
179
183
  readonly dropdownWidth: _angular_core.Signal<string>;
180
184
  constructor();
185
+ /**
186
+ * Repaint when the control's own state changes.
187
+ *
188
+ * `touched` and validity are plain `AbstractControl` state, not signals, and
189
+ * this component is `OnPush` — so a host that calls `markAllAsTouched()` on a
190
+ * failed submit marked the connection invalid and nothing re-rendered. The
191
+ * required message only appeared once the user happened to touch a dropdown,
192
+ * which is the one moment they no longer need telling.
193
+ *
194
+ * `ngOnInit` rather than the constructor: `formControl` / `formControlName`
195
+ * only expose `.control` after their first `ngOnChanges`.
196
+ */
197
+ ngOnInit(): void;
181
198
  /**
182
199
  * Returns a stable numeric ID for a source regardless of whether it is a
183
200
  * level (`levelId`) or a module (`moduleId`). Used as the key in `selections`
184
201
  * and `sourceLevelStates`.
185
202
  */
186
203
  protected getSourceId(source: ConnectionSourceLevel): number;
204
+ /**
205
+ * A source that must be selected and is not. Mirrors
206
+ * {@link requiredSourcesValidator}, which decides the same thing from the
207
+ * control value.
208
+ *
209
+ * A method, not a computed: `selections` is a plain object that `ngModel`
210
+ * mutates in place and carries no signal, so only re-reading it every change
211
+ * detection cycle stays truthful.
212
+ */
213
+ protected isSourceMissing(source: ConnectionSourceLevel): boolean;
214
+ /**
215
+ * The control, but only for the source the message belongs under — every
216
+ * other source gets `null` and renders nothing. `mt-field-validation` still
217
+ * decides whether to paint: it waits for `touched`.
218
+ *
219
+ * Field height stays stable because the reserved line moves rather than
220
+ * appears. A null control reserves nothing, so exactly one slot is live at a
221
+ * time — the missing source's, or {@link unattributedErrorControl}'s below
222
+ * the row.
223
+ */
224
+ protected sourceErrorControl(source: ConnectionSourceLevel): AbstractControl | null;
225
+ /**
226
+ * The control, but only while no source owns the failure — a server error on
227
+ * a fully selected connection has nowhere else to render. Null as soon as a
228
+ * source is missing, so one failure never prints twice.
229
+ */
230
+ protected unattributedErrorControl(): AbstractControl | null;
187
231
  /**
188
232
  * Builds the `contextKey` for the `fetch/query` request based on source type.
189
233
  */
@@ -370,14 +414,17 @@ declare class EntityListField implements ControlValueAccessor {
370
414
  /** Optional HttpContext (kept for back-compat). */
371
415
  readonly context: _angular_core.InputSignal<HttpContext | undefined>;
372
416
  /**
373
- * Stored value for a host that renders this field **outside a form** — a
374
- * preview card, where there is no `FormControl` to write through and so
375
- * `writeValue` is never called.
417
+ * The stored value, for hosts that render this field **outside a form** —
418
+ * the read-only `mt-entity-list-preview` creates it through
419
+ * `NgComponentOutlet`, which can set inputs but cannot drive a
420
+ * `ControlValueAccessor`.
376
421
  *
377
- * Ignored whenever a form control is bound: that control owns the value, and
378
- * letting an input race it would overwrite the user's pending edits.
422
+ * Ignored once a form control is attached, so it can never race
423
+ * `writeValue`. It matters for a `Write`-access list: that field may not read
424
+ * the target module, so its stored `rows[]` are the only thing it has to
425
+ * show.
379
426
  */
380
- readonly value: _angular_core.InputSignal<string | EntityListStoredValue | null>;
427
+ readonly initialValue: _angular_core.InputSignal<string | EntityListStoredValue | null>;
381
428
  private readonly storedValue;
382
429
  /** Runtime-scoped metadata; null until the endpoint answers. */
383
430
  private readonly metadata;
@@ -533,6 +580,65 @@ declare class EntityListField implements ControlValueAccessor {
533
580
  * against the record values and add an empty cell to every row.
534
581
  */
535
582
  protected readonly tableColumns: _angular_core.Signal<EntityListColumnDef[]>;
583
+ /** Loaded document plus this session's edits; see `LocalEditorState`. */
584
+ private readonly localState;
585
+ /** The bound value was a Local document, whatever the metadata says yet. */
586
+ private readonly localValueSeen;
587
+ /** The last Local value emitted, so its echo does not reset the edits. */
588
+ private lastLocalEmit;
589
+ /**
590
+ * Rows live inside the parent record: no target records, no `fetch/query`,
591
+ * and the value is a document of its own rather than operation markers.
592
+ * Known from the metadata, or earlier from the value itself.
593
+ */
594
+ protected readonly localMode: _angular_core.Signal<boolean>;
595
+ /**
596
+ * The schema the table is built from. A loaded value's own schema wins: it
597
+ * is the one its rows were projected against, and pending or approved
598
+ * evidence stays pinned to the schema it was submitted with. The metadata's
599
+ * active schema is the fallback for a list that has never been saved.
600
+ */
601
+ private readonly localSchema;
602
+ protected readonly localFields: _angular_core.Signal<_masterteam_components_entities.EntityListLocalSchemaField[]>;
603
+ /**
604
+ * Render the Local table once the metadata answered: it is the access
605
+ * boundary, and it carries the operation switches the table obeys.
606
+ */
607
+ protected readonly localReady: _angular_core.Signal<boolean>;
608
+ /**
609
+ * Writes are staged into the parent's submission, never sent on their own.
610
+ *
611
+ * Whether the host lets this field be edited is the form's call —
612
+ * `readonly` — as it is for a linked list; `pendingSubmission` is not one.
613
+ * A loaded request is not always a review: a returned request is loaded to
614
+ * be corrected and resubmitted, and the backend projects the active schema
615
+ * for exactly that.
616
+ */
617
+ private readonly localWritable;
618
+ protected readonly localCanCreate: _angular_core.Signal<boolean>;
619
+ private readonly localCanEdit;
620
+ private readonly localCanDelete;
621
+ /** Reordering rewrites loaded rows, so it is an edit. */
622
+ protected readonly localCanReorder: _angular_core.Signal<boolean>;
623
+ /**
624
+ * One column per visible schema field, keyed by the field's local id — the
625
+ * id cells are keyed by. Sorting is off while rows can be dragged: a sorted
626
+ * table would show an order that is not the one being saved.
627
+ */
628
+ protected readonly localColumns: _angular_core.Signal<EntityListColumnDef[]>;
629
+ /**
630
+ * Rows as rendered: loaded rows with this session's edits over them, then
631
+ * new rows, in the order they would be saved. A loaded cell renders from the
632
+ * backend's resolved `value`; a cell the user set renders from the dialog's
633
+ * control value and option label, like a locally added linked row.
634
+ */
635
+ protected readonly localTableRows: _angular_core.Signal<EntityListRow[]>;
636
+ /**
637
+ * Edit and delete per row. A row added in this session is still part of the
638
+ * create — changing or dropping it undoes nothing stored — so it follows
639
+ * `allowCreate`; a loaded row follows `allowEdit` / `allowDelete`.
640
+ */
641
+ protected readonly localRowActions: _angular_core.Signal<TableAction[]>;
536
642
  /** Enough context to ask the backend what this field should render. */
537
643
  protected readonly hasRequiredContext: _angular_core.Signal<boolean>;
538
644
  /**
@@ -558,8 +664,34 @@ declare class EntityListField implements ControlValueAccessor {
558
664
  * `writeFields`.
559
665
  */
560
666
  private readonly addDialogComponent;
667
+ /**
668
+ * Row dialog of a Local list, built from the schema's captured definitions
669
+ * (`provideEntityListAddForm()` registers it beside the linked one). Without
670
+ * it a Local list renders read-only.
671
+ */
672
+ private readonly localDialogComponent;
561
673
  constructor();
562
674
  writeValue(value: EntityListStoredValue | string | null): void;
675
+ /**
676
+ * Take a Local document, and say whether it was one.
677
+ *
678
+ * - Our own emission echoed back (`mt-dynamic-form` re-writes the model on
679
+ * every change) keeps the session's edits.
680
+ * - A value some instance of this field emitted restores that instance's
681
+ * state — see `LOCAL_EDITOR_STATES`.
682
+ * - A document the backend sent starts a fresh session on it: the projection
683
+ * `process-form-load` returns (its `schema` set, cells rendered), or the
684
+ * stored document the fetch endpoints return for a preview (`schema:
685
+ * null`, cells unrendered) — the schema then comes from the metadata.
686
+ * Every backend document carries the `schema` member, null or not; a
687
+ * mutation never does. So a mutation nobody here emitted has no rows to
688
+ * rebuild the table from and is left as the control's value, untouched
689
+ * until the user edits.
690
+ *
691
+ * An empty value resets the Local session too — a form reset — and still
692
+ * falls through, since which storage the list uses may not be known yet.
693
+ */
694
+ private writeLocalValue;
563
695
  /**
564
696
  * True when the written value still carries exactly the rows and deletions
565
697
  * we last emitted — i.e. the form is echoing our own value back rather than
@@ -591,6 +723,57 @@ declare class EntityListField implements ControlValueAccessor {
591
723
  * existing records are queued in `deletedIds` for the backend to delete.
592
724
  */
593
725
  protected deleteRow(row: EntityListRow): void;
726
+ /**
727
+ * Add a Local row (no `row`) or edit one. The dialog is built from the
728
+ * schema; its `submit` map is serialized here into cell `rawValue`s.
729
+ *
730
+ * A loaded row keeps only the cells that differ from what was loaded, so an
731
+ * untouched cell is omitted and retained. Emptying a cell that had a value
732
+ * is a clear, sent as `null` — the dialog is filled from every schema field,
733
+ * so an empty control here really was emptied.
734
+ */
735
+ protected openLocalRowDialog(row?: EntityListRow): void;
736
+ /**
737
+ * Remove a Local row. A loaded row is listed in `deletedRowIds` and its
738
+ * pending edit dropped — a row is never both deleted and submitted. A row
739
+ * added in this session just disappears.
740
+ */
741
+ protected deleteLocalRow(row: EntityListRow): void;
742
+ /**
743
+ * Apply a drag within the table. Replays PrimeNG's own move on the rows as
744
+ * rendered: `p-table` is bound to a derived array, so the event's `value`
745
+ * is not reliably the reordered one.
746
+ */
747
+ protected onLocalReorder(event: {
748
+ dragIndex?: number;
749
+ dropIndex?: number;
750
+ }): void;
751
+ /**
752
+ * Serialize one dialog result into cells, by field id, for every visible
753
+ * field. `submit` is the dialog's reduction to stored scalars and wins over
754
+ * the raw control value, as for linked rows.
755
+ */
756
+ private toLocalCells;
757
+ /**
758
+ * Publish the Local state as the control's value.
759
+ *
760
+ * With changes, the value is a mutation: the loaded list and schema
761
+ * versions, only the changed rows and cells, explicit deletions, and a
762
+ * `mutationId` that stays the same while the content does (a retry of the
763
+ * same save) and changes with it (a new save). Without changes it is the
764
+ * loaded document again, which `mapFormValueToSubmitFields` leaves out of the
765
+ * submission — an unchanged Local list is omitted, never re-sent.
766
+ */
767
+ private emitLocal;
768
+ /** A cell the user set in this session, shaped like a backend one. */
769
+ private buildLocalDraftCell;
770
+ /**
771
+ * A loaded cell: the backend's rendered `value` beside its `rawValue`. A
772
+ * stored document from the fetch endpoints has no rendered values, so the
773
+ * raw one is shaped the way a locally set cell would be — a user id still
774
+ * renders as a user, though only as its id until the backend renders it.
775
+ */
776
+ private buildLocalLoadedCell;
594
777
  /**
595
778
  * Normalize the add/edit dialog close payload. The rich dialog returns
596
779
  * `{ values, display }`; a custom add-dialog may still return the raw values
@@ -711,7 +894,7 @@ declare class EntityListField implements ControlValueAccessor {
711
894
  private applyRecords;
712
895
  private toEntityData;
713
896
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<EntityListField, never>;
714
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<EntityListField, "mt-entity-list-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "propertyId": { "alias": "propertyId"; "required": false; "isSignal": true; }; "configuration": { "alias": "configuration"; "required": false; "isSignal": true; }; "runtimeContext": { "alias": "runtimeContext"; "required": false; "isSignal": true; }; "pendingSubmission": { "alias": "pendingSubmission"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "context": { "alias": "context"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
897
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<EntityListField, "mt-entity-list-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "propertyId": { "alias": "propertyId"; "required": false; "isSignal": true; }; "configuration": { "alias": "configuration"; "required": false; "isSignal": true; }; "runtimeContext": { "alias": "runtimeContext"; "required": false; "isSignal": true; }; "pendingSubmission": { "alias": "pendingSubmission"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "context": { "alias": "context"; "required": false; "isSignal": true; }; "initialValue": { "alias": "initialValue"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
715
898
  }
716
899
 
717
900
  /** Inputs the EntityList add-row dialog will receive via ModalService inputValues. */
@@ -739,20 +922,67 @@ interface EntityListAddDialogInputs {
739
922
  * token is not registered, the field falls back to a minimal text-only popup.
740
923
  */
741
924
  declare const ENTITY_LIST_ADD_DIALOG_COMPONENT: InjectionToken<Type<unknown>>;
925
+ /**
926
+ * Inputs the Local row dialog receives via `ModalService` `inputValues`.
927
+ *
928
+ * A Local list (`storageMode: "Local"`) has no source form to load: its rows
929
+ * belong to the parent record, and the source module only lent its field
930
+ * definitions, which the published schema captured. So the dialog is built
931
+ * from `fields` — never from `process-form-load` of the source module, which
932
+ * may not even be mapped to this level.
933
+ */
934
+ interface EntityListLocalRowDialogInputs {
935
+ /** Visible schema fields, in order, each with its captured definition. */
936
+ fields: EntityListLocalSchemaField[];
937
+ /** Host form's lookup catalog, for `Lookup` / `LookupMultiSelect` fields. */
938
+ lookups?: unknown[];
939
+ /**
940
+ * The loaded cells of the row being edited, by field id. Each is mapped the
941
+ * way a top-level form maps a loaded value (a `User` from its rendered
942
+ * object, a `Checkbox` from its stored text …).
943
+ */
944
+ initialCells?: Record<string, EntityListLocalCell>;
945
+ /** Control values from this session, by field id; win over `initialCells`. */
946
+ initialValues?: Record<string, unknown>;
947
+ isEdit?: boolean;
948
+ }
949
+ /**
950
+ * Close payload of the Local row dialog, keyed by field id. Same three maps as
951
+ * the linked dialog: `values` refills the form, `display` renders option
952
+ * labels, and `submit` is each value reduced to the scalar the backend
953
+ * stores — the field only serializes it.
954
+ */
955
+ interface EntityListLocalRowDialogResult {
956
+ values: Record<string, unknown>;
957
+ display: Record<string, unknown>;
958
+ submit: Record<string, unknown>;
959
+ }
960
+ /**
961
+ * Local counterpart of `ENTITY_LIST_ADD_DIALOG_COMPONENT`, registered by the
962
+ * same `provideEntityListAddForm()`. Without it a Local list is read-only.
963
+ */
964
+ declare const ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT: InjectionToken<Type<unknown>>;
742
965
 
743
966
  /**
744
- * Lets a preview render an `EntityList` property as the same read-only table
745
- * the form shows, instead of the compact count-and-drawer.
967
+ * Lets `mt-entity-list-preview` render a module-backed `EntityList` as the
968
+ * real, fetched table instead of its count-and-drawer trigger.
969
+ *
970
+ * Pair it with an `EntityRuntimeContextStore` carrying the owning level and
971
+ * level-data ids — the preview needs both, and without the context this
972
+ * provider changes nothing. `mt-client-instance-preview` sets both up, so a
973
+ * host rendering preview cards through it needs neither.
746
974
  *
747
- * Register it once in app providers, beside `provideEntityListAddForm()`. It
748
- * only takes effect where a call site passes an `entityListContext` — the card
749
- * grid does, a table cell deliberately does not — so registering it does not
750
- * change how nested lists render inside another table.
975
+ * The indirection exists because `entities` cannot import `table`: `table`
976
+ * already imports `entities`, and they are separate entry points of
977
+ * `@masterteam/components`. See `ENTITY_LIST_TABLE_COMPONENT`.
751
978
  *
752
- * The field is bound `readonly`, so it loads its own metadata and rows and
753
- * renders no Add / Edit / Delete.
979
+ * ```ts
980
+ * @Component({
981
+ * providers: [EntityRuntimeContextStore, provideEntityListTablePreview()],
982
+ * })
983
+ * ```
754
984
  */
755
- declare function provideEntityListTable(): Provider;
985
+ declare function provideEntityListTablePreview(): Provider;
756
986
 
757
987
  /** One picker option — only the name is shown. */
758
988
  interface ScheduleItemOption {
@@ -945,5 +1175,5 @@ declare class LookupModuleCheckListField implements ControlValueAccessor, OnInit
945
1175
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<LookupModuleCheckListField, "mt-lookup-module-check-list-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "lookupOptions": { "alias": "lookupOptions"; "required": false; "isSignal": true; }; "lookups": { "alias": "lookups"; "required": false; "isSignal": true; }; "propertyFields": { "alias": "propertyFields"; "required": false; "isSignal": true; }; "scopeId": { "alias": "scopeId"; "required": false; "isSignal": true; }; "propertyKeys": { "alias": "propertyKeys"; "required": false; "isSignal": true; }; "runtimeContext": { "alias": "runtimeContext"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
946
1176
  }
947
1177
 
948
- export { ENTITY_LIST_ADD_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField, provideEntityListTable };
949
- export type { ConnectionPayload, ConnectionSource, ConnectionSourceLevel, EntityListAddDialogInputs, LookupCheckListFormInputs, SchemaConnectionConfig, SourceLevelState };
1178
+ export { ENTITY_LIST_ADD_DIALOG_COMPONENT, ENTITY_LIST_LOCAL_ROW_DIALOG_COMPONENT, EntityListField, LOOKUP_CHECK_LIST_FORM_COMPONENT, LookupMatrixField, LookupModuleCheckListField, ScheduleItemSelectorField, SchedulePredecessorField, SchemaConnectionField, provideEntityListTablePreview };
1179
+ export type { ConnectionPayload, ConnectionSource, ConnectionSourceLevel, EntityListAddDialogInputs, EntityListLocalRowDialogInputs, EntityListLocalRowDialogResult, LookupCheckListFormInputs, SchemaConnectionConfig, SourceLevelState };