@wise/dynamic-flow-client 2.2.0 → 2.2.1
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 +411 -406
- package/build/main.min.js +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
|
};
|
|
@@ -4775,15 +4761,14 @@ var isValidGenericSchema = (schema, model, errors) => {
|
|
|
4775
4761
|
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
4776
4762
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4777
4763
|
var JsonSchemaForm = (props) => {
|
|
4778
|
-
const schemaProps = {
|
|
4764
|
+
const schemaProps = __spreadValues({
|
|
4779
4765
|
model: null,
|
|
4780
4766
|
errors: null,
|
|
4781
4767
|
disabled: false,
|
|
4782
|
-
baseUrl: ""
|
|
4783
|
-
|
|
4784
|
-
};
|
|
4768
|
+
baseUrl: ""
|
|
4769
|
+
}, props);
|
|
4785
4770
|
if (useHasHttpClientProvider() || schemaProps.baseUrl == null) {
|
|
4786
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, {
|
|
4771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps));
|
|
4787
4772
|
}
|
|
4788
4773
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4789
4774
|
Providers,
|
|
@@ -4791,17 +4776,17 @@ var JsonSchemaForm = (props) => {
|
|
|
4791
4776
|
baseUrl: schemaProps.baseUrl,
|
|
4792
4777
|
onEvent: schemaProps.onEvent,
|
|
4793
4778
|
onLog: schemaProps.onLog,
|
|
4794
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, {
|
|
4779
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, __spreadValues({}, schemaProps))
|
|
4795
4780
|
}
|
|
4796
4781
|
);
|
|
4797
4782
|
};
|
|
4798
4783
|
var JsonSchemaForm_default = JsonSchemaForm;
|
|
4799
4784
|
var Providers = ({ baseUrl, onEvent, onLog, children }) => {
|
|
4800
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog
|
|
4785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog != null ? onLog : noop2, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4801
4786
|
EventsContextProvider,
|
|
4802
4787
|
{
|
|
4803
4788
|
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
4804
|
-
onEvent: onEvent
|
|
4789
|
+
onEvent: onEvent != null ? onEvent : noop2,
|
|
4805
4790
|
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children })
|
|
4806
4791
|
}
|
|
4807
4792
|
) });
|
|
@@ -4822,7 +4807,7 @@ var DynamicForm = (props) => {
|
|
|
4822
4807
|
submitted: props.submitted,
|
|
4823
4808
|
errors: props.errors,
|
|
4824
4809
|
onChange: (parameters) => {
|
|
4825
|
-
props.onModelChange({ formSchema,
|
|
4810
|
+
props.onModelChange(__spreadValues({ formSchema }, parameters));
|
|
4826
4811
|
},
|
|
4827
4812
|
onPersistAsync: props.onPersistAsync
|
|
4828
4813
|
}
|
|
@@ -4882,7 +4867,7 @@ var DynamicImage = ({ component: image }) => {
|
|
|
4882
4867
|
if (!imageSource) {
|
|
4883
4868
|
return null;
|
|
4884
4869
|
}
|
|
4885
|
-
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components18.Image, { className: `img-responsive ${getMargin(margin || "md")}
|
|
4870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components18.Image, __spreadValues({ className: `img-responsive ${getMargin(margin || "md")}` }, imageProps)) });
|
|
4886
4871
|
};
|
|
4887
4872
|
var readImageBlobAsDataURL = (imageBlob) => {
|
|
4888
4873
|
return new Promise((resolve, reject) => {
|
|
@@ -4893,8 +4878,9 @@ var readImageBlobAsDataURL = (imageBlob) => {
|
|
|
4893
4878
|
});
|
|
4894
4879
|
};
|
|
4895
4880
|
var getImageSource = async (httpClient, imageUrl) => {
|
|
4881
|
+
var _a;
|
|
4896
4882
|
try {
|
|
4897
|
-
if (isRelativePath(imageUrl) || imageUrl
|
|
4883
|
+
if (isRelativePath(imageUrl) || (imageUrl == null ? void 0 : imageUrl.indexOf(`${(_a = window == null ? void 0 : window.location) == null ? void 0 : _a.origin}/`)) === 0) {
|
|
4898
4884
|
return httpClient(imageUrl, {
|
|
4899
4885
|
method: "GET",
|
|
4900
4886
|
headers: { "Content-Type": "image/image" },
|
|
@@ -4907,7 +4893,7 @@ var getImageSource = async (httpClient, imageUrl) => {
|
|
|
4907
4893
|
}).then(readImageBlobAsDataURL).catch(() => imageUrl);
|
|
4908
4894
|
}
|
|
4909
4895
|
return imageUrl;
|
|
4910
|
-
} catch {
|
|
4896
|
+
} catch (e) {
|
|
4911
4897
|
return imageUrl;
|
|
4912
4898
|
}
|
|
4913
4899
|
};
|
|
@@ -4979,7 +4965,7 @@ var DynamicLayout = (props) => {
|
|
|
4979
4965
|
onModelChange,
|
|
4980
4966
|
onPersistAsync
|
|
4981
4967
|
},
|
|
4982
|
-
getKey({
|
|
4968
|
+
getKey(__spreadProps(__spreadValues({}, component), { errors: errors != null ? errors : null }))
|
|
4983
4969
|
);
|
|
4984
4970
|
case "button":
|
|
4985
4971
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
@@ -5034,14 +5020,12 @@ var DynamicStatusList = ({ component }) => {
|
|
|
5034
5020
|
] });
|
|
5035
5021
|
};
|
|
5036
5022
|
var mapListItemToSummary = ({ title, description, icon, status }) => {
|
|
5037
|
-
const props = {
|
|
5023
|
+
const props = __spreadValues(__spreadValues({
|
|
5038
5024
|
key: `${title}/${description || ""}`,
|
|
5039
5025
|
title,
|
|
5040
|
-
description
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
};
|
|
5044
|
-
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Summary, { ...props });
|
|
5026
|
+
description
|
|
5027
|
+
}, (icon == null ? void 0 : icon.name) ? { icon: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(DynamicIcon_default, { type: icon.name }) } : {}), status ? { status: statusMap[status] } : {});
|
|
5028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Summary, __spreadValues({}, props));
|
|
5045
5029
|
};
|
|
5046
5030
|
var statusListMap = {
|
|
5047
5031
|
done: "done",
|
|
@@ -5053,7 +5037,7 @@ var legacyStatusMap = {
|
|
|
5053
5037
|
warning: "pending",
|
|
5054
5038
|
neutral: "notDone"
|
|
5055
5039
|
};
|
|
5056
|
-
var statusMap = {
|
|
5040
|
+
var statusMap = __spreadValues(__spreadValues({}, statusListMap), legacyStatusMap);
|
|
5057
5041
|
var DynamicStatusList_default = DynamicStatusList;
|
|
5058
5042
|
|
|
5059
5043
|
// src/layout/loadingIndicator/DynamicLoadingIndicator.tsx
|
|
@@ -5116,7 +5100,8 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5116
5100
|
const createSnackbar = useSnackBarIfAvailable();
|
|
5117
5101
|
const { text } = component;
|
|
5118
5102
|
const copy = () => {
|
|
5119
|
-
|
|
5103
|
+
var _a;
|
|
5104
|
+
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
5120
5105
|
};
|
|
5121
5106
|
const classNames7 = getTextAlignmentAndMargin({ align: component.align }) + " form-control";
|
|
5122
5107
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
@@ -5289,7 +5274,8 @@ var useSearch = (defaultSearchConfig) => {
|
|
|
5289
5274
|
const httpClient = useHttpClient();
|
|
5290
5275
|
const search = (0, import_react25.useCallback)(
|
|
5291
5276
|
async (query, { url, method, param } = defaultSearchConfig) => {
|
|
5292
|
-
|
|
5277
|
+
var _a;
|
|
5278
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
5293
5279
|
if (!query) {
|
|
5294
5280
|
setState({ status: "idle" });
|
|
5295
5281
|
return;
|
|
@@ -5399,6 +5385,7 @@ var getDefaultValue = (schema) => {
|
|
|
5399
5385
|
return schema.type === "boolean" && isNullish(schema.default) ? false : schema.default;
|
|
5400
5386
|
};
|
|
5401
5387
|
var BasicTypeSchema = (props) => {
|
|
5388
|
+
var _a, _b, _c;
|
|
5402
5389
|
const onChange = (newModel) => {
|
|
5403
5390
|
setChanged(true);
|
|
5404
5391
|
setModelAndBroadcast(sanitiseModel(newModel), "user");
|
|
@@ -5429,8 +5416,8 @@ var BasicTypeSchema = (props) => {
|
|
|
5429
5416
|
props.onBlur();
|
|
5430
5417
|
}
|
|
5431
5418
|
};
|
|
5432
|
-
const [model, setModel] = (0, import_react27.useState)(props.model
|
|
5433
|
-
const [lastModel, setLastModel] = (0, import_react27.useState)(props.model
|
|
5419
|
+
const [model, setModel] = (0, import_react27.useState)((_a = props.model) != null ? _a : null);
|
|
5420
|
+
const [lastModel, setLastModel] = (0, import_react27.useState)((_b = props.model) != null ? _b : null);
|
|
5434
5421
|
const [changed, setChanged] = (0, import_react27.useState)(false);
|
|
5435
5422
|
const [focused, setFocused] = (0, import_react27.useState)(false);
|
|
5436
5423
|
const [blurred, setBlurred] = (0, import_react27.useState)(false);
|
|
@@ -5453,7 +5440,8 @@ var BasicTypeSchema = (props) => {
|
|
|
5453
5440
|
(0, import_react27.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
5454
5441
|
(0, import_react27.useEffect)(onSchemaChange, [props.schema]);
|
|
5455
5442
|
(0, import_react27.useEffect)(() => {
|
|
5456
|
-
|
|
5443
|
+
var _a2;
|
|
5444
|
+
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
5457
5445
|
if (newModel !== model) {
|
|
5458
5446
|
setModel(newModel);
|
|
5459
5447
|
}
|
|
@@ -5495,7 +5483,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5495
5483
|
focused,
|
|
5496
5484
|
blurred,
|
|
5497
5485
|
submitted: props.submitted,
|
|
5498
|
-
errors: props.errors
|
|
5486
|
+
errors: (_c = props.errors) != null ? _c : null,
|
|
5499
5487
|
schema: props.schema,
|
|
5500
5488
|
validations,
|
|
5501
5489
|
infoMessage: props.infoMessage
|
|
@@ -5517,7 +5505,8 @@ var getIdFromResponse = (idProperty, response) => {
|
|
|
5517
5505
|
return response[idProperty];
|
|
5518
5506
|
};
|
|
5519
5507
|
var getErrorFromResponse = (errorProperty, response) => {
|
|
5520
|
-
|
|
5508
|
+
var _a;
|
|
5509
|
+
return (_a = response.validation) == null ? void 0 : _a[errorProperty];
|
|
5521
5510
|
};
|
|
5522
5511
|
var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
|
|
5523
5512
|
FormControlType.RADIO,
|
|
@@ -5569,14 +5558,14 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5569
5558
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
5570
5559
|
} else if (isStatus422(response.status)) {
|
|
5571
5560
|
const { validation } = responseBody;
|
|
5572
|
-
const error = isObject(validation) && validation
|
|
5561
|
+
const error = isObject(validation) && (validation == null ? void 0 : validation[param]) || null;
|
|
5573
5562
|
setPersistAsyncError(error);
|
|
5574
5563
|
onChange({ model: null, triggerSchema: schema, triggerModel: null });
|
|
5575
5564
|
} else {
|
|
5576
5565
|
setGenericPersistAsyncError();
|
|
5577
5566
|
}
|
|
5578
5567
|
onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
|
|
5579
|
-
} catch {
|
|
5568
|
+
} catch (e) {
|
|
5580
5569
|
onEvent("Dynamic Flow - PersistAsync", { status: "failure", schemaId: schema.$id });
|
|
5581
5570
|
setGenericPersistAsyncError();
|
|
5582
5571
|
}
|
|
@@ -5650,9 +5639,7 @@ var usePersistAsync = (persistAsync) => {
|
|
|
5650
5639
|
const requestBody = isBlob ? wrapInFormData(requestKey, model) : JSON.stringify({ [requestKey]: model });
|
|
5651
5640
|
return {
|
|
5652
5641
|
method: persistAsync.method,
|
|
5653
|
-
headers: {
|
|
5654
|
-
...!isBlob && { "Content-Type": "application/json" }
|
|
5655
|
-
},
|
|
5642
|
+
headers: __spreadValues({}, !isBlob && { "Content-Type": "application/json" }),
|
|
5656
5643
|
body: requestBody,
|
|
5657
5644
|
signal
|
|
5658
5645
|
};
|
|
@@ -5793,7 +5780,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5793
5780
|
}, [polling, httpClient]);
|
|
5794
5781
|
const onPollingResponse = (0, import_react32.useCallback)(
|
|
5795
5782
|
(pollingResponse) => {
|
|
5796
|
-
if (pollingResponse
|
|
5783
|
+
if (pollingResponse == null ? void 0 : pollingResponse.action) {
|
|
5797
5784
|
onAction(pollingResponse.action);
|
|
5798
5785
|
return false;
|
|
5799
5786
|
}
|
|
@@ -5803,8 +5790,8 @@ function useStepPolling(polling, onAction) {
|
|
|
5803
5790
|
);
|
|
5804
5791
|
usePolling({
|
|
5805
5792
|
asyncFn,
|
|
5806
|
-
interval: 1e3 * (polling
|
|
5807
|
-
maxAttempts: polling
|
|
5793
|
+
interval: 1e3 * ((polling == null ? void 0 : polling.interval) || 0),
|
|
5794
|
+
maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
|
|
5808
5795
|
maxConsecutiveFails: 1,
|
|
5809
5796
|
onPollingResponse,
|
|
5810
5797
|
onFailure: (0, import_react32.useCallback)(() => {
|
|
@@ -5818,6 +5805,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5818
5805
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5819
5806
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5820
5807
|
var getComponents = (step, options) => {
|
|
5808
|
+
var _a;
|
|
5821
5809
|
if (isEmpty(step)) {
|
|
5822
5810
|
return [];
|
|
5823
5811
|
}
|
|
@@ -5826,7 +5814,7 @@ var getComponents = (step, options) => {
|
|
|
5826
5814
|
layout,
|
|
5827
5815
|
schemas: step.schemas || [],
|
|
5828
5816
|
actions: step.actions || [],
|
|
5829
|
-
model: step.model
|
|
5817
|
+
model: (_a = step.model) != null ? _a : null
|
|
5830
5818
|
});
|
|
5831
5819
|
};
|
|
5832
5820
|
var LayoutStep = (props) => {
|
|
@@ -5933,16 +5921,17 @@ var import_react33 = require("react");
|
|
|
5933
5921
|
|
|
5934
5922
|
// src/step/cameraStep/cameraCapture/utils/index.ts
|
|
5935
5923
|
var isSelfieCamera = (stream) => {
|
|
5936
|
-
|
|
5924
|
+
var _a;
|
|
5925
|
+
const { facingMode } = ((_a = getVideoTrack(stream)) == null ? void 0 : _a.getSettings()) || {};
|
|
5937
5926
|
return facingMode === "user" || facingMode === void 0;
|
|
5938
5927
|
};
|
|
5939
|
-
var isMainBackCamera = (deviceInfo) => !!(deviceInfo
|
|
5928
|
+
var isMainBackCamera = (deviceInfo) => !!((deviceInfo == null ? void 0 : deviceInfo.label) || "").match(/camera2? 0/g);
|
|
5940
5929
|
var generateCanvasFromVideo = async (video) => {
|
|
5941
5930
|
const canvas = document.createElement("canvas");
|
|
5942
5931
|
if (video) {
|
|
5943
5932
|
canvas.setAttribute("height", `${video.videoHeight}`);
|
|
5944
5933
|
canvas.setAttribute("width", `${video.videoWidth}`);
|
|
5945
|
-
const context = canvas
|
|
5934
|
+
const context = canvas == null ? void 0 : canvas.getContext("2d");
|
|
5946
5935
|
if (context) {
|
|
5947
5936
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
5948
5937
|
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
@@ -5950,16 +5939,29 @@ var generateCanvasFromVideo = async (video) => {
|
|
|
5950
5939
|
}
|
|
5951
5940
|
return canvas;
|
|
5952
5941
|
};
|
|
5953
|
-
var getAvailableVideoDevices = async () =>
|
|
5954
|
-
|
|
5955
|
-
)
|
|
5956
|
-
|
|
5942
|
+
var getAvailableVideoDevices = async () => {
|
|
5943
|
+
var _a, _b;
|
|
5944
|
+
return (await ((_b = (_a = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a.enumerateDevices) == null ? void 0 : _b.call(_a)) || []).filter(
|
|
5945
|
+
(deviceInfo) => deviceInfo.kind === "videoinput"
|
|
5946
|
+
);
|
|
5947
|
+
};
|
|
5948
|
+
var getAvailableVideoDeviceLabels = async () => {
|
|
5949
|
+
var _a, _b;
|
|
5950
|
+
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);
|
|
5951
|
+
};
|
|
5957
5952
|
var getActiveVideoDeviceLabel = async (videoStream) => {
|
|
5953
|
+
var _a, _b, _c;
|
|
5958
5954
|
const capabilities = getVideoCapabilities(videoStream);
|
|
5959
|
-
return (await navigator
|
|
5955
|
+
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;
|
|
5956
|
+
};
|
|
5957
|
+
var getVideoTrack = (videoStream) => {
|
|
5958
|
+
var _a;
|
|
5959
|
+
return (((_a = videoStream == null ? void 0 : videoStream.getVideoTracks) == null ? void 0 : _a.call(videoStream)) || [])[0];
|
|
5960
|
+
};
|
|
5961
|
+
var getVideoCapabilities = (videoStream) => {
|
|
5962
|
+
var _a, _b;
|
|
5963
|
+
return (_b = (_a = getVideoTrack(videoStream)) == null ? void 0 : _a.getCapabilities) == null ? void 0 : _b.call(_a);
|
|
5960
5964
|
};
|
|
5961
|
-
var getVideoTrack = (videoStream) => (videoStream?.getVideoTracks?.() || [])[0];
|
|
5962
|
-
var getVideoCapabilities = (videoStream) => getVideoTrack(videoStream)?.getCapabilities?.();
|
|
5963
5965
|
|
|
5964
5966
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
5965
5967
|
var useVideoConstraints = (direction) => {
|
|
@@ -5977,11 +5979,10 @@ var useVideoConstraints = (direction) => {
|
|
|
5977
5979
|
const getVideoConstraints = async (direction2) => {
|
|
5978
5980
|
if (direction2 === "back") {
|
|
5979
5981
|
const mainCamera = (await getAvailableVideoDevices()).find(isMainBackCamera);
|
|
5980
|
-
if (mainCamera
|
|
5981
|
-
return {
|
|
5982
|
-
...defaultVideoConstraints,
|
|
5982
|
+
if (mainCamera == null ? void 0 : mainCamera.deviceId) {
|
|
5983
|
+
return __spreadProps(__spreadValues({}, defaultVideoConstraints), {
|
|
5983
5984
|
deviceId: { exact: mainCamera.deviceId }
|
|
5984
|
-
};
|
|
5985
|
+
});
|
|
5985
5986
|
}
|
|
5986
5987
|
}
|
|
5987
5988
|
return defaultVideoConstraints;
|
|
@@ -6010,7 +6011,8 @@ var Overlay = ({
|
|
|
6010
6011
|
const svgReference = (0, import_react34.useRef)(null);
|
|
6011
6012
|
(0, import_react34.useEffect)(() => {
|
|
6012
6013
|
const listener = debounce(() => {
|
|
6013
|
-
|
|
6014
|
+
var _a;
|
|
6015
|
+
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
6014
6016
|
const reference = svgReference.current;
|
|
6015
6017
|
reference.innerHTML += "";
|
|
6016
6018
|
}
|
|
@@ -6051,11 +6053,11 @@ var Overlay = ({
|
|
|
6051
6053
|
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
|
|
6052
6054
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("mask", { id: "mask", children: [
|
|
6053
6055
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("rect", { width: "100%", height: "100%", fill: "#fff" }),
|
|
6054
|
-
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", { href: overlay,
|
|
6056
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", __spreadValues({ href: overlay }, framePosition))
|
|
6055
6057
|
] }) }),
|
|
6056
6058
|
overlay && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("rect", { width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.72" }),
|
|
6057
|
-
outline && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", { href: outline,
|
|
6058
|
-
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "camera-capture-text-and-image-container",
|
|
6059
|
+
outline && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", __spreadValues({ href: outline }, framePosition)),
|
|
6060
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", __spreadProps(__spreadValues({ className: "camera-capture-text-and-image-container" }, helperBoxPosition), { children: helperBox })) })
|
|
6059
6061
|
] });
|
|
6060
6062
|
};
|
|
6061
6063
|
var Overlay_default = Overlay;
|
|
@@ -6126,22 +6128,22 @@ var CameraNotSupported = () => {
|
|
|
6126
6128
|
var CameraNotSupported_default = CameraNotSupported;
|
|
6127
6129
|
|
|
6128
6130
|
// 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
|
|
6131
|
+
var trackCameraPermissionDenied = (onEvent) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Permission Denied", {});
|
|
6132
|
+
var trackCameraFeedStarted = async (onEvent, props, stream) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Feed Started", await getCameraStartedProperties(props, stream));
|
|
6133
|
+
var trackCameraNotSupported = (onEvent, error) => onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Not Supported", { Error: error });
|
|
6132
6134
|
var getCameraStartedProperties = async (props, videoStream) => {
|
|
6135
|
+
var _a;
|
|
6133
6136
|
const videoTrack = getVideoTrack(videoStream);
|
|
6134
6137
|
const capabilities = getVideoCapabilities(videoStream);
|
|
6135
|
-
const settings = videoTrack
|
|
6136
|
-
return {
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
};
|
|
6138
|
+
const settings = (_a = videoTrack == null ? void 0 : videoTrack.getSettings) == null ? void 0 : _a.call(videoTrack);
|
|
6139
|
+
return __spreadProps(__spreadValues({}, videoTrack && {
|
|
6140
|
+
"Available Video Devices (by label)": await getAvailableVideoDeviceLabels(),
|
|
6141
|
+
"Active Video Device (by label)": await getActiveVideoDeviceLabel(videoStream),
|
|
6142
|
+
"Camera Capabilities": capabilities,
|
|
6143
|
+
"Camera Settings": settings
|
|
6144
|
+
}), {
|
|
6145
|
+
"Camera Direction (Asked)": props == null ? void 0 : props.direction
|
|
6146
|
+
});
|
|
6145
6147
|
};
|
|
6146
6148
|
|
|
6147
6149
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
@@ -6165,10 +6167,11 @@ var CameraCapture = ({
|
|
|
6165
6167
|
const { videoConstraints } = useVideoConstraints(direction);
|
|
6166
6168
|
const intl = (0, import_react_intl28.useIntl)();
|
|
6167
6169
|
const handleCapture = (0, import_react35.useCallback)(async () => {
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
canvas
|
|
6170
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6171
|
+
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) {
|
|
6172
|
+
(_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
|
|
6173
|
+
const canvas = await generateCanvasFromVideo((_f = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _f.video);
|
|
6174
|
+
canvas == null ? void 0 : canvas.toBlob(
|
|
6172
6175
|
(blob) => {
|
|
6173
6176
|
if (blob) {
|
|
6174
6177
|
if (showReview) {
|
|
@@ -6187,7 +6190,7 @@ var CameraCapture = ({
|
|
|
6187
6190
|
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
6188
6191
|
const handleUserMediaError = (0, import_react35.useCallback)(
|
|
6189
6192
|
(error) => {
|
|
6190
|
-
if (error instanceof DOMException && error
|
|
6193
|
+
if (error instanceof DOMException && (error == null ? void 0 : error.name) === "NotAllowedError") {
|
|
6191
6194
|
setMode("NO_CAMERA_ACCESS");
|
|
6192
6195
|
trackCameraPermissionDenied(onEvent);
|
|
6193
6196
|
return;
|
|
@@ -6206,7 +6209,7 @@ var CameraCapture = ({
|
|
|
6206
6209
|
[setIsVideoMirrored, onEvent, direction]
|
|
6207
6210
|
);
|
|
6208
6211
|
const handleReviewSubmit = () => {
|
|
6209
|
-
onCapture(reviewImage
|
|
6212
|
+
onCapture((reviewImage == null ? void 0 : reviewImage.blob) || null);
|
|
6210
6213
|
};
|
|
6211
6214
|
const handleReviewRetry = () => {
|
|
6212
6215
|
setMode("CAPTURE");
|
|
@@ -6238,7 +6241,7 @@ var CameraCapture = ({
|
|
|
6238
6241
|
ready && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
6239
6242
|
] });
|
|
6240
6243
|
const reviewScreen = /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
|
|
6241
|
-
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("img", { className: "review-image", src: reviewImage
|
|
6244
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)("img", { className: "review-image", src: reviewImage == null ? void 0 : reviewImage.source, alt: "" }),
|
|
6242
6245
|
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
6243
6246
|
Overlay_default,
|
|
6244
6247
|
{
|
|
@@ -6337,10 +6340,11 @@ function getCameraSchema(step) {
|
|
|
6337
6340
|
return firstProperty;
|
|
6338
6341
|
}
|
|
6339
6342
|
function getFirstAction(step) {
|
|
6340
|
-
|
|
6343
|
+
var _a, _b;
|
|
6344
|
+
if (!step.schemas || ((_a = filterHiddenSchemas(step.schemas)) == null ? void 0 : _a.length) !== 1) {
|
|
6341
6345
|
throw new Error("camera step expects 1 non-hidden object schema");
|
|
6342
6346
|
}
|
|
6343
|
-
if (step
|
|
6347
|
+
if (((_b = step == null ? void 0 : step.actions) == null ? void 0 : _b.length) !== 1) {
|
|
6344
6348
|
throw new Error("camera step expects 1 action");
|
|
6345
6349
|
}
|
|
6346
6350
|
return step.actions[0];
|
|
@@ -6439,7 +6443,7 @@ var ExternalConfirmationStep_default = ExternalConfirmationStep;
|
|
|
6439
6443
|
function getOrigin(url) {
|
|
6440
6444
|
try {
|
|
6441
6445
|
return new URL(url).origin;
|
|
6442
|
-
} catch {
|
|
6446
|
+
} catch (e) {
|
|
6443
6447
|
return url;
|
|
6444
6448
|
}
|
|
6445
6449
|
}
|
|
@@ -6454,7 +6458,7 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6454
6458
|
{
|
|
6455
6459
|
onClick: (event) => {
|
|
6456
6460
|
event.preventDefault();
|
|
6457
|
-
onAction({
|
|
6461
|
+
onAction(__spreadProps(__spreadValues({}, action), { skipValidation: true }));
|
|
6458
6462
|
},
|
|
6459
6463
|
href: "/",
|
|
6460
6464
|
className: "df-back-btn",
|
|
@@ -6471,9 +6475,10 @@ var BackButton_default = BackButton;
|
|
|
6471
6475
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6472
6476
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6473
6477
|
var DynamicFlowStep = (props) => {
|
|
6478
|
+
var _a, _b, _c;
|
|
6474
6479
|
const { step, globalError, onAction } = props;
|
|
6475
|
-
const externalUrl = step
|
|
6476
|
-
const backButton = step
|
|
6480
|
+
const externalUrl = (_a = step == null ? void 0 : step.external) == null ? void 0 : _a.url;
|
|
6481
|
+
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
6482
|
const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
|
|
6478
6483
|
if (step === void 0) {
|
|
6479
6484
|
return null;
|
|
@@ -6482,12 +6487,12 @@ var DynamicFlowStep = (props) => {
|
|
|
6482
6487
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
6483
6488
|
}
|
|
6484
6489
|
if (isCameraStep(step)) {
|
|
6485
|
-
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CameraStep_default, {
|
|
6490
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CameraStep_default, __spreadProps(__spreadValues({}, props), { step }));
|
|
6486
6491
|
}
|
|
6487
6492
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
6488
|
-
backButton && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BackButton_default, {
|
|
6493
|
+
backButton && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BackButton_default, __spreadProps(__spreadValues({}, backButton), { onAction })),
|
|
6489
6494
|
globalError ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DynamicAlert_default, { component: { context: "negative", markdown: globalError, margin: "lg" } }) : null,
|
|
6490
|
-
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(LayoutStep_default, {
|
|
6495
|
+
/* @__PURE__ */ (0, import_jsx_runtime65.jsx)(LayoutStep_default, __spreadProps(__spreadValues({}, props), { stepSpecification: step }))
|
|
6491
6496
|
] });
|
|
6492
6497
|
};
|
|
6493
6498
|
|
|
@@ -6520,29 +6525,30 @@ var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && sche
|
|
|
6520
6525
|
// src/dynamicFlow/utils/useDynamicFlowState.ts
|
|
6521
6526
|
var import_react38 = require("react");
|
|
6522
6527
|
var useDynamicFlowState = (initialStep) => {
|
|
6523
|
-
|
|
6524
|
-
const [
|
|
6528
|
+
var _a, _b;
|
|
6529
|
+
const [formErrors, setFormErrors] = (0, import_react38.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
|
|
6530
|
+
const [globalError, setGlobalError] = (0, import_react38.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
|
|
6525
6531
|
const [stepAndModels, setStepAndModels] = (0, import_react38.useState)({
|
|
6526
6532
|
step: initialStep || void 0,
|
|
6527
|
-
models: initialStep
|
|
6533
|
+
models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
6528
6534
|
etag: void 0
|
|
6529
6535
|
});
|
|
6530
6536
|
const { step, models, etag } = stepAndModels;
|
|
6531
6537
|
const setStepAndEtag = (step2, etag2) => {
|
|
6538
|
+
var _a2, _b2, _c, _d;
|
|
6532
6539
|
setStepAndModels((previous) => ({
|
|
6533
6540
|
step: step2,
|
|
6534
6541
|
models: step2.model ? buildInitialModels(step2.model, getAllSchemas(step2)) : previous.models,
|
|
6535
6542
|
etag: etag2
|
|
6536
6543
|
}));
|
|
6537
|
-
setFormErrors(step2
|
|
6538
|
-
setGlobalError(step2
|
|
6544
|
+
setFormErrors((_b2 = (_a2 = step2 == null ? void 0 : step2.errors) == null ? void 0 : _a2.validation) != null ? _b2 : null);
|
|
6545
|
+
setGlobalError((_d = (_c = step2 == null ? void 0 : step2.errors) == null ? void 0 : _c.error) != null ? _d : null);
|
|
6539
6546
|
};
|
|
6540
6547
|
const setSchemaModel = (schemaId, objectModel, onModelsUpdated) => {
|
|
6541
6548
|
setStepAndModels((previous) => {
|
|
6542
|
-
const updatedModels = {
|
|
6543
|
-
...previous.models,
|
|
6549
|
+
const updatedModels = __spreadProps(__spreadValues({}, previous.models), {
|
|
6544
6550
|
[schemaId]: objectModel
|
|
6545
|
-
};
|
|
6551
|
+
});
|
|
6546
6552
|
const updatedState = {
|
|
6547
6553
|
step: previous.step,
|
|
6548
6554
|
models: updatedModels,
|
|
@@ -6574,15 +6580,14 @@ var buildInitialModels = (model, schemas = []) => {
|
|
|
6574
6580
|
if (!schema.$id) {
|
|
6575
6581
|
console.warn("Schema without $id property found.");
|
|
6576
6582
|
}
|
|
6577
|
-
return {
|
|
6578
|
-
...acc,
|
|
6583
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
6579
6584
|
[schema.$id || ""]: getValidObjectModelParts(model, schema) || {}
|
|
6580
|
-
};
|
|
6585
|
+
});
|
|
6581
6586
|
}, {});
|
|
6582
6587
|
};
|
|
6583
6588
|
var getAllSchemas = (step) => [
|
|
6584
|
-
...getAllSchemasInLayout(step
|
|
6585
|
-
...step
|
|
6589
|
+
...getAllSchemasInLayout((step == null ? void 0 : step.layout) || []),
|
|
6590
|
+
...(step == null ? void 0 : step.schemas) || []
|
|
6586
6591
|
];
|
|
6587
6592
|
var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
6588
6593
|
switch (component.type) {
|
|
@@ -6597,8 +6602,8 @@ var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
|
6597
6602
|
}
|
|
6598
6603
|
});
|
|
6599
6604
|
var getAllValidatableSchemas = (step) => [
|
|
6600
|
-
...getAllReferencedSchemaIds(step
|
|
6601
|
-
...getAllSchemasInLayout(step
|
|
6605
|
+
...getAllReferencedSchemaIds((step == null ? void 0 : step.layout) || []).map((id) => ((step == null ? void 0 : step.schemas) || []).find((schema) => schema.$id === id)).filter(Boolean),
|
|
6606
|
+
...getAllSchemasInLayout((step == null ? void 0 : step.layout) || [])
|
|
6602
6607
|
];
|
|
6603
6608
|
var getAllReferencedSchemaIds = (components) => components.flatMap((component) => {
|
|
6604
6609
|
switch (component.type) {
|
|
@@ -6613,12 +6618,12 @@ var getAllReferencedSchemaIds = (components) => components.flatMap((component) =
|
|
|
6613
6618
|
}
|
|
6614
6619
|
}).filter(Boolean);
|
|
6615
6620
|
var areModelsValid = (formModels, schemas = []) => {
|
|
6616
|
-
return !schemas
|
|
6621
|
+
return !(schemas == null ? void 0 : schemas.some((schema) => {
|
|
6617
6622
|
if (!schema.$id) {
|
|
6618
6623
|
console.warn("Schema without $id property found.");
|
|
6619
6624
|
}
|
|
6620
6625
|
return !isValidSchema(formModels[schema.$id || ""] || {}, schema);
|
|
6621
|
-
});
|
|
6626
|
+
}));
|
|
6622
6627
|
};
|
|
6623
6628
|
var getSchemaReference = (component) => {
|
|
6624
6629
|
if (component.schema && !isInlineSchema(component.schema)) {
|
|
@@ -6635,12 +6640,11 @@ var import_components31 = require("@transferwise/components");
|
|
|
6635
6640
|
var import_react39 = require("react");
|
|
6636
6641
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
6637
6642
|
function useLoader(loaderConfig, initialState) {
|
|
6638
|
-
const config = {
|
|
6643
|
+
const config = __spreadValues({
|
|
6639
6644
|
size: import_components31.Size.EXTRA_LARGE,
|
|
6640
6645
|
initial: true,
|
|
6641
|
-
submission: false
|
|
6642
|
-
|
|
6643
|
-
};
|
|
6646
|
+
submission: false
|
|
6647
|
+
}, loaderConfig);
|
|
6644
6648
|
const [loadingState, setLoadingState] = (0, import_react39.useState)(initialState);
|
|
6645
6649
|
const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
|
|
6646
6650
|
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
@@ -6751,16 +6755,17 @@ var parseExitResponse = async (response) => {
|
|
|
6751
6755
|
return { type: "exit", result: await getJsonObjectOrNull(response) };
|
|
6752
6756
|
};
|
|
6753
6757
|
var parseFetchResponse = async (response) => {
|
|
6758
|
+
var _a, _b, _c;
|
|
6754
6759
|
assertResponseIsValid(response);
|
|
6755
|
-
if (response.headers
|
|
6760
|
+
if ((_a = response.headers) == null ? void 0 : _a.has("X-Df-Response-Type")) {
|
|
6756
6761
|
const type = response.headers.get("X-Df-Response-Type");
|
|
6757
6762
|
return parseFetchResponseByResponseType(response, type);
|
|
6758
6763
|
}
|
|
6759
|
-
if (response.headers
|
|
6764
|
+
if ((_b = response.headers) == null ? void 0 : _b.has("X-Df-ResponseType")) {
|
|
6760
6765
|
const type = response.headers.get("X-Df-ResponseType");
|
|
6761
6766
|
return parseFetchResponseByResponseType(response, type);
|
|
6762
6767
|
}
|
|
6763
|
-
if (response.headers
|
|
6768
|
+
if ((_c = response.headers) == null ? void 0 : _c.has("X-Df-Exit")) {
|
|
6764
6769
|
return parseExitResponse(response);
|
|
6765
6770
|
}
|
|
6766
6771
|
const jsonBody = await parseResponseJson(response.clone());
|
|
@@ -6788,7 +6793,7 @@ var getJsonObjectOrNull = async (response) => {
|
|
|
6788
6793
|
var parseResponseJson = async (response) => {
|
|
6789
6794
|
try {
|
|
6790
6795
|
return await response.json();
|
|
6791
|
-
} catch {
|
|
6796
|
+
} catch (e) {
|
|
6792
6797
|
return null;
|
|
6793
6798
|
}
|
|
6794
6799
|
};
|
|
@@ -6838,9 +6843,12 @@ var DynamicFlowComponent = ({
|
|
|
6838
6843
|
loaderConfig,
|
|
6839
6844
|
initialStep ? "idle" : "initial"
|
|
6840
6845
|
);
|
|
6841
|
-
const logCritical = getLogger("critical", onLog, flowId, step
|
|
6846
|
+
const logCritical = getLogger("critical", onLog, flowId, (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key));
|
|
6842
6847
|
const analyticsMetadata = (0, import_react41.useMemo)(
|
|
6843
|
-
() =>
|
|
6848
|
+
() => {
|
|
6849
|
+
var _a;
|
|
6850
|
+
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 : {});
|
|
6851
|
+
},
|
|
6844
6852
|
[flowId, step]
|
|
6845
6853
|
);
|
|
6846
6854
|
const dispatchEvent = (0, import_react41.useMemo)(
|
|
@@ -6850,14 +6858,13 @@ var DynamicFlowComponent = ({
|
|
|
6850
6858
|
const dfHttpClient = (0, import_react41.useCallback)(
|
|
6851
6859
|
({ action, data, etag: etag2 }) => {
|
|
6852
6860
|
const { url, method = "POST" } = action;
|
|
6853
|
-
return httpClient(url
|
|
6861
|
+
return httpClient(url != null ? url : "", {
|
|
6854
6862
|
method,
|
|
6855
|
-
headers: {
|
|
6863
|
+
headers: __spreadValues({
|
|
6856
6864
|
"accept-language": locale,
|
|
6857
6865
|
// FIXME move this out of the library https://transferwise.atlassian.net/browse/MC-3286
|
|
6858
|
-
"Content-Type": "application/json"
|
|
6859
|
-
|
|
6860
|
-
},
|
|
6866
|
+
"Content-Type": "application/json"
|
|
6867
|
+
}, etag2 ? { "If-None-Match": etag2 } : {}),
|
|
6861
6868
|
credentials: "include",
|
|
6862
6869
|
body: method === "GET" ? void 0 : JSON.stringify(data)
|
|
6863
6870
|
});
|
|
@@ -6895,7 +6902,7 @@ var DynamicFlowComponent = ({
|
|
|
6895
6902
|
};
|
|
6896
6903
|
const handleExitResponse = async (response, actionResult) => {
|
|
6897
6904
|
const exitResult = await getJsonObjectOrNull(response);
|
|
6898
|
-
dispatchEventAndComplete({
|
|
6905
|
+
dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
|
|
6899
6906
|
};
|
|
6900
6907
|
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6901
6908
|
const dispatchEventAndComplete = (0, import_react41.useCallback)(
|
|
@@ -6910,11 +6917,10 @@ var DynamicFlowComponent = ({
|
|
|
6910
6917
|
}, []);
|
|
6911
6918
|
(0, import_react41.useEffect)(() => {
|
|
6912
6919
|
if (!initialStep) {
|
|
6913
|
-
const action = {
|
|
6920
|
+
const action = __spreadValues({
|
|
6914
6921
|
id: "#initial-step-request",
|
|
6915
|
-
method: "GET"
|
|
6916
|
-
|
|
6917
|
-
};
|
|
6922
|
+
method: "GET"
|
|
6923
|
+
}, initialAction);
|
|
6918
6924
|
void performAction(action, action.data);
|
|
6919
6925
|
}
|
|
6920
6926
|
}, [httpClient, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
@@ -6946,10 +6952,9 @@ var DynamicFlowComponent = ({
|
|
|
6946
6952
|
setLoadingState("idle");
|
|
6947
6953
|
if (fetchType === "submission") {
|
|
6948
6954
|
setSubmitted(false);
|
|
6949
|
-
dispatchEvent("Dynamic Flow - Step Started", {
|
|
6950
|
-
stepId: newStep.id || newStep.key
|
|
6951
|
-
|
|
6952
|
-
});
|
|
6955
|
+
dispatchEvent("Dynamic Flow - Step Started", __spreadValues({
|
|
6956
|
+
stepId: newStep.id || newStep.key
|
|
6957
|
+
}, newStep == null ? void 0 : newStep.analytics));
|
|
6953
6958
|
} else {
|
|
6954
6959
|
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
|
|
6955
6960
|
}
|
|
@@ -6995,7 +7000,7 @@ var DynamicFlowComponent = ({
|
|
|
6995
7000
|
const { triggerSchema } = props;
|
|
6996
7001
|
if (shouldTriggerRefresh(props)) {
|
|
6997
7002
|
const triggerSchemaRefreshUrl = triggerSchema.refreshUrl || triggerSchema.refreshFormUrl;
|
|
6998
|
-
const stepRefreshUrl = step
|
|
7003
|
+
const stepRefreshUrl = (step == null ? void 0 : step.refreshUrl) || (step == null ? void 0 : step.refreshFormUrl);
|
|
6999
7004
|
const refreshUrl = triggerSchemaRefreshUrl || stepRefreshUrl;
|
|
7000
7005
|
if (refreshUrl) {
|
|
7001
7006
|
debouncedRefresh(refreshUrl, combineModels2(updatedModels), etag, triggerSchema);
|
|
@@ -7012,7 +7017,7 @@ var DynamicFlowComponent = ({
|
|
|
7012
7017
|
}
|
|
7013
7018
|
const actionHandler = action.exit ? performExitAction : performAction;
|
|
7014
7019
|
const { data, method, skipValidation } = action;
|
|
7015
|
-
const submissionData = {
|
|
7020
|
+
const submissionData = __spreadValues(__spreadValues({}, combineModels2(models)), data);
|
|
7016
7021
|
if (isSubmissionMethod(method)) {
|
|
7017
7022
|
setFormErrors(null);
|
|
7018
7023
|
if (!skipValidation) {
|
|
@@ -7025,7 +7030,7 @@ var DynamicFlowComponent = ({
|
|
|
7025
7030
|
await actionHandler(action);
|
|
7026
7031
|
}
|
|
7027
7032
|
};
|
|
7028
|
-
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(LogProvider, { flowId, stepId: step
|
|
7033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(LogProvider, { flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key), onLog, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(EventsContextProvider, { metadata: analyticsMetadata, onEvent, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowProvider, { loading: isLoading, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(HttpClientProvider, { httpClient, children: loader !== null ? loader : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
7029
7034
|
DynamicFlowStep,
|
|
7030
7035
|
{
|
|
7031
7036
|
step,
|
|
@@ -7041,10 +7046,10 @@ var DynamicFlowComponent = ({
|
|
|
7041
7046
|
}
|
|
7042
7047
|
) }) }) }) });
|
|
7043
7048
|
};
|
|
7044
|
-
var DynamicFlow = (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ErrorBoundary_default, { onError: props.onError, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowComponent, {
|
|
7049
|
+
var DynamicFlow = (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ErrorBoundary_default, { onError: props.onError, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowComponent, __spreadValues({}, props)) });
|
|
7045
7050
|
var DynamicFlow_default = DynamicFlow;
|
|
7046
7051
|
var combineModels2 = (formModels) => {
|
|
7047
|
-
return Object.values(formModels).reduce((previous, model) => ({
|
|
7052
|
+
return Object.values(formModels).reduce((previous, model) => __spreadValues(__spreadValues({}, previous), model), {});
|
|
7048
7053
|
};
|
|
7049
7054
|
var isSubmissionMethod = (method = "POST") => {
|
|
7050
7055
|
const submissionMethods = ["POST", "PUT", "PATCH"];
|
|
@@ -7054,7 +7059,7 @@ var shouldTriggerRefresh = (props) => {
|
|
|
7054
7059
|
const { type, triggerSchema, triggerModel, lastTriggerModel = null } = props;
|
|
7055
7060
|
const isValid = () => isValidSchema(triggerModel, triggerSchema);
|
|
7056
7061
|
const wasValid = () => isValidSchema(lastTriggerModel, triggerSchema);
|
|
7057
|
-
const hasRefreshOnChange = triggerSchema
|
|
7062
|
+
const hasRefreshOnChange = (triggerSchema == null ? void 0 : triggerSchema.refreshStepOnChange) || (triggerSchema == null ? void 0 : triggerSchema.refreshFormOnChange);
|
|
7058
7063
|
return type !== "init" && hasRefreshOnChange && (isValid() || wasValid());
|
|
7059
7064
|
};
|
|
7060
7065
|
|