@wise/dynamic-flow-client 4.3.9 → 4.3.11

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.
package/build/main.js CHANGED
@@ -2448,7 +2448,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
2448
2448
  return submission;
2449
2449
  }
2450
2450
  const newAbortController = abortAndResetController(abortController);
2451
- if (isNullish(currentValue)) {
2451
+ if (isNullish(currentValue) || currentValue === "") {
2452
2452
  const resolvedNull = Promise.resolve(null);
2453
2453
  update((draft) => {
2454
2454
  draft.persistedState.abortController = newAbortController;
@@ -2563,9 +2563,17 @@ var debounce = (callback, waitMs) => {
2563
2563
  clearTimer();
2564
2564
  }
2565
2565
  };
2566
+ debouncedFn.isPending = () => timeoutId !== null;
2566
2567
  return debouncedFn;
2567
2568
  };
2568
2569
 
2570
+ // src/revamp/domain/components/utils/isOrWasValid.ts
2571
+ var isOrWasValid = (getErrors, previous, current) => {
2572
+ const wasValid = getErrors(previous).length === 0 && previous !== null;
2573
+ const isValid = getErrors(current).length === 0;
2574
+ return wasValid || isValid;
2575
+ };
2576
+
2569
2577
  // src/revamp/domain/features/refresh/getPerformRefresh.ts
2570
2578
  var getPerformRefresh = (schema, onRefresh) => {
2571
2579
  var _a, _b;
@@ -2578,7 +2586,21 @@ var getPerformRefresh = (schema, onRefresh) => {
2578
2586
  }
2579
2587
  return void 0;
2580
2588
  };
2581
- var getDebouncedPerformRefresh = (performRefresh) => performRefresh ? debounce(performRefresh, 1e3) : void 0;
2589
+ var getDebouncedPerformRefresh = (performRefresh, getValidationErrors) => {
2590
+ if (!performRefresh) {
2591
+ return void 0;
2592
+ }
2593
+ const performDebouncedRefresh = debounce(performRefresh, 1e3);
2594
+ const debouncedFn = (prevValue, updatedValue) => {
2595
+ if (isOrWasValid(getValidationErrors, prevValue, updatedValue) || (performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.isPending())) {
2596
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
2597
+ }
2598
+ };
2599
+ debouncedFn.flush = () => performDebouncedRefresh.flush();
2600
+ debouncedFn.cancel = () => performDebouncedRefresh.cancel();
2601
+ debouncedFn.isPending = () => performDebouncedRefresh.isPending();
2602
+ return debouncedFn;
2603
+ };
2582
2604
 
2583
2605
  // src/revamp/domain/features/validationAsync/getComponentValidationAsync.ts
2584
2606
  var getComponentValidationAsync = (update, performValidationAsync) => (
@@ -2587,10 +2609,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2587
2609
  * the description or set errors when the request completes.
2588
2610
  */
2589
2611
  async (validationAsyncState, currentValue) => {
2590
- const { abortController, lastSubmitted } = validationAsyncState;
2591
- if (lastSubmitted === currentValue) {
2592
- return;
2593
- }
2612
+ const { abortController } = validationAsyncState;
2594
2613
  const newAbortController = abortAndResetController(abortController);
2595
2614
  if (isNullish(currentValue)) {
2596
2615
  update((draft) => {
@@ -2628,9 +2647,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2628
2647
  return newSubmission;
2629
2648
  }
2630
2649
  );
2631
-
2632
- // src/revamp/domain/components/utils/isOrWasValid.ts
2633
- var isOrWasValid = (getErrors, previous, current) => getErrors(previous).length === 0 || getErrors(current).length === 0;
2650
+ var getDebouncedComponentValidationAsync = (update, performValidationAsync) => debounce(getComponentValidationAsync(update, performValidationAsync), 1e3);
2634
2651
 
2635
2652
  // src/revamp/domain/components/NumberInputComponent.ts
2636
2653
  var createNumberInputComponent = (numberInputProps, updateComponent) => {
@@ -2653,9 +2670,9 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2653
2670
  "onValueChange",
2654
2671
  "summariser"
2655
2672
  ]);
2656
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
2657
2673
  const update = getInputUpdateFunction(uid, updateComponent);
2658
2674
  const getValidationErrors = getLocalValueValidator(checks);
2675
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
2659
2676
  const getAndSetValidationErrors = (currentValue) => {
2660
2677
  const messages = getValidationErrors(currentValue);
2661
2678
  update((draft) => {
@@ -2681,9 +2698,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2681
2698
  draft.validationAsyncState.messages = {};
2682
2699
  draft.value = updatedValue;
2683
2700
  });
2684
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
2685
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
2686
- }
2701
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
2687
2702
  onValueChange();
2688
2703
  },
2689
2704
  async getSubmittableValue() {
@@ -2725,12 +2740,17 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2725
2740
  });
2726
2741
  }
2727
2742
  if (performValidationAsync) {
2728
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
2743
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
2729
2744
  return __spreadProps(__spreadValues({}, numberComponent), {
2730
2745
  onBlur() {
2731
2746
  if (this.validate()) {
2732
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
2733
- });
2747
+ validateAsync.flush();
2748
+ }
2749
+ },
2750
+ onChange(updatedValue) {
2751
+ numberComponent.onChange.call(this, updatedValue);
2752
+ if (getValidationErrors(updatedValue).length === 0) {
2753
+ validateAsync(this.validationAsyncState, updatedValue);
2734
2754
  }
2735
2755
  }
2736
2756
  });
