@wise/dynamic-flow-client 2.2.0-beta-f39e6a.11 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/i18n/en.json +0 -2
- package/build/main.css +0 -19
- package/build/main.js +510 -570
- package/build/main.min.js +1 -1
- package/build/types/common/contexts/eventsContext/EventsContext.d.ts +1 -1
- package/build/types/common/utils/index.d.ts +0 -1
- package/build/types/layout/search/SearchInput.d.ts +2 -1
- package/build/types/step/cameraStep/cameraCapture/components/index.d.ts +0 -1
- package/package.json +65 -65
- package/build/types/common/utils/mobile-utils.d.ts +0 -4
- package/build/types/step/cameraStep/cameraCapture/components/orientationLock/OrientationLock.d.ts +0 -2
- package/build/types/step/cameraStep/cameraCapture/components/orientationLock/OrientationLock.messages.d.ts +0 -13
package/build/main.js
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
10
7
|
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 ||= {})
|
|
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));
|
|
25
8
|
var __commonJS = (cb, mod) => function __require() {
|
|
26
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
27
10
|
};
|
|
@@ -50,6 +33,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
50
33
|
// ../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js
|
|
51
34
|
var require_classnames = __commonJS({
|
|
52
35
|
"../../node_modules/.pnpm/classnames@2.3.2/node_modules/classnames/index.js"(exports, module2) {
|
|
36
|
+
"use strict";
|
|
53
37
|
(function() {
|
|
54
38
|
"use strict";
|
|
55
39
|
var hasOwn = {}.hasOwnProperty;
|
|
@@ -98,9 +82,10 @@ var require_classnames = __commonJS({
|
|
|
98
82
|
}
|
|
99
83
|
});
|
|
100
84
|
|
|
101
|
-
// ../../node_modules/.pnpm/react-webcam@7.
|
|
85
|
+
// ../../node_modules/.pnpm/react-webcam@7.1.1_biqbaboplfbrettd7655fr4n2y/node_modules/react-webcam/dist/react-webcam.js
|
|
102
86
|
var require_react_webcam = __commonJS({
|
|
103
|
-
"../../node_modules/.pnpm/react-webcam@7.
|
|
87
|
+
"../../node_modules/.pnpm/react-webcam@7.1.1_biqbaboplfbrettd7655fr4n2y/node_modules/react-webcam/dist/react-webcam.js"(exports, module2) {
|
|
88
|
+
"use strict";
|
|
104
89
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
105
90
|
if (typeof exports === "object" && typeof module2 === "object")
|
|
106
91
|
module2.exports = factory(require("react"));
|
|
@@ -373,6 +358,8 @@ var require_react_webcam = __commonJS({
|
|
|
373
358
|
}
|
|
374
359
|
var _b = this, ctx = _b.ctx, canvas = _b.canvas;
|
|
375
360
|
if (ctx && canvas) {
|
|
361
|
+
canvas.width = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.width) || canvas.width;
|
|
362
|
+
canvas.height = (screenshotDimensions === null || screenshotDimensions === void 0 ? void 0 : screenshotDimensions.height) || canvas.height;
|
|
376
363
|
if (props.mirrored) {
|
|
377
364
|
ctx.translate(canvas.width, 0);
|
|
378
365
|
ctx.scale(-1, 1);
|
|
@@ -611,7 +598,7 @@ function convertFinalStepToDynamicLayout(step) {
|
|
|
611
598
|
}
|
|
612
599
|
if (step.actions) {
|
|
613
600
|
const actions = step.actions.map(
|
|
614
|
-
(action) => convertStepActionToDynamicAction(
|
|
601
|
+
(action) => convertStepActionToDynamicAction({ ...action, type: action.type || "primary" })
|
|
615
602
|
);
|
|
616
603
|
layout.push(dynamicBox(actions, "md"));
|
|
617
604
|
}
|
|
@@ -687,7 +674,7 @@ function convertFinalStepImageToDynamicImage(image) {
|
|
|
687
674
|
} : convertStepImageToDynamicImage(image);
|
|
688
675
|
}
|
|
689
676
|
function convertStepActionToDynamicAction(action) {
|
|
690
|
-
const newAction =
|
|
677
|
+
const newAction = { ...action, title: action.title };
|
|
691
678
|
return {
|
|
692
679
|
type: "button",
|
|
693
680
|
action: newAction
|
|
@@ -781,7 +768,7 @@ function inlineFormSchema({
|
|
|
781
768
|
};
|
|
782
769
|
}
|
|
783
770
|
if (formComponent.schema && !isReference(formComponent.schema)) {
|
|
784
|
-
return
|
|
771
|
+
return { ...formComponent };
|
|
785
772
|
}
|
|
786
773
|
throw new Error('Invalid form layout component. Missing "schema" or "schemaId" properties.');
|
|
787
774
|
}
|
|
@@ -789,22 +776,22 @@ function inlineDecisionActions({
|
|
|
789
776
|
decisionComponent,
|
|
790
777
|
actions
|
|
791
778
|
}) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
779
|
+
const newOptions = decisionComponent?.options?.map((option) => {
|
|
780
|
+
return option.action && isReference(option.action) ? {
|
|
781
|
+
...option,
|
|
795
782
|
action: getActionById(actions, option.action.$ref)
|
|
796
|
-
}
|
|
783
|
+
} : option;
|
|
797
784
|
});
|
|
798
|
-
return
|
|
785
|
+
return {
|
|
786
|
+
...decisionComponent,
|
|
799
787
|
options: newOptions
|
|
800
|
-
}
|
|
788
|
+
};
|
|
801
789
|
}
|
|
802
790
|
function inlineAction({
|
|
803
791
|
actionComponent,
|
|
804
792
|
actions
|
|
805
793
|
}) {
|
|
806
|
-
|
|
807
|
-
if (actionComponent.action && isReference(actionComponent.action) && ((_a = actionComponent.action) == null ? void 0 : _a.$ref)) {
|
|
794
|
+
if (actionComponent.action && isReference(actionComponent.action) && actionComponent.action?.$ref) {
|
|
808
795
|
const newAction = getActionById(actions, actionComponent.action.$ref);
|
|
809
796
|
return convertStepActionToDynamicAction(newAction);
|
|
810
797
|
}
|
|
@@ -816,9 +803,10 @@ function inlineBoxReferences({
|
|
|
816
803
|
actions,
|
|
817
804
|
model
|
|
818
805
|
}) {
|
|
819
|
-
return
|
|
806
|
+
return {
|
|
807
|
+
...boxComponent,
|
|
820
808
|
components: inlineReferences({ layout: boxComponent.components, schemas, actions, model })
|
|
821
|
-
}
|
|
809
|
+
};
|
|
822
810
|
}
|
|
823
811
|
function inlineColumnsReferences({
|
|
824
812
|
columnsComponent,
|
|
@@ -826,10 +814,11 @@ function inlineColumnsReferences({
|
|
|
826
814
|
actions,
|
|
827
815
|
model
|
|
828
816
|
}) {
|
|
829
|
-
return
|
|
817
|
+
return {
|
|
818
|
+
...columnsComponent,
|
|
830
819
|
left: inlineReferences({ layout: columnsComponent.left, schemas, actions, model }),
|
|
831
820
|
right: inlineReferences({ layout: columnsComponent.right, schemas, actions, model })
|
|
832
|
-
}
|
|
821
|
+
};
|
|
833
822
|
}
|
|
834
823
|
function getSchemaById(schemas, id) {
|
|
835
824
|
const schema = schemas.find((schema2) => schema2.$id === id);
|
|
@@ -851,7 +840,7 @@ function isReference(block) {
|
|
|
851
840
|
|
|
852
841
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
853
842
|
var import_react41 = require("react");
|
|
854
|
-
var
|
|
843
|
+
var import_react_intl32 = require("react-intl");
|
|
855
844
|
|
|
856
845
|
// src/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
|
|
857
846
|
var import_react2 = require("react");
|
|
@@ -916,8 +905,8 @@ function useEventDispatcher() {
|
|
|
916
905
|
}
|
|
917
906
|
var getEventDispatcher = (onEvent, metadata) => (eventName, properties = {}) => {
|
|
918
907
|
try {
|
|
919
|
-
onEvent(eventName,
|
|
920
|
-
} catch
|
|
908
|
+
onEvent(eventName, { ...metadata, ...properties });
|
|
909
|
+
} catch {
|
|
921
910
|
}
|
|
922
911
|
};
|
|
923
912
|
|
|
@@ -940,8 +929,8 @@ function isRelativePath(url = "") {
|
|
|
940
929
|
// src/common/makeHttpClient/makeHttpClient.ts
|
|
941
930
|
var makeHttpClient = (baseUrl, additionalHeaders) => (input, init) => {
|
|
942
931
|
const resource = applyBaseUrl(input, baseUrl || "");
|
|
943
|
-
const headers2 = mergeHeaders(init
|
|
944
|
-
return fetch(resource,
|
|
932
|
+
const headers2 = mergeHeaders(init?.headers, additionalHeaders);
|
|
933
|
+
return fetch(resource, { ...init || {}, headers: headers2 });
|
|
945
934
|
};
|
|
946
935
|
var applyBaseUrl = (input, baseUrl) => {
|
|
947
936
|
return typeof input === "string" && isRelativePath(input) ? baseUrl + input : input;
|
|
@@ -981,11 +970,12 @@ var import_react5 = require("react");
|
|
|
981
970
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
982
971
|
var getLogger = (level, onLog, flowId = "UNKNOWN-FLOW-ID", stepId = "UNKNOWN-FLOW-ID") => (title, description, extra) => {
|
|
983
972
|
try {
|
|
984
|
-
onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`,
|
|
973
|
+
onLog(level, `Dynamic Flow ${level} - ${title} - ${description}`, {
|
|
985
974
|
flowId,
|
|
986
|
-
stepId
|
|
987
|
-
|
|
988
|
-
|
|
975
|
+
stepId,
|
|
976
|
+
...extra
|
|
977
|
+
});
|
|
978
|
+
} catch {
|
|
989
979
|
}
|
|
990
980
|
};
|
|
991
981
|
var LogContext = (0, import_react5.createContext)(null);
|
|
@@ -1019,7 +1009,7 @@ var isInteger = (value) => {
|
|
|
1019
1009
|
return isNumber(value) && Math.floor(value) === value;
|
|
1020
1010
|
};
|
|
1021
1011
|
var isBoolean = (value) => typeof value === "boolean";
|
|
1022
|
-
var isObject = (value) => !isNull(value) && !isUndefined(value) &&
|
|
1012
|
+
var isObject = (value) => !isNull(value) && !isUndefined(value) && value?.constructor === Object;
|
|
1023
1013
|
var isArray = (value) => Array.isArray(value);
|
|
1024
1014
|
var isNull = (value) => value === null;
|
|
1025
1015
|
var isUndefined = (value) => typeof value === "undefined";
|
|
@@ -1034,12 +1024,11 @@ function cleanBasicModelWithOneOfSchema(model, schema) {
|
|
|
1034
1024
|
) ? model : null;
|
|
1035
1025
|
}
|
|
1036
1026
|
function cleanArrayModelWithOneOfSchema(model, schema) {
|
|
1037
|
-
var _a;
|
|
1038
1027
|
const validModels = schema.oneOf.map((nestedSchema) => getValidArrayModelOrNull(model, nestedSchema)).filter((item) => item !== null);
|
|
1039
1028
|
if (validModels.length === 0) {
|
|
1040
1029
|
return null;
|
|
1041
1030
|
}
|
|
1042
|
-
return
|
|
1031
|
+
return validModels.find((model2) => model2.some((item) => item !== null)) ?? validModels[0];
|
|
1043
1032
|
}
|
|
1044
1033
|
function getValidArrayModelOrNull(model, schema) {
|
|
1045
1034
|
if (!isArraySchema(schema)) {
|
|
@@ -1081,7 +1070,7 @@ function cleanObjectModelWithObjectSchema(model, schema) {
|
|
|
1081
1070
|
const subSchema = schema.properties[property];
|
|
1082
1071
|
const newValue = getValidModelParts(subModel, subSchema);
|
|
1083
1072
|
if (!isNull(newValue)) {
|
|
1084
|
-
return
|
|
1073
|
+
return { ...cleanedModel, [property]: newValue };
|
|
1085
1074
|
}
|
|
1086
1075
|
}
|
|
1087
1076
|
return cleanedModel;
|
|
@@ -1091,7 +1080,7 @@ function cleanObjectModelWithAllOfSchema(model, schema) {
|
|
|
1091
1080
|
return schema.allOf.reduce((cleanObjectModel, nestedSchema) => {
|
|
1092
1081
|
const validSubsetOfModel = getValidObjectModelParts(model, nestedSchema);
|
|
1093
1082
|
if (isObjectModel(validSubsetOfModel)) {
|
|
1094
|
-
return
|
|
1083
|
+
return { ...cleanObjectModel, ...validSubsetOfModel };
|
|
1095
1084
|
}
|
|
1096
1085
|
return cleanObjectModel;
|
|
1097
1086
|
}, {});
|
|
@@ -1116,15 +1105,17 @@ function deepMergeObject(object1, object2) {
|
|
|
1116
1105
|
const object1Property = object1[property];
|
|
1117
1106
|
const object2Property = object2[property];
|
|
1118
1107
|
if (isObjectModel(object1Property) && isObjectModel(object2Property)) {
|
|
1119
|
-
return
|
|
1108
|
+
return {
|
|
1109
|
+
...acc,
|
|
1120
1110
|
[property]: deepMergeObject(object1Property, object2Property)
|
|
1121
|
-
}
|
|
1111
|
+
};
|
|
1122
1112
|
}
|
|
1123
|
-
return
|
|
1113
|
+
return {
|
|
1114
|
+
...acc,
|
|
1124
1115
|
[property]: object2[property]
|
|
1125
|
-
}
|
|
1116
|
+
};
|
|
1126
1117
|
},
|
|
1127
|
-
|
|
1118
|
+
{ ...object1 }
|
|
1128
1119
|
);
|
|
1129
1120
|
}
|
|
1130
1121
|
|
|
@@ -1539,7 +1530,7 @@ var toBase64 = (file) => {
|
|
|
1539
1530
|
};
|
|
1540
1531
|
function areFilesSame(newFiles, files) {
|
|
1541
1532
|
const fileIdToExistingFileMap = files.reduce((map, fileObject) => {
|
|
1542
|
-
return
|
|
1533
|
+
return { ...map, [fileObject.id]: fileObject };
|
|
1543
1534
|
}, {});
|
|
1544
1535
|
for (const newFile of newFiles) {
|
|
1545
1536
|
const existingFileObject = fileIdToExistingFileMap[newFile.id];
|
|
@@ -1562,7 +1553,7 @@ var generateRandomId = (prefix = "") => {
|
|
|
1562
1553
|
|
|
1563
1554
|
// src/common/utils/schema-utils.ts
|
|
1564
1555
|
function isConstSchema(schema) {
|
|
1565
|
-
return !isUndefined(schema
|
|
1556
|
+
return !isUndefined(schema?.const);
|
|
1566
1557
|
}
|
|
1567
1558
|
function isNoNConstSchema(schema) {
|
|
1568
1559
|
return !!schema && !isConstSchema(schema);
|
|
@@ -1652,16 +1643,13 @@ var isCameraStep = (step) => {
|
|
|
1652
1643
|
return isFormStep(step) && hasSingleAction(step) && hasSingleFileUploadSchemaWithCameraOnly(step);
|
|
1653
1644
|
};
|
|
1654
1645
|
var isFormStep = (step) => !step.type || step.type === "form";
|
|
1655
|
-
var hasSingleAction = (step) =>
|
|
1656
|
-
var _a;
|
|
1657
|
-
return ((_a = step == null ? void 0 : step.actions) == null ? void 0 : _a.length) === 1;
|
|
1658
|
-
};
|
|
1646
|
+
var hasSingleAction = (step) => step?.actions?.length === 1;
|
|
1659
1647
|
var hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
1660
1648
|
if (!step.schemas) {
|
|
1661
1649
|
return false;
|
|
1662
1650
|
}
|
|
1663
1651
|
const schemas = filterHiddenSchemas(step.schemas);
|
|
1664
|
-
if (
|
|
1652
|
+
if (schemas?.length !== 1) {
|
|
1665
1653
|
return false;
|
|
1666
1654
|
}
|
|
1667
1655
|
const firstSchema = schemas[0];
|
|
@@ -1677,9 +1665,9 @@ var hasSingleFileUploadSchemaWithCameraOnly = (step) => {
|
|
|
1677
1665
|
var filterHiddenSchemas = (schemas) => {
|
|
1678
1666
|
return schemas.filter((schema) => {
|
|
1679
1667
|
if (isObjectSchema(schema)) {
|
|
1680
|
-
return Object.values(
|
|
1668
|
+
return Object.values(schema?.properties || {}).find((schema2) => schema2?.hidden !== true);
|
|
1681
1669
|
}
|
|
1682
|
-
return
|
|
1670
|
+
return schema?.hidden !== true;
|
|
1683
1671
|
});
|
|
1684
1672
|
};
|
|
1685
1673
|
|
|
@@ -1709,30 +1697,6 @@ var isNullableArrayModel = (model) => {
|
|
|
1709
1697
|
// src/common/utils/misc-utils.ts
|
|
1710
1698
|
var isBasicError = (error) => isString(error) || isNull(error);
|
|
1711
1699
|
|
|
1712
|
-
// src/common/utils/mobile-utils.ts
|
|
1713
|
-
var isMobile = () => {
|
|
1714
|
-
return isMobileScreenSize() && (isTouchScreen() || isMobileUA());
|
|
1715
|
-
};
|
|
1716
|
-
var isMobileUA = (userAgent = window.navigator.userAgent) => {
|
|
1717
|
-
return /Mobi|\b(iPhone|Android|BlackBerry|webOS|Windows Phone)\b/i.test(userAgent);
|
|
1718
|
-
};
|
|
1719
|
-
var isMobileScreenSize = (width = window.screen.width, height = window.screen.height) => {
|
|
1720
|
-
return width < 768 || height < 768;
|
|
1721
|
-
};
|
|
1722
|
-
var isTouchScreen = (navigator2 = window.navigator, matchMedia = window.matchMedia) => {
|
|
1723
|
-
if ("maxTouchPoints" in navigator2) {
|
|
1724
|
-
return navigator2.maxTouchPoints > 0;
|
|
1725
|
-
}
|
|
1726
|
-
if ("msMaxTouchPoints" in navigator2) {
|
|
1727
|
-
return navigator2["msMaxTouchPoints"] > 0;
|
|
1728
|
-
}
|
|
1729
|
-
const mQ = matchMedia == null ? void 0 : matchMedia("(pointer:coarse)");
|
|
1730
|
-
if ((mQ == null ? void 0 : mQ.media) === "(pointer:coarse)") {
|
|
1731
|
-
return !!mQ.matches;
|
|
1732
|
-
}
|
|
1733
|
-
return false;
|
|
1734
|
-
};
|
|
1735
|
-
|
|
1736
1700
|
// src/common/hooks/useDebouncedFunction/useDebouncedFunction.tsx
|
|
1737
1701
|
var import_react6 = require("react");
|
|
1738
1702
|
function useDebouncedFunction(callback, waitMs) {
|
|
@@ -1766,7 +1730,7 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1766
1730
|
if (response.ok) {
|
|
1767
1731
|
try {
|
|
1768
1732
|
return response.json();
|
|
1769
|
-
} catch
|
|
1733
|
+
} catch {
|
|
1770
1734
|
throw new Error("failed");
|
|
1771
1735
|
}
|
|
1772
1736
|
} else {
|
|
@@ -1780,30 +1744,30 @@ function useExternalStepPolling(polling, onAction) {
|
|
|
1780
1744
|
}, [polling, httpClient]);
|
|
1781
1745
|
const onPollingResponse = (0, import_react8.useCallback)(
|
|
1782
1746
|
(pollingResponse) => {
|
|
1783
|
-
const responseHandlers =
|
|
1747
|
+
const responseHandlers = polling?.responseHandlers || [];
|
|
1784
1748
|
const responseHandler = responseHandlers.find(
|
|
1785
1749
|
(handler) => handler.result === pollingResponse.result
|
|
1786
1750
|
);
|
|
1787
|
-
if (responseHandler
|
|
1751
|
+
if (responseHandler?.action) {
|
|
1788
1752
|
const { action } = responseHandler;
|
|
1789
1753
|
if (action.exit) {
|
|
1790
|
-
const mergedResult =
|
|
1791
|
-
onAction(
|
|
1754
|
+
const mergedResult = { ...action.result || {}, ...pollingResponse.data || {} };
|
|
1755
|
+
onAction({ ...action, result: mergedResult });
|
|
1792
1756
|
} else {
|
|
1793
|
-
const mergedData =
|
|
1794
|
-
onAction(
|
|
1757
|
+
const mergedData = { ...action.data || {}, ...pollingResponse.data || {} };
|
|
1758
|
+
onAction({ ...action, data: mergedData });
|
|
1795
1759
|
}
|
|
1796
1760
|
return false;
|
|
1797
1761
|
}
|
|
1798
1762
|
return true;
|
|
1799
1763
|
},
|
|
1800
|
-
[polling
|
|
1764
|
+
[polling?.responseHandlers, onAction]
|
|
1801
1765
|
);
|
|
1802
1766
|
usePolling({
|
|
1803
1767
|
asyncFn,
|
|
1804
|
-
interval:
|
|
1805
|
-
maxAttempts:
|
|
1806
|
-
maxConsecutiveFails:
|
|
1768
|
+
interval: polling?.interval || 0,
|
|
1769
|
+
maxAttempts: polling?.maxAttempts || 0,
|
|
1770
|
+
maxConsecutiveFails: polling?.maxConsecutiveFails || 0,
|
|
1807
1771
|
onPollingResponse,
|
|
1808
1772
|
onFailure: (0, import_react8.useCallback)(() => {
|
|
1809
1773
|
if (polling) {
|
|
@@ -2099,10 +2063,7 @@ var NamedIcon = ({ name }) => {
|
|
|
2099
2063
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { size: 24 });
|
|
2100
2064
|
};
|
|
2101
2065
|
var toCapitalisedCamelCase = (value) => value.split("-").map(capitaliseFirstChar).join("");
|
|
2102
|
-
var capitaliseFirstChar = (value) => {
|
|
2103
|
-
var _a;
|
|
2104
|
-
return `${(_a = value[0]) == null ? void 0 : _a.toUpperCase()}${value.slice(1)}`;
|
|
2105
|
-
};
|
|
2066
|
+
var capitaliseFirstChar = (value) => `${value[0]?.toUpperCase()}${value.slice(1)}`;
|
|
2106
2067
|
|
|
2107
2068
|
// src/layout/icon/DynamicIcon.tsx
|
|
2108
2069
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
@@ -2123,13 +2084,13 @@ var DynamicIcon_default = DynamicIcon;
|
|
|
2123
2084
|
// src/layout/utils/getNavigationOptionMedia.tsx
|
|
2124
2085
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
2125
2086
|
var getNavigationOptionMedia = ({ icon, image }) => {
|
|
2126
|
-
if (icon
|
|
2087
|
+
if (icon?.name) {
|
|
2127
2088
|
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 }) });
|
|
2128
2089
|
}
|
|
2129
|
-
if (icon
|
|
2090
|
+
if (icon?.text) {
|
|
2130
2091
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_components.Avatar, { type: import_components.AvatarType.INITIALS, children: icon.text });
|
|
2131
2092
|
}
|
|
2132
|
-
if (image
|
|
2093
|
+
if (image?.url) {
|
|
2133
2094
|
const { url, text } = image;
|
|
2134
2095
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("img", { src: url, alt: text });
|
|
2135
2096
|
}
|
|
@@ -2266,9 +2227,8 @@ var priorities = {
|
|
|
2266
2227
|
negative: "primary"
|
|
2267
2228
|
};
|
|
2268
2229
|
var getButtonPriority = (component) => {
|
|
2269
|
-
var _a;
|
|
2270
2230
|
const actionType = component.action.type;
|
|
2271
|
-
return
|
|
2231
|
+
return component.control ?? (actionType ? priorities[actionType] : "secondary");
|
|
2272
2232
|
};
|
|
2273
2233
|
var types = {
|
|
2274
2234
|
primary: "neutral",
|
|
@@ -2278,9 +2238,8 @@ var types = {
|
|
|
2278
2238
|
negative: "negative"
|
|
2279
2239
|
};
|
|
2280
2240
|
var getButtonType = (component) => {
|
|
2281
|
-
var _a;
|
|
2282
2241
|
const actionType = component.action.type;
|
|
2283
|
-
const type =
|
|
2242
|
+
const type = component.context ?? (actionType ? types[actionType] : "neutral");
|
|
2284
2243
|
return type === "neutral" ? "accent" : type;
|
|
2285
2244
|
};
|
|
2286
2245
|
var getButtonSize = (size) => {
|
|
@@ -2300,7 +2259,6 @@ var getButtonSize = (size) => {
|
|
|
2300
2259
|
// src/layout/button/DynamicButton.tsx
|
|
2301
2260
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2302
2261
|
var DynamicButton = (props) => {
|
|
2303
|
-
var _a;
|
|
2304
2262
|
const { component, onAction } = props;
|
|
2305
2263
|
const componentAction = component.action;
|
|
2306
2264
|
const type = getButtonType(component);
|
|
@@ -2317,7 +2275,7 @@ var DynamicButton = (props) => {
|
|
|
2317
2275
|
className,
|
|
2318
2276
|
disabled: component.disabled || componentAction.disabled || loading,
|
|
2319
2277
|
onClick: () => onAction(componentAction),
|
|
2320
|
-
children:
|
|
2278
|
+
children: component.title ?? componentAction.title
|
|
2321
2279
|
}
|
|
2322
2280
|
);
|
|
2323
2281
|
};
|
|
@@ -2429,9 +2387,10 @@ var DynamicExternal = ({ component, onAction }) => {
|
|
|
2429
2387
|
(0, import_react9.useEffect)(() => {
|
|
2430
2388
|
openExternalUrl();
|
|
2431
2389
|
}, [openExternalUrl]);
|
|
2432
|
-
const pollingConfiguration = polling && responseHandlers ?
|
|
2390
|
+
const pollingConfiguration = polling && responseHandlers ? {
|
|
2391
|
+
...polling,
|
|
2433
2392
|
responseHandlers
|
|
2434
|
-
}
|
|
2393
|
+
} : void 0;
|
|
2435
2394
|
useExternalStepPolling(pollingConfiguration, onAction);
|
|
2436
2395
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
2437
2396
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_components5.Loader, { size: import_components5.Size.LARGE, classNames: { "tw-loader": "tw-loader m-x-auto" } }),
|
|
@@ -2453,7 +2412,7 @@ var splitModel = (model, schemas) => {
|
|
|
2453
2412
|
};
|
|
2454
2413
|
var combineModels = (models) => {
|
|
2455
2414
|
return models.reduce((current, combined) => {
|
|
2456
|
-
return
|
|
2415
|
+
return { ...combined, ...current };
|
|
2457
2416
|
}, {});
|
|
2458
2417
|
};
|
|
2459
2418
|
var getSchemaColumnClasses = (width) => {
|
|
@@ -2468,7 +2427,7 @@ var AllOfSchema = (props) => {
|
|
|
2468
2427
|
const modelSchema = props.schema.allOf[index];
|
|
2469
2428
|
models[index] = getValidObjectModelParts(onChangeProps.model, modelSchema) || {};
|
|
2470
2429
|
setModels(models);
|
|
2471
|
-
props.onChange(
|
|
2430
|
+
props.onChange({ ...onChangeProps, model: combineModels(models) });
|
|
2472
2431
|
};
|
|
2473
2432
|
const [models, setModels] = (0, import_react10.useState)(splitModel(props.model, props.schema.allOf));
|
|
2474
2433
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
@@ -2484,10 +2443,11 @@ var AllOfSchema = (props) => {
|
|
|
2484
2443
|
errors: props.errors,
|
|
2485
2444
|
submitted: props.submitted,
|
|
2486
2445
|
disabled: props.disabled,
|
|
2487
|
-
onChange: (onChangeProps) => onChangeModelIndex(index,
|
|
2446
|
+
onChange: (onChangeProps) => onChangeModelIndex(index, {
|
|
2447
|
+
...onChangeProps,
|
|
2488
2448
|
// We can safely assume that the model here is going to be of the same type as the model prop
|
|
2489
2449
|
model: onChangeProps.model
|
|
2490
|
-
})
|
|
2450
|
+
}),
|
|
2491
2451
|
onPersistAsync: props.onPersistAsync
|
|
2492
2452
|
}
|
|
2493
2453
|
) }, index)
|
|
@@ -2567,11 +2527,17 @@ var ControlFeedback_messages_default = (0, import_react_intl4.defineMessages)({
|
|
|
2567
2527
|
// src/jsonSchemaForm/controlFeedback/ControlFeedback.tsx
|
|
2568
2528
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2569
2529
|
var ControlFeedback = (props) => {
|
|
2570
|
-
var _a;
|
|
2571
2530
|
const defaultValidationMessages = useDefaultValidationMessages(props.schema);
|
|
2572
|
-
const validationMessages =
|
|
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
|
+
};
|
|
2573
2539
|
const isErrorVisible = (props.submitted || !props.changed) && !!props.errors;
|
|
2574
|
-
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && !!
|
|
2540
|
+
const isValidationVisible = !isErrorVisible && (props.submitted || props.changed && props.blurred) && !!props.validations?.length;
|
|
2575
2541
|
const isDescriptionVisible = props.focused && props.schema.description && !isValidationVisible;
|
|
2576
2542
|
const hasInfoMessage = !!props.infoMessage;
|
|
2577
2543
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { id: props.id, children: [
|
|
@@ -2632,7 +2598,10 @@ function useDefaultValidationMessages(schema) {
|
|
|
2632
2598
|
)
|
|
2633
2599
|
}) : void 0
|
|
2634
2600
|
};
|
|
2635
|
-
return
|
|
2601
|
+
return {
|
|
2602
|
+
...formattedMessages,
|
|
2603
|
+
...dateOverrides
|
|
2604
|
+
};
|
|
2636
2605
|
}
|
|
2637
2606
|
return formattedMessages;
|
|
2638
2607
|
}
|
|
@@ -2653,7 +2622,7 @@ async function createPayload(userUploadedFile, isBlobSchema2) {
|
|
|
2653
2622
|
}
|
|
2654
2623
|
function constructUploadResponse(response) {
|
|
2655
2624
|
const id = response.data;
|
|
2656
|
-
return
|
|
2625
|
+
return { id, ...response };
|
|
2657
2626
|
}
|
|
2658
2627
|
function constructUploadError(response) {
|
|
2659
2628
|
const isError = response instanceof Error;
|
|
@@ -2666,9 +2635,10 @@ function constructUploadError(response) {
|
|
|
2666
2635
|
const error = response;
|
|
2667
2636
|
return { id: generateRandomId(), message: error.message };
|
|
2668
2637
|
} else {
|
|
2669
|
-
return
|
|
2670
|
-
message: isString(response.message) ? response.message : ""
|
|
2671
|
-
|
|
2638
|
+
return {
|
|
2639
|
+
message: isString(response.message) ? response.message : "",
|
|
2640
|
+
...response
|
|
2641
|
+
};
|
|
2672
2642
|
}
|
|
2673
2643
|
}
|
|
2674
2644
|
|
|
@@ -2723,7 +2693,6 @@ function useFormattedDefaultErrorMessages({
|
|
|
2723
2693
|
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/multipleFileUploadSchema/MultipleFileUploadSchema.tsx
|
|
2724
2694
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2725
2695
|
var MultipleFileUploadSchema = (props) => {
|
|
2726
|
-
var _a, _b;
|
|
2727
2696
|
const { onChange, schema } = props;
|
|
2728
2697
|
const onEvent = useEventDispatcher();
|
|
2729
2698
|
const defaultErrorMessages = useFormattedDefaultErrorMessages(schema);
|
|
@@ -2765,27 +2734,28 @@ var MultipleFileUploadSchema = (props) => {
|
|
|
2765
2734
|
const showError = Boolean(props.errors) || (inputChanged || props.submitted) && Boolean(fileListValidationFailures.length);
|
|
2766
2735
|
const accepts = "accepts" in fileSchemaDescriptor && fileSchemaDescriptor.accepts;
|
|
2767
2736
|
const maxSize = "maxSize" in fileSchemaDescriptor && fileSchemaDescriptor.maxSize;
|
|
2768
|
-
const uploadInputProps =
|
|
2737
|
+
const uploadInputProps = {
|
|
2769
2738
|
multiple: true,
|
|
2770
2739
|
className: "form-control",
|
|
2771
2740
|
files,
|
|
2772
2741
|
fileInputName: uid,
|
|
2773
|
-
id: uid
|
|
2774
|
-
|
|
2775
|
-
|
|
2742
|
+
id: uid,
|
|
2743
|
+
...accepts ? { fileTypes: accepts } : void 0,
|
|
2744
|
+
...maxSize ? { sizeLimit: toKilobytes(maxSize) } : void 0,
|
|
2745
|
+
sizeLimitErrorMessage: fileSchemaDescriptor.validationMessages?.maxSize || defaultErrorMessages.maxFileSizeErrorMessage,
|
|
2776
2746
|
maxFiles: props.schema.maxItems,
|
|
2777
|
-
maxFilesErrorMessage:
|
|
2747
|
+
maxFilesErrorMessage: props.schema.validationMessages?.maxItems || defaultErrorMessages.maxItemsErrorMessage,
|
|
2778
2748
|
uploadButtonTitle: fileSchemaDescriptor.title,
|
|
2779
2749
|
description: fileSchemaDescriptor.description,
|
|
2780
2750
|
disabled: props.disabled,
|
|
2781
2751
|
onUploadFile: (formData) => uploadFile(formData.get(uid)),
|
|
2782
2752
|
onFilesChange,
|
|
2783
2753
|
onDeleteFile: () => Promise.resolve()
|
|
2784
|
-
}
|
|
2754
|
+
};
|
|
2785
2755
|
const feedbackId = `${uid}-feedback`;
|
|
2786
2756
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: (0, import_classnames2.default)("form-group", { "has-error": showError }), children: [
|
|
2787
2757
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("label", { className: "d-block control-label", htmlFor: uid, children: props.schema.title }),
|
|
2788
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput,
|
|
2758
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components7.UploadInput, { ...uploadInputProps }) }),
|
|
2789
2759
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
2790
2760
|
ControlFeedback_default,
|
|
2791
2761
|
{
|
|
@@ -2823,7 +2793,11 @@ function isValidId(id) {
|
|
|
2823
2793
|
}
|
|
2824
2794
|
function getValidationMessages(schema, required, defaultErrorMessages) {
|
|
2825
2795
|
const { minItems, maxItems } = schema;
|
|
2826
|
-
return
|
|
2796
|
+
return {
|
|
2797
|
+
...required && { required: defaultErrorMessages.requiredMessage },
|
|
2798
|
+
...minItems && { minItems: defaultErrorMessages.minItemsErrorMessage },
|
|
2799
|
+
...maxItems && { maxItems: defaultErrorMessages.maxItemsErrorMessage }
|
|
2800
|
+
};
|
|
2827
2801
|
}
|
|
2828
2802
|
|
|
2829
2803
|
// src/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
|
|
@@ -3005,19 +2979,13 @@ var getItemSummaryFromSchema = (schema, model, defaults = {}) => {
|
|
|
3005
2979
|
schema,
|
|
3006
2980
|
model,
|
|
3007
2981
|
providesProp: "providesIcon",
|
|
3008
|
-
getValueFromSchema: (schema2) =>
|
|
3009
|
-
var _a;
|
|
3010
|
-
return (_a = schema2.icon) != null ? _a : null;
|
|
3011
|
-
}
|
|
2982
|
+
getValueFromSchema: (schema2) => schema2.icon ?? null
|
|
3012
2983
|
});
|
|
3013
2984
|
const image = getSummaryPropFromSchema({
|
|
3014
2985
|
schema,
|
|
3015
2986
|
model,
|
|
3016
2987
|
providesProp: "providesImage",
|
|
3017
|
-
getValueFromSchema: (schema2) =>
|
|
3018
|
-
var _a;
|
|
3019
|
-
return (_a = schema2.image) != null ? _a : null;
|
|
3020
|
-
}
|
|
2988
|
+
getValueFromSchema: (schema2) => schema2.image ?? null
|
|
3021
2989
|
});
|
|
3022
2990
|
return {
|
|
3023
2991
|
value: model,
|
|
@@ -3053,10 +3021,11 @@ var getObjectValueFromSchema = (props) => {
|
|
|
3053
3021
|
for (const propertyKey in objectSchema.properties) {
|
|
3054
3022
|
const propertySchema = objectSchema.properties[propertyKey];
|
|
3055
3023
|
const propertyModel = isObjectModel(model) && propertyKey in model ? model[propertyKey] : null;
|
|
3056
|
-
const result = getSummaryPropFromSchema(
|
|
3024
|
+
const result = getSummaryPropFromSchema({
|
|
3025
|
+
...props,
|
|
3057
3026
|
schema: propertySchema,
|
|
3058
3027
|
model: propertyModel
|
|
3059
|
-
})
|
|
3028
|
+
});
|
|
3060
3029
|
if (result) {
|
|
3061
3030
|
return result;
|
|
3062
3031
|
}
|
|
@@ -3074,26 +3043,29 @@ var getOneOfValueFromSchema = (props) => {
|
|
|
3074
3043
|
return null;
|
|
3075
3044
|
}
|
|
3076
3045
|
const activeSchema = schema.oneOf[activeSchemaIndex2];
|
|
3077
|
-
return getSummaryPropFromSchema(
|
|
3046
|
+
return getSummaryPropFromSchema({
|
|
3047
|
+
...props,
|
|
3078
3048
|
schema: activeSchema
|
|
3079
|
-
})
|
|
3049
|
+
});
|
|
3080
3050
|
}
|
|
3081
3051
|
const oneOfSchema = schema;
|
|
3082
3052
|
const activeSchemaIndex = getActiveSchemaIndex(oneOfSchema, model);
|
|
3083
3053
|
if (activeSchemaIndex === null || activeSchemaIndex < 0) {
|
|
3084
3054
|
return null;
|
|
3085
3055
|
}
|
|
3086
|
-
return getSummaryPropFromSchema(
|
|
3056
|
+
return getSummaryPropFromSchema({
|
|
3057
|
+
...props,
|
|
3087
3058
|
schema: oneOfSchema.oneOf[activeSchemaIndex]
|
|
3088
|
-
})
|
|
3059
|
+
});
|
|
3089
3060
|
};
|
|
3090
3061
|
var getAllOfValueFromSchema = (props) => {
|
|
3091
3062
|
const { schema } = props;
|
|
3092
3063
|
const allOfSchema = schema;
|
|
3093
3064
|
for (const childSchema of allOfSchema.allOf) {
|
|
3094
|
-
const result = getSummaryPropFromSchema(
|
|
3065
|
+
const result = getSummaryPropFromSchema({
|
|
3066
|
+
...props,
|
|
3095
3067
|
schema: childSchema
|
|
3096
|
-
})
|
|
3068
|
+
});
|
|
3097
3069
|
if (result) {
|
|
3098
3070
|
return result;
|
|
3099
3071
|
}
|
|
@@ -3130,7 +3102,7 @@ var RepeatableSchema = ({
|
|
|
3130
3102
|
"RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
|
|
3131
3103
|
);
|
|
3132
3104
|
}
|
|
3133
|
-
return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema
|
|
3105
|
+
return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema?.summary)) : null;
|
|
3134
3106
|
});
|
|
3135
3107
|
const [editableItem, setEditableItem] = (0, import_react12.useState)({ item: null, model: null });
|
|
3136
3108
|
const broadcastModelChange = (updatedItems) => {
|
|
@@ -3149,7 +3121,10 @@ var RepeatableSchema = ({
|
|
|
3149
3121
|
setOpenModalType("edit");
|
|
3150
3122
|
};
|
|
3151
3123
|
const onSaveItem = (action) => {
|
|
3152
|
-
const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(schema.items, editableItem.model, schema
|
|
3124
|
+
const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(schema.items, editableItem.model, schema?.summary);
|
|
3125
|
+
if (action !== "remove" && !isValidSchema(updatedItem?.value ?? null, schema.items)) {
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3153
3128
|
const updatedItemSummaries = getUpdatedItemSummaries(action, {
|
|
3154
3129
|
originalItem: editableItem.item,
|
|
3155
3130
|
updatedItem,
|
|
@@ -3192,13 +3167,13 @@ var RepeatableSchema = ({
|
|
|
3192
3167
|
body: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
3193
3168
|
RepeatableSchemaStep_default,
|
|
3194
3169
|
{
|
|
3195
|
-
type: openModalType
|
|
3170
|
+
type: openModalType ?? "add",
|
|
3196
3171
|
schema,
|
|
3197
3172
|
model: editableItem.model,
|
|
3198
3173
|
errors,
|
|
3199
3174
|
submitted,
|
|
3200
3175
|
onAction: onSaveItem,
|
|
3201
|
-
onModelChange: ({ model: model2 }) => setEditableItem(
|
|
3176
|
+
onModelChange: ({ model: model2 }) => setEditableItem({ ...editableItem, model: model2 })
|
|
3202
3177
|
}
|
|
3203
3178
|
)
|
|
3204
3179
|
}
|
|
@@ -3234,10 +3209,10 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
|
3234
3209
|
var ArrayListSchema = (props) => {
|
|
3235
3210
|
const { schema } = props;
|
|
3236
3211
|
if (isMultipleFileUploadSchema(schema)) {
|
|
3237
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default,
|
|
3212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(MultipleFileUploadSchema_default, { ...props, schema });
|
|
3238
3213
|
}
|
|
3239
3214
|
if (isListArraySchema(schema)) {
|
|
3240
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RepeatableSchema_default,
|
|
3215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(RepeatableSchema_default, { ...props, schema });
|
|
3241
3216
|
}
|
|
3242
3217
|
throw new Error("Invalid array list schema");
|
|
3243
3218
|
};
|
|
@@ -3252,7 +3227,7 @@ var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
|
3252
3227
|
var ArraySchema = (props) => {
|
|
3253
3228
|
const { schema } = props;
|
|
3254
3229
|
if (isListArraySchema(schema)) {
|
|
3255
|
-
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default,
|
|
3230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(ArrayListSchema_default, { ...props });
|
|
3256
3231
|
}
|
|
3257
3232
|
throw new Error("Not implemented");
|
|
3258
3233
|
};
|
|
@@ -3273,7 +3248,9 @@ var getSchemaColumnClasses2 = (width) => {
|
|
|
3273
3248
|
};
|
|
3274
3249
|
};
|
|
3275
3250
|
var ObjectSchema = (props) => {
|
|
3276
|
-
const [model, setModel] = (0, import_react13.useState)(() =>
|
|
3251
|
+
const [model, setModel] = (0, import_react13.useState)(() => ({
|
|
3252
|
+
...getValidObjectModelParts(props.model, props.schema)
|
|
3253
|
+
}));
|
|
3277
3254
|
const onChangeProperty = (propertyName, onChangeProps) => {
|
|
3278
3255
|
if (onChangeProps.model !== null) {
|
|
3279
3256
|
model[propertyName] = onChangeProps.model;
|
|
@@ -3281,7 +3258,7 @@ var ObjectSchema = (props) => {
|
|
|
3281
3258
|
delete model[propertyName];
|
|
3282
3259
|
}
|
|
3283
3260
|
setModel(model);
|
|
3284
|
-
props.onChange(
|
|
3261
|
+
props.onChange({ ...onChangeProps, model });
|
|
3285
3262
|
};
|
|
3286
3263
|
const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
|
|
3287
3264
|
(0, import_react13.useEffect)(() => {
|
|
@@ -3495,7 +3472,7 @@ var logInvalidTypeFallbackWarning = ({
|
|
|
3495
3472
|
|
|
3496
3473
|
// src/formControl/FormControl.tsx
|
|
3497
3474
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
3498
|
-
var
|
|
3475
|
+
var FormControl = class _FormControl extends import_react14.PureComponent {
|
|
3499
3476
|
constructor(props) {
|
|
3500
3477
|
super(props);
|
|
3501
3478
|
/**
|
|
@@ -3511,19 +3488,14 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3511
3488
|
this.props.onChange(event.target.value);
|
|
3512
3489
|
};
|
|
3513
3490
|
this.handleOnFocus = () => {
|
|
3514
|
-
|
|
3515
|
-
(_b = (_a = this.props).onFocus) == null ? void 0 : _b.call(_a);
|
|
3491
|
+
this.props.onFocus?.();
|
|
3516
3492
|
};
|
|
3517
3493
|
this.handleOnBlur = () => {
|
|
3518
|
-
|
|
3519
|
-
(_b = (_a = this.props).onBlur) == null ? void 0 : _b.call(_a);
|
|
3494
|
+
this.props.onBlur?.();
|
|
3520
3495
|
};
|
|
3521
3496
|
this.getSelectedOption = (options) => {
|
|
3522
3497
|
if (this.state.selectedOption !== null && typeof this.state.selectedOption !== "undefined") {
|
|
3523
|
-
return options.find((option) =>
|
|
3524
|
-
var _a;
|
|
3525
|
-
return ((_a = this.state.selectedOption) == null ? void 0 : _a.value) === option.value;
|
|
3526
|
-
});
|
|
3498
|
+
return options.find((option) => this.state.selectedOption?.value === option.value);
|
|
3527
3499
|
}
|
|
3528
3500
|
if (this.props.value !== null && typeof this.props.value !== "undefined") {
|
|
3529
3501
|
return options.find((option) => this.props.value === option.value);
|
|
@@ -3531,12 +3503,13 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3531
3503
|
return void 0;
|
|
3532
3504
|
};
|
|
3533
3505
|
this.mapOption = (option) => {
|
|
3534
|
-
return
|
|
3506
|
+
return {
|
|
3507
|
+
...option,
|
|
3535
3508
|
value: isNumber(option.value) || isString(option.value) ? option.value : void 0,
|
|
3536
3509
|
secondary: option.note,
|
|
3537
3510
|
disabled: option.disabled || this.props.disabled,
|
|
3538
3511
|
readOnly: this.props.readOnly
|
|
3539
|
-
}
|
|
3512
|
+
};
|
|
3540
3513
|
};
|
|
3541
3514
|
this.state = {
|
|
3542
3515
|
selectedOption: props.selectedOption,
|
|
@@ -3544,6 +3517,18 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3544
3517
|
prevValue: props.value
|
|
3545
3518
|
};
|
|
3546
3519
|
}
|
|
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
|
+
}
|
|
3547
3532
|
static getDerivedStateFromProps(nextProps, previousState) {
|
|
3548
3533
|
if (previousState.prevValue !== nextProps.value) {
|
|
3549
3534
|
return { prevValue: nextProps.value, value: nextProps.value };
|
|
@@ -3551,7 +3536,6 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3551
3536
|
return null;
|
|
3552
3537
|
}
|
|
3553
3538
|
render() {
|
|
3554
|
-
var _a;
|
|
3555
3539
|
const {
|
|
3556
3540
|
name,
|
|
3557
3541
|
placeholder,
|
|
@@ -3621,9 +3605,8 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3621
3605
|
searchPlaceholder,
|
|
3622
3606
|
searchValue,
|
|
3623
3607
|
onChange: (option) => {
|
|
3624
|
-
|
|
3625
|
-
this.
|
|
3626
|
-
this.props.onChange((_a2 = option == null ? void 0 : option.value) != null ? _a2 : null);
|
|
3608
|
+
this.setState({ selectedOption: option ?? void 0 });
|
|
3609
|
+
this.props.onChange(option?.value ?? null);
|
|
3627
3610
|
},
|
|
3628
3611
|
onFocus: this.handleOnFocus,
|
|
3629
3612
|
onBlur: this.handleOnBlur,
|
|
@@ -3635,7 +3618,7 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3635
3618
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3636
3619
|
import_components11.Tabs,
|
|
3637
3620
|
{
|
|
3638
|
-
selected:
|
|
3621
|
+
selected: this.getSelectedOption(options)?.value || 0,
|
|
3639
3622
|
tabs: options.map((option) => ({
|
|
3640
3623
|
title: option.label,
|
|
3641
3624
|
content: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, {}),
|
|
@@ -3777,19 +3760,20 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3777
3760
|
if (this.props.displayPattern) {
|
|
3778
3761
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3779
3762
|
import_components11.TextareaWithDisplayFormat,
|
|
3780
|
-
|
|
3781
|
-
displayPattern: this.props.displayPattern
|
|
3782
|
-
|
|
3763
|
+
{
|
|
3764
|
+
displayPattern: this.props.displayPattern,
|
|
3765
|
+
...textareaProps,
|
|
3783
3766
|
onChange: this.handleOnChange
|
|
3784
|
-
}
|
|
3767
|
+
}
|
|
3785
3768
|
);
|
|
3786
3769
|
}
|
|
3787
3770
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3788
3771
|
"textarea",
|
|
3789
|
-
|
|
3772
|
+
{
|
|
3773
|
+
...textareaProps,
|
|
3790
3774
|
onChange: this.handleInputOnChange,
|
|
3791
3775
|
"aria-describedby": describedBy
|
|
3792
|
-
}
|
|
3776
|
+
}
|
|
3793
3777
|
);
|
|
3794
3778
|
}
|
|
3795
3779
|
case FormControlType.FILE:
|
|
@@ -3799,7 +3783,8 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3799
3783
|
// @ts-expect-error - TODO: Remove this once Upload is migrated to TypeScript
|
|
3800
3784
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3801
3785
|
import_components11.Upload,
|
|
3802
|
-
|
|
3786
|
+
{
|
|
3787
|
+
...uploadProps,
|
|
3803
3788
|
usAccept: uploadProps.usAccept || "*",
|
|
3804
3789
|
usDisabled: uploadProps.usDisabled || disabled,
|
|
3805
3790
|
onSuccess: (base64url) => {
|
|
@@ -3811,7 +3796,7 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3811
3796
|
onCancel: () => {
|
|
3812
3797
|
this.handleOnChange(null);
|
|
3813
3798
|
}
|
|
3814
|
-
}
|
|
3799
|
+
}
|
|
3815
3800
|
)
|
|
3816
3801
|
);
|
|
3817
3802
|
}
|
|
@@ -3836,59 +3821,57 @@ var _FormControl = class extends import_react14.PureComponent {
|
|
|
3836
3821
|
if (this.props.displayPattern) {
|
|
3837
3822
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3838
3823
|
import_components11.InputWithDisplayFormat,
|
|
3839
|
-
|
|
3840
|
-
displayPattern: this.props.displayPattern
|
|
3841
|
-
|
|
3824
|
+
{
|
|
3825
|
+
displayPattern: this.props.displayPattern,
|
|
3826
|
+
...inputProps,
|
|
3842
3827
|
onChange: this.handleOnChange
|
|
3843
|
-
}
|
|
3828
|
+
}
|
|
3844
3829
|
);
|
|
3845
3830
|
}
|
|
3846
3831
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
3847
3832
|
"input",
|
|
3848
|
-
|
|
3833
|
+
{
|
|
3834
|
+
...inputProps,
|
|
3849
3835
|
onChange: this.handleInputOnChange,
|
|
3850
3836
|
"aria-describedby": describedBy
|
|
3851
|
-
}
|
|
3837
|
+
}
|
|
3852
3838
|
);
|
|
3853
3839
|
}
|
|
3854
3840
|
}
|
|
3855
3841
|
}
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
type: _FormControl.Type.TEXT,
|
|
3890
|
-
uploadProps: {},
|
|
3891
|
-
value: null
|
|
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
|
+
}
|
|
3892
3875
|
};
|
|
3893
3876
|
|
|
3894
3877
|
// src/jsonSchemaForm/schemaFormControl/utils/mapping-utils.tsx
|
|
@@ -3904,22 +3887,30 @@ var mapConstSchemaToOption = (schema, controlType) => {
|
|
|
3904
3887
|
}
|
|
3905
3888
|
};
|
|
3906
3889
|
var mapConstSchemaToRadioOption = (schema) => {
|
|
3907
|
-
return
|
|
3890
|
+
return {
|
|
3908
3891
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
3909
3892
|
label: schema.title,
|
|
3910
|
-
value: schema.const
|
|
3911
|
-
|
|
3893
|
+
value: schema.const,
|
|
3894
|
+
...getOptionDescription(schema.title, schema.description),
|
|
3895
|
+
...getAvatarPropertyForRadioOption(schema),
|
|
3896
|
+
...getDisabled(schema.disabled)
|
|
3897
|
+
};
|
|
3912
3898
|
};
|
|
3913
3899
|
var mapConstSchemaToSelectOption = (schema) => {
|
|
3914
|
-
return
|
|
3900
|
+
return {
|
|
3915
3901
|
// TODO: LOW avoid type assertion -- using || '' would fail some tests
|
|
3916
3902
|
label: schema.title,
|
|
3917
|
-
value: schema.const
|
|
3918
|
-
|
|
3903
|
+
value: schema.const,
|
|
3904
|
+
...getOptionDescription(schema.title, schema.description),
|
|
3905
|
+
...getIconPropertyForSelectOption(schema.icon),
|
|
3906
|
+
...mapImage(schema.image),
|
|
3907
|
+
...getDisabled(schema.disabled),
|
|
3908
|
+
...mapKeywordsToSearchStrings(schema.keywords)
|
|
3909
|
+
};
|
|
3919
3910
|
};
|
|
3920
3911
|
var mapKeywordsToSearchStrings = (searchStrings) => isArray(searchStrings) ? { searchStrings } : {};
|
|
3921
3912
|
var mapImage = (image) => {
|
|
3922
|
-
if (image
|
|
3913
|
+
if (image?.url) {
|
|
3923
3914
|
return {
|
|
3924
3915
|
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 || "" }) }) })
|
|
3925
3916
|
};
|
|
@@ -3927,36 +3918,38 @@ var mapImage = (image) => {
|
|
|
3927
3918
|
return null;
|
|
3928
3919
|
};
|
|
3929
3920
|
var getIconPropertyForSelectOption = (icon) => {
|
|
3930
|
-
if (
|
|
3921
|
+
if (icon?.name && isFlagIcon(icon.name)) {
|
|
3931
3922
|
return { currency: icon.name.substring(5) };
|
|
3932
3923
|
}
|
|
3933
|
-
if (
|
|
3924
|
+
if (icon?.name && isValidIconName(icon.name)) {
|
|
3934
3925
|
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(DynamicIcon_default, { type: icon.name }) };
|
|
3935
3926
|
}
|
|
3936
|
-
if (icon
|
|
3927
|
+
if (icon?.text) {
|
|
3937
3928
|
return { icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { children: icon.text }) };
|
|
3938
3929
|
}
|
|
3939
3930
|
return null;
|
|
3940
3931
|
};
|
|
3941
3932
|
var getAvatarPropertyForRadioOption = ({ image, icon }) => {
|
|
3942
|
-
if (image
|
|
3933
|
+
if (image?.url) {
|
|
3943
3934
|
return {
|
|
3944
3935
|
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: "" }) })
|
|
3945
3936
|
};
|
|
3946
3937
|
}
|
|
3947
|
-
if (
|
|
3938
|
+
if (icon?.name && isValidIconName(icon.name)) {
|
|
3948
3939
|
return {
|
|
3949
3940
|
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 }) })
|
|
3950
3941
|
};
|
|
3951
3942
|
}
|
|
3952
|
-
if (icon
|
|
3943
|
+
if (icon?.text) {
|
|
3953
3944
|
return {
|
|
3954
3945
|
avatar: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components12.Avatar, { type: import_components12.AvatarType.INITIALS, children: icon.text })
|
|
3955
3946
|
};
|
|
3956
3947
|
}
|
|
3957
3948
|
return null;
|
|
3958
3949
|
};
|
|
3959
|
-
var mapSchemaToUploadOptions = ({ accepts }) =>
|
|
3950
|
+
var mapSchemaToUploadOptions = ({ accepts }) => ({
|
|
3951
|
+
...isArray(accepts) && { usAccept: accepts.join(",") }
|
|
3952
|
+
});
|
|
3960
3953
|
var getOptionDescription = (title, description) => {
|
|
3961
3954
|
if (title && description) {
|
|
3962
3955
|
const keyForDescription = (title + description).length > 50 ? "secondary" : "note";
|
|
@@ -4049,7 +4042,7 @@ var SchemaFormControl = (props) => {
|
|
|
4049
4042
|
uploadProps: mapSchemaToUploadOptions(schema),
|
|
4050
4043
|
describedBy
|
|
4051
4044
|
};
|
|
4052
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl,
|
|
4045
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-describedby": describedBy, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(FormControl, { type: controlType, value: safeValue, ...events, ...controlProps }) });
|
|
4053
4046
|
};
|
|
4054
4047
|
SchemaFormControl.defaultProps = {
|
|
4055
4048
|
value: null,
|
|
@@ -4141,7 +4134,7 @@ var OneOfSchema = (props) => {
|
|
|
4141
4134
|
if (type !== "init" && props.schema.analyticsId) {
|
|
4142
4135
|
onEvent("Dynamic Flow - OneOf Selected", {
|
|
4143
4136
|
oneOfId: props.schema.analyticsId,
|
|
4144
|
-
schemaId: newSchema
|
|
4137
|
+
schemaId: newSchema?.analyticsId
|
|
4145
4138
|
});
|
|
4146
4139
|
}
|
|
4147
4140
|
};
|
|
@@ -4216,7 +4209,7 @@ function getTitleAndHelp(schema, id) {
|
|
|
4216
4209
|
return schema.title ? titleElement : helpElement;
|
|
4217
4210
|
}
|
|
4218
4211
|
function getValidations(props, schemaIndex) {
|
|
4219
|
-
const selectedSchema = props.schema.oneOf[schemaIndex
|
|
4212
|
+
const selectedSchema = props.schema.oneOf[schemaIndex ?? -1];
|
|
4220
4213
|
if (isConstSchema(selectedSchema)) {
|
|
4221
4214
|
return getValidationFailures(selectedSchema.const, props.schema, !!props.required);
|
|
4222
4215
|
}
|
|
@@ -4235,7 +4228,7 @@ function getModelPartsForSchemas(model, schemas) {
|
|
|
4235
4228
|
return schemas.map((schema) => getValidModelParts(model, schema));
|
|
4236
4229
|
}
|
|
4237
4230
|
function mapSchemasForSelect(schema) {
|
|
4238
|
-
return
|
|
4231
|
+
return { ...schema, oneOf: schema.oneOf.map(mapOneOfToConst) };
|
|
4239
4232
|
}
|
|
4240
4233
|
function mapOneOfToConst(schema, index) {
|
|
4241
4234
|
const { title, description, disabled = false, icon, image, keywords } = schema;
|
|
@@ -4355,7 +4348,7 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4355
4348
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", { className: (0, import_classnames5.default)(formGroupClasses), children: [
|
|
4356
4349
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "aria-describedby": feedbackId, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4357
4350
|
UploadInputAdapter,
|
|
4358
|
-
|
|
4351
|
+
{
|
|
4359
4352
|
id,
|
|
4360
4353
|
fileId: props.model,
|
|
4361
4354
|
idProperty: props.schema.persistAsync.idProperty,
|
|
@@ -4367,8 +4360,9 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4367
4360
|
httpClient,
|
|
4368
4361
|
onSuccess,
|
|
4369
4362
|
onFailure,
|
|
4370
|
-
onCancel
|
|
4371
|
-
|
|
4363
|
+
onCancel,
|
|
4364
|
+
...mapSchemaToUploadOptions(props.schema.persistAsync.schema)
|
|
4365
|
+
}
|
|
4372
4366
|
) }),
|
|
4373
4367
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4374
4368
|
ControlFeedback_default,
|
|
@@ -4381,9 +4375,10 @@ var PersistAsyncBlobSchema = (props) => {
|
|
|
4381
4375
|
errors: props.errors,
|
|
4382
4376
|
schema: props.schema,
|
|
4383
4377
|
validations: combinedValidations,
|
|
4384
|
-
validationMessages:
|
|
4385
|
-
required: "Value is required..."
|
|
4386
|
-
|
|
4378
|
+
validationMessages: {
|
|
4379
|
+
required: "Value is required...",
|
|
4380
|
+
...persistAsyncValidationMessages
|
|
4381
|
+
},
|
|
4387
4382
|
infoMessage: null
|
|
4388
4383
|
}
|
|
4389
4384
|
)
|
|
@@ -4402,10 +4397,12 @@ var PersistAsyncSchema = (props) => {
|
|
|
4402
4397
|
if (persistAsyncSchemaType === "blob") {
|
|
4403
4398
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
4404
4399
|
PersistAsyncBlobSchema_default,
|
|
4405
|
-
|
|
4400
|
+
{
|
|
4401
|
+
...props
|
|
4402
|
+
}
|
|
4406
4403
|
);
|
|
4407
4404
|
}
|
|
4408
|
-
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default,
|
|
4405
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(PersistAsyncBasicSchema_default, { ...props });
|
|
4409
4406
|
};
|
|
4410
4407
|
PersistAsyncSchema.defaultProps = {
|
|
4411
4408
|
required: false
|
|
@@ -4430,7 +4427,7 @@ var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
|
4430
4427
|
var PromotedOneOfCheckboxControl = (props) => {
|
|
4431
4428
|
const { id, selection, setSelection } = props;
|
|
4432
4429
|
const { promoted, other, checkedMeans } = props.promotion;
|
|
4433
|
-
const title = checkedMeans === "other" ? other.title :
|
|
4430
|
+
const title = checkedMeans === "other" ? other.title : promoted?.title || props.promotedOneOf.title;
|
|
4434
4431
|
const selectionWhenChecked = checkedMeans === "other" ? "other" : "promoted";
|
|
4435
4432
|
const selectionWhenUnchecked = checkedMeans === "other" ? "promoted" : "other";
|
|
4436
4433
|
const checked = selection === selectionWhenChecked;
|
|
@@ -4446,20 +4443,21 @@ var PromotedOneOfCheckboxControl_default = PromotedOneOfCheckboxControl;
|
|
|
4446
4443
|
var import_components15 = require("@transferwise/components");
|
|
4447
4444
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
4448
4445
|
var PromotedOneOfRadioControl = (props) => {
|
|
4449
|
-
var _a, _b;
|
|
4450
4446
|
const { id, selection, setSelection, promotion, promotedOneOf, title } = props;
|
|
4451
4447
|
const radios = [
|
|
4452
|
-
|
|
4448
|
+
{
|
|
4453
4449
|
value: "promoted",
|
|
4454
4450
|
// TODO: LOW avoid type assertion below the expression may be nullish, but "label" cannot be
|
|
4455
|
-
label:
|
|
4456
|
-
secondary:
|
|
4457
|
-
|
|
4458
|
-
|
|
4451
|
+
label: promotion.promoted?.title || promotedOneOf.title,
|
|
4452
|
+
secondary: promotion.promoted?.description || promotedOneOf.description,
|
|
4453
|
+
...getAvatarPropertyForRadioOption(promotedOneOf)
|
|
4454
|
+
},
|
|
4455
|
+
{
|
|
4459
4456
|
value: "other",
|
|
4460
4457
|
label: promotion.other.title,
|
|
4461
|
-
secondary: promotion.other.description
|
|
4462
|
-
|
|
4458
|
+
secondary: promotion.other.description,
|
|
4459
|
+
...getAvatarPropertyForRadioOption(promotion.other)
|
|
4460
|
+
}
|
|
4463
4461
|
];
|
|
4464
4462
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: "form-group", children: [
|
|
4465
4463
|
title && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("label", { className: "control-label", htmlFor: id, children: title }),
|
|
@@ -4486,9 +4484,9 @@ var PromotedOneOfControl = (props) => {
|
|
|
4486
4484
|
const controlType = props.promotion.control || "radio";
|
|
4487
4485
|
switch (controlType) {
|
|
4488
4486
|
case "radio":
|
|
4489
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default,
|
|
4487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfRadioControl_default, { ...props });
|
|
4490
4488
|
case "checkbox":
|
|
4491
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default,
|
|
4489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(PromotedOneOfCheckboxControl_default, { ...props });
|
|
4492
4490
|
default:
|
|
4493
4491
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_jsx_runtime35.Fragment, {});
|
|
4494
4492
|
}
|
|
@@ -4503,9 +4501,8 @@ var PromotedOneOfControl_default = PromotedOneOfControl;
|
|
|
4503
4501
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
4504
4502
|
var isPromoted = (schema) => schema.promoted === true;
|
|
4505
4503
|
var PromotedOneOfSchema = (props) => {
|
|
4506
|
-
var _a;
|
|
4507
4504
|
const [selection, setSelection] = (0, import_react19.useState)(
|
|
4508
|
-
getSelectionFromModel(props.schema, props.model) ||
|
|
4505
|
+
getSelectionFromModel(props.schema, props.model) || props.schema.promotion?.default || "promoted"
|
|
4509
4506
|
);
|
|
4510
4507
|
const promotedAlert = props.schema.alert;
|
|
4511
4508
|
const promotedOneOf = props.schema.oneOf.find(isPromoted);
|
|
@@ -4524,23 +4521,23 @@ var PromotedOneOfSchema = (props) => {
|
|
|
4524
4521
|
setSelection
|
|
4525
4522
|
}
|
|
4526
4523
|
),
|
|
4527
|
-
selection === "promoted" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ObjectSchema_default,
|
|
4528
|
-
selection === "other" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(GenericSchema_default,
|
|
4524
|
+
selection === "promoted" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ObjectSchema_default, { ...props, schema: promotedObjectSchema }),
|
|
4525
|
+
selection === "other" && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(GenericSchema_default, { ...props, schema: otherOneOf })
|
|
4529
4526
|
] });
|
|
4530
4527
|
};
|
|
4531
4528
|
function getPromotedObjectSchema(promotedSchema) {
|
|
4532
|
-
return
|
|
4529
|
+
return {
|
|
4530
|
+
...promotedSchema,
|
|
4533
4531
|
// We don't need to show these since they are already displayed in the radio option
|
|
4534
4532
|
title: void 0,
|
|
4535
4533
|
description: void 0
|
|
4536
|
-
}
|
|
4534
|
+
};
|
|
4537
4535
|
}
|
|
4538
4536
|
function getOtherOneOf(schema) {
|
|
4539
|
-
|
|
4540
|
-
const
|
|
4541
|
-
const title = (_c = (_b = schema.promotion) == null ? void 0 : _b.other.heading) == null ? void 0 : _c.text;
|
|
4537
|
+
const other = schema.promotion?.displayTwice ? [...schema.oneOf] : schema.oneOf.filter((one) => !isPromoted(one));
|
|
4538
|
+
const title = schema.promotion?.other.heading?.text;
|
|
4542
4539
|
if (other.length === 1) {
|
|
4543
|
-
return
|
|
4540
|
+
return { ...other[0], title };
|
|
4544
4541
|
}
|
|
4545
4542
|
if (other.length > 1) {
|
|
4546
4543
|
return {
|
|
@@ -4612,7 +4609,7 @@ function getSelectedOneOf(schema, model) {
|
|
|
4612
4609
|
function getValueFromOption(option) {
|
|
4613
4610
|
const text = option.title && option.description ? `${option.title} - ${option.description}` : option.title || "";
|
|
4614
4611
|
const icon = getAvatarPropertyForRadioOption({ icon: option.icon });
|
|
4615
|
-
return
|
|
4612
|
+
return icon?.avatar ? /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
|
|
4616
4613
|
icon.avatar,
|
|
4617
4614
|
" ",
|
|
4618
4615
|
text
|
|
@@ -4669,7 +4666,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4669
4666
|
} else if (response.status === 422) {
|
|
4670
4667
|
setValidationAsyncErrors(isString(jsonResponse.message) ? jsonResponse.message : null);
|
|
4671
4668
|
}
|
|
4672
|
-
} catch
|
|
4669
|
+
} catch {
|
|
4673
4670
|
onEvent("Dynamic Flow - ValidationAsync", { status: "failure" });
|
|
4674
4671
|
}
|
|
4675
4672
|
};
|
|
@@ -4687,10 +4684,11 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4687
4684
|
}
|
|
4688
4685
|
};
|
|
4689
4686
|
const onValidationAsyncChange = (parameters) => {
|
|
4690
|
-
onChange(
|
|
4687
|
+
onChange({
|
|
4688
|
+
...parameters,
|
|
4691
4689
|
triggerSchema: schema,
|
|
4692
4690
|
triggerModel: parameters.model
|
|
4693
|
-
})
|
|
4691
|
+
});
|
|
4694
4692
|
setValidationAsyncErrors(null);
|
|
4695
4693
|
setValidationAsyncSuccessMessage(null);
|
|
4696
4694
|
setValidationAsyncModel(parameters.model);
|
|
@@ -4705,7 +4703,7 @@ var ValidationAsyncSchema = (props) => {
|
|
|
4705
4703
|
required,
|
|
4706
4704
|
schema
|
|
4707
4705
|
};
|
|
4708
|
-
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default,
|
|
4706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(BasicTypeSchema_default, { ...basicTypeSchemaProps });
|
|
4709
4707
|
};
|
|
4710
4708
|
ValidationAsyncSchema.defaultProps = { required: false };
|
|
4711
4709
|
var ValidationAsyncSchema_default = ValidationAsyncSchema;
|
|
@@ -4715,7 +4713,7 @@ var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
|
4715
4713
|
var import_react22 = require("react");
|
|
4716
4714
|
var GenericSchemaForm = (props) => {
|
|
4717
4715
|
const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
|
|
4718
|
-
const schemaProps =
|
|
4716
|
+
const schemaProps = { ...props, model, errors, hideTitle, disabled };
|
|
4719
4717
|
const type = getSchemaType(schema);
|
|
4720
4718
|
const log = useLogger();
|
|
4721
4719
|
(0, import_react21.useEffect)(() => {
|
|
@@ -4728,25 +4726,25 @@ var GenericSchemaForm = (props) => {
|
|
|
4728
4726
|
}, [JSON.stringify(schema), JSON.stringify(model), JSON.stringify(errors), type, log]);
|
|
4729
4727
|
switch (type) {
|
|
4730
4728
|
case "readOnly":
|
|
4731
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default,
|
|
4729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ReadOnlySchema_default, { ...schemaProps });
|
|
4732
4730
|
case "persistAsync":
|
|
4733
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default,
|
|
4731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PersistAsyncSchema_default, { ...schemaProps });
|
|
4734
4732
|
case "validationAsync":
|
|
4735
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default,
|
|
4733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ValidationAsyncSchema_default, { ...schemaProps });
|
|
4736
4734
|
case "basic": {
|
|
4737
|
-
const basicTypeProps =
|
|
4738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default,
|
|
4735
|
+
const basicTypeProps = { infoMessage: null, ...schemaProps };
|
|
4736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(BasicTypeSchema_default, { ...basicTypeProps });
|
|
4739
4737
|
}
|
|
4740
4738
|
case "object":
|
|
4741
|
-
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default,
|
|
4739
|
+
return /* @__PURE__ */ (0, import_react22.createElement)(ObjectSchema_default, { ...schemaProps, key: JSON.stringify(schema) });
|
|
4742
4740
|
case "array":
|
|
4743
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default,
|
|
4741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ArraySchema_default, { ...schemaProps });
|
|
4744
4742
|
case "promotedOneOf":
|
|
4745
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default,
|
|
4743
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(PromotedOneOfSchema_default, { ...schemaProps });
|
|
4746
4744
|
case "oneOf":
|
|
4747
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default,
|
|
4745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OneOfSchema_default, { ...schemaProps });
|
|
4748
4746
|
case "allOf":
|
|
4749
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default,
|
|
4747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(AllOfSchema_default, { ...schemaProps });
|
|
4750
4748
|
}
|
|
4751
4749
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, {});
|
|
4752
4750
|
};
|
|
@@ -4777,14 +4775,15 @@ var isValidGenericSchema = (schema, model, errors) => {
|
|
|
4777
4775
|
// src/jsonSchemaForm/JsonSchemaForm.tsx
|
|
4778
4776
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
4779
4777
|
var JsonSchemaForm = (props) => {
|
|
4780
|
-
const schemaProps =
|
|
4778
|
+
const schemaProps = {
|
|
4781
4779
|
model: null,
|
|
4782
4780
|
errors: null,
|
|
4783
4781
|
disabled: false,
|
|
4784
|
-
baseUrl: ""
|
|
4785
|
-
|
|
4782
|
+
baseUrl: "",
|
|
4783
|
+
...props
|
|
4784
|
+
};
|
|
4786
4785
|
if (useHasHttpClientProvider() || schemaProps.baseUrl == null) {
|
|
4787
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default,
|
|
4786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, { ...schemaProps });
|
|
4788
4787
|
}
|
|
4789
4788
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4790
4789
|
Providers,
|
|
@@ -4792,17 +4791,17 @@ var JsonSchemaForm = (props) => {
|
|
|
4792
4791
|
baseUrl: schemaProps.baseUrl,
|
|
4793
4792
|
onEvent: schemaProps.onEvent,
|
|
4794
4793
|
onLog: schemaProps.onLog,
|
|
4795
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default,
|
|
4794
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(GenericSchema_default, { ...schemaProps })
|
|
4796
4795
|
}
|
|
4797
4796
|
);
|
|
4798
4797
|
};
|
|
4799
4798
|
var JsonSchemaForm_default = JsonSchemaForm;
|
|
4800
4799
|
var Providers = ({ baseUrl, onEvent, onLog, children }) => {
|
|
4801
|
-
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog
|
|
4800
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(LogProvider, { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm", onLog: onLog ?? noop2, children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
|
|
4802
4801
|
EventsContextProvider,
|
|
4803
4802
|
{
|
|
4804
4803
|
metadata: { flowId: "JsonSchemaForm", stepId: "JsonSchemaForm" },
|
|
4805
|
-
onEvent: onEvent
|
|
4804
|
+
onEvent: onEvent ?? noop2,
|
|
4806
4805
|
children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(HttpClientProviderFromBaseUrl, { baseUrl, children })
|
|
4807
4806
|
}
|
|
4808
4807
|
) });
|
|
@@ -4823,7 +4822,7 @@ var DynamicForm = (props) => {
|
|
|
4823
4822
|
submitted: props.submitted,
|
|
4824
4823
|
errors: props.errors,
|
|
4825
4824
|
onChange: (parameters) => {
|
|
4826
|
-
props.onModelChange(
|
|
4825
|
+
props.onModelChange({ formSchema, ...parameters });
|
|
4827
4826
|
},
|
|
4828
4827
|
onPersistAsync: props.onPersistAsync
|
|
4829
4828
|
}
|
|
@@ -4883,7 +4882,7 @@ var DynamicImage = ({ component: image }) => {
|
|
|
4883
4882
|
if (!imageSource) {
|
|
4884
4883
|
return null;
|
|
4885
4884
|
}
|
|
4886
|
-
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `df-image ${size || "md"}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components18.Image,
|
|
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")}`, ...imageProps }) });
|
|
4887
4886
|
};
|
|
4888
4887
|
var readImageBlobAsDataURL = (imageBlob) => {
|
|
4889
4888
|
return new Promise((resolve, reject) => {
|
|
@@ -4894,9 +4893,8 @@ var readImageBlobAsDataURL = (imageBlob) => {
|
|
|
4894
4893
|
});
|
|
4895
4894
|
};
|
|
4896
4895
|
var getImageSource = async (httpClient, imageUrl) => {
|
|
4897
|
-
var _a;
|
|
4898
4896
|
try {
|
|
4899
|
-
if (isRelativePath(imageUrl) ||
|
|
4897
|
+
if (isRelativePath(imageUrl) || imageUrl?.indexOf(`${window?.location?.origin}/`) === 0) {
|
|
4900
4898
|
return httpClient(imageUrl, {
|
|
4901
4899
|
method: "GET",
|
|
4902
4900
|
headers: { "Content-Type": "image/image" },
|
|
@@ -4909,7 +4907,7 @@ var getImageSource = async (httpClient, imageUrl) => {
|
|
|
4909
4907
|
}).then(readImageBlobAsDataURL).catch(() => imageUrl);
|
|
4910
4908
|
}
|
|
4911
4909
|
return imageUrl;
|
|
4912
|
-
} catch
|
|
4910
|
+
} catch {
|
|
4913
4911
|
return imageUrl;
|
|
4914
4912
|
}
|
|
4915
4913
|
};
|
|
@@ -4981,7 +4979,7 @@ var DynamicLayout = (props) => {
|
|
|
4981
4979
|
onModelChange,
|
|
4982
4980
|
onPersistAsync
|
|
4983
4981
|
},
|
|
4984
|
-
getKey(
|
|
4982
|
+
getKey({ ...component, errors: errors ?? null })
|
|
4985
4983
|
);
|
|
4986
4984
|
case "button":
|
|
4987
4985
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DynamicButton_default, { component, onAction }, getKey(component));
|
|
@@ -5036,12 +5034,14 @@ var DynamicStatusList = ({ component }) => {
|
|
|
5036
5034
|
] });
|
|
5037
5035
|
};
|
|
5038
5036
|
var mapListItemToSummary = ({ title, description, icon, status }) => {
|
|
5039
|
-
const props =
|
|
5037
|
+
const props = {
|
|
5040
5038
|
key: `${title}/${description || ""}`,
|
|
5041
5039
|
title,
|
|
5042
|
-
description
|
|
5043
|
-
|
|
5044
|
-
|
|
5040
|
+
description,
|
|
5041
|
+
...icon?.name ? { icon: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(DynamicIcon_default, { type: icon.name }) } : {},
|
|
5042
|
+
...status ? { status: statusMap[status] } : {}
|
|
5043
|
+
};
|
|
5044
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components20.Summary, { ...props });
|
|
5045
5045
|
};
|
|
5046
5046
|
var statusListMap = {
|
|
5047
5047
|
done: "done",
|
|
@@ -5053,7 +5053,7 @@ var legacyStatusMap = {
|
|
|
5053
5053
|
warning: "pending",
|
|
5054
5054
|
neutral: "notDone"
|
|
5055
5055
|
};
|
|
5056
|
-
var statusMap =
|
|
5056
|
+
var statusMap = { ...statusListMap, ...legacyStatusMap };
|
|
5057
5057
|
var DynamicStatusList_default = DynamicStatusList;
|
|
5058
5058
|
|
|
5059
5059
|
// src/layout/loadingIndicator/DynamicLoadingIndicator.tsx
|
|
@@ -5116,8 +5116,7 @@ var CopyableDynamicParagraph = ({ component }) => {
|
|
|
5116
5116
|
const createSnackbar = useSnackBarIfAvailable();
|
|
5117
5117
|
const { text } = component;
|
|
5118
5118
|
const copy = () => {
|
|
5119
|
-
|
|
5120
|
-
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
5119
|
+
navigator.clipboard?.writeText(text).then(() => createSnackbar({ text: formatMessage(DynamicParagraph_messages_default.copied) })).catch(noop4);
|
|
5121
5120
|
};
|
|
5122
5121
|
const classNames7 = getTextAlignmentAndMargin({ align: component.align }) + " form-control";
|
|
5123
5122
|
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: getTextAlignmentAndMargin(component), children: [
|
|
@@ -5205,10 +5204,18 @@ var import_react26 = require("react");
|
|
|
5205
5204
|
// src/layout/search/SearchInput.tsx
|
|
5206
5205
|
var import_components25 = require("@transferwise/components");
|
|
5207
5206
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
5208
|
-
var SearchInput = ({ title, value, onChange }) => {
|
|
5207
|
+
var SearchInput = ({ title, value, onFocus, onChange }) => {
|
|
5209
5208
|
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("label", { className: "control-label d-inline", children: [
|
|
5210
5209
|
title,
|
|
5211
|
-
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
5210
|
+
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
5211
|
+
import_components25.Input,
|
|
5212
|
+
{
|
|
5213
|
+
type: "text",
|
|
5214
|
+
value,
|
|
5215
|
+
onFocus,
|
|
5216
|
+
onChange: (event) => onChange(event.currentTarget.value)
|
|
5217
|
+
}
|
|
5218
|
+
)
|
|
5212
5219
|
] });
|
|
5213
5220
|
};
|
|
5214
5221
|
|
|
@@ -5282,8 +5289,7 @@ var useSearch = (defaultSearchConfig) => {
|
|
|
5282
5289
|
const httpClient = useHttpClient();
|
|
5283
5290
|
const search = (0, import_react25.useCallback)(
|
|
5284
5291
|
async (query, { url, method, param } = defaultSearchConfig) => {
|
|
5285
|
-
|
|
5286
|
-
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
5292
|
+
abortControllerRef.current?.abort();
|
|
5287
5293
|
if (!query) {
|
|
5288
5294
|
setState({ status: "idle" });
|
|
5289
5295
|
return;
|
|
@@ -5349,18 +5355,27 @@ var DynamicSearch = ({ component, onAction }) => {
|
|
|
5349
5355
|
const [query, setQuery] = (0, import_react26.useState)("");
|
|
5350
5356
|
const { title, margin, url, method, param, emptyMessage } = component;
|
|
5351
5357
|
const { status, results, search } = useSearch({ url, method, param });
|
|
5358
|
+
const onEvent = useEventDispatcher();
|
|
5352
5359
|
const debouncedSearch = (0, import_react26.useMemo)(() => debounce(search, DEBOUNCE_TIME), [search]);
|
|
5360
|
+
const onSearchStart = () => {
|
|
5361
|
+
onEvent("Dynamic Flow - Search Started", {});
|
|
5362
|
+
};
|
|
5353
5363
|
const onChange = (value) => {
|
|
5354
5364
|
setQuery(value);
|
|
5355
5365
|
debouncedSearch(value);
|
|
5356
5366
|
};
|
|
5357
5367
|
const onResultSelected = ({ type, value }) => {
|
|
5358
5368
|
if (type === "action") {
|
|
5369
|
+
onEvent("Dynamic Flow - Search Result Selected", {
|
|
5370
|
+
type: "action",
|
|
5371
|
+
actionId: value.id || value.$id
|
|
5372
|
+
});
|
|
5359
5373
|
onAction(value);
|
|
5360
5374
|
}
|
|
5361
5375
|
if (type === "search") {
|
|
5362
5376
|
setQuery(value.query);
|
|
5363
5377
|
const { url: url2, method: method2, param: param2, query: query2 } = value;
|
|
5378
|
+
onEvent("Dynamic Flow - Search Result Selected", { type: "search" });
|
|
5364
5379
|
void search(query2, { url: url2, method: method2, param: param2 });
|
|
5365
5380
|
}
|
|
5366
5381
|
};
|
|
@@ -5369,7 +5384,7 @@ var DynamicSearch = ({ component, onAction }) => {
|
|
|
5369
5384
|
void search(query);
|
|
5370
5385
|
};
|
|
5371
5386
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: getMargin(margin), children: [
|
|
5372
|
-
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SearchInput, { title, value: query, onChange }),
|
|
5387
|
+
/* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SearchInput, { title, value: query, onChange, onFocus: onSearchStart }),
|
|
5373
5388
|
status === "loading" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(DynamicLoadingIndicator_default, { component: { type: "loading-indicator", size: "sm" } }),
|
|
5374
5389
|
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ErrorResult, { onRetrySearch }),
|
|
5375
5390
|
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(SearchResults, { results, emptyMessage, onSelect: onResultSelected })
|
|
@@ -5384,7 +5399,6 @@ var getDefaultValue = (schema) => {
|
|
|
5384
5399
|
return schema.type === "boolean" && isNullish(schema.default) ? false : schema.default;
|
|
5385
5400
|
};
|
|
5386
5401
|
var BasicTypeSchema = (props) => {
|
|
5387
|
-
var _a, _b, _c;
|
|
5388
5402
|
const onChange = (newModel) => {
|
|
5389
5403
|
setChanged(true);
|
|
5390
5404
|
setModelAndBroadcast(sanitiseModel(newModel), "user");
|
|
@@ -5415,8 +5429,8 @@ var BasicTypeSchema = (props) => {
|
|
|
5415
5429
|
props.onBlur();
|
|
5416
5430
|
}
|
|
5417
5431
|
};
|
|
5418
|
-
const [model, setModel] = (0, import_react27.useState)(
|
|
5419
|
-
const [lastModel, setLastModel] = (0, import_react27.useState)(
|
|
5432
|
+
const [model, setModel] = (0, import_react27.useState)(props.model ?? null);
|
|
5433
|
+
const [lastModel, setLastModel] = (0, import_react27.useState)(props.model ?? null);
|
|
5420
5434
|
const [changed, setChanged] = (0, import_react27.useState)(false);
|
|
5421
5435
|
const [focused, setFocused] = (0, import_react27.useState)(false);
|
|
5422
5436
|
const [blurred, setBlurred] = (0, import_react27.useState)(false);
|
|
@@ -5439,8 +5453,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5439
5453
|
(0, import_react27.useEffect)(refreshValidations, [props.model, props.submitted]);
|
|
5440
5454
|
(0, import_react27.useEffect)(onSchemaChange, [props.schema]);
|
|
5441
5455
|
(0, import_react27.useEffect)(() => {
|
|
5442
|
-
|
|
5443
|
-
const newModel = (_a2 = props.model) != null ? _a2 : null;
|
|
5456
|
+
const newModel = props.model ?? null;
|
|
5444
5457
|
if (newModel !== model) {
|
|
5445
5458
|
setModel(newModel);
|
|
5446
5459
|
}
|
|
@@ -5482,7 +5495,7 @@ var BasicTypeSchema = (props) => {
|
|
|
5482
5495
|
focused,
|
|
5483
5496
|
blurred,
|
|
5484
5497
|
submitted: props.submitted,
|
|
5485
|
-
errors:
|
|
5498
|
+
errors: props.errors ?? null,
|
|
5486
5499
|
schema: props.schema,
|
|
5487
5500
|
validations,
|
|
5488
5501
|
infoMessage: props.infoMessage
|
|
@@ -5504,8 +5517,7 @@ var getIdFromResponse = (idProperty, response) => {
|
|
|
5504
5517
|
return response[idProperty];
|
|
5505
5518
|
};
|
|
5506
5519
|
var getErrorFromResponse = (errorProperty, response) => {
|
|
5507
|
-
|
|
5508
|
-
return (_a = response.validation) == null ? void 0 : _a[errorProperty];
|
|
5520
|
+
return response.validation?.[errorProperty];
|
|
5509
5521
|
};
|
|
5510
5522
|
var controlTypesWithPersistOnChange = /* @__PURE__ */ new Set([
|
|
5511
5523
|
FormControlType.RADIO,
|
|
@@ -5557,14 +5569,14 @@ var PersistAsyncBasicSchema = (props) => {
|
|
|
5557
5569
|
onChange({ model: id, triggerSchema: schema, triggerModel: id });
|
|
5558
5570
|
} else if (isStatus422(response.status)) {
|
|
5559
5571
|
const { validation } = responseBody;
|
|
5560
|
-
const error = isObject(validation) &&
|
|
5572
|
+
const error = isObject(validation) && validation?.[param] || null;
|
|
5561
5573
|
setPersistAsyncError(error);
|
|
5562
5574
|
onChange({ model: null, triggerSchema: schema, triggerModel: null });
|
|
5563
5575
|
} else {
|
|
5564
5576
|
setGenericPersistAsyncError();
|
|
5565
5577
|
}
|
|
5566
5578
|
onEvent("Dynamic Flow - PersistAsync", { status: "success", schemaId: schema.$id });
|
|
5567
|
-
} catch
|
|
5579
|
+
} catch {
|
|
5568
5580
|
onEvent("Dynamic Flow - PersistAsync", { status: "failure", schemaId: schema.$id });
|
|
5569
5581
|
setGenericPersistAsyncError();
|
|
5570
5582
|
}
|
|
@@ -5638,7 +5650,9 @@ var usePersistAsync = (persistAsync) => {
|
|
|
5638
5650
|
const requestBody = isBlob ? wrapInFormData(requestKey, model) : JSON.stringify({ [requestKey]: model });
|
|
5639
5651
|
return {
|
|
5640
5652
|
method: persistAsync.method,
|
|
5641
|
-
headers:
|
|
5653
|
+
headers: {
|
|
5654
|
+
...!isBlob && { "Content-Type": "application/json" }
|
|
5655
|
+
},
|
|
5642
5656
|
body: requestBody,
|
|
5643
5657
|
signal
|
|
5644
5658
|
};
|
|
@@ -5779,7 +5793,7 @@ function useStepPolling(polling, onAction) {
|
|
|
5779
5793
|
}, [polling, httpClient]);
|
|
5780
5794
|
const onPollingResponse = (0, import_react32.useCallback)(
|
|
5781
5795
|
(pollingResponse) => {
|
|
5782
|
-
if (pollingResponse
|
|
5796
|
+
if (pollingResponse?.action) {
|
|
5783
5797
|
onAction(pollingResponse.action);
|
|
5784
5798
|
return false;
|
|
5785
5799
|
}
|
|
@@ -5789,8 +5803,8 @@ function useStepPolling(polling, onAction) {
|
|
|
5789
5803
|
);
|
|
5790
5804
|
usePolling({
|
|
5791
5805
|
asyncFn,
|
|
5792
|
-
interval: 1e3 * (
|
|
5793
|
-
maxAttempts:
|
|
5806
|
+
interval: 1e3 * (polling?.interval || 0),
|
|
5807
|
+
maxAttempts: polling?.maxAttempts || 0,
|
|
5794
5808
|
maxConsecutiveFails: 1,
|
|
5795
5809
|
onPollingResponse,
|
|
5796
5810
|
onFailure: (0, import_react32.useCallback)(() => {
|
|
@@ -5804,7 +5818,6 @@ function useStepPolling(polling, onAction) {
|
|
|
5804
5818
|
// src/step/layoutStep/LayoutStep.tsx
|
|
5805
5819
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
5806
5820
|
var getComponents = (step, options) => {
|
|
5807
|
-
var _a;
|
|
5808
5821
|
if (isEmpty(step)) {
|
|
5809
5822
|
return [];
|
|
5810
5823
|
}
|
|
@@ -5813,7 +5826,7 @@ var getComponents = (step, options) => {
|
|
|
5813
5826
|
layout,
|
|
5814
5827
|
schemas: step.schemas || [],
|
|
5815
5828
|
actions: step.actions || [],
|
|
5816
|
-
model:
|
|
5829
|
+
model: step.model ?? null
|
|
5817
5830
|
});
|
|
5818
5831
|
};
|
|
5819
5832
|
var LayoutStep = (props) => {
|
|
@@ -5845,7 +5858,7 @@ var import_react36 = require("react");
|
|
|
5845
5858
|
|
|
5846
5859
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
5847
5860
|
var import_react35 = require("react");
|
|
5848
|
-
var
|
|
5861
|
+
var import_react_intl28 = require("react-intl");
|
|
5849
5862
|
var import_react_webcam = __toESM(require_react_webcam());
|
|
5850
5863
|
|
|
5851
5864
|
// src/step/cameraStep/cameraCapture/CameraCapture.messages.ts
|
|
@@ -5870,56 +5883,16 @@ var CameraCapture_messages_default = (0, import_react_intl22.defineMessages)({
|
|
|
5870
5883
|
|
|
5871
5884
|
// src/step/cameraStep/cameraCapture/components/index.tsx
|
|
5872
5885
|
var import_components27 = require("@transferwise/components");
|
|
5873
|
-
var import_react_intl25 = require("react-intl");
|
|
5874
|
-
|
|
5875
|
-
// src/step/cameraStep/cameraCapture/components/orientationLock/OrientationLock.tsx
|
|
5876
|
-
var import_react_intl24 = require("react-intl");
|
|
5877
|
-
|
|
5878
|
-
// src/step/cameraStep/cameraCapture/components/orientationLock/OrientationLock.messages.ts
|
|
5879
5886
|
var import_react_intl23 = require("react-intl");
|
|
5880
|
-
var OrientationLock_messages_default = (0, import_react_intl23.defineMessages)({
|
|
5881
|
-
text: {
|
|
5882
|
-
id: "dynamicFlows.CameraCapture.rotatePhone.text",
|
|
5883
|
-
defaultMessage: "Rotate your phone to portrait view to take a photo",
|
|
5884
|
-
description: "Prompt the user to rotate their phone from landscape to portrait mode when attempting to take a photo"
|
|
5885
|
-
},
|
|
5886
|
-
imgAlt: {
|
|
5887
|
-
id: "dynamicFlows.CameraCapture.rotatePhone.imgAlt",
|
|
5888
|
-
defaultMessage: "Rotate your phone icon",
|
|
5889
|
-
description: "Rotate phone icon alt text"
|
|
5890
|
-
}
|
|
5891
|
-
});
|
|
5892
|
-
|
|
5893
|
-
// src/step/cameraStep/cameraCapture/components/orientationLock/OrientationLock.tsx
|
|
5894
5887
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
5895
|
-
var
|
|
5896
|
-
const intl = (0, import_react_intl24.useIntl)();
|
|
5897
|
-
return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "orientation-lock-overlay p-x-3 p-y-3", "data-testid": "orientation-lock", children: [
|
|
5898
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5899
|
-
"img",
|
|
5900
|
-
{
|
|
5901
|
-
className: "m-b-3",
|
|
5902
|
-
src: "https://transferwise.com/public-resources/assets/camera-guidelines/icon-rotate-phone.svg",
|
|
5903
|
-
width: "96",
|
|
5904
|
-
height: "96",
|
|
5905
|
-
alt: intl.formatMessage(OrientationLock_messages_default.imgAlt)
|
|
5906
|
-
}
|
|
5907
|
-
),
|
|
5908
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("p", { className: "text-center m-b-0", children: intl.formatMessage(OrientationLock_messages_default.text) })
|
|
5909
|
-
] });
|
|
5910
|
-
};
|
|
5911
|
-
var OrientationLock_default = OrientationLock;
|
|
5912
|
-
|
|
5913
|
-
// src/step/cameraStep/cameraCapture/components/index.tsx
|
|
5914
|
-
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
5915
|
-
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "bottom-bar", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(CaptureButton, { onClick: onCapture }) });
|
|
5888
|
+
var CaptureBottomBar = ({ onCapture }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "bottom-bar", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(CaptureButton, { onClick: onCapture }) });
|
|
5916
5889
|
var ReviewBottomBar = ({
|
|
5917
5890
|
onSubmit,
|
|
5918
5891
|
onRetry
|
|
5919
5892
|
}) => {
|
|
5920
|
-
const intl = (0,
|
|
5921
|
-
return /* @__PURE__ */ (0,
|
|
5922
|
-
/* @__PURE__ */ (0,
|
|
5893
|
+
const intl = (0, import_react_intl23.useIntl)();
|
|
5894
|
+
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "bottom-bar p-x-2", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)("div", { className: "col-xs-12 col-md-6 col-md-offset-3", children: [
|
|
5895
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5923
5896
|
import_components27.Button,
|
|
5924
5897
|
{
|
|
5925
5898
|
className: "m-b-1",
|
|
@@ -5930,7 +5903,7 @@ var ReviewBottomBar = ({
|
|
|
5930
5903
|
children: intl.formatMessage(CameraCapture_messages_default.reviewSubmit)
|
|
5931
5904
|
}
|
|
5932
5905
|
),
|
|
5933
|
-
/* @__PURE__ */ (0,
|
|
5906
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5934
5907
|
import_components27.Button,
|
|
5935
5908
|
{
|
|
5936
5909
|
className: "m-b-2",
|
|
@@ -5944,14 +5917,14 @@ var ReviewBottomBar = ({
|
|
|
5944
5917
|
)
|
|
5945
5918
|
] }) }) });
|
|
5946
5919
|
};
|
|
5947
|
-
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0,
|
|
5920
|
+
var CaptureButton = ({ onClick }) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
5948
5921
|
"button",
|
|
5949
5922
|
{
|
|
5950
5923
|
type: "button",
|
|
5951
5924
|
className: "camera-capture-btn m-b-2",
|
|
5952
5925
|
"data-testid": "camera-capture-button",
|
|
5953
5926
|
onClick,
|
|
5954
|
-
children: /* @__PURE__ */ (0,
|
|
5927
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "camera-capture-btn-inner" })
|
|
5955
5928
|
}
|
|
5956
5929
|
);
|
|
5957
5930
|
|
|
@@ -5960,17 +5933,16 @@ var import_react33 = require("react");
|
|
|
5960
5933
|
|
|
5961
5934
|
// src/step/cameraStep/cameraCapture/utils/index.ts
|
|
5962
5935
|
var isSelfieCamera = (stream) => {
|
|
5963
|
-
|
|
5964
|
-
const { facingMode } = ((_a = getVideoTrack(stream)) == null ? void 0 : _a.getSettings()) || {};
|
|
5936
|
+
const { facingMode } = getVideoTrack(stream)?.getSettings() || {};
|
|
5965
5937
|
return facingMode === "user" || facingMode === void 0;
|
|
5966
5938
|
};
|
|
5967
|
-
var isMainBackCamera = (deviceInfo) => !!(
|
|
5939
|
+
var isMainBackCamera = (deviceInfo) => !!(deviceInfo?.label || "").match(/camera2? 0/g);
|
|
5968
5940
|
var generateCanvasFromVideo = async (video) => {
|
|
5969
5941
|
const canvas = document.createElement("canvas");
|
|
5970
5942
|
if (video) {
|
|
5971
5943
|
canvas.setAttribute("height", `${video.videoHeight}`);
|
|
5972
5944
|
canvas.setAttribute("width", `${video.videoWidth}`);
|
|
5973
|
-
const context = canvas
|
|
5945
|
+
const context = canvas?.getContext("2d");
|
|
5974
5946
|
if (context) {
|
|
5975
5947
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
5976
5948
|
context.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
@@ -5978,29 +5950,16 @@ var generateCanvasFromVideo = async (video) => {
|
|
|
5978
5950
|
}
|
|
5979
5951
|
return canvas;
|
|
5980
5952
|
};
|
|
5981
|
-
var getAvailableVideoDevices = async () =>
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
);
|
|
5986
|
-
};
|
|
5987
|
-
var getAvailableVideoDeviceLabels = async () => {
|
|
5988
|
-
var _a, _b;
|
|
5989
|
-
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);
|
|
5990
|
-
};
|
|
5953
|
+
var getAvailableVideoDevices = async () => (await navigator?.mediaDevices?.enumerateDevices?.() || []).filter(
|
|
5954
|
+
(deviceInfo) => deviceInfo.kind === "videoinput"
|
|
5955
|
+
);
|
|
5956
|
+
var getAvailableVideoDeviceLabels = async () => (await navigator?.mediaDevices?.enumerateDevices?.() || []).filter((deviceInfo) => deviceInfo.kind === "videoinput").map((deviceInfo) => deviceInfo.label);
|
|
5991
5957
|
var getActiveVideoDeviceLabel = async (videoStream) => {
|
|
5992
|
-
var _a, _b, _c;
|
|
5993
5958
|
const capabilities = getVideoCapabilities(videoStream);
|
|
5994
|
-
return (
|
|
5995
|
-
};
|
|
5996
|
-
var getVideoTrack = (videoStream) => {
|
|
5997
|
-
var _a;
|
|
5998
|
-
return (((_a = videoStream == null ? void 0 : videoStream.getVideoTracks) == null ? void 0 : _a.call(videoStream)) || [])[0];
|
|
5999
|
-
};
|
|
6000
|
-
var getVideoCapabilities = (videoStream) => {
|
|
6001
|
-
var _a, _b;
|
|
6002
|
-
return (_b = (_a = getVideoTrack(videoStream)) == null ? void 0 : _a.getCapabilities) == null ? void 0 : _b.call(_a);
|
|
5959
|
+
return (await navigator?.mediaDevices?.enumerateDevices?.() || []).filter((deviceInfo) => deviceInfo.kind === "videoinput").find((deviceInfo) => deviceInfo.deviceId === capabilities?.deviceId)?.label;
|
|
6003
5960
|
};
|
|
5961
|
+
var getVideoTrack = (videoStream) => (videoStream?.getVideoTracks?.() || [])[0];
|
|
5962
|
+
var getVideoCapabilities = (videoStream) => getVideoTrack(videoStream)?.getCapabilities?.();
|
|
6004
5963
|
|
|
6005
5964
|
// src/step/cameraStep/cameraCapture/hooks/index.ts
|
|
6006
5965
|
var useVideoConstraints = (direction) => {
|
|
@@ -6018,10 +5977,11 @@ var useVideoConstraints = (direction) => {
|
|
|
6018
5977
|
const getVideoConstraints = async (direction2) => {
|
|
6019
5978
|
if (direction2 === "back") {
|
|
6020
5979
|
const mainCamera = (await getAvailableVideoDevices()).find(isMainBackCamera);
|
|
6021
|
-
if (mainCamera
|
|
6022
|
-
return
|
|
5980
|
+
if (mainCamera?.deviceId) {
|
|
5981
|
+
return {
|
|
5982
|
+
...defaultVideoConstraints,
|
|
6023
5983
|
deviceId: { exact: mainCamera.deviceId }
|
|
6024
|
-
}
|
|
5984
|
+
};
|
|
6025
5985
|
}
|
|
6026
5986
|
}
|
|
6027
5987
|
return defaultVideoConstraints;
|
|
@@ -6031,7 +5991,7 @@ var useVideoConstraints = (direction) => {
|
|
|
6031
5991
|
|
|
6032
5992
|
// src/step/cameraStep/cameraCapture/overlay/Overlay.tsx
|
|
6033
5993
|
var import_react34 = require("react");
|
|
6034
|
-
var
|
|
5994
|
+
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
6035
5995
|
var captureButtonHeight = 92;
|
|
6036
5996
|
var reviewButtonsHeight = 120;
|
|
6037
5997
|
var imageHeight = 40;
|
|
@@ -6050,8 +6010,7 @@ var Overlay = ({
|
|
|
6050
6010
|
const svgReference = (0, import_react34.useRef)(null);
|
|
6051
6011
|
(0, import_react34.useEffect)(() => {
|
|
6052
6012
|
const listener = debounce(() => {
|
|
6053
|
-
|
|
6054
|
-
if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
|
|
6013
|
+
if (svgReference.current?.innerHTML) {
|
|
6055
6014
|
const reference = svgReference.current;
|
|
6056
6015
|
reference.innerHTML += "";
|
|
6057
6016
|
}
|
|
@@ -6060,18 +6019,18 @@ var Overlay = ({
|
|
|
6060
6019
|
return () => window.removeEventListener("resize", listener);
|
|
6061
6020
|
});
|
|
6062
6021
|
let helperBoxHeight = (imageUrl ? imageHeight : 0) + (title ? titleHeight : 0) + (instructions ? instructionsHeight : 0);
|
|
6063
|
-
let helperBox = /* @__PURE__ */ (0,
|
|
6064
|
-
imageUrl && /* @__PURE__ */ (0,
|
|
6065
|
-
title && /* @__PURE__ */ (0,
|
|
6066
|
-
instructions && /* @__PURE__ */ (0,
|
|
6022
|
+
let helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
|
|
6023
|
+
imageUrl && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("img", { className: "camera-capture-img", src: imageUrl, alt: "" }),
|
|
6024
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("h4", { className: "camera-capture-title", children: title }),
|
|
6025
|
+
instructions && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("small", { className: "camera-capture-instructions", children: instructions })
|
|
6067
6026
|
] });
|
|
6068
6027
|
const frameBottomMargin = captureButtonHeight + helperBoxHeight;
|
|
6069
6028
|
if (reviewInstructions) {
|
|
6070
6029
|
helperBoxHeight = frameBottomMargin - reviewButtonsHeight;
|
|
6071
|
-
helperBox = /* @__PURE__ */ (0,
|
|
6030
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("small", { className: "camera-capture-instructions", children: reviewInstructions });
|
|
6072
6031
|
const frameWithReviewInstructionsMinBottomMargin = reviewButtonsHeight + reviewInstructionsHeight;
|
|
6073
6032
|
if (frameBottomMargin < frameWithReviewInstructionsMinBottomMargin) {
|
|
6074
|
-
helperBox = /* @__PURE__ */ (0,
|
|
6033
|
+
helperBox = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_jsx_runtime58.Fragment, {});
|
|
6075
6034
|
}
|
|
6076
6035
|
}
|
|
6077
6036
|
const framePosition = {
|
|
@@ -6089,25 +6048,25 @@ var Overlay = ({
|
|
|
6089
6048
|
width: "90%"
|
|
6090
6049
|
}
|
|
6091
6050
|
};
|
|
6092
|
-
return /* @__PURE__ */ (0,
|
|
6093
|
-
/* @__PURE__ */ (0,
|
|
6094
|
-
/* @__PURE__ */ (0,
|
|
6095
|
-
/* @__PURE__ */ (0,
|
|
6051
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
|
|
6052
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("mask", { id: "mask", children: [
|
|
6053
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("rect", { width: "100%", height: "100%", fill: "#fff" }),
|
|
6054
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("image", { href: overlay, ...framePosition })
|
|
6096
6055
|
] }) }),
|
|
6097
|
-
overlay && /* @__PURE__ */ (0,
|
|
6098
|
-
outline && /* @__PURE__ */ (0,
|
|
6099
|
-
/* @__PURE__ */ (0,
|
|
6056
|
+
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, ...framePosition }),
|
|
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", ...helperBoxPosition, children: helperBox }) })
|
|
6100
6059
|
] });
|
|
6101
6060
|
};
|
|
6102
6061
|
var Overlay_default = Overlay;
|
|
6103
6062
|
|
|
6104
6063
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
6105
6064
|
var import_components28 = require("@transferwise/components");
|
|
6106
|
-
var
|
|
6065
|
+
var import_react_intl25 = require("react-intl");
|
|
6107
6066
|
|
|
6108
6067
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.messages.ts
|
|
6109
|
-
var
|
|
6110
|
-
var NoCameraAccess_messages_default = (0,
|
|
6068
|
+
var import_react_intl24 = require("react-intl");
|
|
6069
|
+
var NoCameraAccess_messages_default = (0, import_react_intl24.defineMessages)({
|
|
6111
6070
|
title: {
|
|
6112
6071
|
id: "dynamicFlows.CameraCapture.NoCameraAccess.title",
|
|
6113
6072
|
defaultMessage: "We can't access your camera",
|
|
@@ -6126,23 +6085,23 @@ var NoCameraAccess_messages_default = (0, import_react_intl26.defineMessages)({
|
|
|
6126
6085
|
});
|
|
6127
6086
|
|
|
6128
6087
|
// src/step/cameraStep/cameraCapture/screens/NoCameraAccess/NoCameraAccess.tsx
|
|
6129
|
-
var
|
|
6088
|
+
var import_jsx_runtime59 = require("react/jsx-runtime");
|
|
6130
6089
|
var NoCameraAccess = ({ onAction }) => {
|
|
6131
|
-
const intl = (0,
|
|
6132
|
-
return /* @__PURE__ */ (0,
|
|
6133
|
-
/* @__PURE__ */ (0,
|
|
6134
|
-
/* @__PURE__ */ (0,
|
|
6135
|
-
/* @__PURE__ */ (0,
|
|
6090
|
+
const intl = (0, import_react_intl25.useIntl)();
|
|
6091
|
+
return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { id: "no-camera-access", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "container p-t-5", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)("div", { className: "col-md-6 col-md-offset-3", children: [
|
|
6092
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(NoCameraAccess_messages_default.title) }),
|
|
6093
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(NoCameraAccess_messages_default.paragraph) }),
|
|
6094
|
+
/* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_components28.Button, { block: true, onClick: onAction, children: intl.formatMessage(NoCameraAccess_messages_default.action) })
|
|
6136
6095
|
] }) }) }) });
|
|
6137
6096
|
};
|
|
6138
6097
|
var NoCameraAccess_default = NoCameraAccess;
|
|
6139
6098
|
|
|
6140
6099
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
6141
|
-
var
|
|
6100
|
+
var import_react_intl27 = require("react-intl");
|
|
6142
6101
|
|
|
6143
6102
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.messages.ts
|
|
6144
|
-
var
|
|
6145
|
-
var CameraNotSupported_messages_default = (0,
|
|
6103
|
+
var import_react_intl26 = require("react-intl");
|
|
6104
|
+
var CameraNotSupported_messages_default = (0, import_react_intl26.defineMessages)({
|
|
6146
6105
|
title: {
|
|
6147
6106
|
id: "dynamicFlows.CameraCapture.CameraNotSupported.title",
|
|
6148
6107
|
defaultMessage: "Camera not supported",
|
|
@@ -6156,37 +6115,37 @@ var CameraNotSupported_messages_default = (0, import_react_intl28.defineMessages
|
|
|
6156
6115
|
});
|
|
6157
6116
|
|
|
6158
6117
|
// src/step/cameraStep/cameraCapture/screens/CameraNotSupported/CameraNotSupported.tsx
|
|
6159
|
-
var
|
|
6118
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
6160
6119
|
var CameraNotSupported = () => {
|
|
6161
|
-
const intl = (0,
|
|
6162
|
-
return /* @__PURE__ */ (0,
|
|
6163
|
-
/* @__PURE__ */ (0,
|
|
6164
|
-
/* @__PURE__ */ (0,
|
|
6120
|
+
const intl = (0, import_react_intl27.useIntl)();
|
|
6121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { id: "camera-not-supported", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "container p-t-5", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "row", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "col-md-6 col-md-offset-3", children: [
|
|
6122
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("h2", { className: "text-xs-center m-b-3", children: intl.formatMessage(CameraNotSupported_messages_default.title) }),
|
|
6123
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { className: "text-xs-center m-b-5", children: intl.formatMessage(CameraNotSupported_messages_default.paragraph) })
|
|
6165
6124
|
] }) }) }) });
|
|
6166
6125
|
};
|
|
6167
6126
|
var CameraNotSupported_default = CameraNotSupported;
|
|
6168
6127
|
|
|
6169
6128
|
// src/step/cameraStep/cameraCapture/tracking/index.ts
|
|
6170
|
-
var trackCameraPermissionDenied = (onEvent) => onEvent
|
|
6171
|
-
var trackCameraFeedStarted = async (onEvent, props, stream) => onEvent
|
|
6172
|
-
var trackCameraNotSupported = (onEvent, error) => onEvent
|
|
6129
|
+
var trackCameraPermissionDenied = (onEvent) => onEvent?.("Dynamic Flow - Camera Permission Denied", {});
|
|
6130
|
+
var trackCameraFeedStarted = async (onEvent, props, stream) => onEvent?.("Dynamic Flow - Camera Feed Started", await getCameraStartedProperties(props, stream));
|
|
6131
|
+
var trackCameraNotSupported = (onEvent, error) => onEvent?.("Dynamic Flow - Camera Not Supported", { Error: error });
|
|
6173
6132
|
var getCameraStartedProperties = async (props, videoStream) => {
|
|
6174
|
-
var _a;
|
|
6175
6133
|
const videoTrack = getVideoTrack(videoStream);
|
|
6176
6134
|
const capabilities = getVideoCapabilities(videoStream);
|
|
6177
|
-
const settings =
|
|
6178
|
-
return
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6135
|
+
const settings = videoTrack?.getSettings?.();
|
|
6136
|
+
return {
|
|
6137
|
+
...videoTrack && {
|
|
6138
|
+
"Available Video Devices (by label)": await getAvailableVideoDeviceLabels(),
|
|
6139
|
+
"Active Video Device (by label)": await getActiveVideoDeviceLabel(videoStream),
|
|
6140
|
+
"Camera Capabilities": capabilities,
|
|
6141
|
+
"Camera Settings": settings
|
|
6142
|
+
},
|
|
6143
|
+
"Camera Direction (Asked)": props?.direction
|
|
6144
|
+
};
|
|
6186
6145
|
};
|
|
6187
6146
|
|
|
6188
6147
|
// src/step/cameraStep/cameraCapture/CameraCapture.tsx
|
|
6189
|
-
var
|
|
6148
|
+
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
6190
6149
|
var CameraCapture = ({
|
|
6191
6150
|
direction = "back",
|
|
6192
6151
|
overlay = "",
|
|
@@ -6202,16 +6161,14 @@ var CameraCapture = ({
|
|
|
6202
6161
|
const [isVideoMirrored, setIsVideoMirrored] = (0, import_react35.useState)(false);
|
|
6203
6162
|
const [ready, setReady] = (0, import_react35.useState)(false);
|
|
6204
6163
|
const [reviewImage, setReviewImage] = (0, import_react35.useState)();
|
|
6205
|
-
const isMobileDevice = (0, import_react35.useMemo)(() => isMobile(), []);
|
|
6206
6164
|
const webcamReference = (0, import_react35.useRef)(null);
|
|
6207
6165
|
const { videoConstraints } = useVideoConstraints(direction);
|
|
6208
|
-
const intl = (0,
|
|
6166
|
+
const intl = (0, import_react_intl28.useIntl)();
|
|
6209
6167
|
const handleCapture = (0, import_react35.useCallback)(async () => {
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
canvas == null ? void 0 : canvas.toBlob(
|
|
6168
|
+
if (webcamReference?.current?.video && webcamReference?.current?.video?.readyState >= 3) {
|
|
6169
|
+
webcamReference?.current?.video?.pause();
|
|
6170
|
+
const canvas = await generateCanvasFromVideo(webcamReference?.current?.video);
|
|
6171
|
+
canvas?.toBlob(
|
|
6215
6172
|
(blob) => {
|
|
6216
6173
|
if (blob) {
|
|
6217
6174
|
if (showReview) {
|
|
@@ -6230,7 +6187,7 @@ var CameraCapture = ({
|
|
|
6230
6187
|
}, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
|
|
6231
6188
|
const handleUserMediaError = (0, import_react35.useCallback)(
|
|
6232
6189
|
(error) => {
|
|
6233
|
-
if (error instanceof DOMException &&
|
|
6190
|
+
if (error instanceof DOMException && error?.name === "NotAllowedError") {
|
|
6234
6191
|
setMode("NO_CAMERA_ACCESS");
|
|
6235
6192
|
trackCameraPermissionDenied(onEvent);
|
|
6236
6193
|
return;
|
|
@@ -6249,27 +6206,15 @@ var CameraCapture = ({
|
|
|
6249
6206
|
[setIsVideoMirrored, onEvent, direction]
|
|
6250
6207
|
);
|
|
6251
6208
|
const handleReviewSubmit = () => {
|
|
6252
|
-
onCapture(
|
|
6209
|
+
onCapture(reviewImage?.blob || null);
|
|
6253
6210
|
};
|
|
6254
6211
|
const handleReviewRetry = () => {
|
|
6255
6212
|
setMode("CAPTURE");
|
|
6256
6213
|
setReviewImage(void 0);
|
|
6257
6214
|
};
|
|
6258
6215
|
const handleRetryCameraAccess = () => setMode("CAPTURE");
|
|
6259
|
-
(0,
|
|
6260
|
-
|
|
6261
|
-
window.screen.orientation.lock("portrait").catch(() => {
|
|
6262
|
-
});
|
|
6263
|
-
}
|
|
6264
|
-
return () => {
|
|
6265
|
-
var _a, _b;
|
|
6266
|
-
if ((_b = (_a = window.screen) == null ? void 0 : _a.orientation) == null ? void 0 : _b.unlock) {
|
|
6267
|
-
window.screen.orientation.unlock();
|
|
6268
|
-
}
|
|
6269
|
-
};
|
|
6270
|
-
}, [mode, isMobileDevice]);
|
|
6271
|
-
const captureScreen = /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
|
|
6272
|
-
videoConstraints && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
6216
|
+
const captureScreen = /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
|
|
6217
|
+
videoConstraints && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
6273
6218
|
import_react_webcam.default,
|
|
6274
6219
|
{
|
|
6275
6220
|
ref: webcamReference,
|
|
@@ -6280,7 +6225,7 @@ var CameraCapture = ({
|
|
|
6280
6225
|
onUserMedia: handleUserMedia
|
|
6281
6226
|
}
|
|
6282
6227
|
),
|
|
6283
|
-
/* @__PURE__ */ (0,
|
|
6228
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
6284
6229
|
Overlay_default,
|
|
6285
6230
|
{
|
|
6286
6231
|
overlay,
|
|
@@ -6290,12 +6235,11 @@ var CameraCapture = ({
|
|
|
6290
6235
|
instructions
|
|
6291
6236
|
}
|
|
6292
6237
|
),
|
|
6293
|
-
|
|
6294
|
-
ready && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
6238
|
+
ready && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CaptureBottomBar, { onCapture: () => void handleCapture() })
|
|
6295
6239
|
] });
|
|
6296
|
-
const reviewScreen = /* @__PURE__ */ (0,
|
|
6297
|
-
/* @__PURE__ */ (0,
|
|
6298
|
-
/* @__PURE__ */ (0,
|
|
6240
|
+
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?.source, alt: "" }),
|
|
6242
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
|
|
6299
6243
|
Overlay_default,
|
|
6300
6244
|
{
|
|
6301
6245
|
overlay,
|
|
@@ -6305,19 +6249,19 @@ var CameraCapture = ({
|
|
|
6305
6249
|
reviewInstructions: intl.formatMessage(CameraCapture_messages_default.reviewInstructions)
|
|
6306
6250
|
}
|
|
6307
6251
|
),
|
|
6308
|
-
/* @__PURE__ */ (0,
|
|
6252
|
+
/* @__PURE__ */ (0, import_jsx_runtime61.jsx)(ReviewBottomBar, { onSubmit: handleReviewSubmit, onRetry: handleReviewRetry })
|
|
6309
6253
|
] });
|
|
6310
|
-
return /* @__PURE__ */ (0,
|
|
6254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)("section", { className: "camera-capture", children: [
|
|
6311
6255
|
mode === "CAPTURE" && captureScreen,
|
|
6312
6256
|
mode === "REVIEW" && reviewScreen,
|
|
6313
|
-
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0,
|
|
6314
|
-
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0,
|
|
6257
|
+
mode === "NO_CAMERA_ACCESS" && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(NoCameraAccess_default, { onAction: handleRetryCameraAccess }),
|
|
6258
|
+
mode === "CAMERA_NOT_SUPPORTED" && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(CameraNotSupported_default, {})
|
|
6315
6259
|
] });
|
|
6316
6260
|
};
|
|
6317
6261
|
var CameraCapture_default = CameraCapture;
|
|
6318
6262
|
|
|
6319
6263
|
// src/step/cameraStep/CameraStep.tsx
|
|
6320
|
-
var
|
|
6264
|
+
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
6321
6265
|
function blobToBase64(blob) {
|
|
6322
6266
|
return new Promise((resolve, _) => {
|
|
6323
6267
|
const reader = new FileReader();
|
|
@@ -6355,7 +6299,7 @@ var CameraStep = (props) => {
|
|
|
6355
6299
|
});
|
|
6356
6300
|
}
|
|
6357
6301
|
};
|
|
6358
|
-
return /* @__PURE__ */ (0,
|
|
6302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
|
|
6359
6303
|
CameraCapture_default,
|
|
6360
6304
|
{
|
|
6361
6305
|
overlay,
|
|
@@ -6393,22 +6337,21 @@ function getCameraSchema(step) {
|
|
|
6393
6337
|
return firstProperty;
|
|
6394
6338
|
}
|
|
6395
6339
|
function getFirstAction(step) {
|
|
6396
|
-
|
|
6397
|
-
if (!step.schemas || ((_a = filterHiddenSchemas(step.schemas)) == null ? void 0 : _a.length) !== 1) {
|
|
6340
|
+
if (!step.schemas || filterHiddenSchemas(step.schemas)?.length !== 1) {
|
|
6398
6341
|
throw new Error("camera step expects 1 non-hidden object schema");
|
|
6399
6342
|
}
|
|
6400
|
-
if (
|
|
6343
|
+
if (step?.actions?.length !== 1) {
|
|
6401
6344
|
throw new Error("camera step expects 1 action");
|
|
6402
6345
|
}
|
|
6403
6346
|
return step.actions[0];
|
|
6404
6347
|
}
|
|
6405
6348
|
|
|
6406
6349
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
6407
|
-
var
|
|
6350
|
+
var import_react_intl30 = require("react-intl");
|
|
6408
6351
|
|
|
6409
6352
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.messages.ts
|
|
6410
|
-
var
|
|
6411
|
-
var ExternalConfirmationStep_messages_default = (0,
|
|
6353
|
+
var import_react_intl29 = require("react-intl");
|
|
6354
|
+
var ExternalConfirmationStep_messages_default = (0, import_react_intl29.defineMessages)({
|
|
6412
6355
|
title: {
|
|
6413
6356
|
id: "dynamicFlows.ExternalConfirmation.title",
|
|
6414
6357
|
defaultMessage: "Please confirm",
|
|
@@ -6432,12 +6375,12 @@ var ExternalConfirmationStep_messages_default = (0, import_react_intl31.defineMe
|
|
|
6432
6375
|
});
|
|
6433
6376
|
|
|
6434
6377
|
// src/step/externalConfirmationStep/ExternalConfirmationStep.tsx
|
|
6435
|
-
var
|
|
6378
|
+
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
6436
6379
|
var noop5 = () => {
|
|
6437
6380
|
};
|
|
6438
6381
|
var ExternalConfirmationStep = ({ url, onClose }) => {
|
|
6439
|
-
const { formatMessage } = (0,
|
|
6440
|
-
return /* @__PURE__ */ (0,
|
|
6382
|
+
const { formatMessage } = (0, import_react_intl30.useIntl)();
|
|
6383
|
+
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
6441
6384
|
DynamicLayout_default,
|
|
6442
6385
|
{
|
|
6443
6386
|
components: [
|
|
@@ -6496,7 +6439,7 @@ var ExternalConfirmationStep_default = ExternalConfirmationStep;
|
|
|
6496
6439
|
function getOrigin(url) {
|
|
6497
6440
|
try {
|
|
6498
6441
|
return new URL(url).origin;
|
|
6499
|
-
} catch
|
|
6442
|
+
} catch {
|
|
6500
6443
|
return url;
|
|
6501
6444
|
}
|
|
6502
6445
|
}
|
|
@@ -6504,21 +6447,21 @@ function getOrigin(url) {
|
|
|
6504
6447
|
// src/dynamicFlow/BackButton.tsx
|
|
6505
6448
|
var import_components30 = require("@transferwise/components");
|
|
6506
6449
|
var import_icons2 = require("@transferwise/icons");
|
|
6507
|
-
var
|
|
6450
|
+
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
6508
6451
|
var BackButton = ({ title, action, onAction }) => {
|
|
6509
|
-
return /* @__PURE__ */ (0,
|
|
6452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(
|
|
6510
6453
|
"a",
|
|
6511
6454
|
{
|
|
6512
6455
|
onClick: (event) => {
|
|
6513
6456
|
event.preventDefault();
|
|
6514
|
-
onAction(
|
|
6457
|
+
onAction({ ...action, skipValidation: true });
|
|
6515
6458
|
},
|
|
6516
6459
|
href: "/",
|
|
6517
6460
|
className: "df-back-btn",
|
|
6518
6461
|
"aria-label": title,
|
|
6519
6462
|
children: [
|
|
6520
|
-
/* @__PURE__ */ (0,
|
|
6521
|
-
/* @__PURE__ */ (0,
|
|
6463
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)("span", { className: "sr-only", children: title }),
|
|
6464
|
+
/* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_components30.Avatar, { type: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_icons2.ArrowLeft, { size: "24" }) })
|
|
6522
6465
|
]
|
|
6523
6466
|
}
|
|
6524
6467
|
);
|
|
@@ -6526,26 +6469,25 @@ var BackButton = ({ title, action, onAction }) => {
|
|
|
6526
6469
|
var BackButton_default = BackButton;
|
|
6527
6470
|
|
|
6528
6471
|
// src/dynamicFlow/DynamicFlowStep.tsx
|
|
6529
|
-
var
|
|
6472
|
+
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
6530
6473
|
var DynamicFlowStep = (props) => {
|
|
6531
|
-
var _a, _b, _c;
|
|
6532
6474
|
const { step, globalError, onAction } = props;
|
|
6533
|
-
const externalUrl =
|
|
6534
|
-
const backButton =
|
|
6475
|
+
const externalUrl = step?.external?.url;
|
|
6476
|
+
const backButton = step?.navigation?.back || step?.navigation?.backButton;
|
|
6535
6477
|
const { requiresManualTrigger, dismissConfirmation } = useExternal(externalUrl);
|
|
6536
6478
|
if (step === void 0) {
|
|
6537
6479
|
return null;
|
|
6538
6480
|
}
|
|
6539
6481
|
if (externalUrl && requiresManualTrigger) {
|
|
6540
|
-
return /* @__PURE__ */ (0,
|
|
6482
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(ExternalConfirmationStep_default, { url: externalUrl, onClose: dismissConfirmation });
|
|
6541
6483
|
}
|
|
6542
6484
|
if (isCameraStep(step)) {
|
|
6543
|
-
return /* @__PURE__ */ (0,
|
|
6485
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(CameraStep_default, { ...props, step });
|
|
6544
6486
|
}
|
|
6545
|
-
return /* @__PURE__ */ (0,
|
|
6546
|
-
backButton && /* @__PURE__ */ (0,
|
|
6547
|
-
globalError ? /* @__PURE__ */ (0,
|
|
6548
|
-
/* @__PURE__ */ (0,
|
|
6487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
|
|
6488
|
+
backButton && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BackButton_default, { ...backButton, onAction }),
|
|
6489
|
+
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, { ...props, stepSpecification: step })
|
|
6549
6491
|
] });
|
|
6550
6492
|
};
|
|
6551
6493
|
|
|
@@ -6578,30 +6520,29 @@ var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && sche
|
|
|
6578
6520
|
// src/dynamicFlow/utils/useDynamicFlowState.ts
|
|
6579
6521
|
var import_react38 = require("react");
|
|
6580
6522
|
var useDynamicFlowState = (initialStep) => {
|
|
6581
|
-
|
|
6582
|
-
const [
|
|
6583
|
-
const [globalError, setGlobalError] = (0, import_react38.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
|
|
6523
|
+
const [formErrors, setFormErrors] = (0, import_react38.useState)(initialStep?.errors?.validation);
|
|
6524
|
+
const [globalError, setGlobalError] = (0, import_react38.useState)(initialStep?.errors?.error);
|
|
6584
6525
|
const [stepAndModels, setStepAndModels] = (0, import_react38.useState)({
|
|
6585
6526
|
step: initialStep || void 0,
|
|
6586
|
-
models:
|
|
6527
|
+
models: initialStep?.model ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
|
|
6587
6528
|
etag: void 0
|
|
6588
6529
|
});
|
|
6589
6530
|
const { step, models, etag } = stepAndModels;
|
|
6590
6531
|
const setStepAndEtag = (step2, etag2) => {
|
|
6591
|
-
var _a2, _b2, _c, _d;
|
|
6592
6532
|
setStepAndModels((previous) => ({
|
|
6593
6533
|
step: step2,
|
|
6594
6534
|
models: step2.model ? buildInitialModels(step2.model, getAllSchemas(step2)) : previous.models,
|
|
6595
6535
|
etag: etag2
|
|
6596
6536
|
}));
|
|
6597
|
-
setFormErrors(
|
|
6598
|
-
setGlobalError(
|
|
6537
|
+
setFormErrors(step2?.errors?.validation ?? null);
|
|
6538
|
+
setGlobalError(step2?.errors?.error ?? null);
|
|
6599
6539
|
};
|
|
6600
6540
|
const setSchemaModel = (schemaId, objectModel, onModelsUpdated) => {
|
|
6601
6541
|
setStepAndModels((previous) => {
|
|
6602
|
-
const updatedModels =
|
|
6542
|
+
const updatedModels = {
|
|
6543
|
+
...previous.models,
|
|
6603
6544
|
[schemaId]: objectModel
|
|
6604
|
-
}
|
|
6545
|
+
};
|
|
6605
6546
|
const updatedState = {
|
|
6606
6547
|
step: previous.step,
|
|
6607
6548
|
models: updatedModels,
|
|
@@ -6633,14 +6574,15 @@ var buildInitialModels = (model, schemas = []) => {
|
|
|
6633
6574
|
if (!schema.$id) {
|
|
6634
6575
|
console.warn("Schema without $id property found.");
|
|
6635
6576
|
}
|
|
6636
|
-
return
|
|
6577
|
+
return {
|
|
6578
|
+
...acc,
|
|
6637
6579
|
[schema.$id || ""]: getValidObjectModelParts(model, schema) || {}
|
|
6638
|
-
}
|
|
6580
|
+
};
|
|
6639
6581
|
}, {});
|
|
6640
6582
|
};
|
|
6641
6583
|
var getAllSchemas = (step) => [
|
|
6642
|
-
...getAllSchemasInLayout(
|
|
6643
|
-
...
|
|
6584
|
+
...getAllSchemasInLayout(step?.layout || []),
|
|
6585
|
+
...step?.schemas || []
|
|
6644
6586
|
];
|
|
6645
6587
|
var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
6646
6588
|
switch (component.type) {
|
|
@@ -6655,8 +6597,8 @@ var getAllSchemasInLayout = (components) => components.flatMap((component) => {
|
|
|
6655
6597
|
}
|
|
6656
6598
|
});
|
|
6657
6599
|
var getAllValidatableSchemas = (step) => [
|
|
6658
|
-
...getAllReferencedSchemaIds(
|
|
6659
|
-
...getAllSchemasInLayout(
|
|
6600
|
+
...getAllReferencedSchemaIds(step?.layout || []).map((id) => (step?.schemas || []).find((schema) => schema.$id === id)).filter(Boolean),
|
|
6601
|
+
...getAllSchemasInLayout(step?.layout || [])
|
|
6660
6602
|
];
|
|
6661
6603
|
var getAllReferencedSchemaIds = (components) => components.flatMap((component) => {
|
|
6662
6604
|
switch (component.type) {
|
|
@@ -6671,12 +6613,12 @@ var getAllReferencedSchemaIds = (components) => components.flatMap((component) =
|
|
|
6671
6613
|
}
|
|
6672
6614
|
}).filter(Boolean);
|
|
6673
6615
|
var areModelsValid = (formModels, schemas = []) => {
|
|
6674
|
-
return !
|
|
6616
|
+
return !schemas?.some((schema) => {
|
|
6675
6617
|
if (!schema.$id) {
|
|
6676
6618
|
console.warn("Schema without $id property found.");
|
|
6677
6619
|
}
|
|
6678
6620
|
return !isValidSchema(formModels[schema.$id || ""] || {}, schema);
|
|
6679
|
-
})
|
|
6621
|
+
});
|
|
6680
6622
|
};
|
|
6681
6623
|
var getSchemaReference = (component) => {
|
|
6682
6624
|
if (component.schema && !isInlineSchema(component.schema)) {
|
|
@@ -6691,16 +6633,17 @@ var isInlineSchema = (schema) => {
|
|
|
6691
6633
|
// src/dynamicFlow/utils/useLoader.tsx
|
|
6692
6634
|
var import_components31 = require("@transferwise/components");
|
|
6693
6635
|
var import_react39 = require("react");
|
|
6694
|
-
var
|
|
6636
|
+
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
6695
6637
|
function useLoader(loaderConfig, initialState) {
|
|
6696
|
-
const config =
|
|
6638
|
+
const config = {
|
|
6697
6639
|
size: import_components31.Size.EXTRA_LARGE,
|
|
6698
6640
|
initial: true,
|
|
6699
|
-
submission: false
|
|
6700
|
-
|
|
6641
|
+
submission: false,
|
|
6642
|
+
...loaderConfig
|
|
6643
|
+
};
|
|
6701
6644
|
const [loadingState, setLoadingState] = (0, import_react39.useState)(initialState);
|
|
6702
6645
|
const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
|
|
6703
|
-
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0,
|
|
6646
|
+
const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
6704
6647
|
import_components31.Loader,
|
|
6705
6648
|
{
|
|
6706
6649
|
size: config.size,
|
|
@@ -6716,11 +6659,11 @@ var import_react40 = require("react");
|
|
|
6716
6659
|
|
|
6717
6660
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundaryAlert.tsx
|
|
6718
6661
|
var import_components32 = require("@transferwise/components");
|
|
6719
|
-
var
|
|
6720
|
-
var
|
|
6662
|
+
var import_react_intl31 = require("react-intl");
|
|
6663
|
+
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
6721
6664
|
var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
6722
|
-
const { formatMessage } = (0,
|
|
6723
|
-
return /* @__PURE__ */ (0,
|
|
6665
|
+
const { formatMessage } = (0, import_react_intl31.useIntl)();
|
|
6666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
|
|
6724
6667
|
import_components32.Alert,
|
|
6725
6668
|
{
|
|
6726
6669
|
action: {
|
|
@@ -6736,7 +6679,7 @@ var ErrorBoundaryAlert = ({ onDismiss }) => {
|
|
|
6736
6679
|
};
|
|
6737
6680
|
|
|
6738
6681
|
// src/dynamicFlow/utils/errorBoundary/ErrorBoundary.tsx
|
|
6739
|
-
var
|
|
6682
|
+
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
6740
6683
|
var noop6 = () => {
|
|
6741
6684
|
};
|
|
6742
6685
|
var ErrorBoundary = class extends import_react40.Component {
|
|
@@ -6757,8 +6700,8 @@ var ErrorBoundary = class extends import_react40.Component {
|
|
|
6757
6700
|
render() {
|
|
6758
6701
|
const { children } = this.props;
|
|
6759
6702
|
const { hasError, isFatalError } = this.state;
|
|
6760
|
-
return /* @__PURE__ */ (0,
|
|
6761
|
-
hasError && /* @__PURE__ */ (0,
|
|
6703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime68.jsxs)(import_jsx_runtime68.Fragment, { children: [
|
|
6704
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(ErrorBoundaryAlert, { onDismiss: this.handleErrorReset }),
|
|
6762
6705
|
!isFatalError && children
|
|
6763
6706
|
] });
|
|
6764
6707
|
}
|
|
@@ -6808,17 +6751,16 @@ var parseExitResponse = async (response) => {
|
|
|
6808
6751
|
return { type: "exit", result: await getJsonObjectOrNull(response) };
|
|
6809
6752
|
};
|
|
6810
6753
|
var parseFetchResponse = async (response) => {
|
|
6811
|
-
var _a, _b, _c;
|
|
6812
6754
|
assertResponseIsValid(response);
|
|
6813
|
-
if (
|
|
6755
|
+
if (response.headers?.has("X-Df-Response-Type")) {
|
|
6814
6756
|
const type = response.headers.get("X-Df-Response-Type");
|
|
6815
6757
|
return parseFetchResponseByResponseType(response, type);
|
|
6816
6758
|
}
|
|
6817
|
-
if (
|
|
6759
|
+
if (response.headers?.has("X-Df-ResponseType")) {
|
|
6818
6760
|
const type = response.headers.get("X-Df-ResponseType");
|
|
6819
6761
|
return parseFetchResponseByResponseType(response, type);
|
|
6820
6762
|
}
|
|
6821
|
-
if (
|
|
6763
|
+
if (response.headers?.has("X-Df-Exit")) {
|
|
6822
6764
|
return parseExitResponse(response);
|
|
6823
6765
|
}
|
|
6824
6766
|
const jsonBody = await parseResponseJson(response.clone());
|
|
@@ -6846,7 +6788,7 @@ var getJsonObjectOrNull = async (response) => {
|
|
|
6846
6788
|
var parseResponseJson = async (response) => {
|
|
6847
6789
|
try {
|
|
6848
6790
|
return await response.json();
|
|
6849
|
-
} catch
|
|
6791
|
+
} catch {
|
|
6850
6792
|
return null;
|
|
6851
6793
|
}
|
|
6852
6794
|
};
|
|
@@ -6863,7 +6805,7 @@ var assertResponseIsValid = (response) => {
|
|
|
6863
6805
|
var isResponse = (response) => typeof response === "object" && response !== null && "clone" in response && "bodyUsed" in response;
|
|
6864
6806
|
|
|
6865
6807
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
6866
|
-
var
|
|
6808
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
6867
6809
|
var noop7 = () => {
|
|
6868
6810
|
};
|
|
6869
6811
|
var DynamicFlowComponent = ({
|
|
@@ -6878,7 +6820,7 @@ var DynamicFlowComponent = ({
|
|
|
6878
6820
|
onEvent = noop7,
|
|
6879
6821
|
onLog = noop7
|
|
6880
6822
|
}) => {
|
|
6881
|
-
const { locale } = (0,
|
|
6823
|
+
const { locale } = (0, import_react_intl32.useIntl)();
|
|
6882
6824
|
const {
|
|
6883
6825
|
formErrors,
|
|
6884
6826
|
globalError,
|
|
@@ -6896,12 +6838,9 @@ var DynamicFlowComponent = ({
|
|
|
6896
6838
|
loaderConfig,
|
|
6897
6839
|
initialStep ? "idle" : "initial"
|
|
6898
6840
|
);
|
|
6899
|
-
const logCritical = getLogger("critical", onLog, flowId,
|
|
6841
|
+
const logCritical = getLogger("critical", onLog, flowId, step?.id || step?.key);
|
|
6900
6842
|
const analyticsMetadata = (0, import_react41.useMemo)(
|
|
6901
|
-
() => {
|
|
6902
|
-
var _a;
|
|
6903
|
-
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 : {});
|
|
6904
|
-
},
|
|
6843
|
+
() => ({ flowId, stepId: step?.id || step?.key, ...step?.analytics ?? {} }),
|
|
6905
6844
|
[flowId, step]
|
|
6906
6845
|
);
|
|
6907
6846
|
const dispatchEvent = (0, import_react41.useMemo)(
|
|
@@ -6911,13 +6850,14 @@ var DynamicFlowComponent = ({
|
|
|
6911
6850
|
const dfHttpClient = (0, import_react41.useCallback)(
|
|
6912
6851
|
({ action, data, etag: etag2 }) => {
|
|
6913
6852
|
const { url, method = "POST" } = action;
|
|
6914
|
-
return httpClient(url
|
|
6853
|
+
return httpClient(url ?? "", {
|
|
6915
6854
|
method,
|
|
6916
|
-
headers:
|
|
6855
|
+
headers: {
|
|
6917
6856
|
"accept-language": locale,
|
|
6918
6857
|
// FIXME move this out of the library https://transferwise.atlassian.net/browse/MC-3286
|
|
6919
|
-
"Content-Type": "application/json"
|
|
6920
|
-
|
|
6858
|
+
"Content-Type": "application/json",
|
|
6859
|
+
...etag2 ? { "If-None-Match": etag2 } : {}
|
|
6860
|
+
},
|
|
6921
6861
|
credentials: "include",
|
|
6922
6862
|
body: method === "GET" ? void 0 : JSON.stringify(data)
|
|
6923
6863
|
});
|
|
@@ -6955,7 +6895,7 @@ var DynamicFlowComponent = ({
|
|
|
6955
6895
|
};
|
|
6956
6896
|
const handleExitResponse = async (response, actionResult) => {
|
|
6957
6897
|
const exitResult = await getJsonObjectOrNull(response);
|
|
6958
|
-
dispatchEventAndComplete(
|
|
6898
|
+
dispatchEventAndComplete({ ...exitResult, ...actionResult });
|
|
6959
6899
|
};
|
|
6960
6900
|
const debouncedRefresh = useDebouncedRefresh(performRefresh);
|
|
6961
6901
|
const dispatchEventAndComplete = (0, import_react41.useCallback)(
|
|
@@ -6970,10 +6910,11 @@ var DynamicFlowComponent = ({
|
|
|
6970
6910
|
}, []);
|
|
6971
6911
|
(0, import_react41.useEffect)(() => {
|
|
6972
6912
|
if (!initialStep) {
|
|
6973
|
-
const action =
|
|
6913
|
+
const action = {
|
|
6974
6914
|
id: "#initial-step-request",
|
|
6975
|
-
method: "GET"
|
|
6976
|
-
|
|
6915
|
+
method: "GET",
|
|
6916
|
+
...initialAction
|
|
6917
|
+
};
|
|
6977
6918
|
void performAction(action, action.data);
|
|
6978
6919
|
}
|
|
6979
6920
|
}, [httpClient, locale, JSON.stringify(initialStep), JSON.stringify(initialAction)]);
|
|
@@ -7005,9 +6946,10 @@ var DynamicFlowComponent = ({
|
|
|
7005
6946
|
setLoadingState("idle");
|
|
7006
6947
|
if (fetchType === "submission") {
|
|
7007
6948
|
setSubmitted(false);
|
|
7008
|
-
dispatchEvent("Dynamic Flow - Step Started",
|
|
7009
|
-
stepId: newStep.id || newStep.key
|
|
7010
|
-
|
|
6949
|
+
dispatchEvent("Dynamic Flow - Step Started", {
|
|
6950
|
+
stepId: newStep.id || newStep.key,
|
|
6951
|
+
...newStep?.analytics
|
|
6952
|
+
});
|
|
7011
6953
|
} else {
|
|
7012
6954
|
dispatchEvent("Dynamic Flow - Step Refreshed", { status: "success" });
|
|
7013
6955
|
}
|
|
@@ -7053,7 +6995,7 @@ var DynamicFlowComponent = ({
|
|
|
7053
6995
|
const { triggerSchema } = props;
|
|
7054
6996
|
if (shouldTriggerRefresh(props)) {
|
|
7055
6997
|
const triggerSchemaRefreshUrl = triggerSchema.refreshUrl || triggerSchema.refreshFormUrl;
|
|
7056
|
-
const stepRefreshUrl =
|
|
6998
|
+
const stepRefreshUrl = step?.refreshUrl || step?.refreshFormUrl;
|
|
7057
6999
|
const refreshUrl = triggerSchemaRefreshUrl || stepRefreshUrl;
|
|
7058
7000
|
if (refreshUrl) {
|
|
7059
7001
|
debouncedRefresh(refreshUrl, combineModels2(updatedModels), etag, triggerSchema);
|
|
@@ -7070,7 +7012,7 @@ var DynamicFlowComponent = ({
|
|
|
7070
7012
|
}
|
|
7071
7013
|
const actionHandler = action.exit ? performExitAction : performAction;
|
|
7072
7014
|
const { data, method, skipValidation } = action;
|
|
7073
|
-
const submissionData =
|
|
7015
|
+
const submissionData = { ...combineModels2(models), ...data };
|
|
7074
7016
|
if (isSubmissionMethod(method)) {
|
|
7075
7017
|
setFormErrors(null);
|
|
7076
7018
|
if (!skipValidation) {
|
|
@@ -7083,7 +7025,7 @@ var DynamicFlowComponent = ({
|
|
|
7083
7025
|
await actionHandler(action);
|
|
7084
7026
|
}
|
|
7085
7027
|
};
|
|
7086
|
-
return /* @__PURE__ */ (0,
|
|
7028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(LogProvider, { flowId, stepId: step?.id || 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)(
|
|
7087
7029
|
DynamicFlowStep,
|
|
7088
7030
|
{
|
|
7089
7031
|
step,
|
|
@@ -7099,10 +7041,10 @@ var DynamicFlowComponent = ({
|
|
|
7099
7041
|
}
|
|
7100
7042
|
) }) }) }) });
|
|
7101
7043
|
};
|
|
7102
|
-
var DynamicFlow = (props) => /* @__PURE__ */ (0,
|
|
7044
|
+
var DynamicFlow = (props) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(ErrorBoundary_default, { onError: props.onError, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DynamicFlowComponent, { ...props }) });
|
|
7103
7045
|
var DynamicFlow_default = DynamicFlow;
|
|
7104
7046
|
var combineModels2 = (formModels) => {
|
|
7105
|
-
return Object.values(formModels).reduce((previous, model) =>
|
|
7047
|
+
return Object.values(formModels).reduce((previous, model) => ({ ...previous, ...model }), {});
|
|
7106
7048
|
};
|
|
7107
7049
|
var isSubmissionMethod = (method = "POST") => {
|
|
7108
7050
|
const submissionMethods = ["POST", "PUT", "PATCH"];
|
|
@@ -7112,7 +7054,7 @@ var shouldTriggerRefresh = (props) => {
|
|
|
7112
7054
|
const { type, triggerSchema, triggerModel, lastTriggerModel = null } = props;
|
|
7113
7055
|
const isValid = () => isValidSchema(triggerModel, triggerSchema);
|
|
7114
7056
|
const wasValid = () => isValidSchema(lastTriggerModel, triggerSchema);
|
|
7115
|
-
const hasRefreshOnChange =
|
|
7057
|
+
const hasRefreshOnChange = triggerSchema?.refreshStepOnChange || triggerSchema?.refreshFormOnChange;
|
|
7116
7058
|
return type !== "init" && hasRefreshOnChange && (isValid() || wasValid());
|
|
7117
7059
|
};
|
|
7118
7060
|
|
|
@@ -7176,8 +7118,6 @@ var en_default = {
|
|
|
7176
7118
|
"dynamicFlows.CameraCapture.reviewInstructions": "Is your picture clear, readable and complete?",
|
|
7177
7119
|
"dynamicFlows.CameraCapture.reviewRetry": "No, try again",
|
|
7178
7120
|
"dynamicFlows.CameraCapture.reviewSubmit": "Yes, submit",
|
|
7179
|
-
"dynamicFlows.CameraCapture.rotatePhone.imgAlt": "Rotate your phone icon",
|
|
7180
|
-
"dynamicFlows.CameraCapture.rotatePhone.text": "Rotate your phone to portrait view to take a photo",
|
|
7181
7121
|
"dynamicFlows.ControlFeedback.maxLength": "Please enter {maxLength} or fewer characters.",
|
|
7182
7122
|
"dynamicFlows.ControlFeedback.maximum": "Please enter a number that's {maximum} or less.",
|
|
7183
7123
|
"dynamicFlows.ControlFeedback.maximumDate": "Please enter a date that's on or before {maximum}.",
|