@ecodev/natural 48.0.3 → 49.0.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.
@@ -14,6 +14,7 @@ import { NaturalDataSource, PaginatedData } from './data-source';
14
14
  import { NaturalQueryVariablesManager, PaginationInput, QueryVariables, Sorting } from './query-variable-manager';
15
15
  import { ExtractTall, ExtractVall, Literal } from '../types/types';
16
16
  import { NavigableItem } from './abstract-navigable-list';
17
+ import { AvailableColumn } from '../modules/columns-picker/types';
17
18
  import * as i0 from "@angular/core";
18
19
  type MaybeNavigable = Literal | NavigableItem<Literal>;
19
20
  /**
@@ -33,15 +34,21 @@ export declare class NaturalAbstractList<TService extends NaturalAbstractModelSe
33
34
  */
34
35
  persistSearch: boolean;
35
36
  /**
36
- * Columns list after interaction with <natural-columns-picker>
37
+ * List of columns that are available to the end-user to select from, via `<natural-columns-picker>`
38
+ */
39
+ availableColumns: AvailableColumn[];
40
+ /**
41
+ * Columns list after interaction with `<natural-columns-picker>`
37
42
  */
38
43
  columnsForTable: string[];
39
44
  /**
40
- * The default column selection that automatically happened after <natural-columns-picker> initialization
45
+ * The default column selection that automatically happened after `<natural-columns-picker>` initialization
41
46
  */
42
47
  private defaultSelectedColumns;
43
48
  /**
44
49
  * Visible (checked) columns
50
+ *
51
+ * Instead of using this, you should consider correctly configuring `AvailableColumn.checked`.
45
52
  */
46
53
  selectedColumns?: string[];
47
54
  /**
@@ -157,6 +164,7 @@ export declare class NaturalAbstractList<TService extends NaturalAbstractModelSe
157
164
  * Uses data provided by router such as:
158
165
  *
159
166
  * - `route.data.forcedVariables`
167
+ * - `route.data.availableColumns`
160
168
  * - `route.data.selectedColumns`
161
169
  */
162
170
  protected initFromRoute(): void;
@@ -175,6 +183,6 @@ export declare class NaturalAbstractList<TService extends NaturalAbstractModelSe
175
183
  private applyForcedVariables;
176
184
  selectColumns(columns: string[]): void;
177
185
  static ɵfac: i0.ɵɵFactoryDeclaration<NaturalAbstractList<any, any>, never>;
178
- static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalAbstractList<any, any>, never, never, { "persistSearch": "persistSearch"; "selectedColumns": "selectedColumns"; "forcedVariables": "forcedVariables"; }, {}, never, never, false, never>;
186
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalAbstractList<any, any>, never, never, { "persistSearch": "persistSearch"; "availableColumns": "availableColumns"; "selectedColumns": "selectedColumns"; "forcedVariables": "forcedVariables"; }, {}, never, never, false, never>;
179
187
  }
180
188
  export {};