@@ -2807,7 +2827,7 @@ var getAboveMaxLengthCheck = ({ maxLength }, messageFunctions) => (value) => {
2807
2827
  return null;
2808
2828
  };
2809
2829
  var getBelowMinLengthCheck = ({ minLength }, messageFunctions) => (value) => {
2810
- if (isNumber(minLength) && isString(value) && value.length < minLength) {
2830
+ if (isNumber(minLength) && isString(value) && value && value.length < minLength) {
2811
2831
  return messageFunctions.minLength(minLength);
2812
2832
  }
2813
2833
  return null;
@@ -2831,7 +2851,7 @@ var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
2831
2851
  return null;
2832
2852
  };
2833
2853
  var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
2834
- if (isString(minimum) && isString(value) && value < minimum) {
2854
+ if (isString(minimum) && isString(value) && value && value < minimum) {
2835
2855
  return messageFunctions.minimumDate(minimum);
2836
2856
  }
2837
2857
  return null;
@@ -2839,7 +2859,7 @@ var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
2839
2859
  var getNotAdheringToPatternCheck = ({ pattern }, messageFunctions, options) => {
2840
2860
  validateStringPattern(pattern, options == null ? void 0 : options.logEvent);
2841
2861
  return (value) => {
2842
- if (isString(pattern) && isString(value)) {
2862
+ if (isString(pattern) && isString(value) && value) {
2843
2863
  return new RegExp(pattern).test(value) ? null : messageFunctions.pattern();
2844
2864
  }
2845
2865
  return null;
@@ -3445,9 +3465,9 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3445
3465
  "onValueChange",
3446
3466
  "summariser"
3447
3467
  ]);
3448
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
3449
3468
  const update = getInputUpdateFunction(uid, updateComponent);
3450
3469
  const getValidationErrors = getLocalValueValidator(checks);
3470
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
3451
3471
  const getAndSetValidationErrors = (currentValue) => {
3452
3472
  const messages = getValidationErrors(currentValue);
3453
3473
  update((draft) => {
@@ -3474,9 +3494,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3474
3494
  draft.validationAsyncState.messages = {};
3475
3495
  draft.value = updatedValue;
3476
3496
  });
3477
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
3478
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
3479
- }
3497
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
3480
3498
  onValueChange();
3481
3499
  },
3482
3500
  async getSubmittableValue() {
@@ -3518,12 +3536,17 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3518
3536
  });
3519
3537
  }
