@indigina/ui-kit 1.1.277 → 1.1.278

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.
@@ -9309,6 +9309,7 @@ class KitCardDetailsComponent {
9309
9309
  skip: 0,
9310
9310
  take: 0,
9311
9311
  }, ...(ngDevMode ? [{ debugName: "dataState" }] : []));
9312
+ this.newCreatedCards = signal([], ...(ngDevMode ? [{ debugName: "newCreatedCards" }] : []));
9312
9313
  this.shouldAppendFetchedData = true;
9313
9314
  }
9314
9315
  ngOnInit() {
@@ -9320,6 +9321,16 @@ class KitCardDetailsComponent {
9320
9321
  this.initSearchSubscription();
9321
9322
  this.initStateFromUrl();
9322
9323
  }
9324
+ get skipNewCreatedCardFilter() {
9325
+ return this.newCreatedCards().length ? {
9326
+ logic: KitFilterLogic.AND,
9327
+ filters: this.newCreatedCards().map(card => ({
9328
+ field: 'id',
9329
+ operator: KitFilterOperator.NEQ,
9330
+ value: card.id,
9331
+ })),
9332
+ } : {};
9333
+ }
9323
9334
  loadMoreData() {
9324
9335
  this.shouldAppendFetchedData = true;
9325
9336
  this.dataState.update(state => ({
@@ -9340,18 +9351,36 @@ class KitCardDetailsComponent {
9340
9351
  ...this.cardData(),
9341
9352
  ...cards,
9342
9353
  ]);
9343
- this.total.set(this.total() + 1);
9354
+ this.newCreatedCards.set([
9355
+ ...this.newCreatedCards(),
9356
+ ...cards,
9357
+ ]);
9358
+ this.dataState.update(state => ({
9359
+ ...state,
9360
+ filters: this.skipNewCreatedCardFilter,
9361
+ }));
9362
+ this.total.set(this.total() + cards.length);
9344
9363
  }
9345
9364
  deleteCard(cardId) {
9346
9365
  this.isLoading.set(true);
9347
9366
  this.cardData.set(this.cardData().filter(card => card.id.toString() !== cardId.toString()));
9348
9367
  this.total.set(this.total() - 1);
9349
9368
  const skip = (this.dataState().skip ?? 0) + 1;
9369
+ if (this.newCreatedCards().some(card => card.id.toString() === cardId.toString())) {
9370
+ this.newCreatedCards.set(this.newCreatedCards().filter(card => card.id.toString() !== cardId.toString()));
9371
+ this.dataState.update(state => ({
9372
+ ...state,
9373
+ filters: this.skipNewCreatedCardFilter,
9374
+ }));
9375
+ this.isLoading.set(false);
9376
+ return;
9377
+ }
9350
9378
  if (skip >= this.total()) {
9379
+ this.isLoading.set(false);
9351
9380
  return;
9352
9381
  }
9353
9382
  this.shouldAppendFetchedData = true;
9354
- this.dataStateChanged.emit({ skip, take: 1 });
9383
+ this.dataStateChanged.emit({ skip, take: 1, filters: this.skipNewCreatedCardFilter, search: this.dataState().search });
9355
9384
  }
9356
9385
  updateSpecificCardData(cardData) {
9357
9386
  this.cardData.set(this.cardData().map(card => {
@@ -9362,8 +9391,9 @@ class KitCardDetailsComponent {
9362
9391
  }));
9363
9392
  }
9364
9393
  initSearchSubscription() {
9365
- this.kitTextboxComponent().changed.pipe(filter(() => !this.isLoading()), debounceTime(500), takeUntilDestroyed(this.destroyRef)).subscribe(searchValue => {
9394
+ this.kitTextboxComponent().changed.pipe(filter(() => !this.isLoading()), debounceTime(500), takeUntilDestroyed(this.destroyRef), map(value => value.trim())).subscribe(searchValue => {
9366
9395
  this.cardData.set([]);
9396
+ this.newCreatedCards.set([]);
9367
9397
  this.dataState.set({ skip: 0, take: this.pageSize(), search: searchValue || undefined });
9368
9398
  this.shouldAppendFetchedData = true;
9369
9399
  this.updateData();
@@ -9399,7 +9429,7 @@ class KitCardDetailsComponent {
9399
9429
  ...this.cardData(),
9400
9430
  ...data.results.data,
9401
9431
  ]);
9402
- this.total.set(data.results.total);
9432
+ this.total.set(data.results.total + this.newCreatedCards().length);
9403
9433
  this.shouldAppendFetchedData = false;
9404
9434
  }
9405
9435
  if (!handledInitialActiveId
@@ -9437,7 +9467,7 @@ class KitCardDetailsComponent {
9437
9467
  setStateToUrl(state) {
9438
9468
  const queryParams = Object.keys(state).reduce((acc, key) => {
9439
9469
  const val = state[key];
9440
- if (val !== undefined) {
9470
+ if (val !== undefined && key !== 'filters') {
9441
9471
  acc[key] = val;
9442
9472
  }
9443
9473
  return acc;