@one-paragon/angular-utilities 2.3.2 → 2.3.4

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 { Input, Directive, inject, Injector, TemplateRef, ViewContainerRef, NgModule, assertInInjectionContext, DestroyRef, signal, computed, isSignal, InjectionToken, Injectable, runInInjectionContext, input, Renderer2, ElementRef, booleanAttribute, Pipe, makeEnvironmentProviders, ChangeDetectionStrategy, Component, HostListener, EventEmitter, untracked, Output, effect, ContentChildren, ChangeDetectorRef, output, viewChild, EnvironmentInjector, createComponent, linkedSignal, contentChild, forwardRef, contentChildren, provideAppInitializer } from '@angular/core';
2
+ import { Input, Directive, inject, Injector, TemplateRef, ViewContainerRef, NgModule, assertInInjectionContext, DestroyRef, signal, computed, isSignal, effect, untracked, InjectionToken, Injectable, runInInjectionContext, input, Renderer2, ElementRef, booleanAttribute, Pipe, makeEnvironmentProviders, ChangeDetectionStrategy, Component, HostListener, EventEmitter, Output, ContentChildren, ChangeDetectorRef, output, viewChild, EnvironmentInjector, createComponent, linkedSignal, contentChild, forwardRef, contentChildren, provideAppInitializer } from '@angular/core';
3
3
  import { shareReplay, map, switchAll, filter, tap, catchError, startWith, switchMap, mergeMap, concatMap as concatMap$1, takeUntil, distinctUntilChanged, debounceTime } from 'rxjs/operators';
4
4
  import * as i1 from 'rxjs';
5
5
  import { isObservable, Subject, of, ReplaySubject, filter as filter$1, first, map as map$1, Observable, combineLatest, Subscription, startWith as startWith$1, pairwise, pipe, concatMap, merge, delay, fromEvent, takeUntil as takeUntil$1, tap as tap$1, switchMap as switchMap$1, scan, timestamp } from 'rxjs';
@@ -594,6 +594,10 @@ class RequestStateStore {
594
594
  * @deprecated use the standalone subscriber helper function
595
595
  */
596
596
  this.on = this.subscriber;
597
+ /**
598
+ * @param params An observable or signal that returns an array to be spread into the request function.
599
+ * If undefined is returned, the request will not be made.
600
+ */
597
601
  this.requestWith = (params) => {
598
602
  if (isSignal(params)) {
599
603
  params = toObservable(params, { injector: this.injector }).pipe(notNull());
@@ -601,6 +605,32 @@ class RequestStateStore {
601
605
  params.pipe(takeUntil(this.destroy$)).subscribe((p) => this.request(...p));
602
606
  return this;
603
607
  };
608
+ /**
609
+ * @param params The parameters to be passed to the request function.
610
+ * The parameters can be either actual values or wrapped in a signal.
611
+ * If any of the parameters are a signal, it will be unwrapped and passed to the request.
612
+ * It will be tracked and the request will be made whenever its value changes.
613
+ * If any of the signals return undefined, the request will not be made.
614
+ */
615
+ this.requestOn = (...params) => {
616
+ const paramsArr = computed(() => {
617
+ const p = params.map(param => isSignal(param)
618
+ ? ({ param, isSignal: true })
619
+ : ({ param, isSignal: false }));
620
+ const allVals = p.every(({ param, isSignal }) => !isSignal || param() != undefined);
621
+ if (allVals)
622
+ return p.map(({ param, isSignal }) => isSignal ? param() : param);
623
+ return undefined;
624
+ });
625
+ effect(() => {
626
+ const vals = paramsArr();
627
+ untracked(() => {
628
+ if (vals)
629
+ this.request(...vals);
630
+ });
631
+ }, { injector: this.injector });
632
+ return this;
633
+ };
604
634
  this.assertInjectionContext();
605
635
  this.injector.get(DestroyRef).onDestroy(() => this.destroy$.next());
606
636
  this.project = project;
@@ -688,6 +718,7 @@ class RequestStateStore {
688
718
  class CancellationToken {
689
719
  }
690
720
  /**
721
+ * @param sigOrObs An array of signals or observables to be wrapped in an array to be spread into the request function.
691
722
  * If any values from the array of signals or observables are null or undefined, all values will be filtered
692
723
  */
693
724
  function wrapInArr(...sigOrObs) {
@@ -2235,7 +2266,6 @@ class TableStore extends ComponentStore {
2235
2266
  delete newState.userDefined.headerHeight;
2236
2267
  return newState;
2237
2268
  }
2238
- return newState;
2239
2269
  });
2240
2270
  this.updateStateFromPersistedState = this.updater((state, persistedState) => {
2241
2271
  const incomingTableState = cleanPersistedState(state, persistedState);
@@ -2426,6 +2456,16 @@ class TableStore extends ComponentStore {
2426
2456
  this.setLinkMaps = this.updater((state, maps) => {
2427
2457
  return ({ ...state, linkMaps: maps });
2428
2458
  });
2459
+ this.updateRowProps = this.updater((state, updates) => {
2460
+ const notPersistedTableSettings = merge$1(new NotPersistedTableSettings(), (state.notPersistedTableSettings));
2461
+ if (updates.rowClasses)
2462
+ notPersistedTableSettings.rowClasses = updates.rowClasses;
2463
+ if (updates.rowClick)
2464
+ notPersistedTableSettings.rowClick = updates.rowClick;
2465
+ if (updates.rowStyles)
2466
+ notPersistedTableSettings.rowStyles = updates.rowStyles;
2467
+ return ({ ...state, notPersistedTableSettings });
2468
+ });
2429
2469
  this.on = (srcObservable, func) => {
2430
2470
  this.effect(() => srcObservable.pipe(tap(func)));
2431
2471
  return this;