@wise/dynamic-flow-client 4.3.13 → 4.4.0
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 +439 -311
- package/build/main.mjs +439 -311
- package/build/types/revamp/domain/components/AlertComponent.d.ts +2 -14
- 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/ListComponent.d.ts +3 -16
- package/build/types/revamp/domain/components/ModalContentComponent.d.ts +11 -0
- 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 +7 -2
- package/build/types/revamp/domain/components/SelectInputComponent.d.ts +2 -2
- package/build/types/revamp/domain/components/StepDomainComponent.d.ts +6 -0
- 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/layout/modalToContent.d.ts +4 -0
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +1 -1
- package/build/types/revamp/domain/mappers/utils/call-to-action-utils.d.ts +1 -13
- package/build/types/revamp/domain/types.d.ts +17 -6
- package/build/types/revamp/flow/executeSubmission.d.ts +4 -0
- package/build/types/revamp/flow/getResponseType.d.ts +1 -1
- package/build/types/revamp/flow/response-utils.d.ts +2 -1
- package/build/types/revamp/renderers/mappers/modalContentComponentToProps.d.ts +4 -0
- package/build/types/revamp/renderers/stepComponentToProps.d.ts +1 -1
- package/package.json +10 -10
- package/build/types/revamp/utils/findComponent.d.ts +0 -3
package/build/main.mjs
CHANGED
|
@@ -1041,6 +1041,7 @@ function getChildren(node) {
|
|
|
1041
1041
|
case "form":
|
|
1042
1042
|
case "section":
|
|
1043
1043
|
case "step":
|
|
1044
|
+
case "modal-content":
|
|
1044
1045
|
return node.childrenProps;
|
|
1045
1046
|
case "columns":
|
|
1046
1047
|
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
@@ -1116,7 +1117,6 @@ var getRenderFunction = (renderers) => {
|
|
|
1116
1117
|
};
|
|
1117
1118
|
|
|
1118
1119
|
// src/revamp/utils/type-utils.ts
|
|
1119
|
-
var hasChildren = (component) => "getChildren" in component && typeof component.getChildren === "function";
|
|
1120
1120
|
var isHiddenComponent = (component) => "hidden" in component && component.hidden;
|
|
1121
1121
|
var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
1122
1122
|
var isArrayLocalValue = (value) => Array.isArray(value);
|
|
@@ -1639,20 +1639,20 @@ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__s
|
|
|
1639
1639
|
});
|
|
1640
1640
|
|
|
1641
1641
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
1642
|
-
var stepComponentToProps = ({
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
}
|
|
1655
|
-
const childrenProps =
|
|
1642
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1643
|
+
const {
|
|
1644
|
+
uid,
|
|
1645
|
+
back,
|
|
1646
|
+
control,
|
|
1647
|
+
description,
|
|
1648
|
+
error,
|
|
1649
|
+
external,
|
|
1650
|
+
loadingState,
|
|
1651
|
+
step,
|
|
1652
|
+
title,
|
|
1653
|
+
onBehavior
|
|
1654
|
+
} = component;
|
|
1655
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1656
1656
|
return __spreadValues({
|
|
1657
1657
|
type: "step",
|
|
1658
1658
|
id: step.id,
|
|
@@ -1684,6 +1684,21 @@ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
|
1684
1684
|
};
|
|
1685
1685
|
};
|
|
1686
1686
|
|
|
1687
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1688
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1689
|
+
const { uid, open, title, close } = component;
|
|
1690
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1691
|
+
return __spreadValues({
|
|
1692
|
+
uid,
|
|
1693
|
+
type: "modal-content",
|
|
1694
|
+
open,
|
|
1695
|
+
title,
|
|
1696
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1697
|
+
childrenProps,
|
|
1698
|
+
onClose: close.bind(component)
|
|
1699
|
+
}, rendererMapperProps);
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1687
1702
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1688
1703
|
var componentToRendererProps = (component, rendererMapperProps) => {
|
|
1689
1704
|
if (isHiddenComponent(component)) {
|
|
@@ -1734,6 +1749,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1734
1749
|
return markdownComponentToProps(component, rendererMapperProps);
|
|
1735
1750
|
case "modal":
|
|
1736
1751
|
return modalComponentToProps(component, rendererMapperProps);
|
|
1752
|
+
case "modal-content":
|
|
1753
|
+
return modalContentComponentToProps(component, rendererMapperProps);
|
|
1737
1754
|
case "multi-select":
|
|
1738
1755
|
return multiSelectInputComponentToProps(component, rendererMapperProps);
|
|
1739
1756
|
case "multi-upload":
|
|
@@ -1770,47 +1787,13 @@ import { validateStep } from "@wise/dynamic-flow-types";
|
|
|
1770
1787
|
import { useCallback as useCallback2, useEffect, useMemo, useRef as useRef2, useState } from "react";
|
|
1771
1788
|
import { useIntl as useIntl2 } from "react-intl";
|
|
1772
1789
|
|
|
1773
|
-
// src/revamp/domain/components/
|
|
1774
|
-
var
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
},
|
|
1781
|
-
getLocalValue() {
|
|
1782
|
-
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1783
|
-
},
|
|
1784
|
-
async getSubmittableValue() {
|
|
1785
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
1786
|
-
},
|
|
1787
|
-
getSubmittableValueSync() {
|
|
1788
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
|
|
1789
|
-
},
|
|
1790
|
-
getSummary() {
|
|
1791
|
-
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1792
|
-
},
|
|
1793
|
-
validate() {
|
|
1794
|
-
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1795
|
-
},
|
|
1796
|
-
setLoadingState(loadingState) {
|
|
1797
|
-
var _a;
|
|
1798
|
-
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1799
|
-
},
|
|
1800
|
-
getLoadingState() {
|
|
1801
|
-
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1802
|
-
},
|
|
1803
|
-
getTrackEvent() {
|
|
1804
|
-
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1805
|
-
},
|
|
1806
|
-
hasStep() {
|
|
1807
|
-
return Boolean(this.stepComponent);
|
|
1808
|
-
},
|
|
1809
|
-
stop() {
|
|
1810
|
-
var _a;
|
|
1811
|
-
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1790
|
+
// src/revamp/domain/components/utils/component-utils.ts
|
|
1791
|
+
var getInputUpdateFunction = (updateComponent) => {
|
|
1792
|
+
return (component, updateFn) => {
|
|
1793
|
+
updateFn(component);
|
|
1794
|
+
updateComponent();
|
|
1795
|
+
};
|
|
1796
|
+
};
|
|
1814
1797
|
|
|
1815
1798
|
// src/revamp/utils/component-utils.ts
|
|
1816
1799
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
@@ -1843,6 +1826,72 @@ var mergeModels = (valueA, valueB) => {
|
|
|
1843
1826
|
return valueB;
|
|
1844
1827
|
};
|
|
1845
1828
|
|
|
1829
|
+
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1830
|
+
var createRootDomainComponent = (updateComponent) => {
|
|
1831
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1832
|
+
const rootComponent = {
|
|
1833
|
+
type: "root",
|
|
1834
|
+
uid: "root",
|
|
1835
|
+
stepComponent: null,
|
|
1836
|
+
_update(updateFn) {
|
|
1837
|
+
update(this, updateFn);
|
|
1838
|
+
},
|
|
1839
|
+
dismissAllModals() {
|
|
1840
|
+
var _a;
|
|
1841
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
|
|
1842
|
+
},
|
|
1843
|
+
dismissModal() {
|
|
1844
|
+
var _a;
|
|
1845
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
|
|
1846
|
+
},
|
|
1847
|
+
showModal(modal) {
|
|
1848
|
+
var _a;
|
|
1849
|
+
(_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
|
|
1850
|
+
},
|
|
1851
|
+
getChildren() {
|
|
1852
|
+
return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
|
|
1853
|
+
},
|
|
1854
|
+
getLocalValue() {
|
|
1855
|
+
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1856
|
+
},
|
|
1857
|
+
async getSubmittableValue() {
|
|
1858
|
+
return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1859
|
+
},
|
|
1860
|
+
getSubmittableValueSync() {
|
|
1861
|
+
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1862
|
+
},
|
|
1863
|
+
getSummary() {
|
|
1864
|
+
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1865
|
+
},
|
|
1866
|
+
validate() {
|
|
1867
|
+
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1868
|
+
},
|
|
1869
|
+
setLoadingState(loadingState) {
|
|
1870
|
+
var _a;
|
|
1871
|
+
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1872
|
+
},
|
|
1873
|
+
getLoadingState() {
|
|
1874
|
+
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1875
|
+
},
|
|
1876
|
+
getTrackEvent() {
|
|
1877
|
+
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1878
|
+
},
|
|
1879
|
+
hasStep() {
|
|
1880
|
+
return Boolean(this.stepComponent);
|
|
1881
|
+
},
|
|
1882
|
+
stop() {
|
|
1883
|
+
var _a;
|
|
1884
|
+
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1885
|
+
},
|
|
1886
|
+
setStep(stepComponent) {
|
|
1887
|
+
this._update((draft) => {
|
|
1888
|
+
draft.stepComponent = stepComponent;
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
return rootComponent;
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1846
1895
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
1847
1896
|
var getSummariser = (schema) => (value) => {
|
|
1848
1897
|
const { summary, icon, image } = schema;
|
|
@@ -1883,25 +1932,38 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
|
1883
1932
|
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
1884
1933
|
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
1885
1934
|
|
|
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
1935
|
// src/revamp/domain/components/StepDomainComponent.ts
|
|
1895
1936
|
var createStepComponent = (stepProps) => {
|
|
1896
1937
|
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
1897
|
-
const update = getInputUpdateFunction(
|
|
1898
|
-
|
|
1938
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1939
|
+
const component = __spreadProps(__spreadValues({
|
|
1899
1940
|
uid
|
|
1900
1941
|
}, rest), {
|
|
1901
1942
|
type: "step",
|
|
1943
|
+
modals: [],
|
|
1944
|
+
dismissModal() {
|
|
1945
|
+
var _a2;
|
|
1946
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
1947
|
+
},
|
|
1948
|
+
dismissAllModals() {
|
|
1949
|
+
this._update((draft) => {
|
|
1950
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
1951
|
+
});
|
|
1952
|
+
},
|
|
1953
|
+
showModal(modal) {
|
|
1954
|
+
this._update((draft) => {
|
|
1955
|
+
draft.modals = [...draft.modals, modal];
|
|
1956
|
+
});
|
|
1957
|
+
},
|
|
1958
|
+
_update(updateFn) {
|
|
1959
|
+
update(this, updateFn);
|
|
1960
|
+
},
|
|
1902
1961
|
getChildren() {
|
|
1903
1962
|
return this.components;
|
|
1904
1963
|
},
|
|
1964
|
+
getModals() {
|
|
1965
|
+
return this.modals;
|
|
1966
|
+
},
|
|
1905
1967
|
async getSubmittableValue() {
|
|
1906
1968
|
return getSubmittableData(this.components);
|
|
1907
1969
|
},
|
|
@@ -1918,15 +1980,19 @@ var createStepComponent = (stepProps) => {
|
|
|
1918
1980
|
return validateComponents(this.getChildren());
|
|
1919
1981
|
},
|
|
1920
1982
|
setLoadingState(loadingState) {
|
|
1921
|
-
|
|
1983
|
+
this._update((draft) => {
|
|
1922
1984
|
draft.loadingState = loadingState;
|
|
1923
1985
|
});
|
|
1924
1986
|
},
|
|
1925
1987
|
stop() {
|
|
1926
1988
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
1927
1989
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
1990
|
+
this._update((draft) => {
|
|
1991
|
+
draft.modals = [];
|
|
1992
|
+
});
|
|
1928
1993
|
}
|
|
1929
1994
|
});
|
|
1995
|
+
return component;
|
|
1930
1996
|
};
|
|
1931
1997
|
|
|
1932
1998
|
// src/revamp/domain/mappers/utils/behavior-utils.ts
|
|
@@ -2052,9 +2118,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2052
2118
|
void onBehavior(behavior);
|
|
2053
2119
|
};
|
|
2054
2120
|
switch (behavior.type) {
|
|
2055
|
-
case "action":
|
|
2121
|
+
case "action":
|
|
2122
|
+
case "modal":
|
|
2123
|
+
case "dismiss": {
|
|
2056
2124
|
return {
|
|
2057
|
-
type:
|
|
2125
|
+
type: behavior.type,
|
|
2058
2126
|
title: title != null ? title : "",
|
|
2059
2127
|
accessibilityDescription,
|
|
2060
2128
|
onClick
|
|
@@ -2350,6 +2418,22 @@ var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
|
2350
2418
|
// src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
2351
2419
|
var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
|
|
2352
2420
|
|
|
2421
|
+
// src/revamp/domain/components/utils/getRandomId.ts
|
|
2422
|
+
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
2423
|
+
|
|
2424
|
+
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
2425
|
+
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
2426
|
+
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
2427
|
+
return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
|
|
2428
|
+
}
|
|
2429
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2430
|
+
const keysA = Object.keys(valueA);
|
|
2431
|
+
const keysB = Object.keys(valueB);
|
|
2432
|
+
return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
|
|
2433
|
+
}
|
|
2434
|
+
return valueA === valueB;
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2353
2437
|
// src/revamp/domain/features/utils/http-utils.ts
|
|
2354
2438
|
function constructPayload({
|
|
2355
2439
|
value,
|
|
@@ -2377,37 +2461,21 @@ var abortAndResetController = (abortController) => {
|
|
|
2377
2461
|
return new AbortController();
|
|
2378
2462
|
};
|
|
2379
2463
|
|
|
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
2464
|
// src/revamp/domain/features/persistAsync/getComponentPersistAsync.ts
|
|
2397
2465
|
var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
2398
2466
|
/**
|
|
2399
2467
|
* Will update the persistedState when a new request is made, and will update
|
|
2400
2468
|
* the value or set errors when the request completes.
|
|
2401
2469
|
*/
|
|
2402
|
-
async (
|
|
2403
|
-
const { abortController, lastSubmitted, submission } = persistedState;
|
|
2470
|
+
async (component, currentValue) => {
|
|
2471
|
+
const { abortController, lastSubmitted, submission } = component.persistedState;
|
|
2404
2472
|
if (isExactLocalValueMatch(lastSubmitted, currentValue)) {
|
|
2405
2473
|
return submission;
|
|
2406
2474
|
}
|
|
2407
2475
|
const newAbortController = abortAndResetController(abortController);
|
|
2408
2476
|
if (isNullish(currentValue) || currentValue === "") {
|
|
2409
2477
|
const resolvedNull = Promise.resolve(null);
|
|
2410
|
-
update((draft) => {
|
|
2478
|
+
update(component, (draft) => {
|
|
2411
2479
|
draft.persistedState.abortController = newAbortController;
|
|
2412
2480
|
draft.persistedState.lastResponse = null;
|
|
2413
2481
|
draft.persistedState.lastSubmitted = currentValue;
|
|
@@ -2417,7 +2485,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2417
2485
|
}
|
|
2418
2486
|
const { signal } = newAbortController;
|
|
2419
2487
|
const newSubmission = performPersistAsync({ value: currentValue, signal }).then((newValue) => {
|
|
2420
|
-
update((draft) => {
|
|
2488
|
+
update(component, (draft) => {
|
|
2421
2489
|
draft.persistedState.lastResponse = newValue;
|
|
2422
2490
|
});
|
|
2423
2491
|
return newValue;
|
|
@@ -2425,14 +2493,14 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2425
2493
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2426
2494
|
return null;
|
|
2427
2495
|
}
|
|
2428
|
-
update((draft) => {
|
|
2496
|
+
update(component, (draft) => {
|
|
2429
2497
|
draft.errors = [error.message];
|
|
2430
2498
|
draft.persistedState.lastResponse = null;
|
|
2431
2499
|
draft.persistedState.lastSubmitted = null;
|
|
2432
2500
|
});
|
|
2433
2501
|
throw error;
|
|
2434
2502
|
});
|
|
2435
|
-
update((draft) => {
|
|
2503
|
+
update(component, (draft) => {
|
|
2436
2504
|
draft.persistedState = {
|
|
2437
2505
|
abortController: newAbortController,
|
|
2438
2506
|
lastResponse: null,
|
|
@@ -2448,19 +2516,19 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2448
2516
|
* Will update the persistedState when a new request is made, and will update
|
|
2449
2517
|
* the value or set errors when the request completes.
|
|
2450
2518
|
*/
|
|
2451
|
-
async (index, value) => {
|
|
2519
|
+
async (component, index, value) => {
|
|
2452
2520
|
if (isNullish(value)) {
|
|
2453
2521
|
throw new Error("Value must be a file or base64 string.");
|
|
2454
2522
|
}
|
|
2455
2523
|
const newAbortController = new AbortController();
|
|
2456
2524
|
const { signal } = newAbortController;
|
|
2457
2525
|
const newSubmission = performPersistAsync({ value, signal }).then((newValue) => {
|
|
2458
|
-
update((draft) => {
|
|
2526
|
+
update(component, (draft) => {
|
|
2459
2527
|
draft.persistedState[index].lastResponse = newValue;
|
|
2460
2528
|
});
|
|
2461
2529
|
return newValue;
|
|
2462
2530
|
}).catch((error) => {
|
|
2463
|
-
update((draft) => {
|
|
2531
|
+
update(component, (draft) => {
|
|
2464
2532
|
draft.persistedState = [
|
|
2465
2533
|
...draft.persistedState.slice(0, index),
|
|
2466
2534
|
...draft.persistedState.slice(index + 1)
|
|
@@ -2470,7 +2538,7 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2470
2538
|
});
|
|
2471
2539
|
throw error;
|
|
2472
2540
|
});
|
|
2473
|
-
update((draft) => {
|
|
2541
|
+
update(component, (draft) => {
|
|
2474
2542
|
draft.persistedState = [
|
|
2475
2543
|
...draft.persistedState.slice(0, index),
|
|
2476
2544
|
{
|
|
@@ -2565,11 +2633,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2565
2633
|
* Will update the validationAsyncState when a new request is made, and will update
|
|
2566
2634
|
* the description or set errors when the request completes.
|
|
2567
2635
|
*/
|
|
2568
|
-
async (
|
|
2569
|
-
const { abortController } = validationAsyncState;
|
|
2636
|
+
async (component, currentValue) => {
|
|
2637
|
+
const { abortController } = component.validationAsyncState;
|
|
2570
2638
|
const newAbortController = abortAndResetController(abortController);
|
|
2571
2639
|
if (isNullish(currentValue)) {
|
|
2572
|
-
update((draft) => {
|
|
2640
|
+
update(component, (draft) => {
|
|
2573
2641
|
draft.validationAsyncState = {
|
|
2574
2642
|
abortController: newAbortController,
|
|
2575
2643
|
lastSubmitted: currentValue,
|
|
@@ -2580,7 +2648,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2580
2648
|
}
|
|
2581
2649
|
const { signal } = newAbortController;
|
|
2582
2650
|
const newSubmission = performValidationAsync({ value: currentValue, signal }).then((message) => {
|
|
2583
|
-
update((draft) => {
|
|
2651
|
+
update(component, (draft) => {
|
|
2584
2652
|
if (message) {
|
|
2585
2653
|
draft.validationAsyncState.messages.success = message;
|
|
2586
2654
|
}
|
|
@@ -2590,11 +2658,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2590
2658
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2591
2659
|
return null;
|
|
2592
2660
|
}
|
|
2593
|
-
update((draft) => {
|
|
2661
|
+
update(component, (draft) => {
|
|
2594
2662
|
draft.validationAsyncState.messages.error = error.message;
|
|
2595
2663
|
});
|
|
2596
2664
|
});
|
|
2597
|
-
update((draft) => {
|
|
2665
|
+
update(component, (draft) => {
|
|
2598
2666
|
draft.validationAsyncState = {
|
|
2599
2667
|
abortController: newAbortController,
|
|
2600
2668
|
lastSubmitted: currentValue,
|
|
@@ -2627,22 +2695,18 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2627
2695
|
"onValueChange",
|
|
2628
2696
|
"summariser"
|
|
2629
2697
|
]);
|
|
2630
|
-
const update = getInputUpdateFunction(
|
|
2698
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2631
2699
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
2632
2700
|
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
2701
|
const numberComponent = __spreadValues({
|
|
2641
2702
|
type: "number",
|
|
2642
2703
|
uid,
|
|
2643
2704
|
id,
|
|
2705
|
+
_update(updateFn) {
|
|
2706
|
+
update(this, updateFn);
|
|
2707
|
+
},
|
|
2644
2708
|
onBlur() {
|
|
2645
|
-
|
|
2709
|
+
this.validate();
|
|
2646
2710
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
2647
2711
|
},
|
|
2648
2712
|
onFocus() {
|
|
@@ -2650,7 +2714,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2650
2714
|
// Noop
|
|
2651
2715
|
onChange(updatedValue) {
|
|
2652
2716
|
const prevValue = this.value;
|
|
2653
|
-
|
|
2717
|
+
this._update((draft) => {
|
|
2654
2718
|
draft.errors = [];
|
|
2655
2719
|
draft.validationAsyncState.messages = {};
|
|
2656
2720
|
draft.value = updatedValue;
|
|
@@ -2672,8 +2736,11 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2672
2736
|
return this.value;
|
|
2673
2737
|
},
|
|
2674
2738
|
validate() {
|
|
2675
|
-
const
|
|
2676
|
-
|
|
2739
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
2740
|
+
this._update((draft) => {
|
|
2741
|
+
draft.errors = errors;
|
|
2742
|
+
});
|
|
2743
|
+
return errors.length === 0;
|
|
2677
2744
|
}
|
|
2678
2745
|
}, rest);
|
|
2679
2746
|
if (performRefresh) {
|
|
@@ -2684,12 +2751,12 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2684
2751
|
return __spreadProps(__spreadValues({}, numberComponent), {
|
|
2685
2752
|
onBlur() {
|
|
2686
2753
|
if (this.validate()) {
|
|
2687
|
-
persist(this
|
|
2754
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
2688
2755
|
});
|
|
2689
2756
|
}
|
|
2690
2757
|
},
|
|
2691
2758
|
async getSubmittableValue() {
|
|
2692
|
-
return persist(this
|
|
2759
|
+
return persist(this, this.getLocalValue());
|
|
2693
2760
|
},
|
|
2694
2761
|
getSubmittableValueSync() {
|
|
2695
2762
|
return this.persistedState.lastResponse;
|
|
@@ -2707,7 +2774,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2707
2774
|
onChange(updatedValue) {
|
|
2708
2775
|
numberComponent.onChange.call(this, updatedValue);
|
|
2709
2776
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
2710
|
-
validateAsync(this
|
|
2777
|
+
validateAsync(this, updatedValue);
|
|
2711
2778
|
}
|
|
2712
2779
|
}
|
|
2713
2780
|
});
|
|
@@ -2943,6 +3010,16 @@ function assertActionResponseBody(body) {
|
|
|
2943
3010
|
);
|
|
2944
3011
|
}
|
|
2945
3012
|
}
|
|
3013
|
+
function assertModalResponseBody(body) {
|
|
3014
|
+
if (isObject(body)) {
|
|
3015
|
+
if ("content" in body && isArray(body.content)) {
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
throw new Error(
|
|
3020
|
+
"Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
|
|
3021
|
+
);
|
|
3022
|
+
}
|
|
2946
3023
|
function isErrorResponseBody(body) {
|
|
2947
3024
|
return Boolean(
|
|
2948
3025
|
isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
@@ -2998,7 +3075,7 @@ var getPerformPersistAsync = ({
|
|
|
2998
3075
|
}
|
|
2999
3076
|
return json[idProperty];
|
|
3000
3077
|
}
|
|
3001
|
-
} catch (
|
|
3078
|
+
} catch (e) {
|
|
3002
3079
|
trackFailure();
|
|
3003
3080
|
throw new Error(genericErrorMessage);
|
|
3004
3081
|
}
|
|
@@ -3425,23 +3502,19 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3425
3502
|
"onValueChange",
|
|
3426
3503
|
"summariser"
|
|
3427
3504
|
]);
|
|
3428
|
-
const update = getInputUpdateFunction(
|
|
3505
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3429
3506
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3430
3507
|
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
3508
|
const integerComponent = __spreadValues({
|
|
3439
3509
|
type: "integer",
|
|
3440
3510
|
uid,
|
|
3441
3511
|
id,
|
|
3442
3512
|
value,
|
|
3513
|
+
_update(updateFn) {
|
|
3514
|
+
update(this, updateFn);
|
|
3515
|
+
},
|
|
3443
3516
|
onBlur() {
|
|
3444
|
-
|
|
3517
|
+
this.validate();
|
|
3445
3518
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
3446
3519
|
},
|
|
3447
3520
|
onFocus() {
|
|
@@ -3449,7 +3522,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3449
3522
|
// Noop
|
|
3450
3523
|
onChange(updatedValue) {
|
|
3451
3524
|
const prevValue = this.value;
|
|
3452
|
-
|
|
3525
|
+
this._update((draft) => {
|
|
3453
3526
|
draft.errors = [];
|
|
3454
3527
|
draft.validationAsyncState.messages = {};
|
|
3455
3528
|
draft.value = updatedValue;
|
|
@@ -3471,8 +3544,11 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3471
3544
|
return this.value;
|
|
3472
3545
|
},
|
|
3473
3546
|
validate() {
|
|
3474
|
-
const
|
|
3475
|
-
|
|
3547
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3548
|
+
this._update((draft) => {
|
|
3549
|
+
draft.errors = errors;
|
|
3550
|
+
});
|
|
3551
|
+
return errors.length === 0;
|
|
3476
3552
|
}
|
|
3477
3553
|
}, rest);
|
|
3478
3554
|
if (performRefresh) {
|
|
@@ -3483,12 +3559,12 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3483
3559
|
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3484
3560
|
onBlur() {
|
|
3485
3561
|
if (this.validate()) {
|
|
3486
|
-
persist(this
|
|
3562
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3487
3563
|
});
|
|
3488
3564
|
}
|
|
3489
3565
|
},
|
|
3490
3566
|
async getSubmittableValue() {
|
|
3491
|
-
return persist(this
|
|
3567
|
+
return persist(this, this.getLocalValue());
|
|
3492
3568
|
},
|
|
3493
3569
|
getSubmittableValueSync() {
|
|
3494
3570
|
return this.persistedState.lastResponse;
|
|
@@ -3506,7 +3582,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3506
3582
|
onChange(updatedValue) {
|
|
3507
3583
|
integerComponent.onChange.call(this, updatedValue);
|
|
3508
3584
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
3509
|
-
validateAsync(this
|
|
3585
|
+
validateAsync(this, updatedValue);
|
|
3510
3586
|
}
|
|
3511
3587
|
}
|
|
3512
3588
|
});
|
|
@@ -3580,16 +3656,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3580
3656
|
(option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
|
|
3581
3657
|
);
|
|
3582
3658
|
const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
3583
|
-
const update = getInputUpdateFunction(
|
|
3659
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3584
3660
|
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({
|
|
3661
|
+
const component = __spreadProps(__spreadValues({
|
|
3593
3662
|
uid,
|
|
3594
3663
|
type: "select",
|
|
3595
3664
|
children,
|
|
@@ -3597,6 +3666,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3597
3666
|
selectedIndex,
|
|
3598
3667
|
value: null
|
|
3599
3668
|
}, rest), {
|
|
3669
|
+
_update(updateFn) {
|
|
3670
|
+
update(this, updateFn);
|
|
3671
|
+
},
|
|
3600
3672
|
getChildren() {
|
|
3601
3673
|
return this.children;
|
|
3602
3674
|
},
|
|
@@ -3620,19 +3692,22 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3620
3692
|
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
3621
3693
|
},
|
|
3622
3694
|
onBlur() {
|
|
3623
|
-
|
|
3695
|
+
this.validate();
|
|
3624
3696
|
},
|
|
3625
3697
|
onFocus() {
|
|
3626
3698
|
},
|
|
3627
3699
|
// noop
|
|
3628
3700
|
onSelect(updatedIndex) {
|
|
3701
|
+
if (updatedIndex === this.selectedIndex) {
|
|
3702
|
+
return;
|
|
3703
|
+
}
|
|
3629
3704
|
if (updatedIndex !== null && this.analyticsId) {
|
|
3630
3705
|
selectProps.trackEvent("OneOf Selected", {
|
|
3631
3706
|
oneOfId: this.analyticsId,
|
|
3632
3707
|
schemaId: this.children[updatedIndex].analyticsId
|
|
3633
3708
|
});
|
|
3634
3709
|
}
|
|
3635
|
-
|
|
3710
|
+
this._update((draft) => {
|
|
3636
3711
|
draft.errors = [];
|
|
3637
3712
|
draft.selectedIndex = updatedIndex;
|
|
3638
3713
|
});
|
|
@@ -3642,10 +3717,14 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3642
3717
|
validate() {
|
|
3643
3718
|
var _a2, _b;
|
|
3644
3719
|
const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3720
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3721
|
+
this._update((draft) => {
|
|
3722
|
+
draft.errors = errors;
|
|
3723
|
+
});
|
|
3724
|
+
return errors.length === 0 && validChild;
|
|
3647
3725
|
}
|
|
3648
3726
|
});
|
|
3727
|
+
return component;
|
|
3649
3728
|
};
|
|
3650
3729
|
|
|
3651
3730
|
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
@@ -3740,29 +3819,25 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3740
3819
|
"summariser",
|
|
3741
3820
|
"value"
|
|
3742
3821
|
]);
|
|
3743
|
-
const update = getInputUpdateFunction(
|
|
3822
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3744
3823
|
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
3824
|
const dateInputComponent = __spreadValues({
|
|
3753
3825
|
type: "date",
|
|
3754
3826
|
uid,
|
|
3755
3827
|
id,
|
|
3756
3828
|
value,
|
|
3829
|
+
_update(updateFn) {
|
|
3830
|
+
update(this, updateFn);
|
|
3831
|
+
},
|
|
3757
3832
|
onBlur() {
|
|
3758
|
-
|
|
3833
|
+
this.validate();
|
|
3759
3834
|
},
|
|
3760
3835
|
onFocus() {
|
|
3761
3836
|
},
|
|
3762
3837
|
// Noop
|
|
3763
3838
|
onChange(updatedValue) {
|
|
3764
3839
|
const prevValue = this.value;
|
|
3765
|
-
|
|
3840
|
+
this._update((draft) => {
|
|
3766
3841
|
draft.errors = [];
|
|
3767
3842
|
draft.validationAsyncState.messages = {};
|
|
3768
3843
|
draft.value = updatedValue;
|
|
@@ -3786,8 +3861,11 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3786
3861
|
return this.value;
|
|
3787
3862
|
},
|
|
3788
3863
|
validate() {
|
|
3789
|
-
const
|
|
3790
|
-
|
|
3864
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3865
|
+
this._update((draft) => {
|
|
3866
|
+
draft.errors = errors;
|
|
3867
|
+
});
|
|
3868
|
+
return errors.length === 0;
|
|
3791
3869
|
}
|
|
3792
3870
|
}, rest);
|
|
3793
3871
|
if (performRefresh) {
|
|
@@ -3800,12 +3878,12 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3800
3878
|
dateInputComponent.onChange.call(this, updatedValue);
|
|
3801
3879
|
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
3802
3880
|
if (isValid) {
|
|
3803
|
-
persist(this
|
|
3881
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3804
3882
|
});
|
|
3805
3883
|
}
|
|
3806
3884
|
},
|
|
3807
3885
|
async getSubmittableValue() {
|
|
3808
|
-
return persist(this
|
|
3886
|
+
return persist(this, this.getLocalValue());
|
|
3809
3887
|
},
|
|
3810
3888
|
getSubmittableValueSync() {
|
|
3811
3889
|
return this.persistedState.lastResponse;
|
|
@@ -3817,7 +3895,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3817
3895
|
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
3818
3896
|
onBlur() {
|
|
3819
3897
|
if (this.validate()) {
|
|
3820
|
-
validateAsync(this
|
|
3898
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
3821
3899
|
});
|
|
3822
3900
|
}
|
|
3823
3901
|
}
|
|
@@ -3920,29 +3998,25 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3920
3998
|
"onValueChange",
|
|
3921
3999
|
"summariser"
|
|
3922
4000
|
]);
|
|
3923
|
-
const update = getInputUpdateFunction(
|
|
4001
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3924
4002
|
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
4003
|
const uploadComponent = __spreadValues({
|
|
3933
4004
|
type: "upload",
|
|
3934
4005
|
uid,
|
|
3935
4006
|
id,
|
|
3936
4007
|
format: "base64",
|
|
3937
4008
|
value,
|
|
4009
|
+
_update(updateFn) {
|
|
4010
|
+
update(this, updateFn);
|
|
4011
|
+
},
|
|
3938
4012
|
onBlur() {
|
|
3939
|
-
|
|
4013
|
+
this.validate();
|
|
3940
4014
|
},
|
|
3941
4015
|
onFocus() {
|
|
3942
4016
|
},
|
|
3943
4017
|
// Noop
|
|
3944
4018
|
async onUpload(updatedValue) {
|
|
3945
|
-
|
|
4019
|
+
this._update((draft) => {
|
|
3946
4020
|
draft.errors = [];
|
|
3947
4021
|
draft.value = updatedValue;
|
|
3948
4022
|
});
|
|
@@ -3964,8 +4038,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3964
4038
|
return this.value;
|
|
3965
4039
|
},
|
|
3966
4040
|
validate() {
|
|
3967
|
-
const
|
|
3968
|
-
|
|
4041
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4042
|
+
this._update((draft) => {
|
|
4043
|
+
draft.errors = errors;
|
|
4044
|
+
});
|
|
4045
|
+
return errors.length === 0;
|
|
3969
4046
|
}
|
|
3970
4047
|
}, rest);
|
|
3971
4048
|
if (!performPersistAsync) {
|
|
@@ -3975,14 +4052,14 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3975
4052
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
3976
4053
|
format,
|
|
3977
4054
|
async onUpload(file) {
|
|
3978
|
-
|
|
4055
|
+
this._update((draft) => {
|
|
3979
4056
|
draft.errors = [];
|
|
3980
4057
|
draft.value = file;
|
|
3981
4058
|
});
|
|
3982
4059
|
onValueChange();
|
|
3983
4060
|
const submission = format === "base64" && file ? await toBase64(file) : file;
|
|
3984
|
-
await persist(this
|
|
3985
|
-
|
|
4061
|
+
await persist(this, submission).catch((error) => {
|
|
4062
|
+
this._update((draft) => {
|
|
3986
4063
|
draft.persistedState.lastResponse = null;
|
|
3987
4064
|
draft.persistedState.lastSubmitted = null;
|
|
3988
4065
|
draft.persistedState.submission = Promise.resolve(null);
|
|
@@ -4061,23 +4138,19 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4061
4138
|
"summariser",
|
|
4062
4139
|
"value"
|
|
4063
4140
|
]);
|
|
4064
|
-
const update = getInputUpdateFunction(
|
|
4141
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4065
4142
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4066
4143
|
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
4144
|
const inputComponent = __spreadValues({
|
|
4075
4145
|
type: "text",
|
|
4076
4146
|
uid,
|
|
4077
4147
|
id,
|
|
4078
4148
|
value,
|
|
4149
|
+
_update(updateFn) {
|
|
4150
|
+
update(this, updateFn);
|
|
4151
|
+
},
|
|
4079
4152
|
onBlur() {
|
|
4080
|
-
|
|
4153
|
+
this.validate();
|
|
4081
4154
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
4082
4155
|
},
|
|
4083
4156
|
onFocus() {
|
|
@@ -4085,7 +4158,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4085
4158
|
// Noop
|
|
4086
4159
|
onChange(updatedValue) {
|
|
4087
4160
|
const prevValue = this.value;
|
|
4088
|
-
|
|
4161
|
+
this._update((draft) => {
|
|
4089
4162
|
draft.errors = [];
|
|
4090
4163
|
draft.validationAsyncState.messages = {};
|
|
4091
4164
|
draft.value = updatedValue;
|
|
@@ -4106,8 +4179,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4106
4179
|
return this.value;
|
|
4107
4180
|
},
|
|
4108
4181
|
validate() {
|
|
4109
|
-
const
|
|
4110
|
-
|
|
4182
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4183
|
+
this._update((draft) => {
|
|
4184
|
+
draft.errors = errors;
|
|
4185
|
+
});
|
|
4186
|
+
return errors.length === 0;
|
|
4111
4187
|
}
|
|
4112
4188
|
}, rest);
|
|
4113
4189
|
if (performRefresh) {
|
|
@@ -4118,12 +4194,12 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4118
4194
|
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
4119
4195
|
onBlur() {
|
|
4120
4196
|
if (this.validate()) {
|
|
4121
|
-
persist(this
|
|
4197
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4122
4198
|
});
|
|
4123
4199
|
}
|
|
4124
4200
|
},
|
|
4125
4201
|
async getSubmittableValue() {
|
|
4126
|
-
return persist(this
|
|
4202
|
+
return persist(this, this.getLocalValue());
|
|
4127
4203
|
},
|
|
4128
4204
|
getSubmittableValueSync() {
|
|
4129
4205
|
return this.persistedState.lastResponse;
|
|
@@ -4141,7 +4217,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4141
4217
|
onChange(updatedValue) {
|
|
4142
4218
|
inputComponent.onChange.call(this, updatedValue);
|
|
4143
4219
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
4144
|
-
validateAsync(this
|
|
4220
|
+
validateAsync(this, updatedValue);
|
|
4145
4221
|
}
|
|
4146
4222
|
if (!updatedValue) {
|
|
4147
4223
|
validateAsync.cancel();
|
|
@@ -4279,9 +4355,9 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4279
4355
|
"createEditableComponent",
|
|
4280
4356
|
"summariser"
|
|
4281
4357
|
]);
|
|
4282
|
-
const update = getInputUpdateFunction(
|
|
4358
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4283
4359
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4284
|
-
|
|
4360
|
+
const repeatableComponent = __spreadProps(__spreadValues({
|
|
4285
4361
|
uid,
|
|
4286
4362
|
id,
|
|
4287
4363
|
type: "repeatable",
|
|
@@ -4295,8 +4371,11 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4295
4371
|
image: summary == null ? void 0 : summary.defaultImage
|
|
4296
4372
|
}
|
|
4297
4373
|
}, componentProps), {
|
|
4374
|
+
_update(updateFn) {
|
|
4375
|
+
update(this, updateFn);
|
|
4376
|
+
},
|
|
4298
4377
|
onEdit(itemIndex) {
|
|
4299
|
-
|
|
4378
|
+
this._update((draft) => {
|
|
4300
4379
|
draft.editableComponent = createEditableComponent(
|
|
4301
4380
|
draft.components[itemIndex].getLocalValue()
|
|
4302
4381
|
);
|
|
@@ -4304,7 +4383,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4304
4383
|
});
|
|
4305
4384
|
},
|
|
4306
4385
|
onAdd() {
|
|
4307
|
-
|
|
4386
|
+
this._update((draft) => {
|
|
4308
4387
|
draft.editableComponent = createEditableComponent(null);
|
|
4309
4388
|
draft.editableIndex = null;
|
|
4310
4389
|
draft.errors = [];
|
|
@@ -4316,7 +4395,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4316
4395
|
if (!isValid) {
|
|
4317
4396
|
return false;
|
|
4318
4397
|
}
|
|
4319
|
-
|
|
4398
|
+
this._update((draft) => {
|
|
4320
4399
|
if (draft.editableComponent === null) {
|
|
4321
4400
|
return;
|
|
4322
4401
|
}
|
|
@@ -4335,7 +4414,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4335
4414
|
return true;
|
|
4336
4415
|
},
|
|
4337
4416
|
onRemove() {
|
|
4338
|
-
|
|
4417
|
+
this._update((draft) => {
|
|
4339
4418
|
if (draft.editableIndex === null) {
|
|
4340
4419
|
return;
|
|
4341
4420
|
}
|
|
@@ -4363,12 +4442,13 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4363
4442
|
validate() {
|
|
4364
4443
|
const messages = getValidationErrors(this.getLocalValue());
|
|
4365
4444
|
const childComponentsValid = validateComponents(this.getChildren());
|
|
4366
|
-
|
|
4445
|
+
this._update((draft) => {
|
|
4367
4446
|
draft.errors = messages;
|
|
4368
4447
|
});
|
|
4369
4448
|
return messages.length === 0 && childComponentsValid;
|
|
4370
4449
|
}
|
|
4371
4450
|
});
|
|
4451
|
+
return repeatableComponent;
|
|
4372
4452
|
};
|
|
4373
4453
|
|
|
4374
4454
|
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
|
|
@@ -4468,30 +4548,26 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4468
4548
|
"onValueChange",
|
|
4469
4549
|
"summariser"
|
|
4470
4550
|
]);
|
|
4471
|
-
const update = getInputUpdateFunction(
|
|
4551
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4472
4552
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4473
4553
|
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
4554
|
const uploadComponent = __spreadValues({
|
|
4482
4555
|
type: "multi-upload",
|
|
4483
4556
|
uid,
|
|
4484
4557
|
id,
|
|
4485
4558
|
format: "base64",
|
|
4486
4559
|
files: [],
|
|
4560
|
+
_update(updateFn) {
|
|
4561
|
+
update(this, updateFn);
|
|
4562
|
+
},
|
|
4487
4563
|
onBlur() {
|
|
4488
|
-
|
|
4564
|
+
this.validate();
|
|
4489
4565
|
},
|
|
4490
4566
|
onFocus() {
|
|
4491
4567
|
},
|
|
4492
4568
|
// Noop
|
|
4493
4569
|
async onRemoveFile(index) {
|
|
4494
|
-
|
|
4570
|
+
this._update((draft) => {
|
|
4495
4571
|
draft.value.splice(index, 1);
|
|
4496
4572
|
draft.files.splice(index, 1);
|
|
4497
4573
|
});
|
|
@@ -4499,7 +4575,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4499
4575
|
async onInsertFile(index, file) {
|
|
4500
4576
|
const fileErrors = getFileValidationErrors(file);
|
|
4501
4577
|
const fileId = getRandomId();
|
|
4502
|
-
|
|
4578
|
+
this._update((draft) => {
|
|
4503
4579
|
draft.value.splice(index, 0, file);
|
|
4504
4580
|
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4505
4581
|
draft.errors = [];
|
|
@@ -4521,8 +4597,11 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4521
4597
|
return this.value;
|
|
4522
4598
|
},
|
|
4523
4599
|
validate() {
|
|
4524
|
-
const
|
|
4525
|
-
|
|
4600
|
+
const errorMsgs = getValidationErrors(this.getLocalValue());
|
|
4601
|
+
this._update((draft) => {
|
|
4602
|
+
draft.errors = errorMsgs;
|
|
4603
|
+
});
|
|
4604
|
+
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
4526
4605
|
}
|
|
4527
4606
|
}, rest);
|
|
4528
4607
|
if (!performPersistAsync) {
|
|
@@ -4534,7 +4613,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4534
4613
|
async onInsertFile(index, file) {
|
|
4535
4614
|
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4536
4615
|
const submission = format === "blob" ? file : await toBase64(file);
|
|
4537
|
-
await persist(index, submission);
|
|
4616
|
+
await persist(this, index, submission);
|
|
4538
4617
|
onValueChange();
|
|
4539
4618
|
return fileId;
|
|
4540
4619
|
},
|
|
@@ -4542,7 +4621,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4542
4621
|
var _a2;
|
|
4543
4622
|
await uploadComponent.onRemoveFile.call(this, index);
|
|
4544
4623
|
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4545
|
-
|
|
4624
|
+
this._update((draft) => {
|
|
4546
4625
|
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4547
4626
|
});
|
|
4548
4627
|
},
|
|
@@ -4648,17 +4727,10 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4648
4727
|
"performRefresh",
|
|
4649
4728
|
"onValueChange"
|
|
4650
4729
|
]);
|
|
4651
|
-
const update = getInputUpdateFunction(
|
|
4730
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4652
4731
|
const children = options.map((option) => option.component);
|
|
4653
4732
|
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4654
4733
|
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
4734
|
const inputComponent = __spreadProps(__spreadValues({
|
|
4663
4735
|
uid,
|
|
4664
4736
|
type: "multi-select",
|
|
@@ -4667,14 +4739,20 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4667
4739
|
selectedIndices,
|
|
4668
4740
|
value: null
|
|
4669
4741
|
}, rest), {
|
|
4742
|
+
_update(updateFn) {
|
|
4743
|
+
update(this, updateFn);
|
|
4744
|
+
},
|
|
4670
4745
|
onSelect(indices) {
|
|
4671
|
-
|
|
4746
|
+
this._update((draft) => {
|
|
4672
4747
|
draft.selectedIndices = indices;
|
|
4673
4748
|
draft.errors = [];
|
|
4674
4749
|
});
|
|
4675
4750
|
performRefresh == null ? void 0 : performRefresh();
|
|
4676
4751
|
onValueChange();
|
|
4677
|
-
|
|
4752
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4753
|
+
this._update((draft) => {
|
|
4754
|
+
draft.errors = errors;
|
|
4755
|
+
});
|
|
4678
4756
|
},
|
|
4679
4757
|
onBlur() {
|
|
4680
4758
|
},
|
|
@@ -4687,8 +4765,11 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4687
4765
|
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
4688
4766
|
},
|
|
4689
4767
|
validate() {
|
|
4690
|
-
const
|
|
4691
|
-
|
|
4768
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4769
|
+
this._update((draft) => {
|
|
4770
|
+
draft.errors = errors;
|
|
4771
|
+
});
|
|
4772
|
+
return errors.length === 0;
|
|
4692
4773
|
},
|
|
4693
4774
|
async getSubmittableValue() {
|
|
4694
4775
|
const selected = this.getSelectedChildren();
|
|
@@ -4718,7 +4799,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4718
4799
|
onSelect(indices) {
|
|
4719
4800
|
inputComponent.onSelect.call(this, indices);
|
|
4720
4801
|
if (this.validate()) {
|
|
4721
|
-
validateAsync(this
|
|
4802
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4722
4803
|
});
|
|
4723
4804
|
}
|
|
4724
4805
|
}
|
|
@@ -4919,13 +5000,16 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4919
5000
|
"onValueChange",
|
|
4920
5001
|
"summariser"
|
|
4921
5002
|
]);
|
|
4922
|
-
const update = getInputUpdateFunction(
|
|
5003
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4923
5004
|
const booleanComponent = __spreadValues({
|
|
4924
5005
|
type: "boolean",
|
|
4925
5006
|
uid,
|
|
4926
5007
|
id,
|
|
4927
5008
|
autoComplete: "",
|
|
4928
5009
|
value,
|
|
5010
|
+
_update(updateFn) {
|
|
5011
|
+
update(this, updateFn);
|
|
5012
|
+
},
|
|
4929
5013
|
onBlur() {
|
|
4930
5014
|
},
|
|
4931
5015
|
// Noop
|
|
@@ -4933,7 +5017,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4933
5017
|
},
|
|
4934
5018
|
// Noop
|
|
4935
5019
|
onChange(updatedValue) {
|
|
4936
|
-
|
|
5020
|
+
this._update((draft) => {
|
|
4937
5021
|
draft.errors = [];
|
|
4938
5022
|
draft.value = updatedValue;
|
|
4939
5023
|
});
|
|
@@ -4962,11 +5046,11 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4962
5046
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4963
5047
|
onChange(updatedValue) {
|
|
4964
5048
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4965
|
-
persist(this
|
|
5049
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4966
5050
|
});
|
|
4967
5051
|
},
|
|
4968
5052
|
async getSubmittableValue() {
|
|
4969
|
-
return persist(this
|
|
5053
|
+
return persist(this, this.getLocalValue());
|
|
4970
5054
|
},
|
|
4971
5055
|
getSubmittableValueSync() {
|
|
4972
5056
|
return this.persistedState.lastResponse;
|
|
@@ -4978,7 +5062,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4978
5062
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
4979
5063
|
onChange(updatedValue) {
|
|
4980
5064
|
booleanComponent.onChange.call(this, updatedValue);
|
|
4981
|
-
validateAsync(this
|
|
5065
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4982
5066
|
});
|
|
4983
5067
|
}
|
|
4984
5068
|
});
|
|
@@ -5423,9 +5507,9 @@ var getOrientationControl = ({
|
|
|
5423
5507
|
var DEBOUNCE_TIME = 400;
|
|
5424
5508
|
var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
|
|
5425
5509
|
const { uid, control, emptyMessage, margin, title } = searchProps;
|
|
5426
|
-
const update = getInputUpdateFunction(
|
|
5510
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5427
5511
|
let abortController = new AbortController();
|
|
5428
|
-
const search = (query, searchConfig) => {
|
|
5512
|
+
const search = (component2, query, searchConfig) => {
|
|
5429
5513
|
abortController.abort();
|
|
5430
5514
|
abortController = new AbortController();
|
|
5431
5515
|
const { signal } = abortController;
|
|
@@ -5435,7 +5519,7 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5435
5519
|
config: searchConfig
|
|
5436
5520
|
}).then((results) => {
|
|
5437
5521
|
if (!signal.aborted) {
|
|
5438
|
-
update((draft) => {
|
|
5522
|
+
update(component2, (draft) => {
|
|
5439
5523
|
draft.results = results;
|
|
5440
5524
|
draft.isLoading = false;
|
|
5441
5525
|
draft.error = void 0;
|
|
@@ -5443,33 +5527,15 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5443
5527
|
}
|
|
5444
5528
|
}).catch(() => {
|
|
5445
5529
|
if (!signal.aborted) {
|
|
5446
|
-
update((draft) => {
|
|
5530
|
+
update(component2, (draft) => {
|
|
5447
5531
|
draft.error = "No response";
|
|
5448
5532
|
draft.isLoading = false;
|
|
5449
5533
|
});
|
|
5450
5534
|
}
|
|
5451
5535
|
});
|
|
5452
5536
|
};
|
|
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
5537
|
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 {
|
|
5538
|
+
const component = {
|
|
5473
5539
|
type: "search",
|
|
5474
5540
|
uid,
|
|
5475
5541
|
control,
|
|
@@ -5479,15 +5545,39 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5479
5545
|
isLoading: false,
|
|
5480
5546
|
query: "",
|
|
5481
5547
|
results: [],
|
|
5548
|
+
_update(updateFn) {
|
|
5549
|
+
update(this, updateFn);
|
|
5550
|
+
},
|
|
5482
5551
|
getSubmittableValue: async () => null,
|
|
5483
5552
|
getSubmittableValueSync: () => null,
|
|
5484
5553
|
getLocalValue: () => null,
|
|
5485
5554
|
getSummary: () => ({}),
|
|
5486
5555
|
// Noop
|
|
5487
5556
|
validate: () => true,
|
|
5488
|
-
onChange
|
|
5489
|
-
|
|
5557
|
+
onChange(query) {
|
|
5558
|
+
this._update((draft) => {
|
|
5559
|
+
draft.query = query;
|
|
5560
|
+
draft.isLoading = true;
|
|
5561
|
+
});
|
|
5562
|
+
debouncedSearch(this, query.trim());
|
|
5563
|
+
},
|
|
5564
|
+
onSelect({ type, value }) {
|
|
5565
|
+
if (type === "action") {
|
|
5566
|
+
void onBehavior({ type: "action", action: value });
|
|
5567
|
+
} else {
|
|
5568
|
+
this._update((draft) => {
|
|
5569
|
+
draft.query = value.query;
|
|
5570
|
+
draft.isLoading = true;
|
|
5571
|
+
});
|
|
5572
|
+
search(this, value.query, {
|
|
5573
|
+
method: value.method,
|
|
5574
|
+
param: value.param,
|
|
5575
|
+
url: value.url
|
|
5576
|
+
});
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5490
5579
|
};
|
|
5580
|
+
return component;
|
|
5491
5581
|
};
|
|
5492
5582
|
|
|
5493
5583
|
// src/revamp/domain/features/search/getPerformSearchFunction.ts
|
|
@@ -5800,7 +5890,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5800
5890
|
};
|
|
5801
5891
|
|
|
5802
5892
|
// src/revamp/flow/getResponseType.ts
|
|
5803
|
-
var responseTypes = ["step", "action", "exit"];
|
|
5893
|
+
var responseTypes = ["step", "action", "exit", "modal"];
|
|
5804
5894
|
var getResponseType = async (response) => {
|
|
5805
5895
|
assertResponseIsValid(response);
|
|
5806
5896
|
const headerResponseType = getResponseTypeFromHeader(response);
|
|
@@ -5828,7 +5918,7 @@ var getResponseTypeFromHeader = (response) => {
|
|
|
5828
5918
|
function assertDFResponseType(type) {
|
|
5829
5919
|
if (!responseTypes.includes(type)) {
|
|
5830
5920
|
throw new Error(
|
|
5831
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
5921
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
|
|
5832
5922
|
);
|
|
5833
5923
|
}
|
|
5834
5924
|
}
|
|
@@ -5983,6 +6073,10 @@ var executeSubmission = async (props) => {
|
|
|
5983
6073
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
5984
6074
|
return await triggerAction(body.action, null, false);
|
|
5985
6075
|
}
|
|
6076
|
+
case "modal": {
|
|
6077
|
+
assertModalResponseBody(body);
|
|
6078
|
+
return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
|
|
6079
|
+
}
|
|
5986
6080
|
default: {
|
|
5987
6081
|
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
5988
6082
|
}
|
|
@@ -6217,29 +6311,6 @@ var formatDateOptions = {
|
|
|
6217
6311
|
dateStyle: "long"
|
|
6218
6312
|
};
|
|
6219
6313
|
|
|
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
6314
|
// src/revamp/utils/useStableCallback.tsx
|
|
6244
6315
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
6245
6316
|
function useStableCallback(handler) {
|
|
@@ -6250,6 +6321,55 @@ function useStableCallback(handler) {
|
|
|
6250
6321
|
return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6251
6322
|
}
|
|
6252
6323
|
|
|
6324
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6325
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6326
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
6327
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6328
|
+
type: "modal-content",
|
|
6329
|
+
open: true
|
|
6330
|
+
}, modalProps), {
|
|
6331
|
+
_update(updateFn) {
|
|
6332
|
+
update(this, updateFn);
|
|
6333
|
+
},
|
|
6334
|
+
getChildren() {
|
|
6335
|
+
return this.components;
|
|
6336
|
+
},
|
|
6337
|
+
getLocalValue() {
|
|
6338
|
+
return getLocalValues(this.getChildren());
|
|
6339
|
+
},
|
|
6340
|
+
async getSubmittableValue() {
|
|
6341
|
+
return getSubmittableData(this.getChildren());
|
|
6342
|
+
},
|
|
6343
|
+
getSubmittableValueSync() {
|
|
6344
|
+
return getSubmittableDataSync(this.getChildren());
|
|
6345
|
+
},
|
|
6346
|
+
getSummary() {
|
|
6347
|
+
return summariseFromChildren(this.getChildren());
|
|
6348
|
+
},
|
|
6349
|
+
validate() {
|
|
6350
|
+
return validateComponents(this.getChildren());
|
|
6351
|
+
},
|
|
6352
|
+
close() {
|
|
6353
|
+
update(this, (draft) => {
|
|
6354
|
+
draft.open = false;
|
|
6355
|
+
});
|
|
6356
|
+
}
|
|
6357
|
+
});
|
|
6358
|
+
return modalContentComponent;
|
|
6359
|
+
};
|
|
6360
|
+
|
|
6361
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6362
|
+
var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
|
|
6363
|
+
{
|
|
6364
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
6365
|
+
title,
|
|
6366
|
+
components: content.map(
|
|
6367
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
|
|
6368
|
+
)
|
|
6369
|
+
},
|
|
6370
|
+
mapperProps.updateComponent
|
|
6371
|
+
);
|
|
6372
|
+
|
|
6253
6373
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6254
6374
|
function useDynamicFlowCore(props) {
|
|
6255
6375
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6266,15 +6386,7 @@ function useDynamicFlowCore(props) {
|
|
|
6266
6386
|
[formatMessage, locale]
|
|
6267
6387
|
);
|
|
6268
6388
|
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
|
-
);
|
|
6389
|
+
const rootComponentRef = useRef2(createRootDomainComponent(rerender));
|
|
6278
6390
|
const stepCount = useRef2(0);
|
|
6279
6391
|
const stepRef = useRef2(initialStep != null ? initialStep : null);
|
|
6280
6392
|
const etagRef = useRef2(null);
|
|
@@ -6307,6 +6419,20 @@ function useDynamicFlowCore(props) {
|
|
|
6307
6419
|
var _a2;
|
|
6308
6420
|
initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
|
|
6309
6421
|
}, []);
|
|
6422
|
+
const getMapperProps = () => ({
|
|
6423
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6424
|
+
displayStepTitle,
|
|
6425
|
+
loadingState: "idle",
|
|
6426
|
+
updateComponent: () => rerender(),
|
|
6427
|
+
getErrorMessageFunctions,
|
|
6428
|
+
trackEvent,
|
|
6429
|
+
logEvent,
|
|
6430
|
+
httpClient,
|
|
6431
|
+
onBehavior,
|
|
6432
|
+
onRefresh,
|
|
6433
|
+
onPoll,
|
|
6434
|
+
onValueChange
|
|
6435
|
+
});
|
|
6310
6436
|
const initialiseWithStep = useCallback2(
|
|
6311
6437
|
(newStep, etag, localValue) => {
|
|
6312
6438
|
rootComponentRef.current.stop();
|
|
@@ -6319,25 +6445,11 @@ function useDynamicFlowCore(props) {
|
|
|
6319
6445
|
});
|
|
6320
6446
|
}
|
|
6321
6447
|
try {
|
|
6322
|
-
const newStepComponent = mapStepToComponent({
|
|
6323
|
-
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6448
|
+
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6324
6449
|
stepLocalValue: localValue,
|
|
6325
|
-
step: newStep
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
updateComponent,
|
|
6329
|
-
getErrorMessageFunctions,
|
|
6330
|
-
trackEvent,
|
|
6331
|
-
logEvent,
|
|
6332
|
-
httpClient,
|
|
6333
|
-
onBehavior,
|
|
6334
|
-
onRefresh,
|
|
6335
|
-
onPoll,
|
|
6336
|
-
onValueChange
|
|
6337
|
-
});
|
|
6338
|
-
updateComponent(rootComponentRef.current.uid, (draft) => {
|
|
6339
|
-
draft.stepComponent = newStepComponent;
|
|
6340
|
-
});
|
|
6450
|
+
step: newStep
|
|
6451
|
+
}, getMapperProps()));
|
|
6452
|
+
rootComponentRef.current.setStep(newStepComponent);
|
|
6341
6453
|
} catch (error) {
|
|
6342
6454
|
closeWithError(error);
|
|
6343
6455
|
}
|
|
@@ -6389,6 +6501,7 @@ function useDynamicFlowCore(props) {
|
|
|
6389
6501
|
const onBehavior = useCallback2(async (behavior) => {
|
|
6390
6502
|
switch (behavior.type) {
|
|
6391
6503
|
case "action": {
|
|
6504
|
+
rootComponentRef.current.dismissAllModals();
|
|
6392
6505
|
try {
|
|
6393
6506
|
const { action } = behavior;
|
|
6394
6507
|
await rootComponentRef.current.getSubmittableValue();
|
|
@@ -6408,10 +6521,20 @@ function useDynamicFlowCore(props) {
|
|
|
6408
6521
|
onLink(behavior.url);
|
|
6409
6522
|
break;
|
|
6410
6523
|
}
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6524
|
+
case "modal":
|
|
6525
|
+
if (stepRef.current) {
|
|
6526
|
+
rootComponentRef.current.showModal(
|
|
6527
|
+
modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
|
|
6528
|
+
step: stepRef.current,
|
|
6529
|
+
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6530
|
+
}, getMapperProps()))
|
|
6531
|
+
);
|
|
6532
|
+
}
|
|
6533
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6534
|
+
break;
|
|
6535
|
+
case "dismiss":
|
|
6536
|
+
rootComponentRef.current.dismissModal();
|
|
6537
|
+
break;
|
|
6415
6538
|
case "none":
|
|
6416
6539
|
break;
|
|
6417
6540
|
}
|
|
@@ -6476,6 +6599,11 @@ function useDynamicFlowCore(props) {
|
|
|
6476
6599
|
void onRefresh(void 0, refreshUrl, errors);
|
|
6477
6600
|
break;
|
|
6478
6601
|
}
|
|
6602
|
+
case "behavior": {
|
|
6603
|
+
void onBehavior(command.behavior);
|
|
6604
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6605
|
+
break;
|
|
6606
|
+
}
|
|
6479
6607
|
}
|
|
6480
6608
|
} catch (error) {
|
|
6481
6609
|
closeWithError(error);
|