@wise/dynamic-flow-client 4.5.4 → 4.5.6
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 +417 -579
- package/build/main.mjs +417 -579
- package/build/types/revamp/domain/components/AllOfComponent.d.ts +4 -5
- package/build/types/revamp/domain/components/ColumnsComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/ConstComponent.d.ts +2 -3
- package/build/types/revamp/domain/components/ContainerComponent.d.ts +1 -2
- package/build/types/revamp/domain/components/DecisionComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/FormComponent.d.ts +4 -4
- package/build/types/revamp/domain/components/HeadingComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/InstructionsComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/ListComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/MarkdownComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/ModalContentComponent.d.ts +1 -2
- package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +5 -5
- package/build/types/revamp/domain/components/ObjectComponent.d.ts +4 -5
- package/build/types/revamp/domain/components/RepeatableComponent.d.ts +6 -7
- package/build/types/revamp/domain/components/ReviewComponent.d.ts +1 -1
- package/build/types/revamp/domain/components/RootDomainComponent.d.ts +5 -2
- package/build/types/revamp/domain/components/SelectInputComponent.d.ts +5 -5
- package/build/types/revamp/domain/components/TupleComponent.d.ts +4 -5
- package/build/types/revamp/domain/components/step/ExternalConfirmationComponent.d.ts +1 -2
- package/build/types/revamp/domain/components/step/StepDomainComponent.d.ts +6 -3
- package/build/types/revamp/domain/features/summary/summary-utils.d.ts +2 -2
- package/build/types/revamp/domain/features/validation/validation-functions.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/boxLayoutToComponents.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/columnsLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/formLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/modalLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/layout/modalToContent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapLayoutToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +2 -2
- package/build/types/revamp/domain/mappers/mapStepSchemas.d.ts +2 -2
- package/build/types/revamp/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +1 -1
- package/build/types/revamp/domain/types.d.ts +15 -18
- package/build/types/revamp/utils/analyse-step.d.ts +3 -0
- package/build/types/revamp/utils/component-utils.d.ts +4 -4
- package/package.json +4 -4
package/build/main.mjs
CHANGED
|
@@ -1832,41 +1832,9 @@ var getComponentAlertProps = (component, rendererMapperProps) => "alert" in comp
|
|
|
1832
1832
|
}, rendererMapperProps) : null;
|
|
1833
1833
|
|
|
1834
1834
|
// src/revamp/useDynamicFlowCore.tsx
|
|
1835
|
-
import { validateStep } from "@wise/dynamic-flow-types";
|
|
1836
1835
|
import { useCallback as useCallback2, useEffect, useMemo, useRef as useRef2, useState } from "react";
|
|
1837
1836
|
import { useIntl as useIntl2 } from "react-intl";
|
|
1838
1837
|
|
|
1839
|
-
// src/revamp/utils/component-utils.ts
|
|
1840
|
-
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
1841
|
-
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
1842
|
-
);
|
|
1843
|
-
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
1844
|
-
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
1845
|
-
var mergeLocalValues = (valueA, valueB) => {
|
|
1846
|
-
if (valueA === null) {
|
|
1847
|
-
return valueB;
|
|
1848
|
-
}
|
|
1849
|
-
if (valueB === null) {
|
|
1850
|
-
return valueA;
|
|
1851
|
-
}
|
|
1852
|
-
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
1853
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1854
|
-
}
|
|
1855
|
-
return valueB;
|
|
1856
|
-
};
|
|
1857
|
-
var mergeModels = (valueA, valueB) => {
|
|
1858
|
-
if (valueA === null) {
|
|
1859
|
-
return valueB;
|
|
1860
|
-
}
|
|
1861
|
-
if (valueB === null) {
|
|
1862
|
-
return valueA;
|
|
1863
|
-
}
|
|
1864
|
-
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
1865
|
-
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
1866
|
-
}
|
|
1867
|
-
return valueB;
|
|
1868
|
-
};
|
|
1869
|
-
|
|
1870
1838
|
// src/revamp/domain/components/utils/component-utils.ts
|
|
1871
1839
|
var getInputUpdateFunction = (updateComponent) => {
|
|
1872
1840
|
return (component, updateFn) => {
|
|
@@ -1904,13 +1872,7 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1904
1872
|
return this.stepComponent ? this.stepComponent.getLocalValue() : null;
|
|
1905
1873
|
},
|
|
1906
1874
|
async getSubmittableValue() {
|
|
1907
|
-
return this.stepComponent ?
|
|
1908
|
-
},
|
|
1909
|
-
getSubmittableValueSync() {
|
|
1910
|
-
return this.stepComponent ? getSubmittableDataSync([this.stepComponent, ...this.stepComponent.getModals()]) : null;
|
|
1911
|
-
},
|
|
1912
|
-
getSummary() {
|
|
1913
|
-
return this.stepComponent ? this.stepComponent.getSummary() : {};
|
|
1875
|
+
return this.stepComponent ? this.stepComponent.getSubmittableValue() : null;
|
|
1914
1876
|
},
|
|
1915
1877
|
validate() {
|
|
1916
1878
|
return this.stepComponent ? this.stepComponent.validate() : false;
|
|
@@ -1922,8 +1884,8 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1922
1884
|
getLoadingState() {
|
|
1923
1885
|
return this.stepComponent ? this.stepComponent.loadingState : "initial";
|
|
1924
1886
|
},
|
|
1925
|
-
|
|
1926
|
-
return this.stepComponent ? this.stepComponent.
|
|
1887
|
+
getSchemaComponents() {
|
|
1888
|
+
return this.stepComponent ? this.stepComponent.schemaComponents : [];
|
|
1927
1889
|
},
|
|
1928
1890
|
getTrackEvent() {
|
|
1929
1891
|
return this.stepComponent ? this.stepComponent.trackEvent : null;
|
|
@@ -1944,141 +1906,36 @@ var createRootDomainComponent = (updateComponent) => {
|
|
|
1944
1906
|
return rootComponent;
|
|
1945
1907
|
};
|
|
1946
1908
|
|
|
1947
|
-
// src/revamp/domain/components/
|
|
1948
|
-
var
|
|
1949
|
-
const update = getInputUpdateFunction(updateComponent);
|
|
1950
|
-
return {
|
|
1951
|
-
type: "external-confirmation",
|
|
1952
|
-
uid,
|
|
1953
|
-
url,
|
|
1954
|
-
status: "initial",
|
|
1955
|
-
onSuccess() {
|
|
1956
|
-
update(this, (draft) => {
|
|
1957
|
-
draft.status = "success";
|
|
1958
|
-
});
|
|
1959
|
-
},
|
|
1960
|
-
onFailure() {
|
|
1961
|
-
if (this.status === "initial") {
|
|
1962
|
-
update(this, (draft) => {
|
|
1963
|
-
draft.status = "failure";
|
|
1964
|
-
});
|
|
1965
|
-
}
|
|
1966
|
-
},
|
|
1967
|
-
onCancel() {
|
|
1968
|
-
update(this, (draft) => {
|
|
1969
|
-
draft.status = "dismissed";
|
|
1970
|
-
});
|
|
1971
|
-
},
|
|
1972
|
-
getSubmittableValue: async () => null,
|
|
1973
|
-
getSubmittableValueSync: () => null,
|
|
1974
|
-
getLocalValue: () => null,
|
|
1975
|
-
getSummary: () => ({}),
|
|
1976
|
-
// Noop
|
|
1977
|
-
validate: () => true
|
|
1978
|
-
};
|
|
1979
|
-
};
|
|
1980
|
-
|
|
1981
|
-
// src/revamp/domain/features/summary/summary-utils.ts
|
|
1982
|
-
var getSummariser = (schema) => (value) => {
|
|
1983
|
-
const { summary, icon, image } = schema;
|
|
1984
|
-
const stringValueOrNull = isString(value) ? value : null;
|
|
1985
|
-
return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
|
|
1986
|
-
};
|
|
1987
|
-
var getConstSummary = (schema, model) => {
|
|
1988
|
-
const { summary, icon, image } = schema;
|
|
1989
|
-
const value = isString(model) ? model : null;
|
|
1990
|
-
return summaryIfProvides(summary, { value, icon, image });
|
|
1991
|
-
};
|
|
1992
|
-
var summariseFromChildren = (components) => components.reduce(
|
|
1993
|
-
(acc, component) => mergeSummaries(acc, component.getSummary()),
|
|
1994
|
-
{}
|
|
1995
|
-
);
|
|
1996
|
-
var mergeSummaries = (summaryA, summaryB) => {
|
|
1997
|
-
var _a, _b, _c, _d;
|
|
1998
|
-
return {
|
|
1999
|
-
title: (_a = summaryA.title) != null ? _a : summaryB.title,
|
|
2000
|
-
description: (_b = summaryA.description) != null ? _b : summaryB.description,
|
|
2001
|
-
icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
|
|
2002
|
-
image: (_d = summaryA.image) != null ? _d : summaryB.image
|
|
2003
|
-
};
|
|
2004
|
-
};
|
|
2005
|
-
var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
2006
|
-
if (!summary) {
|
|
2007
|
-
return {};
|
|
2008
|
-
}
|
|
2009
|
-
return {
|
|
2010
|
-
title: summary.providesTitle && value || void 0,
|
|
2011
|
-
description: summary.providesDescription && value || void 0,
|
|
2012
|
-
icon: summary.providesIcon && icon || void 0,
|
|
2013
|
-
image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
|
|
2014
|
-
};
|
|
2015
|
-
};
|
|
2016
|
-
|
|
2017
|
-
// src/revamp/domain/components/step/StepDomainComponent.ts
|
|
2018
|
-
var createStepComponent = (stepProps) => {
|
|
2019
|
-
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
1909
|
+
// src/revamp/domain/components/ModalContentComponent.ts
|
|
1910
|
+
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
2020
1911
|
const update = getInputUpdateFunction(updateComponent);
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
modals: [],
|
|
2026
|
-
dismissModal() {
|
|
2027
|
-
var _a2;
|
|
2028
|
-
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
2029
|
-
},
|
|
2030
|
-
dismissAllModals() {
|
|
2031
|
-
this._update((draft) => {
|
|
2032
|
-
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
2033
|
-
});
|
|
2034
|
-
},
|
|
2035
|
-
showModal(modal) {
|
|
2036
|
-
this._update((draft) => {
|
|
2037
|
-
draft.modals = [...draft.modals, modal];
|
|
2038
|
-
});
|
|
2039
|
-
},
|
|
1912
|
+
const modalContentComponent = __spreadProps(__spreadValues({
|
|
1913
|
+
type: "modal-content",
|
|
1914
|
+
open: true
|
|
1915
|
+
}, modalProps), {
|
|
2040
1916
|
_update(updateFn) {
|
|
2041
1917
|
update(this, updateFn);
|
|
2042
1918
|
},
|
|
2043
1919
|
getChildren() {
|
|
2044
|
-
return this.
|
|
2045
|
-
},
|
|
2046
|
-
getModals() {
|
|
2047
|
-
return this.modals;
|
|
2048
|
-
},
|
|
2049
|
-
async getSubmittableValue() {
|
|
2050
|
-
return getSubmittableData(this.inputComponents);
|
|
2051
|
-
},
|
|
2052
|
-
getSubmittableValueSync() {
|
|
2053
|
-
return getSubmittableDataSync(this.inputComponents);
|
|
2054
|
-
},
|
|
2055
|
-
getSummary() {
|
|
2056
|
-
return summariseFromChildren(this.getChildren());
|
|
2057
|
-
},
|
|
2058
|
-
getLocalValue() {
|
|
2059
|
-
return getLocalValues(this.inputComponents);
|
|
2060
|
-
},
|
|
2061
|
-
validate() {
|
|
2062
|
-
return this.inputComponents.every(
|
|
2063
|
-
(inputComponent) => inputComponent.isSchemaReferencedInStep ? inputComponent.validate() : true
|
|
2064
|
-
);
|
|
2065
|
-
},
|
|
2066
|
-
setLoadingState(loadingState) {
|
|
2067
|
-
this._update((draft) => {
|
|
2068
|
-
draft.loadingState = loadingState;
|
|
2069
|
-
});
|
|
1920
|
+
return this.components;
|
|
2070
1921
|
},
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
this._update((draft) => {
|
|
2075
|
-
draft.modals = [];
|
|
1922
|
+
close() {
|
|
1923
|
+
update(this, (draft) => {
|
|
1924
|
+
draft.open = false;
|
|
2076
1925
|
});
|
|
2077
1926
|
}
|
|
2078
1927
|
});
|
|
2079
|
-
return
|
|
1928
|
+
return modalContentComponent;
|
|
2080
1929
|
};
|
|
2081
1930
|
|
|
1931
|
+
// src/revamp/domain/components/utils/getRandomId.ts
|
|
1932
|
+
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
1933
|
+
|
|
1934
|
+
// src/revamp/domain/components/AlertComponent.ts
|
|
1935
|
+
var createAlertComponent = (alertProps) => __spreadValues({
|
|
1936
|
+
type: "alert"
|
|
1937
|
+
}, alertProps);
|
|
1938
|
+
|
|
2082
1939
|
// src/revamp/domain/mappers/utils/behavior-utils.ts
|
|
2083
1940
|
var getDomainLayerBehavior = ({
|
|
2084
1941
|
action,
|
|
@@ -2118,73 +1975,6 @@ var getActionByReference = ($ref, actions = []) => {
|
|
|
2118
1975
|
return action;
|
|
2119
1976
|
};
|
|
2120
1977
|
|
|
2121
|
-
// src/revamp/domain/features/polling/getStepPolling.ts
|
|
2122
|
-
var getStepPolling = ({
|
|
2123
|
-
pollingConfig,
|
|
2124
|
-
onBehavior,
|
|
2125
|
-
onPoll
|
|
2126
|
-
}) => {
|
|
2127
|
-
const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
|
|
2128
|
-
let abortController = new AbortController();
|
|
2129
|
-
if (delay == null) {
|
|
2130
|
-
throw new Error("Polling configuration must include delay or interval");
|
|
2131
|
-
}
|
|
2132
|
-
const onErrorBehavior = skipValidation(getDomainLayerBehavior(onError, []));
|
|
2133
|
-
let attempts = 0;
|
|
2134
|
-
const poll = () => {
|
|
2135
|
-
attempts += 1;
|
|
2136
|
-
abortController.abort();
|
|
2137
|
-
abortController = new AbortController();
|
|
2138
|
-
const { signal } = abortController;
|
|
2139
|
-
onPoll(url, onErrorBehavior, signal).then((result) => {
|
|
2140
|
-
if (result) {
|
|
2141
|
-
stop();
|
|
2142
|
-
return;
|
|
2143
|
-
}
|
|
2144
|
-
if (attempts >= maxAttempts && !signal.aborted) {
|
|
2145
|
-
void onBehavior(onErrorBehavior);
|
|
2146
|
-
stop();
|
|
2147
|
-
}
|
|
2148
|
-
}).catch(() => {
|
|
2149
|
-
});
|
|
2150
|
-
};
|
|
2151
|
-
const intervalRef = setInterval(poll, delay * 1e3);
|
|
2152
|
-
const stop = () => {
|
|
2153
|
-
clearTimeout(intervalRef);
|
|
2154
|
-
abortController.abort();
|
|
2155
|
-
};
|
|
2156
|
-
poll();
|
|
2157
|
-
return { stop };
|
|
2158
|
-
};
|
|
2159
|
-
|
|
2160
|
-
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
2161
|
-
var ONE_SECOND = 1e3;
|
|
2162
|
-
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
2163
|
-
const targetTime = new Date(refreshAfter).getTime();
|
|
2164
|
-
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
2165
|
-
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
2166
|
-
}
|
|
2167
|
-
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
2168
|
-
const timeout = setTimeout(() => {
|
|
2169
|
-
void onRefresh("refreshAfter");
|
|
2170
|
-
}, timeLeft);
|
|
2171
|
-
return {
|
|
2172
|
-
stop: () => clearTimeout(timeout)
|
|
2173
|
-
};
|
|
2174
|
-
};
|
|
2175
|
-
|
|
2176
|
-
// src/revamp/domain/components/AlertComponent.ts
|
|
2177
|
-
var createAlertComponent = (alertProps) => __spreadProps(__spreadValues({
|
|
2178
|
-
type: "alert"
|
|
2179
|
-
}, alertProps), {
|
|
2180
|
-
getSubmittableValue: async () => null,
|
|
2181
|
-
getSubmittableValueSync: () => null,
|
|
2182
|
-
getLocalValue: () => null,
|
|
2183
|
-
getSummary: () => ({}),
|
|
2184
|
-
// Noop
|
|
2185
|
-
validate: () => true
|
|
2186
|
-
});
|
|
2187
|
-
|
|
2188
1978
|
// src/revamp/domain/mappers/utils/call-to-action-utils.ts
|
|
2189
1979
|
var getDomainLayerCallToAction = (callToAction, onBehavior, stepActions) => {
|
|
2190
1980
|
if (!callToAction) {
|
|
@@ -2291,56 +2081,30 @@ var alertLayoutToComponent = (uid, { control, markdown, margin = "md", context =
|
|
|
2291
2081
|
});
|
|
2292
2082
|
};
|
|
2293
2083
|
|
|
2294
|
-
// src/revamp/domain/features/validation/validation-functions.ts
|
|
2295
|
-
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
2296
|
-
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
2297
|
-
|
|
2298
2084
|
// src/revamp/domain/components/BoxComponent.ts
|
|
2299
2085
|
var createBoxComponent = (boxProps) => __spreadProps(__spreadValues({}, boxProps), {
|
|
2300
2086
|
type: "box",
|
|
2301
2087
|
getChildren() {
|
|
2302
2088
|
return this.components;
|
|
2303
|
-
},
|
|
2304
|
-
async getSubmittableValue() {
|
|
2305
|
-
return getSubmittableData(this.components);
|
|
2306
|
-
},
|
|
2307
|
-
getSubmittableValueSync() {
|
|
2308
|
-
return getSubmittableDataSync(this.components);
|
|
2309
|
-
},
|
|
2310
|
-
getSummary() {
|
|
2311
|
-
return summariseFromChildren(this.getChildren());
|
|
2312
|
-
},
|
|
2313
|
-
getLocalValue() {
|
|
2314
|
-
return getLocalValues(this.components);
|
|
2315
|
-
},
|
|
2316
|
-
validate() {
|
|
2317
|
-
return validateComponents(this.getChildren());
|
|
2318
2089
|
}
|
|
2319
2090
|
});
|
|
2320
2091
|
|
|
2321
2092
|
// src/revamp/domain/mappers/layout/boxLayoutToComponents.ts
|
|
2322
|
-
var boxLayoutToComponent = (uid, { border = false, components, control, margin = "md", width = "xl" }, mapperProps,
|
|
2093
|
+
var boxLayoutToComponent = (uid, { border = false, components, control, margin = "md", width = "xl" }, mapperProps, schemaComponents) => createBoxComponent({
|
|
2323
2094
|
uid,
|
|
2324
2095
|
border,
|
|
2325
2096
|
control,
|
|
2326
2097
|
margin,
|
|
2327
2098
|
width,
|
|
2328
2099
|
components: components.map(
|
|
2329
|
-
(component, index) => mapLayoutToComponent(`${uid}.box-${index}`, component, mapperProps,
|
|
2100
|
+
(component, index) => mapLayoutToComponent(`${uid}.box-${index}`, component, mapperProps, schemaComponents)
|
|
2330
2101
|
)
|
|
2331
2102
|
});
|
|
2332
2103
|
|
|
2333
2104
|
// src/revamp/domain/components/ButtonComponent.ts
|
|
2334
|
-
var createButtonComponent = (buttonProps) =>
|
|
2105
|
+
var createButtonComponent = (buttonProps) => __spreadValues({
|
|
2335
2106
|
type: "button"
|
|
2336
|
-
}, buttonProps)
|
|
2337
|
-
getSubmittableValue: async () => null,
|
|
2338
|
-
getSubmittableValueSync: () => null,
|
|
2339
|
-
getLocalValue: () => null,
|
|
2340
|
-
getSummary: () => ({}),
|
|
2341
|
-
// Noop
|
|
2342
|
-
validate: () => true
|
|
2343
|
-
});
|
|
2107
|
+
}, buttonProps);
|
|
2344
2108
|
|
|
2345
2109
|
// src/revamp/domain/mappers/layout/buttonLayoutToComponent.ts
|
|
2346
2110
|
var buttonLayoutToComponent = (uid, button, mapperProps) => {
|
|
@@ -2422,26 +2186,11 @@ var createColumnsComponent = (columnsProps) => __spreadProps(__spreadValues({},
|
|
|
2422
2186
|
type: "columns",
|
|
2423
2187
|
getChildren() {
|
|
2424
2188
|
return [...this.startComponents, ...this.endComponents];
|
|
2425
|
-
},
|
|
2426
|
-
async getSubmittableValue() {
|
|
2427
|
-
return getSubmittableData(this.getChildren());
|
|
2428
|
-
},
|
|
2429
|
-
getSubmittableValueSync() {
|
|
2430
|
-
return getSubmittableDataSync(this.getChildren());
|
|
2431
|
-
},
|
|
2432
|
-
getSummary() {
|
|
2433
|
-
return summariseFromChildren(this.getChildren());
|
|
2434
|
-
},
|
|
2435
|
-
getLocalValue() {
|
|
2436
|
-
return getLocalValues(this.getChildren());
|
|
2437
|
-
},
|
|
2438
|
-
validate() {
|
|
2439
|
-
return validateComponents(this.getChildren());
|
|
2440
2189
|
}
|
|
2441
2190
|
});
|
|
2442
2191
|
|
|
2443
2192
|
// src/revamp/domain/mappers/layout/columnsLayoutToComponent.ts
|
|
2444
|
-
var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", margin = "md" }, mapperProps,
|
|
2193
|
+
var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", margin = "md" }, mapperProps, schemaComponents) => createColumnsComponent({
|
|
2445
2194
|
uid,
|
|
2446
2195
|
control,
|
|
2447
2196
|
margin,
|
|
@@ -2451,25 +2200,18 @@ var columnsLayoutToComponent = (uid, { control, left, right, bias = "none", marg
|
|
|
2451
2200
|
`${uid}.columns-start-${index}`,
|
|
2452
2201
|
component,
|
|
2453
2202
|
mapperProps,
|
|
2454
|
-
|
|
2203
|
+
schemaComponents
|
|
2455
2204
|
)
|
|
2456
2205
|
),
|
|
2457
2206
|
endComponents: right.map(
|
|
2458
|
-
(component, index) => mapLayoutToComponent(`${uid}.columns-end-${index}`, component, mapperProps,
|
|
2207
|
+
(component, index) => mapLayoutToComponent(`${uid}.columns-end-${index}`, component, mapperProps, schemaComponents)
|
|
2459
2208
|
)
|
|
2460
2209
|
});
|
|
2461
2210
|
|
|
2462
2211
|
// src/revamp/domain/components/DecisionComponent.ts
|
|
2463
|
-
var createDecisionComponent = (decisionProps) =>
|
|
2212
|
+
var createDecisionComponent = (decisionProps) => __spreadValues({
|
|
2464
2213
|
type: "decision"
|
|
2465
|
-
}, decisionProps)
|
|
2466
|
-
getSubmittableValue: async () => null,
|
|
2467
|
-
getSubmittableValueSync: () => null,
|
|
2468
|
-
getLocalValue: () => null,
|
|
2469
|
-
getSummary: () => ({}),
|
|
2470
|
-
// Noop
|
|
2471
|
-
validate: () => true
|
|
2472
|
-
});
|
|
2214
|
+
}, decisionProps);
|
|
2473
2215
|
|
|
2474
2216
|
// src/revamp/domain/mappers/utils/utils.ts
|
|
2475
2217
|
var mapInlineAlert = (alert) => {
|
|
@@ -2526,16 +2268,9 @@ var mapOption = (option, onBehavior, stepActions = []) => {
|
|
|
2526
2268
|
};
|
|
2527
2269
|
|
|
2528
2270
|
// src/revamp/domain/components/StatusListComponent.ts
|
|
2529
|
-
var createStatusListComponent = (statusListProps) =>
|
|
2271
|
+
var createStatusListComponent = (statusListProps) => __spreadValues({
|
|
2530
2272
|
type: "status-list"
|
|
2531
|
-
}, statusListProps)
|
|
2532
|
-
getLocalValue: () => null,
|
|
2533
|
-
getSubmittableValue: async () => null,
|
|
2534
|
-
getSubmittableValueSync: () => null,
|
|
2535
|
-
getSummary: () => ({}),
|
|
2536
|
-
// Noop,
|
|
2537
|
-
validate: () => true
|
|
2538
|
-
});
|
|
2273
|
+
}, statusListProps);
|
|
2539
2274
|
|
|
2540
2275
|
// src/revamp/domain/mappers/layout/deprecatedListLayoutToComponent.ts
|
|
2541
2276
|
var isDeprecatedListLayout = (layout) => {
|
|
@@ -2570,16 +2305,9 @@ var mapLegacyStatus = (status) => {
|
|
|
2570
2305
|
};
|
|
2571
2306
|
|
|
2572
2307
|
// src/revamp/domain/components/DividerComponent.ts
|
|
2573
|
-
var createDividerComponent = (props) =>
|
|
2308
|
+
var createDividerComponent = (props) => __spreadValues({
|
|
2574
2309
|
type: "divider"
|
|
2575
|
-
}, props)
|
|
2576
|
-
getSubmittableValue: async () => null,
|
|
2577
|
-
getSubmittableValueSync: () => null,
|
|
2578
|
-
getLocalValue: () => null,
|
|
2579
|
-
getSummary: () => ({}),
|
|
2580
|
-
// Noop
|
|
2581
|
-
validate: () => true
|
|
2582
|
-
});
|
|
2310
|
+
}, props);
|
|
2583
2311
|
|
|
2584
2312
|
// src/revamp/domain/mappers/layout/dividerLayoutToComponent.ts
|
|
2585
2313
|
var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDividerComponent({ uid, control, margin });
|
|
@@ -2588,56 +2316,36 @@ var dividerLayoutToComponent = (uid, { control, margin = "md" }) => createDivide
|
|
|
2588
2316
|
var createFormComponent = (formProps) => __spreadProps(__spreadValues({}, formProps), {
|
|
2589
2317
|
type: "form",
|
|
2590
2318
|
getChildren() {
|
|
2591
|
-
return [this.
|
|
2592
|
-
},
|
|
2593
|
-
async getSubmittableValue() {
|
|
2594
|
-
return this.inputComponent.getSubmittableValue();
|
|
2595
|
-
},
|
|
2596
|
-
getSubmittableValueSync() {
|
|
2597
|
-
return this.inputComponent.getSubmittableValueSync();
|
|
2598
|
-
},
|
|
2599
|
-
getSummary() {
|
|
2600
|
-
return this.inputComponent.getSummary();
|
|
2601
|
-
},
|
|
2602
|
-
getLocalValue() {
|
|
2603
|
-
return this.inputComponent.getLocalValue();
|
|
2604
|
-
},
|
|
2605
|
-
validate() {
|
|
2606
|
-
return this.inputComponent.validate();
|
|
2319
|
+
return [this.schemaComponent];
|
|
2607
2320
|
}
|
|
2608
2321
|
});
|
|
2609
2322
|
|
|
2610
2323
|
// src/revamp/domain/mappers/layout/formLayoutToComponent.ts
|
|
2611
|
-
var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin = "md" },
|
|
2324
|
+
var formLayoutToComponent = (uid, { schemaId, schema: schemaRef, control, margin = "md" }, schemaComponents) => {
|
|
2612
2325
|
const id = schemaId != null ? schemaId : schemaRef == null ? void 0 : schemaRef.$ref;
|
|
2613
2326
|
if (id == null) {
|
|
2614
2327
|
throw new Error(
|
|
2615
2328
|
"FormLayouts must refer to a schema. Set the `schemaId` property to the intended schema."
|
|
2616
2329
|
);
|
|
2617
2330
|
}
|
|
2618
|
-
const
|
|
2619
|
-
if (!
|
|
2620
|
-
throw new Error(
|
|
2331
|
+
const schemaComponent = schemaComponents.find((component) => component.schemaId === id);
|
|
2332
|
+
if (!schemaComponent) {
|
|
2333
|
+
throw new Error(
|
|
2334
|
+
`FormLayout with schemaId ${id} not found in inputComponents. The schema is probably missing in the step.schemas array.`
|
|
2335
|
+
);
|
|
2621
2336
|
}
|
|
2622
2337
|
return createFormComponent({
|
|
2623
2338
|
uid,
|
|
2624
|
-
|
|
2339
|
+
schemaComponent,
|
|
2625
2340
|
control,
|
|
2626
2341
|
margin
|
|
2627
2342
|
});
|
|
2628
2343
|
};
|
|
2629
2344
|
|
|
2630
2345
|
// src/revamp/domain/components/HeadingComponent.ts
|
|
2631
|
-
var createHeadingComponent = (headingProps) =>
|
|
2346
|
+
var createHeadingComponent = (headingProps) => __spreadValues({
|
|
2632
2347
|
type: "heading"
|
|
2633
|
-
}, headingProps)
|
|
2634
|
-
getSubmittableValue: async () => null,
|
|
2635
|
-
getSubmittableValueSync: () => null,
|
|
2636
|
-
getSummary: () => ({}),
|
|
2637
|
-
// Noop
|
|
2638
|
-
getLocalValue: () => null,
|
|
2639
|
-
validate: () => true
|
|
2640
|
-
});
|
|
2348
|
+
}, headingProps);
|
|
2641
2349
|
|
|
2642
2350
|
// src/revamp/domain/mappers/layout/headingLayoutToComponent.ts
|
|
2643
2351
|
var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md", control, text }) => createHeadingComponent({
|
|
@@ -2650,16 +2358,9 @@ var headingLayoutToComponent = (uid, { align = "left", margin = "md", size = "md
|
|
|
2650
2358
|
});
|
|
2651
2359
|
|
|
2652
2360
|
// src/revamp/domain/components/ImageComponent.ts
|
|
2653
|
-
var createImageComponent = (imageProps) =>
|
|
2361
|
+
var createImageComponent = (imageProps) => __spreadValues({
|
|
2654
2362
|
type: "image"
|
|
2655
|
-
}, imageProps)
|
|
2656
|
-
getSubmittableValue: async () => null,
|
|
2657
|
-
getSubmittableValueSync: () => null,
|
|
2658
|
-
getLocalValue: () => null,
|
|
2659
|
-
getSummary: () => ({}),
|
|
2660
|
-
// Noop
|
|
2661
|
-
validate: () => true
|
|
2662
|
-
});
|
|
2363
|
+
}, imageProps);
|
|
2663
2364
|
|
|
2664
2365
|
// src/revamp/domain/mappers/layout/imageLayoutToComponent.ts
|
|
2665
2366
|
var imageLayoutToComponent = (uid, {
|
|
@@ -2687,15 +2388,9 @@ var imageLayoutToComponent = (uid, {
|
|
|
2687
2388
|
};
|
|
2688
2389
|
|
|
2689
2390
|
// src/revamp/domain/components/MarkdownComponent.ts
|
|
2690
|
-
var createMarkdownComponent = (markdownProps) =>
|
|
2391
|
+
var createMarkdownComponent = (markdownProps) => __spreadValues({
|
|
2691
2392
|
type: "markdown"
|
|
2692
|
-
}, markdownProps)
|
|
2693
|
-
getSubmittableValue: async () => null,
|
|
2694
|
-
getSubmittableValueSync: () => null,
|
|
2695
|
-
getLocalValue: () => null,
|
|
2696
|
-
getSummary: () => ({}),
|
|
2697
|
-
validate: () => true
|
|
2698
|
-
});
|
|
2393
|
+
}, markdownProps);
|
|
2699
2394
|
|
|
2700
2395
|
// src/revamp/domain/mappers/layout/infoLayoutToComponent.ts
|
|
2701
2396
|
var infoLayoutToComponent = (uid, { align = "left", control, margin = "md", markdown: content }) => createMarkdownComponent({
|
|
@@ -2707,16 +2402,9 @@ var infoLayoutToComponent = (uid, { align = "left", control, margin = "md", mark
|
|
|
2707
2402
|
});
|
|
2708
2403
|
|
|
2709
2404
|
// src/revamp/domain/components/InstructionsComponent.ts
|
|
2710
|
-
var createInstructionsComponent = (instructionsProps) =>
|
|
2405
|
+
var createInstructionsComponent = (instructionsProps) => __spreadValues({
|
|
2711
2406
|
type: "instructions"
|
|
2712
|
-
}, instructionsProps)
|
|
2713
|
-
getLocalValue: () => null,
|
|
2714
|
-
getSubmittableValue: async () => null,
|
|
2715
|
-
getSubmittableValueSync: () => null,
|
|
2716
|
-
getSummary: () => ({}),
|
|
2717
|
-
// Noop
|
|
2718
|
-
validate: () => true
|
|
2719
|
-
});
|
|
2407
|
+
}, instructionsProps);
|
|
2720
2408
|
|
|
2721
2409
|
// src/revamp/domain/mappers/layout/instructionsLayoutToComponent.ts
|
|
2722
2410
|
var instructionsLayoutToComponent = (uid, { control, items, margin = "md", title }) => createInstructionsComponent({
|
|
@@ -2730,16 +2418,9 @@ var instructionsLayoutToComponent = (uid, { control, items, margin = "md", title
|
|
|
2730
2418
|
});
|
|
2731
2419
|
|
|
2732
2420
|
// src/revamp/domain/components/ListComponent.ts
|
|
2733
|
-
var createListComponent = (listProps) =>
|
|
2421
|
+
var createListComponent = (listProps) => __spreadValues({
|
|
2734
2422
|
type: "list"
|
|
2735
|
-
}, listProps)
|
|
2736
|
-
getLocalValue: () => null,
|
|
2737
|
-
getSubmittableValue: async () => null,
|
|
2738
|
-
getSubmittableValueSync: () => null,
|
|
2739
|
-
getSummary: () => ({}),
|
|
2740
|
-
// noop
|
|
2741
|
-
validate: () => true
|
|
2742
|
-
});
|
|
2423
|
+
}, listProps);
|
|
2743
2424
|
|
|
2744
2425
|
// src/revamp/domain/mappers/layout/listLayoutToComponent.ts
|
|
2745
2426
|
var listLayoutToComponent = (uid, { callToAction, control, items, margin = "md", title }, mapperProps) => {
|
|
@@ -2774,16 +2455,9 @@ var mapSupportingValues = (item) => {
|
|
|
2774
2455
|
};
|
|
2775
2456
|
|
|
2776
2457
|
// src/revamp/domain/components/LoadingIndicatorComponent.ts
|
|
2777
|
-
var createLoadingIndicatorComponent = (loadingIndicatorProps) =>
|
|
2458
|
+
var createLoadingIndicatorComponent = (loadingIndicatorProps) => __spreadValues({
|
|
2778
2459
|
type: "loading-indicator"
|
|
2779
|
-
}, loadingIndicatorProps)
|
|
2780
|
-
getSubmittableValue: async () => null,
|
|
2781
|
-
getSubmittableValueSync: () => null,
|
|
2782
|
-
getLocalValue: () => null,
|
|
2783
|
-
getSummary: () => ({}),
|
|
2784
|
-
// Noop
|
|
2785
|
-
validate: () => true
|
|
2786
|
-
});
|
|
2460
|
+
}, loadingIndicatorProps);
|
|
2787
2461
|
|
|
2788
2462
|
// src/revamp/domain/mappers/layout/loadingIndicatorLayoutToComponent.ts
|
|
2789
2463
|
var loadingIndicatorLayoutToComponent = (uid, { size = "md", margin = "md", control }) => createLoadingIndicatorComponent({ uid, size, control, margin });
|
|
@@ -2803,32 +2477,17 @@ var createModalComponent = (modalProps) => __spreadProps(__spreadValues({
|
|
|
2803
2477
|
}, modalProps), {
|
|
2804
2478
|
getChildren() {
|
|
2805
2479
|
return this.content.components;
|
|
2806
|
-
},
|
|
2807
|
-
getLocalValue() {
|
|
2808
|
-
return getLocalValues(this.getChildren());
|
|
2809
|
-
},
|
|
2810
|
-
async getSubmittableValue() {
|
|
2811
|
-
return getSubmittableData(this.getChildren());
|
|
2812
|
-
},
|
|
2813
|
-
getSubmittableValueSync() {
|
|
2814
|
-
return getSubmittableDataSync(this.getChildren());
|
|
2815
|
-
},
|
|
2816
|
-
getSummary() {
|
|
2817
|
-
return summariseFromChildren(this.getChildren());
|
|
2818
|
-
},
|
|
2819
|
-
validate() {
|
|
2820
|
-
return validateComponents(this.getChildren());
|
|
2821
2480
|
}
|
|
2822
2481
|
});
|
|
2823
2482
|
|
|
2824
2483
|
// src/revamp/domain/mappers/layout/modalLayoutToComponent.ts
|
|
2825
|
-
var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger }, mapperProps,
|
|
2484
|
+
var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger }, mapperProps, schemaComponents) => {
|
|
2826
2485
|
const { components, title } = content;
|
|
2827
2486
|
return createModalComponent({
|
|
2828
2487
|
uid,
|
|
2829
2488
|
content: {
|
|
2830
2489
|
components: components.map(
|
|
2831
|
-
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps,
|
|
2490
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, schemaComponents)
|
|
2832
2491
|
),
|
|
2833
2492
|
title
|
|
2834
2493
|
},
|
|
@@ -2839,16 +2498,9 @@ var modalLayoutToComponent = (uid, { content, control, margin = "md", trigger },
|
|
|
2839
2498
|
};
|
|
2840
2499
|
|
|
2841
2500
|
// src/revamp/domain/components/ParagraphComponent.ts
|
|
2842
|
-
var createParagraphComponent = (paragraphProps) =>
|
|
2501
|
+
var createParagraphComponent = (paragraphProps) => __spreadValues({
|
|
2843
2502
|
type: "paragraph"
|
|
2844
|
-
}, paragraphProps)
|
|
2845
|
-
getSubmittableValue: async () => null,
|
|
2846
|
-
getSubmittableValueSync: () => null,
|
|
2847
|
-
getSummary: () => ({}),
|
|
2848
|
-
// Noop
|
|
2849
|
-
getLocalValue: () => null,
|
|
2850
|
-
validate: () => true
|
|
2851
|
-
});
|
|
2503
|
+
}, paragraphProps);
|
|
2852
2504
|
|
|
2853
2505
|
// src/revamp/domain/mappers/layout/paragraphLayoutToComponent.ts
|
|
2854
2506
|
var paragraphLayoutToComponent = (uid, { align = "left", control, margin = "md", text }) => createParagraphComponent({
|
|
@@ -2860,16 +2512,9 @@ var paragraphLayoutToComponent = (uid, { align = "left", control, margin = "md",
|
|
|
2860
2512
|
});
|
|
2861
2513
|
|
|
2862
2514
|
// src/revamp/domain/components/ReviewComponent.ts
|
|
2863
|
-
var createReviewComponent = (reviewProps) =>
|
|
2515
|
+
var createReviewComponent = (reviewProps) => __spreadValues({
|
|
2864
2516
|
type: "review"
|
|
2865
|
-
}, reviewProps)
|
|
2866
|
-
getLocalValue: () => null,
|
|
2867
|
-
getSubmittableValue: async () => null,
|
|
2868
|
-
getSubmittableValueSync: () => null,
|
|
2869
|
-
getSummary: () => ({}),
|
|
2870
|
-
// Noop
|
|
2871
|
-
validate: () => true
|
|
2872
|
-
});
|
|
2517
|
+
}, reviewProps);
|
|
2873
2518
|
|
|
2874
2519
|
// src/revamp/domain/mappers/layout/reviewLayoutToComponent.ts
|
|
2875
2520
|
var reviewLayoutToComponent = (uid, { fields, title, callToAction, control, margin = "md", orientation, action }, { onBehavior, step }) => createReviewComponent({
|
|
@@ -3009,12 +2654,6 @@ var createSearchComponent = (searchProps, performSearch, onBehavior, updateCompo
|
|
|
3009
2654
|
_update(updateFn) {
|
|
3010
2655
|
update(this, updateFn);
|
|
3011
2656
|
},
|
|
3012
|
-
getSubmittableValue: async () => null,
|
|
3013
|
-
getSubmittableValueSync: () => null,
|
|
3014
|
-
getLocalValue: () => null,
|
|
3015
|
-
getSummary: () => ({}),
|
|
3016
|
-
// Noop
|
|
3017
|
-
validate: () => true,
|
|
3018
2657
|
onChange(query) {
|
|
3019
2658
|
this._update((draft) => {
|
|
3020
2659
|
draft.query = query;
|
|
@@ -3077,104 +2716,286 @@ var parseResponse = async (response) => {
|
|
|
3077
2716
|
}
|
|
3078
2717
|
return body.results;
|
|
3079
2718
|
}
|
|
3080
|
-
}
|
|
3081
|
-
throw Error("error response");
|
|
3082
|
-
};
|
|
3083
|
-
var addQueryParameter = (url, key, value) => {
|
|
3084
|
-
const [urlBase, urlQuery] = url.split("?");
|
|
3085
|
-
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
3086
|
-
urlQueryParams.set(key, value);
|
|
3087
|
-
return `${urlBase}?${urlQueryParams.toString()}`;
|
|
2719
|
+
}
|
|
2720
|
+
throw Error("error response");
|
|
2721
|
+
};
|
|
2722
|
+
var addQueryParameter = (url, key, value) => {
|
|
2723
|
+
const [urlBase, urlQuery] = url.split("?");
|
|
2724
|
+
const urlQueryParams = new URLSearchParams(urlQuery);
|
|
2725
|
+
urlQueryParams.set(key, value);
|
|
2726
|
+
return `${urlBase}?${urlQueryParams.toString()}`;
|
|
2727
|
+
};
|
|
2728
|
+
var isValidResponseBody = (body) => isObject(body) && "results" in body && isArray(body.results) && body.results.every(
|
|
2729
|
+
(result) => isObject(result) && "title" in result && "type" in result && "value" in result
|
|
2730
|
+
);
|
|
2731
|
+
var hashRequest = (query, config) => JSON.stringify({ query, config });
|
|
2732
|
+
|
|
2733
|
+
// src/revamp/domain/mappers/layout/searchLayoutToComponent.ts
|
|
2734
|
+
var searchLayoutToComponent = (uid, { control, emptyMessage = "", method, param, title, url, margin = "md" }, mapperProps) => {
|
|
2735
|
+
const { httpClient, onBehavior, updateComponent } = mapperProps;
|
|
2736
|
+
const search = getPerformSearchFunction(httpClient, { method, param, url });
|
|
2737
|
+
return createSearchComponent(
|
|
2738
|
+
{
|
|
2739
|
+
uid,
|
|
2740
|
+
control,
|
|
2741
|
+
emptyMessage,
|
|
2742
|
+
margin,
|
|
2743
|
+
title
|
|
2744
|
+
},
|
|
2745
|
+
search,
|
|
2746
|
+
onBehavior,
|
|
2747
|
+
updateComponent
|
|
2748
|
+
);
|
|
2749
|
+
};
|
|
2750
|
+
|
|
2751
|
+
// src/revamp/domain/mappers/layout/statusListLayoutToComponent.ts
|
|
2752
|
+
var statusListLayoutToComponent = (uid, { control, items, margin = "md", title }, { onBehavior, step }) => createStatusListComponent({
|
|
2753
|
+
uid,
|
|
2754
|
+
control,
|
|
2755
|
+
items: items.map((item) => {
|
|
2756
|
+
var _a;
|
|
2757
|
+
const callToAction = getDomainLayerCallToAction(
|
|
2758
|
+
item.callToAction,
|
|
2759
|
+
onBehavior,
|
|
2760
|
+
(_a = step.actions) != null ? _a : []
|
|
2761
|
+
);
|
|
2762
|
+
return __spreadProps(__spreadValues({}, item), { callToAction });
|
|
2763
|
+
}),
|
|
2764
|
+
margin,
|
|
2765
|
+
title
|
|
2766
|
+
});
|
|
2767
|
+
|
|
2768
|
+
// src/revamp/domain/mappers/mapLayoutToComponent.ts
|
|
2769
|
+
var mapLayoutToComponent = (uid, layout, mapperProps, schemaComponents) => {
|
|
2770
|
+
switch (layout.type) {
|
|
2771
|
+
case "alert":
|
|
2772
|
+
return alertLayoutToComponent(uid, layout, mapperProps);
|
|
2773
|
+
case "box":
|
|
2774
|
+
return boxLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2775
|
+
case "button":
|
|
2776
|
+
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
2777
|
+
case "columns":
|
|
2778
|
+
return columnsLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2779
|
+
case "decision":
|
|
2780
|
+
return decisionLayoutToComponent(uid, layout, mapperProps);
|
|
2781
|
+
case "divider":
|
|
2782
|
+
return dividerLayoutToComponent(uid, layout);
|
|
2783
|
+
case "form":
|
|
2784
|
+
return formLayoutToComponent(uid, layout, schemaComponents);
|
|
2785
|
+
case "heading":
|
|
2786
|
+
return headingLayoutToComponent(uid, layout);
|
|
2787
|
+
case "image":
|
|
2788
|
+
return imageLayoutToComponent(uid, layout);
|
|
2789
|
+
case "info":
|
|
2790
|
+
return infoLayoutToComponent(uid, layout);
|
|
2791
|
+
case "instructions":
|
|
2792
|
+
return instructionsLayoutToComponent(uid, layout);
|
|
2793
|
+
case "list":
|
|
2794
|
+
return isDeprecatedListLayout(layout) ? deprecatedListLayoutToComponent(uid, layout) : listLayoutToComponent(uid, layout, mapperProps);
|
|
2795
|
+
case "loading-indicator":
|
|
2796
|
+
return loadingIndicatorLayoutToComponent(uid, layout);
|
|
2797
|
+
case "markdown":
|
|
2798
|
+
return markdownLayoutToComponent(uid, layout);
|
|
2799
|
+
case "modal":
|
|
2800
|
+
return modalLayoutToComponent(uid, layout, mapperProps, schemaComponents);
|
|
2801
|
+
case "paragraph":
|
|
2802
|
+
return paragraphLayoutToComponent(uid, layout);
|
|
2803
|
+
case "review":
|
|
2804
|
+
return reviewLayoutToComponent(uid, layout, mapperProps);
|
|
2805
|
+
case "search":
|
|
2806
|
+
return searchLayoutToComponent(uid, layout, mapperProps);
|
|
2807
|
+
case "status-list":
|
|
2808
|
+
return statusListLayoutToComponent(uid, layout, mapperProps);
|
|
2809
|
+
default:
|
|
2810
|
+
throw new Error(`Invalid layout type in ${JSON.stringify(layout)}`);
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
2815
|
+
var modalToContent = (uid, { content, title }, mapperProps, schemaComponents) => createModalContentComponent(
|
|
2816
|
+
{
|
|
2817
|
+
uid: `${uid}-modal-${getRandomId()}`,
|
|
2818
|
+
title,
|
|
2819
|
+
components: content.map(
|
|
2820
|
+
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, schemaComponents)
|
|
2821
|
+
)
|
|
2822
|
+
},
|
|
2823
|
+
mapperProps.updateComponent
|
|
2824
|
+
);
|
|
2825
|
+
|
|
2826
|
+
// src/revamp/domain/components/step/ExternalConfirmationComponent.ts
|
|
2827
|
+
var createExternalConfirmation = (uid, url, updateComponent) => {
|
|
2828
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2829
|
+
return {
|
|
2830
|
+
type: "external-confirmation",
|
|
2831
|
+
uid,
|
|
2832
|
+
url,
|
|
2833
|
+
status: "initial",
|
|
2834
|
+
onSuccess() {
|
|
2835
|
+
update(this, (draft) => {
|
|
2836
|
+
draft.status = "success";
|
|
2837
|
+
});
|
|
2838
|
+
},
|
|
2839
|
+
onFailure() {
|
|
2840
|
+
if (this.status === "initial") {
|
|
2841
|
+
update(this, (draft) => {
|
|
2842
|
+
draft.status = "failure";
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
},
|
|
2846
|
+
onCancel() {
|
|
2847
|
+
update(this, (draft) => {
|
|
2848
|
+
draft.status = "dismissed";
|
|
2849
|
+
});
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
};
|
|
2853
|
+
|
|
2854
|
+
// src/revamp/utils/component-utils.ts
|
|
2855
|
+
var getSubmittableData = async (components) => Promise.all(components.map(async (component) => component.getSubmittableValue())).then(
|
|
2856
|
+
(values) => values.reduce((acc, value) => mergeModels(acc, value), null)
|
|
2857
|
+
);
|
|
2858
|
+
var getSubmittableDataSync = (components) => components.map((component) => component.getSubmittableValueSync()).reduce((acc, value) => mergeModels(acc, value), null);
|
|
2859
|
+
var getLocalValues = (components) => components.map((component) => component.getLocalValue()).reduce((acc, value) => mergeLocalValues(acc, value), null);
|
|
2860
|
+
var mergeLocalValues = (valueA, valueB) => {
|
|
2861
|
+
if (valueA === null) {
|
|
2862
|
+
return valueB;
|
|
2863
|
+
}
|
|
2864
|
+
if (valueB === null) {
|
|
2865
|
+
return valueA;
|
|
2866
|
+
}
|
|
2867
|
+
if (isObjectLocalValue(valueA) && isObjectLocalValue(valueB)) {
|
|
2868
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
2869
|
+
}
|
|
2870
|
+
return valueB;
|
|
2871
|
+
};
|
|
2872
|
+
var mergeModels = (valueA, valueB) => {
|
|
2873
|
+
if (valueA === null) {
|
|
2874
|
+
return valueB;
|
|
2875
|
+
}
|
|
2876
|
+
if (valueB === null) {
|
|
2877
|
+
return valueA;
|
|
2878
|
+
}
|
|
2879
|
+
if (isObjectModel(valueA) && isObjectModel(valueB)) {
|
|
2880
|
+
return __spreadValues(__spreadValues({}, valueA), valueB);
|
|
2881
|
+
}
|
|
2882
|
+
return valueB;
|
|
2883
|
+
};
|
|
2884
|
+
|
|
2885
|
+
// src/revamp/domain/components/step/StepDomainComponent.ts
|
|
2886
|
+
var createStepComponent = (stepProps) => {
|
|
2887
|
+
const _a = stepProps, { uid, stepPolling, stepRefreshAfter, updateComponent } = _a, rest = __objRest(_a, ["uid", "stepPolling", "stepRefreshAfter", "updateComponent"]);
|
|
2888
|
+
const update = getInputUpdateFunction(updateComponent);
|
|
2889
|
+
const component = __spreadProps(__spreadValues({
|
|
2890
|
+
uid
|
|
2891
|
+
}, rest), {
|
|
2892
|
+
type: "step",
|
|
2893
|
+
modals: [],
|
|
2894
|
+
dismissModal() {
|
|
2895
|
+
var _a2;
|
|
2896
|
+
(_a2 = this.modals.at(-1)) == null ? void 0 : _a2.close();
|
|
2897
|
+
},
|
|
2898
|
+
dismissAllModals() {
|
|
2899
|
+
this._update((draft) => {
|
|
2900
|
+
draft.modals = draft.modals.map((m) => __spreadProps(__spreadValues({}, m), { open: false }));
|
|
2901
|
+
});
|
|
2902
|
+
},
|
|
2903
|
+
showModal(modal) {
|
|
2904
|
+
this._update((draft) => {
|
|
2905
|
+
draft.modals = [...draft.modals, modal];
|
|
2906
|
+
});
|
|
2907
|
+
},
|
|
2908
|
+
_update(updateFn) {
|
|
2909
|
+
update(this, updateFn);
|
|
2910
|
+
},
|
|
2911
|
+
getChildren() {
|
|
2912
|
+
return this.externalConfirmation ? [...this.layoutComponents, this.externalConfirmation] : this.layoutComponents;
|
|
2913
|
+
},
|
|
2914
|
+
getModals() {
|
|
2915
|
+
return this.modals;
|
|
2916
|
+
},
|
|
2917
|
+
async getSubmittableValue() {
|
|
2918
|
+
return getSubmittableData(this.schemaComponents);
|
|
2919
|
+
},
|
|
2920
|
+
getLocalValue() {
|
|
2921
|
+
return getLocalValues(this.schemaComponents);
|
|
2922
|
+
},
|
|
2923
|
+
validate() {
|
|
2924
|
+
return this.schemaComponents.every(
|
|
2925
|
+
(inputComponent) => inputComponent.isSchemaReferencedInStep ? inputComponent.validate() : true
|
|
2926
|
+
);
|
|
2927
|
+
},
|
|
2928
|
+
setLoadingState(loadingState) {
|
|
2929
|
+
this._update((draft) => {
|
|
2930
|
+
draft.loadingState = loadingState;
|
|
2931
|
+
});
|
|
2932
|
+
},
|
|
2933
|
+
stop() {
|
|
2934
|
+
stepPolling == null ? void 0 : stepPolling.stop();
|
|
2935
|
+
stepRefreshAfter == null ? void 0 : stepRefreshAfter.stop();
|
|
2936
|
+
this._update((draft) => {
|
|
2937
|
+
draft.modals = [];
|
|
2938
|
+
});
|
|
2939
|
+
}
|
|
2940
|
+
});
|
|
2941
|
+
return component;
|
|
3088
2942
|
};
|
|
3089
|
-
var isValidResponseBody = (body) => isObject(body) && "results" in body && isArray(body.results) && body.results.every(
|
|
3090
|
-
(result) => isObject(result) && "title" in result && "type" in result && "value" in result
|
|
3091
|
-
);
|
|
3092
|
-
var hashRequest = (query, config) => JSON.stringify({ query, config });
|
|
3093
2943
|
|
|
3094
|
-
// src/revamp/domain/
|
|
3095
|
-
var
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
2944
|
+
// src/revamp/domain/features/polling/getStepPolling.ts
|
|
2945
|
+
var getStepPolling = ({
|
|
2946
|
+
pollingConfig,
|
|
2947
|
+
onBehavior,
|
|
2948
|
+
onPoll
|
|
2949
|
+
}) => {
|
|
2950
|
+
const { interval, delay = interval, maxAttempts, url, onError } = pollingConfig;
|
|
2951
|
+
let abortController = new AbortController();
|
|
2952
|
+
if (delay == null) {
|
|
2953
|
+
throw new Error("Polling configuration must include delay or interval");
|
|
2954
|
+
}
|
|
2955
|
+
const onErrorBehavior = skipValidation(getDomainLayerBehavior(onError, []));
|
|
2956
|
+
let attempts = 0;
|
|
2957
|
+
const poll = () => {
|
|
2958
|
+
attempts += 1;
|
|
2959
|
+
abortController.abort();
|
|
2960
|
+
abortController = new AbortController();
|
|
2961
|
+
const { signal } = abortController;
|
|
2962
|
+
onPoll(url, onErrorBehavior, signal).then((result) => {
|
|
2963
|
+
if (result) {
|
|
2964
|
+
stop();
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
if (attempts >= maxAttempts && !signal.aborted) {
|
|
2968
|
+
void onBehavior(onErrorBehavior);
|
|
2969
|
+
stop();
|
|
2970
|
+
}
|
|
2971
|
+
}).catch(() => {
|
|
2972
|
+
});
|
|
2973
|
+
};
|
|
2974
|
+
const intervalRef = setInterval(poll, delay * 1e3);
|
|
2975
|
+
const stop = () => {
|
|
2976
|
+
clearTimeout(intervalRef);
|
|
2977
|
+
abortController.abort();
|
|
2978
|
+
};
|
|
2979
|
+
poll();
|
|
2980
|
+
return { stop };
|
|
3110
2981
|
};
|
|
3111
2982
|
|
|
3112
|
-
// src/revamp/domain/
|
|
3113
|
-
var
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
const callToAction = getDomainLayerCallToAction(
|
|
3119
|
-
item.callToAction,
|
|
3120
|
-
onBehavior,
|
|
3121
|
-
(_a = step.actions) != null ? _a : []
|
|
3122
|
-
);
|
|
3123
|
-
return __spreadProps(__spreadValues({}, item), { callToAction });
|
|
3124
|
-
}),
|
|
3125
|
-
margin,
|
|
3126
|
-
title
|
|
3127
|
-
});
|
|
3128
|
-
|
|
3129
|
-
// src/revamp/domain/mappers/mapLayoutToComponent.ts
|
|
3130
|
-
var mapLayoutToComponent = (uid, layout, mapperProps, inputComponents) => {
|
|
3131
|
-
switch (layout.type) {
|
|
3132
|
-
case "alert":
|
|
3133
|
-
return alertLayoutToComponent(uid, layout, mapperProps);
|
|
3134
|
-
case "box":
|
|
3135
|
-
return boxLayoutToComponent(uid, layout, mapperProps, inputComponents);
|
|
3136
|
-
case "button":
|
|
3137
|
-
return buttonLayoutToComponent(uid, layout, mapperProps);
|
|
3138
|
-
case "columns":
|
|
3139
|
-
return columnsLayoutToComponent(uid, layout, mapperProps, inputComponents);
|
|
3140
|
-
case "decision":
|
|
3141
|
-
return decisionLayoutToComponent(uid, layout, mapperProps);
|
|
3142
|
-
case "divider":
|
|
3143
|
-
return dividerLayoutToComponent(uid, layout);
|
|
3144
|
-
case "form":
|
|
3145
|
-
return formLayoutToComponent(uid, layout, inputComponents);
|
|
3146
|
-
case "heading":
|
|
3147
|
-
return headingLayoutToComponent(uid, layout);
|
|
3148
|
-
case "image":
|
|
3149
|
-
return imageLayoutToComponent(uid, layout);
|
|
3150
|
-
case "info":
|
|
3151
|
-
return infoLayoutToComponent(uid, layout);
|
|
3152
|
-
case "instructions":
|
|
3153
|
-
return instructionsLayoutToComponent(uid, layout);
|
|
3154
|
-
case "list":
|
|
3155
|
-
return isDeprecatedListLayout(layout) ? deprecatedListLayoutToComponent(uid, layout) : listLayoutToComponent(uid, layout, mapperProps);
|
|
3156
|
-
case "loading-indicator":
|
|
3157
|
-
return loadingIndicatorLayoutToComponent(uid, layout);
|
|
3158
|
-
case "markdown":
|
|
3159
|
-
return markdownLayoutToComponent(uid, layout);
|
|
3160
|
-
case "modal":
|
|
3161
|
-
return modalLayoutToComponent(uid, layout, mapperProps, inputComponents);
|
|
3162
|
-
case "paragraph":
|
|
3163
|
-
return paragraphLayoutToComponent(uid, layout);
|
|
3164
|
-
case "review":
|
|
3165
|
-
return reviewLayoutToComponent(uid, layout, mapperProps);
|
|
3166
|
-
case "search":
|
|
3167
|
-
return searchLayoutToComponent(uid, layout, mapperProps);
|
|
3168
|
-
case "status-list":
|
|
3169
|
-
return statusListLayoutToComponent(uid, layout, mapperProps);
|
|
3170
|
-
default:
|
|
3171
|
-
throw new Error(`Invalid layout type in ${JSON.stringify(layout)}`);
|
|
2983
|
+
// src/revamp/domain/features/refreshAfter/getStepRefreshAfter.ts
|
|
2984
|
+
var ONE_SECOND = 1e3;
|
|
2985
|
+
var getStepRefreshAfter = ({ refreshAfter, onRefresh }) => {
|
|
2986
|
+
const targetTime = new Date(refreshAfter).getTime();
|
|
2987
|
+
if (typeof refreshAfter !== "string" || Number.isNaN(targetTime)) {
|
|
2988
|
+
throw new Error(`Invalid refreshAfter value: ${String(refreshAfter)}`);
|
|
3172
2989
|
}
|
|
2990
|
+
const timeLeft = Math.max(targetTime - Date.now(), ONE_SECOND);
|
|
2991
|
+
const timeout = setTimeout(() => {
|
|
2992
|
+
void onRefresh("refreshAfter");
|
|
2993
|
+
}, timeLeft);
|
|
2994
|
+
return {
|
|
2995
|
+
stop: () => clearTimeout(timeout)
|
|
2996
|
+
};
|
|
3173
2997
|
};
|
|
3174
2998
|
|
|
3175
|
-
// src/revamp/domain/components/utils/getRandomId.ts
|
|
3176
|
-
var getRandomId = () => Math.random().toString(36).substring(2);
|
|
3177
|
-
|
|
3178
2999
|
// src/revamp/domain/components/utils/isExactLocalValueMatch.ts
|
|
3179
3000
|
var isExactLocalValueMatch = (valueA, valueB) => {
|
|
3180
3001
|
if (isArrayLocalValue(valueA) && isArrayLocalValue(valueB)) {
|
|
@@ -3344,6 +3165,10 @@ var getDebouncedPerformRefresh = (performRefresh, getValidationErrors) => {
|
|
|
3344
3165
|
return debouncedFn;
|
|
3345
3166
|
};
|
|
3346
3167
|
|
|
3168
|
+
// src/revamp/domain/features/validation/validation-functions.ts
|
|
3169
|
+
var validateComponents = (components) => components.reduce((acc, component) => component.validate() && acc, true);
|
|
3170
|
+
var getLocalValueValidator = (checks) => (currentValue) => checks.map((check) => check(currentValue)).filter(isString);
|
|
3171
|
+
|
|
3347
3172
|
// src/revamp/domain/features/validationAsync/getComponentValidationAsync.ts
|
|
3348
3173
|
var getComponentValidationAsync = (update, performValidationAsync) => (
|
|
3349
3174
|
/**
|
|
@@ -3844,6 +3669,42 @@ var getPerformPersisAsyncFn = (schemaMapperProps, mapperProps) => {
|
|
|
3844
3669
|
};
|
|
3845
3670
|
var schemaHasValidationMessages = (schema) => Boolean("validationMessages" in schema && schema.validationMessages);
|
|
3846
3671
|
|
|
3672
|
+
// src/revamp/domain/features/summary/summary-utils.ts
|
|
3673
|
+
var getSummariser = (schema) => (value) => {
|
|
3674
|
+
const { summary, icon, image } = schema;
|
|
3675
|
+
const stringValueOrNull = isString(value) ? value : null;
|
|
3676
|
+
return summaryIfProvides(summary, { value: stringValueOrNull, icon, image });
|
|
3677
|
+
};
|
|
3678
|
+
var getConstSummary = (schema, model) => {
|
|
3679
|
+
const { summary, icon, image } = schema;
|
|
3680
|
+
const value = isString(model) ? model : null;
|
|
3681
|
+
return summaryIfProvides(summary, { value, icon, image });
|
|
3682
|
+
};
|
|
3683
|
+
var summariseFromChildren = (components) => components.reduce(
|
|
3684
|
+
(acc, component) => mergeSummaries(acc, component.getSummary()),
|
|
3685
|
+
{}
|
|
3686
|
+
);
|
|
3687
|
+
var mergeSummaries = (summaryA, summaryB) => {
|
|
3688
|
+
var _a, _b, _c, _d;
|
|
3689
|
+
return {
|
|
3690
|
+
title: (_a = summaryA.title) != null ? _a : summaryB.title,
|
|
3691
|
+
description: (_b = summaryA.description) != null ? _b : summaryB.description,
|
|
3692
|
+
icon: (_c = summaryA.icon) != null ? _c : summaryB.icon,
|
|
3693
|
+
image: (_d = summaryA.image) != null ? _d : summaryB.image
|
|
3694
|
+
};
|
|
3695
|
+
};
|
|
3696
|
+
var summaryIfProvides = (summary, { value, icon, image }) => {
|
|
3697
|
+
if (!summary) {
|
|
3698
|
+
return {};
|
|
3699
|
+
}
|
|
3700
|
+
return {
|
|
3701
|
+
title: summary.providesTitle && value || void 0,
|
|
3702
|
+
description: summary.providesDescription && value || void 0,
|
|
3703
|
+
icon: summary.providesIcon && icon || void 0,
|
|
3704
|
+
image: summary.providesImage && mapSpecImage(image != null ? image : void 0) || void 0
|
|
3705
|
+
};
|
|
3706
|
+
};
|
|
3707
|
+
|
|
3847
3708
|
// src/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.ts
|
|
3848
3709
|
var mapCommonSchemaProps = (schemaMapperProps) => {
|
|
3849
3710
|
var _a;
|
|
@@ -4481,7 +4342,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4481
4342
|
const children = options.map((option) => option.component);
|
|
4482
4343
|
const selectedIndices = getInitialModelIndices(initialValue, children);
|
|
4483
4344
|
const getValidationErrors = getLocalValueValidator(checks);
|
|
4484
|
-
const
|
|
4345
|
+
const component = __spreadProps(__spreadValues({
|
|
4485
4346
|
uid,
|
|
4486
4347
|
type: "multi-select",
|
|
4487
4348
|
children,
|
|
@@ -4541,13 +4402,13 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4541
4402
|
}
|
|
4542
4403
|
});
|
|
4543
4404
|
if (performRefresh) {
|
|
4544
|
-
return
|
|
4405
|
+
return component;
|
|
4545
4406
|
}
|
|
4546
4407
|
if (performValidationAsync) {
|
|
4547
4408
|
const validateAsync = getComponentValidationAsync(update, performValidationAsync);
|
|
4548
|
-
return __spreadProps(__spreadValues({},
|
|
4409
|
+
return __spreadProps(__spreadValues({}, component), {
|
|
4549
4410
|
onSelect(indices) {
|
|
4550
|
-
|
|
4411
|
+
component.onSelect.call(this, indices);
|
|
4551
4412
|
if (this.validate()) {
|
|
4552
4413
|
validateAsync(this, this.getLocalValue()).catch(() => {
|
|
4553
4414
|
});
|
|
@@ -4555,7 +4416,7 @@ var createMultiSelectComponent = (multiSelectProps, updateComponent) => {
|
|
|
4555
4416
|
}
|
|
4556
4417
|
});
|
|
4557
4418
|
}
|
|
4558
|
-
return
|
|
4419
|
+
return component;
|
|
4559
4420
|
};
|
|
4560
4421
|
var getInitialModelIndices = (model, options) => {
|
|
4561
4422
|
if (!isArray(model)) {
|
|
@@ -5004,6 +4865,7 @@ var createConstComponent = (hiddenProps) => {
|
|
|
5004
4865
|
uid,
|
|
5005
4866
|
schemaId,
|
|
5006
4867
|
analyticsId,
|
|
4868
|
+
hidden: true,
|
|
5007
4869
|
getLocalValue: () => value,
|
|
5008
4870
|
getSubmittableValue: async () => value,
|
|
5009
4871
|
getSubmittableValueSync: () => value,
|
|
@@ -5916,7 +5778,7 @@ var mapStepSchemas = (uid, step, stepLocalValue, mapperProps, referencedSchemaId
|
|
|
5916
5778
|
const isReferenced = (schemaId) => schemaId != null && referencedSchemaIds.includes(schemaId);
|
|
5917
5779
|
return step.schemas.map((schema, i) => {
|
|
5918
5780
|
var _a, _b;
|
|
5919
|
-
const
|
|
5781
|
+
const schemaComponent = mapSchemaToComponent(
|
|
5920
5782
|
{
|
|
5921
5783
|
uid: `${uid}.schemas-${i}.${schema.$id}`,
|
|
5922
5784
|
schemaId: schema.$id,
|
|
@@ -5928,7 +5790,9 @@ var mapStepSchemas = (uid, step, stepLocalValue, mapperProps, referencedSchemaId
|
|
|
5928
5790
|
},
|
|
5929
5791
|
mapperProps
|
|
5930
5792
|
);
|
|
5931
|
-
return __spreadProps(__spreadValues({},
|
|
5793
|
+
return __spreadProps(__spreadValues({}, schemaComponent), {
|
|
5794
|
+
isSchemaReferencedInStep: isReferenced(schema.$id)
|
|
5795
|
+
});
|
|
5932
5796
|
});
|
|
5933
5797
|
};
|
|
5934
5798
|
|
|
@@ -5986,7 +5850,7 @@ var mapStepToComponent = (_a) => {
|
|
|
5986
5850
|
const externalConfirmation = (external == null ? void 0 : external.url) ? createExternalConfirmation(`${uid}-external-confirmation`, external == null ? void 0 : external.url, updateComponent) : void 0;
|
|
5987
5851
|
const mapperProps = __spreadProps(__spreadValues({}, restProps), { trackEvent, onBehavior, onRefresh });
|
|
5988
5852
|
const referencedSchemaIds = getReferencedSchemaId(step);
|
|
5989
|
-
const
|
|
5853
|
+
const schemaComponents = mapStepSchemas(
|
|
5990
5854
|
uid,
|
|
5991
5855
|
step,
|
|
5992
5856
|
stepLocalValue,
|
|
@@ -5994,13 +5858,13 @@ var mapStepToComponent = (_a) => {
|
|
|
5994
5858
|
referencedSchemaIds
|
|
5995
5859
|
);
|
|
5996
5860
|
const layoutComponents = layout.map(
|
|
5997
|
-
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps,
|
|
5861
|
+
(layoutComponent, index) => mapLayoutToComponent(`${uid}.layout-${index}`, layoutComponent, mapperProps, schemaComponents)
|
|
5998
5862
|
);
|
|
5999
5863
|
const stepComponent = createStepComponent({
|
|
6000
5864
|
uid,
|
|
6001
5865
|
back,
|
|
6002
5866
|
layoutComponents,
|
|
6003
|
-
|
|
5867
|
+
schemaComponents,
|
|
6004
5868
|
control,
|
|
6005
5869
|
description,
|
|
6006
5870
|
error: errors == null ? void 0 : errors.error,
|
|
@@ -6441,6 +6305,34 @@ var formatDateOptions = {
|
|
|
6441
6305
|
dateStyle: "long"
|
|
6442
6306
|
};
|
|
6443
6307
|
|
|
6308
|
+
// src/revamp/utils/analyse-step.ts
|
|
6309
|
+
import { validateStep } from "@wise/dynamic-flow-types";
|
|
6310
|
+
var analyseStep = (step, logEvent) => {
|
|
6311
|
+
validateStepTypes(step, logEvent);
|
|
6312
|
+
warnWhenPollingWithSchemas(step, logEvent);
|
|
6313
|
+
};
|
|
6314
|
+
var warnWhenPollingWithSchemas = (step, logEvent) => {
|
|
6315
|
+
var _a;
|
|
6316
|
+
const hasPolling = step.polling != null;
|
|
6317
|
+
const hasSchemas = step.schemas != null && step.schemas.length > 0;
|
|
6318
|
+
if (hasPolling && hasSchemas) {
|
|
6319
|
+
logEvent("warning", "DynamicFlow Polling and Schema Warning.", {
|
|
6320
|
+
message: "The provided step is configured with polling and schemas. Actions triggered from a polling response will not contain the schema values in their payload.",
|
|
6321
|
+
stepId: (_a = step.id) != null ? _a : step.key
|
|
6322
|
+
});
|
|
6323
|
+
}
|
|
6324
|
+
};
|
|
6325
|
+
var validateStepTypes = (step, logEvent) => {
|
|
6326
|
+
var _a;
|
|
6327
|
+
const validationResult = validateStep(step);
|
|
6328
|
+
if (!validationResult.valid) {
|
|
6329
|
+
logEvent("info", "The provided step does not conform to the specification.", {
|
|
6330
|
+
stepId: (_a = step.id) != null ? _a : step.key,
|
|
6331
|
+
errors: validationResult.errors
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
};
|
|
6335
|
+
|
|
6444
6336
|
// src/revamp/utils/useStableCallback.tsx
|
|
6445
6337
|
import { useCallback, useLayoutEffect, useRef } from "react";
|
|
6446
6338
|
function useStableCallback(handler) {
|
|
@@ -6451,55 +6343,6 @@ function useStableCallback(handler) {
|
|
|
6451
6343
|
return useCallback((...args) => ref.current ? ref.current(...args) : null, []);
|
|
6452
6344
|
}
|
|
6453
6345
|
|
|
6454
|
-
// src/revamp/domain/components/ModalContentComponent.ts
|
|
6455
|
-
var createModalContentComponent = (modalProps, updateComponent) => {
|
|
6456
|
-
const update = getInputUpdateFunction(updateComponent);
|
|
6457
|
-
const modalContentComponent = __spreadProps(__spreadValues({
|
|
6458
|
-
type: "modal-content",
|
|
6459
|
-
open: true
|
|
6460
|
-
}, modalProps), {
|
|
6461
|
-
_update(updateFn) {
|
|
6462
|
-
update(this, updateFn);
|
|
6463
|
-
},
|
|
6464
|
-
getChildren() {
|
|
6465
|
-
return this.components;
|
|
6466
|
-
},
|
|
6467
|
-
getLocalValue() {
|
|
6468
|
-
return getLocalValues(this.getChildren());
|
|
6469
|
-
},
|
|
6470
|
-
async getSubmittableValue() {
|
|
6471
|
-
return getSubmittableData(this.getChildren());
|
|
6472
|
-
},
|
|
6473
|
-
getSubmittableValueSync() {
|
|
6474
|
-
return getSubmittableDataSync(this.getChildren());
|
|
6475
|
-
},
|
|
6476
|
-
getSummary() {
|
|
6477
|
-
return summariseFromChildren(this.getChildren());
|
|
6478
|
-
},
|
|
6479
|
-
validate() {
|
|
6480
|
-
return validateComponents(this.getChildren());
|
|
6481
|
-
},
|
|
6482
|
-
close() {
|
|
6483
|
-
update(this, (draft) => {
|
|
6484
|
-
draft.open = false;
|
|
6485
|
-
});
|
|
6486
|
-
}
|
|
6487
|
-
});
|
|
6488
|
-
return modalContentComponent;
|
|
6489
|
-
};
|
|
6490
|
-
|
|
6491
|
-
// src/revamp/domain/mappers/layout/modalToContent.ts
|
|
6492
|
-
var modalToContent = (uid, { content, title }, mapperProps, inputComponents) => createModalContentComponent(
|
|
6493
|
-
{
|
|
6494
|
-
uid: `${uid}-modal-${getRandomId()}`,
|
|
6495
|
-
title,
|
|
6496
|
-
components: content.map(
|
|
6497
|
-
(component, index) => mapLayoutToComponent(`${uid}.modal-${index}`, component, mapperProps, inputComponents)
|
|
6498
|
-
)
|
|
6499
|
-
},
|
|
6500
|
-
mapperProps.updateComponent
|
|
6501
|
-
);
|
|
6502
|
-
|
|
6503
6346
|
// src/revamp/useDynamicFlowCore.tsx
|
|
6504
6347
|
function useDynamicFlowCore(props) {
|
|
6505
6348
|
const _a = props, { flowId, initialAction, initialStep, displayStepTitle = true } = _a, rest = __objRest(_a, ["flowId", "initialAction", "initialStep", "displayStepTitle"]);
|
|
@@ -6568,12 +6411,7 @@ function useDynamicFlowCore(props) {
|
|
|
6568
6411
|
rootComponentRef.current.stop();
|
|
6569
6412
|
stepRef.current = newStep;
|
|
6570
6413
|
etagRef.current = etag;
|
|
6571
|
-
|
|
6572
|
-
if (!validationResult.valid) {
|
|
6573
|
-
logEvent("info", "The provided step does not conform to the specification.", {
|
|
6574
|
-
errors: validationResult.errors
|
|
6575
|
-
});
|
|
6576
|
-
}
|
|
6414
|
+
analyseStep(newStep, logEvent);
|
|
6577
6415
|
try {
|
|
6578
6416
|
const newStepComponent = mapStepToComponent(__spreadValues({
|
|
6579
6417
|
stepLocalValue: localValue,
|
|
@@ -6661,7 +6499,7 @@ function useDynamicFlowCore(props) {
|
|
|
6661
6499
|
step: stepRef.current,
|
|
6662
6500
|
stepLocalValue: rootComponentRef.current.getLocalValue()
|
|
6663
6501
|
}, getMapperProps()),
|
|
6664
|
-
rootComponentRef.current.
|
|
6502
|
+
rootComponentRef.current.getSchemaComponents()
|
|
6665
6503
|
)
|
|
6666
6504
|
);
|
|
6667
6505
|
}
|