@piying-lib/angular-daisyui 1.1.1 → 1.1.3

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.
@@ -189,7 +189,7 @@ declare class SortService {
189
189
  #private;
190
190
  value$$: rxjs.Observable<SortList>;
191
191
  multiple: _angular_core.WritableSignal<boolean>;
192
- sortList: _angular_core.WritableSignal<string[]>;
192
+ sortList: _angular_core.WritableSignal<string[] | undefined>;
193
193
  /** 设置初始值 */
194
194
  setInitValue(object: Record<string, SortDirection>): void;
195
195
  update(key: string, direction: SortDirection): void;
@@ -293,9 +293,10 @@ declare class CheckboxService<D = any> {
293
293
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<CheckboxService<any>>;
294
294
  }
295
295
 
296
- type RequestFn = ((input: any) => Promise<[number, any[]]> | [number, any[]]) | undefined;
296
+ type RequestFn = ((input: any, needUpdate: boolean) => Promise<[number, any[]]> | [number, any[]]) | undefined;
297
297
  declare class TableResourceService {
298
298
  #private;
299
+ EMPTY_VALUE: (number | never[])[];
299
300
  list$$: _angular_core.Signal<unknown>;
300
301
  count$$: _angular_core.Signal<unknown>;
301
302
  isLoading$$: _angular_core.Signal<boolean>;
@@ -339,7 +339,7 @@ class SortService {
339
339
  })
340
340
  .filter(Boolean)), takeUntilDestroyed(), shareReplay(1));
341
341
  multiple = signal(true, ...(ngDevMode ? [{ debugName: "multiple" }] : []));
342
- sortList = signal([], ...(ngDevMode ? [{ debugName: "sortList" }] : []));
342
+ sortList = signal(undefined, ...(ngDevMode ? [{ debugName: "sortList" }] : []));
343
343
  /** 设置初始值 */
344
344
  setInitValue(object) {
345
345
  this.#restore$.next(object);
@@ -675,13 +675,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
675
675
  }] } });
676
676
 
677
677
  class TableResourceService {
678
+ EMPTY_VALUE = [0, []];
678
679
  #requestFn$ = signal(undefined, ...(ngDevMode ? [{ debugName: "#requestFn$" }] : []));
679
680
  #queryParams$ = signal({}, ...(ngDevMode ? [{ debugName: "#queryParams$" }] : []));
680
681
  #data$ = resource({
681
682
  params: computed(() => {
682
683
  const params = this.#queryParams$();
683
684
  let requestFn = this.#requestFn$();
684
- this.#updateIndex$();
685
685
  return {
686
686
  requestFn,
687
687
  params,
@@ -689,10 +689,14 @@ class TableResourceService {
689
689
  };
690
690
  }),
691
691
  loader: async (res) => {
692
+ let needUpdate = res.params.index !== this.#preUpdateIndex$();
693
+ if (needUpdate) {
694
+ this.#preUpdateIndex$.set(res.params.index);
695
+ }
692
696
  if (!res.params.requestFn) {
693
- return [0, []];
697
+ return this.EMPTY_VALUE;
694
698
  }
695
- return res.params.requestFn(res.params.params);
699
+ return res.params.requestFn(res.params.params, needUpdate);
696
700
  },
697
701
  });
698
702
  list$$ = computedWithPrev((value) => {
@@ -705,6 +709,7 @@ class TableResourceService {
705
709
  return this.#data$.isLoading();
706
710
  }, ...(ngDevMode ? [{ debugName: "isLoading$$" }] : []));
707
711
  #updateIndex$ = signal(0, ...(ngDevMode ? [{ debugName: "#updateIndex$" }] : []));
712
+ #preUpdateIndex$ = signal(0, ...(ngDevMode ? [{ debugName: "#preUpdateIndex$" }] : []));
708
713
  needUpdate() {
709
714
  this.#updateIndex$.update((a) => ++a);
710
715
  }