@wise/dynamic-flow-client 4.3.13 → 4.3.14

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
@@ -1159,7 +1159,6 @@ var getRenderFunction = (renderers) => {
1159
1159
  };
1160
1160
 
1161
1161
  // src/revamp/utils/type-utils.ts
1162
- var hasChildren = (component) => "getChildren" in component && typeof component.getChildren === "function";
1163
1162
  var isHiddenComponent = (component) => "hidden" in component && component.hidden;
1164
1163
  var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
1165
1164
  var isArrayLocalValue = (value) => Array.isArray(value);
@@ -1813,47 +1812,67 @@ var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
1813
1812
  var import_react3 = require("react");
1814
1813
  var import_react_intl7 = require("react-intl");
1815
1814
 
1815
+ // src/revamp/domain/components/utils/component-utils.ts
1816
+ var getInputUpdateFunction = (updateComponent) => {
1817
+ return (component, updateFn) => {
1818
+ updateFn(component);
1819
+ updateComponent();
1820
+ };
1821
+ };
1822
+
1816
1823
  // src/revamp/domain/components/RootDomainComponent.ts
1817
- var createRootDomainComponent = () => ({
1818
- type: "root",
1819
- uid: "root",
1820
- stepComponent: null,
1821
- getChildren() {
1822
- return this.stepComponent ? [this.stepComponent] : [];
1823
- },
1824
- getLocalValue() {
1825
- return this.stepComponent ? this.stepComponent.getLocalValue() : null;
1826
- },
1827
- async getSubmittableValue() {
1828
- return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
1829
- },
1830
- getSubmittableValueSync() {
1831
- return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
1832
- },
1833
- getSummary() {
1834
- return this.stepComponent ? this.stepComponent.getSummary() : {};
1835
- },
1836
- validate() {
1837
- return this.stepComponent ? this.stepComponent.validate() : false;
1838
- },
1839
- setLoadingState(loadingState) {
1840
- var _a;
1841
- (_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
1842
- },
1843
- getLoadingState() {
1844
- return this.stepComponent ? this.stepComponent.loadingState : "initial";
1845
- },
1846
- getTrackEvent() {
1847
- return this.stepComponent ? this.stepComponent.trackEvent : null;
1848
- },
1849
- hasStep() {
1850
- return Boolean(this.stepComponent);
1851
- },
1852
- stop() {
1853
- var _a;
1854
- (_a = this.stepComponent) == null ? void 0 : _a.stop();
1855
- }
1856
- });
1824
+ var createRootDomainComponent = (updateComponent) => {
1825
+ const update = getInputUpdateFunction(updateComponent);
1826
+ const rootComponent = {
1827
+ type: "root",
1828
+ uid: "root",
1829
+ stepComponent: null,
1830
+ _update(updateFn) {
1831
+ update(this, updateFn);
1832
+ },
1833
+ getChildren() {
1834
+ return this.stepComponent ? [this.stepComponent] : [];
1835
+ },
1836
+ getLocalValue() {
1837
+ return this.stepComponent ? this.stepComponent.getLocalValue() : null;
1838
+ },
1839
+ async getSubmittableValue() {
1840
+ return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
1841
+ },
1842
+ getSubmittableValueSync() {
1843
+ return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
1844
+ },
1845
+ getSummary() {
1846
+ return this.stepComponent ? this.stepComponent.getSummary() : {};
1847
+ },
1848
+ validate() {
1849
+ return this.stepComponent ? this.stepComponent.validate() : false;
1850
+ },
1851
+ setLoadingState(loadingState) {
1852
+ var _a;
1853
+ (_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
1854
+ },
1855
+ getLoadingState() {
1856
+ return this.stepComponent ? this.stepComponent.loadingState : "initial";
1857
+ },
1858
+ getTrackEvent() {
1859
+ return this.stepComponent ? this.stepComponent.trackEvent : null;
1860
+ },
1861
+ hasStep() {
1862
+ return Boolean(this.stepComponent);
1863
+ },
1864
+ stop() {
1865
+ var _a;
1866
+ (_a = this.stepComponent) == null ? void 0 : _a.stop();
1867
+ },
1868
+ setStep(stepComponent) {
1869
+ this._update((draft) => {
1870
+ draft.stepComponent = stepComponent;
1871
+ });
1872
+ }
1873
+ };
1874
+ return rootComponent;
1875
+ };
1857
1876
 
1858
1877
  // src/revamp/utils/component-utils.ts
1859
1878
  var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
@@ -1926,22 +1945,17 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
1926
1945
  var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
1927
1946
  var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
1928
1947
 
1929
- // src/revamp/domain/components/utils/component-utils.ts
1930
- var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
1931
- updateComponent(uid, (draft) => {
1932
- const draftState = draft;
1933
- updateFn(draftState);
1934
- });
1935
- };
1936
-
1937
1948
  // src/revamp/domain/components/StepDomainComponent.ts
1938
1949
  var createStepComponent = (stepProps) => {
1939
1950
  const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
1940
- const update = getInputUpdateFunction(uid, updateComponent);
1941
- return __spreadProps(__spreadValues({
1951
+ const update = getInputUpdateFunction(updateComponent);
1952
+ const component = __spreadProps(__spreadValues({
1942
1953
  uid
1943
1954
  }, rest), {
1944
1955
  type: "step",
1956
+ _update(updateFn) {
1957
+ update(this, updateFn);
1958
+ },
1945
1959
  getChildren() {
1946
1960
  return this.components;
1947
1961
  },
@@ -1961,7 +1975,7 @@ var createStepComponent = (stepProps) => {
1961
1975
  return validateComponents(this.getChildren());
1962
1976
  },
1963
1977
  setLoadingState(loadingState) {
1964
- update((draft) => {
1978
+ this._update((draft) => {
1965
1979
  draft.loadingState = loadingState;
1966
1980
  });
1967
1981
  },
@@ -1970,6 +1984,7 @@ var createStepComponent = (stepProps) => {
1970
1984
  stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
1971
1985
  }
1972
1986
  });
1987
+ return component;
1973
1988
  };
1974
1989
 
1975
1990
  // src/revamp/domain/mappers/utils/behavior-utils.ts
@@ -2393,6 +2408,22 @@ var createDividerComponent = (props) => __spreadProps(__spreadValues({
2393
2408
  // src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
2394
2409
  var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
2395
2410
 
2411
+ // src/revamp/domain/components/utils/getRandomId.ts
2412
+ var getRandomId = () => Math.random().toString(36).substring(2);
2413
+
2414
+ // src/revamp/domain/components/utils/isExactLocalValueMatch.ts
2415
+ var isExactLocalValueMatch = (valueA, valueB) => {
2416
+ if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
2417
+ return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
2418
+ }
2419
+ if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
2420
+ const keysA = Object.keys(valueA);
2421
+ const keysB = Object.keys(valueB);
2422
+ return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
2423
+ }
2424
+ return valueA === valueB;
2425
+ };
2426
+
2396
2427
  // src/revamp/domain/features/utils/http-utils.ts
2397
2428
  function constructPayload({
2398
2429
  value,
@@ -2420,37 +2451,21 @@ var abortAndResetController = (abortController) => {
2420
2451
  return new AbortController();
2421
2452
  };
2422
2453
 
2423
- // src/revamp/domain/components/utils/isExactLocalValueMatch.ts
2424
- var isExactLocalValueMatch = (valueA, valueB) => {
2425
- if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
2426
- return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
2427
- }
2428
- if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
2429
- const keysA = Object.keys(valueA);
2430
- const keysB = Object.keys(valueB);
2431
- return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
2432
- }
2433
- return valueA === valueB;
2434
- };
2435
-
2436
- // src/revamp/domain/components/utils/getRandomId.ts
2437
- var getRandomId = () => Math.random().toString(36).substring(2);
2438
-
2439
2454
  // src/revamp/domain/features/persistAsync/getComponentPersistAsync.ts
2440
2455
  var getComponentPersistAsync = (update, performPersistAsync) => (
2441
2456
  /**
2442
2457
  * Will update the persistedState when a new request is made, and will update
2443
2458
  * the value or set errors when the request completes.
2444
2459
  */
2445
- async (persistedState, currentValue) => {
2446
- const { abortController, lastSubmitted, submission } = persistedState;
2460
+ async (component, currentValue) => {
2461
+ const { abortController, lastSubmitted, submission } = component.persistedState;
2447
2462
  if (isExactLocalValueMatch(lastSubmitted, currentValue)) {
2448
2463
  return submission;
2449
2464
  }
2450
2465
  const newAbortController = abortAndResetController(abortController);
2451
2466
  if (isNullish(currentValue) || currentValue === "") {
2452
2467
  const resolvedNull = Promise.resolve(null);
2453
- update((draft) => {
2468
+ update(component, (draft) => {
2454
2469
  draft.persistedState.abortController = newAbortController;
2455
2470
  draft.persistedState.lastResponse = null;
2456
2471
  draft.persistedState.lastSubmitted = currentValue;
@@ -2460,7 +2475,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
2460
2475
  }
2461
2476
  const { signal } = newAbortController;
2462
2477
  const newSubmission = performPersistAsync({ value: currentValue, signal }).then((newValue) => {
2463
- update((draft) => {
2478
+ update(component, (draft) => {
2464
2479
  draft.persistedState.lastResponse = newValue;
2465
2480
  });
2466
2481
  return newValue;
@@ -2468,14 +2483,14 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
2468
2483
  if (error instanceof DOMException && error.name === "AbortError") {
2469
2484
  return null;
2470
2485
  }
2471
- update((draft) => {
2486
+ update(component, (draft) => {
2472
2487
  draft.errors = [error.message];
2473
2488
  draft.persistedState.lastResponse = null;
2474
2489
  draft.persistedState.lastSubmitted = null;
2475
2490
  });
2476
2491
  throw error;
2477
2492
  });
2478
- update((draft) => {
2493
+ update(component, (draft) => {
2479
2494
  draft.persistedState = {
2480
2495
  abortController: newAbortController,
2481
2496
  lastResponse: null,
@@ -2491,19 +2506,19 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
2491
2506
  * Will update the persistedState when a new request is made, and will update
2492
2507
  * the value or set errors when the request completes.
2493
2508
  */
2494
- async (index, value) => {
2509
+ async (component, index, value) => {
2495
2510
  if (isNullish(value)) {
2496
2511
  throw new Error("Value must be a file or base64 string.");
2497
2512
  }
2498
2513
  const newAbortController = new AbortController();
2499
2514
  const { signal } = newAbortController;
2500
2515
  const newSubmission = performPersistAsync({ value, signal }).then((newValue) => {
2501
- update((draft) => {
2516
+ update(component, (draft) => {
2502
2517
  draft.persistedState[index].lastResponse = newValue;
2503
2518
  });
2504
2519
  return newValue;
2505
2520
  }).catch((error) => {
2506
- update((draft) => {
2521
+ update(component, (draft) => {
2507
2522
  draft.persistedState = [
2508
2523
  ...draft.persistedState.slice(0, index),
2509
2524
  ...draft.persistedState.slice(index + 1)
@@ -2513,7 +2528,7 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
2513
2528
  });
2514
2529
  throw error;
2515
2530
  });
2516
- update((draft) => {
2531
+ update(component, (draft) => {
2517
2532
  draft.persistedState = [
2518
2533
  ...draft.persistedState.slice(0, index),
2519
2534
  {
@@ -2608,11 +2623,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2608
2623
  * Will update the validationAsyncState when a new request is made, and will update
2609
2624
  * the description or set errors when the request completes.
2610
2625
  */
2611
- async (validationAsyncState, currentValue) => {
2612
- const { abortController } = validationAsyncState;
2626
+ async (component, currentValue) => {
2627
+ const { abortController } = component.validationAsyncState;
2613
2628
  const newAbortController = abortAndResetController(abortController);
2614
2629
  if (isNullish(currentValue)) {
2615
- update((draft) => {
2630
+ update(component, (draft) => {
2616
2631
  draft.validationAsyncState = {
2617
2632
  abortController: newAbortController,
2618
2633
  lastSubmitted: currentValue,
@@ -2623,7 +2638,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2623
2638
  }
2624
2639
  const { signal } = newAbortController;
2625
2640
  const newSubmission = performValidationAsync({ value: currentValue, signal }).then((message) => {
2626
- update((draft) => {
2641
+ update(component, (draft) => {
2627
2642
  if (message) {
2628
2643
  draft.validationAsyncState.messages.success = message;
2629
2644
  }
@@ -2633,11 +2648,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
2633
2648
  if (error instanceof DOMException && error.name === "AbortError") {
2634
2649
  return null;
2635
2650
  }
2636
- update((draft) => {
2651
+ update(component, (draft) => {
2637
2652
  draft.validationAsyncState.messages.error = error.message;
2638
2653
  });
2639
2654
  });
2640
- update((draft) => {
2655
+ update(component, (draft) => {
2641
2656
  draft.validationAsyncState = {
2642
2657
  abortController: newAbortController,
2643
2658
  lastSubmitted: currentValue,
@@ -2670,22 +2685,18 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2670
2685
  "onValueChange",
2671
2686
  "summariser"
2672
2687
  ]);
2673
- const update = getInputUpdateFunction(uid, updateComponent);
2688
+ const update = getInputUpdateFunction(updateComponent);
2674
2689
  const getValidationErrors = getLocalValueValidator(checks);
2675
2690
  const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
2676
- const getAndSetValidationErrors = (currentValue) => {
2677
- const messages = getValidationErrors(currentValue);
2678
- update((draft) => {
2679
- draft.errors = messages;
2680
- });
2681
- return messages;
2682
- };
2683
2691
  const numberComponent = __spreadValues({
2684
2692
  type: "number",
2685
2693
  uid,
2686
2694
  id,
2695
+ _update(updateFn) {
2696
+ update(this, updateFn);
2697
+ },
2687
2698
  onBlur() {
2688
- getAndSetValidationErrors(this.getLocalValue());
2699
+ this.validate();
2689
2700
  performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
2690
2701
  },
2691
2702
  onFocus() {
@@ -2693,7 +2704,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2693
2704
  // Noop
2694
2705
  onChange(updatedValue) {
2695
2706
  const prevValue = this.value;
2696
- update((draft) => {
2707
+ this._update((draft) => {
2697
2708
  draft.errors = [];
2698
2709
  draft.validationAsyncState.messages = {};
2699
2710
  draft.value = updatedValue;
@@ -2715,8 +2726,11 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2715
2726
  return this.value;
2716
2727
  },
2717
2728
  validate() {
2718
- const messages = getAndSetValidationErrors(this.getLocalValue());
2719
- return messages.length === 0;
2729
+ const errors = getValidationErrors(this.getLocalValue());
2730
+ this._update((draft) => {
2731
+ draft.errors = errors;
2732
+ });
2733
+ return errors.length === 0;
2720
2734
  }
2721
2735
  }, rest);
2722
2736
  if (performRefresh) {
@@ -2727,12 +2741,12 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2727
2741
  return __spreadProps(__spreadValues({}, numberComponent), {
2728
2742
  onBlur() {
2729
2743
  if (this.validate()) {
2730
- persist(this.persistedState, this.getLocalValue()).catch(() => {
2744
+ persist(this, this.getLocalValue()).catch(() => {
2731
2745
  });
2732
2746
  }
2733
2747
  },
2734
2748
  async getSubmittableValue() {
2735
- return persist(this.persistedState, this.getLocalValue());
2749
+ return persist(this, this.getLocalValue());
2736
2750
  },
2737
2751
  getSubmittableValueSync() {
2738
2752
  return this.persistedState.lastResponse;
@@ -2750,7 +2764,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
2750
2764
  onChange(updatedValue) {
2751
2765
  numberComponent.onChange.call(this, updatedValue);
2752
2766
  if (getValidationErrors(updatedValue).length === 0) {
2753
- validateAsync(this.validationAsyncState, updatedValue);
2767
+ validateAsync(this, updatedValue);
2754
2768
  }
2755
2769
  }
2756
2770
  });
@@ -3041,7 +3055,7 @@ var getPerformPersistAsync = ({
3041
3055
  }
3042
3056
  return json[idProperty];
3043
3057
  }
3044
- } catch (error) {
3058
+ } catch (e) {
3045
3059
  trackFailure();
3046
3060
  throw new Error(genericErrorMessage);
3047
3061
  }
@@ -3468,23 +3482,19 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3468
3482
  "onValueChange",
3469
3483
  "summariser"
3470
3484
  ]);
3471
- const update = getInputUpdateFunction(uid, updateComponent);
3485
+ const update = getInputUpdateFunction(updateComponent);
3472
3486
  const getValidationErrors = getLocalValueValidator(checks);
3473
3487
  const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
3474
- const getAndSetValidationErrors = (currentValue) => {
3475
- const messages = getValidationErrors(currentValue);
3476
- update((draft) => {
3477
- draft.errors = messages;
3478
- });
3479
- return messages;
3480
- };
3481
3488
  const integerComponent = __spreadValues({
3482
3489
  type: "integer",
3483
3490
  uid,
3484
3491
  id,
3485
3492
  value,
3493
+ _update(updateFn) {
3494
+ update(this, updateFn);
3495
+ },
3486
3496
  onBlur() {
3487
- getAndSetValidationErrors(this.getLocalValue());
3497
+ this.validate();
3488
3498
  performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
3489
3499
  },
3490
3500
  onFocus() {
@@ -3492,7 +3502,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3492
3502
  // Noop
3493
3503
  onChange(updatedValue) {
3494
3504
  const prevValue = this.value;
3495
- update((draft) => {
3505
+ this._update((draft) => {
3496
3506
  draft.errors = [];
3497
3507
  draft.validationAsyncState.messages = {};
3498
3508
  draft.value = updatedValue;
@@ -3514,8 +3524,11 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3514
3524
  return this.value;
3515
3525
  },
3516
3526
  validate() {
3517
- const messages = getAndSetValidationErrors(this.getLocalValue());
3518
- return messages.length === 0;
3527
+ const errors = getValidationErrors(this.getLocalValue());
3528
+ this._update((draft) => {
3529
+ draft.errors = errors;
3530
+ });
3531
+ return errors.length === 0;
3519
3532
  }
3520
3533
  }, rest);
3521
3534
  if (performRefresh) {
@@ -3526,12 +3539,12 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3526
3539
  return __spreadProps(__spreadValues({}, integerComponent), {
3527
3540
  onBlur() {
3528
3541
  if (this.validate()) {
3529
- persist(this.persistedState, this.getLocalValue()).catch(() => {
3542
+ persist(this, this.getLocalValue()).catch(() => {
3530
3543
  });
3531
3544
  }
3532
3545
  },
3533
3546
  async getSubmittableValue() {
3534
- return persist(this.persistedState, this.getLocalValue());
3547
+ return persist(this, this.getLocalValue());
3535
3548
  },
3536
3549
  getSubmittableValueSync() {
3537
3550
  return this.persistedState.lastResponse;
@@ -3549,7 +3562,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
3549
3562
  onChange(updatedValue) {
3550
3563
  integerComponent.onChange.call(this, updatedValue);
3551
3564
  if (getValidationErrors(updatedValue).length === 0) {
3552
- validateAsync(this.validationAsyncState, updatedValue);
3565
+ validateAsync(this, updatedValue);
3553
3566
  }
3554
3567
  }
3555
3568
  });
@@ -3623,16 +3636,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3623
3636
  (option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
3624
3637
  );
3625
3638
  const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
3626
- const update = getInputUpdateFunction(uid, updateComponent);
3639
+ const update = getInputUpdateFunction(updateComponent);
3627
3640
  const getValidationErrors = getLocalValueValidator(checks);
3628
- const getAndSetValidationErrors = (currentValue) => {
3629
- const messages = getValidationErrors(currentValue);
3630
- update((draft) => {
3631
- draft.errors = messages;
3632
- });
3633
- return messages;
3634
- };
3635
- return __spreadProps(__spreadValues({
3641
+ const component = __spreadProps(__spreadValues({
3636
3642
  uid,
3637
3643
  type: "select",
3638
3644
  children,
@@ -3640,6 +3646,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3640
3646
  selectedIndex,
3641
3647
  value: null
3642
3648
  }, rest), {
3649
+ _update(updateFn) {
3650
+ update(this, updateFn);
3651
+ },
3643
3652
  getChildren() {
3644
3653
  return this.children;
3645
3654
  },
@@ -3663,7 +3672,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3663
3672
  return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
3664
3673
  },
3665
3674
  onBlur() {
3666
- getAndSetValidationErrors(this.getLocalValue());
3675
+ this.validate();
3667
3676
  },
3668
3677
  onFocus() {
3669
3678
  },
@@ -3675,7 +3684,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3675
3684
  schemaId: this.children[updatedIndex].analyticsId
3676
3685
  });
3677
3686
  }
3678
- update((draft) => {
3687
+ this._update((draft) => {
3679
3688
  draft.errors = [];
3680
3689
  draft.selectedIndex = updatedIndex;
3681
3690
  });
@@ -3685,10 +3694,14 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
3685
3694
  validate() {
3686
3695
  var _a2, _b;
3687
3696
  const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
3688
- const messages = getAndSetValidationErrors(this.getLocalValue());
3689
- return messages.length === 0 && validChild;
3697
+ const errors = getValidationErrors(this.getLocalValue());
3698
+ this._update((draft) => {
3699
+ draft.errors = errors;
3700
+ });
3701
+ return errors.length === 0 && validChild;
3690
3702
  }
3691
3703
  });
3704
+ return component;
3692
3705
  };
3693
3706
 
3694
3707
  // src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
@@ -3783,29 +3796,25 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
3783
3796
  "summariser",
3784
3797
  "value"
3785
3798
  ]);
3786
- const update = getInputUpdateFunction(uid, updateComponent);
3799
+ const update = getInputUpdateFunction(updateComponent);
3787
3800
  const getValidationErrors = getLocalValueValidator(checks);
3788
- const getAndSetValidationErrors = (currentValue) => {
3789
- const messages = getValidationErrors(currentValue);
3790
- update((draft) => {
3791
- draft.errors = messages;
3792
- });
3793
- return messages;
3794
- };
3795
3801
  const dateInputComponent = __spreadValues({
3796
3802
  type: "date",
3797
3803
  uid,
3798
3804
  id,
3799
3805
  value,
3806
+ _update(updateFn) {
3807
+ update(this, updateFn);
3808
+ },
3800
3809
  onBlur() {
3801
- getAndSetValidationErrors(this.getLocalValue());
3810
+ this.validate();
3802
3811
  },
3803
3812
  onFocus() {
3804
3813
  },
3805
3814
  // Noop
3806
3815
  onChange(updatedValue) {
3807
3816
  const prevValue = this.value;
3808
- update((draft) => {
3817
+ this._update((draft) => {
3809
3818
  draft.errors = [];
3810
3819
  draft.validationAsyncState.messages = {};
3811
3820
  draft.value = updatedValue;
@@ -3829,8 +3838,11 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
3829
3838
  return this.value;
3830
3839
  },
3831
3840
  validate() {
3832
- const messages = getAndSetValidationErrors(this.getLocalValue());
3833
- return messages.length === 0;
3841
+ const errors = getValidationErrors(this.getLocalValue());
3842
+ this._update((draft) => {
3843
+ draft.errors = errors;
3844
+ });
3845
+ return errors.length === 0;
3834
3846
  }
3835
3847
  }, rest);
3836
3848
  if (performRefresh) {
@@ -3843,12 +3855,12 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
3843
3855
  dateInputComponent.onChange.call(this, updatedValue);
3844
3856
  const isValid = getValidationErrors(updatedValue).length === 0;
3845
3857
  if (isValid) {
3846
- persist(this.persistedState, this.getLocalValue()).catch(() => {
3858
+ persist(this, this.getLocalValue()).catch(() => {
3847
3859
  });
3848
3860
  }
3849
3861
  },
3850
3862
  async getSubmittableValue() {
3851
- return persist(this.persistedState, this.getLocalValue());
3863
+ return persist(this, this.getLocalValue());
3852
3864
  },
3853
3865
  getSubmittableValueSync() {
3854
3866
  return this.persistedState.lastResponse;
@@ -3860,7 +3872,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
3860
3872
  return __spreadProps(__spreadValues({}, dateInputComponent), {
3861
3873
  onBlur() {
3862
3874
  if (this.validate()) {
3863
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
3875
+ validateAsync(this, this.getLocalValue()).catch(() => {
3864
3876
  });
3865
3877
  }
3866
3878
  }
@@ -3963,29 +3975,25 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
3963
3975
  "onValueChange",
3964
3976
  "summariser"
3965
3977
  ]);
3966
- const update = getInputUpdateFunction(uid, updateComponent);
3978
+ const update = getInputUpdateFunction(updateComponent);
3967
3979
  const getValidationErrors = getLocalValueValidator(checks);
3968
- const getAndSetValidationErrors = (currentValue) => {
3969
- const messages = getValidationErrors(currentValue);
3970
- update((draft) => {
3971
- draft.errors = messages;
3972
- });
3973
- return messages;
3974
- };
3975
3980
  const uploadComponent = __spreadValues({
3976
3981
  type: "upload",
3977
3982
  uid,
3978
3983
  id,
3979
3984
  format: "base64",
3980
3985
  value,
3986
+ _update(updateFn) {
3987
+ update(this, updateFn);
3988
+ },
3981
3989
  onBlur() {
3982
- getAndSetValidationErrors(this.getLocalValue());
3990
+ this.validate();
3983
3991
  },
3984
3992
  onFocus() {
3985
3993
  },
3986
3994
  // Noop
3987
3995
  async onUpload(updatedValue) {
3988
- update((draft) => {
3996
+ this._update((draft) => {
3989
3997
  draft.errors = [];
3990
3998
  draft.value = updatedValue;
3991
3999
  });
@@ -4007,8 +4015,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4007
4015
  return this.value;
4008
4016
  },
4009
4017
  validate() {
4010
- const messages = getAndSetValidationErrors(this.getLocalValue());
4011
- return messages.length === 0;
4018
+ const errors = getValidationErrors(this.getLocalValue());
4019
+ this._update((draft) => {
4020
+ draft.errors = errors;
4021
+ });
4022
+ return errors.length === 0;
4012
4023
  }
4013
4024
  }, rest);
4014
4025
  if (!performPersistAsync) {
@@ -4018,14 +4029,14 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
4018
4029
  return __spreadProps(__spreadValues({}, uploadComponent), {
4019
4030
  format,
4020
4031
  async onUpload(file) {
4021
- update((draft) => {
4032
+ this._update((draft) => {
4022
4033
  draft.errors = [];
4023
4034
  draft.value = file;
4024
4035
  });
4025
4036
  onValueChange();
4026
4037
  const submission = format === "base64" && file ? await toBase64(file) : file;
4027
- await persist(this.persistedState, submission).catch((error) => {
4028
- update((draft) => {
4038
+ await persist(this, submission).catch((error) => {
4039
+ this._update((draft) => {
4029
4040
  draft.persistedState.lastResponse = null;
4030
4041
  draft.persistedState.lastSubmitted = null;
4031
4042
  draft.persistedState.submission = Promise.resolve(null);
@@ -4104,23 +4115,19 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4104
4115
  "summariser",
4105
4116
  "value"
4106
4117
  ]);
4107
- const update = getInputUpdateFunction(uid, updateComponent);
4118
+ const update = getInputUpdateFunction(updateComponent);
4108
4119
  const getValidationErrors = getLocalValueValidator(checks);
4109
4120
  const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
4110
- const getAndSetValidationErrors = (currentValue) => {
4111
- const messages = getValidationErrors(currentValue);
4112
- update((draft) => {
4113
- draft.errors = messages;
4114
- });
4115
- return messages;
4116
- };
4117
4121
  const inputComponent = __spreadValues({
4118
4122
  type: "text",
4119
4123
  uid,
4120
4124
  id,
4121
4125
  value,
4126
+ _update(updateFn) {
4127
+ update(this, updateFn);
4128
+ },
4122
4129
  onBlur() {
4123
- getAndSetValidationErrors(this.getLocalValue());
4130
+ this.validate();
4124
4131
  performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
4125
4132
  },
4126
4133
  onFocus() {
@@ -4128,7 +4135,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4128
4135
  // Noop
4129
4136
  onChange(updatedValue) {
4130
4137
  const prevValue = this.value;
4131
- update((draft) => {
4138
+ this._update((draft) => {
4132
4139
  draft.errors = [];
4133
4140
  draft.validationAsyncState.messages = {};
4134
4141
  draft.value = updatedValue;
@@ -4149,8 +4156,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4149
4156
  return this.value;
4150
4157
  },
4151
4158
  validate() {
4152
- const messages = getAndSetValidationErrors(this.getLocalValue());
4153
- return messages.length === 0;
4159
+ const errors = getValidationErrors(this.getLocalValue());
4160
+ this._update((draft) => {
4161
+ draft.errors = errors;
4162
+ });
4163
+ return errors.length === 0;
4154
4164
  }
4155
4165
  }, rest);
4156
4166
  if (performRefresh) {
@@ -4161,12 +4171,12 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4161
4171
  return __spreadProps(__spreadValues({}, inputComponent), {
4162
4172
  onBlur() {
4163
4173
  if (this.validate()) {
4164
- persist(this.persistedState, this.getLocalValue()).catch(() => {
4174
+ persist(this, this.getLocalValue()).catch(() => {
4165
4175
  });
4166
4176
  }
4167
4177
  },
4168
4178
  async getSubmittableValue() {
4169
- return persist(this.persistedState, this.getLocalValue());
4179
+ return persist(this, this.getLocalValue());
4170
4180
  },
4171
4181
  getSubmittableValueSync() {
4172
4182
  return this.persistedState.lastResponse;
@@ -4184,7 +4194,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
4184
4194
  onChange(updatedValue) {
4185
4195
  inputComponent.onChange.call(this, updatedValue);
4186
4196
  if (getValidationErrors(updatedValue).length === 0) {
4187
- validateAsync(this.validationAsyncState, updatedValue);
4197
+ validateAsync(this, updatedValue);
4188
4198
  }
4189
4199
  if (!updatedValue) {
4190
4200
  validateAsync.cancel();
@@ -4322,9 +4332,9 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4322
4332
  "createEditableComponent",
4323
4333
  "summariser"
4324
4334
  ]);
4325
- const update = getInputUpdateFunction(uid, updateComponent);
4335
+ const update = getInputUpdateFunction(updateComponent);
4326
4336
  const getValidationErrors = getLocalValueValidator(checks);
4327
- return __spreadProps(__spreadValues({
4337
+ const repeatableComponent = __spreadProps(__spreadValues({
4328
4338
  uid,
4329
4339
  id,
4330
4340
  type: "repeatable",
@@ -4338,8 +4348,11 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4338
4348
  image: summary == null ? void 0 : summary.defaultImage
4339
4349
  }
4340
4350
  }, componentProps), {
4351
+ _update(updateFn) {
4352
+ update(this, updateFn);
4353
+ },
4341
4354
  onEdit(itemIndex) {
4342
- update((draft) => {
4355
+ this._update((draft) => {
4343
4356
  draft.editableComponent = createEditableComponent(
4344
4357
  draft.components[itemIndex].getLocalValue()
4345
4358
  );
@@ -4347,7 +4360,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4347
4360
  });
4348
4361
  },
4349
4362
  onAdd() {
4350
- update((draft) => {
4363
+ this._update((draft) => {
4351
4364
  draft.editableComponent = createEditableComponent(null);
4352
4365
  draft.editableIndex = null;
4353
4366
  draft.errors = [];
@@ -4359,7 +4372,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4359
4372
  if (!isValid) {
4360
4373
  return false;
4361
4374
  }
4362
- update((draft) => {
4375
+ this._update((draft) => {
4363
4376
  if (draft.editableComponent === null) {
4364
4377
  return;
4365
4378
  }
@@ -4378,7 +4391,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4378
4391
  return true;
4379
4392
  },
4380
4393
  onRemove() {
4381
- update((draft) => {
4394
+ this._update((draft) => {
4382
4395
  if (draft.editableIndex === null) {
4383
4396
  return;
4384
4397
  }
@@ -4406,12 +4419,13 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
4406
4419
  validate() {
4407
4420
  const messages = getValidationErrors(this.getLocalValue());
4408
4421
  const childComponentsValid = validateComponents(this.getChildren());
4409
- update((draft) => {
4422
+ this._update((draft) => {
4410
4423
  draft.errors = messages;
4411
4424
  });
4412
4425
  return messages.length === 0 && childComponentsValid;
4413
4426
  }
4414
4427
  });
4428
+ return repeatableComponent;
4415
4429
  };
4416
4430
 
4417
4431
  // src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
@@ -4511,30 +4525,26 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4511
4525
  "onValueChange",
4512
4526
  "summariser"
4513
4527
  ]);
4514
- const update = getInputUpdateFunction(uid, updateComponent);
4528
+ const update = getInputUpdateFunction(updateComponent);
4515
4529
  const getValidationErrors = getLocalValueValidator(checks);
4516
4530
  const getFileValidationErrors = getLocalValueValidator(fileChecks);
4517
- const getAndSetValidationErrors = (currentValue) => {
4518
- const messages = getValidationErrors(currentValue);
4519
- update((draft) => {
4520
- draft.errors = messages;
4521
- });
4522
- return messages;
4523
- };
4524
4531
  const uploadComponent = __spreadValues({
4525
4532
  type: "multi-upload",
4526
4533
  uid,
4527
4534
  id,
4528
4535
  format: "base64",
4529
4536
  files: [],
4537
+ _update(updateFn) {
4538
+ update(this, updateFn);
4539
+ },
4530
4540
  onBlur() {
4531
- getAndSetValidationErrors(this.getLocalValue());
4541
+ this.validate();
4532
4542
  },
4533
4543
  onFocus() {
4534
4544
  },
4535
4545
  // Noop
4536
4546
  async onRemoveFile(index) {
4537
- update((draft) => {
4547
+ this._update((draft) => {
4538
4548
  draft.value.splice(index, 1);
4539
4549
  draft.files.splice(index, 1);
4540
4550
  });
@@ -4542,7 +4552,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4542
4552
  async onInsertFile(index, file) {
4543
4553
  const fileErrors = getFileValidationErrors(file);
4544
4554
  const fileId = getRandomId();
4545
- update((draft) => {
4555
+ this._update((draft) => {
4546
4556
  draft.value.splice(index, 0, file);
4547
4557
  draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
4548
4558
  draft.errors = [];
@@ -4564,8 +4574,11 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4564
4574
  return this.value;
4565
4575
  },
4566
4576
  validate() {
4567
- const messages = getAndSetValidationErrors(this.getLocalValue());
4568
- return messages.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4577
+ const errorMsgs = getValidationErrors(this.getLocalValue());
4578
+ this._update((draft) => {
4579
+ draft.errors = errorMsgs;
4580
+ });
4581
+ return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
4569
4582
  }
4570
4583
  }, rest);
4571
4584
  if (!performPersistAsync) {
@@ -4577,7 +4590,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4577
4590
  async onInsertFile(index, file) {
4578
4591
  const fileId = await uploadComponent.onInsertFile.call(this, index, file);
4579
4592
  const submission = format === "blob" ? file : await toBase64(file);
4580
- await persist(index, submission);
4593
+ await persist(this, index, submission);
4581
4594
  onValueChange();
4582
4595
  return fileId;
4583
4596
  },
@@ -4585,7 +4598,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
4585
4598
  var _a2;
4586
4599
  await uploadComponent.onRemoveFile.call(this, index);
4587
4600
  (_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
4588
- update((draft) => {
4601
+ this._update((draft) => {
4589
4602
  draft.persistedState = draft.persistedState.splice(index, 1);
4590
4603
  });
4591
4604
  },
@@ -4691,17 +4704,10 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4691
4704
  "performRefresh",
4692
4705
  "onValueChange"
4693
4706
  ]);
4694
- const update = getInputUpdateFunction(uid, updateComponent);
4707
+ const update = getInputUpdateFunction(updateComponent);
4695
4708
  const children = options.map((option) => option.component);
4696
4709
  const selectedIndices = getInitialModelIndices(initialValue, children);
4697
4710
  const getValidationErrors = getLocalValueValidator(checks);
4698
- const getAndSetValidationErrors = (currentValue) => {
4699
- const messages = getValidationErrors(currentValue);
4700
- update((draft) => {
4701
- draft.errors = messages;
4702
- });
4703
- return messages;
4704
- };
4705
4711
  const inputComponent = __spreadProps(__spreadValues({
4706
4712
  uid,
4707
4713
  type: "multi-select",
@@ -4710,14 +4716,20 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4710
4716
  selectedIndices,
4711
4717
  value: null
4712
4718
  }, rest), {
4719
+ _update(updateFn) {
4720
+ update(this, updateFn);
4721
+ },
4713
4722
  onSelect(indices) {
4714
- update((draft) => {
4723
+ this._update((draft) => {
4715
4724
  draft.selectedIndices = indices;
4716
4725
  draft.errors = [];
4717
4726
  });
4718
4727
  performRefresh == null ? void 0 : performRefresh();
4719
4728
  onValueChange();
4720
- getAndSetValidationErrors(this.getLocalValue());
4729
+ const errors = getValidationErrors(this.getLocalValue());
4730
+ this._update((draft) => {
4731
+ draft.errors = errors;
4732
+ });
4721
4733
  },
4722
4734
  onBlur() {
4723
4735
  },
@@ -4730,8 +4742,11 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4730
4742
  return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
4731
4743
  },
4732
4744
  validate() {
4733
- const messages = getAndSetValidationErrors(this.getLocalValue());
4734
- return messages.length === 0;
4745
+ const errors = getValidationErrors(this.getLocalValue());
4746
+ this._update((draft) => {
4747
+ draft.errors = errors;
4748
+ });
4749
+ return errors.length === 0;
4735
4750
  },
4736
4751
  async getSubmittableValue() {
4737
4752
  const selected = this.getSelectedChildren();
@@ -4761,7 +4776,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
4761
4776
  onSelect(indices) {
4762
4777
  inputComponent.onSelect.call(this, indices);
4763
4778
  if (this.validate()) {
4764
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
4779
+ validateAsync(this, this.getLocalValue()).catch(() => {
4765
4780
  });
4766
4781
  }
4767
4782
  }
@@ -4962,13 +4977,16 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4962
4977
  "onValueChange",
4963
4978
  "summariser"
4964
4979
  ]);
4965
- const update = getInputUpdateFunction(uid, updateComponent);
4980
+ const update = getInputUpdateFunction(updateComponent);
4966
4981
  const booleanComponent = __spreadValues({
4967
4982
  type: "boolean",
4968
4983
  uid,
4969
4984
  id,
4970
4985
  autoComplete: "",
4971
4986
  value,
4987
+ _update(updateFn) {
4988
+ update(this, updateFn);
4989
+ },
4972
4990
  onBlur() {
4973
4991
  },
4974
4992
  // Noop
@@ -4976,7 +4994,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
4976
4994
  },
4977
4995
  // Noop
4978
4996
  onChange(updatedValue) {
4979
- update((draft) => {
4997
+ this._update((draft) => {
4980
4998
  draft.errors = [];
4981
4999
  draft.value = updatedValue;
4982
5000
  });
@@ -5005,11 +5023,11 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5005
5023
  return __spreadProps(__spreadValues({}, booleanComponent), {
5006
5024
  onChange(updatedValue) {
5007
5025
  booleanComponent.onChange.call(this, updatedValue);
5008
- persist(this.persistedState, this.getLocalValue()).catch(() => {
5026
+ persist(this, this.getLocalValue()).catch(() => {
5009
5027
  });
5010
5028
  },
5011
5029
  async getSubmittableValue() {
5012
- return persist(this.persistedState, this.getLocalValue());
5030
+ return persist(this, this.getLocalValue());
5013
5031
  },
5014
5032
  getSubmittableValueSync() {
5015
5033
  return this.persistedState.lastResponse;
@@ -5021,7 +5039,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
5021
5039
  return __spreadProps(__spreadValues({}, booleanComponent), {
5022
5040
  onChange(updatedValue) {
5023
5041
  booleanComponent.onChange.call(this, updatedValue);
5024
- validateAsync(this.validationAsyncState, this.getLocalValue()).catch(() => {
5042
+ validateAsync(this, this.getLocalValue()).catch(() => {
5025
5043
  });
5026
5044
  }
5027
5045
  });
@@ -5466,9 +5484,9 @@ var getOrientationControl = ({
5466
5484
  var DEBOUNCE_TIME = 400;
5467
5485
  var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
5468
5486
  const { uid, control, emptyMessage, margin, title } = searchProps;
5469
- const update = getInputUpdateFunction(uid, updateComponent);
5487
+ const update = getInputUpdateFunction(updateComponent);
5470
5488
  let abortController = new AbortController();
5471
- const search = (query, searchConfig) => {
5489
+ const search = (component2, query, searchConfig) => {
5472
5490
  abortController.abort();
5473
5491
  abortController = new AbortController();
5474
5492
  const { signal } = abortController;
@@ -5478,7 +5496,7 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
5478
5496
  config: searchConfig
5479
5497
  }).then((results) => {
5480
5498
  if (!signal.aborted) {
5481
- update((draft) => {
5499
+ update(component2, (draft) => {
5482
5500
  draft.results = results;
5483
5501
  draft.isLoading = false;
5484
5502
  draft.error = void 0;
@@ -5486,33 +5504,15 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
5486
5504
  }
5487
5505
  }).catch(() => {
5488
5506
  if (!signal.aborted) {
5489
- update((draft) => {
5507
+ update(component2, (draft) => {
5490
5508
  draft.error = "No response";
5491
5509
  draft.isLoading = false;
5492
5510
  });
5493
5511
  }
5494
5512
  });
5495
5513
  };
5496
- const onSelect = ({ type, value }) => {
5497
- if (type === "action") {
5498
- void onBehavior({ type: "action", action: value });
5499
- } else {
5500
- update((draft) => {
5501
- draft.query = value.query;
5502
- draft.isLoading = true;
5503
- });
5504
- search(value.query, { method: value.method, param: value.param, url: value.url });
5505
- }
5506
- };
5507
5514
  const debouncedSearch = debounce(search, DEBOUNCE_TIME);
5508
- const onChange = (query) => {
5509
- update((draft) => {
5510
- draft.query = query;
5511
- draft.isLoading = true;
5512
- });
5513
- debouncedSearch(query.trim());
5514
- };
5515
- return {
5515
+ const component = {
5516
5516
  type: "search",
5517
5517
  uid,
5518
5518
  control,
@@ -5522,15 +5522,39 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
5522
5522
  isLoading: false,
5523
5523
  query: "",
5524
5524
  results: [],
5525
+ _update(updateFn) {
5526
+ update(this, updateFn);
5527
+ },
5525
5528
  getSubmittableValue: async () => null,
5526
5529
  getSubmittableValueSync: () => null,
5527
5530
  getLocalValue: () => null,
5528
5531
  getSummary: () => ({}),
5529
5532
  // Noop
5530
5533
  validate: () => true,
5531
- onChange,
5532
- onSelect
5534
+ onChange(query) {
5535
+ this._update((draft) => {
5536
+ draft.query = query;
5537
+ draft.isLoading = true;
5538
+ });
5539
+ debouncedSearch(this, query.trim());
5540
+ },
5541
+ onSelect({ type, value }) {
5542
+ if (type === "action") {
5543
+ void onBehavior({ type: "action", action: value });
5544
+ } else {
5545
+ this._update((draft) => {
5546
+ draft.query = value.query;
5547
+ draft.isLoading = true;
5548
+ });
5549
+ search(this, value.query, {
5550
+ method: value.method,
5551
+ param: value.param,
5552
+ url: value.url
5553
+ });
5554
+ }
5555
+ }
5533
5556
  };
5557
+ return component;
5534
5558
  };
5535
5559
 
5536
5560
  // src/revamp/domain/features/search/getPerformSearchFunction.ts
@@ -6260,29 +6284,6 @@ var formatDateOptions = {
6260
6284
  dateStyle: "long"
6261
6285
  };
6262
6286
 
6263
- // src/revamp/utils/findComponent.ts
6264
- var findComponent = (components, id, logEvent) => {
6265
- const flattened = flattenComponents(components);
6266
- const matching = flattened.filter((component) => component.uid === id);
6267
- if (matching.length === 1) {
6268
- return matching[0];
6269
- }
6270
- if (matching.length > 1) {
6271
- throw new Error(`Multiple components with the same uid: ${id}`);
6272
- }
6273
- logEvent("error", "Failed to find domain layer component", {
6274
- componentUid: id,
6275
- componentsTree: flattened.map((component) => component.uid)
6276
- });
6277
- throw new Error(`Failed to find any components with uid: ${id}`);
6278
- };
6279
- var flattenComponents = (components) => components.reduce((acc, component) => {
6280
- if (hasChildren(component)) {
6281
- return [...acc, component, ...flattenComponents(component.getChildren())];
6282
- }
6283
- return [...acc, component];
6284
- }, []);
6285
-
6286
6287
  // src/revamp/utils/useStableCallback.tsx
6287
6288
  var import_react2 = require("react");
6288
6289
  function useStableCallback(handler) {
@@ -6309,15 +6310,7 @@ function useDynamicFlowCore(props) {
6309
6310
  [formatMessage, locale]
6310
6311
  );
6311
6312
  const rerender = useRerender();
6312
- const rootComponentRef = (0, import_react3.useRef)(createRootDomainComponent());
6313
- const updateComponent = (0, import_react3.useCallback)(
6314
- (id, update) => {
6315
- update(findComponent([rootComponentRef.current], id, logEvent));
6316
- rerender();
6317
- },
6318
- // eslint-disable-next-line react-hooks/exhaustive-deps
6319
- []
6320
- );
6313
+ const rootComponentRef = (0, import_react3.useRef)(createRootDomainComponent(rerender));
6321
6314
  const stepCount = (0, import_react3.useRef)(0);
6322
6315
  const stepRef = (0, import_react3.useRef)(initialStep != null ? initialStep : null);
6323
6316
  const etagRef = (0, import_react3.useRef)(null);
@@ -6362,25 +6355,24 @@ function useDynamicFlowCore(props) {
6362
6355
  });
6363
6356
  }
6364
6357
  try {
6365
- const newStepComponent = mapStepToComponent({
6366
- uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
6367
- stepLocalValue: localValue,
6368
- step: newStep,
6369
- displayStepTitle,
6370
- loadingState: "idle",
6371
- updateComponent,
6372
- getErrorMessageFunctions,
6373
- trackEvent,
6374
- logEvent,
6375
- httpClient,
6376
- onBehavior,
6377
- onRefresh,
6378
- onPoll,
6379
- onValueChange
6380
- });
6381
- updateComponent(rootComponentRef.current.uid, (draft) => {
6382
- draft.stepComponent = newStepComponent;
6383
- });
6358
+ rootComponentRef.current.setStep(
6359
+ mapStepToComponent({
6360
+ uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
6361
+ stepLocalValue: localValue,
6362
+ step: newStep,
6363
+ displayStepTitle,
6364
+ loadingState: "idle",
6365
+ updateComponent: () => rerender(),
6366
+ getErrorMessageFunctions,
6367
+ trackEvent,
6368
+ logEvent,
6369
+ httpClient,
6370
+ onBehavior,
6371
+ onRefresh,
6372
+ onPoll,
6373
+ onValueChange
6374
+ })
6375
+ );
6384
6376
  } catch (error) {
6385
6377
  closeWithError(error);
6386
6378
  }