@ecodev/natural 44.0.4 → 45.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.
@@ -30,7 +30,6 @@ export declare abstract class NaturalAbstractFile extends NaturalAbstractControl
30
30
  protected readonly naturalFileService: NaturalFileService;
31
31
  private readonly document;
32
32
  private fileElement?;
33
- private readonly validators;
34
33
  /**
35
34
  * Whether we should accept a single file or multiple files
36
35
  */
@@ -90,8 +89,6 @@ export declare abstract class NaturalAbstractFile extends NaturalAbstractControl
90
89
  private beforeSelect;
91
90
  onChange(event: Event): void;
92
91
  private validate;
93
- private acceptValidator;
94
- private fileSizeValidator;
95
92
  static ɵfac: i0.ɵɵFactoryDeclaration<NaturalAbstractFile, never>;
96
93
  static ɵdir: i0.ɵɵDirectiveDeclaration<NaturalAbstractFile, never, never, { "multiple": "multiple"; "accept": "accept"; "maxSize": "maxSize"; "fileSelectionDisabled": "fileSelectionDisabled"; "selectable": "selectable"; "broadcast": "broadcast"; }, { "fileChange": "fileChange"; "filesChange": "filesChange"; }, never, never, false>;
97
94
  }
@@ -2,6 +2,7 @@ export declare function acceptType(accept: string, type: string, filename: strin
2
2
  export declare function isFileInput(elm: HTMLElement): elm is HTMLInputElement;
3
3
  export declare function detectSwipe(event: Event | TouchEvent): boolean;
4
4
  export declare function createInvisibleFileInputWrap(document: Document): HTMLLabelElement;
5
+ export declare function isDirectory(file: File): Promise<boolean>;
5
6
  export declare function stopEvent(event: Event): void;
6
7
  export declare function fileListToArray(fileList: FileList): File[];
7
8
  export declare function eventToFiles(event: Event | DragEvent): File[];
@@ -1,18 +1,26 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { FormGroup } from '@angular/forms';
3
+ import { ActivatedRoute } from '@angular/router';
3
4
  import * as i0 from "@angular/core";
4
- export declare class NaturalFixedButtonDetailComponent {
5
- model: {
6
- id?: string;
7
- permissions?: {
8
- delete: boolean;
9
- };
5
+ declare type Model = {
6
+ id?: string;
7
+ permissions?: {
8
+ delete: boolean;
10
9
  };
10
+ };
11
+ export declare class NaturalFixedButtonDetailComponent {
12
+ private canChange;
13
+ isCreation: boolean;
14
+ get model(): Model;
15
+ set model(value: Model);
16
+ private _model;
11
17
  form: FormGroup;
12
18
  readonly create: EventEmitter<void>;
13
19
  readonly delete: EventEmitter<void>;
20
+ constructor(route: ActivatedRoute);
14
21
  clickCreate(): void;
15
22
  clickDelete(): void;
16
23
  static ɵfac: i0.ɵɵFactoryDeclaration<NaturalFixedButtonDetailComponent, never>;
17
24
  static ɵcmp: i0.ɵɵComponentDeclaration<NaturalFixedButtonDetailComponent, "natural-fixed-button-detail", never, { "model": "model"; "form": "form"; }, { "create": "create"; "delete": "delete"; }, never, never, false>;
18
25
  }
26
+ export {};
@@ -6,6 +6,7 @@ import { Observable, OperatorFunction } from 'rxjs';
6
6
  import { NaturalQueryVariablesManager, QueryVariables } from '../classes/query-variable-manager';
7
7
  import { Literal } from '../types/types';
8
8
  import { PaginatedData } from '../classes/data-source';
9
+ import { NaturalDebounceService } from './debounce.service';
9
10
  export interface FormValidators {
10
11
  [key: string]: ValidatorFn[];
11
12
  }
@@ -33,21 +34,18 @@ export declare abstract class NaturalAbstractModelService<Tone, Vone extends {
33
34
  ids: string[];
34
35
  }> {
35
36
  protected readonly apollo: Apollo;
37
+ protected readonly naturalDebounceService: NaturalDebounceService;
36
38
  protected readonly name: string;
37
39
  protected readonly oneQuery: DocumentNode | null;
38
40
  protected readonly allQuery: DocumentNode | null;
39
41
  protected readonly createMutation: DocumentNode | null;
40
42
  protected readonly updateMutation: DocumentNode | null;
41
43
  protected readonly deleteMutation: DocumentNode | null;
42
- /**
43
- * Stores the debounced update function
44
- */
45
- private debouncedUpdateCache;
46
44
  /**
47
45
  * Store the creation mutations that are pending
48
46
  */
49
47
  private readonly creatingCache;
50
- constructor(apollo: Apollo, name: string, oneQuery: DocumentNode | null, allQuery: DocumentNode | null, createMutation: DocumentNode | null, updateMutation: DocumentNode | null, deleteMutation: DocumentNode | null);
48
+ constructor(apollo: Apollo, naturalDebounceService: NaturalDebounceService, name: string, oneQuery: DocumentNode | null, allQuery: DocumentNode | null, createMutation: DocumentNode | null, updateMutation: DocumentNode | null, deleteMutation: DocumentNode | null);
51
49
  getConsolidatedForClient(): Literal;
52
50
  /**
53
51
  * List of individual fields validators
@@ -0,0 +1,46 @@
1
+ import { Observable } from 'rxjs';
2
+ import { NaturalAbstractModelService } from './abstract-model.service';
3
+ import * as i0 from "@angular/core";
4
+ declare type Key = NaturalAbstractModelService<unknown, any, any, any, unknown, any, unknown, any, unknown, any>;
5
+ /**
6
+ * Debounce subscriptions to observable, with possibility to cancel one, or flush all of them. Typically,
7
+ * observables are object updates, so `NaturalAbstractModelService.updateNow()`.
8
+ *
9
+ * `key` must be an instance of `NaturalAbstractModelService` to separate objects by their types. So User with ID 1 is
10
+ * not confused with Product with ID 1. It has no other purpose.
11
+ *
12
+ * `id` should be the ID of the object that will be updated.
13
+ */
14
+ export declare class NaturalDebounceService {
15
+ private readonly flusher;
16
+ /**
17
+ * Stores the debounced update function
18
+ */
19
+ private readonly allDebouncedUpdateCache;
20
+ /**
21
+ * Debounce the given source observable for a short time. If called multiple times with the same key and id,
22
+ * it will postpone the subscription to the source observable.
23
+ *
24
+ * Giving the same key and id but a different source observable will replace the original observable, but
25
+ * keep the same debouncing timeline.
26
+ */
27
+ debounce<T>(key: Key, id: string, source: Observable<T>): Observable<T>;
28
+ cancel<T>(key: Key, id: string): void;
29
+ /**
30
+ * Immediately execute all pending updates.
31
+ *
32
+ * It should typically be called before login out.
33
+ *
34
+ * The returned observable will complete when all updates complete, even if some of them error.
35
+ */
36
+ flush(): Observable<void>;
37
+ /**
38
+ * Count of pending updates
39
+ */
40
+ get count(): number;
41
+ private getMap;
42
+ private delete;
43
+ static ɵfac: i0.ɵɵFactoryDeclaration<NaturalDebounceService, never>;
44
+ static ɵprov: i0.ɵɵInjectableDeclaration<NaturalDebounceService>;
45
+ }
46
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecodev/natural",
3
- "version": "44.0.4",
3
+ "version": "45.0.0",
4
4
  "license": "MIT",
5
5
  "repository": "github:Ecodev/natural",
6
6
  "sideEffects": false,
package/public-api.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './lib/classes/utility';
12
12
  export * from './lib/classes/validators';
13
13
  export { validTlds } from './lib/classes/tld';
14
14
  export * from './lib/services/abstract-model.service';
15
+ export { NaturalDebounceService } from './lib/services/debounce.service';
15
16
  export * from './lib/services/enum.service';
16
17
  export * from './lib/services/link-mutation.service';
17
18
  export * from './lib/services/persistence.service';