@@ -1,11 +1,15 @@
1
- import { AfterViewInit, ChangeDetectorRef, EventEmitter, OnDestroy, QueryList } from '@angular/core';
2
- import { NaturalColumnsPickerColumnDirective } from './columns-picker-column.directive';
1
+ import { EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
2
+ import { AvailableColumn } from './types';
3
3
  import * as i0 from "@angular/core";
4
- export declare class NaturalColumnsPickerComponent implements AfterViewInit, OnDestroy {
5
- private readonly changeDetectorRef;
4
+ export declare class NaturalColumnsPickerComponent implements OnChanges, OnDestroy {
6
5
  private _selections?;
6
+ private _availableColumns;
7
7
  /**
8
- * Set the columns that are wanted but might be unavailable.
8
+ * Set all the columns that are available.
9
+ */
10
+ set availableColumns(columns: Readonly<Readonly<AvailableColumn>[]> | undefined);
11
+ /**
12
+ * Set the columns that we would like to select but might be unavailable.
9
13
  *
10
14
  * If a column is unavailable it will be ignored silently. To know what columns were actually applied
11
15
  * you should use `selectionChange`.
@@ -17,20 +21,15 @@ export declare class NaturalColumnsPickerComponent implements AfterViewInit, OnD
17
21
  * Emit a list of valid and selected column keys whenever the selection changes
18
22
  */
19
23
  readonly selectionChange: EventEmitter<string[]>;
20
- /**
21
- * Available columns are defined by options in the template
22
- */
23
- availableColumns: QueryList<NaturalColumnsPickerColumnDirective> | null;
24
24
  /**
25
25
  * Displayed options in the dropdown menu
26
26
  */
27
- displayedColumns: NaturalColumnsPickerColumnDirective[];
28
- private ngUnsubscribe;
29
- constructor(changeDetectorRef: ChangeDetectorRef);
30
- ngAfterViewInit(): void;
27
+ displayedColumns: Required<AvailableColumn>[];
28
+ private readonly ngUnsubscribe;
31
29
  private initColumns;
32
30
  updateColumns(): void;
33
31
  ngOnDestroy(): void;
32
+ ngOnChanges(changes: SimpleChanges): void;
34
33
  static ɵfac: i0.ɵɵFactoryDeclaration<NaturalColumnsPickerComponent, never>;
35
- static ɵcmp: i0.ɵɵComponentDeclaration<NaturalColumnsPickerComponent, "natural-columns-picker", never, { "selections": "selections"; }, { "selectionChange": "selectionChange"; }, ["availableColumns"], never, false, never>;
34
+ static ɵcmp: i0.ɵɵComponentDeclaration<NaturalColumnsPickerComponent, "natural-columns-picker", never, { "availableColumns": "availableColumns"; "selections": "selections"; }, { "selectionChange": "selectionChange"; }, never, never, false, never>;
36
35
  }
@@ -1,16 +1,15 @@
1
1
  import * as i0 from "@angular/core";
2
- import * as i1 from "./columns-picker-column.directive";
3
- import * as i2 from "./columns-picker.component";
4
- import * as i3 from "@angular/common";
5
- import * as i4 from "@angular/forms";
6
- import * as i5 from "@angular/material/menu";
7
- import * as i6 from "@angular/material/button";
8
- import * as i7 from "@angular/material/checkbox";
9
- import * as i8 from "../icon/icon.module";
10
- import * as i9 from "@angular/material/tooltip";
11
- import * as i10 from "@angular/material/icon";
2
+ import * as i1 from "./columns-picker.component";
3
+ import * as i2 from "@angular/common";
4
+ import * as i3 from "@angular/forms";
5
+ import * as i4 from "@angular/material/menu";
6
+ import * as i5 from "@angular/material/button";
7
+ import * as i6 from "@angular/material/checkbox";
8
+ import * as i7 from "../icon/icon.module";
9
+ import * as i8 from "@angular/material/tooltip";
10
+ import * as i9 from "@angular/material/icon";
12
11
  export declare class NaturalColumnsPickerModule {
13
12
  static ɵfac: i0.ɵɵFactoryDeclaration<NaturalColumnsPickerModule, never>;
14
- static ɵmod: i0.ɵɵNgModuleDeclaration<NaturalColumnsPickerModule, [typeof i1.NaturalColumnsPickerColumnDirective, typeof i2.NaturalColumnsPickerComponent], [typeof i3.CommonModule, typeof i4.FormsModule, typeof i5.MatMenuModule, typeof i6.MatButtonModule, typeof i7.MatCheckboxModule, typeof i8.NaturalIconModule, typeof i9.MatTooltipModule, typeof i10.MatIconModule], [typeof i1.NaturalColumnsPickerColumnDirective, typeof i2.NaturalColumnsPickerComponent]>;
13
+ static ɵmod: i0.ɵɵNgModuleDeclaration<NaturalColumnsPickerModule, [typeof i1.NaturalColumnsPickerComponent], [typeof i2.CommonModule, typeof i3.FormsModule, typeof i4.MatMenuModule, typeof i5.MatButtonModule, typeof i6.MatCheckboxModule, typeof i7.NaturalIconModule, typeof i8.MatTooltipModule, typeof i9.MatIconModule], [typeof i1.NaturalColumnsPickerComponent]>;
15
14
  static ɵinj: i0.ɵɵInjectorDeclaration<NaturalColumnsPickerModule>;
16
15
  }
@@ -1,3 +1,3 @@
1
- export * from './columns-picker-column.directive';
1
+ export { AvailableColumn } from './types';
2
2
  export * from './columns-picker.component';
3
3
  export * from './columns-picker.module';
@@ -0,0 +1,30 @@
1
+ export type AvailableColumn = {
2
+ /**
3
+ * This must be the column ID as defined in `matColumnDef`
4
+ *
5
+ * Implementation details:
6
+ *
7
+ * Unfortunately, we cannot use a `Record<AvailableColumn>` where keys would implicitly be unique and would replace
8
+ * this ID property, because only ES2020 guarantee the order of object keys, and we must still support ES2015 for
9
+ * iPhone 6. So, instead of `Record<AvailableColumn>`, we use `AvailableColumn[]` for now. But this could be
10
+ * revisited once we drop support of ES2015.
11
+ *
12
+ * @see https://stackoverflow.com/questions/30076219/does-es6-introduce-a-well-defined-order-of-enumeration-for-object-properties
13
+ */
14
+ id: string;
15
+ /**
16
+ * Localized label of column for human
17
+ */
18
+ label: string;
19
+ /**
20
+ * Initial checked state, defaults to `true`.
21
+ */
22
+ checked?: boolean;
23
+ /**
24
+ * Initial visibility state, defaults to `false`.
25
+ *
26
+ * A column that is hidden will not appear in the list of choice,
27
+ * but it will be included in the result of selected columns.
28
+ */
29
+ hidden?: boolean;
30
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodev/natural",
3
- "version": "48.0.3",
3
+ "version": "49.0.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:Ecodev/natural",
6
6
  "sideEffects": false,
@@ -1,47 +0,0 @@
1
- import { Directive, Input } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- export class NaturalColumnsPickerColumnDirective {
4
- constructor(elementRef) {
5
- this.elementRef = elementRef;
6
- /**
7
- * Initial checked state
8
- */
9
- this.checked = true;
10
- /**
11
- * Initial visibility state
12
- */
13
- this.hidden = false;
14
- /**
15
- * Localized label of column, if absent default to key
16
- */
17
- this.label = '';
18
- }
19
- /**
20
- * This must be the column key as defined in matColumnDef
21
- */
22
- set naturalColumnsPickerColumn(value) {
23
- this.key = value;
24
- }
25
- ngOnInit() {
26
- // Default label to key before real label is accessible
27
- this.label = this.key;
28
- }
29
- ngAfterViewInit() {
30
- this.label = this.elementRef.nativeElement.textContent ?? '';
31
- }
32
- }
33
- NaturalColumnsPickerColumnDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalColumnsPickerColumnDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
34
- NaturalColumnsPickerColumnDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.2", type: NaturalColumnsPickerColumnDirective, selector: "[naturalColumnsPickerColumn]", inputs: { checked: "checked", hidden: "hidden", naturalColumnsPickerColumn: "naturalColumnsPickerColumn" }, ngImport: i0 });
35
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.2", ngImport: i0, type: NaturalColumnsPickerColumnDirective, decorators: [{
36
- type: Directive,
37
- args: [{
38
- selector: '[naturalColumnsPickerColumn]',
39
- }]
40
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { checked: [{
41
- type: Input
42
- }], hidden: [{
43
- type: Input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Y29sdW1uIGtleSBhcyBkZWZpbmVkIGluIG1hdENvbHVtbkRlZlxuICAgICAqL1xuICAgIEBJbnB1dCgpXG4gICAgcHVibGljIHNldCBuYXR1cmFsQ29sdW1uc1BpY2tlckNvbHVtbih2YWx1ZTogc3RyaW5nKSB7XG4gICAgICAgIHRoaXMua2V5ID0gdmFsdWU7XG4gICAgfVxuXG4gICAgcHVibGljIG5nT25Jbml0KCk6IHZvaWQge1xuICAgICAgICAvLyBEZWZhdWx0IGxhYmVsIHRvIGtleSBiZWZvcmUgcmVhbCBsYWJlbCBpcyBhY2Nlc3NpYmxlXG4gICAgICAgIHRoaXMubGFiZWwgPSB0aGlzLmtleTtcbiAgICB9XG5cbiAgICBwdWJsaWMgbmdBZnRlclZpZXdJbml0KCk6IHZvaWQge1xuICAgICAgICB0aGlzLmxhYmVsID0gdGhpcy5lbGVtZW50UmVmLm5hdGl2ZUVsZW1lbnQudGV4dENvbnRlbnQgPz8gJyc7XG4gICAgfVxufVxuIl19
@@ -1,27 +0,0 @@
1
- import { AfterViewInit, ElementRef, OnInit } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- export declare class NaturalColumnsPickerColumnDirective implements AfterViewInit, OnInit {
4
- private readonly elementRef;
5
- key: string;
6
- /**
7
- * Initial checked state
8
- */
9
- checked: boolean;
10
- /**
11
- * Initial visibility state
12
- */
13
- hidden: boolean;
14
- /**
15
- * Localized label of column, if absent default to key
16
- */
17
- label: string;
18
- constructor(elementRef: ElementRef<HTMLElement>);
19
- /**
20
- * This must be the column key as defined in matColumnDef
21
- */
22
- set naturalColumnsPickerColumn(value: string);
23
- ngOnInit(): void;
24
- ngAfterViewInit(): void;
25
- static ɵfac: i0.ɵɵFactoryDeclaration<NaturalColumnsPickerColumnDirective, never>;
26
- static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalColumnsPickerColumnDirective, "[naturalColumnsPickerColumn]", never, { "checked": "checked"; "hidden": "hidden"; "naturalColumnsPickerColumn": "naturalColumnsPickerColumn"; }, {}, never, never, false, never>;
27
- }