@sumaris-net/ngx-components 18.23.72 → 18.24.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Directive, Pipe, Injectable, EventEmitter, Output, Optional, Inject, inject, NgModule, forwardRef, booleanAttribute, ViewChildren, Input, ChangeDetectionStrategy, Component, HostListener, HostBinding, ElementRef, numberAttribute, ViewChild, ANIMATION_MODULE_TYPE, RendererStyleFlags2, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef, Self, ViewEncapsulation, APP_INITIALIZER, DestroyRef, input, output, Renderer2, effect, signal, SecurityContext, viewChildren, viewChild, model, computed, untracked } from '@angular/core';
2
+ import { InjectionToken, Directive, Pipe, Injectable, EventEmitter, Output, Optional, Inject, inject, NgModule, forwardRef, booleanAttribute, ViewChildren, Input, ChangeDetectionStrategy, Component, HostListener, HostBinding, ElementRef, numberAttribute, ViewChild, ANIMATION_MODULE_TYPE, RendererStyleFlags2, CUSTOM_ELEMENTS_SCHEMA, ChangeDetectorRef, Self, ViewEncapsulation, Injector, APP_INITIALIZER, DestroyRef, input, output, Renderer2, effect, signal, SecurityContext, viewChildren, viewChild, model, computed, untracked } from '@angular/core';
3
3
  import { firstValueFrom, shareReplay, tap, of, timer, Subject, merge, delay, isObservable, from, Subscription, BehaviorSubject, fromEvent, noop as noop$9, Observable, forkJoin, timeout, defer, combineLatest, debounceTime as debounceTime$1, distinctUntilChanged as distinctUntilChanged$1, mergeMap as mergeMap$1, switchMap as switchMap$1, EMPTY, interval } from 'rxjs';
4
4
  import { catchError, map, filter, takeUntil, first, switchMap, tap as tap$1, throttleTime, debounceTime, startWith, distinctUntilChanged, mergeMap, skip, finalize, distinctUntilKeyChanged, take } from 'rxjs/operators';
5
5
  import * as cloneImported from 'clone';
