@myrmidon/cadmus-ui 15.0.0 → 15.1.1

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/index.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { OnInit, ElementRef, OnDestroy } from '@angular/core';
2
+ import { OnInit, ElementRef, OnDestroy, Type } from '@angular/core';
3
3
  import { FormGroup, UntypedFormGroup, FormArray, FormControl, FormBuilder, UntypedFormControl, UntypedFormBuilder, ValidatorFn, AbstractControl } from '@angular/forms';
4
- import { TokenLocation, TextLayerService, FacetDefinition, FlagDefinition, LayerHint, DataPinInfo, IndexLookupDefinitions, Thesaurus, PartTypeIds, ThesaurusEntry, Part, Fragment, PartIdentity, FragmentIdentity, EditedObject } from '@myrmidon/cadmus-core';
4
+ import { TokenLocation, TextLayerService, FacetDefinition, FlagDefinition, LayerHint, DataPinInfo, IndexLookupDefinitions, ThesaurusEntry as ThesaurusEntry$1, Thesaurus, PartTypeIds, Part, Fragment, PartIdentity, FragmentIdentity, EditedObject } from '@myrmidon/cadmus-core';
5
5
  import { DialogService } from '@myrmidon/ngx-mat-tools';
6
6
  import { Observable, BehaviorSubject } from 'rxjs';
7
7
  import { ItemService, FacetService, UserService } from '@myrmidon/cadmus-api';
8
- import { NestedTreeControl } from '@angular/cdk/tree';
9
- import { MatTreeNestedDataSource } from '@angular/material/tree';
8
+ import { CdkDragDrop } from '@angular/cdk/drag-drop';
9
+ import { PagedTreeStoreService, TreeNodeFilter, PagedTreeNode, PagedTreeStore, PageChangeRequest } from '@myrmidon/paged-data-browsers';
10
+ import { DataPage } from '@myrmidon/ngx-tools';
11
+ import { MatDialogRef } from '@angular/material/dialog';
10
12
  import { AuthJwtService, User } from '@myrmidon/auth-jwt-login';
11
13
  import { AppRepository } from '@myrmidon/cadmus-state';
12
14
  import { RefLookupService, RefLookupFilter } from '@myrmidon/cadmus-refs-lookup';