3520
3538
  if (performValidationAsync) {
3521
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
3539
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
3522
3540
  return __spreadProps(__spreadValues({}, integerComponent), {
3523
3541
  onBlur() {
3524
3542
  if (this.validate()) {
3525
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
3526
- });
3543
+ validateAsync.flush();
3544
+ }
3545
+ },
3546
+ onChange(updatedValue) {
3547
+ integerComponent.onChange.call(this, updatedValue);
3548
+ if (getValidationErrors(updatedValue).length === 0) {
3549
+ validateAsync(this.validationAsyncState, updatedValue);
3527
3550
  }
3528
3551
  }
3529
3552
  });
@@ -4078,9 +4101,9 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4078
4101
  "summariser",
4079
4102
  "value"
4080
4103
  ]);
4081
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
4082
4104
  const update = getInputUpdateFunction(uid, updateComponent);
4083
4105
  const getValidationErrors = getLocalValueValidator(checks);
4106
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
4084
4107
  const getAndSetValidationErrors = (currentValue) => {
4085
4108
  const messages = getValidationErrors(currentValue);
4086
4109
  update((draft) => {
@@ -4107,9 +4130,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4107
4130
  draft.validationAsyncState.messages = {};
4108
4131
  draft.value = updatedValue;
4109
4132
  });
4110
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
4111
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
4112
- }
4133
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
4113
4134
  onValueChange();
4114
4135
  },
4115
4136
  async getSubmittableValue() {
@@ -4151,12 +4172,17 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4151
4172
  });
4152
4173
  }
4153
4174
  if (performValidationAsync) {
4154
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4175
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
4155
4176
  return __spreadProps(__spreadValues({}, inputComponent), {
4156
4177
  onBlur() {
4157
4178
  if (this.validate()) {
4158
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
4159
- });
4179
+ validateAsync.flush();
4180
+ }
4181
+ },
4182
+ onChange(updatedValue) {
4183
+ inputComponent.onChange.call(this, updatedValue);
4184
+ if (getValidationErrors(updatedValue).length === 0) {
4185
+ validateAsync(this.validationAsyncState, updatedValue);
4160
4186
  }
4161
4187
  }
4162
4188
  });
