@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 +281 -289
- package/build/main.mjs +281 -289
- package/build/types/revamp/domain/components/DateInputComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/MultiUploadInputComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/RepeatableComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/RootDomainComponent.d.ts +3 -2
- package/build/types/revamp/domain/components/SelectInputComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/UploadInputComponent.d.ts +3 -3
- package/build/types/revamp/domain/components/utils/WithUpdate.d.ts +4 -0
- package/build/types/revamp/domain/components/utils/component-utils.d.ts +2 -6
- package/build/types/revamp/domain/features/persistAsync/getComponentPersistAsync.d.ts +7 -6
- package/build/types/revamp/domain/features/persistAsync/getPerformPersistAsync.d.ts +2 -2
- package/build/types/revamp/domain/features/validationAsync/getComponentValidationAsync.d.ts +5 -5
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +1 -1
- package/build/types/revamp/domain/types.d.ts +1 -1
- package/package.json +5 -5
- package/build/types/revamp/utils/findComponent.d.ts +0 -3
package/build/main.mjs
CHANGED
|
@@ -1116,7 +1116,6 @@ var getRenderFunction = (renderers) => {
|
|
|
1116
1116
|
};
|
|
1117
1117
|
|
|
1118
1118
|
// src/revamp/utils/type-utils.ts
|
|
1119
|
-
var hasChildren = (component) => "getChildren" in component && typeof component.getChildren === "function";
|
|
1120
1119
|
var isHiddenComponent = (component) => "hidden" in component && component.hidden;
|
|
1121
1120
|
var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
1122
1121
|
var isArrayLocalValue = (value) => Array.isArray(value);
|
|
@@ -1770,47 +1769,67 @@ import { validateStep } from "@wise/dynamic-flow-types";
|
|
|
1770
1769
|
import { useCallback as useCallback2, useEffect, useMemo, useRef as useRef2, useState } from "react";
|
|
1771
1770
|
import { useIntl as useIntl2 } from "react-intl";
|
|
1772
1771
|
|
|
1772
|
+
// src/revamp/domain/components/utils/component-utils.ts
|
|
1773
|
+
var getInputUpdateFunction = (updateComponent) => {
|
|
1774
|
+
return (component, updateFn) => {
|
|
1775
|
+
updateFn(component);
|
|
1776
|
+
updateComponent();
|
|
1777
|
+
};
|
|
1778
|
+
};
|
|
1779
|
+
|
|
1773
1780
|
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1774
|
-
var createRootDomainComponent = () =>
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
(
|
|
1812
|
-
|
|
1813
|
-
}
|
|
1781
|
+
var createRootDomainComponent = (updateComponent) => {
|
|
1782
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1783
|
+
const rootComponent = {
|
|
1784
|
+
type: "root",
|
|
1785
|
+
uid: "root",
|
|
1786
|
+
stepComponent: null,
|
|
1787
|
+
_update(updateFn) {
|
|
1788
|
+
update(this, updateFn);
|
|
1789
|
+
},
|
|
1790
|
+
getChildren() {
|
|
1791
|
+
return this.stepComponent ? [this.stepComponent] : [];
|
|
1792
|
+
},
|
|
1793
|
+
getLocalValue() {
|
|
1794
|
+
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1795
|
+
},
|
|
1796
|
+
async getSubmittableValue() {
|
|
1797
|
+
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
1798
|
+
},
|
|
1799
|
+
getSubmittableValueSync() {
|
|
1800
|
+
return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
|
|
1801
|
+
},
|
|
1802
|
+
getSummary() {
|
|
1803
|
+
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1804
|
+
},
|
|
1805
|
+
validate() {
|
|
1806
|
+
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1807
|
+
},
|
|
1808
|
+
setLoadingState(loadingState) {
|
|
1809
|
+
var _a;
|
|
1810
|
+
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1811
|
+
},
|
|
1812
|
+
getLoadingState() {
|
|
1813
|
+
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1814
|
+
},
|
|
1815
|
+
getTrackEvent() {
|
|
1816
|
+
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1817
|
+
},
|
|
1818
|
+
hasStep() {
|
|
1819
|
+
return Boolean(this.stepComponent);
|
|
1820
|
+
},
|
|
1821
|
+
stop() {
|
|
1822
|
+
var _a;
|
|
1823
|
+
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1824
|
+
},
|
|
1825
|
+
setStep(stepComponent) {
|
|
1826
|
+
this._update((draft) => {
|
|
1827
|
+
draft.stepComponent = stepComponent;
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
return rootComponent;
|
|
1832
|
+
};
|
|
1814
1833
|
|
|
1815
1834
|
// src/revamp/utils/component-utils.ts
|
|
1816
1835
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
@@ -1883,22 +1902,17 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
|
1883
1902
|
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
1884
1903
|
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
1885
1904
|
|
|
1886
|
-
// src/revamp/domain/components/utils/component-utils.ts
|
|
1887
|
-
var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
1888
|
-
updateComponent(uid, (draft) => {
|
|
1889
|
-
const draftState = draft;
|
|
1890
|
-
updateFn(draftState);
|
|
1891
|
-
});
|
|
1892
|
-
};
|
|
1893
|
-
|
|
1894
1905
|
// src/revamp/domain/components/StepDomainComponent.ts
|
|
1895
1906
|
var createStepComponent = (stepProps) => {
|
|
1896
1907
|
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
1897
|
-
const update = getInputUpdateFunction(
|
|
1898
|
-
|
|
1908
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1909
|
+
const component = __spreadProps(__spreadValues({
|
|
1899
1910
|
uid
|
|
1900
1911
|
}, rest), {
|
|
1901
1912
|
type: "step",
|
|
1913
|
+
_update(updateFn) {
|
|
1914
|
+
update(this, updateFn);
|
|
1915
|
+
},
|
|
1902
1916
|
getChildren() {
|
|
1903
1917
|
return this.components;
|
|
1904
1918
|
},
|
|
@@ -1918,7 +1932,7 @@ var createStepComponent = (stepProps) => {
|
|
|
1918
1932
|
return validateComponents(this.getChildren());
|
|
1919
1933
|
},
|
|
1920
1934
|
setLoadingState(loadingState) {
|
|
1921
|
-
|
|
1935
|
+
this._update((draft) => {
|
|
1922
1936
|
draft.loadingState = loadingState;
|
|
1923
1937
|
});
|
|
1924
1938
|
},
|
|
@@ -1927,6 +1941,7 @@ var createStepComponent = (stepProps) => {
|
|
|
1927
1941
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
1928
1942
|
}
|
|
1929
1943
|
});
|
|
1944
|
+
return component;
|
|
1930
1945
|
};
|
|
1931
1946
|
|
|
1932
1947
|
// src/revamp/domain/mappers/utils/behavior-utils.ts
|
|
@@ -2350,6 +2365,22 @@ var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
|
2350
2365
|
// src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
2351
2366
|
var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
|
|
2352
2367
|
|
|
2368
|
+
// src/revamp/domain/components/utils/getRandomId.ts
|
|
2369
|
+
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
2370
|
+
|
|
2371
|
+
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
2372
|
+
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
2373
|
+
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
2374
|
+
return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
|
|
2375
|
+
}
|
|
2376
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2377
|
+
const keysA = Object.keys(valueA);
|
|
2378
|
+
const keysB = Object.keys(valueB);
|
|
2379
|
+
return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
|
|
2380
|
+
}
|
|
2381
|
+
return valueA === valueB;
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2353
2384
|
// src/revamp/domain/features/utils/http-utils.ts
|
|
2354
2385
|
function constructPayload({
|
|
2355
2386
|
value,
|
|
@@ -2377,37 +2408,21 @@ var abortAndResetController = (abortController) => {
|
|
|
2377
2408
|
return new AbortController();
|
|
2378
2409
|
};
|
|
2379
2410
|
|
|
2380
|
-
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
2381
|
-
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
2382
|
-
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
2383
|
-
return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
|
|
2384
|
-
}
|
|
2385
|
-
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2386
|
-
const keysA = Object.keys(valueA);
|
|
2387
|
-
const keysB = Object.keys(valueB);
|
|
2388
|
-
return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
|
|
2389
|
-
}
|
|
2390
|
-
return valueA === valueB;
|
|
2391
|
-
};
|
|
2392
|
-
|
|
2393
|
-
// src/revamp/domain/components/utils/getRandomId.ts
|
|
2394
|
-
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
2395
|
-
|
|
2396
2411
|
// src/revamp/domain/features/persistAsync/getComponentPersistAsync.ts
|
|
2397
2412
|
var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
2398
2413
|
/**
|
|
2399
2414
|
* Will update the persistedState when a new request is made, and will update
|
|
2400
2415
|
* the value or set errors when the request completes.
|
|
2401
2416
|
*/
|
|
2402
|
-
async (
|
|
2403
|
-
const { abortController, lastSubmitted, submission } = persistedState;
|
|
2417
|
+
async (component, currentValue) => {
|
|
2418
|
+
const { abortController, lastSubmitted, submission } = component.persistedState;
|
|
2404
2419
|
if (isExactLocalValueMatch(lastSubmitted, currentValue)) {
|
|
2405
2420
|
return submission;
|
|
2406
2421
|
}
|
|
2407
2422
|
const newAbortController = abortAndResetController(abortController);
|
|
2408
2423
|
if (isNullish(currentValue) || currentValue === "") {
|
|
2409
2424
|
const resolvedNull = Promise.resolve(null);
|
|
2410
|
-
update((draft) => {
|
|
2425
|
+
update(component, (draft) => {
|
|
2411
2426
|
draft.persistedState.abortController = newAbortController;
|
|
2412
2427
|
draft.persistedState.lastResponse = null;
|
|
2413
2428
|
draft.persistedState.lastSubmitted = currentValue;
|
|
@@ -2417,7 +2432,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2417
2432
|
}
|
|
2418
2433
|
const { signal } = newAbortController;
|
|
2419
2434
|
const newSubmission = performPersistAsync({ value: currentValue, signal }).then((newValue) => {
|
|
2420
|
-
update((draft) => {
|
|
2435
|
+
update(component, (draft) => {
|
|
2421
2436
|
draft.persistedState.lastResponse = newValue;
|
|
2422
2437
|
});
|
|
2423
2438
|
return newValue;
|
|
@@ -2425,14 +2440,14 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2425
2440
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2426
2441
|
return null;
|
|
2427
2442
|
}
|
|
2428
|
-
update((draft) => {
|
|
2443
|
+
update(component, (draft) => {
|
|
2429
2444
|
draft.errors = [error.message];
|
|
2430
2445
|
draft.persistedState.lastResponse = null;
|
|
2431
2446
|
draft.persistedState.lastSubmitted = null;
|
|
2432
2447
|
});
|
|
2433
2448
|
throw error;
|
|
2434
2449
|
});
|
|
2435
|
-
update((draft) => {
|
|
2450
|
+
update(component, (draft) => {
|
|
2436
2451
|
draft.persistedState = {
|
|
2437
2452
|
abortController: newAbortController,
|
|
2438
2453
|
lastResponse: null,
|
|
@@ -2448,19 +2463,19 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2448
2463
|
* Will update the persistedState when a new request is made, and will update
|
|
2449
2464
|
* the value or set errors when the request completes.
|
|
2450
2465
|
*/
|
|
2451
|
-
async (index, value) => {
|
|
2466
|
+
async (component, index, value) => {
|
|
2452
2467
|
if (isNullish(value)) {
|
|
2453
2468
|
throw new Error("Value must be a file or base64 string.");
|
|
2454
2469
|
}
|
|
2455
2470
|
const newAbortController = new AbortController();
|
|
2456
2471
|
const { signal } = newAbortController;
|
|
2457
2472
|
const newSubmission = performPersistAsync({ value, signal }).then((newValue) => {
|
|
2458
|
-
update((draft) => {
|
|
2473
|
+
update(component, (draft) => {
|
|
2459
2474
|
draft.persistedState[index].lastResponse = newValue;
|
|
2460
2475
|
});
|
|
2461
2476
|
return newValue;
|
|
2462
2477
|
}).catch((error) => {
|
|
2463
|
-
update((draft) => {
|
|
2478
|
+
update(component, (draft) => {
|
|
2464
2479
|
draft.persistedState = [
|
|
2465
2480
|
...draft.persistedState.slice(0, index),
|
|
2466
2481
|
...draft.persistedState.slice(index + 1)
|
|
@@ -2470,7 +2485,7 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2470
2485
|
});
|
|
2471
2486
|
throw error;
|
|
2472
2487
|
});
|
|
2473
|
-
update((draft) => {
|
|
2488
|
+
update(component, (draft) => {
|
|
2474
2489
|
draft.persistedState = [
|
|
2475
2490
|
...draft.persistedState.slice(0, index),
|
|
2476
2491
|
{
|
|
@@ -2565,11 +2580,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2565
2580
|
* Will update the validationAsyncState when a new request is made, and will update
|
|
2566
2581
|
* the description or set errors when the request completes.
|
|
2567
2582
|
*/
|
|
2568
|
-
async (
|
|
2569
|
-
const { abortController } = validationAsyncState;
|
|
2583
|
+
async (component, currentValue) => {
|
|
2584
|
+
const { abortController } = component.validationAsyncState;
|
|
2570
2585
|
const newAbortController = abortAndResetController(abortController);
|
|
2571
2586
|
if (isNullish(currentValue)) {
|
|
2572
|
-
update((draft) => {
|
|
2587
|
+
update(component, (draft) => {
|
|
2573
2588
|
draft.validationAsyncState = {
|
|
2574
2589
|
abortController: newAbortController,
|
|
2575
2590
|
lastSubmitted: currentValue,
|
|
@@ -2580,7 +2595,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2580
2595
|
}
|
|
2581
2596
|
const { signal } = newAbortController;
|
|
2582
2597
|
const newSubmission = performValidationAsync({ value: currentValue, signal }).then((message) => {
|
|
2583
|
-
update((draft) => {
|
|
2598
|
+
update(component, (draft) => {
|
|
2584
2599
|
if (message) {
|
|
2585
2600
|
draft.validationAsyncState.messages.success = message;
|
|
2586
2601
|
}
|
|
@@ -2590,11 +2605,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2590
2605
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2591
2606
|
return null;
|
|
2592
2607
|
}
|
|
2593
|
-
update((draft) => {
|
|
2608
|
+
update(component, (draft) => {
|
|
2594
2609
|
draft.validationAsyncState.messages.error = error.message;
|
|
2595
2610
|
});
|
|
2596
2611
|
});
|
|
2597
|
-
update((draft) => {
|
|
2612
|
+
update(component, (draft) => {
|
|
2598
2613
|
draft.validationAsyncState = {
|
|
2599
2614
|
abortController: newAbortController,
|
|
2600
2615
|
lastSubmitted: currentValue,
|
|
@@ -2627,22 +2642,18 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2627
2642
|
"onValueChange",
|
|
2628
2643
|
"summariser"
|
|
2629
2644
|
]);
|
|
2630
|
-
const update = getInputUpdateFunction(
|
|
2645
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2631
2646
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
2632
2647
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
2633
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
2634
|
-
const messages = getValidationErrors(currentValue);
|
|
2635
|
-
update((draft) => {
|
|
2636
|
-
draft.errors = messages;
|
|
2637
|
-
});
|
|
2638
|
-
return messages;
|
|
2639
|
-
};
|
|
2640
2648
|
const numberComponent = __spreadValues({
|
|
2641
2649
|
type: "number",
|
|
2642
2650
|
uid,
|
|
2643
2651
|
id,
|
|
2652
|
+
_update(updateFn) {
|
|
2653
|
+
update(this, updateFn);
|
|
2654
|
+
},
|
|
2644
2655
|
onBlur() {
|
|
2645
|
-
|
|
2656
|
+
this.validate();
|
|
2646
2657
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
2647
2658
|
},
|
|
2648
2659
|
onFocus() {
|
|
@@ -2650,7 +2661,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2650
2661
|
// Noop
|
|
2651
2662
|
onChange(updatedValue) {
|
|
2652
2663
|
const prevValue = this.value;
|
|
2653
|
-
|
|
2664
|
+
this._update((draft) => {
|
|
2654
2665
|
draft.errors = [];
|
|
2655
2666
|
draft.validationAsyncState.messages = {};
|
|
2656
2667
|
draft.value = updatedValue;
|
|
@@ -2672,8 +2683,11 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2672
2683
|
return this.value;
|
|
2673
2684
|
},
|
|
2674
2685
|
validate() {
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2686
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
2687
|
+
this._update((draft) => {
|
|
2688
|
+
draft.errors = errors;
|
|
2689
|
+
});
|
|
2690
|
+
return errors.length === 0;
|
|
2677
2691
|
}
|
|
2678
2692
|
}, rest);
|
|
2679
2693
|
if (performRefresh) {
|
|
@@ -2684,12 +2698,12 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2684
2698
|
return __spreadProps(__spreadValues({}, numberComponent), {
|
|
2685
2699
|
onBlur() {
|
|
2686
2700
|
if (this.validate()) {
|
|
2687
|
-
persist(this
|
|
2701
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
2688
2702
|
});
|
|
2689
2703
|
}
|
|
2690
2704
|
},
|
|
2691
2705
|
async getSubmittableValue() {
|
|
2692
|
-
return persist(this
|
|
2706
|
+
return persist(this, this.getLocalValue());
|
|
2693
2707
|
},
|
|
2694
2708
|
getSubmittableValueSync() {
|
|
2695
2709
|
return this.persistedState.lastResponse;
|
|
@@ -2707,7 +2721,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2707
2721
|
onChange(updatedValue) {
|
|
2708
2722
|
numberComponent.onChange.call(this, updatedValue);
|
|
2709
2723
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
2710
|
-
validateAsync(this
|
|
2724
|
+
validateAsync(this, updatedValue);
|
|
2711
2725
|
}
|
|
2712
2726
|
}
|
|
2713
2727
|
});
|
|
@@ -2998,7 +3012,7 @@ var getPerformPersistAsync = ({
|
|
|
2998
3012
|
}
|
|
2999
3013
|
return json[idProperty];
|
|
3000
3014
|
}
|
|
3001
|
-
} catch (
|
|
3015
|
+
} catch (e) {
|
|
3002
3016
|
trackFailure();
|
|
3003
3017
|
throw new Error(genericErrorMessage);
|
|
3004
3018
|
}
|
|
@@ -3425,23 +3439,19 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3425
3439
|
"onValueChange",
|
|
3426
3440
|
"summariser"
|
|
3427
3441
|
]);
|
|
3428
|
-
const update = getInputUpdateFunction(
|
|
3442
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3429
3443
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3430
3444
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
3431
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3432
|
-
const messages = getValidationErrors(currentValue);
|
|
3433
|
-
update((draft) => {
|
|
3434
|
-
draft.errors = messages;
|
|
3435
|
-
});
|
|
3436
|
-
return messages;
|
|
3437
|
-
};
|
|
3438
3445
|
const integerComponent = __spreadValues({
|
|
3439
3446
|
type: "integer",
|
|
3440
3447
|
uid,
|
|
3441
3448
|
id,
|
|
3442
3449
|
value,
|
|
3450
|
+
_update(updateFn) {
|
|
3451
|
+
update(this, updateFn);
|
|
3452
|
+
},
|
|
3443
3453
|
onBlur() {
|
|
3444
|
-
|
|
3454
|
+
this.validate();
|
|
3445
3455
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
3446
3456
|
},
|
|
3447
3457
|
onFocus() {
|
|
@@ -3449,7 +3459,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3449
3459
|
// Noop
|
|
3450
3460
|
onChange(updatedValue) {
|
|
3451
3461
|
const prevValue = this.value;
|
|
3452
|
-
|
|
3462
|
+
this._update((draft) => {
|
|
3453
3463
|
draft.errors = [];
|
|
3454
3464
|
draft.validationAsyncState.messages = {};
|
|
3455
3465
|
draft.value = updatedValue;
|
|
@@ -3471,8 +3481,11 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3471
3481
|
return this.value;
|
|
3472
3482
|
},
|
|
3473
3483
|
validate() {
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3484
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3485
|
+
this._update((draft) => {
|
|
3486
|
+
draft.errors = errors;
|
|
3487
|
+
});
|
|
3488
|
+
return errors.length === 0;
|
|
3476
3489
|
}
|
|
3477
3490
|
}, rest);
|
|
3478
3491
|
if (performRefresh) {
|
|
@@ -3483,12 +3496,12 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3483
3496
|
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3484
3497
|
onBlur() {
|
|
3485
3498
|
if (this.validate()) {
|
|
3486
|
-
persist(this
|
|
3499
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3487
3500
|
});
|
|
3488
3501
|
}
|
|
3489
3502
|
},
|
|
3490
3503
|
async getSubmittableValue() {
|
|
3491
|
-
return persist(this
|
|
3504
|
+
return persist(this, this.getLocalValue());
|
|
3492
3505
|
},
|
|
3493
3506
|
getSubmittableValueSync() {
|
|
3494
3507
|
return this.persistedState.lastResponse;
|
|
@@ -3506,7 +3519,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3506
3519
|
onChange(updatedValue) {
|
|
3507
3520
|
integerComponent.onChange.call(this, updatedValue);
|
|
3508
3521
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
3509
|
-
validateAsync(this
|
|
3522
|
+
validateAsync(this, updatedValue);
|
|
3510
3523
|
}
|
|
3511
3524
|
}
|
|
3512
3525
|
});
|
|
@@ -3580,16 +3593,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3580
3593
|
(option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
|
|
3581
3594
|
);
|
|
3582
3595
|
const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
3583
|
-
const update = getInputUpdateFunction(
|
|
3596
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3584
3597
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3585
|
-
const
|
|
3586
|
-
const messages = getValidationErrors(currentValue);
|
|
3587
|
-
update((draft) => {
|
|
3588
|
-
draft.errors = messages;
|
|
3589
|
-
});
|
|
3590
|
-
return messages;
|
|
3591
|
-
};
|
|
3592
|
-
return __spreadProps(__spreadValues({
|
|
3598
|
+
const component = __spreadProps(__spreadValues({
|
|
3593
3599
|
uid,
|
|
3594
3600
|
type: "select",
|
|
3595
3601
|
children,
|
|
@@ -3597,6 +3603,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3597
3603
|
selectedIndex,
|
|
3598
3604
|
value: null
|
|
3599
3605
|
}, rest), {
|
|
3606
|
+
_update(updateFn) {
|
|
3607
|
+
update(this, updateFn);
|
|
3608
|
+
},
|
|
3600
3609
|
getChildren() {
|
|
3601
3610
|
return this.children;
|
|
3602
3611
|
},
|
|
@@ -3620,7 +3629,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3620
3629
|
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
3621
3630
|
},
|
|
3622
3631
|
onBlur() {
|
|
3623
|
-
|
|
3632
|
+
this.validate();
|
|
3624
3633
|
},
|
|
3625
3634
|
onFocus() {
|
|
3626
3635
|
},
|
|
@@ -3632,7 +3641,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3632
3641
|
schemaId: this.children[updatedIndex].analyticsId
|
|
3633
3642
|
});
|
|
3634
3643
|
}
|
|
3635
|
-
|
|
3644
|
+
this._update((draft) => {
|
|
3636
3645
|
draft.errors = [];
|
|
3637
3646
|
draft.selectedIndex = updatedIndex;
|
|
3638
3647
|
});
|
|
@@ -3642,10 +3651,14 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3642
3651
|
validate() {
|
|
3643
3652
|
var _a2, _b;
|
|
3644
3653
|
const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3654
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3655
|
+
this._update((draft) => {
|
|
3656
|
+
draft.errors = errors;
|
|
3657
|
+
});
|
|
3658
|
+
return errors.length === 0 && validChild;
|
|
3647
3659
|
}
|
|
3648
3660
|
});
|
|
3661
|
+
return component;
|
|
3649
3662
|
};
|
|
3650
3663
|
|
|
3651
3664
|
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
@@ -3740,29 +3753,25 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3740
3753
|
"summariser",
|
|
3741
3754
|
"value"
|
|
3742
3755
|
]);
|
|
3743
|
-
const update = getInputUpdateFunction(
|
|
3756
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3744
3757
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3745
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3746
|
-
const messages = getValidationErrors(currentValue);
|
|
3747
|
-
update((draft) => {
|
|
3748
|
-
draft.errors = messages;
|
|
3749
|
-
});
|
|
3750
|
-
return messages;
|
|
3751
|
-
};
|
|
3752
3758
|
const dateInputComponent = __spreadValues({
|
|
3753
3759
|
type: "date",
|
|
3754
3760
|
uid,
|
|
3755
3761
|
id,
|
|
3756
3762
|
value,
|
|
3763
|
+
_update(updateFn) {
|
|
3764
|
+
update(this, updateFn);
|
|
3765
|
+
},
|
|
3757
3766
|
onBlur() {
|
|
3758
|
-
|
|
3767
|
+
this.validate();
|
|
3759
3768
|
},
|
|
3760
3769
|
onFocus() {
|
|
3761
3770
|
},
|
|
3762
3771
|
// Noop
|
|
3763
3772
|
onChange(updatedValue) {
|
|
3764
3773
|
const prevValue = this.value;
|
|
3765
|
-
|
|
3774
|
+
this._update((draft) => {
|
|
3766
3775
|
draft.errors = [];
|
|
3767
3776
|
draft.validationAsyncState.messages = {};
|
|
3768
3777
|
draft.value = updatedValue;
|
|
@@ -3786,8 +3795,11 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3786
3795
|
return this.value;
|
|
3787
3796
|
},
|
|
3788
3797
|
validate() {
|
|
3789
|
-
const
|
|
3790
|
-
|
|
3798
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3799
|
+
this._update((draft) => {
|
|
3800
|
+
draft.errors = errors;
|
|
3801
|
+
});
|
|
3802
|
+
return errors.length === 0;
|
|
3791
3803
|
}
|
|
3792
3804
|
}, rest);
|
|
3793
3805
|
if (performRefresh) {
|
|
@@ -3800,12 +3812,12 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3800
3812
|
dateInputComponent.onChange.call(this, updatedValue);
|
|
3801
3813
|
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
3802
3814
|
if (isValid) {
|
|
3803
|
-
persist(this
|
|
3815
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3804
3816
|
});
|
|
3805
3817
|
}
|
|
3806
3818
|
},
|
|
3807
3819
|
async getSubmittableValue() {
|
|
3808
|
-
return persist(this
|
|
3820
|
+
return persist(this, this.getLocalValue());
|
|
3809
3821
|
},
|
|
3810
3822
|
getSubmittableValueSync() {
|
|
3811
3823
|
return this.persistedState.lastResponse;
|
|
@@ -3817,7 +3829,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3817
3829
|
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
3818
3830
|
onBlur() {
|
|
3819
3831
|
if (this.validate()) {
|
|
3820
|
-
validateAsync(this
|
|
3832
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
3821
3833
|
});
|
|
3822
3834
|
}
|
|
3823
3835
|
}
|
|
@@ -3920,29 +3932,25 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3920
3932
|
"onValueChange",
|
|
3921
3933
|
"summariser"
|
|
3922
3934
|
]);
|
|
3923
|
-
const update = getInputUpdateFunction(
|
|
3935
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3924
3936
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3925
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3926
|
-
const messages = getValidationErrors(currentValue);
|
|
3927
|
-
update((draft) => {
|
|
3928
|
-
draft.errors = messages;
|
|
3929
|
-
});
|
|
3930
|
-
return messages;
|
|
3931
|
-
};
|
|
3932
3937
|
const uploadComponent = __spreadValues({
|
|
3933
3938
|
type: "upload",
|
|
3934
3939
|
uid,
|
|
3935
3940
|
id,
|
|
3936
3941
|
format: "base64",
|
|
3937
3942
|
value,
|
|
3943
|
+
_update(updateFn) {
|
|
3944
|
+
update(this, updateFn);
|
|
3945
|
+
},
|
|
3938
3946
|
onBlur() {
|
|
3939
|
-
|
|
3947
|
+
this.validate();
|
|
3940
3948
|
},
|
|
3941
3949
|
onFocus() {
|
|
3942
3950
|
},
|
|
3943
3951
|
// Noop
|
|
3944
3952
|
async onUpload(updatedValue) {
|
|
3945
|
-
|
|
3953
|
+
this._update((draft) => {
|
|
3946
3954
|
draft.errors = [];
|
|
3947
3955
|
draft.value = updatedValue;
|
|
3948
3956
|
});
|
|
@@ -3964,8 +3972,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3964
3972
|
return this.value;
|
|
3965
3973
|
},
|
|
3966
3974
|
validate() {
|
|
3967
|
-
const
|
|
3968
|
-
|
|
3975
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3976
|
+
this._update((draft) => {
|
|
3977
|
+
draft.errors = errors;
|
|
3978
|
+
});
|
|
3979
|
+
return errors.length === 0;
|
|
3969
3980
|
}
|
|
3970
3981
|
}, rest);
|
|
3971
3982
|
if (!performPersistAsync) {
|
|
@@ -3975,14 +3986,14 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3975
3986
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
3976
3987
|
format,
|
|
3977
3988
|
async onUpload(file) {
|
|
3978
|
-
|
|
3989
|
+
this._update((draft) => {
|
|
3979
3990
|
draft.errors = [];
|
|
3980
3991
|
draft.value = file;
|
|
3981
3992
|
});
|
|
3982
3993
|
onValueChange();
|
|
3983
3994
|
const submission = format === "base64" && file ? await toBase64(file) : file;
|
|
3984
|
-
await persist(this
|
|
3985
|
-
|
|
3995
|
+
await persist(this, submission).catch((error) => {
|
|
3996
|
+
this._update((draft) => {
|
|
3986
3997
|
draft.persistedState.lastResponse = null;
|
|
3987
3998
|
draft.persistedState.lastSubmitted = null;
|
|
3988
3999
|
draft.persistedState.submission = Promise.resolve(null);
|
|
@@ -4061,23 +4072,19 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4061
4072
|
"summariser",
|
|
4062
4073
|
"value"
|
|
4063
4074
|
]);
|
|
4064
|
-
const update = getInputUpdateFunction(
|
|
4075
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4065
4076
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4066
4077
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
4067
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4068
|
-
const messages = getValidationErrors(currentValue);
|
|
4069
|
-
update((draft) => {
|
|
4070
|
-
draft.errors = messages;
|
|
4071
|
-
});
|
|
4072
|
-
return messages;
|
|
4073
|
-
};
|
|
4074
4078
|
const inputComponent = __spreadValues({
|
|
4075
4079
|
type: "text",
|
|
4076
4080
|
uid,
|
|
4077
4081
|
id,
|
|
4078
4082
|
value,
|
|
4083
|
+
_update(updateFn) {
|
|
4084
|
+
update(this, updateFn);
|
|
4085
|
+
},
|
|
4079
4086
|
onBlur() {
|
|
4080
|
-
|
|
4087
|
+
this.validate();
|
|
4081
4088
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
4082
4089
|
},
|
|
4083
4090
|
onFocus() {
|
|
@@ -4085,7 +4092,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4085
4092
|
// Noop
|
|
4086
4093
|
onChange(updatedValue) {
|
|
4087
4094
|
const prevValue = this.value;
|
|
4088
|
-
|
|
4095
|
+
this._update((draft) => {
|
|
4089
4096
|
draft.errors = [];
|
|
4090
4097
|
draft.validationAsyncState.messages = {};
|
|
4091
4098
|
draft.value = updatedValue;
|
|
@@ -4106,8 +4113,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4106
4113
|
return this.value;
|
|
4107
4114
|
},
|
|
4108
4115
|
validate() {
|
|
4109
|
-
const
|
|
4110
|
-
|
|
4116
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4117
|
+
this._update((draft) => {
|
|
4118
|
+
draft.errors = errors;
|
|
4119
|
+
});
|
|
4120
|
+
return errors.length === 0;
|
|
4111
4121
|
}
|
|
4112
4122
|
}, rest);
|
|
4113
4123
|
if (performRefresh) {
|
|
@@ -4118,12 +4128,12 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4118
4128
|
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
4119
4129
|
onBlur() {
|
|
4120
4130
|
if (this.validate()) {
|
|
4121
|
-
persist(this
|
|
4131
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4122
4132
|
});
|
|
4123
4133
|
}
|
|
4124
4134
|
},
|
|
4125
4135
|
async getSubmittableValue() {
|
|
4126
|
-
return persist(this
|
|
4136
|
+
return persist(this, this.getLocalValue());
|
|
4127
4137
|
},
|
|
4128
4138
|
getSubmittableValueSync() {
|
|
4129
4139
|
return this.persistedState.lastResponse;
|
|
@@ -4141,7 +4151,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4141
4151
|
onChange(updatedValue) {
|
|
4142
4152
|
inputComponent.onChange.call(this, updatedValue);
|
|
4143
4153
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
4144
|
-
validateAsync(this
|
|
4154
|
+
validateAsync(this, updatedValue);
|
|
4145
4155
|
}
|
|
4146
4156
|
if (!updatedValue) {
|
|
4147
4157
|
validateAsync.cancel();
|
|
@@ -4279,9 +4289,9 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4279
4289
|
"createEditableComponent",
|
|
4280
4290
|
"summariser"
|
|
4281
4291
|
]);
|
|
4282
|
-
const update = getInputUpdateFunction(
|
|
4292
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4283
4293
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4284
|
-
|
|
4294
|
+
const repeatableComponent = __spreadProps(__spreadValues({
|
|
4285
4295
|
uid,
|
|
4286
4296
|
id,
|
|
4287
4297
|
type: "repeatable",
|
|
@@ -4295,8 +4305,11 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4295
4305
|
image: summary == null ? void 0 : summary.defaultImage
|
|
4296
4306
|
}
|
|
4297
4307
|
}, componentProps), {
|
|
4308
|
+
_update(updateFn) {
|
|
4309
|
+
update(this, updateFn);
|
|
4310
|
+
},
|
|
4298
4311
|
onEdit(itemIndex) {
|
|
4299
|
-
|
|
4312
|
+
this._update((draft) => {
|
|
4300
4313
|
draft.editableComponent = createEditableComponent(
|
|
4301
4314
|
draft.components[itemIndex].getLocalValue()
|
|
4302
4315
|
);
|
|
@@ -4304,7 +4317,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4304
4317
|
});
|
|
4305
4318
|
},
|
|
4306
4319
|
onAdd() {
|
|
4307
|
-
|
|
4320
|
+
this._update((draft) => {
|
|
4308
4321
|
draft.editableComponent = createEditableComponent(null);
|
|
4309
4322
|
draft.editableIndex = null;
|
|
4310
4323
|
draft.errors = [];
|
|
@@ -4316,7 +4329,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4316
4329
|
if (!isValid) {
|
|
4317
4330
|
return false;
|
|
4318
4331
|
}
|
|
4319
|
-
|
|
4332
|
+
this._update((draft) => {
|
|
4320
4333
|
if (draft.editableComponent === null) {
|
|
4321
4334
|
return;
|
|
4322
4335
|
}
|
|
@@ -4335,7 +4348,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4335
4348
|
return true;
|
|
4336
4349
|
},
|
|
4337
4350
|
onRemove() {
|
|
4338
|
-
|
|
4351
|
+
this._update((draft) => {
|
|
4339
4352
|
if (draft.editableIndex === null) {
|
|
4340
4353
|
return;
|
|
4341
4354
|
}
|
|
@@ -4363,12 +4376,13 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4363
4376
|
validate() {
|
|
4364
4377
|
const messages = getValidationErrors(this.getLocalValue());
|
|
4365
4378
|
const childComponentsValid = validateComponents(this.getChildren());
|
|
4366
|
-
|
|
4379
|
+
this._update((draft) => {
|
|
4367
4380
|
draft.errors = messages;
|
|
4368
4381
|
});
|
|
4369
4382
|
return messages.length === 0 && childComponentsValid;
|
|
4370
4383
|
}
|
|
4371
4384
|
});
|
|
4385
|
+
return repeatableComponent;
|
|
4372
4386
|
};
|
|
4373
4387
|
|
|
4374
4388
|
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
|
|
@@ -4468,30 +4482,26 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4468
4482
|
"onValueChange",
|
|
4469
4483
|
"summariser"
|
|
4470
4484
|
]);
|
|
4471
|
-
const update = getInputUpdateFunction(
|
|
4485
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4472
4486
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4473
4487
|
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
4474
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4475
|
-
const messages = getValidationErrors(currentValue);
|
|
4476
|
-
update((draft) => {
|
|
4477
|
-
draft.errors = messages;
|
|
4478
|
-
});
|
|
4479
|
-
return messages;
|
|
4480
|
-
};
|
|
4481
4488
|
const uploadComponent = __spreadValues({
|
|
4482
4489
|
type: "multi-upload",
|
|
4483
4490
|
uid,
|
|
4484
4491
|
id,
|
|
4485
4492
|
format: "base64",
|
|
4486
4493
|
files: [],
|
|
4494
|
+
_update(updateFn) {
|
|
4495
|
+
update(this, updateFn);
|
|
4496
|
+
},
|
|
4487
4497
|
onBlur() {
|
|
4488
|
-
|
|
4498
|
+
this.validate();
|
|
4489
4499
|
},
|
|
4490
4500
|
onFocus() {
|
|
4491
4501
|
},
|
|
4492
4502
|
// Noop
|
|
4493
4503
|
async onRemoveFile(index) {
|
|
4494
|
-
|
|
4504
|
+
this._update((draft) => {
|
|
4495
4505
|
draft.value.splice(index, 1);
|
|
4496
4506
|
draft.files.splice(index, 1);
|
|
4497
4507
|
});
|
|
@@ -4499,7 +4509,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4499
4509
|
async onInsertFile(index, file) {
|
|
4500
4510
|
const fileErrors = getFileValidationErrors(file);
|
|
4501
4511
|
const fileId = getRandomId();
|
|
4502
|
-
|
|
4512
|
+
this._update((draft) => {
|
|
4503
4513
|
draft.value.splice(index, 0, file);
|
|
4504
4514
|
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4505
4515
|
draft.errors = [];
|
|
@@ -4521,8 +4531,11 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4521
4531
|
return this.value;
|
|
4522
4532
|
},
|
|
4523
4533
|
validate() {
|
|
4524
|
-
const
|
|
4525
|
-
|
|
4534
|
+
const errorMsgs = getValidationErrors(this.getLocalValue());
|
|
4535
|
+
this._update((draft) => {
|
|
4536
|
+
draft.errors = errorMsgs;
|
|
4537
|
+
});
|
|
4538
|
+
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
4526
4539
|
}
|
|
4527
4540
|
}, rest);
|
|
4528
4541
|
if (!performPersistAsync) {
|
|
@@ -4534,7 +4547,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4534
4547
|
async onInsertFile(index, file) {
|
|
4535
4548
|
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4536
4549
|
const submission = format === "blob" ? file : await toBase64(file);
|
|
4537
|
-
await persist(index, submission);
|
|
4550
|
+
await persist(this, index, submission);
|
|
4538
4551
|
onValueChange();
|
|
4539
4552
|
return fileId;
|
|
4540
4553
|
},
|
|
@@ -4542,7 +4555,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4542
4555
|
var _a2;
|
|
4543
4556
|
await uploadComponent.onRemoveFile.call(this, index);
|
|
4544
4557
|
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4545
|
-
|
|
4558
|
+
this._update((draft) => {
|
|
4546
4559
|
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4547
4560
|
});
|
|
4548
4561
|
},
|
|
@@ -4648,17 +4661,10 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4648
4661
|
"performRefresh",
|
|
4649
4662
|
"onValueChange"
|
|
4650
4663
|
]);
|
|
4651
|
-
const update = getInputUpdateFunction(
|
|
4664
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4652
4665
|
const children = options.map((option) => option.component);
|
|
4653
4666
|
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4654
4667
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4655
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4656
|
-
const messages = getValidationErrors(currentValue);
|
|
4657
|
-
update((draft) => {
|
|
4658
|
-
draft.errors = messages;
|
|
4659
|
-
});
|
|
4660
|
-
return messages;
|
|
4661
|
-
};
|
|
4662
4668
|
const inputComponent = __spreadProps(__spreadValues({
|
|
4663
4669
|
uid,
|
|
4664
4670
|
type: "multi-select",
|
|
@@ -4667,14 +4673,20 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4667
4673
|
selectedIndices,
|
|
4668
4674
|
value: null
|
|
4669
4675
|
}, rest), {
|
|
4676
|
+
_update(updateFn) {
|
|
4677
|
+
update(this, updateFn);
|
|
4678
|
+
},
|
|
4670
4679
|
onSelect(indices) {
|
|
4671
|
-
|
|
4680
|
+
this._update((draft) => {
|
|
4672
4681
|
draft.selectedIndices = indices;
|
|
4673
4682
|
draft.errors = [];
|
|
4674
4683
|
});
|
|
4675
4684
|
performRefresh == null ? void 0 : performRefresh();
|
|
4676
4685
|
onValueChange();
|
|
4677
|
-
|
|
4686
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4687
|
+
this._update((draft) => {
|
|
4688
|
+
draft.errors = errors;
|
|
4689
|
+
});
|
|
4678
4690
|
},
|
|
4679
4691
|
onBlur() {
|
|
4680
4692
|
},
|
|
@@ -4687,8 +4699,11 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4687
4699
|
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
4688
4700
|
},
|
|
4689
4701
|
validate() {
|
|
4690
|
-
const
|
|
4691
|
-
|
|
4702
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4703
|
+
this._update((draft) => {
|
|
4704
|
+
draft.errors = errors;
|
|
4705
|
+
});
|
|
4706
|
+
return errors.length === 0;
|
|
4692
4707
|
},
|
|
4693
4708
|
async getSubmittableValue() {
|
|
4694
4709
|
const selected = this.getSelectedChildren();
|
|
@@ -4718,7 +4733,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4718
4733
|
onSelect(indices) {
|
|
4719
4734
|
inputComponent.onSelect.call(this, indices);
|
|
4720
4735
|
if (this.validate()) {
|
|
4721
|
-
validateAsync(this
|
|
4736
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4722
4737
|
});
|
|
4723
4738
|
}
|
|
4724
4739
|
}
|
|
@@ -4919,13 +4934,16 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4919
4934
|
"onValueChange",
|
|
4920
4935
|
"summariser"
|
|
4921
4936
|
]);
|
|
4922
|
-
const update = getInputUpdateFunction(
|
|
4937
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4923
4938
|
const booleanComponent = __spreadValues({
|
|
4924
4939
|
type: "boolean",
|
|
4925
4940
|
uid,
|
|
4926
4941
|
id,
|
|
4927
4942
|
autoComplete: "",
|
|
4928
4943
|
value,
|
|
4944
|
+
_update(updateFn) {
|
|
4945
|
+
update(this, updateFn);
|
|
4946
|
+
},
|
|
4929
4947
|
onBlur() {
|
|
4930
4948
|
},
|
|
4931
4949
|
// Noop
|
|
@@ -4933,7 +4951,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4933
4951
|
},
|
|
4934
4952
|
// Noop
|
|
4935
4953
|
onChange(updatedValue) {
|
|
4936
|
-
|
|
4954
|
+
this._update((draft) => {
|
|
4937
4955
|
draft.errors = [];
|
|
4938
4956
|
draft.value = updatedValue;
|
|
4939
4957
|
});
|
|
@@ -4962,11 +4980,11 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4962
4980
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4963
4981
|
onChange(updatedValue) {
|
|
4964
4982
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4965
|
-
persist(this
|
|
4983
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4966
4984
|
});
|
|
4967
4985
|
},
|
|
4968
4986
|
async getSubmittableValue() {
|
|
4969
|
-
return persist(this
|
|
4987
|
+
return persist(this, this.getLocalValue());
|
|
4970
4988
|
},
|
|
4971
4989
|
getSubmittableValueSync() {
|
|
4972
4990
|
return this.persistedState.lastResponse;
|
|
@@ -4978,7 +4996,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4978
4996
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4979
4997
|
onChange(updatedValue) {
|
|
4980
4998
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4981
|
-
validateAsync(this
|
|
4999
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4982
5000
|
});
|
|
4983
5001
|
}
|
|
4984
5002
|
});
|
|
@@ -5423,9 +5441,9 @@ var getOrientationControl = ({
|
|
|
5423
5441
|
var DEBOUNCE_TIME = 400;
|
|
5424
5442
|
var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
|
|
5425
5443
|
const { uid, control, emptyMessage, margin, title } = searchProps;
|
|
5426
|
-
const update = getInputUpdateFunction(
|
|
5444
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5427
5445
|
let abortController = new AbortController();
|
|
5428
|
-
const search = (query, searchConfig) => {
|
|
5446
|
+
const search = (component2, query, searchConfig) => {
|
|
5429
5447
|
abortController.abort();
|
|
5430
5448
|
abortController = new AbortController();
|
|
5431
5449
|
const { signal } = abortController;
|
|
@@ -5435,7 +5453,7 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5435
5453
|
config: searchConfig
|
|
5436
5454
|
}).then((results) => {
|
|
5437
5455
|
if (!signal.aborted) {
|
|
5438
|
-
update((draft) => {
|
|
5456
|
+
update(component2, (draft) => {
|
|
5439
5457
|
draft.results = results;
|
|
5440
5458
|
draft.isLoading = false;
|
|
5441
5459
|
draft.error = void 0;
|
|
@@ -5443,33 +5461,15 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5443
5461
|
}
|
|
5444
5462
|
}).catch(() => {
|
|
5445
5463
|
if (!signal.aborted) {
|
|
5446
|
-
update((draft) => {
|
|
5464
|
+
update(component2, (draft) => {
|
|
5447
5465
|
draft.error = "No response";
|
|
5448
5466
|
draft.isLoading = false;
|
|
5449
5467
|
});
|
|
5450
5468
|
}
|
|
5451
5469
|
});
|
|
5452
5470
|
};
|
|
5453
|
-
const onSelect = ({ type, value }) => {
|
|
5454
|
-
if (type === "action") {
|
|
5455
|
-
void onBehavior({ type: "action", action: value });
|
|
5456
|
-
} else {
|
|
5457
|
-
update((draft) => {
|
|
5458
|
-
draft.query = value.query;
|
|
5459
|
-
draft.isLoading = true;
|
|
5460
|
-
});
|
|
5461
|
-
search(value.query, { method: value.method, param: value.param, url: value.url });
|
|
5462
|
-
}
|
|
5463
|
-
};
|
|
5464
5471
|
const debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
5465
|
-
const
|
|
5466
|
-
update((draft) => {
|
|
5467
|
-
draft.query = query;
|
|
5468
|
-
draft.isLoading = true;
|
|
5469
|
-
});
|
|
5470
|
-
debouncedSearch(query.trim());
|
|
5471
|
-
};
|
|
5472
|
-
return {
|
|
5472
|
+
const component = {
|
|
5473
5473
|
type: "search",
|
|
5474
5474
|
uid,
|
|
5475
5475
|
control,
|
|
@@ -5479,15 +5479,39 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5479
5479
|
isLoading: false,
|
|
5480
5480
|
query: "",
|
|
5481
5481
|
results: [],
|
|
5482
|
+
_update(updateFn) {
|
|
5483
|
+
update(this, updateFn);
|
|
5484
|
+
},
|
|
5482
5485
|
getSubmittableValue: async () => null,
|
|
5483
5486
|
getSubmittableValueSync: () => null,
|
|
5484
5487
|
getLocalValue: () => null,
|
|
5485
5488
|
getSummary: () => ({}),
|
|
5486
5489
|
// Noop
|
|
5487
5490
|
validate: () => true,
|
|
5488
|
-
onChange
|
|
5489
|
-
|
|
5491
|
+
onChange(query) {
|
|
5492
|
+
this._update((draft) => {
|
|
5493
|
+
draft.query = query;
|
|
5494
|
+
draft.isLoading = true;
|
|
5495
|
+
});
|
|
5496
|
+
debouncedSearch(this, query.trim());
|
|
5497
|
+
},
|
|
5498
|
+
onSelect({ type, value }) {
|
|
5499
|
+
if (type === "action") {
|
|
5500
|
+
void onBehavior({ type: "action", action: value });
|
|
5501
|
+
} else {
|
|
5502
|
+
this._update((draft) => {
|
|
5503
|
+
draft.query = value.query;
|
|
5504
|
+
draft.isLoading = true;
|
|
5505
|
+
});
|
|
5506
|
+
search(this, value.query, {
|
|
5507
|
+
method: value.method,
|
|
5508
|
+
param: value.param,
|
|
5509
|
+
url: value.url
|
|
5510
|
+
});
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5490
5513
|
};
|
|
5514
|
+
return component;
|
|
5491
5515
|
};
|
|
5492
5516
|
|
|
5493
5517
|
// src/revamp/domain/features/search/getPerformSearchFunction.ts
|
|
@@ -6217,29 +6241,6 @@ var formatDateOptions = {
|
|
|
6217
6241
|
dateStyle: "long"
|
|
6218
6242
|
};
|
|
6219
6243
|
|
|
6220
|
-
// src/revamp/utils/findComponent.ts
|
|
6221
|
-
var findComponent = (components, id, logEvent) => {
|
|
6222
|
-
const flattened = flattenComponents(components);
|
|
6223
|
-
const matching = flattened.filter((component) => component.uid === id);
|
|
6224
|
-
if (matching.length === 1) {
|
|
6225
|
-
return matching[0];
|
|
6226
|
-
}
|
|
6227
|
-
if (matching.length > 1) {
|
|
6228
|
-
throw new Error(`Multiple components with the same uid: ${id}`);
|
|
6229
|
-
}
|
|
6230
|
-
logEvent("error", "Failed to find domain layer component", {
|
|
6231
|
-
componentUid: id,
|
|
6232
|
-
componentsTree: flattened.map((component) => component.uid)
|
|
6233
|
-
});
|
|
6234
|
-
throw new Error(`Failed to find any components with uid: ${id}`);
|
|
6235
|
-
};
|
|
6236
|
-
var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
6237
|
-
if (hasChildren(component)) {
|
|
6238
|
-
return [...acc, component, ...flattenComponents(component.getChildren())];
|
|
6239
|
-
}
|
|
6240
|
-
return [...acc, component];
|
|
6241
|
-
}, []);
|
|
6242
|
-
|
|
6243
6244
|
// src/revamp/utils/useStableCallback.tsx
|
|
6244
6245
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
6245
6246
|
function useStableCallback(handler) {
|
|
@@ -6266,15 +6267,7 @@ function useDynamicFlowCore(props) {
|
|
|
6266
6267
|
[formatMessage, locale]
|
|
6267
6268
|
);
|
|
6268
6269
|
const rerender = useRerender();
|
|
6269
|
-
const rootComponentRef = useRef2(createRootDomainComponent());
|
|
6270
|
-
const updateComponent = useCallback2(
|
|
6271
|
-
(id, update) => {
|
|
6272
|
-
update(findComponent([rootComponentRef.current], id, logEvent));
|
|
6273
|
-
rerender();
|
|
6274
|
-
},
|
|
6275
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6276
|
-
[]
|
|
6277
|
-
);
|
|
6270
|
+
const rootComponentRef = useRef2(createRootDomainComponent(rerender));
|
|
6278
6271
|
const stepCount = useRef2(0);
|
|
6279
6272
|
const stepRef = useRef2(initialStep != null ? initialStep : null);
|
|
6280
6273
|
const etagRef = useRef2(null);
|
|
@@ -6319,25 +6312,24 @@ function useDynamicFlowCore(props) {
|
|
|
6319
6312
|
});
|
|
6320
6313
|
}
|
|
6321
6314
|
try {
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
});
|
|
6315
|
+
rootComponentRef.current.setStep(
|
|
6316
|
+
mapStepToComponent({
|
|
6317
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6318
|
+
stepLocalValue: localValue,
|
|
6319
|
+
step: newStep,
|
|
6320
|
+
displayStepTitle,
|
|
6321
|
+
loadingState: "idle",
|
|
6322
|
+
updateComponent: () => rerender(),
|
|
6323
|
+
getErrorMessageFunctions,
|
|
6324
|
+
trackEvent,
|
|
6325
|
+
logEvent,
|
|
6326
|
+
httpClient,
|
|
6327
|
+
onBehavior,
|
|
6328
|
+
onRefresh,
|
|
6329
|
+
onPoll,
|
|
6330
|
+
onValueChange
|
|
6331
|
+
})
|
|
6332
|
+
);
|
|
6341
6333
|
} catch (error) {
|
|
6342
6334
|
closeWithError(error);
|
|
6343
6335
|
}
|