@wise/dynamic-flow-client 4.3.12 → 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 +288 -291
- package/build/main.mjs +288 -291
- 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 +9 -9
- 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
|
});
|
|
@@ -2829,6 +2843,9 @@ var getRequiredCheck = (required, messageFunctions) => (value) => {
|
|
|
2829
2843
|
if (isArray(value) && value.length === 0) {
|
|
2830
2844
|
return messageFunctions.required();
|
|
2831
2845
|
}
|
|
2846
|
+
if (value === "") {
|
|
2847
|
+
return messageFunctions.required();
|
|
2848
|
+
}
|
|
2832
2849
|
return isNullish(value) ? messageFunctions.required() : null;
|
|
2833
2850
|
};
|
|
2834
2851
|
|
|
@@ -2995,7 +3012,7 @@ var getPerformPersistAsync = ({
|
|
|
2995
3012
|
}
|
|
2996
3013
|
return json[idProperty];
|
|
2997
3014
|
}
|
|
2998
|
-
} catch (
|
|
3015
|
+
} catch (e) {
|
|
2999
3016
|
trackFailure();
|
|
3000
3017
|
throw new Error(genericErrorMessage);
|
|
3001
3018
|
}
|
|
@@ -3422,23 +3439,19 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3422
3439
|
"onValueChange",
|
|
3423
3440
|
"summariser"
|
|
3424
3441
|
]);
|
|
3425
|
-
const update = getInputUpdateFunction(
|
|
3442
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3426
3443
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3427
3444
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
3428
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3429
|
-
const messages = getValidationErrors(currentValue);
|
|
3430
|
-
update((draft) => {
|
|
3431
|
-
draft.errors = messages;
|
|
3432
|
-
});
|
|
3433
|
-
return messages;
|
|
3434
|
-
};
|
|
3435
3445
|
const integerComponent = __spreadValues({
|
|
3436
3446
|
type: "integer",
|
|
3437
3447
|
uid,
|
|
3438
3448
|
id,
|
|
3439
3449
|
value,
|
|
3450
|
+
_update(updateFn) {
|
|
3451
|
+
update(this, updateFn);
|
|
3452
|
+
},
|
|
3440
3453
|
onBlur() {
|
|
3441
|
-
|
|
3454
|
+
this.validate();
|
|
3442
3455
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
3443
3456
|
},
|
|
3444
3457
|
onFocus() {
|
|
@@ -3446,7 +3459,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3446
3459
|
// Noop
|
|
3447
3460
|
onChange(updatedValue) {
|
|
3448
3461
|
const prevValue = this.value;
|
|
3449
|
-
|
|
3462
|
+
this._update((draft) => {
|
|
3450
3463
|
draft.errors = [];
|
|
3451
3464
|
draft.validationAsyncState.messages = {};
|
|
3452
3465
|
draft.value = updatedValue;
|
|
@@ -3468,8 +3481,11 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3468
3481
|
return this.value;
|
|
3469
3482
|
},
|
|
3470
3483
|
validate() {
|
|
3471
|
-
const
|
|
3472
|
-
|
|
3484
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3485
|
+
this._update((draft) => {
|
|
3486
|
+
draft.errors = errors;
|
|
3487
|
+
});
|
|
3488
|
+
return errors.length === 0;
|
|
3473
3489
|
}
|
|
3474
3490
|
}, rest);
|
|
3475
3491
|
if (performRefresh) {
|
|
@@ -3480,12 +3496,12 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3480
3496
|
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3481
3497
|
onBlur() {
|
|
3482
3498
|
if (this.validate()) {
|
|
3483
|
-
persist(this
|
|
3499
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3484
3500
|
});
|
|
3485
3501
|
}
|
|
3486
3502
|
},
|
|
3487
3503
|
async getSubmittableValue() {
|
|
3488
|
-
return persist(this
|
|
3504
|
+
return persist(this, this.getLocalValue());
|
|
3489
3505
|
},
|
|
3490
3506
|
getSubmittableValueSync() {
|
|
3491
3507
|
return this.persistedState.lastResponse;
|
|
@@ -3503,7 +3519,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3503
3519
|
onChange(updatedValue) {
|
|
3504
3520
|
integerComponent.onChange.call(this, updatedValue);
|
|
3505
3521
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
3506
|
-
validateAsync(this
|
|
3522
|
+
validateAsync(this, updatedValue);
|
|
3507
3523
|
}
|
|
3508
3524
|
}
|
|
3509
3525
|
});
|
|
@@ -3577,16 +3593,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3577
3593
|
(option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
|
|
3578
3594
|
);
|
|
3579
3595
|
const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
3580
|
-
const update = getInputUpdateFunction(
|
|
3596
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3581
3597
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3582
|
-
const
|
|
3583
|
-
const messages = getValidationErrors(currentValue);
|
|
3584
|
-
update((draft) => {
|
|
3585
|
-
draft.errors = messages;
|
|
3586
|
-
});
|
|
3587
|
-
return messages;
|
|
3588
|
-
};
|
|
3589
|
-
return __spreadProps(__spreadValues({
|
|
3598
|
+
const component = __spreadProps(__spreadValues({
|
|
3590
3599
|
uid,
|
|
3591
3600
|
type: "select",
|
|
3592
3601
|
children,
|
|
@@ -3594,6 +3603,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3594
3603
|
selectedIndex,
|
|
3595
3604
|
value: null
|
|
3596
3605
|
}, rest), {
|
|
3606
|
+
_update(updateFn) {
|
|
3607
|
+
update(this, updateFn);
|
|
3608
|
+
},
|
|
3597
3609
|
getChildren() {
|
|
3598
3610
|
return this.children;
|
|
3599
3611
|
},
|
|
@@ -3617,7 +3629,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3617
3629
|
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
3618
3630
|
},
|
|
3619
3631
|
onBlur() {
|
|
3620
|
-
|
|
3632
|
+
this.validate();
|
|
3621
3633
|
},
|
|
3622
3634
|
onFocus() {
|
|
3623
3635
|
},
|
|
@@ -3629,7 +3641,7 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3629
3641
|
schemaId: this.children[updatedIndex].analyticsId
|
|
3630
3642
|
});
|
|
3631
3643
|
}
|
|
3632
|
-
|
|
3644
|
+
this._update((draft) => {
|
|
3633
3645
|
draft.errors = [];
|
|
3634
3646
|
draft.selectedIndex = updatedIndex;
|
|
3635
3647
|
});
|
|
@@ -3639,10 +3651,14 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3639
3651
|
validate() {
|
|
3640
3652
|
var _a2, _b;
|
|
3641
3653
|
const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3654
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3655
|
+
this._update((draft) => {
|
|
3656
|
+
draft.errors = errors;
|
|
3657
|
+
});
|
|
3658
|
+
return errors.length === 0 && validChild;
|
|
3644
3659
|
}
|
|
3645
3660
|
});
|
|
3661
|
+
return component;
|
|
3646
3662
|
};
|
|
3647
3663
|
|
|
3648
3664
|
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
@@ -3737,29 +3753,25 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3737
3753
|
"summariser",
|
|
3738
3754
|
"value"
|
|
3739
3755
|
]);
|
|
3740
|
-
const update = getInputUpdateFunction(
|
|
3756
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3741
3757
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3742
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3743
|
-
const messages = getValidationErrors(currentValue);
|
|
3744
|
-
update((draft) => {
|
|
3745
|
-
draft.errors = messages;
|
|
3746
|
-
});
|
|
3747
|
-
return messages;
|
|
3748
|
-
};
|
|
3749
3758
|
const dateInputComponent = __spreadValues({
|
|
3750
3759
|
type: "date",
|
|
3751
3760
|
uid,
|
|
3752
3761
|
id,
|
|
3753
3762
|
value,
|
|
3763
|
+
_update(updateFn) {
|
|
3764
|
+
update(this, updateFn);
|
|
3765
|
+
},
|
|
3754
3766
|
onBlur() {
|
|
3755
|
-
|
|
3767
|
+
this.validate();
|
|
3756
3768
|
},
|
|
3757
3769
|
onFocus() {
|
|
3758
3770
|
},
|
|
3759
3771
|
// Noop
|
|
3760
3772
|
onChange(updatedValue) {
|
|
3761
3773
|
const prevValue = this.value;
|
|
3762
|
-
|
|
3774
|
+
this._update((draft) => {
|
|
3763
3775
|
draft.errors = [];
|
|
3764
3776
|
draft.validationAsyncState.messages = {};
|
|
3765
3777
|
draft.value = updatedValue;
|
|
@@ -3783,8 +3795,11 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3783
3795
|
return this.value;
|
|
3784
3796
|
},
|
|
3785
3797
|
validate() {
|
|
3786
|
-
const
|
|
3787
|
-
|
|
3798
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3799
|
+
this._update((draft) => {
|
|
3800
|
+
draft.errors = errors;
|
|
3801
|
+
});
|
|
3802
|
+
return errors.length === 0;
|
|
3788
3803
|
}
|
|
3789
3804
|
}, rest);
|
|
3790
3805
|
if (performRefresh) {
|
|
@@ -3797,12 +3812,12 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3797
3812
|
dateInputComponent.onChange.call(this, updatedValue);
|
|
3798
3813
|
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
3799
3814
|
if (isValid) {
|
|
3800
|
-
persist(this
|
|
3815
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3801
3816
|
});
|
|
3802
3817
|
}
|
|
3803
3818
|
},
|
|
3804
3819
|
async getSubmittableValue() {
|
|
3805
|
-
return persist(this
|
|
3820
|
+
return persist(this, this.getLocalValue());
|
|
3806
3821
|
},
|
|
3807
3822
|
getSubmittableValueSync() {
|
|
3808
3823
|
return this.persistedState.lastResponse;
|
|
@@ -3814,7 +3829,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3814
3829
|
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
3815
3830
|
onBlur() {
|
|
3816
3831
|
if (this.validate()) {
|
|
3817
|
-
validateAsync(this
|
|
3832
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
3818
3833
|
});
|
|
3819
3834
|
}
|
|
3820
3835
|
}
|
|
@@ -3917,29 +3932,25 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3917
3932
|
"onValueChange",
|
|
3918
3933
|
"summariser"
|
|
3919
3934
|
]);
|
|
3920
|
-
const update = getInputUpdateFunction(
|
|
3935
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3921
3936
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3922
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3923
|
-
const messages = getValidationErrors(currentValue);
|
|
3924
|
-
update((draft) => {
|
|
3925
|
-
draft.errors = messages;
|
|
3926
|
-
});
|
|
3927
|
-
return messages;
|
|
3928
|
-
};
|
|
3929
3937
|
const uploadComponent = __spreadValues({
|
|
3930
3938
|
type: "upload",
|
|
3931
3939
|
uid,
|
|
3932
3940
|
id,
|
|
3933
3941
|
format: "base64",
|
|
3934
3942
|
value,
|
|
3943
|
+
_update(updateFn) {
|
|
3944
|
+
update(this, updateFn);
|
|
3945
|
+
},
|
|
3935
3946
|
onBlur() {
|
|
3936
|
-
|
|
3947
|
+
this.validate();
|
|
3937
3948
|
},
|
|
3938
3949
|
onFocus() {
|
|
3939
3950
|
},
|
|
3940
3951
|
// Noop
|
|
3941
3952
|
async onUpload(updatedValue) {
|
|
3942
|
-
|
|
3953
|
+
this._update((draft) => {
|
|
3943
3954
|
draft.errors = [];
|
|
3944
3955
|
draft.value = updatedValue;
|
|
3945
3956
|
});
|
|
@@ -3961,8 +3972,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3961
3972
|
return this.value;
|
|
3962
3973
|
},
|
|
3963
3974
|
validate() {
|
|
3964
|
-
const
|
|
3965
|
-
|
|
3975
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3976
|
+
this._update((draft) => {
|
|
3977
|
+
draft.errors = errors;
|
|
3978
|
+
});
|
|
3979
|
+
return errors.length === 0;
|
|
3966
3980
|
}
|
|
3967
3981
|
}, rest);
|
|
3968
3982
|
if (!performPersistAsync) {
|
|
@@ -3972,14 +3986,14 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3972
3986
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
3973
3987
|
format,
|
|
3974
3988
|
async onUpload(file) {
|
|
3975
|
-
|
|
3989
|
+
this._update((draft) => {
|
|
3976
3990
|
draft.errors = [];
|
|
3977
3991
|
draft.value = file;
|
|
3978
3992
|
});
|
|
3979
3993
|
onValueChange();
|
|
3980
3994
|
const submission = format === "base64" && file ? await toBase64(file) : file;
|
|
3981
|
-
await persist(this
|
|
3982
|
-
|
|
3995
|
+
await persist(this, submission).catch((error) => {
|
|
3996
|
+
this._update((draft) => {
|
|
3983
3997
|
draft.persistedState.lastResponse = null;
|
|
3984
3998
|
draft.persistedState.lastSubmitted = null;
|
|
3985
3999
|
draft.persistedState.submission = Promise.resolve(null);
|
|
@@ -4058,23 +4072,19 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4058
4072
|
"summariser",
|
|
4059
4073
|
"value"
|
|
4060
4074
|
]);
|
|
4061
|
-
const update = getInputUpdateFunction(
|
|
4075
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4062
4076
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4063
4077
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
4064
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4065
|
-
const messages = getValidationErrors(currentValue);
|
|
4066
|
-
update((draft) => {
|
|
4067
|
-
draft.errors = messages;
|
|
4068
|
-
});
|
|
4069
|
-
return messages;
|
|
4070
|
-
};
|
|
4071
4078
|
const inputComponent = __spreadValues({
|
|
4072
4079
|
type: "text",
|
|
4073
4080
|
uid,
|
|
4074
4081
|
id,
|
|
4075
4082
|
value,
|
|
4083
|
+
_update(updateFn) {
|
|
4084
|
+
update(this, updateFn);
|
|
4085
|
+
},
|
|
4076
4086
|
onBlur() {
|
|
4077
|
-
|
|
4087
|
+
this.validate();
|
|
4078
4088
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
4079
4089
|
},
|
|
4080
4090
|
onFocus() {
|
|
@@ -4082,7 +4092,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4082
4092
|
// Noop
|
|
4083
4093
|
onChange(updatedValue) {
|
|
4084
4094
|
const prevValue = this.value;
|
|
4085
|
-
|
|
4095
|
+
this._update((draft) => {
|
|
4086
4096
|
draft.errors = [];
|
|
4087
4097
|
draft.validationAsyncState.messages = {};
|
|
4088
4098
|
draft.value = updatedValue;
|
|
@@ -4094,8 +4104,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4094
4104
|
return this.getSubmittableValueSync();
|
|
4095
4105
|
},
|
|
4096
4106
|
getSubmittableValueSync() {
|
|
4097
|
-
|
|
4098
|
-
return (_a2 = this.getLocalValue()) != null ? _a2 : null;
|
|
4107
|
+
return this.getLocalValue() || null;
|
|
4099
4108
|
},
|
|
4100
4109
|
getSummary() {
|
|
4101
4110
|
return summariser(this.getLocalValue());
|
|
@@ -4104,8 +4113,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4104
4113
|
return this.value;
|
|
4105
4114
|
},
|
|
4106
4115
|
validate() {
|
|
4107
|
-
const
|
|
4108
|
-
|
|
4116
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4117
|
+
this._update((draft) => {
|
|
4118
|
+
draft.errors = errors;
|
|
4119
|
+
});
|
|
4120
|
+
return errors.length === 0;
|
|
4109
4121
|
}
|
|
4110
4122
|
}, rest);
|
|
4111
4123
|
if (performRefresh) {
|
|
@@ -4116,12 +4128,12 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4116
4128
|
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
4117
4129
|
onBlur() {
|
|
4118
4130
|
if (this.validate()) {
|
|
4119
|
-
persist(this
|
|
4131
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4120
4132
|
});
|
|
4121
4133
|
}
|
|
4122
4134
|
},
|
|
4123
4135
|
async getSubmittableValue() {
|
|
4124
|
-
return persist(this
|
|
4136
|
+
return persist(this, this.getLocalValue());
|
|
4125
4137
|
},
|
|
4126
4138
|
getSubmittableValueSync() {
|
|
4127
4139
|
return this.persistedState.lastResponse;
|
|
@@ -4139,7 +4151,10 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4139
4151
|
onChange(updatedValue) {
|
|
4140
4152
|
inputComponent.onChange.call(this, updatedValue);
|
|
4141
4153
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
4142
|
-
validateAsync(this
|
|
4154
|
+
validateAsync(this, updatedValue);
|
|
4155
|
+
}
|
|
4156
|
+
if (!updatedValue) {
|
|
4157
|
+
validateAsync.cancel();
|
|
4143
4158
|
}
|
|
4144
4159
|
}
|
|
4145
4160
|
});
|
|
@@ -4274,9 +4289,9 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4274
4289
|
"createEditableComponent",
|
|
4275
4290
|
"summariser"
|
|
4276
4291
|
]);
|
|
4277
|
-
const update = getInputUpdateFunction(
|
|
4292
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4278
4293
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4279
|
-
|
|
4294
|
+
const repeatableComponent = __spreadProps(__spreadValues({
|
|
4280
4295
|
uid,
|
|
4281
4296
|
id,
|
|
4282
4297
|
type: "repeatable",
|
|
@@ -4290,8 +4305,11 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4290
4305
|
image: summary == null ? void 0 : summary.defaultImage
|
|
4291
4306
|
}
|
|
4292
4307
|
}, componentProps), {
|
|
4308
|
+
_update(updateFn) {
|
|
4309
|
+
update(this, updateFn);
|
|
4310
|
+
},
|
|
4293
4311
|
onEdit(itemIndex) {
|
|
4294
|
-
|
|
4312
|
+
this._update((draft) => {
|
|
4295
4313
|
draft.editableComponent = createEditableComponent(
|
|
4296
4314
|
draft.components[itemIndex].getLocalValue()
|
|
4297
4315
|
);
|
|
@@ -4299,7 +4317,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4299
4317
|
});
|
|
4300
4318
|
},
|
|
4301
4319
|
onAdd() {
|
|
4302
|
-
|
|
4320
|
+
this._update((draft) => {
|
|
4303
4321
|
draft.editableComponent = createEditableComponent(null);
|
|
4304
4322
|
draft.editableIndex = null;
|
|
4305
4323
|
draft.errors = [];
|
|
@@ -4311,7 +4329,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4311
4329
|
if (!isValid) {
|
|
4312
4330
|
return false;
|
|
4313
4331
|
}
|
|
4314
|
-
|
|
4332
|
+
this._update((draft) => {
|
|
4315
4333
|
if (draft.editableComponent === null) {
|
|
4316
4334
|
return;
|
|
4317
4335
|
}
|
|
@@ -4330,7 +4348,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4330
4348
|
return true;
|
|
4331
4349
|
},
|
|
4332
4350
|
onRemove() {
|
|
4333
|
-
|
|
4351
|
+
this._update((draft) => {
|
|
4334
4352
|
if (draft.editableIndex === null) {
|
|
4335
4353
|
return;
|
|
4336
4354
|
}
|
|
@@ -4358,12 +4376,13 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4358
4376
|
validate() {
|
|
4359
4377
|
const messages = getValidationErrors(this.getLocalValue());
|
|
4360
4378
|
const childComponentsValid = validateComponents(this.getChildren());
|
|
4361
|
-
|
|
4379
|
+
this._update((draft) => {
|
|
4362
4380
|
draft.errors = messages;
|
|
4363
4381
|
});
|
|
4364
4382
|
return messages.length === 0 && childComponentsValid;
|
|
4365
4383
|
}
|
|
4366
4384
|
});
|
|
4385
|
+
return repeatableComponent;
|
|
4367
4386
|
};
|
|
4368
4387
|
|
|
4369
4388
|
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
|
|
@@ -4463,30 +4482,26 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4463
4482
|
"onValueChange",
|
|
4464
4483
|
"summariser"
|
|
4465
4484
|
]);
|
|
4466
|
-
const update = getInputUpdateFunction(
|
|
4485
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4467
4486
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4468
4487
|
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
4469
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4470
|
-
const messages = getValidationErrors(currentValue);
|
|
4471
|
-
update((draft) => {
|
|
4472
|
-
draft.errors = messages;
|
|
4473
|
-
});
|
|
4474
|
-
return messages;
|
|
4475
|
-
};
|
|
4476
4488
|
const uploadComponent = __spreadValues({
|
|
4477
4489
|
type: "multi-upload",
|
|
4478
4490
|
uid,
|
|
4479
4491
|
id,
|
|
4480
4492
|
format: "base64",
|
|
4481
4493
|
files: [],
|
|
4494
|
+
_update(updateFn) {
|
|
4495
|
+
update(this, updateFn);
|
|
4496
|
+
},
|
|
4482
4497
|
onBlur() {
|
|
4483
|
-
|
|
4498
|
+
this.validate();
|
|
4484
4499
|
},
|
|
4485
4500
|
onFocus() {
|
|
4486
4501
|
},
|
|
4487
4502
|
// Noop
|
|
4488
4503
|
async onRemoveFile(index) {
|
|
4489
|
-
|
|
4504
|
+
this._update((draft) => {
|
|
4490
4505
|
draft.value.splice(index, 1);
|
|
4491
4506
|
draft.files.splice(index, 1);
|
|
4492
4507
|
});
|
|
@@ -4494,7 +4509,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4494
4509
|
async onInsertFile(index, file) {
|
|
4495
4510
|
const fileErrors = getFileValidationErrors(file);
|
|
4496
4511
|
const fileId = getRandomId();
|
|
4497
|
-
|
|
4512
|
+
this._update((draft) => {
|
|
4498
4513
|
draft.value.splice(index, 0, file);
|
|
4499
4514
|
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4500
4515
|
draft.errors = [];
|
|
@@ -4516,8 +4531,11 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4516
4531
|
return this.value;
|
|
4517
4532
|
},
|
|
4518
4533
|
validate() {
|
|
4519
|
-
const
|
|
4520
|
-
|
|
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);
|
|
4521
4539
|
}
|
|
4522
4540
|
}, rest);
|
|
4523
4541
|
if (!performPersistAsync) {
|
|
@@ -4529,7 +4547,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4529
4547
|
async onInsertFile(index, file) {
|
|
4530
4548
|
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4531
4549
|
const submission = format === "blob" ? file : await toBase64(file);
|
|
4532
|
-
await persist(index, submission);
|
|
4550
|
+
await persist(this, index, submission);
|
|
4533
4551
|
onValueChange();
|
|
4534
4552
|
return fileId;
|
|
4535
4553
|
},
|
|
@@ -4537,7 +4555,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4537
4555
|
var _a2;
|
|
4538
4556
|
await uploadComponent.onRemoveFile.call(this, index);
|
|
4539
4557
|
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4540
|
-
|
|
4558
|
+
this._update((draft) => {
|
|
4541
4559
|
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4542
4560
|
});
|
|
4543
4561
|
},
|
|
@@ -4643,17 +4661,10 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4643
4661
|
"performRefresh",
|
|
4644
4662
|
"onValueChange"
|
|
4645
4663
|
]);
|
|
4646
|
-
const update = getInputUpdateFunction(
|
|
4664
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4647
4665
|
const children = options.map((option) => option.component);
|
|
4648
4666
|
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4649
4667
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4650
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4651
|
-
const messages = getValidationErrors(currentValue);
|
|
4652
|
-
update((draft) => {
|
|
4653
|
-
draft.errors = messages;
|
|
4654
|
-
});
|
|
4655
|
-
return messages;
|
|
4656
|
-
};
|
|
4657
4668
|
const inputComponent = __spreadProps(__spreadValues({
|
|
4658
4669
|
uid,
|
|
4659
4670
|
type: "multi-select",
|
|
@@ -4662,14 +4673,20 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4662
4673
|
selectedIndices,
|
|
4663
4674
|
value: null
|
|
4664
4675
|
}, rest), {
|
|
4676
|
+
_update(updateFn) {
|
|
4677
|
+
update(this, updateFn);
|
|
4678
|
+
},
|
|
4665
4679
|
onSelect(indices) {
|
|
4666
|
-
|
|
4680
|
+
this._update((draft) => {
|
|
4667
4681
|
draft.selectedIndices = indices;
|
|
4668
4682
|
draft.errors = [];
|
|
4669
4683
|
});
|
|
4670
4684
|
performRefresh == null ? void 0 : performRefresh();
|
|
4671
4685
|
onValueChange();
|
|
4672
|
-
|
|
4686
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4687
|
+
this._update((draft) => {
|
|
4688
|
+
draft.errors = errors;
|
|
4689
|
+
});
|
|
4673
4690
|
},
|
|
4674
4691
|
onBlur() {
|
|
4675
4692
|
},
|
|
@@ -4682,8 +4699,11 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4682
4699
|
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
4683
4700
|
},
|
|
4684
4701
|
validate() {
|
|
4685
|
-
const
|
|
4686
|
-
|
|
4702
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4703
|
+
this._update((draft) => {
|
|
4704
|
+
draft.errors = errors;
|
|
4705
|
+
});
|
|
4706
|
+
return errors.length === 0;
|
|
4687
4707
|
},
|
|
4688
4708
|
async getSubmittableValue() {
|
|
4689
4709
|
const selected = this.getSelectedChildren();
|
|
@@ -4713,7 +4733,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4713
4733
|
onSelect(indices) {
|
|
4714
4734
|
inputComponent.onSelect.call(this, indices);
|
|
4715
4735
|
if (this.validate()) {
|
|
4716
|
-
validateAsync(this
|
|
4736
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4717
4737
|
});
|
|
4718
4738
|
}
|
|
4719
4739
|
}
|
|
@@ -4914,13 +4934,16 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4914
4934
|
"onValueChange",
|
|
4915
4935
|
"summariser"
|
|
4916
4936
|
]);
|
|
4917
|
-
const update = getInputUpdateFunction(
|
|
4937
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4918
4938
|
const booleanComponent = __spreadValues({
|
|
4919
4939
|
type: "boolean",
|
|
4920
4940
|
uid,
|
|
4921
4941
|
id,
|
|
4922
4942
|
autoComplete: "",
|
|
4923
4943
|
value,
|
|
4944
|
+
_update(updateFn) {
|
|
4945
|
+
update(this, updateFn);
|
|
4946
|
+
},
|
|
4924
4947
|
onBlur() {
|
|
4925
4948
|
},
|
|
4926
4949
|
// Noop
|
|
@@ -4928,7 +4951,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4928
4951
|
},
|
|
4929
4952
|
// Noop
|
|
4930
4953
|
onChange(updatedValue) {
|
|
4931
|
-
|
|
4954
|
+
this._update((draft) => {
|
|
4932
4955
|
draft.errors = [];
|
|
4933
4956
|
draft.value = updatedValue;
|
|
4934
4957
|
});
|
|
@@ -4957,11 +4980,11 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4957
4980
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4958
4981
|
onChange(updatedValue) {
|
|
4959
4982
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4960
|
-
persist(this
|
|
4983
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4961
4984
|
});
|
|
4962
4985
|
},
|
|
4963
4986
|
async getSubmittableValue() {
|
|
4964
|
-
return persist(this
|
|
4987
|
+
return persist(this, this.getLocalValue());
|
|
4965
4988
|
},
|
|
4966
4989
|
getSubmittableValueSync() {
|
|
4967
4990
|
return this.persistedState.lastResponse;
|
|
@@ -4973,7 +4996,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4973
4996
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4974
4997
|
onChange(updatedValue) {
|
|
4975
4998
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4976
|
-
validateAsync(this
|
|
4999
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4977
5000
|
});
|
|
4978
5001
|
}
|
|
4979
5002
|
});
|
|
@@ -5418,9 +5441,9 @@ var getOrientationControl = ({
|
|
|
5418
5441
|
var DEBOUNCE_TIME = 400;
|
|
5419
5442
|
var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
|
|
5420
5443
|
const { uid, control, emptyMessage, margin, title } = searchProps;
|
|
5421
|
-
const update = getInputUpdateFunction(
|
|
5444
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5422
5445
|
let abortController = new AbortController();
|
|
5423
|
-
const search = (query, searchConfig) => {
|
|
5446
|
+
const search = (component2, query, searchConfig) => {
|
|
5424
5447
|
abortController.abort();
|
|
5425
5448
|
abortController = new AbortController();
|
|
5426
5449
|
const { signal } = abortController;
|
|
@@ -5430,7 +5453,7 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5430
5453
|
config: searchConfig
|
|
5431
5454
|
}).then((results) => {
|
|
5432
5455
|
if (!signal.aborted) {
|
|
5433
|
-
update((draft) => {
|
|
5456
|
+
update(component2, (draft) => {
|
|
5434
5457
|
draft.results = results;
|
|
5435
5458
|
draft.isLoading = false;
|
|
5436
5459
|
draft.error = void 0;
|
|
@@ -5438,33 +5461,15 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5438
5461
|
}
|
|
5439
5462
|
}).catch(() => {
|
|
5440
5463
|
if (!signal.aborted) {
|
|
5441
|
-
update((draft) => {
|
|
5464
|
+
update(component2, (draft) => {
|
|
5442
5465
|
draft.error = "No response";
|
|
5443
5466
|
draft.isLoading = false;
|
|
5444
5467
|
});
|
|
5445
5468
|
}
|
|
5446
5469
|
});
|
|
5447
5470
|
};
|
|
5448
|
-
const onSelect = ({ type, value }) => {
|
|
5449
|
-
if (type === "action") {
|
|
5450
|
-
void onBehavior({ type: "action", action: value });
|
|
5451
|
-
} else {
|
|
5452
|
-
update((draft) => {
|
|
5453
|
-
draft.query = value.query;
|
|
5454
|
-
draft.isLoading = true;
|
|
5455
|
-
});
|
|
5456
|
-
search(value.query, { method: value.method, param: value.param, url: value.url });
|
|
5457
|
-
}
|
|
5458
|
-
};
|
|
5459
5471
|
const debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
5460
|
-
const
|
|
5461
|
-
update((draft) => {
|
|
5462
|
-
draft.query = query;
|
|
5463
|
-
draft.isLoading = true;
|
|
5464
|
-
});
|
|
5465
|
-
debouncedSearch(query.trim());
|
|
5466
|
-
};
|
|
5467
|
-
return {
|
|
5472
|
+
const component = {
|
|
5468
5473
|
type: "search",
|
|
5469
5474
|
uid,
|
|
5470
5475
|
control,
|
|
@@ -5474,15 +5479,39 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5474
5479
|
isLoading: false,
|
|
5475
5480
|
query: "",
|
|
5476
5481
|
results: [],
|
|
5482
|
+
_update(updateFn) {
|
|
5483
|
+
update(this, updateFn);
|
|
5484
|
+
},
|
|
5477
5485
|
getSubmittableValue: async () => null,
|
|
5478
5486
|
getSubmittableValueSync: () => null,
|
|
5479
5487
|
getLocalValue: () => null,
|
|
5480
5488
|
getSummary: () => ({}),
|
|
5481
5489
|
// Noop
|
|
5482
5490
|
validate: () => true,
|
|
5483
|
-
onChange
|
|
5484
|
-
|
|
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
|
+
}
|
|
5485
5513
|
};
|
|
5514
|
+
return component;
|
|
5486
5515
|
};
|
|
5487
5516
|
|
|
5488
5517
|
// src/revamp/domain/features/search/getPerformSearchFunction.ts
|
|
@@ -6212,29 +6241,6 @@ var formatDateOptions = {
|
|
|
6212
6241
|
dateStyle: "long"
|
|
6213
6242
|
};
|
|
6214
6243
|
|
|
6215
|
-
// src/revamp/utils/findComponent.ts
|
|
6216
|
-
var findComponent = (components, id, logEvent) => {
|
|
6217
|
-
const flattened = flattenComponents(components);
|
|
6218
|
-
const matching = flattened.filter((component) => component.uid === id);
|
|
6219
|
-
if (matching.length === 1) {
|
|
6220
|
-
return matching[0];
|
|
6221
|
-
}
|
|
6222
|
-
if (matching.length > 1) {
|
|
6223
|
-
throw new Error(`Multiple components with the same uid: ${id}`);
|
|
6224
|
-
}
|
|
6225
|
-
logEvent("error", "Failed to find domain layer component", {
|
|
6226
|
-
componentUid: id,
|
|
6227
|
-
componentsTree: flattened.map((component) => component.uid)
|
|
6228
|
-
});
|
|
6229
|
-
throw new Error(`Failed to find any components with uid: ${id}`);
|
|
6230
|
-
};
|
|
6231
|
-
var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
6232
|
-
if (hasChildren(component)) {
|
|
6233
|
-
return [...acc, component, ...flattenComponents(component.getChildren())];
|
|
6234
|
-
}
|
|
6235
|
-
return [...acc, component];
|
|
6236
|
-
}, []);
|
|
6237
|
-
|
|
6238
6244
|
// src/revamp/utils/useStableCallback.tsx
|
|
6239
6245
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
6240
6246
|
function useStableCallback(handler) {
|
|
@@ -6261,15 +6267,7 @@ function useDynamicFlowCore(props) {
|
|
|
6261
6267
|
[formatMessage, locale]
|
|
6262
6268
|
);
|
|
6263
6269
|
const rerender = useRerender();
|
|
6264
|
-
const rootComponentRef = useRef2(createRootDomainComponent());
|
|
6265
|
-
const updateComponent = useCallback2(
|
|
6266
|
-
(id, update) => {
|
|
6267
|
-
update(findComponent([rootComponentRef.current], id, logEvent));
|
|
6268
|
-
rerender();
|
|
6269
|
-
},
|
|
6270
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6271
|
-
[]
|
|
6272
|
-
);
|
|
6270
|
+
const rootComponentRef = useRef2(createRootDomainComponent(rerender));
|
|
6273
6271
|
const stepCount = useRef2(0);
|
|
6274
6272
|
const stepRef = useRef2(initialStep != null ? initialStep : null);
|
|
6275
6273
|
const etagRef = useRef2(null);
|
|
@@ -6314,25 +6312,24 @@ function useDynamicFlowCore(props) {
|
|
|
6314
6312
|
});
|
|
6315
6313
|
}
|
|
6316
6314
|
try {
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
});
|
|
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
|
+
);
|
|
6336
6333
|
} catch (error) {
|
|
6337
6334
|
closeWithError(error);
|
|
6338
6335
|
}
|