@@ -7093,8 +7119,8 @@ var isTouchScreen = (navigator2 = window.navigator, matchMedia = window.matchMed
7093
7119
 
7094
7120
  // src/common/utils/debounce.ts
7095
7121
  var debounce2 = (callback, waitMs) => {
7096
- let timeoutId;
7097
- let lastArgs;
7122
+ let timeoutId = null;
7123
+ let lastArgs = null;
7098
7124
  const clearTimer = () => {
7099
7125
  if (timeoutId) {
7100
7126
  clearTimeout(timeoutId);
package/build/main.mjs CHANGED
@@ -2405,7 +2405,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
2405
2405
  return submission;
2406
2406
  }
2407
2407
  const newAbortController = abortAndResetController(abortController);
2408
- if (isNullish(currentValue)) {
2408
+ if (isNullish(currentValue) || currentValue === "") {
2409
2409
  const resolvedNull = Promise.resolve(null);
2410
2410
  update((draft) => {
2411
2411
  draft.persistedState.abortController = newAbortController;
@@ -2520,9 +2520,17 @@ var debounce = (callback, waitMs) => {
2520
2520
  clearTimer();
2521
2521
  }
2522
2522
  };
2523
+ debouncedFn.isPending = () => timeoutId !== null;
2523
2524
  return debouncedFn;
2524
2525
  };
2525
2526
 
2527
+ // src/revamp/domain/components/utils/isOrWasValid.ts
2528
+ var isOrWasValid = (getErrors, previous, current) => {
2529
+ const wasValid = getErrors(previous).length === 0 && previous !== null;
2530
+ const isValid = getErrors(current).length === 0;
2531
+ return wasValid || isValid;
2532
+ };
2533
+
2526
2534
  // src/revamp/domain/features/refresh/getPerformRefresh.ts
2527
2535
  var getPerformRefresh = (schema, onRefresh) => {
2528
2536
  var _a, _b;
@@ -2535,7 +2543,21 @@ var getPerformRefresh = (schema, onRefresh) => {
2535
2543
  }
2536
2544
  return void 0;
2537
2545
  };
2538
- var getDebouncedPerformRefresh = (performRefresh) => performRefresh ? debounce(performRefresh, 1e3) : void 0;
2546
+ var getDebouncedPerformRefresh = (performRefresh, getValidationErrors) => {
2547
+ if (!performRefresh) {
2548
+ return void 0;
2549
+ }
2550
+ const performDebouncedRefresh = debounce(performRefresh, 1e3);
2551
+ const debouncedFn = (prevValue, updatedValue) => {
2552
+ if (isOrWasValid(getValidationErrors, prevValue, updatedValue) || (performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.isPending())) {
2553
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
2554
+ }
2555
+ };
2556
+ debouncedFn.flush = () => performDebouncedRefresh.flush();
2557
+ debouncedFn.cancel = () => performDebouncedRefresh.cancel();
2558
+ debouncedFn.isPending = () => performDebouncedRefresh.isPending();
2559
+ return debouncedFn;
2560
+ };
2539
2561
 
2540
2562
  // src/revamp/domain/features/validationAsync/getComponentValidationAsync.ts
2541
2563
  var getComponentValidationAsync = (update, performValidationAsync) => (
@@ -2544,10 +2566,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2544
2566
  * the description or set errors when the request completes.
2545
2567
  */
2546
2568
  async (validationAsyncState, currentValue) => {
2547
- const { abortController, lastSubmitted } = validationAsyncState;
2548
- if (lastSubmitted === currentValue) {
2549
- return;
2550
- }
2569
+ const { abortController } = validationAsyncState;
2551
2570
  const newAbortController = abortAndResetController(abortController);
2552
2571
  if (isNullish(currentValue)) {
2553
2572
  update((draft) => {
@@ -2585,9 +2604,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2585
2604
  return newSubmission;
2586
2605
  }
2587
2606
  );
2588
-
2589
- // src/revamp/domain/components/utils/isOrWasValid.ts
2590
- var isOrWasValid = (getErrors, previous, current) => getErrors(previous).length === 0 || getErrors(current).length === 0;
2607
+ var getDebouncedComponentValidationAsync = (update, performValidationAsync) => debounce(getComponentValidationAsync(update, performValidationAsync), 1e3);
2591
2608
 
2592
2609
  // src/revamp/domain/components/NumberInputComponent.ts
2593
2610
  var createNumberInputComponent = (numberInputProps, updateComponent) => {
@@ -2610,9 +2627,9 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2610
2627
  "onValueChange",
2611
2628
  "summariser"
2612
2629
  ]);
2613
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
2614
2630
  const update = getInputUpdateFunction(uid, updateComponent);
2615
2631
  const getValidationErrors = getLocalValueValidator(checks);
2632
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
2616
2633
  const getAndSetValidationErrors = (currentValue) => {
2617
2634
  const messages = getValidationErrors(currentValue);
2618
2635
  update((draft) => {
@@ -2638,9 +2655,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2638
2655
  draft.validationAsyncState.messages = {};
2639
2656
  draft.value = updatedValue;
2640
2657
  });
2641
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
2642
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
2643
- }
2658
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
2644
2659
  onValueChange();
2645
2660
  },
2646
2661
  async getSubmittableValue() {
@@ -2682,12 +2697,17 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2682
2697
  });
2683
2698
  }
2684
2699
  if (performValidationAsync) {
2685
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
2700
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
2686
2701
  return __spreadProps(__spreadValues({}, numberComponent), {
2687
2702
  onBlur() {
2688
2703
  if (this.validate()) {
2689
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
2690
- });
2704
+ validateAsync.flush();
2705
+ }
2706
+ },
2707
+ onChange(updatedValue) {
2708
+ numberComponent.onChange.call(this, updatedValue);
2709
+ if (getValidationErrors(updatedValue).length === 0) {
2710
+ validateAsync(this.validationAsyncState, updatedValue);
2691
2711
  }
2692
2712
  }
2693
2713
  });
@@ -2764,7 +2784,7 @@ var getAboveMaxLengthCheck = ({ maxLength }, messageFunctions) => (value) => {
2764
2784
  return null;
2765
2785
  };
2766
2786
  var getBelowMinLengthCheck = ({ minLength }, messageFunctions) => (value) => {
2767
- if (isNumber(minLength) && isString(value) && value.length < minLength) {
2787
+ if (isNumber(minLength) && isString(value) && value && value.length < minLength) {
2768
2788
  return messageFunctions.minLength(minLength);
2769
2789
  }
2770
2790
  return null;
@@ -2788,7 +2808,7 @@ var getAboveMaximumDateCheck = ({ maximum }, messageFunctions) => (value) => {
2788
2808
  return null;
2789
2809
  };
2790
2810
  var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
2791
- if (isString(minimum) && isString(value) && value < minimum) {
2811
+ if (isString(minimum) && isString(value) && value && value < minimum) {
2792
2812
  return messageFunctions.minimumDate(minimum);
2793
2813
  }
2794
2814
  return null;
@@ -2796,7 +2816,7 @@ var getBelowMinimumDateCheck = ({ minimum }, messageFunctions) => (value) => {
2796
2816
  var getNotAdheringToPatternCheck = ({ pattern }, messageFunctions, options) => {
2797
2817
  validateStringPattern(pattern, options == null ? void 0 : options.logEvent);
2798
2818
  return (value) => {
2799
- if (isString(pattern) && isString(value)) {
2819
+ if (isString(pattern) && isString(value) && value) {
2800
2820
  return new RegExp(pattern).test(value) ? null : messageFunctions.pattern();
2801
2821
  }
2802
2822
  return null;
@@ -3402,9 +3422,9 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3402
3422
  "onValueChange",
3403
3423
  "summariser"
3404
3424
  ]);
3405
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
3406
3425
  const update = getInputUpdateFunction(uid, updateComponent);
3407
3426
  const getValidationErrors = getLocalValueValidator(checks);
3427
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
3408
3428
  const getAndSetValidationErrors = (currentValue) => {
3409
3429
  const messages = getValidationErrors(currentValue);
3410
3430
  update((draft) => {
@@ -3431,9 +3451,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3431
3451
  draft.validationAsyncState.messages = {};
3432
3452
  draft.value = updatedValue;
3433
3453
  });
3434
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
3435
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
3436
- }
3454
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
3437
3455
  onValueChange();
3438
3456
  },
3439
3457
  async getSubmittableValue() {
@@ -3475,12 +3493,17 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3475
3493
  });
3476
3494
  }
3477
3495
  if (performValidationAsync) {
3478
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
3496
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
3479
3497
  return __spreadProps(__spreadValues({}, integerComponent), {
3480
3498
  onBlur() {
3481
3499
  if (this.validate()) {
3482
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
3483
- });
3500
+ validateAsync.flush();
3501
+ }
3502
+ },
3503
+ onChange(updatedValue) {
3504
+ integerComponent.onChange.call(this, updatedValue);
3505
+ if (getValidationErrors(updatedValue).length === 0) {
3506
+ validateAsync(this.validationAsyncState, updatedValue);
3484
3507
  }
3485
3508
  }
3486
3509
  });
@@ -4035,9 +4058,9 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4035
4058
  "summariser",
4036
4059
  "value"
4037
4060
  ]);
4038
- const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh);
4039
4061
  const update = getInputUpdateFunction(uid, updateComponent);
4040
4062
  const getValidationErrors = getLocalValueValidator(checks);
4063
+ const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
4041
4064
  const getAndSetValidationErrors = (currentValue) => {
4042
4065
  const messages = getValidationErrors(currentValue);
4043
4066
  update((draft) => {
@@ -4064,9 +4087,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4064
4087
  draft.validationAsyncState.messages = {};
4065
4088
  draft.value = updatedValue;
4066
4089
  });
4067
- if (isOrWasValid(getValidationErrors, prevValue, updatedValue)) {
4068
- performDebouncedRefresh == null ? void 0 : performDebouncedRefresh();
4069
- }
4090
+ performDebouncedRefresh == null ? void 0 : performDebouncedRefresh(prevValue, updatedValue);
4070
4091
  onValueChange();
4071
4092
  },
4072
4093
  async getSubmittableValue() {
@@ -4108,12 +4129,17 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4108
4129
  });
