@wise/dynamic-flow-client 2.2.0 → 2.2.2
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 +595 -599
- package/build/main.min.js +1 -1
- package/build/types/layout/form/DynamicForm.d.ts +1 -1
- package/package.json +14 -14
package/build/main.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
8
25
|
var __commonJS = (cb, mod) => function __require() {
|
|
9
26
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
27
|
};
|
|
@@ -598,7 +615,7 @@ function convertFinalStepToDynamicLayout(step) {
|
|
|
598
615
|
}
|
|
599
616
|
if (step.actions) {
|
|
600
617
|
const actions = step.actions.map(
|
|
601
|
-
(action) => convertStepActionToDynamicAction({
|
|
618
|
+
(action) => convertStepActionToDynamicAction(__spreadProps(__spreadValues({}, action), { type: action.type || "primary" }))
|
|
602
619
|
);
|
|
603
620
|
layout.push(dynamicBox(actions, "md"));
|
|
604
621
|
}
|
|
@@ -674,7 +691,7 @@ function convertFinalStepImageToDynamicImage(image) {
|
|
|
674
691
|
} : convertStepImageToDynamicImage(image);
|
|
675
692
|
}
|
|
676
693
|
function convertStepActionToDynamicAction(action) {
|
|
677
|
-
const newAction = {
|
|
694
|
+
const newAction = __spreadProps(__spreadValues({}, action), { title: action.title });
|
|
678
695
|
return {
|
|
679
696
|
type: "button",
|
|
680
697
|
action: newAction
|
|
@@ -768,7 +785,7 @@ function inlineFormSchema({
|
|
|
768
785
|
};
|
|
769
786
|
}
|
|
770
787
|
if (formComponent.schema && !isReference(formComponent.schema)) {
|
|
771
|
-
return {
|
|
788
|
+
return __spreadValues({}, formComponent);
|
|
772
789
|
}
|
|
773
790
|
throw new Error('Invalid form layout component. Missing "schema" or "schemaId" properties.');
|
|
774
791
|
}
|
|
@@ -776,22 +793,22 @@ function inlineDecisionActions({
|
|
|
776
793
|
decisionComponent,
|
|
777
794
|
actions
|
|
778
795
|
}) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
796
|
+
var _a;
|
|
797
|
+
const newOptions = (_a = decisionComponent == null ? void 0 : decisionComponent.options) == null ? void 0 : _a.map((option) => {
|
|
798
|
+
return option.action && isReference(option.action) ? __spreadProps(__spreadValues({}, option), {
|
|
782
799
|
action: getActionById(actions, option.action.$ref)
|
|
783
|
-
} : option;
|
|
800
|
+
}) : option;
|
|
784
801
|
});
|
|
785
|
-
return {
|
|
786
|
-
...decisionComponent,
|
|
802
|
+
return __spreadProps(__spreadValues({}, decisionComponent), {
|
|
787
803
|
options: newOptions
|
|
788
|
-
};
|
|
804
|
+
});
|
|
789
805
|
}
|
|
790
806
|
function inlineAction({
|
|
791
807
|
actionComponent,
|
|
792
808
|
actions
|
|
793
809
|
}) {
|
|
794
|
-
|
|
810
|
+
var _a;
|
|
811
|
+
if (actionComponent.action && isReference(actionComponent.action) && ((_a = actionComponent.action) == null ? void 0 : _a.$ref)) {
|
|
795
812
|
const newAction = getActionById(actions, actionComponent.action.$ref);
|
|
796
813
|
return convertStepActionToDynamicAction(newAction);
|
|
797
814
|
}
|
|
@@ -803,10 +820,9 @@ function inlineBoxReferences({
|
|
|
803
820
|
actions,
|
|
804
821
|
model
|
|
805
822
|
}) {
|
|
806
|
-
return {
|
|
807
|
-
...boxComponent,
|
|
823
|
+
return __spreadProps(__spreadValues({}, boxComponent), {
|
|
808
824
|
components: inlineReferences({ layout: boxComponent.components, schemas, actions, model })
|
|
809
|
-
};
|
|
825
|
+
});
|
|
810
826
|
}
|
|
811
827
|
function inlineColumnsReferences({
|
|
812
828
|
columnsComponent,
|
|
@@ -814,11 +830,10 @@ function inlineColumnsReferences({
|
|
|
814
830
|
actions,
|
|
815
831
|
model
|
|
816
832
|
}) {
|
|
817
|
-
return {
|
|
818
|
-
...columnsComponent,
|
|
833
|
+
return __spreadProps(__spreadValues({}, columnsComponent), {
|
|
819
834
|
left: inlineReferences({ layout: columnsComponent.left, schemas, actions, model }),
|
|
820
835
|
right: inlineReferences({ layout: columnsComponent.right, schemas, actions, model })
|
|
821
|
-
};
|
|
836
|
+
});
|
|
822
837
|
}
|
|
823
838
|
function getSchemaById(schemas, id) {
|
|
824
839
|
const schema = schemas.find((schema2) => schema2.$id === id);
|
|
@@ -905,8 +920,8 @@ function useEventDispatcher() {
|
|
|
905
920
|
}
|
|
906
921
|
var getEventDispatcher = (onEvent, metadata) => (eventName, properties = {}) => {
|
|
907
922
|
try {
|
|
908
|
-
onEvent(eventName, {
|
|
909
|
-
} catch {
|
|
923
|
+
onEvent(eventName, __spreadValues(__spreadValues({}, metadata), properties));
|
|
924
|
+
} catch (e) {
|
|
910
925
|
}
|
|
911
926
|
};
|
|
912
927
|
|
|
@@ -929,8 +944,8 @@ function isRelativePath(url = "") {
|
|
|
929
944
|
// src/common/makeHttpClient/makeHttpClient.ts
|
|
930
945
|
var makeHttpClient = (baseUrl, additionalHeaders) => (input, init) => {
|
|
931
946
|
const resource = applyBaseUrl(input, baseUrl || "");
|
|
932
|
-
const headers2 = mergeHeaders(init
|
|
933
|
-
return fetch(resource, {
|
|
947
|
+
const headers2 = mergeHeaders(init == null ? void 0 : init.headers, additionalHeaders);
|
|
948
|
+
return fetch(resource, __spreadProps(__spreadValues({}, init || {}), { headers: headers2 }));
|
|
934
949
|
};
|
|
935
950
|
var applyBaseUrl = (input, baseUrl) => {
|
|
936
951
|
return typeof input === "string" && isRelativePath(input) ? baseUrl + input : input;
|
|
@@ -970,12 +985,11 @@ var import_react5 = require("react");
|
|
|
970
985
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
971
986
|
var getLogger = (level, onLog, flowId = "UNKNOWN-FLOW-ID", stepId = "UNKNOWN-FLOW-ID") => (title, description, extra) => {
|
|
972
987
|
try {
|
|
973
|
-
onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`, {
|
|
988
|
+
onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`, __spreadValues({
|
|
974
989
|
flowId,
|
|
975
|
-
stepId
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
} catch {
|
|
990
|
+
stepId
|
|
991
|
+
}, extra));
|
|
992
|
+
} catch (e) {
|
|
979
993
|
}
|
|
980
994
|
};
|
|
981
995
|
var LogContext = (0, import_react5.createContext)(null);
|
|
@@ -1009,7 +1023,7 @@ var isInteger = (value) => {
|
|
|
1009
1023
|
return isNumber(value) && Math.floor(value) === value;
|
|
1010
1024
|
};
|
|
1011
1025
|
var isBoolean = (value) => typeof value === "boolean";
|
|
1012
|
-
var isObject = (value) => !isNull(value) && !isUndefined(value) && value
|
|
1026
|
+
var isObject = (value) => !isNull(value) && !isUndefined(value) && (value == null ? void 0 : value.constructor) === Object;
|
|
1013
1027
|
var isArray = (value) => Array.isArray(value);
|
|
1014
1028
|
var isNull = (value) => value === null;
|
|
1015
1029
|
var isUndefined = (value) => typeof value === "undefined";
|
|
@@ -1024,11 +1038,12 @@ function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
|
1024
1038
|
) ? model : null;
|
|
1025
1039
|
}
|
|
1026
1040
|
function cleanArrayModelWithOneOfSchema(model, schema) {
|
|
1041
|
+
var _a;
|
|
1027
1042
|
const validModels = schema.oneOf.map((nestedSchema) => getValidArrayModelOrNull(model, nestedSchema)).filter((item) => item !== null);
|
|
1028
1043
|
if (validModels.length === 0) {
|
|
1029
1044
|
return null;
|
|
1030
1045
|
}
|
|
1031
|
-
return validModels.find((model2) => model2.some((item) => item !== null))
|
|
1046
|
+
return (_a = validModels.find((model2) => model2.some((item) => item !== null))) != null ? _a : validModels[0];
|
|
1032
1047
|
}
|
|
1033
1048
|
function getValidArrayModelOrNull(model, schema) {
|
|
1034
1049
|
if (!isArraySchema(schema)) {
|
|
@@ -1070,7 +1085,7 @@ function cleanObjectModelWithObjectSchema(model, schema) {
|
|
|
1070
1085
|
const subSchema = schema.properties[property];
|
|
1071
1086
|
const newValue = getValidModelParts(subModel, subSchema);
|
|
1072
1087
|
if (!isNull(newValue)) {
|
|
1073
|
-
return {
|
|
1088
|
+
return __spreadProps(__spreadValues({}, cleanedModel), { [property]: newValue });
|
|
1074
1089
|
}
|
|
1075
1090
|
}
|
|
1076
1091
|
return cleanedModel;
|
|
@@ -1080,7 +1095,7 @@ function cleanObjectModelWithAllOfSchema(model, schema) {
|
|
|
1080
1095
|
return schema.allOf.reduce((cleanObjectModel, nestedSchema) => {
|
|
1081
1096
|
const validSubsetOfModel = getValidObjectModelParts(model, nestedSchema);
|
|
1082
1097
|
if (isObjectModel(validSubsetOfModel)) {
|
|
1083
|
-
return {
|
|
1098
|
+
return __spreadValues(__spreadValues({}, cleanObjectModel), validSubsetOfModel);
|
|
1084
1099
|
}
|
|
1085
1100
|
return cleanObjectModel;
|
|
1086
1101
|
}, {});
|
|
@@ -1105,17 +1120,15 @@ function deepMergeObject(object1, object2) {
|
|
|
1105
1120
|
const object1Property = object1[property];
|
|
1106
1121
|
const object2Property = object2[property];
|
|
1107
1122
|
if (isObjectModel(object1Property) && isObjectModel(object2Property)) {
|
|
1108
|
-
return {
|
|
1109
|
-
...acc,
|
|
1123
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1110
1124
|
[property]: deepMergeObject(object1Property, object2Property)
|
|
1111
|
-
};
|
|
1125
|
+
});
|
|
1112
1126
|
}
|
|
1113
|
-
return {
|
|
1114
|
-
...acc,
|
|
1127
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1115
1128
|
[property]: object2[property]
|
|
1116
|
-
};
|
|
1129
|
+
});
|
|
1117
1130
|
},
|
|
1118
|
-
{
|
|
1131
|
+
__spreadValues({}, object1)
|
|
1119
1132
|
);
|
|
1120
1133
|
}
|
|
1121
1134
|
|
|
@@ -1530,7 +1543,7 @@ var toBase64 = (file) => {
|
|
|
1530
1543
|
};
|
|
1531
1544
|
function areFilesSame(newFiles, files) {
|
|
1532
1545
|
const fileIdToExistingFileMap = files.reduce((map, fileObject) => {
|
|
1533
|
-
return {
|
|
1546
|
+
return __spreadProps(__spreadValues({}, map), { [fileObject.id]: fileObject });
|
|
1534
1547
|
}, {});
|
|
1535
1548
|
for (const newFile of newFiles) {
|
|
1536
1549
|
const existingFileObject = fileIdToExistingFileMap[newFile.id];
|
|
@@ -1553,7 +1566,7 @@ var generateRandomId = (prefix = "") => {
|
|
|
1553
1566
|
|
|
1554
1567
|
// src/common/utils/schema-utils.ts
|
|
1555
1568
|
function isConstSchema(schema) {
|
|
1556
|
-
return !isUndefined(schema
|
|
1569
|
+
return !isUndefined(schema == null ? void 0 : schema.const);
|
|
1557
1570
|
}
|
|
1558
1571
|
function isNoNConstSchema(schema) {
|
|
1559
1572
|
return !!schema && !isConstSchema(schema);
|
|
@@ -1643,13 +1656,16 @@ var isCameraStep = (step) => {
|
|
|
1643
1656
|
return isFormStep(step) && hasSingleAction(step) && hasSingleFileUploadSchemaWithCameraOnly(step);
|
|
1644
1657
|
};
|
|
1645
1658
|
var isFormStep = (step) => !step.type || step.type === "form";
|
|
1646
|
-
var hasSingleAction = (step) =>
|
|
1659
|
+
var hasSingleAction = (step) => {
|
|
1660
|
+
var _a;
|
|
1661
|
+
return ((_a = step == null ? void 0 : step.actions) == null ? void 0 : _a.length) === 1;
|
|
1662
|
+
};
|
|
1647
1663
|
var hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
1648
1664
|
if (!step.schemas) {
|
|
1649
1665
|
return false;
|
|
1650
1666
|
}
|
|
1651
1667
|
const schemas = filterHiddenSchemas(step.schemas);
|
|
1652
|
-
if (schemas
|
|
1668
|
+
if ((schemas == null ? void 0 : schemas.length) !== 1) {
|
|
1653
1669
|
return false;
|
|
1654
1670
|
}
|
|
1655
1671
|
const firstSchema = schemas[0];
|
|
@@ -1665,9 +1681,9 @@ var hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
|
1665
1681
|
var filterHiddenSchemas = (schemas) => {
|
|
1666
1682
|
return schemas.filter((schema) => {
|
|
1667
1683
|
if (isObjectSchema(schema)) {
|
|
1668
|
-
return Object.values(schema
|
|
1684
|
+
return Object.values((schema == null ? void 0 : schema.properties) || {}).find((schema2) => (schema2 == null ? void 0 : schema2.hidden) !== true);
|
|
1669
1685
|
}
|
|
1670
|
-
return schema
|
|
1686
|
+
return (schema == null ? void 0 : schema.hidden) !== true;
|
|
1671
1687
|
});
|
|
1672
1688
|
};
|
|
1673
1689
|
|
|
@@ -1730,7 +1746,7 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1730
1746
|
if (response.ok) {
|
|
1731
1747
|
try {
|
|
1732
1748
|
return response.json();
|
|
1733
|
-
} catch {
|
|
1749
|
+
} catch (e) {
|
|
1734
1750
|
throw new Error("failed");
|
|
1735
1751
|
}
|
|
1736
1752
|
} else {
|
|
@@ -1744,30 +1760,30 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1744
1760
|
}, [polling, httpClient]);
|
|
1745
1761
|
const onPollingResponse = (0, import_react8.useCallback)(
|
|
1746
1762
|
(pollingResponse) => {
|
|
1747
|
-
const responseHandlers = polling
|
|
1763
|
+
const responseHandlers = (polling == null ? void 0 : polling.responseHandlers) || [];
|
|
1748
1764
|
const responseHandler = responseHandlers.find(
|
|
1749
1765
|
(handler) => handler.result === pollingResponse.result
|
|
1750
1766
|
);
|
|
1751
|
-
if (responseHandler
|
|
1767
|
+
if (responseHandler == null ? void 0 : responseHandler.action) {
|
|
1752
1768
|
const { action } = responseHandler;
|
|
1753
1769
|
if (action.exit) {
|
|
1754
|
-
const mergedResult = {
|
|
1755
|
-
onAction({
|
|
1770
|
+
const mergedResult = __spreadValues(__spreadValues({}, action.result || {}), pollingResponse.data || {});
|
|
1771
|
+
onAction(__spreadProps(__spreadValues({}, action), { result: mergedResult }));
|
|
1756
1772
|
} else {
|
|
1757
|
-
const mergedData = {
|
|
1758
|
-
onAction({
|
|
1773
|
+
const mergedData = __spreadValues(__spreadValues({}, action.data || {}), pollingResponse.data || {});
|
|
1774
|
+
onAction(__spreadProps(__spreadValues({}, action), { data: mergedData }));
|
|
1759
1775
|
}
|
|
1760
1776
|
return false;
|
|
1761
1777
|
}
|
|
1762
1778
|
return true;
|
|
1763
1779
|
},
|
|
1764
|
-
[polling
|
|
1780
|
+
[polling == null ? void 0 : polling.responseHandlers, onAction]
|
|
1765
1781
|
);
|
|
1766
1782
|
usePolling({
|
|
1767
1783
|
asyncFn,
|
|
1768
|
-
interval: polling
|
|
1769
|
-
maxAttempts: polling
|
|
1770
|
-
maxConsecutiveFails: polling
|
|
1784
|
+
interval: (polling == null ? void 0 : polling.interval) || 0,
|
|
1785
|
+
maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
|
|
1786
|
+
maxConsecutiveFails: (polling == null ? void 0 : polling.maxConsecutiveFails) || 0,
|
|
1771
1787
|
onPollingResponse,
|
|
1772
1788
|
onFailure: (0, import_react8.useCallback)(() => {
|
|
1773
1789
|
if (polling) {
|
|
@@ -2063,7 +2079,10 @@ var NamedIcon = ({ name }) => {
|
|
|
2063
2079
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { size: 24 });
|
|
2064
2080
|
};
|
|
2065
2081
|
var toCapitalisedCamelCase = (value) => value.split("-").map(capitaliseFirstChar).join("");
|
|
2066
|
-
var capitaliseFirstChar = (value) =>
|
|
2082
|
+
var capitaliseFirstChar = (value) => {
|
|
2083
|
+
var _a;
|
|
2084
|
+
return `${(_a = value[0]) == null ? void 0 : _a.toUpperCase()}${value.slice(1)}`;
|
|
2085
|
+
};
|
|
2067
2086
|
|
|
2068
2087
|
// src/layout/icon/DynamicIcon.tsx
|
|
2069
2088
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -2084,13 +2103,13 @@ var DynamicIcon_default = DynamicIcon;
|
|
|
2084
2103
|
// src/layout/utils/getNavigationOptionMedia.tsx
|
|
2085
2104
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2086
2105
|
var getNavigationOptionMedia = ({ icon, image }) => {
|
|
2087
|
-
if (icon
|
|
2106
|
+
if (icon == null ? void 0 : icon.name) {
|
|
2088
2107
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.Avatar, { type: import_components.AvatarType.ICON, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DynamicIcon_default, { type: icon.name }) });
|
|
2089
2108
|
}
|
|
2090
|
-
if (icon
|
|
2109
|
+
if (icon == null ? void 0 : icon.text) {
|
|
2091
2110
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.Avatar, { type: import_components.AvatarType.INITIALS, children: icon.text });
|
|
2092
2111
|
}
|
|
2093
|
-
if (image
|
|
2112
|
+
if (image == null ? void 0 : image.url) {
|
|
2094
2113
|
const { url, text } = image;
|
|
2095
2114
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: url, alt: text });
|
|
2096
2115
|
}
|
|
@@ -2227,8 +2246,9 @@ var priorities = {
|
|
|
2227
2246
|
negative: "primary"
|
|
2228
2247
|
};
|
|
2229
2248
|
var getButtonPriority = (component) => {
|
|
2249
|
+
var _a;
|
|
2230
2250
|
const actionType = component.action.type;
|
|
2231
|
-
return component.control
|
|
2251
|
+
return (_a = component.control) != null ? _a : actionType ? priorities[actionType] : "secondary";
|
|
2232
2252
|
};
|
|
2233
2253
|
var types = {
|
|
2234
2254
|
primary: "neutral",
|
|
@@ -2238,8 +2258,9 @@ var types = {
|
|
|
2238
2258
|
negative: "negative"
|
|
2239
2259
|
};
|
|
2240
2260
|
var getButtonType = (component) => {
|
|
2261
|
+
var _a;
|
|
2241
2262
|
const actionType = component.action.type;
|
|
2242
|
-
const type = component.context
|
|
2263
|
+
const type = (_a = component.context) != null ? _a : actionType ? types[actionType] : "neutral";
|
|
2243
2264
|
return type === "neutral" ? "accent" : type;
|
|
2244
2265
|
};
|
|
2245
2266
|
var getButtonSize = (size) => {
|
|
@@ -2259,6 +2280,7 @@ var getButtonSize = (size) => {
|
|
|
2259
2280
|
// src/layout/button/DynamicButton.tsx
|
|
2260
2281
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2261
2282
|
var DynamicButton = (props) => {
|
|
2283
|
+
var _a;
|
|
2262
2284
|
const { component, onAction } = props;
|
|
2263
2285
|
const componentAction = component.action;
|
|
2264
2286
|
const type = getButtonType(component);
|
|
@@ -2275,7 +2297,7 @@ var DynamicButton = (props) => {
|
|
|
2275
2297
|
className,
|
|
2276
2298
|
disabled: component.disabled || componentAction.disabled || loading,
|
|
2277
2299
|
onClick: () => onAction(componentAction),
|
|
2278
|
-
children: component.title
|
|
2300
|
+
children: (_a = component.title) != null ? _a : componentAction.title
|
|
2279
2301
|
}
|
|
2280
2302
|
);
|
|
2281
2303
|
};
|
|
@@ -2387,10 +2409,9 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
2387
2409
|
(0, import_react9.useEffect)(() => {
|
|
2388
2410
|
openExternalUrl();
|
|
2389
2411
|
}, [openExternalUrl]);
|
|
2390
|
-
const pollingConfiguration = polling && responseHandlers ? {
|
|
2391
|
-
...polling,
|
|
2412
|
+
const pollingConfiguration = polling && responseHandlers ? __spreadProps(__spreadValues({}, polling), {
|
|
2392
2413
|
responseHandlers
|
|
2393
|
-
} : void 0;
|
|
2414
|
+
}) : void 0;
|
|
2394
2415
|
useExternalStepPolling(pollingConfiguration, onAction);
|
|
2395
2416
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2396
2417
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components5.Loader, { size: import_components5.Size.LARGE, classNames: { "tw-loader": "tw-loader m-x-auto" } }),
|
|
@@ -2412,7 +2433,7 @@ var splitModel = (model, schemas) => {
|
|
|
2412
2433
|
};
|
|
2413
2434
|
var combineModels = (models) => {
|
|
2414
2435
|
return models.reduce((current, combined) => {
|
|
2415
|
-
return {
|
|
2436
|
+
return __spreadValues(__spreadValues({}, combined), current);
|
|
2416
2437
|
}, {});
|
|
2417
2438
|
};
|
|
2418
2439
|
var getSchemaColumnClasses = (width) => {
|
|
@@ -2427,7 +2448,7 @@ var AllOfSchema = (props) => {
|
|
|
2427
2448
|
const modelSchema = props.schema.allOf[index];
|
|
2428
2449
|
models[index] = getValidObjectModelParts(onChangeProps.model, modelSchema) || {};
|
|
2429
2450
|
setModels(models);
|
|
2430
|
-
props.onChange({
|
|
2451
|
+
props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model: combineModels(models) }));
|
|
2431
2452
|
};
|
|
2432
2453
|
const [models, setModels] = (0, import_react10.useState)(splitModel(props.model, props.schema.allOf));
|
|
2433
2454
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
@@ -2443,11 +2464,10 @@ var AllOfSchema = (props) => {
|
|
|
2443
2464
|
errors: props.errors,
|
|
2444
2465
|
submitted: props.submitted,
|
|
2445
2466
|
disabled: props.disabled,
|
|
2446
|
-
onChange: (onChangeProps) => onChangeModelIndex(index, {
|
|
2447
|
-
...onChangeProps,
|
|
2467
|
+
onChange: (onChangeProps) => onChangeModelIndex(index, __spreadProps(__spreadValues({}, onChangeProps), {
|
|
2448
2468
|
// We can safely assume that the model here is going to be of the same type as the model prop
|
|
2449
2469
|
model: onChangeProps.model
|
|
2450
|
-
}),
|
|
2470
|
+
})),
|
|
2451
2471
|
onPersistAsync: props.onPersistAsync
|
|
2452
2472
|
}
|
|
2453
2473
|
) }, index)
|
|
@@ -2527,17 +2547,11 @@ var ControlFeedback_messages_default = (0, import_react_intl4.defineMessages)({
|
|
|
2527
2547
|
// src/jsonSchemaForm/controlFeedback/ControlFeedback.tsx
|
|
2528
2548
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2529
2549
|
var ControlFeedback = (props) => {
|
|
2550
|
+
var _a;
|
|
2530
2551
|
const defaultValidationMessages = useDefaultValidationMessages(props.schema);
|
|
2531
|
-
const validationMessages = {
|
|
2532
|
-
...defaultValidationMessages,
|
|
2533
|
-
// default validation messages
|
|
2534
|
-
...props.validationMessages,
|
|
2535
|
-
// overridden by props
|
|
2536
|
-
...props.schema.validationMessages
|
|
2537
|
-
// overriden by schema
|
|
2538
|
-
};
|
|
2552
|
+
const validationMessages = __spreadValues(__spreadValues(__spreadValues({}, defaultValidationMessages), props.validationMessages), props.schema.validationMessages);
|
|
2539
2553
|
const isErrorVisible = (props.submitted || !props.changed) && !!props.errors;
|
|
2540
|
-
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && !!props.validations
|
|
2554
|
+
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && !!((_a = props.validations) == null ? void 0 : _a.length);
|
|
2541
2555
|
const isDescriptionVisible = props.focused && props.schema.description && !isValidationVisible;
|
|
2542
2556
|
const hasInfoMessage = !!props.infoMessage;
|
|
2543
2557
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { id: props.id, children: [
|
|
@@ -2598,10 +2612,7 @@ function useDefaultValidationMessages(schema) {
|
|
|
2598
2612
|
)
|
|
2599
2613
|
}) : void 0
|
|
2600
2614
|
};
|
|
2601
|
-
return {
|
|
2602
|
-
...formattedMessages,
|
|
2603
|
-
...dateOverrides
|
|
2604
|
-
};
|
|
2615
|
+
return __spreadValues(__spreadValues({}, formattedMessages), dateOverrides);
|
|
2605
2616
|
}
|
|
2606
2617
|
return formattedMessages;
|
|
2607
2618
|
}
|
|
@@ -2622,7 +2633,7 @@ async function createPayload(userUploadedFile, isBlobSchema2) {
|
|
|
2622
2633
|
}
|
|
2623
2634
|
function constructUploadResponse(response) {
|
|
2624
2635
|
const id = response.data;
|
|
2625
|
-
return { id,
|
|
2636
|
+
return __spreadValues({ id }, response);
|
|
2626
2637
|
}
|
|
2627
2638
|
function constructUploadError(response) {
|
|
2628
2639
|
const isError = response instanceof Error;
|
|
@@ -2635,10 +2646,9 @@ function constructUploadError(response) {
|
|
|
2635
2646
|
const error = response;
|
|
2636
2647
|
return { id: generateRandomId(), message: error.message };
|
|
2637
2648
|
} else {
|
|
2638
|
-
return {
|
|
2639
|
-
message: isString(response.message) ? response.message : ""
|
|
2640
|
-
|
|
2641
|
-
};
|
|
2649
|
+
return __spreadValues({
|
|
2650
|
+
message: isString(response.message) ? response.message : ""
|
|
2651
|
+
}, response);
|
|
2642
2652
|
}
|
|
2643
2653
|
}
|
|
2644
2654
|
|
|
@@ -2693,6 +2703,7 @@ function useFormattedDefaultErrorMessages({
|
|
|
2693
2703
|
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.tsx
|
|
2694
2704
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2695
2705
|
var MultipleFileUploadSchema = (props) => {
|
|
2706
|
+
var _a, _b;
|
|
2696
2707
|
const { onChange, schema } = props;
|
|
2697
2708
|
const onEvent = useEventDispatcher();
|
|
2698
2709
|
const defaultErrorMessages = useFormattedDefaultErrorMessages(schema);
|
|
@@ -2734,28 +2745,27 @@ var MultipleFileUploadSchema = (props) => {
|
|
|
2734
2745
|
const showError = Boolean(props.errors) || (inputChanged || props.submitted) && Boolean(fileListValidationFailures.length);
|
|
2735
2746
|
const accepts = "accepts" in fileSchemaDescriptor && fileSchemaDescriptor.accepts;
|
|
2736
2747
|
const maxSize = "maxSize" in fileSchemaDescriptor && fileSchemaDescriptor.maxSize;
|
|
2737
|
-
const uploadInputProps = {
|
|
2748
|
+
const uploadInputProps = __spreadProps(__spreadValues(__spreadValues({
|
|
2738
2749
|
multiple: true,
|
|
2739
2750
|
className: "form-control",
|
|
2740
2751
|
files,
|
|
2741
2752
|
fileInputName: uid,
|
|
2742
|
-
id: uid
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
sizeLimitErrorMessage: fileSchemaDescriptor.validationMessages?.maxSize || defaultErrorMessages.maxFileSizeErrorMessage,
|
|
2753
|
+
id: uid
|
|
2754
|
+
}, accepts ? { fileTypes: accepts } : void 0), maxSize ? { sizeLimit: toKilobytes(maxSize) } : void 0), {
|
|
2755
|
+
sizeLimitErrorMessage: ((_a = fileSchemaDescriptor.validationMessages) == null ? void 0 : _a.maxSize) || defaultErrorMessages.maxFileSizeErrorMessage,
|
|
2746
2756
|
maxFiles: props.schema.maxItems,
|
|
2747
|
-
maxFilesErrorMessage: props.schema.validationMessages
|
|
2757
|
+
maxFilesErrorMessage: ((_b = props.schema.validationMessages) == null ? void 0 : _b.maxItems) || defaultErrorMessages.maxItemsErrorMessage,
|
|
2748
2758
|
uploadButtonTitle: fileSchemaDescriptor.title,
|
|
2749
2759
|
description: fileSchemaDescriptor.description,
|
|
2750
2760
|
disabled: props.disabled,
|
|
2751
2761
|
onUploadFile: (formData) => uploadFile(formData.get(uid)),
|
|
2752
2762
|
onFilesChange,
|
|
2753
2763
|
onDeleteFile: () => Promise.resolve()
|
|
2754
|
-
};
|
|
2764
|
+
});
|
|
2755
2765
|
const feedbackId = `${uid}-feedback`;
|
|
2756
2766
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_classnames2.default)("form-group", { "has-error": showError }), children: [
|
|
2757
2767
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { className: "d-block control-label", htmlFor: uid, children: props.schema.title }),
|
|
2758
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput, {
|
|
2768
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput, __spreadValues({}, uploadInputProps)) }),
|
|
2759
2769
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2760
2770
|
ControlFeedback_default,
|
|
2761
2771
|
{
|
|
@@ -2793,11 +2803,7 @@ function isValidId(id) {
|
|
|
2793
2803
|
}
|
|
2794
2804
|
function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
2795
2805
|
const { minItems, maxItems } = schema;
|
|
2796
|
-
return {
|
|
2797
|
-
...required && { required: defaultErrorMessages.requiredMessage },
|
|
2798
|
-
...minItems && { minItems: defaultErrorMessages.minItemsErrorMessage },
|
|
2799
|
-
...maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage }
|
|
2800
|
-
};
|
|
2806
|
+
return __spreadValues(__spreadValues(__spreadValues({}, required && { required: defaultErrorMessages.requiredMessage }), minItems && { minItems: defaultErrorMessages.minItemsErrorMessage }), maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage });
|
|
2801
2807
|
}
|
|
2802
2808
|
|
|
2803
2809
|
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
|
|
@@ -2979,13 +2985,19 @@ var getItemSummaryFromSchema = (schema, model, defaults = {}) => {
|
|
|
2979
2985
|
schema,
|
|
2980
2986
|
model,
|
|
2981
2987
|
providesProp: "providesIcon",
|
|
2982
|
-
getValueFromSchema: (schema2) =>
|
|
2988
|
+
getValueFromSchema: (schema2) => {
|
|
2989
|
+
var _a;
|
|
2990
|
+
return (_a = schema2.icon) != null ? _a : null;
|
|
2991
|
+
}
|
|
2983
2992
|
});
|
|
2984
2993
|
const image = getSummaryPropFromSchema({
|
|
2985
2994
|
schema,
|
|
2986
2995
|
model,
|
|
2987
2996
|
providesProp: "providesImage",
|
|
2988
|
-
getValueFromSchema: (schema2) =>
|
|
2997
|
+
getValueFromSchema: (schema2) => {
|
|
2998
|
+
var _a;
|
|
2999
|
+
return (_a = schema2.image) != null ? _a : null;
|
|
3000
|
+
}
|
|
2989
3001
|
});
|
|
2990
3002
|
return {
|
|
2991
3003
|
value: model,
|
|
@@ -3021,11 +3033,10 @@ var getObjectValueFromSchema = (props) => {
|
|
|
3021
3033
|
for (const propertyKey in objectSchema.properties) {
|
|
3022
3034
|
const propertySchema = objectSchema.properties[propertyKey];
|
|
3023
3035
|
const propertyModel = isObjectModel(model) && propertyKey in model ? model[propertyKey] : null;
|
|
3024
|
-
const result = getSummaryPropFromSchema({
|
|
3025
|
-
...props,
|
|
3036
|
+
const result = getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3026
3037
|
schema: propertySchema,
|
|
3027
3038
|
model: propertyModel
|
|
3028
|
-
});
|
|
3039
|
+
}));
|
|
3029
3040
|
if (result) {
|
|
3030
3041
|
return result;
|
|
3031
3042
|
}
|
|
@@ -3043,29 +3054,26 @@ var getOneOfValueFromSchema = (props) => {
|
|
|
3043
3054
|
return null;
|
|
3044
3055
|
}
|
|
3045
3056
|
const activeSchema = schema.oneOf[activeSchemaIndex2];
|
|
3046
|
-
return getSummaryPropFromSchema({
|
|
3047
|
-
...props,
|
|
3057
|
+
return getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3048
3058
|
schema: activeSchema
|
|
3049
|
-
});
|
|
3059
|
+
}));
|
|
3050
3060
|
}
|
|
3051
3061
|
const oneOfSchema = schema;
|
|
3052
3062
|
const activeSchemaIndex = getActiveSchemaIndex(oneOfSchema, model);
|
|
3053
3063
|
if (activeSchemaIndex === null || activeSchemaIndex < 0) {
|
|
3054
3064
|
return null;
|
|
3055
3065
|
}
|
|
3056
|
-
return getSummaryPropFromSchema({
|
|
3057
|
-
...props,
|
|
3066
|
+
return getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3058
3067
|
schema: oneOfSchema.oneOf[activeSchemaIndex]
|
|
3059
|
-
});
|
|
3068
|
+
}));
|
|
3060
3069
|
};
|
|
3061
3070
|
var getAllOfValueFromSchema = (props) => {
|
|
3062
3071
|
const { schema } = props;
|
|
3063
3072
|
const allOfSchema = schema;
|
|
3064
3073
|
for (const childSchema of allOfSchema.allOf) {
|
|
3065
|
-
const result = getSummaryPropFromSchema({
|
|
3066
|
-
...props,
|
|
3074
|
+
const result = getSummaryPropFromSchema(__spreadProps(__spreadValues({}, props), {
|
|
3067
3075
|
schema: childSchema
|
|
3068
|
-
});
|
|
3076
|
+
}));
|
|
3069
3077
|
if (result) {
|
|
3070
3078
|
return result;
|
|
3071
3079
|
}
|
|
@@ -3102,7 +3110,7 @@ var RepeatableSchema = ({
|
|
|
3102
3110
|
"RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
|
|
3103
3111
|
);
|
|
3104
3112
|
}
|
|
3105
|
-
return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema
|
|
3113
|
+
return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema == null ? void 0 : schema.summary)) : null;
|
|
3106
3114
|
});
|
|
3107
3115
|
const [editableItem, setEditableItem] = (0, import_react12.useState)({ item: null, model: null });
|
|
3108
3116
|
const broadcastModelChange = (updatedItems) => {
|
|
@@ -3121,8 +3129,9 @@ var RepeatableSchema = ({
|
|
|
3121
3129
|
setOpenModalType("edit");
|
|
3122
3130
|
};
|
|
3123
3131
|
const onSaveItem = (action) => {
|
|
3124
|
-
|
|
3125
|
-
|
|
3132
|
+
var _a;
|
|
3133
|
+
const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(schema.items, editableItem.model, schema == null ? void 0 : schema.summary);
|
|
3134
|
+
if (action !== "remove" && !isValidSchema((_a = updatedItem == null ? void 0 : updatedItem.value) != null ? _a : null, schema.items)) {
|
|
3126
3135
|
return;
|
|
3127
3136
|
}
|
|
3128
3137
|
const updatedItemSummaries = getUpdatedItemSummaries(action, {
|
|
@@ -3167,13 +3176,13 @@ var RepeatableSchema = ({
|
|
|
3167
3176
|
body: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3168
3177
|
RepeatableSchemaStep_default,
|
|
3169
3178
|
{
|
|
3170
|
-
type: openModalType
|
|
3179
|
+
type: openModalType != null ? openModalType : "add",
|
|
3171
3180
|
schema,
|
|
3172
3181
|
model: editableItem.model,
|
|
3173
3182
|
errors,
|
|
3174
3183
|
submitted,
|
|
3175
3184
|
onAction: onSaveItem,
|
|
3176
|
-
onModelChange: ({ model: model2 }) => setEditableItem({
|
|
3185
|
+
onModelChange: ({ model: model2 }) => setEditableItem(__spreadProps(__spreadValues({}, editableItem), { model: model2 }))
|
|
3177
3186
|
}
|
|
3178
3187
|
)
|
|
3179
3188
|
}
|
|
@@ -3209,10 +3218,10 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
|
3209
3218
|
var ArrayListSchema = (props) => {
|
|
3210
3219
|
const { schema } = props;
|
|
3211
3220
|
if (isMultipleFileUploadSchema(schema)) {
|
|
3212
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default, {
|
|
3221
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default, __spreadProps(__spreadValues({}, props), { schema }));
|
|
3213
3222
|
}
|
|
3214
3223
|
if (isListArraySchema(schema)) {
|
|
3215
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RepeatableSchema_default, {
|
|
3224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RepeatableSchema_default, __spreadProps(__spreadValues({}, props), { schema }));
|
|
3216
3225
|
}
|
|
3217
3226
|
throw new Error("Invalid array list schema");
|
|
3218
3227
|
};
|
|
@@ -3227,7 +3236,7 @@ var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
|
3227
3236
|
var ArraySchema = (props) => {
|
|
3228
3237
|
const { schema } = props;
|
|
3229
3238
|
if (isListArraySchema(schema)) {
|
|
3230
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default, {
|
|
3239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default, __spreadValues({}, props));
|
|
3231
3240
|
}
|
|
3232
3241
|
throw new Error("Not implemented");
|
|
3233
3242
|
};
|
|
@@ -3248,9 +3257,7 @@ var getSchemaColumnClasses2 = (width) => {
|
|
|
3248
3257
|
};
|
|
3249
3258
|
};
|
|
3250
3259
|
var ObjectSchema = (props) => {
|
|
3251
|
-
const [model, setModel] = (0, import_react13.useState)(() => ({
|
|
3252
|
-
...getValidObjectModelParts(props.model, props.schema)
|
|
3253
|
-
}));
|
|
3260
|
+
const [model, setModel] = (0, import_react13.useState)(() => __spreadValues({}, getValidObjectModelParts(props.model, props.schema)));
|
|
3254
3261
|
const onChangeProperty = (propertyName, onChangeProps) => {
|
|
3255
3262
|
if (onChangeProps.model !== null) {
|
|
3256
3263
|
model[propertyName] = onChangeProps.model;
|
|
@@ -3258,7 +3265,7 @@ var ObjectSchema = (props) => {
|
|
|
3258
3265
|
delete model[propertyName];
|
|
3259
3266
|
}
|
|
3260
3267
|
setModel(model);
|
|
3261
|
-
props.onChange({
|
|
3268
|
+
props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
|
|
3262
3269
|
};
|
|
3263
3270
|
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
3264
3271
|
(0, import_react13.useEffect)(() => {
|
|
@@ -3472,7 +3479,7 @@ var logInvalidTypeFallbackWarning = ({
|
|
|
3472
3479
|
|
|
3473
3480
|
// src/formControl/FormControl.tsx
|
|
3474
3481
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3475
|
-
var
|
|
3482
|
+
var _FormControl = class _FormControl extends import_react14.PureComponent {
|
|
3476
3483
|
constructor(props) {
|
|
3477
3484
|
super(props);
|
|
3478
3485
|
/**
|
|
@@ -3488,14 +3495,19 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3488
3495
|
this.props.onChange(event.target.value);
|
|
3489
3496
|
};
|
|
3490
3497
|
this.handleOnFocus = () => {
|
|
3491
|
-
|
|
3498
|
+
var _a, _b;
|
|
3499
|
+
(_b = (_a = this.props).onFocus) == null ? void 0 : _b.call(_a);
|
|
3492
3500
|
};
|
|
3493
3501
|
this.handleOnBlur = () => {
|
|
3494
|
-
|
|
3502
|
+
var _a, _b;
|
|
3503
|
+
(_b = (_a = this.props).onBlur) == null ? void 0 : _b.call(_a);
|
|
3495
3504
|
};
|
|
3496
3505
|
this.getSelectedOption = (options) => {
|
|
3497
3506
|
if (this.state.selectedOption !== null && typeof this.state.selectedOption !== "undefined") {
|
|
3498
|
-
return options.find((option) =>
|
|
3507
|
+
return options.find((option) => {
|
|
3508
|
+
var _a;
|
|
3509
|
+
return ((_a = this.state.selectedOption) == null ? void 0 : _a.value) === option.value;
|
|
3510
|
+
});
|
|
3499
3511
|
}
|
|
3500
3512
|
if (this.props.value !== null && typeof this.props.value !== "undefined") {
|
|
3501
3513
|
return options.find((option) => this.props.value === option.value);
|
|
@@ -3503,13 +3515,12 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3503
3515
|
return void 0;
|
|
3504
3516
|
};
|
|
3505
3517
|
this.mapOption = (option) => {
|
|
3506
|
-
return {
|
|
3507
|
-
...option,
|
|
3518
|
+
return __spreadProps(__spreadValues({}, option), {
|
|
3508
3519
|
value: isNumber(option.value) || isString(option.value) ? option.value : void 0,
|
|
3509
3520
|
secondary: option.note,
|
|
3510
3521
|
disabled: option.disabled || this.props.disabled,
|
|
3511
3522
|
readOnly: this.props.readOnly
|
|
3512
|
-
};
|
|
3523
|
+
});
|
|
3513
3524
|
};
|
|
3514
3525
|
this.state = {
|
|
3515
3526
|
selectedOption: props.selectedOption,
|
|
@@ -3517,18 +3528,6 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3517
3528
|
prevValue: props.value
|
|
3518
3529
|
};
|
|
3519
3530
|
}
|
|
3520
|
-
static {
|
|
3521
|
-
this.Type = FormControlType;
|
|
3522
|
-
}
|
|
3523
|
-
static {
|
|
3524
|
-
this.Size = Size;
|
|
3525
|
-
}
|
|
3526
|
-
static {
|
|
3527
|
-
this.MonthFormat = MonthFormat;
|
|
3528
|
-
}
|
|
3529
|
-
static {
|
|
3530
|
-
this.DateMode = DateMode;
|
|
3531
|
-
}
|
|
3532
3531
|
static getDerivedStateFromProps(nextProps, previousState) {
|
|
3533
3532
|
if (previousState.prevValue !== nextProps.value) {
|
|
3534
3533
|
return { prevValue: nextProps.value, value: nextProps.value };
|
|
@@ -3536,6 +3535,7 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3536
3535
|
return null;
|
|
3537
3536
|
}
|
|
3538
3537
|
render() {
|
|
3538
|
+
var _a;
|
|
3539
3539
|
const {
|
|
3540
3540
|
name,
|
|
3541
3541
|
placeholder,
|
|
@@ -3605,8 +3605,9 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3605
3605
|
searchPlaceholder,
|
|
3606
3606
|
searchValue,
|
|
3607
3607
|
onChange: (option) => {
|
|
3608
|
-
|
|
3609
|
-
this.
|
|
3608
|
+
var _a2;
|
|
3609
|
+
this.setState({ selectedOption: option != null ? option : void 0 });
|
|
3610
|
+
this.props.onChange((_a2 = option == null ? void 0 : option.value) != null ? _a2 : null);
|
|
3610
3611
|
},
|
|
3611
3612
|
onFocus: this.handleOnFocus,
|
|
3612
3613
|
onBlur: this.handleOnBlur,
|
|
@@ -3618,7 +3619,7 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3618
3619
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3619
3620
|
import_components11.Tabs,
|
|
3620
3621
|
{
|
|
3621
|
-
selected: this.getSelectedOption(options)
|
|
3622
|
+
selected: ((_a = this.getSelectedOption(options)) == null ? void 0 : _a.value) || 0,
|
|
3622
3623
|
tabs: options.map((option) => ({
|
|
3623
3624
|
title: option.label,
|
|
3624
3625
|
content: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, {}),
|
|
@@ -3760,20 +3761,19 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3760
3761
|
if (this.props.displayPattern) {
|
|
3761
3762
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3762
3763
|
import_components11.TextareaWithDisplayFormat,
|
|
3763
|
-
{
|
|
3764
|
-
displayPattern: this.props.displayPattern
|
|
3765
|
-
|
|
3764
|
+
__spreadProps(__spreadValues({
|
|
3765
|
+
displayPattern: this.props.displayPattern
|
|
3766
|
+
}, textareaProps), {
|
|
3766
3767
|
onChange: this.handleOnChange
|
|
3767
|
-
}
|
|
3768
|
+
})
|
|
3768
3769
|
);
|
|
3769
3770
|
}
|
|
3770
3771
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3771
3772
|
"textarea",
|
|
3772
|
-
{
|
|
3773
|
-
...textareaProps,
|
|
3773
|
+
__spreadProps(__spreadValues({}, textareaProps), {
|
|
3774
3774
|
onChange: this.handleInputOnChange,
|
|
3775
3775
|
"aria-describedby": describedBy
|
|
3776
|
-
}
|
|
3776
|
+
})
|
|
3777
3777
|
);
|
|
3778
3778
|
}
|
|
3779
3779
|
case FormControlType.FILE:
|
|
@@ -3783,8 +3783,7 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3783
3783
|
// @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
|
|
3784
3784
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3785
3785
|
import_components11.Upload,
|
|
3786
|
-
{
|
|
3787
|
-
...uploadProps,
|
|
3786
|
+
__spreadProps(__spreadValues({}, uploadProps), {
|
|
3788
3787
|
usAccept: uploadProps.usAccept || "*",
|
|
3789
3788
|
usDisabled: uploadProps.usDisabled || disabled,
|
|
3790
3789
|
onSuccess: (base64url) => {
|
|
@@ -3796,7 +3795,7 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3796
3795
|
onCancel: () => {
|
|
3797
3796
|
this.handleOnChange(null);
|
|
3798
3797
|
}
|
|
3799
|
-
}
|
|
3798
|
+
})
|
|
3800
3799
|
)
|
|
3801
3800
|
);
|
|
3802
3801
|
}
|
|
@@ -3821,58 +3820,60 @@ var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
|
3821
3820
|
if (this.props.displayPattern) {
|
|
3822
3821
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3823
3822
|
import_components11.InputWithDisplayFormat,
|
|
3824
|
-
{
|
|
3825
|
-
displayPattern: this.props.displayPattern
|
|
3826
|
-
|
|
3823
|
+
__spreadProps(__spreadValues({
|
|
3824
|
+
displayPattern: this.props.displayPattern
|
|
3825
|
+
}, inputProps), {
|
|
3827
3826
|
onChange: this.handleOnChange
|
|
3828
|
-
}
|
|
3827
|
+
})
|
|
3829
3828
|
);
|
|
3830
3829
|
}
|
|
3831
3830
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3832
3831
|
"input",
|
|
3833
|
-
{
|
|
3834
|
-
...inputProps,
|
|
3832
|
+
__spreadProps(__spreadValues({}, inputProps), {
|
|
3835
3833
|
onChange: this.handleInputOnChange,
|
|
3836
3834
|
"aria-describedby": describedBy
|
|
3837
|
-
}
|
|
3835
|
+
})
|
|
3838
3836
|
);
|
|
3839
3837
|
}
|
|
3840
3838
|
}
|
|
3841
3839
|
}
|
|
3842
|
-
static {
|
|
3843
|
-
this.defaultProps = {
|
|
3844
|
-
autoComplete: true,
|
|
3845
|
-
countryCode: null,
|
|
3846
|
-
disabled: false,
|
|
3847
|
-
displayPattern: null,
|
|
3848
|
-
id: null,
|
|
3849
|
-
label: "",
|
|
3850
|
-
max: null,
|
|
3851
|
-
maxDate: null,
|
|
3852
|
-
maxLength: null,
|
|
3853
|
-
min: null,
|
|
3854
|
-
minDate: null,
|
|
3855
|
-
minLength: null,
|
|
3856
|
-
mode: _FormControl.DateMode.DAY_MONTH_YEAR,
|
|
3857
|
-
monthFormat: _FormControl.MonthFormat.LONG,
|
|
3858
|
-
onBlur: null,
|
|
3859
|
-
onFocus: null,
|
|
3860
|
-
onSearchChange: null,
|
|
3861
|
-
options: [],
|
|
3862
|
-
placeholder: null,
|
|
3863
|
-
readOnly: false,
|
|
3864
|
-
required: false,
|
|
3865
|
-
searchPlaceholder: null,
|
|
3866
|
-
searchValue: "",
|
|
3867
|
-
selectedOption: null,
|
|
3868
|
-
size: _FormControl.Size.MEDIUM,
|
|
3869
|
-
step: 1,
|
|
3870
|
-
type: _FormControl.Type.TEXT,
|
|
3871
|
-
uploadProps: {},
|
|
3872
|
-
value: null
|
|
3873
|
-
};
|
|
3874
|
-
}
|
|
3875
3840
|
};
|
|
3841
|
+
_FormControl.Type = FormControlType;
|
|
3842
|
+
_FormControl.Size = Size;
|
|
3843
|
+
_FormControl.MonthFormat = MonthFormat;
|
|
3844
|
+
_FormControl.DateMode = DateMode;
|
|
3845
|
+
_FormControl.defaultProps = {
|
|
3846
|
+
autoComplete: true,
|
|
3847
|
+
countryCode: null,
|
|
3848
|
+
disabled: false,
|
|
3849
|
+
displayPattern: null,
|
|
3850
|
+
id: null,
|
|
3851
|
+
label: "",
|
|
3852
|
+
max: null,
|
|
3853
|
+
maxDate: null,
|
|
3854
|
+
maxLength: null,
|
|
3855
|
+
min: null,
|
|
3856
|
+
minDate: null,
|
|
3857
|
+
minLength: null,
|
|
3858
|
+
mode: _FormControl.DateMode.DAY_MONTH_YEAR,
|
|
3859
|
+
monthFormat: _FormControl.MonthFormat.LONG,
|
|
3860
|
+
onBlur: null,
|
|
3861
|
+
onFocus: null,
|
|
3862
|
+
onSearchChange: null,
|
|
3863
|
+
options: [],
|
|
3864
|
+
placeholder: null,
|
|
3865
|
+
readOnly: false,
|
|
3866
|
+
required: false,
|
|
3867
|
+
searchPlaceholder: null,
|
|
3868
|
+
searchValue: "",
|
|
3869
|
+
selectedOption: null,
|
|
3870
|
+
size: _FormControl.Size.MEDIUM,
|
|
3871
|
+
step: 1,
|
|
3872
|
+
type: _FormControl.Type.TEXT,
|
|
3873
|
+
uploadProps: {},
|
|
3874
|
+
value: null
|
|
3875
|
+
};
|
|
3876
|
+
var FormControl = _FormControl;
|
|
3876
3877
|
|
|
3877
3878
|
// src/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
3878
3879
|
var import_components12 = require("@transferwise/components");
|
|
@@ -3887,30 +3888,22 @@ var mapConstSchemaToOption = (schema, controlType) => {
|
|
|
3887
3888
|
}
|
|
3888
3889
|
};
|
|
3889
3890
|
var mapConstSchemaToRadioOption = (schema) => {
|
|
3890
|
-
return {
|
|
3891
|
+
return __spreadValues(__spreadValues(__spreadValues({
|
|
3891
3892
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
3892
3893
|
label: schema.title,
|
|
3893
|
-
value: schema.const
|
|
3894
|
-
|
|
3895
|
-
...getAvatarPropertyForRadioOption(schema),
|
|
3896
|
-
...getDisabled(schema.disabled)
|
|
3897
|
-
};
|
|
3894
|
+
value: schema.const
|
|
3895
|
+
}, getOptionDescription(schema.title, schema.description)), getAvatarPropertyForRadioOption(schema)), getDisabled(schema.disabled));
|
|
3898
3896
|
};
|
|
3899
3897
|
var mapConstSchemaToSelectOption = (schema) => {
|
|
3900
|
-
return {
|
|
3898
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
3901
3899
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
3902
3900
|
label: schema.title,
|
|
3903
|
-
value: schema.const
|
|
3904
|
-
|
|
3905
|
-
...getIconPropertyForSelectOption(schema.icon),
|
|
3906
|
-
...mapImage(schema.image),
|
|
3907
|
-
...getDisabled(schema.disabled),
|
|
3908
|
-
...mapKeywordsToSearchStrings(schema.keywords)
|
|
3909
|
-
};
|
|
3901
|
+
value: schema.const
|
|
3902
|
+
}, getOptionDescription(schema.title, schema.description)), getIconPropertyForSelectOption(schema.icon)), mapImage(schema.image)), getDisabled(schema.disabled)), mapKeywordsToSearchStrings(schema.keywords));
|
|
3910
3903
|
};
|
|
3911
3904
|
var mapKeywordsToSearchStrings = (searchStrings) => isArray(searchStrings) ? { searchStrings } : {};
|
|
3912
3905
|
var mapImage = (image) => {
|
|
3913
|
-
if (image
|
|
3906
|
+
if (image == null ? void 0 : image.url) {
|
|
3914
3907
|
return {
|
|
3915
3908
|
icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "media", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "np-option__no-media-circle", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: image.url, alt: image.name || "" }) }) })
|
|
3916
3909
|
};
|
|
@@ -3918,38 +3911,36 @@ var mapImage = (image) => {
|
|
|
3918
3911
|
return null;
|
|
3919
3912
|
};
|
|
3920
3913
|
var getIconPropertyForSelectOption = (icon) => {
|
|
3921
|
-
if (icon
|
|
3914
|
+
if ((icon == null ? void 0 : icon.name) && isFlagIcon(icon.name)) {
|
|
3922
3915
|
return { currency: icon.name.substring(5) };
|
|
3923
3916
|
}
|
|
3924
|
-
if (icon
|
|
3917
|
+
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3925
3918
|
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DynamicIcon_default, { type: icon.name }) };
|
|
3926
3919
|
}
|
|
3927
|
-
if (icon
|
|
3920
|
+
if (icon == null ? void 0 : icon.text) {
|
|
3928
3921
|
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: icon.text }) };
|
|
3929
3922
|
}
|
|
3930
3923
|
return null;
|
|
3931
3924
|
};
|
|
3932
3925
|
var getAvatarPropertyForRadioOption = ({ image, icon }) => {
|
|
3933
|
-
if (image
|
|
3926
|
+
if (image == null ? void 0 : image.url) {
|
|
3934
3927
|
return {
|
|
3935
3928
|
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.THUMBNAIL, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { src: image.url, alt: "" }) })
|
|
3936
3929
|
};
|
|
3937
3930
|
}
|
|
3938
|
-
if (icon
|
|
3931
|
+
if ((icon == null ? void 0 : icon.name) && isValidIconName(icon.name)) {
|
|
3939
3932
|
return {
|
|
3940
3933
|
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.ICON, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DynamicIcon_default, { type: icon.name }) })
|
|
3941
3934
|
};
|
|
3942
3935
|
}
|
|
3943
|
-
if (icon
|
|
3936
|
+
if (icon == null ? void 0 : icon.text) {
|
|
3944
3937
|
return {
|
|
3945
3938
|
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.INITIALS, children: icon.text })
|
|
3946
3939
|
};
|
|
3947
3940
|
}
|
|
3948
3941
|
return null;
|
|
3949
3942
|
};
|
|
3950
|
-
var mapSchemaToUploadOptions = ({ accepts }) => ({
|
|
3951
|
-
...isArray(accepts) && { usAccept: accepts.join(",") }
|
|
3952
|
-
});
|
|
3943
|
+
var mapSchemaToUploadOptions = ({ accepts }) => __spreadValues({}, isArray(accepts) && { usAccept: accepts.join(",") });
|
|
3953
3944
|
var getOptionDescription = (title, description) => {
|
|
3954
3945
|
if (title && description) {
|
|
3955
3946
|
const keyForDescription = (title + description).length > 50 ? "secondary" : "note";
|
|
@@ -4042,7 +4033,7 @@ var SchemaFormControl = (props) => {
|
|
|
4042
4033
|
uploadProps: mapSchemaToUploadOptions(schema),
|
|
4043
4034
|
describedBy
|
|
4044
4035
|
};
|
|
4045
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, { type: controlType, value: safeValue,
|
|
4036
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, __spreadValues(__spreadValues({ type: controlType, value: safeValue }, events), controlProps)) });
|
|
4046
4037
|
};
|
|
4047
4038
|
SchemaFormControl.defaultProps = {
|
|
4048
4039
|
value: null,
|
|
@@ -4134,7 +4125,7 @@ var OneOfSchema = (props) => {
|
|
|
4134
4125
|
if (type !== "init" && props.schema.analyticsId) {
|
|
4135
4126
|
onEvent("Dynamic Flow - OneOf Selected", {
|
|
4136
4127
|
oneOfId: props.schema.analyticsId,
|
|
4137
|
-
schemaId: newSchema
|
|
4128
|
+
schemaId: newSchema == null ? void 0 : newSchema.analyticsId
|
|
4138
4129
|
});
|
|
4139
4130
|
}
|
|
4140
4131
|
};
|
|
@@ -4209,7 +4200,7 @@ function getTitleAndHelp(schema, id) {
|
|
|
4209
4200
|
return schema.title ? titleElement : helpElement;
|
|
4210
4201
|
}
|
|
4211
4202
|
function getValidations(props, schemaIndex) {
|
|
4212
|
-
const selectedSchema = props.schema.oneOf[schemaIndex
|
|
4203
|
+
const selectedSchema = props.schema.oneOf[schemaIndex != null ? schemaIndex : -1];
|
|
4213
4204
|
if (isConstSchema(selectedSchema)) {
|
|
4214
4205
|
return getValidationFailures(selectedSchema.const, props.schema, !!props.required);
|
|
4215
4206
|
}
|
|
@@ -4228,7 +4219,7 @@ function getModelPartsForSchemas(model, schemas) {
|
|
|
4228
4219
|
return schemas.map((schema) => getValidModelParts(model, schema));
|
|
4229
4220
|
}
|
|
4230
4221
|
function mapSchemasForSelect(schema) {
|
|
4231
|
-
return {
|
|
4222
|
+
return __spreadProps(__spreadValues({}, schema), { oneOf: schema.oneOf.map(mapOneOfToConst) });
|
|
4232
4223
|
}
|
|
4233
4224
|
function mapOneOfToConst(schema, index) {
|
|
4234
4225
|
const { title, description, disabled = false, icon, image, keywords } = schema;
|
|
@@ -4348,7 +4339,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4348
4339
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_classnames5.default)(formGroupClasses), children: [
|
|
4349
4340
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4350
4341
|
UploadInputAdapter,
|
|
4351
|
-
{
|
|
4342
|
+
__spreadValues({
|
|
4352
4343
|
id,
|
|
4353
4344
|
fileId: props.model,
|
|
4354
4345
|
idProperty: props.schema.persistAsync.idProperty,
|
|
@@ -4360,9 +4351,8 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4360
4351
|
httpClient,
|
|
4361
4352
|
onSuccess,
|
|
4362
4353
|
onFailure,
|
|
4363
|
-
onCancel
|
|
4364
|
-
|
|
4365
|
-
}
|
|
4354
|
+
onCancel
|
|
4355
|
+
}, mapSchemaToUploadOptions(props.schema.persistAsync.schema))
|
|
4366
4356
|
) }),
|
|
4367
4357
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4368
4358
|
ControlFeedback_default,
|
|
@@ -4375,10 +4365,9 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4375
4365
|
errors: props.errors,
|
|
4376
4366
|
schema: props.schema,
|
|
4377
4367
|
validations: combinedValidations,
|
|
4378
|
-
validationMessages: {
|
|
4379
|
-
required: "Value is required..."
|
|
4380
|
-
|
|
4381
|
-
},
|
|
4368
|
+
validationMessages: __spreadValues({
|
|
4369
|
+
required: "Value is required..."
|
|
4370
|
+
}, persistAsyncValidationMessages),
|
|
4382
4371
|
infoMessage: null
|
|
4383
4372
|
}
|
|
4384
4373
|
)
|
|
@@ -4397,12 +4386,10 @@ var PersistAsyncSchema = (props) => {
|
|
|
4397
4386
|
if (persistAsyncSchemaType === "blob") {
|
|
4398
4387
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4399
4388
|
PersistAsyncBlobSchema_default,
|
|
4400
|
-
{
|
|
4401
|
-
...props
|
|
4402
|
-
}
|
|
4389
|
+
__spreadValues({}, props)
|
|
4403
4390
|
);
|
|
4404
4391
|
}
|
|
4405
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default, {
|
|
4392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default, __spreadValues({}, props));
|
|
4406
4393
|
};
|
|
4407
4394
|
PersistAsyncSchema.defaultProps = {
|
|
4408
4395
|
required: false
|
|
@@ -4427,7 +4414,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
|
4427
4414
|
var PromotedOneOfCheckboxControl = (props) => {
|
|
4428
4415
|
const { id, selection, setSelection } = props;
|
|
4429
4416
|
const { promoted, other, checkedMeans } = props.promotion;
|
|
4430
|
-
const title = checkedMeans === "other" ? other.title : promoted
|
|
4417
|
+
const title = checkedMeans === "other" ? other.title : (promoted == null ? void 0 : promoted.title) || props.promotedOneOf.title;
|
|
4431
4418
|
const selectionWhenChecked = checkedMeans === "other" ? "other" : "promoted";
|
|
4432
4419
|
const selectionWhenUnchecked = checkedMeans === "other" ? "promoted" : "other";
|
|
4433
4420
|
const checked = selection === selectionWhenChecked;
|
|
@@ -4443,21 +4430,20 @@ var PromotedOneOfCheckboxControl_default = PromotedOneOfCheckboxControl;
|
|
|
4443
4430
|
var import_components15 = require("@transferwise/components");
|
|
4444
4431
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4445
4432
|
var PromotedOneOfRadioControl = (props) => {
|
|
4433
|
+
var _a, _b;
|
|
4446
4434
|
const { id, selection, setSelection, promotion, promotedOneOf, title } = props;
|
|
4447
4435
|
const radios = [
|
|
4448
|
-
{
|
|
4436
|
+
__spreadValues({
|
|
4449
4437
|
value: "promoted",
|
|
4450
4438
|
// TODO: LOW avoid type assertion below the expression may be nullish, but "label" cannot be
|
|
4451
|
-
label: promotion.promoted
|
|
4452
|
-
secondary: promotion.promoted
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
{
|
|
4439
|
+
label: ((_a = promotion.promoted) == null ? void 0 : _a.title) || promotedOneOf.title,
|
|
4440
|
+
secondary: ((_b = promotion.promoted) == null ? void 0 : _b.description) || promotedOneOf.description
|
|
4441
|
+
}, getAvatarPropertyForRadioOption(promotedOneOf)),
|
|
4442
|
+
__spreadValues({
|
|
4456
4443
|
value: "other",
|
|
4457
4444
|
label: promotion.other.title,
|
|
4458
|
-
secondary: promotion.other.description
|
|
4459
|
-
|
|
4460
|
-
}
|
|
4445
|
+
secondary: promotion.other.description
|
|
4446
|
+
}, getAvatarPropertyForRadioOption(promotion.other))
|
|
4461
4447
|
];
|
|
4462
4448
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "form-group", children: [
|
|
4463
4449
|
title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("label", { className: "control-label", htmlFor: id, children: title }),
|
|
@@ -4484,9 +4470,9 @@ var PromotedOneOfControl = (props) => {
|
|
|
4484
4470
|
const controlType = props.promotion.control || "radio";
|
|
4485
4471
|
switch (controlType) {
|
|
4486
4472
|
case "radio":
|
|
4487
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default, {
|
|
4473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default, __spreadValues({}, props));
|
|
4488
4474
|
case "checkbox":
|
|
4489
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default, {
|
|
4475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default, __spreadValues({}, props));
|
|
4490
4476
|
default:
|
|
4491
4477
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
|
|
4492
4478
|
}
|
|
@@ -4501,8 +4487,9 @@ var PromotedOneOfControl_default = PromotedOneOfControl;
|
|
|
4501
4487
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4502
4488
|
var isPromoted = (schema) => schema.promoted === true;
|
|
4503
4489
|
var PromotedOneOfSchema = (props) => {
|
|
4490
|
+
var _a;
|
|
4504
4491
|
const [selection, setSelection] = (0, import_react19.useState)(
|
|
4505
|
-
getSelectionFromModel(props.schema, props.model) || props.schema.promotion
|
|
4492
|
+
getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
|
|
4506
4493
|
);
|
|
4507
4494
|
const promotedAlert = props.schema.alert;
|
|
4508
4495
|
const promotedOneOf = props.schema.oneOf.find(isPromoted);
|
|
@@ -4521,23 +4508,23 @@ var PromotedOneOfSchema = (props) => {
|
|
|
4521
4508
|
setSelection
|
|
4522
4509
|
}
|
|
4523
4510
|
),
|
|
4524
|
-
selection === "promoted" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ObjectSchema_default, {
|
|
4525
|
-
selection === "other" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(GenericSchema_default, {
|
|
4511
|
+
selection === "promoted" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ObjectSchema_default, __spreadProps(__spreadValues({}, props), { schema: promotedObjectSchema })),
|
|
4512
|
+
selection === "other" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(GenericSchema_default, __spreadProps(__spreadValues({}, props), { schema: otherOneOf }))
|
|
4526
4513
|
] });
|
|
4527
4514
|
};
|
|
4528
4515
|
function getPromotedObjectSchema(promotedSchema) {
|
|
4529
|
-
return {
|
|
4530
|
-
...promotedSchema,
|
|
4516
|
+
return __spreadProps(__spreadValues({}, promotedSchema), {
|
|
4531
4517
|
// We don't need to show these since they are already displayed in the radio option
|
|
4532
4518
|
title: void 0,
|
|
4533
4519
|
description: void 0
|
|
4534
|
-
};
|
|
4520
|
+
});
|
|
4535
4521
|
}
|
|
4536
4522
|
function getOtherOneOf(schema) {
|
|
4537
|
-
|
|
4538
|
-
const
|
|
4523
|
+
var _a, _b, _c;
|
|
4524
|
+
const other = ((_a = schema.promotion) == null ? void 0 : _a.displayTwice) ? [...schema.oneOf] : schema.oneOf.filter((one) => !isPromoted(one));
|
|
4525
|
+
const title = (_c = (_b = schema.promotion) == null ? void 0 : _b.other.heading) == null ? void 0 : _c.text;
|
|
4539
4526
|
if (other.length === 1) {
|
|
4540
|
-
return {
|
|
4527
|
+
return __spreadProps(__spreadValues({}, other[0]), { title });
|
|
4541
4528
|
}
|
|
4542
4529
|
if (other.length > 1) {
|
|
4543
4530
|
return {
|
|
@@ -4609,7 +4596,7 @@ function getSelectedOneOf(schema, model) {
|
|
|
4609
4596
|
function getValueFromOption(option) {
|
|
4610
4597
|
const text = option.title && option.description ? `${option.title} - ${option.description}` : option.title || "";
|
|
4611
4598
|
const icon = getAvatarPropertyForRadioOption({ icon: option.icon });
|
|
4612
|
-
return icon
|
|
4599
|
+
return (icon == null ? void 0 : icon.avatar) ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
4613
4600
|
icon.avatar,
|
|
4614
4601
|
" ",
|
|
4615
4602
|
text
|
|
@@ -4666,7 +4653,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4666
4653
|
} else if (response.status === 422) {
|
|
4667
4654
|
setValidationAsyncErrors(isString(jsonResponse.message) ? jsonResponse.message : null);
|
|
4668
4655
|
}
|
|
4669
|
-
} catch {
|
|
4656
|
+
} catch (e) {
|
|
4670
4657
|
onEvent("Dynamic Flow - ValidationAsync", { status: "failure" });
|
|
4671
4658
|
}
|
|
4672
4659
|
};
|
|
@@ -4684,11 +4671,10 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4684
4671
|
}
|
|
4685
4672
|
};
|
|
4686
4673
|
const onValidationAsyncChange = (parameters) => {
|
|
4687
|
-
onChange({
|
|
4688
|
-
...parameters,
|
|
4674
|
+
onChange(__spreadProps(__spreadValues({}, parameters), {
|
|
4689
4675
|
triggerSchema: schema,
|
|
4690
4676
|
triggerModel: parameters.model
|
|
4691
|
-
});
|
|
4677
|
+
}));
|
|
4692
4678
|
setValidationAsyncErrors(null);
|
|
4693
4679
|
setValidationAsyncSuccessMessage(null);
|
|
4694
4680
|
setValidationAsyncModel(parameters.model);
|
|
@@ -4703,7 +4689,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4703
4689
|
required,
|
|
4704
4690
|
schema
|
|
4705
4691
|
};
|
|
4706
|
-
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default, {
|
|
4692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeSchemaProps));
|
|
4707
4693
|
};
|
|
4708
4694
|
ValidationAsyncSchema.defaultProps = { required: false };
|
|
4709
4695
|
var ValidationAsyncSchema_default = ValidationAsyncSchema;
|
|
@@ -4713,7 +4699,7 @@ var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
|
4713
4699
|
var import_react22 = require("react");
|
|
4714
4700
|
var GenericSchemaForm = (props) => {
|
|
4715
4701
|
const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
|
|
4716
|
-
const schemaProps = {
|
|
4702
|
+
const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
|
|
4717
4703
|
const type = getSchemaType(schema);
|
|
4718
4704
|
const log = useLogger();
|
|
4719
4705
|
(0, import_react21.useEffect)(() => {
|
|
@@ -4726,25 +4712,25 @@ var GenericSchemaForm = (props) => {
|
|
|
4726
4712
|
}, [JSON.stringify(schema), JSON.stringify(model), JSON.stringify(errors), type, log]);
|
|
4727
4713
|
switch (type) {
|
|
4728
4714
|
case "readOnly":
|
|
4729
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default, {
|
|
4715
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default, __spreadValues({}, schemaProps));
|
|
4730
4716
|
case "persistAsync":
|
|
4731
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default, {
|
|
4717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4732
4718
|
case "validationAsync":
|
|
4733
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default, {
|
|
4719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default, __spreadValues({}, schemaProps));
|
|
4734
4720
|
case "basic": {
|
|
4735
|
-
const basicTypeProps = { infoMessage: null,
|
|
4736
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default, {
|
|
4721
|
+
const basicTypeProps = __spreadValues({ infoMessage: null }, schemaProps);
|
|
4722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
|
|
4737
4723
|
}
|
|
4738
4724
|
case "object":
|
|
4739
|
-
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default, {
|
|
4725
|
+
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema) }));
|
|
4740
4726
|
case "array":
|
|
4741
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default, {
|
|
4727
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
|
|
4742
4728
|
case "promotedOneOf":
|
|
4743
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default, {
|
|
4729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4744
4730
|
case "oneOf":
|
|
4745
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default, {
|
|
4731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default, __spreadValues({}, schemaProps));
|
|
4746
4732
|
case "allOf":
|
|
4747
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default, {
|
|
4733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default, __spreadValues({}, schemaProps));
|
|
4748
4734
|
}
|
|
4749
4735
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, {});
|
|
4750
4736
|
};
|
|
@@ -4772,100 +4758,69 @@ var isValidGenericSchema = (schema, model, errors) => {
|
|
|
4772
4758
|
return false;
|
|
4773
4759
|
};
|
|
4774
4760
|
|
|
4775
|
-
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
4776
|
-
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4777
|
-
var JsonSchemaForm = (props) => {
|
|
4778
|
-
const schemaProps = {
|
|
4779
|
-
model: null,
|
|
4780
|
-
errors: null,
|
|
4781
|
-
disabled: false,
|
|
4782
|
-
baseUrl: "",
|
|
4783
|
-
...props
|
|
4784
|
-
};
|
|
4785
|
-
if (useHasHttpClientProvider() || schemaProps.baseUrl == null) {
|
|
4786
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, { ...schemaProps });
|
|
4787
|
-
}
|
|
4788
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4789
|
-
Providers,
|
|
4790
|
-
{
|
|
4791
|
-
baseUrl: schemaProps.baseUrl,
|
|
4792
|
-
onEvent: schemaProps.onEvent,
|
|
4793
|
-
onLog: schemaProps.onLog,
|
|
4794
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, { ...schemaProps })
|
|
4795
|
-
}
|
|
4796
|
-
);
|
|
4797
|
-
};
|
|
4798
|
-
var JsonSchemaForm_default = JsonSchemaForm;
|
|
4799
|
-
var Providers = ({ baseUrl, onEvent, onLog, children }) => {
|
|
4800
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog ?? noop2, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4801
|
-
EventsContextProvider,
|
|
4802
|
-
{
|
|
4803
|
-
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
4804
|
-
onEvent: onEvent ?? noop2,
|
|
4805
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children })
|
|
4806
|
-
}
|
|
4807
|
-
) });
|
|
4808
|
-
};
|
|
4809
|
-
var noop2 = () => {
|
|
4810
|
-
};
|
|
4811
|
-
|
|
4812
4761
|
// src/layout/form/DynamicForm.tsx
|
|
4813
|
-
var
|
|
4814
|
-
var DynamicForm = (
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4762
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4763
|
+
var DynamicForm = ({
|
|
4764
|
+
component,
|
|
4765
|
+
model = null,
|
|
4766
|
+
errors = null,
|
|
4767
|
+
submitted,
|
|
4768
|
+
onModelChange,
|
|
4769
|
+
onPersistAsync
|
|
4770
|
+
}) => {
|
|
4771
|
+
const formSchema = component.schema;
|
|
4772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: getMargin(component.margin || "md"), children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4773
|
+
GenericSchema_default,
|
|
4819
4774
|
{
|
|
4820
4775
|
schema: formSchema,
|
|
4821
|
-
model
|
|
4822
|
-
|
|
4823
|
-
|
|
4776
|
+
model,
|
|
4777
|
+
errors,
|
|
4778
|
+
submitted,
|
|
4824
4779
|
onChange: (parameters) => {
|
|
4825
|
-
|
|
4780
|
+
onModelChange(__spreadValues({ formSchema }, parameters));
|
|
4826
4781
|
},
|
|
4827
|
-
onPersistAsync
|
|
4782
|
+
onPersistAsync
|
|
4828
4783
|
}
|
|
4829
4784
|
) });
|
|
4830
4785
|
};
|
|
4831
4786
|
var DynamicForm_default = DynamicForm;
|
|
4832
4787
|
|
|
4833
4788
|
// src/layout/heading/DynamicHeading.tsx
|
|
4834
|
-
var
|
|
4789
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
4835
4790
|
var DynamicHeading = (props) => {
|
|
4836
4791
|
const { text, size = "md", align = "left", margin = "md" } = props.component;
|
|
4837
4792
|
const classes = getTextAlignmentAndMargin({ align, margin });
|
|
4838
4793
|
switch (size) {
|
|
4839
4794
|
case "xs":
|
|
4840
|
-
return /* @__PURE__ */ (0,
|
|
4795
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h5", { className: classes, children: text });
|
|
4841
4796
|
case "sm":
|
|
4842
|
-
return /* @__PURE__ */ (0,
|
|
4797
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h4", { className: classes, children: text });
|
|
4843
4798
|
case "lg":
|
|
4844
|
-
return /* @__PURE__ */ (0,
|
|
4799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h2", { className: classes, children: text });
|
|
4845
4800
|
case "xl":
|
|
4846
|
-
return /* @__PURE__ */ (0,
|
|
4801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h1", { className: classes, children: text });
|
|
4847
4802
|
case "md":
|
|
4848
4803
|
default:
|
|
4849
|
-
return /* @__PURE__ */ (0,
|
|
4804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: classes, children: text });
|
|
4850
4805
|
}
|
|
4851
4806
|
};
|
|
4852
4807
|
var DynamicHeading_default = DynamicHeading;
|
|
4853
4808
|
|
|
4854
4809
|
// src/layout/markdown/DynamicMarkdown.tsx
|
|
4855
4810
|
var import_components17 = require("@transferwise/components");
|
|
4856
|
-
var
|
|
4811
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
4857
4812
|
var DynamicMarkdown = ({ component }) => {
|
|
4858
4813
|
const { content, align, margin } = component;
|
|
4859
|
-
return /* @__PURE__ */ (0,
|
|
4814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components17.Markdown, { config: { link: { target: "_blank" } }, children: content }) });
|
|
4860
4815
|
};
|
|
4861
4816
|
var DynamicInfo = ({ component }) => {
|
|
4862
|
-
return /* @__PURE__ */ (0,
|
|
4817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getTextAlignmentAndMargin(component), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components17.Markdown, { config: { link: { target: "_blank" } }, children: component.markdown }) });
|
|
4863
4818
|
};
|
|
4864
4819
|
|
|
4865
4820
|
// src/layout/image/DynamicImage.tsx
|
|
4866
4821
|
var import_components18 = require("@transferwise/components");
|
|
4867
4822
|
var import_react23 = require("react");
|
|
4868
|
-
var
|
|
4823
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
4869
4824
|
var DynamicImage = ({ component: image }) => {
|
|
4870
4825
|
const { url, size, text, margin, accessibilityDescription } = image;
|
|
4871
4826
|
const httpClient = useHttpClient();
|
|
@@ -4882,7 +4837,7 @@ var DynamicImage = ({ component: image }) => {
|
|
|
4882
4837
|
if (!imageSource) {
|
|
4883
4838
|
return null;
|
|
4884
4839
|
}
|
|
4885
|
-
return /* @__PURE__ */ (0,
|
|
4840
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components18.Image, __spreadValues({ className: `img-responsive ${getMargin(margin || "md")}` }, imageProps)) });
|
|
4886
4841
|
};
|
|
4887
4842
|
var readImageBlobAsDataURL = (imageBlob) => {
|
|
4888
4843
|
return new Promise((resolve, reject) => {
|
|
@@ -4893,8 +4848,9 @@ var readImageBlobAsDataURL = (imageBlob) => {
|
|
|
4893
4848
|
});
|
|
4894
4849
|
};
|
|
4895
4850
|
var getImageSource = async (httpClient, imageUrl) => {
|
|
4851
|
+
var _a;
|
|
4896
4852
|
try {
|
|
4897
|
-
if (isRelativePath(imageUrl) || imageUrl
|
|
4853
|
+
if (isRelativePath(imageUrl) || (imageUrl == null ? void 0 : imageUrl.indexOf(`${(_a = window == null ? void 0 : window.location) == null ? void 0 : _a.origin}/`)) === 0) {
|
|
4898
4854
|
return httpClient(imageUrl, {
|
|
4899
4855
|
method: "GET",
|
|
4900
4856
|
headers: { "Content-Type": "image/image" },
|
|
@@ -4907,7 +4863,7 @@ var getImageSource = async (httpClient, imageUrl) => {
|
|
|
4907
4863
|
}).then(readImageBlobAsDataURL).catch(() => imageUrl);
|
|
4908
4864
|
}
|
|
4909
4865
|
return imageUrl;
|
|
4910
|
-
} catch {
|
|
4866
|
+
} catch (e) {
|
|
4911
4867
|
return imageUrl;
|
|
4912
4868
|
}
|
|
4913
4869
|
};
|
|
@@ -4915,47 +4871,47 @@ var DynamicImage_default = DynamicImage;
|
|
|
4915
4871
|
|
|
4916
4872
|
// src/layout/instructions/DynamicInstructions.tsx
|
|
4917
4873
|
var import_components19 = require("@transferwise/components");
|
|
4918
|
-
var
|
|
4874
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
4919
4875
|
var doContext = ["positive", "neutral"];
|
|
4920
4876
|
var dontContext = ["warning", "negative"];
|
|
4921
4877
|
var DynamicInstructions = ({ component }) => {
|
|
4922
4878
|
const { items } = component;
|
|
4923
4879
|
const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
|
|
4924
4880
|
const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
|
|
4925
|
-
return /* @__PURE__ */ (0,
|
|
4926
|
-
component.title ? /* @__PURE__ */ (0,
|
|
4927
|
-
/* @__PURE__ */ (0,
|
|
4881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: getMargin(component.margin || "md"), children: [
|
|
4882
|
+
component.title ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components19.Header, { title: component.title }) : null,
|
|
4883
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components19.InstructionsList, { dos, donts })
|
|
4928
4884
|
] });
|
|
4929
4885
|
};
|
|
4930
4886
|
var DynamicInstructions_default = DynamicInstructions;
|
|
4931
4887
|
|
|
4932
4888
|
// src/layout/DynamicLayout.tsx
|
|
4933
|
-
var
|
|
4889
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4934
4890
|
var getKey = (component) => JSON.stringify(component);
|
|
4935
4891
|
var DynamicLayout = (props) => {
|
|
4936
4892
|
const { components, model, submitted, errors, onModelChange, onAction, onPersistAsync, baseUrl } = props;
|
|
4937
4893
|
const renderComponent = (component) => {
|
|
4938
4894
|
switch (component.type) {
|
|
4939
4895
|
case "heading":
|
|
4940
|
-
return /* @__PURE__ */ (0,
|
|
4896
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicHeading_default, { component }, getKey(component));
|
|
4941
4897
|
case "paragraph":
|
|
4942
|
-
return /* @__PURE__ */ (0,
|
|
4898
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicParagraph_default, { component }, getKey(component));
|
|
4943
4899
|
case "image":
|
|
4944
|
-
return /* @__PURE__ */ (0,
|
|
4900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicImage_default, { component }, getKey(component));
|
|
4945
4901
|
case "alert":
|
|
4946
|
-
return /* @__PURE__ */ (0,
|
|
4902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicAlert_default, { component }, getKey(component));
|
|
4947
4903
|
case "review":
|
|
4948
|
-
return /* @__PURE__ */ (0,
|
|
4904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicReview_default, { component, onAction }, getKey(component));
|
|
4949
4905
|
case "divider":
|
|
4950
|
-
return /* @__PURE__ */ (0,
|
|
4906
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicDivider_default, { component }, getKey(component));
|
|
4951
4907
|
case "info":
|
|
4952
|
-
return /* @__PURE__ */ (0,
|
|
4908
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicInfo, { component }, getKey(component));
|
|
4953
4909
|
case "instructions":
|
|
4954
|
-
return /* @__PURE__ */ (0,
|
|
4910
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicInstructions_default, { component }, getKey(component));
|
|
4955
4911
|
case "markdown":
|
|
4956
|
-
return /* @__PURE__ */ (0,
|
|
4912
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicMarkdown, { component }, getKey(component));
|
|
4957
4913
|
case "columns":
|
|
4958
|
-
return /* @__PURE__ */ (0,
|
|
4914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4959
4915
|
DynamicColumns_default,
|
|
4960
4916
|
{
|
|
4961
4917
|
component,
|
|
@@ -4969,7 +4925,7 @@ var DynamicLayout = (props) => {
|
|
|
4969
4925
|
getKey(component)
|
|
4970
4926
|
);
|
|
4971
4927
|
case "form":
|
|
4972
|
-
return /* @__PURE__ */ (0,
|
|
4928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4973
4929
|
DynamicForm_default,
|
|
4974
4930
|
{
|
|
4975
4931
|
component,
|
|
@@ -4979,12 +4935,12 @@ var DynamicLayout = (props) => {
|
|
|
4979
4935
|
onModelChange,
|
|
4980
4936
|
onPersistAsync
|
|
4981
4937
|
},
|
|
4982
|
-
getKey({
|
|
4938
|
+
getKey(__spreadProps(__spreadValues({}, component), { errors: errors != null ? errors : null }))
|
|
4983
4939
|
);
|
|
4984
4940
|
case "button":
|
|
4985
|
-
return /* @__PURE__ */ (0,
|
|
4941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
4986
4942
|
case "box":
|
|
4987
|
-
return /* @__PURE__ */ (0,
|
|
4943
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
4988
4944
|
DynamicBox_default,
|
|
4989
4945
|
{
|
|
4990
4946
|
component,
|
|
@@ -4998,34 +4954,34 @@ var DynamicLayout = (props) => {
|
|
|
4998
4954
|
getKey(component)
|
|
4999
4955
|
);
|
|
5000
4956
|
case "decision":
|
|
5001
|
-
return /* @__PURE__ */ (0,
|
|
4957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicDecision_default, { component, onAction }, getKey(component));
|
|
5002
4958
|
case "external":
|
|
5003
|
-
return /* @__PURE__ */ (0,
|
|
4959
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicExternal_default, { component, onAction }, getKey(component));
|
|
5004
4960
|
case "list":
|
|
5005
4961
|
case "status-list":
|
|
5006
|
-
return /* @__PURE__ */ (0,
|
|
4962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicStatusList_default, { component, onAction }, getKey(component));
|
|
5007
4963
|
case "loading-indicator":
|
|
5008
|
-
return /* @__PURE__ */ (0,
|
|
4964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicLoadingIndicator_default, { component }, getKey(component));
|
|
5009
4965
|
case "search":
|
|
5010
|
-
return /* @__PURE__ */ (0,
|
|
4966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DynamicSearch_default, { component, onAction }, getKey(component));
|
|
5011
4967
|
default:
|
|
5012
|
-
return /* @__PURE__ */ (0,
|
|
4968
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", {}, getKey(component));
|
|
5013
4969
|
}
|
|
5014
4970
|
};
|
|
5015
4971
|
if (useHasHttpClientProvider() || baseUrl == null) {
|
|
5016
|
-
return /* @__PURE__ */ (0,
|
|
4972
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: components.map(renderComponent) });
|
|
5017
4973
|
} else {
|
|
5018
|
-
return /* @__PURE__ */ (0,
|
|
4974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children: components.map(renderComponent) });
|
|
5019
4975
|
}
|
|
5020
4976
|
};
|
|
5021
4977
|
var DynamicLayout_default = DynamicLayout;
|
|
5022
4978
|
|
|
5023
4979
|
// src/layout/list/DynamicStatusList.tsx
|
|
5024
4980
|
var import_components20 = require("@transferwise/components");
|
|
5025
|
-
var
|
|
4981
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5026
4982
|
var DynamicStatusList = ({ component }) => {
|
|
5027
|
-
return /* @__PURE__ */ (0,
|
|
5028
|
-
component.title ? /* @__PURE__ */ (0,
|
|
4983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: getMargin(component.margin || "md"), children: [
|
|
4984
|
+
component.title ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("h4", { className: "m-b-2", children: [
|
|
5029
4985
|
" ",
|
|
5030
4986
|
component.title,
|
|
5031
4987
|
" "
|
|
@@ -5034,14 +4990,12 @@ var DynamicStatusList = ({ component }) => {
|
|
|
5034
4990
|
] });
|
|
5035
4991
|
};
|
|
5036
4992
|
var mapListItemToSummary = ({ title, description, icon, status }) => {
|
|
5037
|
-
const props = {
|
|
4993
|
+
const props = __spreadValues(__spreadValues({
|
|
5038
4994
|
key: `${title}/${description || ""}`,
|
|
5039
4995
|
title,
|
|
5040
|
-
description
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
};
|
|
5044
|
-
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Summary, { ...props });
|
|
4996
|
+
description
|
|
4997
|
+
}, (icon == null ? void 0 : icon.name) ? { icon: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicIcon_default, { type: icon.name }) } : {}), status ? { status: statusMap[status] } : {});
|
|
4998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components20.Summary, __spreadValues({}, props));
|
|
5045
4999
|
};
|
|
5046
5000
|
var statusListMap = {
|
|
5047
5001
|
done: "done",
|
|
@@ -5053,15 +5007,15 @@ var legacyStatusMap = {
|
|
|
5053
5007
|
warning: "pending",
|
|
5054
5008
|
neutral: "notDone"
|
|
5055
5009
|
};
|
|
5056
|
-
var statusMap = {
|
|
5010
|
+
var statusMap = __spreadValues(__spreadValues({}, statusListMap), legacyStatusMap);
|
|
5057
5011
|
var DynamicStatusList_default = DynamicStatusList;
|
|
5058
5012
|
|
|
5059
5013
|
// src/layout/loadingIndicator/DynamicLoadingIndicator.tsx
|
|
5060
5014
|
var import_components21 = require("@transferwise/components");
|
|
5061
|
-
var
|
|
5015
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5062
5016
|
var DynamicLoadingIndicator = ({ component }) => {
|
|
5063
5017
|
const { margin, size = "md" } = component;
|
|
5064
|
-
return /* @__PURE__ */ (0,
|
|
5018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
5065
5019
|
import_components21.Loader,
|
|
5066
5020
|
{
|
|
5067
5021
|
size,
|
|
@@ -5098,15 +5052,15 @@ var import_components22 = require("@transferwise/components");
|
|
|
5098
5052
|
var import_react24 = require("react");
|
|
5099
5053
|
function useSnackBarIfAvailable() {
|
|
5100
5054
|
const context = (0, import_react24.useContext)(import_components22.SnackbarContext);
|
|
5101
|
-
return context ? context.createSnackbar :
|
|
5055
|
+
return context ? context.createSnackbar : noop2;
|
|
5102
5056
|
}
|
|
5103
|
-
function
|
|
5057
|
+
function noop2() {
|
|
5104
5058
|
}
|
|
5105
5059
|
|
|
5106
5060
|
// src/layout/paragraph/DynamicParagraph.tsx
|
|
5107
|
-
var
|
|
5108
|
-
var DynamicParagraph = ({ component }) => component.control === "copyable" ? /* @__PURE__ */ (0,
|
|
5109
|
-
var BasicDynamicParagraph = ({ component }) => /* @__PURE__ */ (0,
|
|
5061
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5062
|
+
var DynamicParagraph = ({ component }) => component.control === "copyable" ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(CopyableDynamicParagraph, { component }) : /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(BasicDynamicParagraph, { component });
|
|
5063
|
+
var BasicDynamicParagraph = ({ component }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("p", { className: getTextAlignmentAndMargin(component), children: [
|
|
5110
5064
|
" ",
|
|
5111
5065
|
component.text,
|
|
5112
5066
|
" "
|
|
@@ -5116,11 +5070,12 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5116
5070
|
const createSnackbar = useSnackBarIfAvailable();
|
|
5117
5071
|
const { text } = component;
|
|
5118
5072
|
const copy = () => {
|
|
5119
|
-
|
|
5073
|
+
var _a;
|
|
5074
|
+
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop3);
|
|
5120
5075
|
};
|
|
5121
5076
|
const classNames7 = getTextAlignmentAndMargin({ align: component.align }) + " form-control";
|
|
5122
|
-
return /* @__PURE__ */ (0,
|
|
5123
|
-
/* @__PURE__ */ (0,
|
|
5077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
5078
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5124
5079
|
"input",
|
|
5125
5080
|
{
|
|
5126
5081
|
type: "text",
|
|
@@ -5130,16 +5085,16 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5130
5085
|
style: { textOverflow: "ellipsis" }
|
|
5131
5086
|
}
|
|
5132
5087
|
),
|
|
5133
|
-
/* @__PURE__ */ (0,
|
|
5088
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components23.Button, { block: true, onClick: copy, className: getMargin("sm"), children: formatMessage(DynamicParagraph_messages_default.copy) })
|
|
5134
5089
|
] });
|
|
5135
5090
|
};
|
|
5136
|
-
function
|
|
5091
|
+
function noop3() {
|
|
5137
5092
|
}
|
|
5138
5093
|
var DynamicParagraph_default = DynamicParagraph;
|
|
5139
5094
|
|
|
5140
5095
|
// src/layout/review/DynamicReview.tsx
|
|
5141
5096
|
var import_components24 = require("@transferwise/components");
|
|
5142
|
-
var
|
|
5097
|
+
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
5143
5098
|
var getDefinitions = (orientation, review) => {
|
|
5144
5099
|
return review.fields.map(
|
|
5145
5100
|
({ label, value, help }, index) => {
|
|
@@ -5153,14 +5108,14 @@ var getDefinitions = (orientation, review) => {
|
|
|
5153
5108
|
};
|
|
5154
5109
|
var getFieldValue = (value, help, orientation) => {
|
|
5155
5110
|
if (help) {
|
|
5156
|
-
return orientation === "HORIZONTAL_RIGHT_ALIGNED" ? /* @__PURE__ */ (0,
|
|
5157
|
-
/* @__PURE__ */ (0,
|
|
5111
|
+
return orientation === "HORIZONTAL_RIGHT_ALIGNED" ? /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
5112
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Help_default, { help }),
|
|
5158
5113
|
" ",
|
|
5159
5114
|
value
|
|
5160
|
-
] }) : /* @__PURE__ */ (0,
|
|
5115
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
5161
5116
|
value,
|
|
5162
5117
|
" ",
|
|
5163
|
-
/* @__PURE__ */ (0,
|
|
5118
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Help_default, { help })
|
|
5164
5119
|
] });
|
|
5165
5120
|
}
|
|
5166
5121
|
return value;
|
|
@@ -5173,7 +5128,7 @@ var DynamicReview = (props) => {
|
|
|
5173
5128
|
const review = props.component;
|
|
5174
5129
|
const margin = getMargin(review.margin || "xs");
|
|
5175
5130
|
const getReviewAction = (action) => {
|
|
5176
|
-
return /* @__PURE__ */ (0,
|
|
5131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
|
|
5177
5132
|
"a",
|
|
5178
5133
|
{
|
|
5179
5134
|
href: action.url,
|
|
@@ -5188,12 +5143,12 @@ var DynamicReview = (props) => {
|
|
|
5188
5143
|
);
|
|
5189
5144
|
};
|
|
5190
5145
|
const orientation = getReviewLayout(review);
|
|
5191
|
-
return /* @__PURE__ */ (0,
|
|
5192
|
-
review.title && /* @__PURE__ */ (0,
|
|
5146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
|
|
5147
|
+
review.title && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("h6", { className: `m-b-2 ${margin}`, children: [
|
|
5193
5148
|
review.title,
|
|
5194
5149
|
review.action && getReviewAction(review.action)
|
|
5195
5150
|
] }),
|
|
5196
|
-
/* @__PURE__ */ (0,
|
|
5151
|
+
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: review.title ? "" : margin, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components24.DefinitionList, { layout: orientation, definitions: getDefinitions(orientation, review) }) })
|
|
5197
5152
|
] });
|
|
5198
5153
|
};
|
|
5199
5154
|
var DynamicReview_default = DynamicReview;
|
|
@@ -5203,11 +5158,11 @@ var import_react26 = require("react");
|
|
|
5203
5158
|
|
|
5204
5159
|
// src/layout/search/SearchInput.tsx
|
|
5205
5160
|
var import_components25 = require("@transferwise/components");
|
|
5206
|
-
var
|
|
5161
|
+
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
5207
5162
|
var SearchInput = ({ title, value, onFocus, onChange }) => {
|
|
5208
|
-
return /* @__PURE__ */ (0,
|
|
5163
|
+
return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("label", { className: "control-label d-inline", children: [
|
|
5209
5164
|
title,
|
|
5210
|
-
/* @__PURE__ */ (0,
|
|
5165
|
+
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
5211
5166
|
import_components25.Input,
|
|
5212
5167
|
{
|
|
5213
5168
|
type: "text",
|
|
@@ -5239,13 +5194,13 @@ var ErrorBoundary_messages_default = (0, import_react_intl18.defineMessages)({
|
|
|
5239
5194
|
});
|
|
5240
5195
|
|
|
5241
5196
|
// src/layout/search/SearchResults.tsx
|
|
5242
|
-
var
|
|
5197
|
+
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
5243
5198
|
var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
5244
5199
|
if (results.length === 0) {
|
|
5245
|
-
return /* @__PURE__ */ (0,
|
|
5200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("p", { className: "m-t-2", children: emptyMessage });
|
|
5246
5201
|
}
|
|
5247
|
-
return /* @__PURE__ */ (0,
|
|
5248
|
-
return /* @__PURE__ */ (0,
|
|
5202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components26.NavigationOptionsList, { children: results.map((result) => {
|
|
5203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
5249
5204
|
import_components26.NavigationOption,
|
|
5250
5205
|
{
|
|
5251
5206
|
title: result.title,
|
|
@@ -5261,10 +5216,10 @@ var SearchResults = ({ results, emptyMessage, onSelect }) => {
|
|
|
5261
5216
|
};
|
|
5262
5217
|
var ErrorResult = ({ onRetrySearch }) => {
|
|
5263
5218
|
const intl = (0, import_react_intl19.useIntl)();
|
|
5264
|
-
return /* @__PURE__ */ (0,
|
|
5219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "m-t-2", children: [
|
|
5265
5220
|
intl.formatMessage(ErrorBoundary_messages_default.errorAlert),
|
|
5266
5221
|
"\xA0",
|
|
5267
|
-
/* @__PURE__ */ (0,
|
|
5222
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
5268
5223
|
"a",
|
|
5269
5224
|
{
|
|
5270
5225
|
href: "/",
|
|
@@ -5289,7 +5244,8 @@ var useSearch = (defaultSearchConfig) => {
|
|
|
5289
5244
|
const httpClient = useHttpClient();
|
|
5290
5245
|
const search = (0, import_react25.useCallback)(
|
|
5291
5246
|
async (query, { url, method, param } = defaultSearchConfig) => {
|
|
5292
|
-
|
|
5247
|
+
var _a;
|
|
5248
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
5293
5249
|
if (!query) {
|
|
5294
5250
|
setState({ status: "idle" });
|
|
5295
5251
|
return;
|
|
@@ -5349,7 +5305,7 @@ var addQueryParameter = (url, key, value) => {
|
|
|
5349
5305
|
};
|
|
5350
5306
|
|
|
5351
5307
|
// src/layout/search/DynamicSearch.tsx
|
|
5352
|
-
var
|
|
5308
|
+
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
5353
5309
|
var DEBOUNCE_TIME = 400;
|
|
5354
5310
|
var DynamicSearch = ({ component, onAction }) => {
|
|
5355
5311
|
const [query, setQuery] = (0, import_react26.useState)("");
|
|
@@ -5383,22 +5339,23 @@ var DynamicSearch = ({ component, onAction }) => {
|
|
|
5383
5339
|
setQuery(query);
|
|
5384
5340
|
void search(query);
|
|
5385
5341
|
};
|
|
5386
|
-
return /* @__PURE__ */ (0,
|
|
5387
|
-
/* @__PURE__ */ (0,
|
|
5388
|
-
status === "loading" && /* @__PURE__ */ (0,
|
|
5389
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
5390
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
5342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: getMargin(margin), children: [
|
|
5343
|
+
/* @__PURE__ */ (0, import_jsx_runtime52.jsx)(SearchInput, { title, value: query, onChange, onFocus: onSearchStart }),
|
|
5344
|
+
status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(DynamicLoadingIndicator_default, { component: { type: "loading-indicator", size: "sm" } }),
|
|
5345
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ErrorResult, { onRetrySearch }),
|
|
5346
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(SearchResults, { results, emptyMessage, onSelect: onResultSelected })
|
|
5391
5347
|
] });
|
|
5392
5348
|
};
|
|
5393
5349
|
var DynamicSearch_default = DynamicSearch;
|
|
5394
5350
|
|
|
5395
5351
|
// src/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
|
|
5396
|
-
var
|
|
5352
|
+
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
5397
5353
|
var isNullish = (value) => isNull(value) || isUndefined(value);
|
|
5398
5354
|
var getDefaultValue = (schema) => {
|
|
5399
5355
|
return schema.type === "boolean" && isNullish(schema.default) ? false : schema.default;
|
|
5400
5356
|
};
|
|
5401
5357
|
var BasicTypeSchema = (props) => {
|
|
5358
|
+
var _a, _b, _c;
|
|
5402
5359
|
const onChange = (newModel) => {
|
|
5403
5360
|
setChanged(true);
|
|
5404
5361
|
setModelAndBroadcast(sanitiseModel(newModel), "user");
|
|
@@ -5429,8 +5386,8 @@ var BasicTypeSchema = (props) => {
|
|
|
5429
5386
|
props.onBlur();
|
|
5430
5387
|
}
|
|
5431
5388
|
};
|
|
5432
|
-
const [model, setModel] = (0, import_react27.useState)(props.model
|
|
5433
|
-
const [lastModel, setLastModel] = (0, import_react27.useState)(props.model
|
|
5389
|
+
const [model, setModel] = (0, import_react27.useState)((_a = props.model) != null ? _a : null);
|
|
5390
|
+
const [lastModel, setLastModel] = (0, import_react27.useState)((_b = props.model) != null ? _b : null);
|
|
5434
5391
|
const [changed, setChanged] = (0, import_react27.useState)(false);
|
|
5435
5392
|
const [focused, setFocused] = (0, import_react27.useState)(false);
|
|
5436
5393
|
const [blurred, setBlurred] = (0, import_react27.useState)(false);
|
|
@@ -5453,7 +5410,8 @@ var BasicTypeSchema = (props) => {
|
|
|
5453
5410
|
(0, import_react27.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
5454
5411
|
(0, import_react27.useEffect)(onSchemaChange, [props.schema]);
|
|
5455
5412
|
(0, import_react27.useEffect)(() => {
|
|
5456
|
-
|
|
5413
|
+
var _a2;
|
|
5414
|
+
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
5457
5415
|
if (newModel !== model) {
|
|
5458
5416
|
setModel(newModel);
|
|
5459
5417
|
}
|
|
@@ -5466,15 +5424,15 @@ var BasicTypeSchema = (props) => {
|
|
|
5466
5424
|
const showLabel = props.schema.format !== "file" && props.schema.type !== "boolean";
|
|
5467
5425
|
const schemaHelp = props.schema.help;
|
|
5468
5426
|
const feedbackId = `${id}-feedback`;
|
|
5469
|
-
return !isHidden ? /* @__PURE__ */ (0,
|
|
5470
|
-
props.schema.alert && /* @__PURE__ */ (0,
|
|
5471
|
-
/* @__PURE__ */ (0,
|
|
5472
|
-
showLabel && /* @__PURE__ */ (0,
|
|
5473
|
-
/* @__PURE__ */ (0,
|
|
5474
|
-
!!schemaHelp && /* @__PURE__ */ (0,
|
|
5427
|
+
return !isHidden ? /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
|
|
5428
|
+
props.schema.alert && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DynamicAlert_default, { component: props.schema.alert }),
|
|
5429
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: (0, import_classnames6.default)(formGroupClasses), children: [
|
|
5430
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "d-inline-block", children: [
|
|
5431
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)("label", { className: "control-label d-inline", htmlFor: id, children: props.schema.title }),
|
|
5432
|
+
!!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Help_default, { help: schemaHelp })
|
|
5475
5433
|
] }),
|
|
5476
|
-
!showLabel && !!schemaHelp && /* @__PURE__ */ (0,
|
|
5477
|
-
/* @__PURE__ */ (0,
|
|
5434
|
+
!showLabel && !!schemaHelp && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(Help_default, { help: schemaHelp }),
|
|
5435
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
5478
5436
|
SchemaFormControl_default,
|
|
5479
5437
|
{
|
|
5480
5438
|
id,
|
|
@@ -5487,7 +5445,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5487
5445
|
describedBy: feedbackId
|
|
5488
5446
|
}
|
|
5489
5447
|
),
|
|
5490
|
-
/* @__PURE__ */ (0,
|
|
5448
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
5491
5449
|
ControlFeedback_default,
|
|
5492
5450
|
{
|
|
5493
5451
|
id: feedbackId,
|
|
@@ -5495,7 +5453,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5495
5453
|
focused,
|
|
5496
5454
|
blurred,
|
|
5497
5455
|
submitted: props.submitted,
|
|
5498
|
-
errors: props.errors
|
|
5456
|
+
errors: (_c = props.errors) != null ? _c : null,
|
|
5499
5457
|
schema: props.schema,
|
|
5500
5458
|
validations,
|
|
5501
5459
|
infoMessage: props.infoMessage
|
|
@@ -5512,12 +5470,13 @@ BasicTypeSchema.defaultProps = {
|
|
|
5512
5470
|
var BasicTypeSchema_default = BasicTypeSchema;
|
|
5513
5471
|
|
|
5514
5472
|
// src/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
|
|
5515
|
-
var
|
|
5473
|
+
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
5516
5474
|
var getIdFromResponse = (idProperty, response) => {
|
|
5517
5475
|
return response[idProperty];
|
|
5518
5476
|
};
|
|
5519
5477
|
var getErrorFromResponse = (errorProperty, response) => {
|
|
5520
|
-
|
|
5478
|
+
var _a;
|
|
5479
|
+
return (_a = response.validation) == null ? void 0 : _a[errorProperty];
|
|
5521
5480
|
};
|
|
5522
5481
|
var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
|
|
5523
5482
|
FormControlType.RADIO,
|
|
@@ -5569,14 +5528,14 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5569
5528
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
5570
5529
|
} else if (isStatus422(response.status)) {
|
|
5571
5530
|
const { validation } = responseBody;
|
|
5572
|
-
const error = isObject(validation) && validation
|
|
5531
|
+
const error = isObject(validation) && (validation == null ? void 0 : validation[param]) || null;
|
|
5573
5532
|
setPersistAsyncError(error);
|
|
5574
5533
|
onChange({ model: null, triggerSchema: schema, triggerModel: null });
|
|
5575
5534
|
} else {
|
|
5576
5535
|
setGenericPersistAsyncError();
|
|
5577
5536
|
}
|
|
5578
5537
|
onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
|
|
5579
|
-
} catch {
|
|
5538
|
+
} catch (e) {
|
|
5580
5539
|
onEvent("Dynamic Flow - PersistAsync", { status: "failure", schemaId: schema.$id });
|
|
5581
5540
|
setGenericPersistAsyncError();
|
|
5582
5541
|
}
|
|
@@ -5603,7 +5562,7 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5603
5562
|
setPersistAsyncModel(newPersistAsyncModel);
|
|
5604
5563
|
}
|
|
5605
5564
|
};
|
|
5606
|
-
return /* @__PURE__ */ (0,
|
|
5565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
|
|
5607
5566
|
BasicTypeSchema_default,
|
|
5608
5567
|
{
|
|
5609
5568
|
required,
|
|
@@ -5650,9 +5609,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
5650
5609
|
const requestBody = isBlob ? wrapInFormData(requestKey, model) : JSON.stringify({ [requestKey]: model });
|
|
5651
5610
|
return {
|
|
5652
5611
|
method: persistAsync.method,
|
|
5653
|
-
headers: {
|
|
5654
|
-
...!isBlob && { "Content-Type": "application/json" }
|
|
5655
|
-
},
|
|
5612
|
+
headers: __spreadValues({}, !isBlob && { "Content-Type": "application/json" }),
|
|
5656
5613
|
body: requestBody,
|
|
5657
5614
|
signal
|
|
5658
5615
|
};
|
|
@@ -5793,7 +5750,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5793
5750
|
}, [polling, httpClient]);
|
|
5794
5751
|
const onPollingResponse = (0, import_react32.useCallback)(
|
|
5795
5752
|
(pollingResponse) => {
|
|
5796
|
-
if (pollingResponse
|
|
5753
|
+
if (pollingResponse == null ? void 0 : pollingResponse.action) {
|
|
5797
5754
|
onAction(pollingResponse.action);
|
|
5798
5755
|
return false;
|
|
5799
5756
|
}
|
|
@@ -5803,8 +5760,8 @@ function useStepPolling(polling, onAction) {
|
|
|
5803
5760
|
);
|
|
5804
5761
|
usePolling({
|
|
5805
5762
|
asyncFn,
|
|
5806
|
-
interval: 1e3 * (polling
|
|
5807
|
-
maxAttempts: polling
|
|
5763
|
+
interval: 1e3 * ((polling == null ? void 0 : polling.interval) || 0),
|
|
5764
|
+
maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
|
|
5808
5765
|
maxConsecutiveFails: 1,
|
|
5809
5766
|
onPollingResponse,
|
|
5810
5767
|
onFailure: (0, import_react32.useCallback)(() => {
|
|
@@ -5816,8 +5773,9 @@ function useStepPolling(polling, onAction) {
|
|
|
5816
5773
|
}
|
|
5817
5774
|
|
|
5818
5775
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5819
|
-
var
|
|
5776
|
+
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
5820
5777
|
var getComponents = (step, options) => {
|
|
5778
|
+
var _a;
|
|
5821
5779
|
if (isEmpty(step)) {
|
|
5822
5780
|
return [];
|
|
5823
5781
|
}
|
|
@@ -5826,7 +5784,7 @@ var getComponents = (step, options) => {
|
|
|
5826
5784
|
layout,
|
|
5827
5785
|
schemas: step.schemas || [],
|
|
5828
5786
|
actions: step.actions || [],
|
|
5829
|
-
model: step.model
|
|
5787
|
+
model: (_a = step.model) != null ? _a : null
|
|
5830
5788
|
});
|
|
5831
5789
|
};
|
|
5832
5790
|
var LayoutStep = (props) => {
|
|
@@ -5838,7 +5796,7 @@ var LayoutStep = (props) => {
|
|
|
5838
5796
|
onEvent("Dynamic Flow - onAction supressed", { reason: "LayoutStep - loading state" });
|
|
5839
5797
|
};
|
|
5840
5798
|
useStepPolling(stepSpecification.polling, onAction);
|
|
5841
|
-
return /* @__PURE__ */ (0,
|
|
5799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5842
5800
|
DynamicLayout_default,
|
|
5843
5801
|
{
|
|
5844
5802
|
components,
|
|
@@ -5884,15 +5842,15 @@ var CameraCapture_messages_default = (0, import_react_intl22.defineMessages)({
|
|
|
5884
5842
|
// src/step/cameraStep/cameraCapture/components/index.tsx
|
|
5885
5843
|
var import_components27 = require("@transferwise/components");
|
|
5886
5844
|
var import_react_intl23 = require("react-intl");
|
|
5887
|
-
var
|
|
5888
|
-
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0,
|
|
5845
|
+
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5846
|
+
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "bottom-bar", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(CaptureButton, { onClick: onCapture }) });
|
|
5889
5847
|
var ReviewBottomBar = ({
|
|
5890
5848
|
onSubmit,
|
|
5891
5849
|
onRetry
|
|
5892
5850
|
}) => {
|
|
5893
5851
|
const intl = (0, import_react_intl23.useIntl)();
|
|
5894
|
-
return /* @__PURE__ */ (0,
|
|
5895
|
-
/* @__PURE__ */ (0,
|
|
5852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "bottom-bar p-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)("div", { className: "col-xs-12 col-md-6 col-md-offset-3", children: [
|
|
5853
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5896
5854
|
import_components27.Button,
|
|
5897
5855
|
{
|
|
5898
5856
|
className: "m-b-1",
|
|
@@ -5903,7 +5861,7 @@ var ReviewBottomBar = ({
|
|
|
5903
5861
|
children: intl.formatMessage(CameraCapture_messages_default.reviewSubmit)
|
|
5904
5862
|
}
|
|
5905
5863
|
),
|
|
5906
|
-
/* @__PURE__ */ (0,
|
|
5864
|
+
/* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5907
5865
|
import_components27.Button,
|
|
5908
5866
|
{
|
|
5909
5867
|
className: "m-b-2",
|
|
@@ -5917,14 +5875,14 @@ var ReviewBottomBar = ({
|
|
|
5917
5875
|
)
|
|
5918
5876
|
] }) }) });
|
|
5919
5877
|
};
|
|
5920
|
-
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0,
|
|
5878
|
+
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
5921
5879
|
"button",
|
|
5922
5880
|
{
|
|
5923
5881
|
type: "button",
|
|
5924
5882
|
className: "camera-capture-btn m-b-2",
|
|
5925
5883
|
"data-testid": "camera-capture-button",
|
|
5926
5884
|
onClick,
|
|
5927
|
-
children: /* @__PURE__ */ (0,
|
|
5885
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("span", { className: "camera-capture-btn-inner" })
|
|
5928
5886
|
}
|
|
5929
5887
|
);
|
|
5930
5888
|
|
|
@@ -5933,16 +5891,17 @@ var import_react33 = require("react");
|
|
|
5933
5891
|
|
|
5934
5892
|
// src/step/cameraStep/cameraCapture/utils/index.ts
|
|
5935
5893
|
var isSelfieCamera = (stream) => {
|
|
5936
|
-
|
|
5894
|
+
var _a;
|
|
5895
|
+
const { facingMode } = ((_a = getVideoTrack(stream)) == null ? void 0 : _a.getSettings()) || {};
|
|
5937
5896
|
return facingMode === "user" || facingMode === void 0;
|
|
5938
5897
|
};
|
|
5939
|
-
var isMainBackCamera = (deviceInfo) => !!(deviceInfo
|
|
5898
|
+
var isMainBackCamera = (deviceInfo) => !!((deviceInfo == null ? void 0 : deviceInfo.label) || "").match(/camera2? 0/g);
|
|
5940
5899
|
var generateCanvasFromVideo = async (video) => {
|
|
5941
5900
|
const canvas = document.createElement("canvas");
|
|
5942
5901
|
if (video) {
|
|
5943
5902
|
canvas.setAttribute("height", `${video.videoHeight}`);
|
|
5944
5903
|
canvas.setAttribute("width", `${video.videoWidth}`);
|
|
5945
|
-
const context = canvas
|
|
5904
|
+
const context = canvas == null ? void 0 : canvas.getContext("2d");
|
|
5946
5905
|
if (context) {
|
|
5947
5906
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
5948
5907
|
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
@@ -5950,16 +5909,29 @@ var generateCanvasFromVideo = async (video) => {
|
|
|
5950
5909
|
}
|
|
5951
5910
|
return canvas;
|
|
5952
5911
|
};
|
|
5953
|
-
var getAvailableVideoDevices = async () =>
|
|
5954
|
-
|
|
5955
|
-
)
|
|
5956
|
-
|
|
5912
|
+
var getAvailableVideoDevices = async () => {
|
|
5913
|
+
var _a, _b;
|
|
5914
|
+
return (await ((_b = (_a = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a.enumerateDevices) == null ? void 0 : _b.call(_a)) || []).filter(
|
|
5915
|
+
(deviceInfo) => deviceInfo.kind === "videoinput"
|
|
5916
|
+
);
|
|
5917
|
+
};
|
|
5918
|
+
var getAvailableVideoDeviceLabels = async () => {
|
|
5919
|
+
var _a, _b;
|
|
5920
|
+
return (await ((_b = (_a = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a.enumerateDevices) == null ? void 0 : _b.call(_a)) || []).filter((deviceInfo) => deviceInfo.kind === "videoinput").map((deviceInfo) => deviceInfo.label);
|
|
5921
|
+
};
|
|
5957
5922
|
var getActiveVideoDeviceLabel = async (videoStream) => {
|
|
5923
|
+
var _a, _b, _c;
|
|
5958
5924
|
const capabilities = getVideoCapabilities(videoStream);
|
|
5959
|
-
return (await navigator
|
|
5925
|
+
return (_c = (await ((_b = (_a = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a.enumerateDevices) == null ? void 0 : _b.call(_a)) || []).filter((deviceInfo) => deviceInfo.kind === "videoinput").find((deviceInfo) => deviceInfo.deviceId === (capabilities == null ? void 0 : capabilities.deviceId))) == null ? void 0 : _c.label;
|
|
5926
|
+
};
|
|
5927
|
+
var getVideoTrack = (videoStream) => {
|
|
5928
|
+
var _a;
|
|
5929
|
+
return (((_a = videoStream == null ? void 0 : videoStream.getVideoTracks) == null ? void 0 : _a.call(videoStream)) || [])[0];
|
|
5930
|
+
};
|
|
5931
|
+
var getVideoCapabilities = (videoStream) => {
|
|
5932
|
+
var _a, _b;
|
|
5933
|
+
return (_b = (_a = getVideoTrack(videoStream)) == null ? void 0 : _a.getCapabilities) == null ? void 0 : _b.call(_a);
|
|
5960
5934
|
};
|
|
5961
|
-
var getVideoTrack = (videoStream) => (videoStream?.getVideoTracks?.() || [])[0];
|
|
5962
|
-
var getVideoCapabilities = (videoStream) => getVideoTrack(videoStream)?.getCapabilities?.();
|
|
5963
5935
|
|
|
5964
5936
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5965
5937
|
var useVideoConstraints = (direction) => {
|
|
@@ -5977,11 +5949,10 @@ var useVideoConstraints = (direction) => {
|
|
|
5977
5949
|
const getVideoConstraints = async (direction2) => {
|
|
5978
5950
|
if (direction2 === "back") {
|
|
5979
5951
|
const mainCamera = (await getAvailableVideoDevices()).find(isMainBackCamera);
|
|
5980
|
-
if (mainCamera
|
|
5981
|
-
return {
|
|
5982
|
-
...defaultVideoConstraints,
|
|
5952
|
+
if (mainCamera == null ? void 0 : mainCamera.deviceId) {
|
|
5953
|
+
return __spreadProps(__spreadValues({}, defaultVideoConstraints), {
|
|
5983
5954
|
deviceId: { exact: mainCamera.deviceId }
|
|
5984
|
-
};
|
|
5955
|
+
});
|
|
5985
5956
|
}
|
|
5986
5957
|
}
|
|
5987
5958
|
return defaultVideoConstraints;
|
|
@@ -5991,7 +5962,7 @@ var useVideoConstraints = (direction) => {
|
|
|
5991
5962
|
|
|
5992
5963
|
// src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
|
|
5993
5964
|
var import_react34 = require("react");
|
|
5994
|
-
var
|
|
5965
|
+
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
5995
5966
|
var captureButtonHeight = 92;
|
|
5996
5967
|
var reviewButtonsHeight = 120;
|
|
5997
5968
|
var imageHeight = 40;
|
|
@@ -6010,7 +5981,8 @@ var Overlay = ({
|
|
|
6010
5981
|
const svgReference = (0, import_react34.useRef)(null);
|
|
6011
5982
|
(0, import_react34.useEffect)(() => {
|
|
6012
5983
|
const listener = debounce(() => {
|
|
6013
|
-
|
|
5984
|
+
var _a;
|
|
5985
|
+
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
6014
5986
|
const reference = svgReference.current;
|
|
6015
5987
|
reference.innerHTML += "";
|
|
6016
5988
|
}
|
|
@@ -6019,18 +5991,18 @@ var Overlay = ({
|
|
|
6019
5991
|
return () => window.removeEventListener("resize", listener);
|
|
6020
5992
|
});
|
|
6021
5993
|
let helperBoxHeight = (imageUrl ? imageHeight : 0) + (title ? titleHeight : 0) + (instructions ? instructionsHeight : 0);
|
|
6022
|
-
let helperBox = /* @__PURE__ */ (0,
|
|
6023
|
-
imageUrl && /* @__PURE__ */ (0,
|
|
6024
|
-
title && /* @__PURE__ */ (0,
|
|
6025
|
-
instructions && /* @__PURE__ */ (0,
|
|
5994
|
+
let helperBox = /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
|
|
5995
|
+
imageUrl && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("img", { className: "camera-capture-img", src: imageUrl, alt: "" }),
|
|
5996
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("h4", { className: "camera-capture-title", children: title }),
|
|
5997
|
+
instructions && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("small", { className: "camera-capture-instructions", children: instructions })
|
|
6026
5998
|
] });
|
|
6027
5999
|
const frameBottomMargin = captureButtonHeight + helperBoxHeight;
|
|
6028
6000
|
if (reviewInstructions) {
|
|
6029
6001
|
helperBoxHeight = frameBottomMargin - reviewButtonsHeight;
|
|
6030
|
-
helperBox = /* @__PURE__ */ (0,
|
|
6002
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("small", { className: "camera-capture-instructions", children: reviewInstructions });
|
|
6031
6003
|
const frameWithReviewInstructionsMinBottomMargin = reviewButtonsHeight + reviewInstructionsHeight;
|
|
6032
6004
|
if (frameBottomMargin < frameWithReviewInstructionsMinBottomMargin) {
|
|
6033
|
-
helperBox = /* @__PURE__ */ (0,
|
|
6005
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_jsx_runtime57.Fragment, {});
|
|
6034
6006
|
}
|
|
6035
6007
|
}
|
|
6036
6008
|
const framePosition = {
|
|
@@ -6048,14 +6020,14 @@ var Overlay = ({
|
|
|
6048
6020
|
width: "90%"
|
|
6049
6021
|
}
|
|
6050
6022
|
};
|
|
6051
|
-
return /* @__PURE__ */ (0,
|
|
6052
|
-
/* @__PURE__ */ (0,
|
|
6053
|
-
/* @__PURE__ */ (0,
|
|
6054
|
-
/* @__PURE__ */ (0,
|
|
6023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
|
|
6024
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("mask", { id: "mask", children: [
|
|
6025
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("rect", { width: "100%", height: "100%", fill: "#fff" }),
|
|
6026
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("image", __spreadValues({ href: overlay }, framePosition))
|
|
6055
6027
|
] }) }),
|
|
6056
|
-
overlay && /* @__PURE__ */ (0,
|
|
6057
|
-
outline && /* @__PURE__ */ (0,
|
|
6058
|
-
/* @__PURE__ */ (0,
|
|
6028
|
+
overlay && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("rect", { width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.72" }),
|
|
6029
|
+
outline && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("image", __spreadValues({ href: outline }, framePosition)),
|
|
6030
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", __spreadProps(__spreadValues({ className: "camera-capture-text-and-image-container" }, helperBoxPosition), { children: helperBox })) })
|
|
6059
6031
|
] });
|
|
6060
6032
|
};
|
|
6061
6033
|
var Overlay_default = Overlay;
|
|
@@ -6085,13 +6057,13 @@ var NoCameraAccess_messages_default = (0, import_react_intl24.defineMessages)({
|
|
|
6085
6057
|
});
|
|
6086
6058
|
|
|
6087
6059
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
6088
|
-
var
|
|
6060
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
6089
6061
|
var NoCameraAccess = ({ onAction }) => {
|
|
6090
6062
|
const intl = (0, import_react_intl25.useIntl)();
|
|
6091
|
-
return /* @__PURE__ */ (0,
|
|
6092
|
-
/* @__PURE__ */ (0,
|
|
6093
|
-
/* @__PURE__ */ (0,
|
|
6094
|
-
/* @__PURE__ */ (0,
|
|
6063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { id: "no-camera-access", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "container p-t-5", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "col-md-6 col-md-offset-3", children: [
|
|
6064
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(NoCameraAccess_messages_default.title) }),
|
|
6065
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(NoCameraAccess_messages_default.paragraph) }),
|
|
6066
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components28.Button, { block: true, onClick: onAction, children: intl.formatMessage(NoCameraAccess_messages_default.action) })
|
|
6095
6067
|
] }) }) }) });
|
|
6096
6068
|
};
|
|
6097
6069
|
var NoCameraAccess_default = NoCameraAccess;
|
|
@@ -6115,37 +6087,37 @@ var CameraNotSupported_messages_default = (0, import_react_intl26.defineMessages
|
|
|
6115
6087
|
});
|
|
6116
6088
|
|
|
6117
6089
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
6118
|
-
var
|
|
6090
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
6119
6091
|
var CameraNotSupported = () => {
|
|
6120
6092
|
const intl = (0, import_react_intl27.useIntl)();
|
|
6121
|
-
return /* @__PURE__ */ (0,
|
|
6122
|
-
/* @__PURE__ */ (0,
|
|
6123
|
-
/* @__PURE__ */ (0,
|
|
6093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { id: "camera-not-supported", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "container p-t-5", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "col-md-6 col-md-offset-3", children: [
|
|
6094
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(CameraNotSupported_messages_default.title) }),
|
|
6095
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(CameraNotSupported_messages_default.paragraph) })
|
|
6124
6096
|
] }) }) }) });
|
|
6125
6097
|
};
|
|
6126
6098
|
var CameraNotSupported_default = CameraNotSupported;
|
|
6127
6099
|
|
|
6128
6100
|
// src/step/cameraStep/cameraCapture/tracking/index.ts
|
|
6129
|
-
var trackCameraPermissionDenied = (onEvent) => onEvent
|
|
6130
|
-
var trackCameraFeedStarted = async (onEvent, props, stream) => onEvent
|
|
6131
|
-
var trackCameraNotSupported = (onEvent, error) => onEvent
|
|
6101
|
+
var trackCameraPermissionDenied = (onEvent) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Permission Denied", {});
|
|
6102
|
+
var trackCameraFeedStarted = async (onEvent, props, stream) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Feed Started", await getCameraStartedProperties(props, stream));
|
|
6103
|
+
var trackCameraNotSupported = (onEvent, error) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Not Supported", { Error: error });
|
|
6132
6104
|
var getCameraStartedProperties = async (props, videoStream) => {
|
|
6105
|
+
var _a;
|
|
6133
6106
|
const videoTrack = getVideoTrack(videoStream);
|
|
6134
6107
|
const capabilities = getVideoCapabilities(videoStream);
|
|
6135
|
-
const settings = videoTrack
|
|
6136
|
-
return {
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
};
|
|
6108
|
+
const settings = (_a = videoTrack == null ? void 0 : videoTrack.getSettings) == null ? void 0 : _a.call(videoTrack);
|
|
6109
|
+
return __spreadProps(__spreadValues({}, videoTrack && {
|
|
6110
|
+
"Available Video Devices (by label)": await getAvailableVideoDeviceLabels(),
|
|
6111
|
+
"Active Video Device (by label)": await getActiveVideoDeviceLabel(videoStream),
|
|
6112
|
+
"Camera Capabilities": capabilities,
|
|
6113
|
+
"Camera Settings": settings
|
|
6114
|
+
}), {
|
|
6115
|
+
"Camera Direction (Asked)": props == null ? void 0 : props.direction
|
|
6116
|
+
});
|
|
6145
6117
|
};
|
|
6146
6118
|
|
|
6147
6119
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
6148
|
-
var
|
|
6120
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
6149
6121
|
var CameraCapture = ({
|
|
6150
6122
|
direction = "back",
|
|
6151
6123
|
overlay = "",
|
|
@@ -6165,10 +6137,11 @@ var CameraCapture = ({
|
|
|
6165
6137
|
const { videoConstraints } = useVideoConstraints(direction);
|
|
6166
6138
|
const intl = (0, import_react_intl28.useIntl)();
|
|
6167
6139
|
const handleCapture = (0, import_react35.useCallback)(async () => {
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
canvas
|
|
6140
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6141
|
+
if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
|
|
6142
|
+
(_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
|
|
6143
|
+
const canvas = await generateCanvasFromVideo((_f = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _f.video);
|
|
6144
|
+
canvas == null ? void 0 : canvas.toBlob(
|
|
6172
6145
|
(blob) => {
|
|
6173
6146
|
if (blob) {
|
|
6174
6147
|
if (showReview) {
|
|
@@ -6187,7 +6160,7 @@ var CameraCapture = ({
|
|
|
6187
6160
|
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
6188
6161
|
const handleUserMediaError = (0, import_react35.useCallback)(
|
|
6189
6162
|
(error) => {
|
|
6190
|
-
if (error instanceof DOMException && error
|
|
6163
|
+
if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
|
|
6191
6164
|
setMode("NO_CAMERA_ACCESS");
|
|
6192
6165
|
trackCameraPermissionDenied(onEvent);
|
|
6193
6166
|
return;
|
|
@@ -6206,15 +6179,15 @@ var CameraCapture = ({
|
|
|
6206
6179
|
[setIsVideoMirrored, onEvent, direction]
|
|
6207
6180
|
);
|
|
6208
6181
|
const handleReviewSubmit = () => {
|
|
6209
|
-
onCapture(reviewImage
|
|
6182
|
+
onCapture((reviewImage == null ? void 0 : reviewImage.blob) || null);
|
|
6210
6183
|
};
|
|
6211
6184
|
const handleReviewRetry = () => {
|
|
6212
6185
|
setMode("CAPTURE");
|
|
6213
6186
|
setReviewImage(void 0);
|
|
6214
6187
|
};
|
|
6215
6188
|
const handleRetryCameraAccess = () => setMode("CAPTURE");
|
|
6216
|
-
const captureScreen = /* @__PURE__ */ (0,
|
|
6217
|
-
videoConstraints && /* @__PURE__ */ (0,
|
|
6189
|
+
const captureScreen = /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
|
|
6190
|
+
videoConstraints && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
6218
6191
|
import_react_webcam.default,
|
|
6219
6192
|
{
|
|
6220
6193
|
ref: webcamReference,
|
|
@@ -6225,7 +6198,7 @@ var CameraCapture = ({
|
|
|
6225
6198
|
onUserMedia: handleUserMedia
|
|
6226
6199
|
}
|
|
6227
6200
|
),
|
|
6228
|
-
/* @__PURE__ */ (0,
|
|
6201
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
6229
6202
|
Overlay_default,
|
|
6230
6203
|
{
|
|
6231
6204
|
overlay,
|
|
@@ -6235,11 +6208,11 @@ var CameraCapture = ({
|
|
|
6235
6208
|
instructions
|
|
6236
6209
|
}
|
|
6237
6210
|
),
|
|
6238
|
-
ready && /* @__PURE__ */ (0,
|
|
6211
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
6239
6212
|
] });
|
|
6240
|
-
const reviewScreen = /* @__PURE__ */ (0,
|
|
6241
|
-
/* @__PURE__ */ (0,
|
|
6242
|
-
/* @__PURE__ */ (0,
|
|
6213
|
+
const reviewScreen = /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(import_jsx_runtime60.Fragment, { children: [
|
|
6214
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("img", { className: "review-image", src: reviewImage == null ? void 0 : reviewImage.source, alt: "" }),
|
|
6215
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
6243
6216
|
Overlay_default,
|
|
6244
6217
|
{
|
|
6245
6218
|
overlay,
|
|
@@ -6249,19 +6222,19 @@ var CameraCapture = ({
|
|
|
6249
6222
|
reviewInstructions: intl.formatMessage(CameraCapture_messages_default.reviewInstructions)
|
|
6250
6223
|
}
|
|
6251
6224
|
),
|
|
6252
|
-
/* @__PURE__ */ (0,
|
|
6225
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ReviewBottomBar, { onSubmit: handleReviewSubmit, onRetry: handleReviewRetry })
|
|
6253
6226
|
] });
|
|
6254
|
-
return /* @__PURE__ */ (0,
|
|
6227
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("section", { className: "camera-capture", children: [
|
|
6255
6228
|
mode === "CAPTURE" && captureScreen,
|
|
6256
6229
|
mode === "REVIEW" && reviewScreen,
|
|
6257
|
-
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0,
|
|
6258
|
-
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0,
|
|
6230
|
+
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(NoCameraAccess_default, { onAction: handleRetryCameraAccess }),
|
|
6231
|
+
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(CameraNotSupported_default, {})
|
|
6259
6232
|
] });
|
|
6260
6233
|
};
|
|
6261
6234
|
var CameraCapture_default = CameraCapture;
|
|
6262
6235
|
|
|
6263
6236
|
// src/step/cameraStep/CameraStep.tsx
|
|
6264
|
-
var
|
|
6237
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
6265
6238
|
function blobToBase64(blob) {
|
|
6266
6239
|
return new Promise((resolve, _) => {
|
|
6267
6240
|
const reader = new FileReader();
|
|
@@ -6299,7 +6272,7 @@ var CameraStep = (props) => {
|
|
|
6299
6272
|
});
|
|
6300
6273
|
}
|
|
6301
6274
|
};
|
|
6302
|
-
return /* @__PURE__ */ (0,
|
|
6275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
6303
6276
|
CameraCapture_default,
|
|
6304
6277
|
{
|
|
6305
6278
|
overlay,
|
|
@@ -6337,10 +6310,11 @@ function getCameraSchema(step) {
|
|
|
6337
6310
|
return firstProperty;
|
|
6338
6311
|
}
|
|
6339
6312
|
function getFirstAction(step) {
|
|
6340
|
-
|
|
6313
|
+
var _a, _b;
|
|
6314
|
+
if (!step.schemas || ((_a = filterHiddenSchemas(step.schemas)) == null ? void 0 : _a.length) !== 1) {
|
|
6341
6315
|
throw new Error("camera step expects 1 non-hidden object schema");
|
|
6342
6316
|
}
|
|
6343
|
-
if (step
|
|
6317
|
+
if (((_b = step == null ? void 0 : step.actions) == null ? void 0 : _b.length) !== 1) {
|
|
6344
6318
|
throw new Error("camera step expects 1 action");
|
|
6345
6319
|
}
|
|
6346
6320
|
return step.actions[0];
|
|
@@ -6375,12 +6349,12 @@ var ExternalConfirmationStep_messages_default = (0, import_react_intl29.defineMe
|
|
|
6375
6349
|
});
|
|
6376
6350
|
|
|
6377
6351
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
6378
|
-
var
|
|
6379
|
-
var
|
|
6352
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
6353
|
+
var noop4 = () => {
|
|
6380
6354
|
};
|
|
6381
6355
|
var ExternalConfirmationStep = ({ url, onClose }) => {
|
|
6382
6356
|
const { formatMessage } = (0, import_react_intl30.useIntl)();
|
|
6383
|
-
return /* @__PURE__ */ (0,
|
|
6357
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
6384
6358
|
DynamicLayout_default,
|
|
6385
6359
|
{
|
|
6386
6360
|
components: [
|
|
@@ -6430,8 +6404,8 @@ var ExternalConfirmationStep = ({ url, onClose }) => {
|
|
|
6430
6404
|
}
|
|
6431
6405
|
onClose();
|
|
6432
6406
|
},
|
|
6433
|
-
onModelChange:
|
|
6434
|
-
onPersistAsync:
|
|
6407
|
+
onModelChange: noop4,
|
|
6408
|
+
onPersistAsync: noop4
|
|
6435
6409
|
}
|
|
6436
6410
|
);
|
|
6437
6411
|
};
|
|
@@ -6439,7 +6413,7 @@ var ExternalConfirmationStep_default = ExternalConfirmationStep;
|
|
|
6439
6413
|
function getOrigin(url) {
|
|
6440
6414
|
try {
|
|
6441
6415
|
return new URL(url).origin;
|
|
6442
|
-
} catch {
|
|
6416
|
+
} catch (e) {
|
|
6443
6417
|
return url;
|
|
6444
6418
|
}
|
|
6445
6419
|
}
|
|
@@ -6447,21 +6421,21 @@ function getOrigin(url) {
|
|
|
6447
6421
|
// src/dynamicFlow/BackButton.tsx
|
|
6448
6422
|
var import_components30 = require("@transferwise/components");
|
|
6449
6423
|
var import_icons2 = require("@transferwise/icons");
|
|
6450
|
-
var
|
|
6424
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
6451
6425
|
var BackButton = ({ title, action, onAction }) => {
|
|
6452
|
-
return /* @__PURE__ */ (0,
|
|
6426
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
|
|
6453
6427
|
"a",
|
|
6454
6428
|
{
|
|
6455
6429
|
onClick: (event) => {
|
|
6456
6430
|
event.preventDefault();
|
|
6457
|
-
onAction({
|
|
6431
|
+
onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true }));
|
|
6458
6432
|
},
|
|
6459
6433
|
href: "/",
|
|
6460
6434
|
className: "df-back-btn",
|
|
6461
6435
|
"aria-label": title,
|
|
6462
6436
|
children: [
|
|
6463
|
-
/* @__PURE__ */ (0,
|
|
6464
|
-
/* @__PURE__ */ (0,
|
|
6437
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)("span", { className: "sr-only", children: title }),
|
|
6438
|
+
/* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components30.Avatar, { type: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_icons2.ArrowLeft, { size: "24" }) })
|
|
6465
6439
|
]
|
|
6466
6440
|
}
|
|
6467
6441
|
);
|
|
@@ -6469,25 +6443,26 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6469
6443
|
var BackButton_default = BackButton;
|
|
6470
6444
|
|
|
6471
6445
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6472
|
-
var
|
|
6446
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
6473
6447
|
var DynamicFlowStep = (props) => {
|
|
6448
|
+
var _a, _b, _c;
|
|
6474
6449
|
const { step, globalError, onAction } = props;
|
|
6475
|
-
const externalUrl = step
|
|
6476
|
-
const backButton = step
|
|
6450
|
+
const externalUrl = (_a = step == null ? void 0 : step.external) == null ? void 0 : _a.url;
|
|
6451
|
+
const backButton = ((_b = step == null ? void 0 : step.navigation) == null ? void 0 : _b.back) || ((_c = step == null ? void 0 : step.navigation) == null ? void 0 : _c.backButton);
|
|
6477
6452
|
const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
|
|
6478
6453
|
if (step === void 0) {
|
|
6479
6454
|
return null;
|
|
6480
6455
|
}
|
|
6481
6456
|
if (externalUrl && requiresManualTrigger) {
|
|
6482
|
-
return /* @__PURE__ */ (0,
|
|
6457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
6483
6458
|
}
|
|
6484
6459
|
if (isCameraStep(step)) {
|
|
6485
|
-
return /* @__PURE__ */ (0,
|
|
6460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step }));
|
|
6486
6461
|
}
|
|
6487
|
-
return /* @__PURE__ */ (0,
|
|
6488
|
-
backButton && /* @__PURE__ */ (0,
|
|
6489
|
-
globalError ? /* @__PURE__ */ (0,
|
|
6490
|
-
/* @__PURE__ */ (0,
|
|
6462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(import_jsx_runtime64.Fragment, { children: [
|
|
6463
|
+
backButton && /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(BackButton_default, __spreadProps(__spreadValues({}, backButton), { onAction })),
|
|
6464
|
+
globalError ? /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(DynamicAlert_default, { component: { context: "negative", markdown: globalError, margin: "lg" } }) : null,
|
|
6465
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification: step }))
|
|
6491
6466
|
] });
|
|
6492
6467
|
};
|
|
6493
6468
|
|
|
@@ -6520,29 +6495,30 @@ var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && sche
|
|
|
6520
6495
|
// src/dynamicFlow/utils/useDynamicFlowState.ts
|
|
6521
6496
|
var import_react38 = require("react");
|
|
6522
6497
|
var useDynamicFlowState = (initialStep) => {
|
|
6523
|
-
|
|
6524
|
-
const [
|
|
6498
|
+
var _a, _b;
|
|
6499
|
+
const [formErrors, setFormErrors] = (0, import_react38.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
|
|
6500
|
+
const [globalError, setGlobalError] = (0, import_react38.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
|
|
6525
6501
|
const [stepAndModels, setStepAndModels] = (0, import_react38.useState)({
|
|
6526
6502
|
step: initialStep || void 0,
|
|
6527
|
-
models: initialStep
|
|
6503
|
+
models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
6528
6504
|
etag: void 0
|
|
6529
6505
|
});
|
|
6530
6506
|
const { step, models, etag } = stepAndModels;
|
|
6531
6507
|
const setStepAndEtag = (step2, etag2) => {
|
|
6508
|
+
var _a2, _b2, _c, _d;
|
|
6532
6509
|
setStepAndModels((previous) => ({
|
|
6533
6510
|
step: step2,
|
|
6534
6511
|
models: step2.model ? buildInitialModels(step2.model, getAllSchemas(step2)) : previous.models,
|
|
6535
6512
|
etag: etag2
|
|
6536
6513
|
}));
|
|
6537
|
-
setFormErrors(step2
|
|
6538
|
-
setGlobalError(step2
|
|
6514
|
+
setFormErrors((_b2 = (_a2 = step2 == null ? void 0 : step2.errors) == null ? void 0 : _a2.validation) != null ? _b2 : null);
|
|
6515
|
+
setGlobalError((_d = (_c = step2 == null ? void 0 : step2.errors) == null ? void 0 : _c.error) != null ? _d : null);
|
|
6539
6516
|
};
|
|
6540
6517
|
const setSchemaModel = (schemaId, objectModel, onModelsUpdated) => {
|
|
6541
6518
|
setStepAndModels((previous) => {
|
|
6542
|
-
const updatedModels = {
|
|
6543
|
-
...previous.models,
|
|
6519
|
+
const updatedModels = __spreadProps(__spreadValues({}, previous.models), {
|
|
6544
6520
|
[schemaId]: objectModel
|
|
6545
|
-
};
|
|
6521
|
+
});
|
|
6546
6522
|
const updatedState = {
|
|
6547
6523
|
step: previous.step,
|
|
6548
6524
|
models: updatedModels,
|
|
@@ -6574,15 +6550,14 @@ var buildInitialModels = (model, schemas = []) => {
|
|
|
6574
6550
|
if (!schema.$id) {
|
|
6575
6551
|
console.warn("Schema without $id property found.");
|
|
6576
6552
|
}
|
|
6577
|
-
return {
|
|
6578
|
-
...acc,
|
|
6553
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
6579
6554
|
[schema.$id || ""]: getValidObjectModelParts(model, schema) || {}
|
|
6580
|
-
};
|
|
6555
|
+
});
|
|
6581
6556
|
}, {});
|
|
6582
6557
|
};
|
|
6583
6558
|
var getAllSchemas = (step) => [
|
|
6584
|
-
...getAllSchemasInLayout(step
|
|
6585
|
-
...step
|
|
6559
|
+
...getAllSchemasInLayout((step == null ? void 0 : step.layout) || []),
|
|
6560
|
+
...(step == null ? void 0 : step.schemas) || []
|
|
6586
6561
|
];
|
|
6587
6562
|
var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
6588
6563
|
switch (component.type) {
|
|
@@ -6597,8 +6572,8 @@ var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
|
6597
6572
|
}
|
|
6598
6573
|
});
|
|
6599
6574
|
var getAllValidatableSchemas = (step) => [
|
|
6600
|
-
...getAllReferencedSchemaIds(step
|
|
6601
|
-
...getAllSchemasInLayout(step
|
|
6575
|
+
...getAllReferencedSchemaIds((step == null ? void 0 : step.layout) || []).map((id) => ((step == null ? void 0 : step.schemas) || []).find((schema) => schema.$id === id)).filter(Boolean),
|
|
6576
|
+
...getAllSchemasInLayout((step == null ? void 0 : step.layout) || [])
|
|
6602
6577
|
];
|
|
6603
6578
|
var getAllReferencedSchemaIds = (components) => components.flatMap((component) => {
|
|
6604
6579
|
switch (component.type) {
|
|
@@ -6613,12 +6588,12 @@ var getAllReferencedSchemaIds = (components) => components.flatMap((component) =
|
|
|
6613
6588
|
}
|
|
6614
6589
|
}).filter(Boolean);
|
|
6615
6590
|
var areModelsValid = (formModels, schemas = []) => {
|
|
6616
|
-
return !schemas
|
|
6591
|
+
return !(schemas == null ? void 0 : schemas.some((schema) => {
|
|
6617
6592
|
if (!schema.$id) {
|
|
6618
6593
|
console.warn("Schema without $id property found.");
|
|
6619
6594
|
}
|
|
6620
6595
|
return !isValidSchema(formModels[schema.$id || ""] || {}, schema);
|
|
6621
|
-
});
|
|
6596
|
+
}));
|
|
6622
6597
|
};
|
|
6623
6598
|
var getSchemaReference = (component) => {
|
|
6624
6599
|
if (component.schema && !isInlineSchema(component.schema)) {
|
|
@@ -6633,17 +6608,16 @@ var isInlineSchema = (schema) => {
|
|
|
6633
6608
|
// src/dynamicFlow/utils/useLoader.tsx
|
|
6634
6609
|
var import_components31 = require("@transferwise/components");
|
|
6635
6610
|
var import_react39 = require("react");
|
|
6636
|
-
var
|
|
6611
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6637
6612
|
function useLoader(loaderConfig, initialState) {
|
|
6638
|
-
const config = {
|
|
6613
|
+
const config = __spreadValues({
|
|
6639
6614
|
size: import_components31.Size.EXTRA_LARGE,
|
|
6640
6615
|
initial: true,
|
|
6641
|
-
submission: false
|
|
6642
|
-
|
|
6643
|
-
};
|
|
6616
|
+
submission: false
|
|
6617
|
+
}, loaderConfig);
|
|
6644
6618
|
const [loadingState, setLoadingState] = (0, import_react39.useState)(initialState);
|
|
6645
6619
|
const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
|
|
6646
|
-
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0,
|
|
6620
|
+
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
6647
6621
|
import_components31.Loader,
|
|
6648
6622
|
{
|
|
6649
6623
|
size: config.size,
|
|
@@ -6660,10 +6634,10 @@ var import_react40 = require("react");
|
|
|
6660
6634
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
|
|
6661
6635
|
var import_components32 = require("@transferwise/components");
|
|
6662
6636
|
var import_react_intl31 = require("react-intl");
|
|
6663
|
-
var
|
|
6637
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
6664
6638
|
var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
6665
6639
|
const { formatMessage } = (0, import_react_intl31.useIntl)();
|
|
6666
|
-
return /* @__PURE__ */ (0,
|
|
6640
|
+
return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
6667
6641
|
import_components32.Alert,
|
|
6668
6642
|
{
|
|
6669
6643
|
action: {
|
|
@@ -6679,8 +6653,8 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
|
6679
6653
|
};
|
|
6680
6654
|
|
|
6681
6655
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6682
|
-
var
|
|
6683
|
-
var
|
|
6656
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
6657
|
+
var noop5 = () => {
|
|
6684
6658
|
};
|
|
6685
6659
|
var ErrorBoundary = class extends import_react40.Component {
|
|
6686
6660
|
constructor(props) {
|
|
@@ -6694,14 +6668,14 @@ var ErrorBoundary = class extends import_react40.Component {
|
|
|
6694
6668
|
return { hasError: true, isFatalError: true };
|
|
6695
6669
|
}
|
|
6696
6670
|
componentDidCatch(error) {
|
|
6697
|
-
const { onError =
|
|
6671
|
+
const { onError = noop5 } = this.props;
|
|
6698
6672
|
onError(error);
|
|
6699
6673
|
}
|
|
6700
6674
|
render() {
|
|
6701
6675
|
const { children } = this.props;
|
|
6702
6676
|
const { hasError, isFatalError } = this.state;
|
|
6703
|
-
return /* @__PURE__ */ (0,
|
|
6704
|
-
hasError && /* @__PURE__ */ (0,
|
|
6677
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
|
|
6678
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ErrorBoundaryAlert, { onDismiss: this.handleErrorReset }),
|
|
6705
6679
|
!isFatalError && children
|
|
6706
6680
|
] });
|
|
6707
6681
|
}
|
|
@@ -6751,16 +6725,17 @@ var parseExitResponse = async (response) => {
|
|
|
6751
6725
|
return { type: "exit", result: await getJsonObjectOrNull(response) };
|
|
6752
6726
|
};
|
|
6753
6727
|
var parseFetchResponse = async (response) => {
|
|
6728
|
+
var _a, _b, _c;
|
|
6754
6729
|
assertResponseIsValid(response);
|
|
6755
|
-
if (response.headers
|
|
6730
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
6756
6731
|
const type = response.headers.get("X-Df-Response-Type");
|
|
6757
6732
|
return parseFetchResponseByResponseType(response, type);
|
|
6758
6733
|
}
|
|
6759
|
-
if (response.headers
|
|
6734
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-ResponseType")) {
|
|
6760
6735
|
const type = response.headers.get("X-Df-ResponseType");
|
|
6761
6736
|
return parseFetchResponseByResponseType(response, type);
|
|
6762
6737
|
}
|
|
6763
|
-
if (response.headers
|
|
6738
|
+
if ((_c = response.headers) == null ? void 0 : _c.has("X-Df-Exit")) {
|
|
6764
6739
|
return parseExitResponse(response);
|
|
6765
6740
|
}
|
|
6766
6741
|
const jsonBody = await parseResponseJson(response.clone());
|
|
@@ -6788,7 +6763,7 @@ var getJsonObjectOrNull = async (response) => {
|
|
|
6788
6763
|
var parseResponseJson = async (response) => {
|
|
6789
6764
|
try {
|
|
6790
6765
|
return await response.json();
|
|
6791
|
-
} catch {
|
|
6766
|
+
} catch (e) {
|
|
6792
6767
|
return null;
|
|
6793
6768
|
}
|
|
6794
6769
|
};
|
|
@@ -6805,8 +6780,8 @@ var assertResponseIsValid = (response) => {
|
|
|
6805
6780
|
var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
6806
6781
|
|
|
6807
6782
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
6808
|
-
var
|
|
6809
|
-
var
|
|
6783
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
6784
|
+
var noop6 = () => {
|
|
6810
6785
|
};
|
|
6811
6786
|
var DynamicFlowComponent = ({
|
|
6812
6787
|
flowId,
|
|
@@ -6817,8 +6792,8 @@ var DynamicFlowComponent = ({
|
|
|
6817
6792
|
displayStepTitle = true,
|
|
6818
6793
|
onCompletion,
|
|
6819
6794
|
onError,
|
|
6820
|
-
onEvent =
|
|
6821
|
-
onLog =
|
|
6795
|
+
onEvent = noop6,
|
|
6796
|
+
onLog = noop6
|
|
6822
6797
|
}) => {
|
|
6823
6798
|
const { locale } = (0, import_react_intl32.useIntl)();
|
|
6824
6799
|
const {
|
|
@@ -6838,9 +6813,12 @@ var DynamicFlowComponent = ({
|
|
|
6838
6813
|
loaderConfig,
|
|
6839
6814
|
initialStep ? "idle" : "initial"
|
|
6840
6815
|
);
|
|
6841
|
-
const logCritical = getLogger("critical", onLog, flowId, step
|
|
6816
|
+
const logCritical = getLogger("critical", onLog, flowId, (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key));
|
|
6842
6817
|
const analyticsMetadata = (0, import_react41.useMemo)(
|
|
6843
|
-
() =>
|
|
6818
|
+
() => {
|
|
6819
|
+
var _a;
|
|
6820
|
+
return __spreadValues({ flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key) }, (_a = step == null ? void 0 : step.analytics) != null ? _a : {});
|
|
6821
|
+
},
|
|
6844
6822
|
[flowId, step]
|
|
6845
6823
|
);
|
|
6846
6824
|
const dispatchEvent = (0, import_react41.useMemo)(
|
|
@@ -6850,14 +6828,13 @@ var DynamicFlowComponent = ({
|
|
|
6850
6828
|
const dfHttpClient = (0, import_react41.useCallback)(
|
|
6851
6829
|
({ action, data, etag: etag2 }) => {
|
|
6852
6830
|
const { url, method = "POST" } = action;
|
|
6853
|
-
return httpClient(url
|
|
6831
|
+
return httpClient(url != null ? url : "", {
|
|
6854
6832
|
method,
|
|
6855
|
-
headers: {
|
|
6833
|
+
headers: __spreadValues({
|
|
6856
6834
|
"accept-language": locale,
|
|
6857
6835
|
// FIXME move this out of the library https://transferwise.atlassian.net/browse/MC-3286
|
|
6858
|
-
"Content-Type": "application/json"
|
|
6859
|
-
|
|
6860
|
-
},
|
|
6836
|
+
"Content-Type": "application/json"
|
|
6837
|
+
}, etag2 ? { "If-None-Match": etag2 } : {}),
|
|
6861
6838
|
credentials: "include",
|
|
6862
6839
|
body: method === "GET" ? void 0 : JSON.stringify(data)
|
|
6863
6840
|
});
|
|
@@ -6895,7 +6872,7 @@ var DynamicFlowComponent = ({
|
|
|
6895
6872
|
};
|
|
6896
6873
|
const handleExitResponse = async (response, actionResult) => {
|
|
6897
6874
|
const exitResult = await getJsonObjectOrNull(response);
|
|
6898
|
-
dispatchEventAndComplete({
|
|
6875
|
+
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
6899
6876
|
};
|
|
6900
6877
|
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6901
6878
|
const dispatchEventAndComplete = (0, import_react41.useCallback)(
|
|
@@ -6910,11 +6887,10 @@ var DynamicFlowComponent = ({
|
|
|
6910
6887
|
}, []);
|
|
6911
6888
|
(0, import_react41.useEffect)(() => {
|
|
6912
6889
|
if (!initialStep) {
|
|
6913
|
-
const action = {
|
|
6890
|
+
const action = __spreadValues({
|
|
6914
6891
|
id: "#initial-step-request",
|
|
6915
|
-
method: "GET"
|
|
6916
|
-
|
|
6917
|
-
};
|
|
6892
|
+
method: "GET"
|
|
6893
|
+
}, initialAction);
|
|
6918
6894
|
void performAction(action, action.data);
|
|
6919
6895
|
}
|
|
6920
6896
|
}, [httpClient, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
@@ -6946,10 +6922,9 @@ var DynamicFlowComponent = ({
|
|
|
6946
6922
|
setLoadingState("idle");
|
|
6947
6923
|
if (fetchType === "submission") {
|
|
6948
6924
|
setSubmitted(false);
|
|
6949
|
-
dispatchEvent("Dynamic Flow - Step Started", {
|
|
6950
|
-
stepId: newStep.id || newStep.key
|
|
6951
|
-
|
|
6952
|
-
});
|
|
6925
|
+
dispatchEvent("Dynamic Flow - Step Started", __spreadValues({
|
|
6926
|
+
stepId: newStep.id || newStep.key
|
|
6927
|
+
}, newStep == null ? void 0 : newStep.analytics));
|
|
6953
6928
|
} else {
|
|
6954
6929
|
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
|
|
6955
6930
|
}
|
|
@@ -6995,7 +6970,7 @@ var DynamicFlowComponent = ({
|
|
|
6995
6970
|
const { triggerSchema } = props;
|
|
6996
6971
|
if (shouldTriggerRefresh(props)) {
|
|
6997
6972
|
const triggerSchemaRefreshUrl = triggerSchema.refreshUrl || triggerSchema.refreshFormUrl;
|
|
6998
|
-
const stepRefreshUrl = step
|
|
6973
|
+
const stepRefreshUrl = (step == null ? void 0 : step.refreshUrl) || (step == null ? void 0 : step.refreshFormUrl);
|
|
6999
6974
|
const refreshUrl = triggerSchemaRefreshUrl || stepRefreshUrl;
|
|
7000
6975
|
if (refreshUrl) {
|
|
7001
6976
|
debouncedRefresh(refreshUrl, combineModels2(updatedModels), etag, triggerSchema);
|
|
@@ -7012,7 +6987,7 @@ var DynamicFlowComponent = ({
|
|
|
7012
6987
|
}
|
|
7013
6988
|
const actionHandler = action.exit ? performExitAction : performAction;
|
|
7014
6989
|
const { data, method, skipValidation } = action;
|
|
7015
|
-
const submissionData = {
|
|
6990
|
+
const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
|
|
7016
6991
|
if (isSubmissionMethod(method)) {
|
|
7017
6992
|
setFormErrors(null);
|
|
7018
6993
|
if (!skipValidation) {
|
|
@@ -7025,7 +7000,7 @@ var DynamicFlowComponent = ({
|
|
|
7025
7000
|
await actionHandler(action);
|
|
7026
7001
|
}
|
|
7027
7002
|
};
|
|
7028
|
-
return /* @__PURE__ */ (0,
|
|
7003
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(HttpClientProvider, { httpClient, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
|
|
7029
7004
|
DynamicFlowStep,
|
|
7030
7005
|
{
|
|
7031
7006
|
step,
|
|
@@ -7041,10 +7016,10 @@ var DynamicFlowComponent = ({
|
|
|
7041
7016
|
}
|
|
7042
7017
|
) }) }) }) });
|
|
7043
7018
|
};
|
|
7044
|
-
var DynamicFlow = (props) => /* @__PURE__ */ (0,
|
|
7019
|
+
var DynamicFlow = (props) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ErrorBoundary_default, { onError: props.onError, children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(DynamicFlowComponent, __spreadValues({}, props)) });
|
|
7045
7020
|
var DynamicFlow_default = DynamicFlow;
|
|
7046
7021
|
var combineModels2 = (formModels) => {
|
|
7047
|
-
return Object.values(formModels).reduce((previous, model) => ({
|
|
7022
|
+
return Object.values(formModels).reduce((previous, model) => __spreadValues(__spreadValues({}, previous), model), {});
|
|
7048
7023
|
};
|
|
7049
7024
|
var isSubmissionMethod = (method = "POST") => {
|
|
7050
7025
|
const submissionMethods = ["POST", "PUT", "PATCH"];
|
|
@@ -7054,10 +7029,31 @@ var shouldTriggerRefresh = (props) => {
|
|
|
7054
7029
|
const { type, triggerSchema, triggerModel, lastTriggerModel = null } = props;
|
|
7055
7030
|
const isValid = () => isValidSchema(triggerModel, triggerSchema);
|
|
7056
7031
|
const wasValid = () => isValidSchema(lastTriggerModel, triggerSchema);
|
|
7057
|
-
const hasRefreshOnChange = triggerSchema
|
|
7032
|
+
const hasRefreshOnChange = (triggerSchema == null ? void 0 : triggerSchema.refreshStepOnChange) || (triggerSchema == null ? void 0 : triggerSchema.refreshFormOnChange);
|
|
7058
7033
|
return type !== "init" && hasRefreshOnChange && (isValid() || wasValid());
|
|
7059
7034
|
};
|
|
7060
7035
|
|
|
7036
|
+
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
7037
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
7038
|
+
var JsonSchemaForm = (props) => {
|
|
7039
|
+
const schemaProps = __spreadValues({
|
|
7040
|
+
model: null,
|
|
7041
|
+
errors: null
|
|
7042
|
+
}, props);
|
|
7043
|
+
const { baseUrl = "", onEvent = noop7, onLog = noop7 } = props;
|
|
7044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7045
|
+
EventsContextProvider,
|
|
7046
|
+
{
|
|
7047
|
+
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
7048
|
+
onEvent,
|
|
7049
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(GenericSchema_default, __spreadValues({}, schemaProps)) })
|
|
7050
|
+
}
|
|
7051
|
+
) });
|
|
7052
|
+
};
|
|
7053
|
+
var JsonSchemaForm_default = JsonSchemaForm;
|
|
7054
|
+
var noop7 = () => {
|
|
7055
|
+
};
|
|
7056
|
+
|
|
7061
7057
|
// src/i18n/de.json
|
|
7062
7058
|
var de_default = {
|
|
7063
7059
|
"dynamicFlows.ArraySchema.addItem": "Speichern",
|