@@ -1558,7 +1558,7 @@ function fromDateISOString(value, opts = { undefinedIfInvalid: true, strict: fal
1558
1558
  }
1559
1559
  else {
1560
1560
  // Parse the input value, as a ISO date time
1561
- date = DateUtils.moment(value, DATE_ISO_PATTERN);
1561
+ date = DateUtils.moment(value, DATE_ISO_PATTERN, opts?.requiredTime);
1562
1562
  if (date.isValid())
1563
1563
  return date; // OK
1564
1564
  // Not valid: trying to convert from unix timestamp (if not strict mode)
@@ -3256,7 +3256,7 @@ class SharedValidators {
3256
3256
  static validDateTime(requiredTime = true) {
3257
3257
  return (control) => {
3258
3258
  const value = control.value;
3259
- const date = !value || isMoment(value) ? value : fromDateISOString(value, { strict: false, undefinedIfInvalid: false, requiredTime });
3259
+ const date = !value || isMoment(value) ? value : fromDateISOString(value, { strict: requiredTime, undefinedIfInvalid: false, requiredTime });
3260
3260
  if (date && (!date.isValid() || date.year() < 1900 || (requiredTime && DateUtils.isNoTime(date)))) {
3261
3261
  return { validDate: true };
3262
3262
  }
@@ -17792,10 +17792,10 @@ class AppForm {
17792
17792
  _subscription = new Subscription();
17793
17793
  _form;
17794
17794
  _enabled = false;
17795
- errorTranslator;
17795
+ errorTranslator = inject(FormErrorTranslator);
17796
17796
  i18nFieldPrefix = null;
17797
- translate;
17798
- settings;
17797
+ translate = inject(TranslateService);
17798
+ settings = inject(LocalSettingsService);
17799
17799
  destroySubject = new Subject();
17800
17800
  // TODO use RxState instead ?
17801
17801
  readySubject = new BehaviorSubject(false);
@@ -17878,12 +17878,11 @@ class AppForm {
17878
17878
  }
17879
17879
  onCancel = new EventEmitter();
17880
17880
  onSubmit = new EventEmitter();
17881
- constructor(injector, form) {
17881
+ constructor(formOrInjector, form) {
17882
+ const injector = formOrInjector instanceof Injector ? formOrInjector : undefined;
17883
+ form = formOrInjector instanceof FormGroup ? formOrInjector : form;
17882
17884
  if (form)
17883
17885
  this.setForm(form);
17884
- this.translate = injector.get(TranslateService);
17885
- this.settings = injector.get(LocalSettingsService);
17886
- this.errorTranslator = injector.get(FormErrorTranslator);
17887
17886
  this.autocompleteHelper = new MatAutocompleteConfigHolder(this.settings && {
17888
17887
  getUserAttributes: (a, b) => this.settings.getFieldDisplayAttributes(a, b),
17889
17888
  });
@@ -18097,12 +18096,12 @@ class AppForm {
18097
18096
  }
18098
18097
  }
18099
18098
  }
18100
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AppForm, deps: [{ token: i0.Injector }, { token: i1$3.UntypedFormGroup }], target: i0.ɵɵFactoryTarget.Directive });
18099
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AppForm, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
18101
18100
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.2.14", type: AppForm, inputs: { debug: ["debug", "debug", booleanAttribute], tabindex: ["tabindex", "tabindex", numberAttribute], errorTranslateOptions: "errorTranslateOptions", form: "form" }, outputs: { onCancel: "onCancel", onSubmit: "onSubmit" }, ngImport: i0 });
18102
18101
  }
18103
18102
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: AppForm, decorators: [{
18104
18103
  type: Directive
18105
- }], ctorParameters: () => [{ type: i0.Injector }, { type: i1$3.UntypedFormGroup }], propDecorators: { debug: [{
18104
+ }], ctorParameters: () => [{ type: undefined }, { type: i1$3.UntypedFormGroup }], propDecorators: { debug: [{
18106
18105
  type: Input,
18107
18106
  args: [{ transform: booleanAttribute }]
18108
18107
  }], tabindex: [{
@@ -44805,13 +44804,30 @@ class AppFormContainer {
44805
44804
  throw new Error('Trying to register an undefined child form');
44806
44805
  this._children = this._children || [];
44807
44806
  this._childrenPath = this._childrenPath || [];
44807
+ // Form getter
44808
44808
  if (typeof form === 'function') {
44809
44809
  this._children.push(new AppFormProvider(form));
44810
44810
  this._childrenPath.push(path ?? null);
44811
44811
  }
44812
- else if (!this._children.includes(form)) {
44813
- this._children.push(form);
44814
- this._childrenPath.push(path ?? null);
44812
+ // Form group
44813
+ else if (form instanceof FormGroup) {
44814
+ if (!path || !this._childrenPath.includes(path)) {
44815
+ this._children.push(new AppForm(form));
44816
+ this._childrenPath.push(path ?? null);
44817
+ }
44818
+ else {
44819
+ throw new Error('Trying to register an already registered child form');
44820
+ }
44821
+ }
44822
+ // IAppForm
44823
+ else {
44824
+ if (!this._children.includes(form) && (!path || !this._childrenPath.includes(path))) {
44825
+ this._children.push(form);
44826
+ this._childrenPath.push(path ?? null);
44827
+ }
44828
+ else {
44829
+ throw new Error('Trying to register an already registered child form');
44830
+ }
44815
44831
  }
44816
44832
  }
44817
44833
  addForms(forms) {
@@ -44820,7 +44836,11 @@ class AppFormContainer {
44820
44836
  removeForm(form) {
44821
44837
  if (!form)
44822
44838
  throw new Error('Trying to remove an undefined child form');
44823
- const index = typeof form == 'string' ? (this._childrenPath || []).findIndex((c) => c === form) : (this._children || []).findIndex((c) => c === form);
44839
+ const index = typeof form == 'string'
44840
+ ? (this._childrenPath || []).findIndex((c) => c === form)
44841
+ : (form instanceof FormGroup)
44842
+ ? (this._children || []).findIndex((c) => c['form'] === form)
44843
+ : (this._children || []).findIndex((c) => c === form);
44824
44844
  if (index !== -1) {
44825
44845
  this._childrenPath.splice(index, 1);
44826
44846
  return this._children.splice(index, 1)?.[0];