@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.js
CHANGED
|
@@ -1084,6 +1084,7 @@ function getChildren(node) {
|
|
|
1084
1084
|
case "form":
|
|
1085
1085
|
case "section":
|
|
1086
1086
|
case "step":
|
|
1087
|
+
case "modal-content":
|
|
1087
1088
|
return node.childrenProps;
|
|
1088
1089
|
case "columns":
|
|
1089
1090
|
return [...node.startChildrenProps, ...node.endChildrenProps];
|
|
@@ -1159,7 +1160,6 @@ var getRenderFunction = (renderers) => {
|
|
|
1159
1160
|
};
|
|
1160
1161
|
|
|
1161
1162
|
// src/revamp/utils/type-utils.ts
|
|
1162
|
-
var hasChildren = (component) => "getChildren" in component && typeof component.getChildren === "function";
|
|
1163
1163
|
var isHiddenComponent = (component) => "hidden" in component && component.hidden;
|
|
1164
1164
|
var isObjectLocalValue = (value) => value != null && typeof value === "object" && !Array.isArray(value) && !(value instanceof File);
|
|
1165
1165
|
var isArrayLocalValue = (value) => Array.isArray(value);
|
|
@@ -1682,20 +1682,20 @@ var listComponentToProps = (component, rendererMapperProps) => __spreadProps(__s
|
|
|
1682
1682
|
});
|
|
1683
1683
|
|
|
1684
1684
|
// src/revamp/renderers/stepComponentToProps.ts
|
|
1685
|
-
var stepComponentToProps = ({
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
}
|
|
1698
|
-
const childrenProps =
|
|
1685
|
+
var stepComponentToProps = (component, rendererMapperProps) => {
|
|
1686
|
+
const {
|
|
1687
|
+
uid,
|
|
1688
|
+
back,
|
|
1689
|
+
control,
|
|
1690
|
+
description,
|
|
1691
|
+
error,
|
|
1692
|
+
external,
|
|
1693
|
+
loadingState,
|
|
1694
|
+
step,
|
|
1695
|
+
title,
|
|
1696
|
+
onBehavior
|
|
1697
|
+
} = component;
|
|
1698
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1699
1699
|
return __spreadValues({
|
|
1700
1700
|
type: "step",
|
|
1701
1701
|
id: step.id,
|
|
@@ -1727,6 +1727,21 @@ var rootComponentToProps = (rootComponent, rendererMapperProps) => {
|
|
|
1727
1727
|
};
|
|
1728
1728
|
};
|
|
1729
1729
|
|
|
1730
|
+
// src/revamp/renderers/mappers/modalContentComponentToProps.ts
|
|
1731
|
+
var modalContentComponentToProps = (component, rendererMapperProps) => {
|
|
1732
|
+
const { uid, open, title, close } = component;
|
|
1733
|
+
const childrenProps = component.getChildren().map((c) => componentToRendererProps(c, rendererMapperProps));
|
|
1734
|
+
return __spreadValues({
|
|
1735
|
+
uid,
|
|
1736
|
+
type: "modal-content",
|
|
1737
|
+
open,
|
|
1738
|
+
title,
|
|
1739
|
+
children: childrenProps.map(rendererMapperProps.render),
|
|
1740
|
+
childrenProps,
|
|
1741
|
+
onClose: close.bind(component)
|
|
1742
|
+
}, rendererMapperProps);
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1730
1745
|
// src/revamp/renderers/mappers/componentToRendererProps.ts
|
|
1731
1746
|
var componentToRendererProps = (component, rendererMapperProps) => {
|
|
1732
1747
|
if (isHiddenComponent(component)) {
|
|
@@ -1777,6 +1792,8 @@ var componentToRendererProps = (component, rendererMapperProps) => {
|
|
|
1777
1792
|
return markdownComponentToProps(component, rendererMapperProps);
|
|
1778
1793
|
case "modal":
|
|
1779
1794
|
return modalComponentToProps(component, rendererMapperProps);
|
|
1795
|
+
case "modal-content":
|
|
1796
|
+
return modalContentComponentToProps(component, rendererMapperProps);
|
|
1780
1797
|
case "multi-select":
|
|
1781
1798
|
return multiSelectInputComponentToProps(component, rendererMapperProps);
|
|
1782
1799
|
case "multi-upload":
|
|
@@ -1813,47 +1830,13 @@ var import_dynamic_flow_types2 = require("@wise/dynamic-flow-types");
|
|
|
1813
1830
|
var import_react3 = require("react");
|
|
1814
1831
|
var import_react_intl7 = require("react-intl");
|
|
1815
1832
|
|
|
1816
|
-
// src/revamp/domain/components/
|
|
1817
|
-
var
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
},
|
|
1824
|
-
getLocalValue() {
|
|
1825
|
-
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1826
|
-
},
|
|
1827
|
-
async getSubmittableValue() {
|
|
1828
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
1829
|
-
},
|
|
1830
|
-
getSubmittableValueSync() {
|
|
1831
|
-
return this.stepComponent ? this.stepComponent.getSubmittableValueSync() : null;
|
|
1832
|
-
},
|
|
1833
|
-
getSummary() {
|
|
1834
|
-
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1835
|
-
},
|
|
1836
|
-
validate() {
|
|
1837
|
-
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1838
|
-
},
|
|
1839
|
-
setLoadingState(loadingState) {
|
|
1840
|
-
var _a;
|
|
1841
|
-
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1842
|
-
},
|
|
1843
|
-
getLoadingState() {
|
|
1844
|
-
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1845
|
-
},
|
|
1846
|
-
getTrackEvent() {
|
|
1847
|
-
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1848
|
-
},
|
|
1849
|
-
hasStep() {
|
|
1850
|
-
return Boolean(this.stepComponent);
|
|
1851
|
-
},
|
|
1852
|
-
stop() {
|
|
1853
|
-
var _a;
|
|
1854
|
-
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1855
|
-
}
|
|
1856
|
-
});
|
|
1833
|
+
// src/revamp/domain/components/utils/component-utils.ts
|
|
1834
|
+
var getInputUpdateFunction = (updateComponent) => {
|
|
1835
|
+
return (component, updateFn) => {
|
|
1836
|
+
updateFn(component);
|
|
1837
|
+
updateComponent();
|
|
1838
|
+
};
|
|
1839
|
+
};
|
|
1857
1840
|
|
|
1858
1841
|
// src/revamp/utils/component-utils.ts
|
|
1859
1842
|
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
@@ -1886,6 +1869,72 @@ var mergeModels = (valueA, valueB) => {
|
|
|
1886
1869
|
return valueB;
|
|
1887
1870
|
};
|
|
1888
1871
|
|
|
1872
|
+
// src/revamp/domain/components/RootDomainComponent.ts
|
|
1873
|
+
var createRootDomainComponent = (updateComponent) => {
|
|
1874
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1875
|
+
const rootComponent = {
|
|
1876
|
+
type: "root",
|
|
1877
|
+
uid: "root",
|
|
1878
|
+
stepComponent: null,
|
|
1879
|
+
_update(updateFn) {
|
|
1880
|
+
update(this, updateFn);
|
|
1881
|
+
},
|
|
1882
|
+
dismissAllModals() {
|
|
1883
|
+
var _a;
|
|
1884
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissAllModals();
|
|
1885
|
+
},
|
|
1886
|
+
dismissModal() {
|
|
1887
|
+
var _a;
|
|
1888
|
+
(_a = this.stepComponent) == null ? void 0 : _a.dismissModal();
|
|
1889
|
+
},
|
|
1890
|
+
showModal(modal) {
|
|
1891
|
+
var _a;
|
|
1892
|
+
(_a = this.stepComponent) == null ? void 0 : _a.showModal(modal);
|
|
1893
|
+
},
|
|
1894
|
+
getChildren() {
|
|
1895
|
+
return this.stepComponent ? [this.stepComponent, ...this.stepComponent.getModals()] : [];
|
|
1896
|
+
},
|
|
1897
|
+
getLocalValue() {
|
|
1898
|
+
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1899
|
+
},
|
|
1900
|
+
async getSubmittableValue() {
|
|
1901
|
+
return this.stepComponent ? getSubmittableData([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1902
|
+
},
|
|
1903
|
+
getSubmittableValueSync() {
|
|
1904
|
+
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1905
|
+
},
|
|
1906
|
+
getSummary() {
|
|
1907
|
+
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1908
|
+
},
|
|
1909
|
+
validate() {
|
|
1910
|
+
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
1911
|
+
},
|
|
1912
|
+
setLoadingState(loadingState) {
|
|
1913
|
+
var _a;
|
|
1914
|
+
(_a = this.stepComponent) == null ? void 0 : _a.setLoadingState(loadingState);
|
|
1915
|
+
},
|
|
1916
|
+
getLoadingState() {
|
|
1917
|
+
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1918
|
+
},
|
|
1919
|
+
getTrackEvent() {
|
|
1920
|
+
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
1921
|
+
},
|
|
1922
|
+
hasStep() {
|
|
1923
|
+
return Boolean(this.stepComponent);
|
|
1924
|
+
},
|
|
1925
|
+
stop() {
|
|
1926
|
+
var _a;
|
|
1927
|
+
(_a = this.stepComponent) == null ? void 0 : _a.stop();
|
|
1928
|
+
},
|
|
1929
|
+
setStep(stepComponent) {
|
|
1930
|
+
this._update((draft) => {
|
|
1931
|
+
draft.stepComponent = stepComponent;
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
};
|
|
1935
|
+
return rootComponent;
|
|
1936
|
+
};
|
|
1937
|
+
|
|
1889
1938
|
// src/revamp/domain/features/summary/summary-utils.ts
|
|
1890
1939
|
var getSummariser = (schema) => (value) => {
|
|
1891
1940
|
const { summary, icon, image } = schema;
|
|
@@ -1926,25 +1975,38 @@ var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
|
1926
1975
|
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
1927
1976
|
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
1928
1977
|
|
|
1929
|
-
// src/revamp/domain/components/utils/component-utils.ts
|
|
1930
|
-
var getInputUpdateFunction = (uid, updateComponent) => (updateFn) => {
|
|
1931
|
-
updateComponent(uid, (draft) => {
|
|
1932
|
-
const draftState = draft;
|
|
1933
|
-
updateFn(draftState);
|
|
1934
|
-
});
|
|
1935
|
-
};
|
|
1936
|
-
|
|
1937
1978
|
// src/revamp/domain/components/StepDomainComponent.ts
|
|
1938
1979
|
var createStepComponent = (stepProps) => {
|
|
1939
1980
|
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
1940
|
-
const update = getInputUpdateFunction(
|
|
1941
|
-
|
|
1981
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
1982
|
+
const component = __spreadProps(__spreadValues({
|
|
1942
1983
|
uid
|
|
1943
1984
|
}, rest), {
|
|
1944
1985
|
type: "step",
|
|
1986
|
+
modals: [],
|
|
1987
|
+
dismissModal() {
|
|
1988
|
+
var _a2;
|
|
1989
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
1990
|
+
},
|
|
1991
|
+
dismissAllModals() {
|
|
1992
|
+
this._update((draft) => {
|
|
1993
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
1994
|
+
});
|
|
1995
|
+
},
|
|
1996
|
+
showModal(modal) {
|
|
1997
|
+
this._update((draft) => {
|
|
1998
|
+
draft.modals = [...draft.modals, modal];
|
|
1999
|
+
});
|
|
2000
|
+
},
|
|
2001
|
+
_update(updateFn) {
|
|
2002
|
+
update(this, updateFn);
|
|
2003
|
+
},
|
|
1945
2004
|
getChildren() {
|
|
1946
2005
|
return this.components;
|
|
1947
2006
|
},
|
|
2007
|
+
getModals() {
|
|
2008
|
+
return this.modals;
|
|
2009
|
+
},
|
|
1948
2010
|
async getSubmittableValue() {
|
|
1949
2011
|
return getSubmittableData(this.components);
|
|
1950
2012
|
},
|
|
@@ -1961,15 +2023,19 @@ var createStepComponent = (stepProps) => {
|
|
|
1961
2023
|
return validateComponents(this.getChildren());
|
|
1962
2024
|
},
|
|
1963
2025
|
setLoadingState(loadingState) {
|
|
1964
|
-
|
|
2026
|
+
this._update((draft) => {
|
|
1965
2027
|
draft.loadingState = loadingState;
|
|
1966
2028
|
});
|
|
1967
2029
|
},
|
|
1968
2030
|
stop() {
|
|
1969
2031
|
stepPolling == null ? void 0 : stepPolling.stop();
|
|
1970
2032
|
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
2033
|
+
this._update((draft) => {
|
|
2034
|
+
draft.modals = [];
|
|
2035
|
+
});
|
|
1971
2036
|
}
|
|
1972
2037
|
});
|
|
2038
|
+
return component;
|
|
1973
2039
|
};
|
|
1974
2040
|
|
|
1975
2041
|
// src/revamp/domain/mappers/utils/behavior-utils.ts
|
|
@@ -2095,9 +2161,11 @@ var getCallToAction = ({ title, accessibilityDescription }, behavior, onBehavior
|
|
|
2095
2161
|
void onBehavior(behavior);
|
|
2096
2162
|
};
|
|
2097
2163
|
switch (behavior.type) {
|
|
2098
|
-
case "action":
|
|
2164
|
+
case "action":
|
|
2165
|
+
case "modal":
|
|
2166
|
+
case "dismiss": {
|
|
2099
2167
|
return {
|
|
2100
|
-
type:
|
|
2168
|
+
type: behavior.type,
|
|
2101
2169
|
title: title != null ? title : "",
|
|
2102
2170
|
accessibilityDescription,
|
|
2103
2171
|
onClick
|
|
@@ -2393,6 +2461,22 @@ var createDividerComponent = (props) => __spreadProps(__spreadValues({
|
|
|
2393
2461
|
// src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
2394
2462
|
var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
|
|
2395
2463
|
|
|
2464
|
+
// src/revamp/domain/components/utils/getRandomId.ts
|
|
2465
|
+
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
2466
|
+
|
|
2467
|
+
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
2468
|
+
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
2469
|
+
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
2470
|
+
return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
|
|
2471
|
+
}
|
|
2472
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2473
|
+
const keysA = Object.keys(valueA);
|
|
2474
|
+
const keysB = Object.keys(valueB);
|
|
2475
|
+
return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
|
|
2476
|
+
}
|
|
2477
|
+
return valueA === valueB;
|
|
2478
|
+
};
|
|
2479
|
+
|
|
2396
2480
|
// src/revamp/domain/features/utils/http-utils.ts
|
|
2397
2481
|
function constructPayload({
|
|
2398
2482
|
value,
|
|
@@ -2420,37 +2504,21 @@ var abortAndResetController = (abortController) => {
|
|
|
2420
2504
|
return new AbortController();
|
|
2421
2505
|
};
|
|
2422
2506
|
|
|
2423
|
-
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
2424
|
-
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
2425
|
-
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
2426
|
-
return valueA.length === valueB.length && valueA.every((value, index) => isExactLocalValueMatch(value, valueB[index]));
|
|
2427
|
-
}
|
|
2428
|
-
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2429
|
-
const keysA = Object.keys(valueA);
|
|
2430
|
-
const keysB = Object.keys(valueB);
|
|
2431
|
-
return keysA.length === keysB.length && keysA.every((key) => isExactLocalValueMatch(valueA[key], valueB[key]));
|
|
2432
|
-
}
|
|
2433
|
-
return valueA === valueB;
|
|
2434
|
-
};
|
|
2435
|
-
|
|
2436
|
-
// src/revamp/domain/components/utils/getRandomId.ts
|
|
2437
|
-
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
2438
|
-
|
|
2439
2507
|
// src/revamp/domain/features/persistAsync/getComponentPersistAsync.ts
|
|
2440
2508
|
var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
2441
2509
|
/**
|
|
2442
2510
|
* Will update the persistedState when a new request is made, and will update
|
|
2443
2511
|
* the value or set errors when the request completes.
|
|
2444
2512
|
*/
|
|
2445
|
-
async (
|
|
2446
|
-
const { abortController, lastSubmitted, submission } = persistedState;
|
|
2513
|
+
async (component, currentValue) => {
|
|
2514
|
+
const { abortController, lastSubmitted, submission } = component.persistedState;
|
|
2447
2515
|
if (isExactLocalValueMatch(lastSubmitted, currentValue)) {
|
|
2448
2516
|
return submission;
|
|
2449
2517
|
}
|
|
2450
2518
|
const newAbortController = abortAndResetController(abortController);
|
|
2451
2519
|
if (isNullish(currentValue) || currentValue === "") {
|
|
2452
2520
|
const resolvedNull = Promise.resolve(null);
|
|
2453
|
-
update((draft) => {
|
|
2521
|
+
update(component, (draft) => {
|
|
2454
2522
|
draft.persistedState.abortController = newAbortController;
|
|
2455
2523
|
draft.persistedState.lastResponse = null;
|
|
2456
2524
|
draft.persistedState.lastSubmitted = currentValue;
|
|
@@ -2460,7 +2528,7 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2460
2528
|
}
|
|
2461
2529
|
const { signal } = newAbortController;
|
|
2462
2530
|
const newSubmission = performPersistAsync({ value: currentValue, signal }).then((newValue) => {
|
|
2463
|
-
update((draft) => {
|
|
2531
|
+
update(component, (draft) => {
|
|
2464
2532
|
draft.persistedState.lastResponse = newValue;
|
|
2465
2533
|
});
|
|
2466
2534
|
return newValue;
|
|
@@ -2468,14 +2536,14 @@ var getComponentPersistAsync = (update, performPersistAsync) => (
|
|
|
2468
2536
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2469
2537
|
return null;
|
|
2470
2538
|
}
|
|
2471
|
-
update((draft) => {
|
|
2539
|
+
update(component, (draft) => {
|
|
2472
2540
|
draft.errors = [error.message];
|
|
2473
2541
|
draft.persistedState.lastResponse = null;
|
|
2474
2542
|
draft.persistedState.lastSubmitted = null;
|
|
2475
2543
|
});
|
|
2476
2544
|
throw error;
|
|
2477
2545
|
});
|
|
2478
|
-
update((draft) => {
|
|
2546
|
+
update(component, (draft) => {
|
|
2479
2547
|
draft.persistedState = {
|
|
2480
2548
|
abortController: newAbortController,
|
|
2481
2549
|
lastResponse: null,
|
|
@@ -2491,19 +2559,19 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2491
2559
|
* Will update the persistedState when a new request is made, and will update
|
|
2492
2560
|
* the value or set errors when the request completes.
|
|
2493
2561
|
*/
|
|
2494
|
-
async (index, value) => {
|
|
2562
|
+
async (component, index, value) => {
|
|
2495
2563
|
if (isNullish(value)) {
|
|
2496
2564
|
throw new Error("Value must be a file or base64 string.");
|
|
2497
2565
|
}
|
|
2498
2566
|
const newAbortController = new AbortController();
|
|
2499
2567
|
const { signal } = newAbortController;
|
|
2500
2568
|
const newSubmission = performPersistAsync({ value, signal }).then((newValue) => {
|
|
2501
|
-
update((draft) => {
|
|
2569
|
+
update(component, (draft) => {
|
|
2502
2570
|
draft.persistedState[index].lastResponse = newValue;
|
|
2503
2571
|
});
|
|
2504
2572
|
return newValue;
|
|
2505
2573
|
}).catch((error) => {
|
|
2506
|
-
update((draft) => {
|
|
2574
|
+
update(component, (draft) => {
|
|
2507
2575
|
draft.persistedState = [
|
|
2508
2576
|
...draft.persistedState.slice(0, index),
|
|
2509
2577
|
...draft.persistedState.slice(index + 1)
|
|
@@ -2513,7 +2581,7 @@ var getComponentMultiPersistAsync = (update, performPersistAsync) => (
|
|
|
2513
2581
|
});
|
|
2514
2582
|
throw error;
|
|
2515
2583
|
});
|
|
2516
|
-
update((draft) => {
|
|
2584
|
+
update(component, (draft) => {
|
|
2517
2585
|
draft.persistedState = [
|
|
2518
2586
|
...draft.persistedState.slice(0, index),
|
|
2519
2587
|
{
|
|
@@ -2608,11 +2676,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2608
2676
|
* Will update the validationAsyncState when a new request is made, and will update
|
|
2609
2677
|
* the description or set errors when the request completes.
|
|
2610
2678
|
*/
|
|
2611
|
-
async (
|
|
2612
|
-
const { abortController } = validationAsyncState;
|
|
2679
|
+
async (component, currentValue) => {
|
|
2680
|
+
const { abortController } = component.validationAsyncState;
|
|
2613
2681
|
const newAbortController = abortAndResetController(abortController);
|
|
2614
2682
|
if (isNullish(currentValue)) {
|
|
2615
|
-
update((draft) => {
|
|
2683
|
+
update(component, (draft) => {
|
|
2616
2684
|
draft.validationAsyncState = {
|
|
2617
2685
|
abortController: newAbortController,
|
|
2618
2686
|
lastSubmitted: currentValue,
|
|
@@ -2623,7 +2691,7 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2623
2691
|
}
|
|
2624
2692
|
const { signal } = newAbortController;
|
|
2625
2693
|
const newSubmission = performValidationAsync({ value: currentValue, signal }).then((message) => {
|
|
2626
|
-
update((draft) => {
|
|
2694
|
+
update(component, (draft) => {
|
|
2627
2695
|
if (message) {
|
|
2628
2696
|
draft.validationAsyncState.messages.success = message;
|
|
2629
2697
|
}
|
|
@@ -2633,11 +2701,11 @@ var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
|
2633
2701
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
2634
2702
|
return null;
|
|
2635
2703
|
}
|
|
2636
|
-
update((draft) => {
|
|
2704
|
+
update(component, (draft) => {
|
|
2637
2705
|
draft.validationAsyncState.messages.error = error.message;
|
|
2638
2706
|
});
|
|
2639
2707
|
});
|
|
2640
|
-
update((draft) => {
|
|
2708
|
+
update(component, (draft) => {
|
|
2641
2709
|
draft.validationAsyncState = {
|
|
2642
2710
|
abortController: newAbortController,
|
|
2643
2711
|
lastSubmitted: currentValue,
|
|
@@ -2670,22 +2738,18 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2670
2738
|
"onValueChange",
|
|
2671
2739
|
"summariser"
|
|
2672
2740
|
]);
|
|
2673
|
-
const update = getInputUpdateFunction(
|
|
2741
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2674
2742
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
2675
2743
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
2676
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
2677
|
-
const messages = getValidationErrors(currentValue);
|
|
2678
|
-
update((draft) => {
|
|
2679
|
-
draft.errors = messages;
|
|
2680
|
-
});
|
|
2681
|
-
return messages;
|
|
2682
|
-
};
|
|
2683
2744
|
const numberComponent = __spreadValues({
|
|
2684
2745
|
type: "number",
|
|
2685
2746
|
uid,
|
|
2686
2747
|
id,
|
|
2748
|
+
_update(updateFn) {
|
|
2749
|
+
update(this, updateFn);
|
|
2750
|
+
},
|
|
2687
2751
|
onBlur() {
|
|
2688
|
-
|
|
2752
|
+
this.validate();
|
|
2689
2753
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
2690
2754
|
},
|
|
2691
2755
|
onFocus() {
|
|
@@ -2693,7 +2757,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2693
2757
|
// Noop
|
|
2694
2758
|
onChange(updatedValue) {
|
|
2695
2759
|
const prevValue = this.value;
|
|
2696
|
-
|
|
2760
|
+
this._update((draft) => {
|
|
2697
2761
|
draft.errors = [];
|
|
2698
2762
|
draft.validationAsyncState.messages = {};
|
|
2699
2763
|
draft.value = updatedValue;
|
|
@@ -2715,8 +2779,11 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2715
2779
|
return this.value;
|
|
2716
2780
|
},
|
|
2717
2781
|
validate() {
|
|
2718
|
-
const
|
|
2719
|
-
|
|
2782
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
2783
|
+
this._update((draft) => {
|
|
2784
|
+
draft.errors = errors;
|
|
2785
|
+
});
|
|
2786
|
+
return errors.length === 0;
|
|
2720
2787
|
}
|
|
2721
2788
|
}, rest);
|
|
2722
2789
|
if (performRefresh) {
|
|
@@ -2727,12 +2794,12 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2727
2794
|
return __spreadProps(__spreadValues({}, numberComponent), {
|
|
2728
2795
|
onBlur() {
|
|
2729
2796
|
if (this.validate()) {
|
|
2730
|
-
persist(this
|
|
2797
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
2731
2798
|
});
|
|
2732
2799
|
}
|
|
2733
2800
|
},
|
|
2734
2801
|
async getSubmittableValue() {
|
|
2735
|
-
return persist(this
|
|
2802
|
+
return persist(this, this.getLocalValue());
|
|
2736
2803
|
},
|
|
2737
2804
|
getSubmittableValueSync() {
|
|
2738
2805
|
return this.persistedState.lastResponse;
|
|
@@ -2750,7 +2817,7 @@ var createNumberInputComponent = (numberInputProps, updateComponent) => {
|
|
|
2750
2817
|
onChange(updatedValue) {
|
|
2751
2818
|
numberComponent.onChange.call(this, updatedValue);
|
|
2752
2819
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
2753
|
-
validateAsync(this
|
|
2820
|
+
validateAsync(this, updatedValue);
|
|
2754
2821
|
}
|
|
2755
2822
|
}
|
|
2756
2823
|
});
|
|
@@ -2986,6 +3053,16 @@ function assertActionResponseBody(body) {
|
|
|
2986
3053
|
);
|
|
2987
3054
|
}
|
|
2988
3055
|
}
|
|
3056
|
+
function assertModalResponseBody(body) {
|
|
3057
|
+
if (isObject(body)) {
|
|
3058
|
+
if ("content" in body && isArray(body.content)) {
|
|
3059
|
+
return;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
throw new Error(
|
|
3063
|
+
"Incorrect response body in modal response. Expected an object satisfying the type { title?: string, components: Layout[] }."
|
|
3064
|
+
);
|
|
3065
|
+
}
|
|
2989
3066
|
function isErrorResponseBody(body) {
|
|
2990
3067
|
return Boolean(
|
|
2991
3068
|
isObject(body) && (body.refreshFormUrl || body.refreshUrl || body.validation || body.error || body.analytics)
|
|
@@ -3041,7 +3118,7 @@ var getPerformPersistAsync = ({
|
|
|
3041
3118
|
}
|
|
3042
3119
|
return json[idProperty];
|
|
3043
3120
|
}
|
|
3044
|
-
} catch (
|
|
3121
|
+
} catch (e) {
|
|
3045
3122
|
trackFailure();
|
|
3046
3123
|
throw new Error(genericErrorMessage);
|
|
3047
3124
|
}
|
|
@@ -3468,23 +3545,19 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3468
3545
|
"onValueChange",
|
|
3469
3546
|
"summariser"
|
|
3470
3547
|
]);
|
|
3471
|
-
const update = getInputUpdateFunction(
|
|
3548
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3472
3549
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3473
3550
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
3474
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3475
|
-
const messages = getValidationErrors(currentValue);
|
|
3476
|
-
update((draft) => {
|
|
3477
|
-
draft.errors = messages;
|
|
3478
|
-
});
|
|
3479
|
-
return messages;
|
|
3480
|
-
};
|
|
3481
3551
|
const integerComponent = __spreadValues({
|
|
3482
3552
|
type: "integer",
|
|
3483
3553
|
uid,
|
|
3484
3554
|
id,
|
|
3485
3555
|
value,
|
|
3556
|
+
_update(updateFn) {
|
|
3557
|
+
update(this, updateFn);
|
|
3558
|
+
},
|
|
3486
3559
|
onBlur() {
|
|
3487
|
-
|
|
3560
|
+
this.validate();
|
|
3488
3561
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
3489
3562
|
},
|
|
3490
3563
|
onFocus() {
|
|
@@ -3492,7 +3565,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3492
3565
|
// Noop
|
|
3493
3566
|
onChange(updatedValue) {
|
|
3494
3567
|
const prevValue = this.value;
|
|
3495
|
-
|
|
3568
|
+
this._update((draft) => {
|
|
3496
3569
|
draft.errors = [];
|
|
3497
3570
|
draft.validationAsyncState.messages = {};
|
|
3498
3571
|
draft.value = updatedValue;
|
|
@@ -3514,8 +3587,11 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3514
3587
|
return this.value;
|
|
3515
3588
|
},
|
|
3516
3589
|
validate() {
|
|
3517
|
-
const
|
|
3518
|
-
|
|
3590
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3591
|
+
this._update((draft) => {
|
|
3592
|
+
draft.errors = errors;
|
|
3593
|
+
});
|
|
3594
|
+
return errors.length === 0;
|
|
3519
3595
|
}
|
|
3520
3596
|
}, rest);
|
|
3521
3597
|
if (performRefresh) {
|
|
@@ -3526,12 +3602,12 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3526
3602
|
return __spreadProps(__spreadValues({}, integerComponent), {
|
|
3527
3603
|
onBlur() {
|
|
3528
3604
|
if (this.validate()) {
|
|
3529
|
-
persist(this
|
|
3605
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3530
3606
|
});
|
|
3531
3607
|
}
|
|
3532
3608
|
},
|
|
3533
3609
|
async getSubmittableValue() {
|
|
3534
|
-
return persist(this
|
|
3610
|
+
return persist(this, this.getLocalValue());
|
|
3535
3611
|
},
|
|
3536
3612
|
getSubmittableValueSync() {
|
|
3537
3613
|
return this.persistedState.lastResponse;
|
|
@@ -3549,7 +3625,7 @@ var createIntegerInputComponent = (integerInputProps, updateComponent) => {
|
|
|
3549
3625
|
onChange(updatedValue) {
|
|
3550
3626
|
integerComponent.onChange.call(this, updatedValue);
|
|
3551
3627
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
3552
|
-
validateAsync(this
|
|
3628
|
+
validateAsync(this, updatedValue);
|
|
3553
3629
|
}
|
|
3554
3630
|
}
|
|
3555
3631
|
});
|
|
@@ -3623,16 +3699,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3623
3699
|
(option) => isPartialModelMatch(option.component.getSubmittableValueSync(), initialModel)
|
|
3624
3700
|
);
|
|
3625
3701
|
const selectedIndex = matchingOptions.filter((match) => match).length === 1 ? matchingOptions.indexOf(true) : null;
|
|
3626
|
-
const update = getInputUpdateFunction(
|
|
3702
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3627
3703
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3628
|
-
const
|
|
3629
|
-
const messages = getValidationErrors(currentValue);
|
|
3630
|
-
update((draft) => {
|
|
3631
|
-
draft.errors = messages;
|
|
3632
|
-
});
|
|
3633
|
-
return messages;
|
|
3634
|
-
};
|
|
3635
|
-
return __spreadProps(__spreadValues({
|
|
3704
|
+
const component = __spreadProps(__spreadValues({
|
|
3636
3705
|
uid,
|
|
3637
3706
|
type: "select",
|
|
3638
3707
|
children,
|
|
@@ -3640,6 +3709,9 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3640
3709
|
selectedIndex,
|
|
3641
3710
|
value: null
|
|
3642
3711
|
}, rest), {
|
|
3712
|
+
_update(updateFn) {
|
|
3713
|
+
update(this, updateFn);
|
|
3714
|
+
},
|
|
3643
3715
|
getChildren() {
|
|
3644
3716
|
return this.children;
|
|
3645
3717
|
},
|
|
@@ -3663,19 +3735,22 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3663
3735
|
return (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.getLocalValue()) != null ? _b : null;
|
|
3664
3736
|
},
|
|
3665
3737
|
onBlur() {
|
|
3666
|
-
|
|
3738
|
+
this.validate();
|
|
3667
3739
|
},
|
|
3668
3740
|
onFocus() {
|
|
3669
3741
|
},
|
|
3670
3742
|
// noop
|
|
3671
3743
|
onSelect(updatedIndex) {
|
|
3744
|
+
if (updatedIndex === this.selectedIndex) {
|
|
3745
|
+
return;
|
|
3746
|
+
}
|
|
3672
3747
|
if (updatedIndex !== null && this.analyticsId) {
|
|
3673
3748
|
selectProps.trackEvent("OneOf Selected", {
|
|
3674
3749
|
oneOfId: this.analyticsId,
|
|
3675
3750
|
schemaId: this.children[updatedIndex].analyticsId
|
|
3676
3751
|
});
|
|
3677
3752
|
}
|
|
3678
|
-
|
|
3753
|
+
this._update((draft) => {
|
|
3679
3754
|
draft.errors = [];
|
|
3680
3755
|
draft.selectedIndex = updatedIndex;
|
|
3681
3756
|
});
|
|
@@ -3685,10 +3760,14 @@ var createSelectInputComponent = (selectProps, updateComponent) => {
|
|
|
3685
3760
|
validate() {
|
|
3686
3761
|
var _a2, _b;
|
|
3687
3762
|
const validChild = (_b = (_a2 = this.getSelectedChild()) == null ? void 0 : _a2.validate()) != null ? _b : true;
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3763
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3764
|
+
this._update((draft) => {
|
|
3765
|
+
draft.errors = errors;
|
|
3766
|
+
});
|
|
3767
|
+
return errors.length === 0 && validChild;
|
|
3690
3768
|
}
|
|
3691
3769
|
});
|
|
3770
|
+
return component;
|
|
3692
3771
|
};
|
|
3693
3772
|
|
|
3694
3773
|
// src/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.ts
|
|
@@ -3783,29 +3862,25 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3783
3862
|
"summariser",
|
|
3784
3863
|
"value"
|
|
3785
3864
|
]);
|
|
3786
|
-
const update = getInputUpdateFunction(
|
|
3865
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3787
3866
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3788
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3789
|
-
const messages = getValidationErrors(currentValue);
|
|
3790
|
-
update((draft) => {
|
|
3791
|
-
draft.errors = messages;
|
|
3792
|
-
});
|
|
3793
|
-
return messages;
|
|
3794
|
-
};
|
|
3795
3867
|
const dateInputComponent = __spreadValues({
|
|
3796
3868
|
type: "date",
|
|
3797
3869
|
uid,
|
|
3798
3870
|
id,
|
|
3799
3871
|
value,
|
|
3872
|
+
_update(updateFn) {
|
|
3873
|
+
update(this, updateFn);
|
|
3874
|
+
},
|
|
3800
3875
|
onBlur() {
|
|
3801
|
-
|
|
3876
|
+
this.validate();
|
|
3802
3877
|
},
|
|
3803
3878
|
onFocus() {
|
|
3804
3879
|
},
|
|
3805
3880
|
// Noop
|
|
3806
3881
|
onChange(updatedValue) {
|
|
3807
3882
|
const prevValue = this.value;
|
|
3808
|
-
|
|
3883
|
+
this._update((draft) => {
|
|
3809
3884
|
draft.errors = [];
|
|
3810
3885
|
draft.validationAsyncState.messages = {};
|
|
3811
3886
|
draft.value = updatedValue;
|
|
@@ -3829,8 +3904,11 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3829
3904
|
return this.value;
|
|
3830
3905
|
},
|
|
3831
3906
|
validate() {
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3907
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
3908
|
+
this._update((draft) => {
|
|
3909
|
+
draft.errors = errors;
|
|
3910
|
+
});
|
|
3911
|
+
return errors.length === 0;
|
|
3834
3912
|
}
|
|
3835
3913
|
}, rest);
|
|
3836
3914
|
if (performRefresh) {
|
|
@@ -3843,12 +3921,12 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3843
3921
|
dateInputComponent.onChange.call(this, updatedValue);
|
|
3844
3922
|
const isValid = getValidationErrors(updatedValue).length === 0;
|
|
3845
3923
|
if (isValid) {
|
|
3846
|
-
persist(this
|
|
3924
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
3847
3925
|
});
|
|
3848
3926
|
}
|
|
3849
3927
|
},
|
|
3850
3928
|
async getSubmittableValue() {
|
|
3851
|
-
return persist(this
|
|
3929
|
+
return persist(this, this.getLocalValue());
|
|
3852
3930
|
},
|
|
3853
3931
|
getSubmittableValueSync() {
|
|
3854
3932
|
return this.persistedState.lastResponse;
|
|
@@ -3860,7 +3938,7 @@ var createDateInputComponent = (textInputProps, updateComponent) => {
|
|
|
3860
3938
|
return __spreadProps(__spreadValues({}, dateInputComponent), {
|
|
3861
3939
|
onBlur() {
|
|
3862
3940
|
if (this.validate()) {
|
|
3863
|
-
validateAsync(this
|
|
3941
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
3864
3942
|
});
|
|
3865
3943
|
}
|
|
3866
3944
|
}
|
|
@@ -3963,29 +4041,25 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
3963
4041
|
"onValueChange",
|
|
3964
4042
|
"summariser"
|
|
3965
4043
|
]);
|
|
3966
|
-
const update = getInputUpdateFunction(
|
|
4044
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
3967
4045
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
3968
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
3969
|
-
const messages = getValidationErrors(currentValue);
|
|
3970
|
-
update((draft) => {
|
|
3971
|
-
draft.errors = messages;
|
|
3972
|
-
});
|
|
3973
|
-
return messages;
|
|
3974
|
-
};
|
|
3975
4046
|
const uploadComponent = __spreadValues({
|
|
3976
4047
|
type: "upload",
|
|
3977
4048
|
uid,
|
|
3978
4049
|
id,
|
|
3979
4050
|
format: "base64",
|
|
3980
4051
|
value,
|
|
4052
|
+
_update(updateFn) {
|
|
4053
|
+
update(this, updateFn);
|
|
4054
|
+
},
|
|
3981
4055
|
onBlur() {
|
|
3982
|
-
|
|
4056
|
+
this.validate();
|
|
3983
4057
|
},
|
|
3984
4058
|
onFocus() {
|
|
3985
4059
|
},
|
|
3986
4060
|
// Noop
|
|
3987
4061
|
async onUpload(updatedValue) {
|
|
3988
|
-
|
|
4062
|
+
this._update((draft) => {
|
|
3989
4063
|
draft.errors = [];
|
|
3990
4064
|
draft.value = updatedValue;
|
|
3991
4065
|
});
|
|
@@ -4007,8 +4081,11 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4007
4081
|
return this.value;
|
|
4008
4082
|
},
|
|
4009
4083
|
validate() {
|
|
4010
|
-
const
|
|
4011
|
-
|
|
4084
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4085
|
+
this._update((draft) => {
|
|
4086
|
+
draft.errors = errors;
|
|
4087
|
+
});
|
|
4088
|
+
return errors.length === 0;
|
|
4012
4089
|
}
|
|
4013
4090
|
}, rest);
|
|
4014
4091
|
if (!performPersistAsync) {
|
|
@@ -4018,14 +4095,14 @@ var createUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4018
4095
|
return __spreadProps(__spreadValues({}, uploadComponent), {
|
|
4019
4096
|
format,
|
|
4020
4097
|
async onUpload(file) {
|
|
4021
|
-
|
|
4098
|
+
this._update((draft) => {
|
|
4022
4099
|
draft.errors = [];
|
|
4023
4100
|
draft.value = file;
|
|
4024
4101
|
});
|
|
4025
4102
|
onValueChange();
|
|
4026
4103
|
const submission = format === "base64" && file ? await toBase64(file) : file;
|
|
4027
|
-
await persist(this
|
|
4028
|
-
|
|
4104
|
+
await persist(this, submission).catch((error) => {
|
|
4105
|
+
this._update((draft) => {
|
|
4029
4106
|
draft.persistedState.lastResponse = null;
|
|
4030
4107
|
draft.persistedState.lastSubmitted = null;
|
|
4031
4108
|
draft.persistedState.submission = Promise.resolve(null);
|
|
@@ -4104,23 +4181,19 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4104
4181
|
"summariser",
|
|
4105
4182
|
"value"
|
|
4106
4183
|
]);
|
|
4107
|
-
const update = getInputUpdateFunction(
|
|
4184
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4108
4185
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4109
4186
|
const performDebouncedRefresh = getDebouncedPerformRefresh(performRefresh, getValidationErrors);
|
|
4110
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4111
|
-
const messages = getValidationErrors(currentValue);
|
|
4112
|
-
update((draft) => {
|
|
4113
|
-
draft.errors = messages;
|
|
4114
|
-
});
|
|
4115
|
-
return messages;
|
|
4116
|
-
};
|
|
4117
4187
|
const inputComponent = __spreadValues({
|
|
4118
4188
|
type: "text",
|
|
4119
4189
|
uid,
|
|
4120
4190
|
id,
|
|
4121
4191
|
value,
|
|
4192
|
+
_update(updateFn) {
|
|
4193
|
+
update(this, updateFn);
|
|
4194
|
+
},
|
|
4122
4195
|
onBlur() {
|
|
4123
|
-
|
|
4196
|
+
this.validate();
|
|
4124
4197
|
performDebouncedRefresh == null ? void 0 : performDebouncedRefresh.flush();
|
|
4125
4198
|
},
|
|
4126
4199
|
onFocus() {
|
|
@@ -4128,7 +4201,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4128
4201
|
// Noop
|
|
4129
4202
|
onChange(updatedValue) {
|
|
4130
4203
|
const prevValue = this.value;
|
|
4131
|
-
|
|
4204
|
+
this._update((draft) => {
|
|
4132
4205
|
draft.errors = [];
|
|
4133
4206
|
draft.validationAsyncState.messages = {};
|
|
4134
4207
|
draft.value = updatedValue;
|
|
@@ -4149,8 +4222,11 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4149
4222
|
return this.value;
|
|
4150
4223
|
},
|
|
4151
4224
|
validate() {
|
|
4152
|
-
const
|
|
4153
|
-
|
|
4225
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4226
|
+
this._update((draft) => {
|
|
4227
|
+
draft.errors = errors;
|
|
4228
|
+
});
|
|
4229
|
+
return errors.length === 0;
|
|
4154
4230
|
}
|
|
4155
4231
|
}, rest);
|
|
4156
4232
|
if (performRefresh) {
|
|
@@ -4161,12 +4237,12 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4161
4237
|
return __spreadProps(__spreadValues({}, inputComponent), {
|
|
4162
4238
|
onBlur() {
|
|
4163
4239
|
if (this.validate()) {
|
|
4164
|
-
persist(this
|
|
4240
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
4165
4241
|
});
|
|
4166
4242
|
}
|
|
4167
4243
|
},
|
|
4168
4244
|
async getSubmittableValue() {
|
|
4169
|
-
return persist(this
|
|
4245
|
+
return persist(this, this.getLocalValue());
|
|
4170
4246
|
},
|
|
4171
4247
|
getSubmittableValueSync() {
|
|
4172
4248
|
return this.persistedState.lastResponse;
|
|
@@ -4184,7 +4260,7 @@ var createTextInputComponent = (textInputProps, updateComponent) => {
|
|
|
4184
4260
|
onChange(updatedValue) {
|
|
4185
4261
|
inputComponent.onChange.call(this, updatedValue);
|
|
4186
4262
|
if (getValidationErrors(updatedValue).length === 0) {
|
|
4187
|
-
validateAsync(this
|
|
4263
|
+
validateAsync(this, updatedValue);
|
|
4188
4264
|
}
|
|
4189
4265
|
if (!updatedValue) {
|
|
4190
4266
|
validateAsync.cancel();
|
|
@@ -4322,9 +4398,9 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4322
4398
|
"createEditableComponent",
|
|
4323
4399
|
"summariser"
|
|
4324
4400
|
]);
|
|
4325
|
-
const update = getInputUpdateFunction(
|
|
4401
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4326
4402
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4327
|
-
|
|
4403
|
+
const repeatableComponent = __spreadProps(__spreadValues({
|
|
4328
4404
|
uid,
|
|
4329
4405
|
id,
|
|
4330
4406
|
type: "repeatable",
|
|
@@ -4338,8 +4414,11 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4338
4414
|
image: summary == null ? void 0 : summary.defaultImage
|
|
4339
4415
|
}
|
|
4340
4416
|
}, componentProps), {
|
|
4417
|
+
_update(updateFn) {
|
|
4418
|
+
update(this, updateFn);
|
|
4419
|
+
},
|
|
4341
4420
|
onEdit(itemIndex) {
|
|
4342
|
-
|
|
4421
|
+
this._update((draft) => {
|
|
4343
4422
|
draft.editableComponent = createEditableComponent(
|
|
4344
4423
|
draft.components[itemIndex].getLocalValue()
|
|
4345
4424
|
);
|
|
@@ -4347,7 +4426,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4347
4426
|
});
|
|
4348
4427
|
},
|
|
4349
4428
|
onAdd() {
|
|
4350
|
-
|
|
4429
|
+
this._update((draft) => {
|
|
4351
4430
|
draft.editableComponent = createEditableComponent(null);
|
|
4352
4431
|
draft.editableIndex = null;
|
|
4353
4432
|
draft.errors = [];
|
|
@@ -4359,7 +4438,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4359
4438
|
if (!isValid) {
|
|
4360
4439
|
return false;
|
|
4361
4440
|
}
|
|
4362
|
-
|
|
4441
|
+
this._update((draft) => {
|
|
4363
4442
|
if (draft.editableComponent === null) {
|
|
4364
4443
|
return;
|
|
4365
4444
|
}
|
|
@@ -4378,7 +4457,7 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4378
4457
|
return true;
|
|
4379
4458
|
},
|
|
4380
4459
|
onRemove() {
|
|
4381
|
-
|
|
4460
|
+
this._update((draft) => {
|
|
4382
4461
|
if (draft.editableIndex === null) {
|
|
4383
4462
|
return;
|
|
4384
4463
|
}
|
|
@@ -4406,12 +4485,13 @@ var createRepeatableComponent = (repeatableProps, updateComponent) => {
|
|
|
4406
4485
|
validate() {
|
|
4407
4486
|
const messages = getValidationErrors(this.getLocalValue());
|
|
4408
4487
|
const childComponentsValid = validateComponents(this.getChildren());
|
|
4409
|
-
|
|
4488
|
+
this._update((draft) => {
|
|
4410
4489
|
draft.errors = messages;
|
|
4411
4490
|
});
|
|
4412
4491
|
return messages.length === 0 && childComponentsValid;
|
|
4413
4492
|
}
|
|
4414
4493
|
});
|
|
4494
|
+
return repeatableComponent;
|
|
4415
4495
|
};
|
|
4416
4496
|
|
|
4417
4497
|
// src/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToRepeatableComponent.ts
|
|
@@ -4511,30 +4591,26 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4511
4591
|
"onValueChange",
|
|
4512
4592
|
"summariser"
|
|
4513
4593
|
]);
|
|
4514
|
-
const update = getInputUpdateFunction(
|
|
4594
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4515
4595
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4516
4596
|
const getFileValidationErrors = getLocalValueValidator(fileChecks);
|
|
4517
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4518
|
-
const messages = getValidationErrors(currentValue);
|
|
4519
|
-
update((draft) => {
|
|
4520
|
-
draft.errors = messages;
|
|
4521
|
-
});
|
|
4522
|
-
return messages;
|
|
4523
|
-
};
|
|
4524
4597
|
const uploadComponent = __spreadValues({
|
|
4525
4598
|
type: "multi-upload",
|
|
4526
4599
|
uid,
|
|
4527
4600
|
id,
|
|
4528
4601
|
format: "base64",
|
|
4529
4602
|
files: [],
|
|
4603
|
+
_update(updateFn) {
|
|
4604
|
+
update(this, updateFn);
|
|
4605
|
+
},
|
|
4530
4606
|
onBlur() {
|
|
4531
|
-
|
|
4607
|
+
this.validate();
|
|
4532
4608
|
},
|
|
4533
4609
|
onFocus() {
|
|
4534
4610
|
},
|
|
4535
4611
|
// Noop
|
|
4536
4612
|
async onRemoveFile(index) {
|
|
4537
|
-
|
|
4613
|
+
this._update((draft) => {
|
|
4538
4614
|
draft.value.splice(index, 1);
|
|
4539
4615
|
draft.files.splice(index, 1);
|
|
4540
4616
|
});
|
|
@@ -4542,7 +4618,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4542
4618
|
async onInsertFile(index, file) {
|
|
4543
4619
|
const fileErrors = getFileValidationErrors(file);
|
|
4544
4620
|
const fileId = getRandomId();
|
|
4545
|
-
|
|
4621
|
+
this._update((draft) => {
|
|
4546
4622
|
draft.value.splice(index, 0, file);
|
|
4547
4623
|
draft.files.splice(index, 0, { file, id: fileId, errors: fileErrors });
|
|
4548
4624
|
draft.errors = [];
|
|
@@ -4564,8 +4640,11 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4564
4640
|
return this.value;
|
|
4565
4641
|
},
|
|
4566
4642
|
validate() {
|
|
4567
|
-
const
|
|
4568
|
-
|
|
4643
|
+
const errorMsgs = getValidationErrors(this.getLocalValue());
|
|
4644
|
+
this._update((draft) => {
|
|
4645
|
+
draft.errors = errorMsgs;
|
|
4646
|
+
});
|
|
4647
|
+
return errorMsgs.length === 0 && this.files.every(({ errors }) => errors.length === 0);
|
|
4569
4648
|
}
|
|
4570
4649
|
}, rest);
|
|
4571
4650
|
if (!performPersistAsync) {
|
|
@@ -4577,7 +4656,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4577
4656
|
async onInsertFile(index, file) {
|
|
4578
4657
|
const fileId = await uploadComponent.onInsertFile.call(this, index, file);
|
|
4579
4658
|
const submission = format === "blob" ? file : await toBase64(file);
|
|
4580
|
-
await persist(index, submission);
|
|
4659
|
+
await persist(this, index, submission);
|
|
4581
4660
|
onValueChange();
|
|
4582
4661
|
return fileId;
|
|
4583
4662
|
},
|
|
@@ -4585,7 +4664,7 @@ var createMultiUploadInputComponent = (uploadInputProps, updateComponent) => {
|
|
|
4585
4664
|
var _a2;
|
|
4586
4665
|
await uploadComponent.onRemoveFile.call(this, index);
|
|
4587
4666
|
(_a2 = this.persistedState[index]) == null ? void 0 : _a2.abortController.abort();
|
|
4588
|
-
|
|
4667
|
+
this._update((draft) => {
|
|
4589
4668
|
draft.persistedState = draft.persistedState.splice(index, 1);
|
|
4590
4669
|
});
|
|
4591
4670
|
},
|
|
@@ -4691,17 +4770,10 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4691
4770
|
"performRefresh",
|
|
4692
4771
|
"onValueChange"
|
|
4693
4772
|
]);
|
|
4694
|
-
const update = getInputUpdateFunction(
|
|
4773
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4695
4774
|
const children = options.map((option) => option.component);
|
|
4696
4775
|
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4697
4776
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4698
|
-
const getAndSetValidationErrors = (currentValue) => {
|
|
4699
|
-
const messages = getValidationErrors(currentValue);
|
|
4700
|
-
update((draft) => {
|
|
4701
|
-
draft.errors = messages;
|
|
4702
|
-
});
|
|
4703
|
-
return messages;
|
|
4704
|
-
};
|
|
4705
4777
|
const inputComponent = __spreadProps(__spreadValues({
|
|
4706
4778
|
uid,
|
|
4707
4779
|
type: "multi-select",
|
|
@@ -4710,14 +4782,20 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4710
4782
|
selectedIndices,
|
|
4711
4783
|
value: null
|
|
4712
4784
|
}, rest), {
|
|
4785
|
+
_update(updateFn) {
|
|
4786
|
+
update(this, updateFn);
|
|
4787
|
+
},
|
|
4713
4788
|
onSelect(indices) {
|
|
4714
|
-
|
|
4789
|
+
this._update((draft) => {
|
|
4715
4790
|
draft.selectedIndices = indices;
|
|
4716
4791
|
draft.errors = [];
|
|
4717
4792
|
});
|
|
4718
4793
|
performRefresh == null ? void 0 : performRefresh();
|
|
4719
4794
|
onValueChange();
|
|
4720
|
-
|
|
4795
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4796
|
+
this._update((draft) => {
|
|
4797
|
+
draft.errors = errors;
|
|
4798
|
+
});
|
|
4721
4799
|
},
|
|
4722
4800
|
onBlur() {
|
|
4723
4801
|
},
|
|
@@ -4730,8 +4808,11 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4730
4808
|
return (_b = (_a2 = this.getSelectedChildren()) == null ? void 0 : _a2.map((child) => child.getLocalValue())) != null ? _b : null;
|
|
4731
4809
|
},
|
|
4732
4810
|
validate() {
|
|
4733
|
-
const
|
|
4734
|
-
|
|
4811
|
+
const errors = getValidationErrors(this.getLocalValue());
|
|
4812
|
+
this._update((draft) => {
|
|
4813
|
+
draft.errors = errors;
|
|
4814
|
+
});
|
|
4815
|
+
return errors.length === 0;
|
|
4735
4816
|
},
|
|
4736
4817
|
async getSubmittableValue() {
|
|
4737
4818
|
const selected = this.getSelectedChildren();
|
|
@@ -4761,7 +4842,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4761
4842
|
onSelect(indices) {
|
|
4762
4843
|
inputComponent.onSelect.call(this, indices);
|
|
4763
4844
|
if (this.validate()) {
|
|
4764
|
-
validateAsync(this
|
|
4845
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4765
4846
|
});
|
|
4766
4847
|
}
|
|
4767
4848
|
}
|
|
@@ -4962,13 +5043,16 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4962
5043
|
"onValueChange",
|
|
4963
5044
|
"summariser"
|
|
4964
5045
|
]);
|
|
4965
|
-
const update = getInputUpdateFunction(
|
|
5046
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
4966
5047
|
const booleanComponent = __spreadValues({
|
|
4967
5048
|
type: "boolean",
|
|
4968
5049
|
uid,
|
|
4969
5050
|
id,
|
|
4970
5051
|
autoComplete: "",
|
|
4971
5052
|
value,
|
|
5053
|
+
_update(updateFn) {
|
|
5054
|
+
update(this, updateFn);
|
|
5055
|
+
},
|
|
4972
5056
|
onBlur() {
|
|
4973
5057
|
},
|
|
4974
5058
|
// Noop
|
|
@@ -4976,7 +5060,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
4976
5060
|
},
|
|
4977
5061
|
// Noop
|
|
4978
5062
|
onChange(updatedValue) {
|
|
4979
|
-
|
|
5063
|
+
this._update((draft) => {
|
|
4980
5064
|
draft.errors = [];
|
|
4981
5065
|
draft.value = updatedValue;
|
|
4982
5066
|
});
|
|
@@ -5005,11 +5089,11 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
5005
5089
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
5006
5090
|
onChange(updatedValue) {
|
|
5007
5091
|
booleanComponent.onChange.call(this, updatedValue);
|
|
5008
|
-
persist(this
|
|
5092
|
+
persist(this, this.getLocalValue()).catch(() => {
|
|
5009
5093
|
});
|
|
5010
5094
|
},
|
|
5011
5095
|
async getSubmittableValue() {
|
|
5012
|
-
return persist(this
|
|
5096
|
+
return persist(this, this.getLocalValue());
|
|
5013
5097
|
},
|
|
5014
5098
|
getSubmittableValueSync() {
|
|
5015
5099
|
return this.persistedState.lastResponse;
|
|
@@ -5021,7 +5105,7 @@ var createBooleanInputComponent = (booleanInputProps, updateComponent) => {
|
|
|
5021
5105
|
return __spreadProps(__spreadValues({}, booleanComponent), {
|
|
5022
5106
|
onChange(updatedValue) {
|
|
5023
5107
|
booleanComponent.onChange.call(this, updatedValue);
|
|
5024
|
-
validateAsync(this
|
|
5108
|
+
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
5025
5109
|
});
|
|
5026
5110
|
}
|
|
5027
5111
|
});
|
|
@@ -5466,9 +5550,9 @@ var getOrientationControl = ({
|
|
|
5466
5550
|
var DEBOUNCE_TIME = 400;
|
|
5467
5551
|
var createSearchComponent = (searchProps, performSearch, onBehavior, updateComponent) => {
|
|
5468
5552
|
const { uid, control, emptyMessage, margin, title } = searchProps;
|
|
5469
|
-
const update = getInputUpdateFunction(
|
|
5553
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
5470
5554
|
let abortController = new AbortController();
|
|
5471
|
-
const search = (query, searchConfig) => {
|
|
5555
|
+
const search = (component2, query, searchConfig) => {
|
|
5472
5556
|
abortController.abort();
|
|
5473
5557
|
abortController = new AbortController();
|
|
5474
5558
|
const { signal } = abortController;
|
|
@@ -5478,7 +5562,7 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5478
5562
|
config: searchConfig
|
|
5479
5563
|
}).then((results) => {
|
|
5480
5564
|
if (!signal.aborted) {
|
|
5481
|
-
update((draft) => {
|
|
5565
|
+
update(component2, (draft) => {
|
|
5482
5566
|
draft.results = results;
|
|
5483
5567
|
draft.isLoading = false;
|
|
5484
5568
|
draft.error = void 0;
|
|
@@ -5486,33 +5570,15 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5486
5570
|
}
|
|
5487
5571
|
}).catch(() => {
|
|
5488
5572
|
if (!signal.aborted) {
|
|
5489
|
-
update((draft) => {
|
|
5573
|
+
update(component2, (draft) => {
|
|
5490
5574
|
draft.error = "No response";
|
|
5491
5575
|
draft.isLoading = false;
|
|
5492
5576
|
});
|
|
5493
5577
|
}
|
|
5494
5578
|
});
|
|
5495
5579
|
};
|
|
5496
|
-
const onSelect = ({ type, value }) => {
|
|
5497
|
-
if (type === "action") {
|
|
5498
|
-
void onBehavior({ type: "action", action: value });
|
|
5499
|
-
} else {
|
|
5500
|
-
update((draft) => {
|
|
5501
|
-
draft.query = value.query;
|
|
5502
|
-
draft.isLoading = true;
|
|
5503
|
-
});
|
|
5504
|
-
search(value.query, { method: value.method, param: value.param, url: value.url });
|
|
5505
|
-
}
|
|
5506
|
-
};
|
|
5507
5580
|
const debouncedSearch = debounce(search, DEBOUNCE_TIME);
|
|
5508
|
-
const
|
|
5509
|
-
update((draft) => {
|
|
5510
|
-
draft.query = query;
|
|
5511
|
-
draft.isLoading = true;
|
|
5512
|
-
});
|
|
5513
|
-
debouncedSearch(query.trim());
|
|
5514
|
-
};
|
|
5515
|
-
return {
|
|
5581
|
+
const component = {
|
|
5516
5582
|
type: "search",
|
|
5517
5583
|
uid,
|
|
5518
5584
|
control,
|
|
@@ -5522,15 +5588,39 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
5522
5588
|
isLoading: false,
|
|
5523
5589
|
query: "",
|
|
5524
5590
|
results: [],
|
|
5591
|
+
_update(updateFn) {
|
|
5592
|
+
update(this, updateFn);
|
|
5593
|
+
},
|
|
5525
5594
|
getSubmittableValue: async () => null,
|
|
5526
5595
|
getSubmittableValueSync: () => null,
|
|
5527
5596
|
getLocalValue: () => null,
|
|
5528
5597
|
getSummary: () => ({}),
|
|
5529
5598
|
// Noop
|
|
5530
5599
|
validate: () => true,
|
|
5531
|
-
onChange
|
|
5532
|
-
|
|
5600
|
+
onChange(query) {
|
|
5601
|
+
this._update((draft) => {
|
|
5602
|
+
draft.query = query;
|
|
5603
|
+
draft.isLoading = true;
|
|
5604
|
+
});
|
|
5605
|
+
debouncedSearch(this, query.trim());
|
|
5606
|
+
},
|
|
5607
|
+
onSelect({ type, value }) {
|
|
5608
|
+
if (type === "action") {
|
|
5609
|
+
void onBehavior({ type: "action", action: value });
|
|
5610
|
+
} else {
|
|
5611
|
+
this._update((draft) => {
|
|
5612
|
+
draft.query = value.query;
|
|
5613
|
+
draft.isLoading = true;
|
|
5614
|
+
});
|
|
5615
|
+
search(this, value.query, {
|
|
5616
|
+
method: value.method,
|
|
5617
|
+
param: value.param,
|
|
5618
|
+
url: value.url
|
|
5619
|
+
});
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5533
5622
|
};
|
|
5623
|
+
return component;
|
|
5534
5624
|
};
|
|
5535
5625
|
|
|
5536
5626
|
// src/revamp/domain/features/search/getPerformSearchFunction.ts
|
|
@@ -5843,7 +5933,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5843
5933
|
};
|
|
5844
5934
|
|
|
5845
5935
|
// src/revamp/flow/getResponseType.ts
|
|
5846
|
-
var responseTypes = ["step", "action", "exit"];
|
|
5936
|
+
var responseTypes = ["step", "action", "exit", "modal"];
|
|
5847
5937
|
var getResponseType = async (response) => {
|
|
5848
5938
|
assertResponseIsValid(response);
|
|
5849
5939
|
const headerResponseType = getResponseTypeFromHeader(response);
|
|
@@ -5871,7 +5961,7 @@ var getResponseTypeFromHeader = (response) => {
|
|
|
5871
5961
|
function assertDFResponseType(type) {
|
|
5872
5962
|
if (!responseTypes.includes(type)) {
|
|
5873
5963
|
throw new Error(
|
|
5874
|
-
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error'."
|
|
5964
|
+
"Unsupported X-Df-Response-Type. Allowed values are 'step', 'action', 'exit', 'error', 'modal'."
|
|
5875
5965
|
);
|
|
5876
5966
|
}
|
|
5877
5967
|
}
|
|
@@ -6026,6 +6116,10 @@ var executeSubmission = async (props) => {
|
|
|
6026
6116
|
trackSubmissionEvent("Action Succeeded", { actionId });
|
|
6027
6117
|
return await triggerAction(body.action, null, false);
|
|
6028
6118
|
}
|
|
6119
|
+
case "modal": {
|
|
6120
|
+
assertModalResponseBody(body);
|
|
6121
|
+
return { type: "behavior", behavior: __spreadProps(__spreadValues({}, body), { type: "modal" }) };
|
|
6122
|
+
}
|
|
6029
6123
|
default: {
|
|
6030
6124
|
throw new Error(`Unsupported response type: ${String(responseType)}`);
|
|
6031
6125
|
}
|
|
@@ -6260,29 +6354,6 @@ var formatDateOptions = {
|
|
|
6260
6354
|
dateStyle: "long"
|
|
6261
6355
|
};
|
|
6262
6356
|
|
|
6263
|
-
// src/revamp/utils/findComponent.ts
|
|
6264
|
-
var findComponent = (components, id, logEvent) => {
|
|
6265
|
-
const flattened = flattenComponents(components);
|
|
6266
|
-
const matching = flattened.filter((component) => component.uid === id);
|
|
6267
|
-
if (matching.length === 1) {
|
|
6268
|
-
return matching[0];
|
|
6269
|
-
}
|
|
6270
|
-
if (matching.length > 1) {
|
|
6271
|
-
throw new Error(`Multiple components with the same uid: ${id}`);
|
|
6272
|
-
}
|
|
6273
|
-
logEvent("error", "Failed to find domain layer component", {
|
|
6274
|
-
componentUid: id,
|
|
6275
|
-
componentsTree: flattened.map((component) => component.uid)
|
|
6276
|
-
});
|
|
6277
|
-
throw new Error(`Failed to find any components with uid: ${id}`);
|
|
6278
|
-
};
|
|
6279
|
-
var flattenComponents = (components) => components.reduce((acc, component) => {
|
|
6280
|
-
if (hasChildren(component)) {
|
|
6281
|
-
return [...acc, component, ...flattenComponents(component.getChildren())];
|
|
6282
|
-
}
|
|
6283
|
-
return [...acc, component];
|
|
6284
|
-
}, []);
|
|
6285
|
-
|
|
6286
6357
|
// src/revamp/utils/useStableCallback.tsx
|
|
6287
6358
|
var import_react2 = require("react");
|
|
6288
6359
|
function useStableCallback(handler) {
|
|
@@ -6293,6 +6364,55 @@ function useStableCallback(handler) {
|
|
|
6293
6364
|
return (0, import_react2.useCallback)((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6294
6365
|
}
|
|
6295
6366
|
|
|
6367
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6368
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6369
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
6370
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6371
|
+
type: "modal-content",
|
|
6372
|
+
open: true
|
|
6373
|
+
}, modalProps), {
|
|
6374
|
+
_update(updateFn) {
|
|
6375
|
+
update(this, updateFn);
|
|
6376
|
+
},
|
|
6377
|
+
getChildren() {
|
|
6378
|
+
return this.components;
|
|
6379
|
+
},
|
|
6380
|
+
getLocalValue() {
|
|
6381
|
+
return getLocalValues(this.getChildren());
|
|
6382
|
+
},
|
|
6383
|
+
async getSubmittableValue() {
|
|
6384
|
+
return getSubmittableData(this.getChildren());
|
|
6385
|
+
},
|
|
6386
|
+
getSubmittableValueSync() {
|
|
6387
|
+
return getSubmittableDataSync(this.getChildren());
|
|
6388
|
+
},
|
|
6389
|
+
getSummary() {
|
|
6390
|
+
return summariseFromChildren(this.getChildren());
|
|
6391
|
+
},
|
|
6392
|
+
validate() {
|
|
6393
|
+
return validateComponents(this.getChildren());
|
|
6394
|
+
},
|
|
6395
|
+
close() {
|
|
6396
|
+
update(this, (draft) => {
|
|
6397
|
+
draft.open = false;
|
|
6398
|
+
});
|
|
6399
|
+
}
|
|
6400
|
+
});
|
|
6401
|
+
return modalContentComponent;
|
|
6402
|
+
};
|
|
6403
|
+
|
|
6404
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6405
|
+
var modalToContent = (uid, { content, title }, mapperProps) => createModalContentComponent(
|
|
6406
|
+
{
|
|
6407
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
6408
|
+
title,
|
|
6409
|
+
components: content.map(
|
|
6410
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps)
|
|
6411
|
+
)
|
|
6412
|
+
},
|
|
6413
|
+
mapperProps.updateComponent
|
|
6414
|
+
);
|
|
6415
|
+
|
|
6296
6416
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6297
6417
|
function useDynamicFlowCore(props) {
|
|
6298
6418
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6309,15 +6429,7 @@ function useDynamicFlowCore(props) {
|
|
|
6309
6429
|
[formatMessage, locale]
|
|
6310
6430
|
);
|
|
6311
6431
|
const rerender = useRerender();
|
|
6312
|
-
const rootComponentRef = (0, import_react3.useRef)(createRootDomainComponent());
|
|
6313
|
-
const updateComponent = (0, import_react3.useCallback)(
|
|
6314
|
-
(id, update) => {
|
|
6315
|
-
update(findComponent([rootComponentRef.current], id, logEvent));
|
|
6316
|
-
rerender();
|
|
6317
|
-
},
|
|
6318
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
6319
|
-
[]
|
|
6320
|
-
);
|
|
6432
|
+
const rootComponentRef = (0, import_react3.useRef)(createRootDomainComponent(rerender));
|
|
6321
6433
|
const stepCount = (0, import_react3.useRef)(0);
|
|
6322
6434
|
const stepRef = (0, import_react3.useRef)(initialStep != null ? initialStep : null);
|
|
6323
6435
|
const etagRef = (0, import_react3.useRef)(null);
|
|
@@ -6350,6 +6462,20 @@ function useDynamicFlowCore(props) {
|
|
|
6350
6462
|
var _a2;
|
|
6351
6463
|
initialiseWithStep(newStep, etag, (_a2 = rootComponentRef.current.getLocalValue()) != null ? _a2 : null);
|
|
6352
6464
|
}, []);
|
|
6465
|
+
const getMapperProps = () => ({
|
|
6466
|
+
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6467
|
+
displayStepTitle,
|
|
6468
|
+
loadingState: "idle",
|
|
6469
|
+
updateComponent: () => rerender(),
|
|
6470
|
+
getErrorMessageFunctions,
|
|
6471
|
+
trackEvent,
|
|
6472
|
+
logEvent,
|
|
6473
|
+
httpClient,
|
|
6474
|
+
onBehavior,
|
|
6475
|
+
onRefresh,
|
|
6476
|
+
onPoll,
|
|
6477
|
+
onValueChange
|
|
6478
|
+
});
|
|
6353
6479
|
const initialiseWithStep = (0, import_react3.useCallback)(
|
|
6354
6480
|
(newStep, etag, localValue) => {
|
|
6355
6481
|
rootComponentRef.current.stop();
|
|
@@ -6362,25 +6488,11 @@ function useDynamicFlowCore(props) {
|
|
|
6362
6488
|
});
|
|
6363
6489
|
}
|
|
6364
6490
|
try {
|
|
6365
|
-
const newStepComponent = mapStepToComponent({
|
|
6366
|
-
uid: `${rootComponentRef.current.uid}:${stepCount.current}`,
|
|
6491
|
+
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6367
6492
|
stepLocalValue: localValue,
|
|
6368
|
-
step: newStep
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
updateComponent,
|
|
6372
|
-
getErrorMessageFunctions,
|
|
6373
|
-
trackEvent,
|
|
6374
|
-
logEvent,
|
|
6375
|
-
httpClient,
|
|
6376
|
-
onBehavior,
|
|
6377
|
-
onRefresh,
|
|
6378
|
-
onPoll,
|
|
6379
|
-
onValueChange
|
|
6380
|
-
});
|
|
6381
|
-
updateComponent(rootComponentRef.current.uid, (draft) => {
|
|
6382
|
-
draft.stepComponent = newStepComponent;
|
|
6383
|
-
});
|
|
6493
|
+
step: newStep
|
|
6494
|
+
}, getMapperProps()));
|
|
6495
|
+
rootComponentRef.current.setStep(newStepComponent);
|
|
6384
6496
|
} catch (error) {
|
|
6385
6497
|
closeWithError(error);
|
|
6386
6498
|
}
|
|
@@ -6432,6 +6544,7 @@ function useDynamicFlowCore(props) {
|
|
|
6432
6544
|
const onBehavior = (0, import_react3.useCallback)(async (behavior) => {
|
|
6433
6545
|
switch (behavior.type) {
|
|
6434
6546
|
case "action": {
|
|
6547
|
+
rootComponentRef.current.dismissAllModals();
|
|
6435
6548
|
try {
|
|
6436
6549
|
const { action } = behavior;
|
|
6437
6550
|
await rootComponentRef.current.getSubmittableValue();
|
|
@@ -6451,10 +6564,20 @@ function useDynamicFlowCore(props) {
|
|
|
6451
6564
|
onLink(behavior.url);
|
|
6452
6565
|
break;
|
|
6453
6566
|
}
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6567
|
+
case "modal":
|
|
6568
|
+
if (stepRef.current) {
|
|
6569
|
+
rootComponentRef.current.showModal(
|
|
6570
|
+
modalToContent(rootComponentRef.current.uid, behavior, __spreadValues({
|
|
6571
|
+
step: stepRef.current,
|
|
6572
|
+
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6573
|
+
}, getMapperProps()))
|
|
6574
|
+
);
|
|
6575
|
+
}
|
|
6576
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6577
|
+
break;
|
|
6578
|
+
case "dismiss":
|
|
6579
|
+
rootComponentRef.current.dismissModal();
|
|
6580
|
+
break;
|
|
6458
6581
|
case "none":
|
|
6459
6582
|
break;
|
|
6460
6583
|
}
|
|
@@ -6519,6 +6642,11 @@ function useDynamicFlowCore(props) {
|
|
|
6519
6642
|
void onRefresh(void 0, refreshUrl, errors);
|
|
6520
6643
|
break;
|
|
6521
6644
|
}
|
|
6645
|
+
case "behavior": {
|
|
6646
|
+
void onBehavior(command.behavior);
|
|
6647
|
+
rootComponentRef.current.setLoadingState("idle");
|
|
6648
|
+
break;
|
|
6649
|
+
}
|
|
6522
6650
|
}
|
|
6523
6651
|
} catch (error) {
|
|
6524
6652
|
closeWithError(error);
|