@@ -228,6 +230,168 @@ declare class LookupPinComponent implements OnInit {
228
230
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<LookupPinComponent, "cadmus-lookup-pin", never, { "initialValue": { "alias": "initialValue"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "limit": { "alias": "limit"; "required": false; "isSignal": true; }; "resetOnPick": { "alias": "resetOnPick"; "required": false; "isSignal": true; }; "lookupKey": { "alias": "lookupKey"; "required": false; "isSignal": true; }; }, { "entryChange": "entryChange"; }, never, never, true, never>;
229
231
  }
230
232
 
233
+ /**
234
+ * The prefix added to custom entries' IDs.
235
+ */
236
+ declare const CUSTOM_ENTRY_PREFIX = "$";
237
+ /**
238
+ * A picker component for thesaurus entries.
239
+ * This component allows picking one or more entries from a given thesaurus.
240
+ * In its collapsed state, it shows the picked entries as chips; when
241
+ * expanded, it shows the thesaurus tree to pick from. Custom entries
242
+ * (not in the thesaurus) can be optionally allowed.
243
+ */
244
+ declare class ThesEntriesPickerComponent {
245
+ /**
246
+ * The thesaurus entries to pick from (required).
247
+ */
248
+ readonly availableEntries: _angular_core.InputSignal<ThesaurusEntry$1[]>;
249
+ /**
250
+ * The picked entries.
251
+ */
252
+ readonly entries: _angular_core.ModelSignal<ThesaurusEntry$1[]>;
253
+ /**
254
+ * True to show the entries with labels shortened according to
255
+ * their hierarchy.
256
+ */
257
+ readonly hierarchicLabels: _angular_core.InputSignal<boolean>;
258
+ /**
259
+ * True to automatically sort entries (disables drag-and-drop).
260
+ * When false, entries can be manually reordered via drag-and-drop.
261
+ */
262
+ readonly autoSort: _angular_core.InputSignal<boolean>;
263
+ /**
264
+ * True to allow custom values (not in the entries list).
265
+ */
266
+ readonly allowCustom: _angular_core.InputSignal<boolean>;
267
+ /**
268
+ * The minimum number of entries to pick.
269
+ */
270
+ readonly minEntries: _angular_core.InputSignal<number>;
271
+ /**
272
+ * The maximum number of entries to pick (0=unlimited).
273
+ */
274
+ readonly maxEntries: _angular_core.InputSignal<number>;
275
+ /**
276
+ * True when the picker is expanded (showing the entries list).
277
+ */
278
+ readonly expanded: _angular_core.ModelSignal<boolean>;
279
+ /**
280
+ * The message to show when there are no picked entries.
281
+ */
282
+ readonly emptyMessage: _angular_core.InputSignal<string>;
283
+ /**
284
+ * The number of remaining entries that can be picked (0=unlimited).
285
+ * This is displayed only if maxEntries > 1.
286
+ */
287
+ readonly remaining: _angular_core.Signal<number>;
288
+ id: FormControl<string>;
289
+ value: FormControl<string>;
290
+ form: FormGroup;
291
+ constructor(formBuilder: FormBuilder);
292
+ renderLabel: (label: string) => string;
293
+ private sortEntries;
294
+ onEntryChange(entry: ThesaurusEntry$1): void;
295
+ addCustomEntry(): void;
296
+ removeEntry(entry: ThesaurusEntry$1): void;
297
+ clear(): void;
298
+ onDrop(event: CdkDragDrop<ThesaurusEntry$1[]>): void;
299
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThesEntriesPickerComponent, never>;
300
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ThesEntriesPickerComponent, "cadmus-thes-entries-picker", never, { "availableEntries": { "alias": "availableEntries"; "required": true; "isSignal": true; }; "entries": { "alias": "entries"; "required": false; "isSignal": true; }; "hierarchicLabels": { "alias": "hierarchicLabels"; "required": false; "isSignal": true; }; "autoSort": { "alias": "autoSort"; "required": false; "isSignal": true; }; "allowCustom": { "alias": "allowCustom"; "required": false; "isSignal": true; }; "minEntries": { "alias": "minEntries"; "required": false; "isSignal": true; }; "maxEntries": { "alias": "maxEntries"; "required": false; "isSignal": true; }; "expanded": { "alias": "expanded"; "required": false; "isSignal": true; }; "emptyMessage": { "alias": "emptyMessage"; "required": false; "isSignal": true; }; }, { "entries": "entriesChange"; "expanded": "expandedChange"; }, never, never, true, never>;
301
+ }
302
+
303
+ interface ThesaurusEntry {
304
+ id: string;
305
+ value: string;
306
+ }
307
+ /**
308
+ * The filter for thesaurus entry nodes. The only filtered property is
309
+ * the node's label.
310
+ */
311
+ interface ThesEntryNodeFilter extends TreeNodeFilter {
312
+ label?: string;
313
+ }
314
+ /**
315
+ * The tree node for thesaurus entries in a paging tree node.
316
+ */
317
+ interface ThesEntryPagedTreeNode extends PagedTreeNode<ThesEntryNodeFilter> {
318
+ key: string;
319
+ value: string;
320
+ }
321
+ /**
322
+ * A label rendering function which removes from a label
323
+ * all the characters past the last colon, trimming the result.
324
+ * This is a typical rendering when dealing with hierarchical
325
+ * thesaurus entries, e.g. "furniture: table: color", where
326
+ * we can shorten the label to just "color", as "furniture"
327
+ * and "table" are its ancestors.
328
+ */
329
+ declare const renderLabelFromLastColon: (label: string) => string;
330
+ /**
331
+ * A static paged tree store service for thesaurus entries.
332
+ * This builds the tree nodes from the thesaurus entries, assuming
333
+ * that entry IDs are hierarchical and separated by dots (.).
334
+ */
335
+ declare class StaticThesPagedTreeStoreService implements PagedTreeStoreService<ThesEntryNodeFilter> {
336
+ private _renderLabel?;
337
+ private _nodes;
338
+ private _built;
339
+ private readonly _entries;
340
+ constructor(entries: ThesaurusEntry[], _renderLabel?: ((label: string) => string) | undefined);
341
+ private ensureNodes;
342
+ /**
343
+ * Get the specified page of nodes.
344
+ * @param filter The filter.
345
+ * @param pageNumber The page number.
346
+ * @param pageSize The page size.
347
+ * @param hasMockRoot Whether the root node is a mock node. Not used here.
348
+ */
349
+ getNodes(filter: ThesEntryNodeFilter, pageNumber: number, pageSize: number, hasMockRoot?: boolean): Observable<DataPage<ThesEntryPagedTreeNode>>;
350
+ }
351
+
352
+ declare class ThesPagedTreeBrowserComponent implements OnInit, OnDestroy {
353
+ private _dialog;
354
+ private _sub?;
355
+ /**
356
+ * The service to use to load the nodes.
357
+ */
358
+ readonly service: _angular_core.InputSignal<StaticThesPagedTreeStoreService>;
359
+ /**
360
+ * Emitted when a node is clicked.
361
+ */
362
+ readonly nodePick: _angular_core.OutputEmitterRef<ThesEntryPagedTreeNode>;
363
+ /**
364
+ * The store instance, built from the service.
365
+ */
366
+ readonly store: _angular_core.Signal<PagedTreeStore<ThesEntryPagedTreeNode, ThesEntryNodeFilter>>;
367
+ readonly loading: _angular_core.WritableSignal<boolean>;
368
+ debug: FormControl<boolean>;
369
+ hideLoc: FormControl<boolean>;
370
+ hideFilter: FormControl<boolean>;
371
+ filter$: Observable<Readonly<ThesEntryNodeFilter>>;
372
+ nodes$: Observable<Readonly<ThesEntryPagedTreeNode[]>>;
373
+ label: FormControl<string | null>;
374
+ form: FormGroup<{
375
+ label: FormControl<string | null>;
376
+ }>;
377
+ constructor();
378
+ ngOnInit(): void;
379
+ ngOnDestroy(): void;
380
+ reset(): void;
381
+ onToggleExpanded(node: ThesEntryPagedTreeNode): void;
382
+ onPageChangeRequest(request: PageChangeRequest): void;
383
+ onFilterChange(filter: ThesEntryNodeFilter | null | undefined): void;
384
+ onEditFilterRequest(node: ThesEntryPagedTreeNode): void;
385
+ expandAll(): void;
386
+ collapseAll(): void;
387
+ clear(): void;
388
+ onNodeClick(node: ThesEntryPagedTreeNode): void;
389
+ findLabels(): void;
390
+ removeHilites(): void;
391
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThesPagedTreeBrowserComponent, never>;
392
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ThesPagedTreeBrowserComponent, "cadmus-thes-paged-tree-browser", never, { "service": { "alias": "service"; "required": false; "isSignal": true; }; }, { "nodePick": "nodePick"; }, never, never, true, never>;
393
+ }
394
+
231
395
  declare enum PartBadgeType {
232
396
  partAndRole = 0,
233
397
  partOnly = 1,
@@ -286,23 +450,29 @@ declare class PartBadgeComponent {
286
450
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<PartBadgeComponent, "cadmus-part-badge", never, { "badgeType": { "alias": "badgeType"; "required": false; "isSignal": true; }; "typeThesaurus": { "alias": "typeThesaurus"; "required": false; "isSignal": true; }; "facetDefinition": { "alias": "facetDefinition"; "required": false; "isSignal": true; }; "partTypeIds": { "alias": "partTypeIds"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
287
451
  }
288
452
 
289
- interface TreeNode {
290
- id: string;
291
- label: string;
292
- originalLabel?: string;
293
- parent?: TreeNode;
294
- children?: TreeNode[];
295
- clickable?: boolean;
296
- }
297
453
  /**
298
- * A label rendering function which removes from a label
299
- * all the characters past the last colon, trimming the result.
300
- * This is a typical rendering when dealing with hierarchical
301
- * thesaurus entries, e.g. "furniture: table: color", where
302
- * we can shorten the label to just "color", as "furniture"
303
- * and "table" are its ancestors.
454
+ * A filter to be used for thesaurus paged tree browsers.
304
455
  */
305
- declare const renderLabelFromLastColon: (label: string) => string;
456
+ declare class ThesPagedTreeFilterComponent implements OnInit {
457
+ readonly dialogRef: MatDialogRef<ThesPagedTreeFilterComponent, any> | null;
458
+ readonly data: any;
459
+ /**
460
+ * The filter.
461
+ */
462
+ readonly filter: _angular_core.ModelSignal<ThesEntryNodeFilter | null | undefined>;
463
+ readonly wrapped: _angular_core.WritableSignal<boolean>;
464
+ label: FormControl<string | null>;
465
+ form: FormGroup;
466
+ constructor();
467
+ ngOnInit(): void;
468
+ private updateForm;
469
+ private getFilter;
470
+ reset(): void;
471
+ apply(): void;
472
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThesPagedTreeFilterComponent, never>;
473
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ThesPagedTreeFilterComponent, "cadmus-thes-paged-tree-filter", never, { "filter": { "alias": "filter"; "required": false; "isSignal": true; }; }, { "filter": "filterChange"; }, never, never, true, never>;
474
+ }
475
+
306
476
  /**
307
477
  * Thesaurus tree component.
308
478
  * This component displays a set of hierarchical thesaurus entries
@@ -316,54 +486,30 @@ declare const renderLabelFromLastColon: (label: string) => string;
316
486
  * event is emitted. Note that even if you specify a label renderer
317
487
  * function, the event always emits the original label.
318
488
  */
319
- declare class ThesaurusTreeComponent implements OnInit {
489
+ declare class ThesaurusTreeComponent {
320
490
  /**
321
491
  * The thesaurus entries.
322
492
  */
323
493
  readonly entries: _angular_core.InputSignal<ThesaurusEntry[] | undefined>;
324
- /**
325
- * The label for the root node.
326
- */
327
- readonly rootLabel: _angular_core.InputSignal<string>;
328
494
  /**
329
495
  * The optional node label rendering function.
330
496
  */
331
- readonly renderLabel: _angular_core.InputSignal<((label: string) => string) | undefined>;
497
+ readonly renderLabel: _angular_core.InputSignal<(label: string) => string>;
332
498
  /**
333
499
  * Fired when a thesaurus entry is selected.
334
500
  */
335
501
  readonly entryChange: _angular_core.OutputEmitterRef<ThesaurusEntry>;
336
- root: TreeNode;
337
- treeControl: NestedTreeControl<TreeNode>;
338
- treeDataSource: MatTreeNestedDataSource<TreeNode>;
339
- filter: FormControl<string | null>;
340
- form: FormGroup;
341
- foundNodes: TreeNode[] | undefined;
342
- hasChildren: (index: number, node: TreeNode) => boolean | undefined;
343
- isRoot: (index: number, node: TreeNode) => boolean;
344
- constructor(formBuilder: FormBuilder);
345
- ngOnInit(): void;
346
- private initTree;
347
- private getLabel;
348
- private addNode;
349
- /**
350
- * Build a tree model from a list of name=value pairs,
351
- * where each value can include one or more components separated by
352
- * the specified separator.
353
- * @param entries The entries to add.
354
- * @param separator string The separator string to use for values.
355
- */
356
- buildTreeModel(entries: ThesaurusEntry[], separator?: string): TreeNode;
357
- onTreeNodeClick(node: TreeNode): void;
358
- expandAll(): void;
359
- collapseAll(): void;
360
- private expandFromNode;
361
- private expandMatchingNodes;
362
- find(): void;
363
- resetFilter(): void;
364
- isFoundNode(node: TreeNode): boolean;
502
+ /**
503
+ * The tree store service, dependent on the current entries and renderLabel.
504
+ */
505
+ readonly service: _angular_core.Signal<StaticThesPagedTreeStoreService>;
506
+ /**
507
+ * The filter component class to use.
508
+ */
509
+ readonly filterComponent: Type<ThesPagedTreeFilterComponent>;
510
+ onNodePick(node: ThesEntryPagedTreeNode): void;
365
511
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<ThesaurusTreeComponent, never>;
366
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<ThesaurusTreeComponent, "cadmus-thesaurus-tree", never, { "entries": { "alias": "entries"; "required": false; "isSignal": true; }; "rootLabel": { "alias": "rootLabel"; "required": false; "isSignal": true; }; "renderLabel": { "alias": "renderLabel"; "required": false; "isSignal": true; }; }, { "entryChange": "entryChange"; }, never, never, true, never>;
512
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ThesaurusTreeComponent, "cadmus-thesaurus-tree", never, { "entries": { "alias": "entries"; "required": false; "isSignal": true; }; "renderLabel": { "alias": "renderLabel"; "required": false; "isSignal": true; }; }, { "entryChange": "entryChange"; }, never, never, true, never>;
367
513
  }
368
514
 
369
515
  /**
@@ -570,5 +716,5 @@ declare const extractTouchedChanges: (control: ObjectLike<AbstractControl, "mark
570
716
  */
571
717
  declare const extractPristineChanges: (control: ObjectLike<AbstractControl, "markAsPristine" | "markAsDirty">) => Observable<boolean>;
572
718
 
573
- export { CloseSaveButtonsComponent, ColorService, CustomValidators, DecoratedTokenTextComponent, ErrorListComponent, FacetBadgeComponent, FlagsBadgeComponent, JsonValidators, LayerHintsComponent, LookupPinComponent, ModelEditorComponentBase, PartBadgeComponent, PartBadgeType, ThesaurusTreeComponent, UserRefLookupService, extractPristineChanges, extractTouchedChanges, getPartIdName, renderLabelFromLastColon };
574
- export type { ArgumentsType, FacetBadgeData, FlagsBadgeData, UserWithRoles };
719
+ export { CUSTOM_ENTRY_PREFIX, CloseSaveButtonsComponent, ColorService, CustomValidators, DecoratedTokenTextComponent, ErrorListComponent, FacetBadgeComponent, FlagsBadgeComponent, JsonValidators, LayerHintsComponent, LookupPinComponent, ModelEditorComponentBase, PartBadgeComponent, PartBadgeType, StaticThesPagedTreeStoreService, ThesEntriesPickerComponent, ThesPagedTreeBrowserComponent, ThesaurusTreeComponent, UserRefLookupService, extractPristineChanges, extractTouchedChanges, getPartIdName, renderLabelFromLastColon };
720
+ export type { ArgumentsType, FacetBadgeData, FlagsBadgeData, ThesEntryNodeFilter, ThesEntryPagedTreeNode, ThesaurusEntry, UserWithRoles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrmidon/cadmus-ui",
3
- "version": "15.0.0",
3
+ "version": "15.1.1",
4
4
  "description": "Cadmus - general UI components.",
5
5
  "keywords": [
6
6
  "Cadmus"
@@ -18,7 +18,7 @@
18
18
  "@angular/core": "^20.0.0",
19
19
  "@angular/material": "^20.0.0",
20
20
  "@myrmidon/ngx-tools": "^2.0.0",
21
- "@myrmidon/cadmus-refs-lookup": "^10.0.3",
21
+ "@myrmidon/cadmus-refs-lookup": "^10.0.5",
22
22
  "@myrmidon/cadmus-core": "^12.0.2"
23
23
  },
24
24
  "dependencies": {