4109
4130
  }
4110
4131
  if (performValidationAsync) {
4111
- const validateAsync = getComponentValidationAsync(update, performValidationAsync);
4132
+ const validateAsync = getDebouncedComponentValidationAsync(update, performValidationAsync);
4112
4133
  return __spreadProps(__spreadValues({}, inputComponent), {
4113
4134
  onBlur() {
4114
4135
  if (this.validate()) {
4115
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
4116
- });
4136
+ validateAsync.flush();
4137
+ }
4138
+ },
4139
+ onChange(updatedValue) {
4140
+ inputComponent.onChange.call(this, updatedValue);
4141
+ if (getValidationErrors(updatedValue).length === 0) {
4142
+ validateAsync(this.validationAsyncState, updatedValue);
4117
4143
  }
4118
4144
  }
4119
4145
  });
@@ -7050,8 +7076,8 @@ var isTouchScreen = (navigator2 = window.navigator, matchMedia = window.matchMed
7050
7076
 
7051
7077
  // src/common/utils/debounce.ts
7052
7078
  var debounce2 = (callback, waitMs) => {
7053
- let timeoutId;
7054
- let lastArgs;
7079
+ let timeoutId = null;
7080
+ let lastArgs = null;
7055
7081
  const clearTimer = () => {
7056
7082
  if (timeoutId) {
7057
7083
  clearTimeout(timeoutId);
@@ -2,5 +2,6 @@ export interface DebouncedFunc<T extends (...args: Parameters<T>) => ReturnType<
2
2
  (...args: Parameters<T>): void;
3
3
  cancel: () => void;
4
4
  flush: () => void;
5
+ isPending: () => boolean;
5
6
  }
6
7
  export declare const debounce: <T extends (...args: Parameters<T>) => ReturnType<T>>(callback: T, waitMs: number) => DebouncedFunc<T>;
@@ -1,5 +1,12 @@
1
1
  import type { Schema } from '@wise/dynamic-flow-types/build/next';
2
- import type { OnRefresh } from '../../types';
2
+ import type { LocalValue, OnRefresh } from '../../types';
3
3
  export type PerformRefresh = () => void;
4
4
  export declare const getPerformRefresh: (schema: Schema, onRefresh: OnRefresh) => PerformRefresh | undefined;
5
- export declare const getDebouncedPerformRefresh: (performRefresh: PerformRefresh | undefined) => import("../../components/utils/debounce").DebouncedFunc<PerformRefresh> | undefined;
5
+ type DebouncedPerformRefresh<V extends LocalValue> = {
6
+ (prevValue: V, updatedValue: V): void;
7
+ cancel: () => void;
8
+ flush: () => void;
9
+ isPending: () => boolean;
10
+ };
11
+ export declare const getDebouncedPerformRefresh: <V extends LocalValue>(performRefresh: PerformRefresh | undefined, getValidationErrors: (value: V) => string[]) => DebouncedPerformRefresh<V> | undefined;
12
+ export {};
@@ -12,4 +12,5 @@ type Validatable = BooleanInputComponent | DateInputComponent | IntegerInputComp
12
12
  * Creates an onValidateAsync handler for a component.
13
13
  */
14
14
  export declare const getComponentValidationAsync: (update: ReturnType<typeof getInputUpdateFunction<Validatable>>, performValidationAsync: PerformValidationAsync) => (validationAsyncState: ValidationAsyncState, currentValue: LocalValue) => Promise<string | null | undefined>;
15
+ export declare const getDebouncedComponentValidationAsync: (update: ReturnType<typeof getInputUpdateFunction<Validatable>>, performValidationAsync: PerformValidationAsync) => import("../../components/utils/debounce").DebouncedFunc<(validationAsyncState: ValidationAsyncState, currentValue: LocalValue) => Promise<string | null | undefined>>;
15
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",